akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Bar> barlist = new ArrayList<>();
        HashMap<Long,Bar> bars = new HashMap<>();
        for (int i = 0; i < N; i++) {
            long a = scan.nextLong();
            if (!bars.containsKey(a)) {
                Bar b = new Bar();
                b.x = a;
                b.count = 1;
                barlist.add(b);
                bars.put(a, b);
            } else {
                Bar b = bars.get(a);
                b.count += 1;
            }
        }
        barlist.sort(new BarComparetor());
        long first = 0;
        long second = 0;
        for (int i = 0; i < N && (first == 0 || second == 0); i++) {
            Bar b = barlist.get(i);
            if (b.count == 1) {
                continue;
            }
            if (first == 0) {
                if (4 <= b.count) {
                    first = b.x;
                    second = b.x;
                } else {
                    first = b.x;
                }
                continue;
            }
            if (second == 0) {
                second = b.x;
            }
        }
        System.out.println(first*second);
    }
    class Bar {
        long x;
        int count;
    }
    class BarComparetor implements Comparator<Bar> {
        @Override
        public int compare(Bar o1, Bar o2) {
            if (o1.x== o2.x) {
                return -Integer.compare(o1.count, o2.count);
            }
            return -Long.compare(o1.x, o2.x);
        }
    }
}


Measured memory_bytes: 64632
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }

    REP(i, N) {
        if(A[i] % 2 == 0) {
            if(!(A[i] % 3 == 0 || A[i] % 5 == 0)) {
                printf("DENIED\n");
                return 0;
            }
        }
    }
    printf("APPROVED\n");

    return 0;
}



Measured memory_bytes: 256
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import sys
import numpy as np

def solve(H, W, Cy, Cx, Dy, Dx, S):
    inf = 1<<60
    Cy -= 1
    Cx -= 1
    Dy -= 1
    Dx -= 1
    st0 = [(Cy,Cx,0)]
    st1 = [(0,0,0)]*0
    D = np.full((H, W), inf)
    D[Cy, Cx] = 0
    while st0 or st1:
        if not st0:
            st0 = st1
            st1 = [(0,0,0)]*0
        y, x, d = st0.pop()
        if D[y, x] != d:
            continue
        for dy in range(-2, 3):
            for dx in range(-2, 3):
                uy = y + dy
                ux = x + dx
                if 0<=uy<H and 0<=ux<W and S[uy,ux]==0:
                    if abs(dy)+abs(dx) <= 1:
                        if D[uy, ux] > d:
                            st0.append((uy, ux, d))
                            D[uy, ux] = d
                    else:
                        if D[uy, ux] > d + 1:
                            st1.append((uy, ux, d+1))
                            D[uy, ux] = d+1
    ans = D[Dy, Dx] if D[Dy, Dx] != inf else -1
    return ans

numba_compile([
    [solve, "i8(i8,i8,i8,i8,i8,i8,u1[:,:])"]
])

def main():
    H, W = map(int, sys.stdin.buffer.readline().split())
    Cy, Cx = map(int, sys.stdin.buffer.readline().split())
    Dy, Dx = map(int, sys.stdin.buffer.readline().split())
    S = np.empty((H, W), dtype=np.uint8)
    for i in range(H):
        S[i] = np.frombuffer(sys.stdin.buffer.readline()[:-1], dtype=np.uint8) == ord("#")
    ans = solve(H, W, Cy, Cx, Dy, Dx, S)
    print(ans)

main()


Measured memory_bytes: 37064
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, i, a[300000], b[300000]={};
    scanf("%d", &n);
    for(i=2;i<=n;i++)
    {
    scanf("%d", &a[i]);
    b[a[i]]++;
    }
    for(i=1;i<=n;i++)
    printf("%d\n", b[i]);
    
    return 0;
}

