solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
q = int(input()) for i in range(q): l,r,d = [int(i) for i in input().split(' ')] if d < l: print(d) else: print(r+d-(r%d))
7
PYTHON3
import sys q = int(input()) for l, r, d in (map(int, l.split()) for l in sys.stdin): if l > d: print(d) else: ans = ((r+d-1) // d)*d print(ans if ans != r else ans+d)
7
PYTHON3
def min_numb(lst): a = list() for elem in lst: if elem[2] < elem[0] or elem[2] > elem[1]: a.append(elem[2]) else: a.append((elem[1] // elem[2]) * elem[2] + elem[2]) return a q = int(input()) b = list() for i in range(q): l, r, d = [int(j) for j in input().split()] b.append([l, r, d]) for x in min_numb(b): print(x)
7
PYTHON3
for _ in range(int(input())): l,r,d=map(int,input().split()) if d<l or d>r: print(d) else: print(d*(r//d+1))
7
PYTHON3
test_cases = int(input()) while test_cases > 0: l,r,d = map(int,input().split()) if d < l: print(d) else: print(r+(d-r%d)) test_cases -= 1
7
PYTHON3
for x in range(int(input())): l,r,d=map(int,input().split()) if d < l: print(d) continue print(d*(int(r/d)+1))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n; int a, b, c; while (cin >> n) { int cnt; for (int i = 0; i < n; i++) { cin >> a >> b >> c; if (a <= c) { if (b >= c) { cnt = b / c + 1; } else { cnt = 1; } } else { cnt = 1; } cout << cnt * c << endl; } } return 0; }
7
CPP
q = int(input()) for tc in range(q): l,r,d = map(int,input().split()) if d < l or d > r: print( d ) else: print(d*((r)//d+1))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int l, r, d; cin >> l >> r >> d; if (d < l) cout << d << endl; else { if (r % d == 0) cout << (r + d) << endl; else cout << (d - r % d) + r << endl; } } return 0; }
7
CPP
import math for _ in range(int(input())): l,r,d=map(int,input().split()) f=math.ceil(l/d)*d s=math.floor(r/d)*d if l>d: print(d) else: print(s+d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int l, r, d; cin >> l >> r >> d; int x = (l - 1) / d; int y = r / d; if (x == 0) { cout << (y + 1) * d << endl; } else { cout << d << endl; } } }
7
CPP
for _ in[0]*int(input()): l,r,d=map(int,input().split()) print((d>=l)*r//d*d+d)
7
PYTHON3
for _ in range(int(input())): l,r,d = map(int,input().split()) if d >= l: if r%d == 0: print(r+d) else: print(((r//d)+1)*d) else: print(d)
7
PYTHON3
q = int(input()) for i in range(q): l, r, d = map(int, input().split()) if d < l: print(d) else: print(((r // d) + 1) * d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long q, l, r, d; cin >> q; for (long long i = 0; i < q; i += 1) { cin >> l >> r >> d; long long ans1 = d; if (ans1 > 0 && ans1 < l) { cout << ans1 << endl; continue; } long long ans = (r / d) * d; ans += d; cout << ans << endl; } }
7
CPP
#include <bits/stdc++.h> using namespace std; int x, y, a, b, c; int main() { cin >> x; for (int i = 0; i < x; i++) { cin >> a >> b >> c; y = a % c; if (a <= c) { y = b % c; cout << b + c - y; } else { cout << c; } if (i < x - 1) { cout << endl; } } }
7
CPP
n = int(input()) for _ in range(n): l, r, d = map(int, input().split()) flag = False if d < l: print(d) continue if d > r: print(d) continue print(r // d * d + d)
7
PYTHON3
#!/usr/bin/env python3 import sys def rint(): return map(int, sys.stdin.readline().split()) #lines = stdin.readlines() q = int(input()) for i in range(q): l, r, d = rint() if l > d: print(d) else: if r%d == 0: print(r+d) else: print((r//d)*d+d)
7
PYTHON3
from math import * n=int(input()) if(n<=500): for i in range(n): l=[int(i) for i in input().split()] if((l[0]>=1 and l[0]<=pow(10,9)) and (l[1]>=1 and l[1]<=pow(10,9)) and (l[2]>=1 and l[2]<=pow(10,9))): j=1 s=0 while(1): if(l[0]==1): if(l[1]<l[2]): s=l[2] break elif(l[1]%l[2]==0): s=l[1]+l[2] break elif(l[1]%l[2]!=0): k=l[1]%l[2] s=l[1]+l[2]-k break elif(l[0]<=l[2]): if(l[1]<l[2]): s=l[2] break elif(l[1]%l[2]==0): s=l[1]+l[2] break elif(l[1]%l[2]!=0): k=l[1]%l[2] s=l[1]+l[2]-k break else: s=l[2]*j if(l[0]>s or s>l[1]): break j+=1 print(s)
7
PYTHON3
q=int(input()) for j in range(q): l,r,d = map(int,input().split(" ")) if d <l: print(d) else: print(((r//d)+1)*d)
7
PYTHON3
t = int(input()) for _ in range(t): l, r, d = map(int, input().split(' ')) if d < l: print(d) elif d > r: print(d) else: print(((r // d) + 1) * d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int l, r, d; cin >> l >> r >> d; if (d < l) { cout << d << endl; } else { cout << (r / d + 1) * d << endl; } } return 0; }
7
CPP
n=int(input()) for i in range(n): l,r,d=map(lambda x:int(x),input().split()) dl=(l-1)//d dr=r//d+1 print((dl<1 and dr*d or d))
7
PYTHON3
import bisect from sys import stdin q = int(stdin.readline()) for _ in range(q): l, r, d = map(int, stdin.readline().split()) if l <= d: if d > r: print(d) elif d == r: print(2 * d) else: x, y = divmod(r + 1, d) if y == 0: print(r + 1) else: print(d * (x + 1)) else: print(d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long l, r, d; cin >> l >> r >> d; if (l <= d && d <= r) { cout << (r / d + 1) * d << endl; } else if (d > r) cout << d << endl; else if (d < l) cout << d << endl; } }
7
CPP
n_queries = int(input()) for k in range(n_queries): r, l, d = list(map(int, input().split())) if d < r or d > l: print(d) else: print(((l // d)+1)*d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long inf = 0x3f3f3f3f; const long long llinf = 1e18; const long long nax = 0; void solve() { long long l, r, d; cin >> l >> r >> d; if (d < l) { cout << d << '\n'; return; } cout << d * (r / d + 1) << '\n'; } int main() { ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); int t; cin >> t; while (t--) { solve(); } }
7
CPP
n = int(input()) lista = [] for i in range(n): l, r, d = input().split() l, r, d = int(l), int(r), int(d) h = d if(d < l or d > r): lista.append(d) elif(r == d): lista.append(d*2) else: lista.append(((r//d)+1)*d) for i in lista: print(i)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long q; cin >> q; while (q--) { long long l, r, d; cin >> l >> r >> d; if (l > d) { cout << d << endl; } else { long long x = r / d; cout << d * (x + 1) << endl; } } return 0; }
7
CPP
import math q=int(input()) #q=1 for _ in range(q): l,r,d=map(int,input().split()) n=l/d m=r/d if n>1: print(d) else: if (math.ceil(m))==m: print(int((m+1)*d)) else: print(d*(math.ceil(m)))
7
PYTHON3
n=int(input()) for i in range(n): s=input() s=s.strip() y=s.find(" ") l=int(s[:y]) r=int(s[y+1:s.rfind(" ")]) d=int(s[s.rfind(" ")+1:]) if(d<l): print(d) else: x=r//d k=(x+1)*d print(k)
7
PYTHON3
q=int(input()) for i in range(q): l,r,d=list(map(int,input().split())) if(l<=d): print(r-r%d+d) else: print(d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int q, l, r, d; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> q; while (q--) { cin >> l >> r >> d; if (l <= d && d <= r) { cout << (r + 1 + d - 1) / d * d << "\n"; } else { cout << d << "\n"; } } }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, j, l, r, d, x, ans; cin >> n; for (i = 0; i < n; i++) { cin >> l >> r >> d; if (d < l) ans = d; else { ans = r / d; ans *= d; if (ans <= r) ans += d; } cout << ans << endl; } return 0; }
7
CPP
import math for t in range(int(input())): l,r,d = [int(x) for x in input().split(" ")] if(d<l or d>r): print(d) else: if(r%d==0): print(int(((r/d+1)*d))) else: print(int(math.ceil(r/d)*d))
7
PYTHON3
for _ in[0]*int(input()):l,r,v=map(int,input().split());print((v>=l)*r//v*v+v)
7
PYTHON3
from math import ceil for _ in range(int(input())): l,r,d=map(int,input().split()) if d<l: print(d) elif d>r: print(d) else: if r%d==0: print((ceil(r/d)+1)*d) else: print(ceil(r/d)*d)
7
PYTHON3
q = int(input()) while q: [l, r, d] = list(map(int, input().split())) minimum = 0 if d <= l - 1: minimum = d elif d <= r: minimum = (r // d + 1) * d else: minimum = d print(minimum) q -= 1
7
PYTHON3
for i in range (int(input())): l,r,d=map(int,input().split()) if(d<l): print(d) elif(d>r): print(d) else: print(((r//d)+1)*d)
7
PYTHON3
q=int(input()) def f(l,r,d): if d<l or d>r:return d return d*(int(r/d)+1) for k in range(q): l,r,d=map(int,input().split()) print(f(l,r,d))
7
PYTHON3
q=int(input()) for i in range(q): j,w,d=map(int,input().split()) if d<j or d>w: www=d else: www=((w//d)+1)*d print(www)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int test; cin >> test; while (test--) { int l, r, d; cin >> l >> r >> d; int left = l / d; int right = r / d; if (left > 1) cout << d << "\n"; else if (left == 1 && l % d != 0) cout << d << "\n"; else { cout << d * (right + 1) << "\n"; } } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; void solve() { long long int l, r, d; cin >> l >> r >> d; if (d < l) { cout << d; return; } long long int x = r / d; x++; cout << x * d; return; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tc = 1; cin >> tc; while (tc--) { solve(); cout << endl; } return 0; }
7
CPP
for _ in range(int(input())): l,r,d=map(int,input().split()) if(d<l): print(d) else: ans=r//d #print(ans) print(d*(ans+1))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); int q; cin >> q; while (q--) { long long l, r, d; cin >> l >> r >> d; if (d < l || d > r) cout << d << endl; else { long long t = r / d; cout << (t + 1) * d << endl; } } return 0; }
7
CPP
q = int(input()) for i in range(0, q): numList1 = list(map(int, input().split())) l = numList1[0] r = numList1[1] d = numList1[2] if d < l: print(d) else: a = r // d print(d + a * d)
7
PYTHON3
q = int(input()) for i in range(q): s = input().split() l, r, d = int(s[0]), int(s[1]), int(s[2]) if d<l: print(d) continue u = r - (r%d) + d print(u)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int tc; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> tc; while (tc--) { int l, r, x; cin >> l >> r >> x; if (x < l) { cout << x << endl; continue; } else { int res = r / x + 1; cout << res * x << endl; } } }
7
CPP
q = int(input()) for i in range(q): l, r, d = map(int, input().split()) if d < l: print(d) else: print((r+d)//d*d)
7
PYTHON3
q=int(input()) for x in range(q): l,r,d=list(map(int,input().split())) a=l/d b=r/d if a>1: print(d) else: print((int(b)+1)*d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const long long N = 1e9; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long n, c = 0, j, m = 0; cin >> n; for (long long i = 1; i <= n; i++) { long long l, r, d; cin >> l >> r >> d; c = d; m = d; if (d > r || d < l) { cout << d << '\n'; } else { j = r / d; if (r % d != 0) { j++; } c = d * j; if (c == r) { c += d; } cout << c << '\n'; } } return 0; }
7
CPP
nb = int(input()) liste = [] roger = True for loop in range(nb): l,r,d = map(int,input().split()) if d<l or d>r: print(d) else: print(((r//d)+1)*d)
7
PYTHON3
t=int(input()) for i in range(t): l,r,d=map(int,input().split()) if d<l: print(d) else: print((r//d)*d+d)
7
PYTHON3
q = int(input()) for i in range(q): l, r, d = [int(i) for i in input().split()] if l > d or d > r: print(d) else: t = r - d x = d + t // d * d + d print(x)
7
PYTHON3
n=int(input()) for q in range(n): j,k,l=list(map(int,input().split())) if j>l: print(l) else: d=k//l s=l*d # print(d) while s<k: s+=l if s==k: s+=l print(s)
7
PYTHON3
q = int(input()) for _ in range(q): l, r, d = map(int, input().split()) if (d < l or d > r): print(d) else: print((r // d) * d + d)
7
PYTHON3
import sys input=sys.stdin.buffer.readline import os from math import* t=int(input()) while t: t-=1 l,r,d=map(int,input().split()) if d<l: print(d) else: if r%d==0: print(r+d) else: print(r+d-(r%d))
7
PYTHON3
import sys def input(): return sys.stdin.readline().strip() for _ in range(int(input())): l, r, d = map(int, input().split()) print(d if d < l else r - r % d + d)
7
PYTHON3
test = int(input()) for i in range(test): ans = 0 l,r,d = input().split() [l,r,d]=[int(l),int(r),int(d)] if l<=d: if(r%d==0): ans=r+d else: ans=r+d-(r%d) elif l>d: ans =d print(ans)
7
PYTHON3
def ceil(a,b): if a%b: return a//b + 1 else: return a//b n=int(input()) for i in range(n): l,r,d=map(int,input().split()) if l>d: print(d) else: print((r//d + 1)*d)
7
PYTHON3
for _ in range(int(input())): l, r, d = map(int, input().split()) if(d < l or d > r): print(d) else: print((r // d) * d + d)
7
PYTHON3
for _ in range(int(input())): l,r,d=map(int,input().split()) if(l>d): print(d) else: print(((r//d)+1)*d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; template <class T> inline bool read(T &x) { int c = getchar(); int sgn = 1; while (~c && c<'0' | c> '9') { if (c == '-') sgn = -1; c = getchar(); } for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; x *= sgn; return ~c; } template <class T> inline long long gcd(T a, T b) { a = abs(a); b = abs(b); while (b) { a = a % b; swap(a, b); } return a; } template <class T> inline long long ext_gcd(T A, T B, T *X, T *Y) { T x2, y2, x1, y1, x, y, r2, r1, q, r; x2 = 1; y2 = 0; x1 = 0; y1 = 1; for (r2 = A, r1 = B; r1 != 0; r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y) { q = r2 / r1; r = r2 % r1; x = x2 - (q * x1); y = y2 - (q * y1); } *X = x2; *Y = y2; return r2; } template <class T> inline long long modInv(T a, T m) { T x, y; ext_gcd(a, m, &x, &y); x %= m; if (x < 0) x += m; return x; } template <class T> inline long long power(T a, T p) { T res = 1, x = a; while (p) { if (p & 1) res = (res * x); x = (x * x); p >>= 1; } return res; } template <class T> inline long long bigmod(T a, T p, T m) { T res = 1 % m, x = a % m; while (p) { if (p & 1) res = (res * x) % m; x = (x * x) % m; p >>= 1; } return res; } int main() { long long q; cin >> q; while (q--) { long long l, r, d; cin >> l >> r >> d; if (d < l || d > r) { cout << d << endl; continue; } long long add = r / d; cout << (d * (add + 1)) << endl; } return 0; }
7
CPP
for i in range(int(input())): l,r,d=map(int,input().split()) if d not in range(l,r+1): print(d) else: print((r//d)*d+d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; while (q--) { int l, r, d; cin >> l >> r >> d; if (d < l) { cout << d; } else { cout << (long long int)(d * (1 + (floor)(r / d))); } cout << endl; } }
7
CPP
for _ in range(int(input())): l,r,d=map(int,input().split()) if not l<=d<=r: print(d) else: print((r//d+1)*d)
7
PYTHON3
for _ in range(int(input())): l,r,d=list(map(int, input().split())) print(d if d<l else (r//d+1)*d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int q; cin >> q; while (q--) { long long int l, r, d; cin >> l >> r >> d; if (d < l) { cout << d << endl; } else { long long int val = (r / d); cout << (val + 1) * d << endl; continue; } } return 0; }
7
CPP
import math q=int(input()) for i in range(q): l,r,d=map(int,input().split()) s=l/d if d<l: print(d) elif d>=l and d<=r: if d*math.ceil(r//d)<=r: print(d*math.ceil(r//d)+d) else: print(d*math.ceil(r//d)) else: print(d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long int q, l, r, d; int main() { cin >> q; while (q--) { cin >> l >> r >> d; if (d < l) { cout << d << endl; } else { cout << (r / d + 1) * d << endl; } } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { int a, b, d; cin >> a >> b >> d; if (a != d && a / d >= 1) { cout << d << endl; } else { int k = b / d; cout << (k + 1) * d << endl; } } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, mod = 1000000007; const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double pi = acosl(-1.), eps = 1e-9; inline int power(int a, int b, int m = mod, int ans = 1) { for (; b; b >>= 1, a = 1LL * a * a % m) if (b & 1) ans = 1LL * ans * a % m; return ans; } int main() { int Q; cin >> Q; int L, R, d; while (Q--) { cin >> L >> R >> d; if (d < L) cout << d << endl; else { if (R < d) cout << d << endl; else cout << (R - (R % d) + d) << endl; } } return 0; }
7
CPP
# coding: utf-8 # In[7]: n = eval(input()) res = 0 for i in range(n): l, r, d = map(int, input().strip().split()) if d < l: print(d) elif l <= d and d <= r: res = r // d * d + d # while(res <= r): # res += d print(res) else: print(d)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int q, l, r, d; scanf("%d", &q); while (q--) { scanf("%d%d%d", &l, &r, &d); if (d < l) printf("%d\n", d); else printf("%d\n", (r / d + 1) * d); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; vector<int> isPrime(20, 1); void seive(int range) { isPrime[0] = isPrime[1] = 0; for (int i = 2; i * i <= range; i++) if (isPrime[i]) for (int j = i * i; j <= range; j += i) isPrime[j] = i; } long long mod_expo(long long n, long long exp, long long p = MOD) { long long res = 1; while (exp > 0) { if (exp & 1) { res = ((res % p) * (n % p)) % p; exp--; }; n = ((n % p) * (n % p)) % p; exp >>= 1; } return res; } int checkPrime(int n) { if (n == 1 or n == 0) return -1; for (int i = 2; i * i <= n; i++) { if (n % i == 0) { return -1; } } return 1; } void solve() { int l, r, d; cin >> l >> r >> d; if (d < l || d > r) { cout << (d) << '\n'; } else { cout << ((r / d) * d + d) << '\n'; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int ts = 1; cin >> ts; std::chrono::time_point<std::chrono::system_clock> start, end; start = std::chrono::system_clock::now(); while (ts--) { solve(); } end = std::chrono::system_clock::now(); std::chrono::duration<double> elapsed_seconds = end - start; std::time_t end_time = std::chrono::system_clock::to_time_t(end); return 0; }
7
CPP
MOD = 10**9 + 7 I = lambda:list(map(int,input().split())) t, = I() while t: t -= 1 l, r, d = I() if l <= d <= r: if r%d == 0: print(r + d) else: print(r - r%d + d) else: print(d)
7
PYTHON3
n=int(input()) for i in range(n): a,b,c = map(int,input().split()) if c<a: print(c) else: print((b//c+1)*c)
7
PYTHON3
q = int(input()) for t in range(q): l,r,d = map(int,input().split()) a = l//d b = r//d if a*d==l: a-=1 if a==1: print(d) elif a>1: print(d) else: if b*d==r: print(r+d) else: x = r-(r%d) x+=d print(x) elif l>=d: x = l - (l%d) if x//d >= 1: print(d) else: if b*d==r: print(r+d) else: x = r-(r%d) x+=d print(x) else: if b*d==r: print(r+d) else: x = r-(r%d) x+=d print(x)
7
PYTHON3
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] # def LF(): return [float(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def LS(): return sys.stdin.readline().split() def S(): return input() def main(): n=I() ans=[] for _ in range(n): a,b,c=LI() x=a/c if 1<x: ans.append(c) else: y=(b//c)*c if b<y: ans.append(y) else: ans.append(y+c) for x in ans: print(x) main() # print(main())
7
PYTHON3
for _ in range(int(input())): l,r,d = map(int,input().split()) if l<=d: print((d-(r%d))+r) else: print(d)
7
PYTHON3
for _ in range(int(input())): l,r,d=map(int,input().split()) if d<l: print(d) else: k = r//d print((k+1)*d)
7
PYTHON3
n = int(input()) for i in range(0, n): l, r, d = map(int, input().split()) ans = 0 if l > d: ans = d else: ans = (r // d + 1) * d print(ans)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { iostream::sync_with_stdio(false); int q; cin >> q; for (int i = 0; i < q; ++i) { int l, r, d; cin >> l; cin >> r; cin >> d; if (l > d) { cout << d << "\n"; } else { int t = r / d; t = (t + 1) * d; cout << t << "\n"; } } return 0; }
7
CPP
tc = int(input()) for _ in range(tc): l, r, d = map(int, input().split(' ')) ans = d if ans >= l: mod = r % d ans = r + (d - mod) print(ans)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int l, r, d; cin >> l >> r >> d; int x, i = 1; if (d < l) { x = d * 1; } else if (d >= l) { r = r / d; x = (r + 1) * d; } cout << x << endl; } return 0; }
7
CPP
t=int(input()) for i in range(t): l,r,d=map(int,input().split()) if d<l or d>r: print(d) else: if (r%d==0): print(r+d) else: x=(r//d)*d+d print(x)
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { long long l, r, d; cin >> l >> r >> d; if (d < l) { cout << d << endl; continue; } else { cout << d * (r / d + 1) << endl; } } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { long long int T, N, i, g, s, l, r, d, x, y, x1, y1; cin >> T; while (T--) { cin >> l >> r >> d; x = r / d; y = l / d; y1 = (y - 1) * d; x1 = (x + 1) * d; if (y == 0) cout << x1 << endl; else if (l > d) cout << d << endl; else if (l == d) cout << x1 << endl; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; long long a, b, c, k, z, mod, m, h, n, x; vector<int> vec; string s; int dp[100005] = {}; void solve() { int l, r, d; cin >> l >> r >> d; if (d > r || d < l) { cout << d; return; } cout << d * (r / d + 1); } int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cout << setprecision(10); int t = 1; cin >> t; while (t--) { solve(); cout << '\n'; } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6; long long l, r, d; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if (fopen("" ".INP", "r")) freopen( "" ".INP", "r", stdin), freopen( "" ".OUT", "w", stdout); int q; cin >> q; while (q--) { cin >> l >> r >> d; long long res1 = d; long long res2 = (r / d + 1) * d; if (res1 > 0 && (res1 < l || res1 > r)) cout << res1 << '\n'; else cout << res2 << '\n'; } }
7
CPP
n = int(input()) q = [[int(j) for j in input().split()] for i in range(n)] for i in range(n): if q[i][2] < q[i][0]: print(q[i][2]) else: print((q[i][1]// q[i][2]+1)* q[i][2])
7
PYTHON3
for _ in range(int(input())): l,r,d=map(int,input().split()) if(d<l): print(d) else: k=r//d print(d*k+d)
7
PYTHON3
n=int(input()) for i in range(n): l=input().split() l,r,d=int(l[0]),int(l[1]),int(l[2]) if l>d: print(d) elif r<d: print(d) else: print(r+d-(r%d))
7
PYTHON3
q=int(input()) for i in range(q): l,r,d=map(int,input().split()) if d<l: print(d) else: print(d*(r//d+1))
7
PYTHON3
for _ in range(int(input())): l,r,d = [int(i) for i in input().split()] print(d if d < l else (r // d+1)*d)
7
PYTHON3
q = int(input()) L = [0]*q R = [0]*q D = [0]*q for i in range(q): entrada = str(input()).split() L[i] = int(entrada[0]) R[i] = int(entrada[1]) D[i] = int(entrada[2]) def find_x(l,r,d): result = d if l <= d <= r: if r % d == 0: result = r + d else: result = int(r/d)*d + d return result for i in range(q): print( find_x(L[i], R[i], D[i]))
7
PYTHON3
import math t=int(input()) for ii in range(t): a,b,c=map(int,input().split()) if c<a or c>b: print(c) else: if b%c==0: print(c*((b//c)+1)) else: print(c*math.ceil(b/c))
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int l, r, d, n, t; cin >> t; while (t--) { cin >> l >> r >> d; if (d < l) cout << d << endl; else { n = r / d; n++; d = d * n; cout << d << endl; } } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int mod = 1000000007; const int mx = 2000001; const long long infL = 0xf3f3f3f3f3f3f3f; const double eps = 1e-9; const double pi = acos(-1.0); int main() { int q, l, r, d, x1, x2; scanf("%d", &q); while (q--) { scanf("%d", &l), scanf("%d", &r), scanf("%d", &d); x1 = d; x2 = (r + d) / d * d; if (x1 >= l) x1 = x2; printf("%d", (int)min(x1, x2)), printf("\n"); } return 0; }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int l, r, d, i, cnt; cin >> l >> r >> d; if (d < l || d > r) cout << d << endl; else { cnt = (r / d); cout << (cnt + 1) * d << endl; } } }
7
CPP