Measured memory_bytes: 5772
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
using P = pair<int, int>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main(void) {

    ios::sync_with_stdio(false); cin.tie(0);

    int a, b;
    cin >> a >> b;

    for (int i = 1; i <= 20000; i++) {
        if (i * 8 / 100 == a && i * 10 / 100 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };


int main()
{
	int A, B;
	cin >> A >> B;
	if (A + B < 10)cout << A + B;
	else cout << "error";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define IoFast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long int
#define float long double
#define foor(i, a, b) for ( int (i) = (a); (i)<(b); (i)++ )
#define foor2(i, a, b) for( int (i) = (a); (i)>(b); (i)-- )
#define foorl(i, a, b) for ( ll (i) = (a); (i)<(b); (i)++ )
#define foorl2(i, a, b) for( ll (i) = (a); (i)>(b); (i)-- )
#define mp make_pair
#define f1 first
#define f2 second
#define pb push_back
#define pii pair<int,int>
#define vpii vector <pii>
#define vi vector<int>
#define sz(a) (int) a.size( )
#define fillArr(n, a) foor(i, 0, n) cin >> a[i];
#define print(a) cout << #a << endl;
#define umax(a,b) a = max ( a, b )
#define umin(a,b) a = min ( a, b )
#define all(k) k.begin ( ), k.end( )
#define rall(k) k.rbegin ( ), k.rend( )
#define clean(k) memset( k, 0, sizeof(k) )
#define endl '\n'


int main(){
	IoFast;
	long long n,a,b;
	cin >> n >> a >> b;
	if(n > 1 && b >= a || n == 1 && a == b)
		cout << (n - 2) * (b - a) + 1 << endl;
	else
		cout << 0 << endl; 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a))
#define mp make_pair
#define All(a) (a).begin(), (a).end()
template <typename T=long long>
inline T IN(){T x; cin>>x; return(x);}
inline void CIN(){}
template <class Head,class... Tail>
inline void CIN(Head&& head,Tail&&... tail){
    cin>>head;
    CIN(move(tail)...);
}
#define CINT(...) int __VA_ARGS__;CIN(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CIN(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CIN(__VA_ARGS__)
 
typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int,V,greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int N,C;
int D[30][30];
map<int,int> c[3];

inline ll SUM(map<int,int> color, int paint){
	ll ret=0;
	FOREACH(cp,color){
		if(cp.first!=paint){
			ret+=cp.second*D[cp.first][paint];
		} 
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>N>>C;
	REP(i,C)REP(j,C){
		D[i][j]=IN();
	}
	REP(i,N)REP(j,N){
		CINT(color);
		color--;
		switch ((i+j)%3){
			case 0:
				c[0][color]++;
				break;
			case 1:
				c[1][color]++;
				break;
			case 2:
				c[2][color]++;
				break;
		}
	}
	ll sum=LINF;
	REP(i,C)REP(j,C)REP(k,C){
		if(j==i|k==i|k==j) continue;
		ll tmp=0;
		tmp+=SUM(c[0],i);
		tmp+=SUM(c[1],j);
		tmp+=SUM(c[2],k);
		sum=min(sum,tmp);
	}
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
//struct InitIO {
//    InitIO() {
//        cin.tie(nullptr);
//        ios_base::sync_with_stdio(false);
//        cout << fixed << setprecision(30);
//    }
//} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	LL n,k;
	cin >> n >> k;
	VL a(n),f(n);
	cin >> a >> f;
	LL l = 0, r = 0;
	SORT(a);
	RSORT(f);
	for (int i = 0; i < n; i++) {
		r = max(r, a[i]*f[i]);
	}
	LL ans = r;
	while (r != l) {
		LL m = ((l+r) >> 1);
		LL count = 0;
		for (int i = 0; i < n; i++) {
			count += max(a[i] - m / f[i], 0LL);
		}
		if (count <= k) {
			ans = m;
			r = m;
		} else {
			l = m+1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {

    let S: String = read();
    let v: Vec<_> = S.chars().collect();
    if (v[0] == 'B' && v[1] == 'B' && v[2] == 'B') ||(v[0] == 'A' && v[1] == 'A' && v[2] == 'A') {
        println!("No");
    } else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  long long A[200];
  int count = 0;
  long long keep = 0;
  cin >> N; // input()
  
  for(int i = 0; i < N; ++i) cin >> A[i];
  
  while(true){
    for(int i = 0; i < N; ++i){
      keep = A[i]%2;
      if(keep == 1){
        break;
      }
      A[i] = A[i]/2;
    }
    if(keep == 1){
        break;
    }
    count++;
  }
  cout << count <<endl; // output()
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;

#define T 10
int ans(int *s, int N){
	int sum = 0, min, i;
	for(i = 0; i < N; ++i){
		sum += s[i];
	}
	min = sum;
	if(sum%T == 0){
		for(i = 0; i < N; ++i){
			if(s[i] < min && s[i]%T != 0){
				min = s[i];
			}
		}
		return sum-min;
	}
	else {
		return sum;
	}
}

int main(){
	int N, *s, i;

	cin >> N;
	s = new int [N];
	for(i = 0; i < N; ++i){
		cin >> s[i];
	}

	cout << ans(s, N) << "\n";

	delete [] s;
	return 0;
}



Measured memory_bytes: 256
/*
      author : nishi5451
      created: 12.08.2020 14:59:12
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) << " " << (a+b>n ? a+b-n : 0)<< endl;
    return 0;
}

Measured memory_bytes: 3532
from bisect import bisect_left, bisect_right
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
A_sum = list(accumulate(A))

ans = A_sum[N-1]
for m in range(2,N-1):
    sum_left = A_sum[m-1]
    i=bisect_left(A_sum,sum_left/2)
    sum1=A_sum[i]
    if i!= 0:
        if A_sum[i]+A_sum[i-1] > sum_left:
            sum1=A_sum[i-1]
    sum2 = sum_left - sum1
    
    sum_right=A_sum[N-1]-sum_left
    i=bisect_left(A_sum,sum_left+sum_right/2)
    sum3=A_sum[i]-sum_left
    if i!=m:
        if A_sum[i]+A_sum[i-1]-2*sum_left>sum_right:
            sum3=A_sum[i-1]-sum_left
    sum4=sum_right-sum3
    max_sum=max(sum1,sum2,sum3,sum4)
    min_sum=min(sum1,sum2,sum3,sum4)
    dif=max_sum-min_sum
    if dif<ans:
        ans=dif
        
print(ans)

Measured memory_bytes: 90488
from functools import partial
from itertools import islice, accumulate


def take(n, iterable):
    return list(islice(iterable, n))


def chunked(iterable, n):
    return iter(partial(take, n, iter(iterable)), [])


def solve(s):
    n, m, q, *lrpq = map(int, s.split())
    lr, pq = lrpq[:2 * m], lrpq[2 * m:]
    t = [[0] * (n + 1) for _ in range(n + 1)]
    for l, r in chunked(lr, 2):
        t[l][r] += 1
    t = [list(accumulate(_t)) for _t in zip(*(accumulate(_t) for _t in t))]
    return "\n".join(
        [str(t[q][q] - t[q][p - 1] - t[p - 1][q] + t[p - 1][p - 1]) for p, q in chunked(pq, 2)])


if __name__ == "__main__":
    n, m, q = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, q) + '\n'.join([input() for _ in range(m + q)])))


Measured memory_bytes: 60740
N = int(input())
S = sorted([int(input()) for i in range(N)])
if sum(S) % 10 == 0:
  N = [i for i in range(N) if S[i] % 10]
  if N:
    print(sum(S) - S[N[0]])
  else:
    print(0)
else:
  print(sum(S))

Measured memory_bytes: 3064
// ※※※ 解答不能 ※※※
// scott_wu氏
// https://atcoder.jp/contests/agc039/submissions/7866514
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int MAXN = 200100;
const ll MOD = 998244353;

int N;
string X;
vector <int> pfac;
ll rv[MAXN];

ll gogo(int K){
    ll cv = 0;
    for(int i = 0; i < K; i++) cv = (2 * cv + (X[i] - '0')) % MOD;
    if(K == N) cv++;
    for(int i = K; i < N; i++){
        int ov = 1 - (X[i-K] - '0');
        int nv = X[i] - '0';
        if (ov > nv){
            break;
        }else if(ov < nv){
            cv++;
            break;
        }else if (i == N - 1){
            cv++;
            break;
        }
    }
    cv %= MOD;
    return cv;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin >> N;
    cin >> X;
    for(int i = 1; i <= N; i++){
        if(N % i == 0){
            if((N / i) % 2 == 1) pfac.push_back(i);
        }
    }
    for(int i = 0; i < pfac.size(); i++){
        rv[i] = gogo (pfac[i]);
        //cout << pfac[i] << " " << rv[i] << "\n";
    }
    for(int i = 0; i < pfac.size(); i++){
        for(int j = i + 1; j < pfac.size(); j++){
            if(pfac[j] % pfac[i] == 0) rv[j] -= rv[i];
        }
    }
    ll ans = 0;
    for(int i = 0; i < pfac.size(); i++){
        //cout << pfac[i] << " " << rv[i] << "\n";
        ans = ans + (2 * pfac[i] * rv[i]);
        ans %= MOD;
    }
    ans = (ans + MOD) % MOD;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

const ll MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  ll par = 0;
  rep(i,n){
    cin >> a[i];
    par += a[i]*a[i];
    par %= MOD;
    sum += a[i];
    sum %= MOD;
  }
  ll ans = (sum*sum-par+MOD)%MOD;
  ans *= 500000004;
  ans %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e6;
const int Nmax=2e5+1;
const int Nd=61;


int main(){
  int n,q; cin>>n>>q;
  string s; cin>>s;
  vector<int> count(n);
  count[0]=0;
  for(int i=1; i<n ; i++){
    count[i]=count[i-1];
    if(s[i]=='C' && s[i-1]=='A'){
      count[i]=count[i-1]+1;
    }
    //cout<<count[i]<<endl;
  }
  rep(i,q){
    int l,r; cin>>l>>r;
    l--;r--;
    cout<<count[r]-count[l]<<endl;
  }



}


Measured memory_bytes: 3808
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=1e5+10;

int main(){
	int N,X;
	cin>>N>>X;
	int ball=0;
	int ans=1;
	rep(_,N){
		int l;
		cin>>l;
		ball+=l;
		if(ball<=X)ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(int i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(int i = 0; i <=(ll)(n); i++)

int main(){
    string s, s_original;
    cin >> s;
    int min_count = 0;
    int count_diff = 0;
    s_original = s;
    reverse(s.begin(), s.end());
    string s_reverse = s;
    rep0(i,s_original.size()-1){
        if(s_reverse[i] != s_original[i]) count_diff++;
    }
    if(count_diff % 2 == 0){
        min_count = count_diff/2;
    }else{
        min_count = (count_diff-1)/2;
    }
    cout << min_count << endl;
    return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n,a,b,c,x;
    cin >> n >> a >> b >> c >> x;
    if(!n&&!a&&!b&&!c&&!x) return 0;
    queue<int> y;
    REP(i,n){
      int tmp;
      cin >> tmp;
      y.push(tmp);
    }
    int answer=0;
    for(;;){
      if(answer>10000){
	answer=-1;
	break;
      }
      if(y.front()==x) y.pop();
      if(y.empty()) break;
      answer++;
      x=(a*x+b)%c;
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define int long long int 
using namespace std;

// Author: Ashish

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n,k,c;
  string s;
  cin>>n>>k>>c>>s;
  int maxWork[n];
  for(int i=n-1;i>=0;i--)
  {
  	maxWork[i]=(s[i]=='o');
  	if(i+1<n) maxWork[i]=max(maxWork[i],maxWork[i+1]);
  	if(i+c+1<n)maxWork[i]=max(maxWork[i],(s[i]=='o')+maxWork[i+c+1]);
  }
  if(maxWork[0]>k) return 0;
  int index=0;
  for(int j=k;j>0;j--)
  {
  	set<int> indices;
  	for(;maxWork[index]==j;index++)
  	{
  		if(s[index]=='o')
  			indices.insert(index);
  	}
  	int index1=*(indices.begin());
  	index=c+1+index1;	
  	if(indices.size()==1)
  		cout<<index1+1<<'\n';
  }

 	return 0;
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
vector <int> vec;
map <int, bool> mp;
priority_queue <int> que;
int a, b, ans;

int main() {
	cin >> a >> b;
	for(int i = 1; i <= 1250; i++) {
		double x = i * 0.08;
		double y = i * 0.1;
		if(floor(x) == a && floor(y) == b) {
			ans = i;
			break;
		}
	}
	if(!ans) puts("-1");
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;

string operator*(string s, int n){
    string r="";
    for(int i=0;i<n;i++){
        r=r+s;
    }
    return r;
}

int main(){
    int sx,sy,tx,ty;

    cin >> sx >> sy >> tx >> ty;
    int w=tx-sx, h=ty-sy;
    string U="U", R="R", D="D", L="L";
    cout << U*h << R*w << D*h << L*w << L << U*(h+1) << R*(w+1) << D << R << D*(h+1) << L*(w+1) << U << endl;

    return 0;
}

Measured memory_bytes: 256
int check[30];

int main() {

  for (int bit = 29; bit >= 0; bit--) {
    check[bit] = 0;
  }

  int n;
  scanf("%d", &n);
  int xor_sum = 0;
  int a;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    xor_sum ^= a;
    a = a ^ (a - 1);

    switch (a) {
    case 1073741823:
      check[29] = 1;
      break;
    case 536870911:
      check[28] = 1;
      break;
    case 268435455:
      check[27] = 1;
      break;
    case 134217727:
      check[26] = 1;
      break;
    case 67108863:
      check[25] = 1;
      break;
    case 33554431:
      check[24] = 1;
      break;
    case 16777215:
      check[23] = 1;
      break;
    case 8388607:
      check[22] = 1;
      break;
    case 4194303:
      check[21] = 1;
      break;
    case 2097151:
      check[20] = 1;
      break;
    case 1048575:
      check[19] = 1;
      break;
    case 524287:
      check[18] = 1;
      break;
    case 262143:
      check[17] = 1;
      break;
    case 131071:
      check[16] = 1;
      break;
    case 65535:
      check[15] = 1;
      break;
    case 32767:
      check[14] = 1;
      break;
    case 16383:
      check[13] = 1;
      break;
    case 8191:
      check[12] = 1;
      break;
    case 4095:
      check[11] = 1;
      break;
    case 2047:
      check[10] = 1;
      break;
    case 1023:
      check[9] = 1;
      break;
    case 511:
      check[8] = 1;
      break;
    case 255:
      check[7] = 1;
      break;
    case 127:
      check[6] = 1;
      break;
    case 63:
      check[5] = 1;
      break;
    case 31:
      check[4] = 1;
      break;
    case 15:
      check[3] = 1;
      break;
    case 7:
      check[2] = 1;
      break;
    case 3:
      check[1] = 1;
      break;
    case 1:
      check[0] = 1;
      break;
    }
  }

  int ans = 0;
  for (int bit = 29; bit >= 0; bit--) {
    if (((1 << bit) & xor_sum) == 0) {
      continue;
    }
    int x = (1 << (bit + 1)) - 1;

    if (check[bit] > 0) {
      xor_sum ^= x;
      ans += 1;
    }
  }

  if (xor_sum != 0) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
ll gcd(ll a, ll b)//最大公約数
{
   if (b == 0)
   {
       return a;
   }
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) //最小公倍数
{
    return (a/gcd(a, b))*b;
}
int main() {
    int N;
    cin >> N;
    vector<ll>T(N);
    rep(i, 0, N){
        cin >> T[i];
    }
    ll ans = 0;
    rep(i, 0, N-1){
        T[i+1] = lcm(T[i], T[i+1]);
    }
    rep(i, 0, N){
        if(ans < T[i]){
            ans = T[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define pob pop_back
#define mp make_pair
#define f first
#define s second

typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

vector <pair<int,int> > A;

bool sortby(const pair<int,int> &a,const pair<int,int> &b){
	if(a.s != b.s) return a.s < b.s;
}

void solve(){
	int n;
	cin>>n;
	A.resize(n);
	for(int i=0;i<n;i++){
		cin>>A[i].s>>A[i].f;
	}
	sort(A.begin(),A.end());
	int time_taken=0;
	bool flag = true;
	for(int i=0;i<n;i++){
		if(time_taken + A[i].s > A[i].f){
			flag = false;
			break;
		}
		time_taken += A[i].s;
	}
	if(flag) cout<<"Yes\n";
	else cout<<"No\n";
}

int main(){
	ios_base::sync_with_stdio(0);
  cin.tie(0);
		solve();
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
	int a, b;
    cin >> a >> b;
    if (a <= b) {
    	cout << a << endl;    
  	}
  	else {
    	cout << a - 1 << endl;
    }
}
/*
*/

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int x;
  cin >> x;
  for(long long int i = 125;i >= -124;i--){
    for(long long int j = i - 1;j >= -125;j--){
      if(((i * i * i * i * i) - (j * j * j * j * j)) == x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3632
/*
    ->->->->-> Vora Mahammasasim <-<-<-<-<-
*/
#include<bits/stdc++.h>
#include<stdio.h>
#define Quick std :: ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
#define ps(a) partial_sum(all(a),a.begin())
using namespace std;





signed main(){

    Quick;
    string s;
    cin>>s;
    int n =s.size();
    int ans = -1;
    for(int i=0;i<n;){
        int cnt = 0;
        if(s[i] == 'R')
        while(s[i] == 'R'){
            cnt++;
            i++;
        }
        else i++;
        ans = max(ans,cnt);
    }
    cout<<ans;

}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n,s) for (int i=a;s>0?i<n:i>n;i+=s)
#define rep(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int inf = 1e9+10, mod = 1e9+7; const long long llinf = 1e18;
// head
template<class T>T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<class T>T lcm(T a, T b) { return a*b / gcd(a,b); }
int main(){
  int k;
  cin >> k;
  int ans = 0;
  rep(a,1,k+1)rep(b,1,k+1)rep(c,1,k+1){
    ans += gcd(gcd(a,b),c);
    // cout << a << b << c << gcd(gcd(a,b),c) << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N = 6e5 + 7;

int n, a[N], k, tree[4 * N];

#define m (l + r) / 2
#define lson 2 * node
#define rson 2 * node + 1

void update(int pos, int v, int l, int r, int node) {
    if (l == r) {
        tree[node] = v;
        return;
    }
    if (pos <= m) update(pos, v, l, m, lson);
    else update(pos, v, m + 1, r, rson);
    tree[node] = max(tree[lson], tree[rson]);
}

int query(int ql, int qr, int l, int r, int node) {
    if (ql <= l && qr >= r) {
        return tree[node];
    }
    int ans = 0;
    if (ql <= m) ans = max(ans, query(ql, qr, l, m, lson));
    if (qr > m) ans = max(ans, query(ql, qr, m + 1, r, rson));
    return ans;
}



int main() {
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int res = query(max(a[i] - k, 0), a[i] + k, 0, N, 1) + 1;
        ans = max(ans, res);
        update(a[i], res, 0, N, 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9060
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

const int MOD = 1000000007;
int n;
int vs[200000+10];
int nexts[200000+10];
int last[200000+10];

ll memo[200000+10];
ll solve(int pos) {
  ll &res = memo[pos];
  if(res < 0) {
    if(pos == n) {
      res = 1;
    } else {
      res = solve(pos+1);
      if(nexts[pos] > pos+1) {
        res = (res + solve(nexts[pos])) % MOD;
      }
    }
  }
  return res;
}

int main(void) {
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i]);
  }
  for(int i = n-1; i >= 0; --i) {
    int v = vs[i];
    if(last[v] > 0) {
      nexts[i] = last[v];
    }
    last[v] = i;
  }
  memset(memo, -1, sizeof memo);
  ll res = solve(0);
  // REP(i, n+1) {
  //   cerr << "memo[" << i << "] = " << memo[i] << endl;
  // }

  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 10368
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// Scan Standard Input
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	str := nextLine()
	n, _ := strconv.Atoi(nextLine())

	for i := 0; i < n; i++ {
		m := strings.Split(nextLine(), " ")
		switch m[0] {
		case "print":
			{
				s_idx, _ := strconv.Atoi(m[1])
				e_idx, _ := strconv.Atoi(m[2])
				fmt.Println(str[s_idx : e_idx+1])
			}
		case "replace":
			{
				s_idx, _ := strconv.Atoi(m[1])
				e_idx, _ := strconv.Atoi(m[2])
				str = str[:s_idx] + m[3] + str[e_idx+1:]
			}
		case "reverse":
			{
				s_idx, _ := strconv.Atoi(m[1])
				e_idx, _ := strconv.Atoi(m[2])
				tmp := []rune(str[s_idx : e_idx+1])

				tt := ""
				for j := len(tmp) - 1; j >= 0; j-- {
					tt = tt + string(tmp[j])
				}
				str = str[:s_idx] + tt + str[e_idx+1:]
			}
		default:
		}
	}
}



Measured memory_bytes: 3364
import java.util.Scanner;

public class Main {
	static Scanner scn = new Scanner(System.in);

	public static void main(String[] args) {
		int n = scn.nextInt();
		int m = scn.nextInt();
		int ans1 = 0;
		if (n > 1) {
			ans1 = n * (n - 1) / 2;
		}
		int ans2 = 0;
		if (m > 1) {
			ans2 = m * (m - 1) / 2;
		}
		System.out.println(ans1 + ans2);
	}
}


Measured memory_bytes: 23764
#include <stdio.h>          // printf(), scanf()

#define MAX_N 100
#define MAX_W 10000
#define max(a, b) ((a) > (b) ? (a) : (b))

int n, W;
int w[MAX_N];
int v[MAX_N];

int
solve()
{
	int dp[MAX_W + 1];
	int i, j;

	for (j = 0; j <= W; ++j)
		dp[j] = 0;

	for (i = 0; i < n; ++i)
	{
		for (j = w[i]; j <= W; ++j)
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
	}

	return dp[W];
}

int
main(int argc, char** argv)
{
	int i;

	scanf("%d %d", &n, &W);
	for (i = 0; i < n; ++i)
		scanf("%d %d", &v[i], &w[i]);


	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    bool c[h+1][w+1];
    rep(i,h){
        rep(j,w){
            c[i][j]=false;
        }
    }
    c[0][0]=true;
    int x=0,y=0;
    while(1){
        if(y==h-1 && x==w-1) break;
        if(s[y][x+1]=='#'){
            c[y][x+1]=true;
            ++x;
            continue;
        }else{
            if(s[y+1][x]=='#'){
                c[y+1][x]=true;
                ++y;
                continue;
            }else{
                cout << "Impossible" << "\n";
                return 0;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(!c[i][j] && s[i][j]=='#'){
                cout << "Impossible" << "\n";
                return 0;
            }
        }
    }
    cout << "Possible" << "\n";
    return 0;
}   

Measured memory_bytes: 3676
#https://atcoder.jp/contests/abc125
# -*- coding: utf-8 -*-

n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))

count = 0
for i in range(n):
        if v[i] > c[i]:
                count += v[i]-c[i]

print(count)

Measured memory_bytes: 3060
from collections import deque

n,m = map(int,input().split())
friend = [[] for i in range(n+1)]
end = [0 for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    friend[a].append(b)
    friend[b].append(a)

for i in range(1,n+1):
    friend[i] = list(set(friend[i]))

memnum = []
q = deque()

for i in range(1,n+1):
    if end[i] != 0:
        continue
    elif end[i] == 0:
        tmp = 1
        num = 0
        end[i] = 1
        for j in friend[i]:
            end[j] = 1
            q.append(j)
        tmp += len(friend[i])
        while len(q) != 0:
            num = q.popleft()
            for j in friend[num]:
                if end[j] == 0:
                    end[j] = 1
                    q.append(j)
                    tmp += 1
        memnum.append(tmp)

print(max(memnum))


Measured memory_bytes: 48584
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  set<int> st;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    st.insert(a);
  }
  if (n == st.size())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<string> ar(n);
	for (auto& s: ar) {
		cin >> s;
	}
	priority_queue<tuple<int, int, int>> q;
	q.emplace(-(ar[0][0] == '#'), 0, 0);
	vector<vector<int>> cost(n, vector<int>(m, 1000000));
	int moves[2][2] = {{0, 1}, {1, 0}};
	while (!q.empty()) {
		int c, x, y;
		tie(c, x, y) = q.top();
		q.pop();
		if (cost[x][y] <= -c) continue;
		cost[x][y] = -c;
		if (x == n - 1 && y == m - 1) {
			cout << -c << endl;
			return 0;
		}
		for (auto& d: moves) {
			int nx = x + d[0];
			int ny = y + d[1];
			if (nx < n && ny < m) {
				if (ar[x][y] == '.' && ar[nx][ny] == '#') {
					q.emplace(c - 1, nx, ny);
				} else {
					q.emplace(c, nx, ny);
				}
			}
		}
	}
}

Measured memory_bytes: 384
n = int(input())
a_list = list(map(int,input().split()))
b_list = [0 for i in range(n)]
for i in range(n,0,-1):
  num = n//i
  if num >= 2 :
    check = 0
    for _ in range(1,num+1):
       check += b_list[_ * i - 1] % 2
    if check % 2 == 1:
      if a_list[i-1] == 0:
        b_list[i-1] = 1
      else:
        b_list[i-1] = 0
    else:
      if a_list[i-1] == 0:
        b_list[i-1] = 0
      else:
        b_list[i-1] = 1

  if num == 1:
    b_list[i-1] = a_list[i - 1]

print(sum(b_list))
ans = []
for i in range(n):
  if b_list[i] ==1:
    ans.append(i+1)
print(*ans)


Measured memory_bytes: 14520
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    int a, b, c, n;
    string s, t;

    cin >> n ;
    vector<long> l(100);
    l[0]=2;
    l[1]=1;

    long cnt=2;
    if (n>=2){
        while(true){
            l[cnt] = l[cnt-1]+l[cnt-2];
            if (cnt==n)break;
            cnt++;
        }
    }else{
        cnt=1;
    }





    cout <<  l[cnt];

    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using pint = pair<int, int>;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll tmp = n % k;
    cout << min(tmp, abs(k - tmp)) << endl;
}

Measured memory_bytes: 3656
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<queue> 
#include<map> 
#include<climits>
#include<set> 
#include<string> 
//#include<time.h>
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 10000
#define E5 100000
#define E6 1000000
#define inf 1001001001
#define longinf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,b) for(lld i=a;i<b;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,b) for(lld i=b-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector
const double EPS = 1e-6;

void google(int i)
{  cout<<"Case #"<<i<<":"; }

//prime sieve if needed 
//prime factors of number
lld prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[i]==1)
           prime[j]=i; 
      }
}

lld gcd(lld a,lld b)
{
    if(a==0)
     return b; 
    return gcd(b%a,a); 
}

//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
/*
void complexity(time_t end,time_t start)
{ 
  double taken = double(end - start); 
    cout<<"Time : "; 
    cout<<fixed<<taken<<setprecision(8);         cout<<" sec "<<endl;
}
*/
void contest(); 
int main()
{   
    /*
    time_t start, end; 
    time(&start); 
    */
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld t=1; 


    rec(i,t) 
    {
     //google(i+1); 
      contest(); 
      cout<<endl; 
    }
    /*
     time(&end); 
    complexity(end,start);
    */
	return 0;
}

void contest()
{ 
  lld n,x,k; 
  cin>>n>>x>>k; 
  lld y; 
  if(n%x==0) 
  y=n/x; 
  else 
  y=(n/x)+1; 
  y*=k; 
  cout<<y; 
  
}

Measured memory_bytes: 3648
#include <stdio.h>
#include<iostream>
#include<algorithm>
#include <string.h>
#include<string>
using namespace std;
int main()
{	
	/*freopen("input.txt","r",stdin);*/
	string s1,s2;
	cin>>s1>>s2;
	char s[100];
	int num1=0,num2=1;
	for(int i=0;i<s1.length();i++)
	{
		s[num1]=s1[i];
		num1+=2;
	}
	for(int i=0;i<s2.length();i++)
	{
		s[num2]=s2[i];
		num2+=2;
	}
	for(int i=0;i<s1.length()+s2.length();i++)
		cout<<s[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
MOD=[]

if N==0:
    print(0)
    exit()

for i in range(1,10**9):
    if 2**(i-3)>abs(N):
        break
    MOD.append(N%(2**i))
#print(MOD)
ans = []
def value(ans):
    buff=0
    for i,a in enumerate(ans):
        buff += a*((-2)**i)
    return buff

for i,mod in enumerate(MOD):
    divide = 2**(i+1)
    if value(ans) % divide == mod:
        ans.append(0)
    else:
        ans.append(1)
#print(ans,value(ans))
ans = list(reversed([str(i) for i in ans]))
while ans[0]=="0":
    ans.pop(0)
print("".join(ans))


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[n];
		for(int i=0;i<a.length;i++) {
			a[i] = scanner.nextInt();
		}
		for(int i=n-1;i>=0;i--) {
			if(i!=n-1) {
				System.out.print(" " + a[i]);
			}else {
				System.out.print(a[i]);
			}
		}
		System.out.println();
		scanner.close();
	}
}


Measured memory_bytes: 26412
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        char[][] map = new char[n][];
        for(int i = 0; i < n; i++){
            map[i] = sc.next().toCharArray();
        }
        int ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                for(int k = 0; k < n; k++){
                    for(int l = 0; l < m; l++){
                        if((i == k) && (j == l)){
                            continue;
                        }
                        if(map[i][j] == '.' && map[k][l] == '.'){
                            ans = Math.max(ans,bfs(n,m,map,i,j,k,l));
                        }
                    }
                }
            }
        }
        System.out.println(ans);
    }

    public static int bfs(int n, int m, char[][]map,int sy,int sx,int gy, int gx){
        char[][] bfsmap = new char[n][];
        for(int i = 0; i < n; i++){
            bfsmap[i] = map[i].clone();
        }
        Point[] D4 = {new Point(-1, 0),new Point(1,0), new Point(0,1), new Point(0,-1)};
        Point start = new Point(sx, sy), goal = new Point(gx, gy);
        boolean arrived = false;
	    int[][] moves = new int[n][m];
	    for(int i = 0; i < n; i++){
            Arrays.fill(moves[i],99999999);
        }
        moves[sy][sx] = 0;
        ArrayDeque<Point> dq = new ArrayDeque<>();
        dq.add(start);

        while (dq.size() > 0) {
            Point p = dq.removeFirst();
            for (int i=0; i<4; i++) {
                int x = p.getX()+D4[i].getX();
                int y = p.getY()+D4[i].getY();
                if(!(0 <= y && y < n && 0 <= x && x < m)){
                    continue;
                }
                else if (bfsmap[y][x] == '.') {
                    dq.addLast(new Point(x, y));
                    bfsmap[y][x] = '#';
                    moves[y][x] = Math.min(moves[y][x],moves[p.getY()][p.getX()] + 1);
                }
                if(x == gx && y == gy){
                    arrived = true;
                }
            }
            if(arrived){
                break;
            }
        }
        if(arrived){
            return moves[goal.getY()][goal.getX()];
        }else{
            return -1;
        }
    }
}

class Point{

	private int x;
	private int y;

	Point(int a, int b) {x=a; y=b;}

	int getX() {return x;}
	int getY() {return y;}
	void setX(int n) {x = n;}
	void setY(int n) {y = n;}

}

Measured memory_bytes: 337876
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=1e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline ll read(){
    ll x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/

ll n,d,cnt;
int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	n=read(),d=read();d=d*d;
	for(int i=1;i<=n;i++){
		ll x=read(),y=read();
		if((x*x+y*y)<=d) ++cnt;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void) {
    int n;
    scanf("%d", &n);
    char input[10001];
    scanf("%s", input);
    char abc[30] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for (int i = 0; i < strlen(input); i++) {
        int j = 0;
        while (input[i] != abc[j]) {
            j++;
        }
        printf("%c", abc[(j+n)%26]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, 0, N)
    {
        cin >> A[i] >> B[i];
    }

    ll num = 0;
    rrep(i, N - 1, 0)
    {
        const ll r = (A[i] + num) % B[i];
        if (r != 0)
        {
            num += B[i] - r;
        }
    }

    cout << num << endl;
}


Measured memory_bytes: 1792