akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    while (true) {
        int count = 0;
        int input_h, input_w;
        vector<int> h, w;
        vector<int> h_factor, w_factor;
        cin >> n >> m;
        if (n == 0) {
            break;
        }
        for (int i=0; i<n; i++) {
            cin >> input_h;
            h.push_back(input_h);
        }
        for (int i=0; i<m; i++) {
            cin >> input_w;
            w.push_back(input_w);
        }
        for (int i=0; i<n; i++) {
            int total = 0;
            for (int j=i; j<n; j++) {
                total += h[j];
                h_factor.push_back(total);
            }
        }
        sort(h_factor.begin(), h_factor.end());
        for (int i=0; i<m; i++) {
            int total = 0;
            for (int j=i; j<m; j++) {
                total += w[j];
                w_factor.push_back(total);
            }
        }
        sort(w_factor.begin(), w_factor.end());
        for (int i=0; i<(int)h_factor.size(); i++) {
            count += upper_bound(w_factor.begin(), w_factor.end(), h_factor[i])
                    -lower_bound(w_factor.begin(), w_factor.end(), h_factor[i]);
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 21072
n,m = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

b = [0] * m
for i in range(m):
    b[i] = int(input())

from operator import mul
for i in range(n):
    print(sum(map(mul, A[i], b)))

Measured memory_bytes: 8184
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll a[12345678], b[12345678], c[12345678];
signed main() {
    ll n, k, ans = 0; cin >> n >> k;
    for (int h = 0; h < n; h++) {
        cin >> a[h] >> b[h] >> c[h];
    }
    for (int i = 0; i <= (1 << 3); i++) {
        vector<ll> sep = { }; ll sum = 0;
        for (int j = 0; j < 3; j++) {
            if ((i & (1 << j)) > 0) {
                sep.push_back(j);
            }
        }
        sep.push_back(INF); vector<ll> v;
        for (int h = 0; h < n; h++) {
            ll aa = a[h], bb = b[h], cc = c[h], z = 0;
            if (sep[z] == 0) { aa = 0 - aa; z++; }
            if (sep[z] == 1) { bb = 0 - bb; z++; }
            if (sep[z] == 2) { cc = 0 - cc; }
            v.push_back(aa + bb + cc);
            //cout << aa << ' ' << bb << ' ' << cc << endl;
        }
        sort(v.begin(), v.end()); reverse(v.begin(), v.end());
        for (int h = 0; h < k; h++) {
            sum += v[h];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <stdio.h>
#include <ctype.h>
int main(){
    char s[101],sp[101];
	char ch ;
	int cnt,i,q,len,len2;
	int point[100]={0};
	gets(s);
	gets(sp);
	cnt=0;
	len=strlen(s);
	len2=strlen(sp);
	for(q=0;q<len2;q++){
		for(i=0;i<len;i++)
		{
			if(i+q >= len){ch = s[i+q-len];}
			else         {ch = s[i+q]    ;}
			if(ch == sp[q])
			{
				point[i]+=1;
				if(point[i]==len2){cnt = 1;}
			}
		}
	}
	if(cnt==1){printf("Yes\n");}
	else{printf("No\n");}
	return 0;
}

Measured memory_bytes: 524
#ifndef bhartiya
    // #pragma GCC optimize("Ofast")
    // #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cout << "\n\nTime elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
}
#else
#define endl '\n'
#define trace(...)
#define start_routine()
#define end_routine()
#endif

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7

ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }
double dp[305][305][305];
bool vis[305][305][305];
double n;

double recur(ll a, ll b, ll c){
    if(a==0 && b==0 && c==0) return 0;
    else if(vis[a][b][c]) return dp[a][b][c];
    double sum = n;
    if(a){
        sum += a*(recur(a-1,b,c));
    }
    if(b){
        sum += b*(recur(a+1,b-1,c));
    }
    if(c){
        sum += c*(recur(a,b+1,c-1));
    }
    vis[a][b][c] = true;
    return dp[a][b][c] = sum/(a+b+c);
}

int main() 
{ 
    start_routine();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        cin>>n;
        ll a=0,b=0,c=0;
        rep(i,n){
            ll x;
            cin>>x;
            if(x==1) a++;
            else if(x==2) b++;
            else if(x == 3) c++;
        }
        trace(n,a,b,c);
        cout<<recur(a,b,c);
    }
    end_routine();
}


Measured memory_bytes: 246016
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
///////////////////////////



int main(){fastio
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll sum=0;
    rep(i,0,n-1)sum+=a[i];
    ll dp[2][sum+1];memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    rep(i,0,n-1){
        rep(j,0,sum)dp[(i+1)&1][j]=0;
        rep(j,0,sum){
            Add(dp[(i+1)&1][j],dp[i&1][j]*2);
            if(j+a[i]<=sum)Add(dp[(i+1)&1][j+a[i]],dp[i&1][j]);
        }
    }
    ll ans=1;rep(i,1,n)ans=mod(ans*3);
    ll del1=0;
    ll del2=0;
    rep(i,(sum+1)/2,sum){
        Add(del1,dp[n&1][i]);
    }
    /*
    rep(i,0,n){
        rep(j,0,sum)cout<<dp[i][j]<<" ";cout<<endl;
    }cout<<endl;
    */
    if(sum%2==1){
        cout<<mod(ans-del1*3)<<endl;return 0;
    }
    ll ep[2][sum+1];memset(ep,0,sizeof(ep));
    ep[0][0]=1;
    rep(i,0,n-1){
        rep(j,0,sum)ep[(i+1)&1][j]=0;
        rep(j,0,sum){
            Add(ep[(i+1)&1][j],ep[i&1][j]);
            if(j+a[i]<=sum)Add(ep[(i+1)&1][j+a[i]],ep[i&1][j]);
        }
    }
    /*
    rep(i,0,n){
        rep(j,0,sum)cout<<ep[i][j]<<" ";cout<<endl;
    }*/
    del2=ep[n&1][sum/2];
   // cout<<ans<<" "<<del1<<" "<<del2<<endl;
    cout<<mod(ans-del1*3+del2*3)<<endl;
    
    return 0;
}


/*
 729 201 8
 150
 */


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

using namespace std;

long long n, dp[5005], ma, x[2][3];
vector<int> v;

int main() {
	scanf("%lld", &n);
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 3; j++)
			scanf("%lld", x[i] + j);
	for (int i = 0; i < 3; i++)
		if (x[1][i] > x[0][i])
			for (int j = n; j >= 0; j--)
				for (int k = 1; j + k * x[0][i] <= n; k++)
					dp[j + k * x[0][i]] = max(dp[j + k * x[0][i]], dp[j] + k * (x[1][i] - x[0][i]));
	for (int i = 0; i <= n; i++)
		ma = max(ma, n + dp[i]);
	n = ma;
	if (n <= 5000) {
		ma = 0;
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < 3; i++)
			if (x[0][i] > x[1][i])
				for (int j = n; j >= 0; j--)
					for (int k = 1; j + k * x[1][i] <= n; k++)
						dp[j + k * x[1][i]] = max(dp[j + k * x[1][i]], dp[j] + k * (x[0][i] - x[1][i]));
		for (int i = 0; i <= n; i++)
			ma = max(ma, n + dp[i]);
	} else {
		for (int i = 0; i < 3; i++)
			if (x[0][i] > x[1][i])
				v.push_back(i);
		if (v.size() == 1) {
			ma = n / x[1][v[0]];
			ma = n + ma * (x[0][v[0]] - x[1][v[0]]);
		} else if (v.size() == 2) {
			ma = 0;
			for (long long i = 0; i * x[1][v[0]] <= n; i++) {
				long long tmp = (n - i * x[1][v[0]]) / x[1][v[1]];
				ma = max(ma, n + i * (x[0][v[0]] - x[1][v[0]]) + tmp * (x[0][v[1]] - x[1][v[1]]));
			}
		}
	}
	printf("%lld\n", ma);
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
#include <complex>
typedef complex<double> P;
double dot(P a, P b) {
	return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(P a, P b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}
int ccw(P a, P b,P c) {
	P e = b - a;
	P f = c - a;
	if (cross(e, f) > eps) {
		return 1;
	}
	if (cross(e, f) < -eps) {
		return -1;
	}
	if (dot(e, f) < -eps) return 2;
	if (abs(e) < abs(f)) return -2;
	return 0;
}
bool intersect(P a, P b, P c, P d) {
	if (ccw(a, b, c) * ccw(a, b, d) <= 0) {
		if (ccw(c, d, a) * ccw(c, d, b) <= 0){
			return 1;
		}
	}
	return 0;
}
int main() {
	int query;
	cin >> query;
	REP(i, query) {
		double a,b,c,d,e, f,g,h;
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
		cout << intersect(P(a, b), P(c, d), P(e, f), P(g, h)) << endl;
	}
	return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	vl v(n); rep(i,n) cin >> v[i];
	vpl od(100005,{0,0}),ev(100005,{0,0});
	for(ll i=0; i<n; i+=2){
		od[v[i]].first++;
		od[v[i]].second = v[i];
	}
	sort(rall(od));
	for(ll i=1; i<n; i+=2){
		ev[v[i]].first++;
		ev[v[i]].second = v[i];
	}
	sort(rall(ev));
	if(od[0].second != ev[0].second) cout << n-od[0].first-ev[0].first << endl;
	else{
		ll mx = max(od[1].first+ev[0].first,od[0].first+ev[1].first);
		cout << n-mx << endl;
	}
}

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

int main() {
  int a;
  int ret = 0;
  cin >> a;
  if(a >= 100) { ret += 1;}
  if(a >= 100){
    if((a-100)/10 >= 1) { ret +=1;}
  }
  else {
    if(a/10 >= 1) { ret +=1;}
  }
  if(a % 10 == 1) { ret += 1;}
  cout << ret << endl;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using bigint = boost::multiprecision::cpp_int;

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(ll, n);
  if (n % 2) {
    out(0);
  } else {
    ll ans = 0;
    ll fives = 1;
    while (bigint(fives) * 5 <= n) {
      fives *= 5;
      ans += n / fives / 2;
      // dbg(tens, cnt, ans);
    }
    out(ans);
  }
}


Measured memory_bytes: 256
N,C = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]

c1 = []
c2 = []
c1x = []
cumv = 0
c1max = -float('inf')
for x,v in src:
    cumv += v
    c1.append(cumv - x)
    c2.append(cumv - 2*x)
    c1max = max(c1max, c1[-1])
    c1x.append(c1max)

r1 = []
r2 = []
r1x = []
cumv = 0
r1max = -float('inf')
for x,v in reversed(src):
    cumv += v
    x = C-x
    r1.append(cumv - x)
    r2.append(cumv - 2*x)
    r1max = max(r1max, r1[-1])
    r1x.append(r1max)

ans = max(c1+r1+[0])
for i,c in enumerate(c2[:-1]):
    ans = max(ans, c + r1x[N-i-2])
for i,r in enumerate(r2[:-1]):
    ans = max(ans, r + c1x[N-i-2])

print(ans)


Measured memory_bytes: 37384
X, K, D = map(int, input().split())
if abs(X) > D*K:
    print(abs(X) - D*K)

else:
    k = abs(X) // D
    X = abs(X) % D
    K -= k
    if K % 2 == 0:
        print(X)
    else:
        print(D-X)


Measured memory_bytes: 9168
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

typedef long long LL;

bool ask(LL n){
    cout << "? " << n << endl;
    fflush(stdout);
    string s;
    cin >> s;
    if(s == "Y")
        return true;
    else
        return false;
}

LL power[15];

bool check(int mid, LL now, LL i){
    LL tmp = (now * 10 + mid) * power[i] + power[i] - 1;
    if(ask(tmp))
        return true;
    else
        return false;
}

int main(){
    power[0] = 1;
    for(int i = 1;i <= 15;i++){
        power[i] = power[i - 1] * 10LL;
    }
    LL now = 1;
    int digit = -1;
    for(int i = 1;i <= 12;i++){
        now *= 10;
        if(!ask(now)){
            digit = i;
            break;
        }
    }
    if(digit == -1){
        now = 0;
        for(int i = 1;i <= 12;i++){
            now = now * 10 + 9;
            if(ask(now)){
                digit = i;
                break;
            }
        }
    }
    now = 0;
    for(int i = digit;i >= 1;i--){
        int l, r;
        if(i == digit)
            l = 1, r = 9;
        else
            l = 0, r = 9;
        while(l < r){
            int mid = (l + r) / 2;
            if(check(mid, now, i)){
                r = mid;
            }else{
                l = mid + 1;
            }
        }
        now = now * 10 + l;
    }
    cout << "! " << now << endl;
    fflush(stdout);
    return 0;
}


Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

int main()
{
    int N,i;
    cin >> N;

    vector<ll> x(N+1);

    REPP(i,N+1){
        cin >> x[i];
    }

    REPP(i,N+1){
        x[i] = x[i]-(i+1);
    }
    sort(x.begin()+1, x.end());

    ll b = x[(N+1) /2];
   
    ll ans = 0;
    REPP(i,N+1){
        ans += abs(x[i]-b);
    }

    cout << ans << endl;
    return 0;    
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    int N,X;
    cin>>N>>X;
    int L[N];
    int T;
    T=0;
    for(int i=0;i<N;i++){
        cin>>L[i];
        T=T+L[i];
        if(T>X){
            cout<<i+1<<endl;
            return 0;
            
        }
    }
    cout<<N+1<<endl;
    
    
    return 0;
    
}

Measured memory_bytes: 256
import sys
n = int(sys.stdin.readline().rstrip("\n"))
s = 0
a = [0]*(10**6)
for z in sys.stdin.readline().rstrip("\n").split():
    z = int(z)
    a[z] += 1
    s += z
q = int(sys.stdin.readline().rstrip("\n"))
for i in range(q):
    b,c = map(int, sys.stdin.readline().rstrip("\n").split())
    d = c-b
    s += d*a[b]
    a[c] += a[b]
    a[b] = 0
    print(s)

Measured memory_bytes: 85420
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const ll MOD=1e9+7;
const int INF=1<<30;


using namespace std;

ll dat[1005][1005];

int main(){
	int r,c;
	string str[1005];
	cin>>r>>c;
	repp(i,0,r-1,1){
		cin>>str[i];
	}
	for(int i=r-1;i>=0;i--){
		for(int j=c-1;j>=0;j--){
			if(i==r-1&&j==c-1){
				dat[i][j]=1;
				continue;
			}
			if(str[i][j]=='.'){
				dat[i][j]=dat[i+1][j]+dat[i][j+1];
				dat[i][j]%=MOD;
			}
			else dat[i][j]=0;
		}
	}
	cout<<dat[0][0]<<endl;
	return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)

vector<int> d1{0,1,2};
vector<int> d2{1,2,0};

int main()
{
    vector<vector<int>> c(3, vector<int>(3, 0));
    
    REP(i,3){
        REP(j, 3){
            cin >> c[i][j];
        }
    }

    bool NG=false;
    REP(i,3){
        REP(j, 3){
            if(c[d1[i]][d1[j]]-c[d1[i]][d2[j]] != c[d2[i]][d1[j]]-c[d2[i]][d2[j]]) {
                NG=true;
                break;
            }
        if(NG) break;
        }
    }

    if(NG) cout << "No" << endl;
    else cout << "Yes" << endl;


   return 0;
}

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

using namespace std;

using ll = long long;

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

    ll n;
    cin >> n;

    string s;
    cin >> s;

    vector<ll>r;
    vector<ll>g;
    vector<ll>b;

    for(ll i=0;i<s.size();i++){
    	if(s[i] == 'R'){
    		r.push_back(i+1);
    	}
    	else if(s[i] == 'G'){
    		g.push_back(i+1);
    	}
    	else{
    		b.push_back(i+1);
    	}
    }

 //    cout << r.size() << "\n";

 //    for(ll i=0;i<r.size();i++){
 //    	cout << r[i] << " ";
 //    }
 //    cout << "\n";

	// cout << g.size() << "\n";

 //    for(ll i=0;i<g.size();i++){
 //    	cout << g[i] << " ";
 //    }
 //    cout << "\n";

 //    cout << b.size() << "\n";

 //    for(ll i=0;i<b.size();i++){
 //    	cout << b[i] << " ";
 //    }
 //    cout << "\n";

    ll sum1 = 0;
    for(ll i=0;i<r.size();i++){
    	for(ll j=0;j<g.size();j++){
    		if(g[j]-r[i] > 0){
    			ll x = g[j]-r[i];
    			ll y = r[i]+(2*x);

    			if(binary_search(b.begin(),b.end(), y)==1){
    				sum1++;
    			}
    		}
    	}
    }

     for(ll i=0;i<r.size();i++){
    	for(ll j=0;j<b.size();j++){
    		if(b[j]-r[i] > 0){
    			ll x = b[j]-r[i];
    			ll y = r[i]+(2*x);

    			if(binary_search(g.begin(),g.end(), y)==1){
    				sum1++;
    			}
    		}
    	}
    }

    for(ll i=0;i<b.size();i++){
    	for(ll j=0;j<g.size();j++){
    		if(g[j]-b[i] > 0){
    			ll x = g[j]-b[i];
    			ll y = b[i]+(2*x);

    			if(binary_search(r.begin(),r.end(), y)==1){
    				sum1++;
    			}
    		}
    	}
    }

	for(ll i=0;i<g.size();i++){
    	for(ll j=0;j<b.size();j++){
    		if(b[j]-g[i] > 0){
    			ll x = b[j]-g[i];
    			ll y = g[i]+(2*x);

    			if(binary_search(r.begin(),r.end(), y)==1){
    				sum1++;
    			}
    		}
    	}
    }  

    for(ll i=0;i<g.size();i++){
    	for(ll j=0;j<r.size();j++){
    		if(r[j]-g[i] > 0){
    			ll x = r[j]-g[i];
    			ll y = g[i]+(2*x);

    			if(binary_search(b.begin(),b.end(), y)==1){
    				sum1++;
    			}
    		}
    	}
    }

    for(ll i=0;i<b.size();i++){
    	for(ll j=0;j<r.size();j++){
    		if(r[j]-b[i] > 0){
    			ll x = r[j]-b[i];
    			ll y = b[i]+(2*x);

    			if(binary_search(g.begin(),g.end(), y)==1){
    				sum1++;
    			}
    		}
    	}
    }
    //cout << sum1 << "\n";

    ll ans = (r.size()*g.size()*b.size()) - sum1;
    cout << ans << "\n";

	return 0;
}

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

void solve()
{
	int n;
	cin >> n;
	unordered_map<int, int> m;

	for(int i = 1; i < n; ++i)
	{
		int a;
		cin >> a;
		m[a]++;
	}
	for(int i = 1; i <= n; ++i)
	{
		cout << m[i] << endl;
	}
}

int main()
{
	solve();

	return 0;
}


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

struct BOX {
  string top;
  string back, left, right, head;
  string buttom;
  bool operator==(const BOX& b) const {
    return(top    == b.top   &&
           back   == b.back  &&
           left   == b.left  &&
           right  == b.right &&
           head   == b.head  &&
           buttom == b.buttom);
  }
};
class UnionFind{
private:
  vector< int > rank, p;
  void link(int x,int y){
    if(rank[x] > rank[y]){
      p[y] = x;
    }else{
      p[x] = y;
      if(rank[x] == rank[y]) rank[y]++;
    }
  }
public:
  UnionFind(int size){
    rank.resize(size,0);
    p.resize(size,0);
    for(int i = 0; i < rank.size(); i++){
      p[i] = i, rank[i] = 0;
    }
  }
  void Unite(int x,int y){
    if(Find(x) != Find(y)) link(Find(x),Find(y));
  }
  int Find(int x){
    return( x != p[x] ? p[x] = Find(p[x]) : p[x]);
  }
};

void Roll(BOX& B)
{
  string temp = B.head;
  B.head = B.right;
  B.right = B.back;
  B.back = B.left;
  B.left = temp;
}
 
void RoLL(BOX& B) {
  string temp = B.head;
  B.head = B.top;
  B.top = B.back;
  B.back = B.buttom;
  B.buttom = temp;
}
void RolL(BOX& B) {
  string temp = B.left;
  B.left = B.top;
  B.top = B.right;
  B.right = B.buttom;
  B.buttom = temp;
}
 
 
bool Myon(BOX& a, BOX& b)
{
  for(int k = 0; k < 4; k++) {
    Roll(a);
    for(int l = 0; l < 4; l++) {
      RoLL(a);
      for(int m = 0; m < 4; m++) {
        RolL(a);
        if(a == b) return(true);
      }
    }
  }
  return(false);
}

int main()
{
  int n;
  vector< BOX > boxes;
  while(cin >> n, n) {
    UnionFind uf(n);

    boxes.resize(n);
    int ret = 0;

    for(int i = 0; i < n; i++) {
      BOX &b = boxes[i];
      cin >> b.top >> b.head >> b.right >> b.left >> b.back >> b.buttom;
    }
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        if(Myon(boxes[i], boxes[j])) uf.Unite(i, j);
      }
    }
    for(int i = 0; i < n; i++) {
      ret += uf.Find(i) == i;
    }
    cout << n - ret << endl;
  }
}

Measured memory_bytes: 1232
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

int checker[4];
int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	int check[4];
	State() {check[0]=0;check[1]=0;check[2]=0;check[3]=0;}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
	}
};


inline bool operator< ( const State& a, const State& b) {
/*
	if( a.enemy == b.enemy )
		return a.budget > b.budget;
		*/
	return a.enemy < b.enemy;
}

inline bool operator> ( const State& a, const State& b) {
/*
	if ( a.enemy == b.enemy )
		return a.budget < b.budget;
		*/
	return a.enemy > b.enemy;
}

priority_queue<State, deque<State>, greater<State> > status;

inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}

inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
	}
}

int main () {


	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

		for ( int i=0; i<m; i++ ) {
			int a,b,d,e;
			cin >> a >> b >> d >> e;

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}

		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}

		priority_queue<State, deque<State>, greater<State> > empty;
		status = empty;

		ncheck[0] = 1;
		status.push(State(0,0,l));
		int count = 0;
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {
					if ( check( i ) ) {
						ncopy();
						add(i);
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
					}
				}
			}
		}
	}
}

		

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

int main() {
  
  int H,W;
  cin >> H >> W;
  
  vector<vector<char>> vec2(H, vector<char>(W, '#'));
  for (int i=0; i<vec2.size()/*==H*/; i++) {
    for (int j=0; j<vec2.at(i).size()/*==W*/; j++) cin >> vec2.at(i).at(j);
  }
  
  for (int i=0; i<vec2.size()/*==H*/; i++) {
    int s=1;
    for (int j=0; j<vec2.at(i).size()/*==W*/; j++) {
      if (vec2.at(i).at(j)=='.') s*=1;
      else s*=0;
    }
    if (s==1) {
      for (int j=0; j<vec2.size()-i-1; j++) vec2.at(i+j)=vec2.at(i+j+1);
      vec2.pop_back();
      i-=1;
    }
  }
  
  for (int i=0; i<vec2.at(0).size()/*==W*/; i++) {
    int s=1;
    for (int j=0; j<vec2.size()/*<=H*/; j++) {
      if (vec2.at(j).at(i)=='.') s*1;
      else s*=0;
    }
    if (s==1) {
      for (int j=0; j<vec2.at(0).size()-i-1; j++) {
        for (int k=0; k<vec2.size(); k++) vec2.at(k).at(i+j)=vec2.at(k).at(i+j+1);
      }
      for (int k=0; k<vec2.size(); k++) vec2.at(k).pop_back();
      i-=1;
    }
  }
  
  for (int i=0; i<vec2.size(); i++) {
    for (int j=0; j<vec2.at(i).size(); j++) cout << vec2.at(i).at(j);
    cout << endl;
  }
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;cin>>k;
  int tot=0;
  for(int i=1;i<=k;i++)for(int j=1;j<=k;j++){
        int tmp=gcd(i,j);      
        for(int l=1;l<=k;l++)tot+=gcd(tmp,l);
  }
  cout<<tot<<endl;
  return 0;
}


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

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

  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; ++i) {
    cin >> h.at(i);
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (h.at(i) >= K) ans++;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
def complain(comp,c,k,last_hold,i):
    # print(k)
    if(k > 26):
        # print("___")
        return comp
    comp += c[k-1]*((i+1) - last_hold[k-1]) 
    k += 1
    # print(comp,"comp")
    return complain(comp,c,k,last_hold,i)

# Σ(Ci * (d - last(d,i)))
# (1~26)


D = int(input())
c = list(map(int,input().split()))
s = ["_"]*(D)
scorelist = ["_"]*D

# print(c)
for i in range(D):
    scorelist[i] = ["_"]*26
    s[i] = list(map(int,input().split()))
    for j in range(26):
        scorelist[i][j] = [s[i][j],j]
# print(scorelist)
last_hold = [0]*26
score = [0]*D
for i in range(D):
    greedy = max(scorelist[i], key = lambda x:x[0])
    t = greedy[1]
    score[i] = greedy[1]+1
for i in range(len(score)):
    print(score[i])

Measured memory_bytes: 10312
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
#define fo(i,n) for( ll int i=0;i<n;++i)
#define fos(j,i,n) for(ll int j=i;j<n;++j)
#define N 100004
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define abs(x) ((x)<0?(-(x)):(x))
#define dis(k) cout << k << endl
#define forr(i,n) for( ll int i= n-1;i>=0;--i)
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define ve vector
#define fi first
#define se second
#define setzero(a) memset(a,0,sizeof(a))
#define setinf(a) memset(a,0x7F,sizeof(a))
typedef ve< ll > vi;
typedef ve< vi > vvi;
typedef pair< ll ,ll > ii;
void solve(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  fo(i,n) cin >> a[i];
  ll p=0;
  fo(i,k) p+=a[i];
  ll pr=p;
  fos(i,k,n){
    pr=p;
    p-=a[i-k];
    p+=a[i];
    if(p>pr) dis("Yes");
    else dis("No");
  }
}

 
 
int main(){
	fast;
	int t=1;
	//cin >> t;
 
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 5216
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

double a[1000];
signed main(){
    int n;
    double ans = 0;
    cin >> n;
    rep(i,n){
        cin >> a[i];
        ans += (double)1/a[i];
    }   
    ans =(double)1/ans;
    cout <<fixed<< ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];

  scanf("%lld",&n);
  while(n >= 10){
    if(n % 10 == 7) result = 1;
    n /= 10;
  }
  if(n == 7) result = 1;
  
  if(result == 1) printf("Yes");
  else printf("No");

  return 0;
}



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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;



typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    ivec v(n), ind(n);
    for(int i=0; i<n; i++) cin >> v[i];
    for(int i=0; i<n; i++) ind[v[i]-1] = i+1;
    for(int i=0; i<n; i++) cout << ind[i] << ' ';
    cout << endl;
};

Measured memory_bytes: 1664
#include <iostream>
#define llint long long int

using namespace std;

llint N;
llint a[55];
llint next_a[55];

int main(void)
{
	cin >> N;
	for(llint i = 0; i < N; i++){
		cin >> a[i];
	}
	
	bool flag;
	llint ans = 0;
	
	while(1){
		flag = true;
		for(llint i = 0; i < N; i++){
			if( a[i] > N-1 ){
				flag = false;
				break;
			}
		}
		if(flag) break;
		
		for(llint i = 0; i < N; i++) next_a[i] = 0;
		for(llint i = 0; i < N; i++){
			llint val = a[i] / N;
			a[i] %= N;
			ans += val;
			
			for(llint j = 0; j < N; j++){
				if(i == j) continue;
				next_a[j] += val;
			}
		}
		for(llint i = 0; i < N; i++) a[i] += next_a[i];
	}
	
	cout << ans << endl;
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int 
#define append push_back
#define mp make_pair
#define endl "\n"
#define MOD 1e9+7 

template <typename T>
void print(T AA[], int nn){for(int ii=0; ii<nn; ii+=1){cout<<AA[ii]<<" ";}cout<<endl;}
template <typename T> inline void print(T nn){ cout << nn << endl;}
/* ----------------------------------------------------------------------------------- */

string s, t;
int n1, n2;
int cache[3005][3005];

int fn(int i, int j){
    if(i==n1 || j==n2) return 0;
    if(cache[i][j] != -1) return cache[i][j];
    int ans = 0;
    if(s[i]==t[j]) ans = 1 + fn(i+1, j+1);
    else ans = max(fn(i+1, j), fn(i, j+1));
  	cache[i][j] = ans;
    return ans;    
}

void path(int i, int j){
    if(i==n1 || j==n2) return;
    if(s[i]==t[j]){
        cout << s[i];
        return path(i+1, j+1);
    }
    else{
        if(fn(i, j)==fn(i+1, j)) return path(i+1, j);
        else return path(i, j+1);
    }
}

int32_t main(){

    IOS
    
    memset(cache, -1, sizeof(cache));
    cin >> s >> t;
    n1 = s.size();
    n2 = t.size();

    int k = fn(0, 0);
    if(k==0) print(" ");
    else path(0, 0);

    return 0;
}


Measured memory_bytes: 71168
import Text.Printf
import Control.Applicative

main = do
  ss <- (map stoi . words) <$> getLine
  let a = (ss !! 0)
      b = (ss !! 1)
  printf "%d %d\n" (a * b) (2 * (a + b))

stoi :: String -> Int
stoi str = read str :: Int

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int dp[10000][10000];

string lcs(string x,string y,int n,int m){
    for(int i=0;i<n+1;i++){
        for(int j=0;j<m+1;j++)
            if(i==0 || j==0)
            dp[i][j] = 0;
    }
    //choice diagram
    for(int i=1;i<n+1;i++){
        for(int j=1;j<m+1;j++)
            if(x[i-1]==y[j-1])
                dp[i][j] = 1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
    }
    int i=n,j=m;
    string s;
    while(i>0&&j>0){
        if(x[i-1]==y[j-1]){
            s.push_back(x[i-1]);
            i--,j--;
        }
        else{
            if(dp[i-1][j] > dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    reverse(s.begin(),s.end());
    return s;
}
int main(){
    memset(dp,-1,sizeof(dp));   //fill dp to -1
    string x,y;
    cin>>x>>y;
    cout<<lcs(x,y,x.size(),y.size());
    return 0;
}


Measured memory_bytes: 394232
def ext_gcd(p, a):
  #require a, m be relative prime
  #m > a  
  if a == 0:
    return 1, 0
  else:
    x1, y1 = ext_gcd(a, p%a)
    y = x1 - y1 * int(p/a)
    x = y1
    return x, y

x, y = map(int, input().split())

n = (2 * y - x)/3
m = (2 * x - y)/3

if n != int(n) or m != int(m) or n<0 or m<0:
  ans = 0
else:
   n = int(n)
   m = int(m)
   if n < m :
      c = m
      m = n
      n = c
   # (n+m!)/(n!)(m!) mod (1e9+7)
   ans = 1
   prime = 1000000007 
   for i in range(n+1,m+n+1):
        ans = int(ans * i) 
        ans = (ans % prime)
   for i in range(1, m+1):
      ori_inv = int(ext_gcd(prime, i)[1])
      while ori_inv < 0 :
        ori_inv += prime
      ans = int(ans * ori_inv)  
      ans = (ans % prime)
print(ans)


Measured memory_bytes: 3188
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(int a, int b)
{
   return a < b;
}
priority_queue<int, vector<int>, function<bool(int, int)>> pq(Compare);

vi pr;
void seive(){
	int p[100005]={0};
	f(i,2,100005){
		if(p[i]==0){
			pr.pb(i);
			for(int j=i*2;j<100005;j+=i) p[j]=1;
		}
	}
}

// https://codeforces.com/blog/entry/79048



void solve(){
	int n,x,t; cin>>n>>x>>t;
	cout<<((n+x-1)/x)*t;	
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!

Measured memory_bytes: 3616
from collections import defaultdict
def main():
    ls = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    dic_str = defaultdict(int)
    dic_num = defaultdict(str)
    for i,st in enumerate(ls):
        dic_str[i] = st
        dic_num[st] = i
    n = int(input())
    s = input()
    ans = ""
    for i in s:
        num = dic_num[i]
        if num+n>25:
            num -= 26
        ans = ans + str(dic_str[int(num)+n])
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 41964
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int n,h[25];
int main(int argc,char const* argv[])
{
  int ans=1;
  cin >> n;
  for(int i=0;i<n;i++)
    {
      cin >> h[i];
    }
  if(n==1)
    {
      cout << 1 << endl;
      return 0;
    }
  for(int i=1;i<n;i++)
    {
      bool cansee=true;
      for(int j=0;j<i;j++)
	{
	  if(h[j]>h[i])
	    {
	      cansee=false;
	    }
	}
      if(cansee) ans++;
    }
  cout << ans << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  cout << s[0] << s[1] << s[2] << s[3] << " " << s[4] << s[5] << s[6] << s[7] << s[8] << s[9] << s[10] << s[11] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element) != container.end())
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(c) c.begin(), c.end()
#define pb push_back
#define mp make_pair
#define mod (1000000000 + 7)
#define inf (1e10+9)
#define fi first
#define se second
#define MAXN   1000001 
typedef long long ll;
using namespace std;
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_set;

long long fastpow(long long n, long long x, long long m){
	
    long long ret = 1;
    
    while(x){
    if(x&1) (ret*=n)%=m;
    x>>=1;
    (n*=n)%=m;
    }
  
 return ret;
}
ll add(ll a,ll b){
	return((a%mod)+(b%mod))%mod;
}
ll prod(ll a,ll b){
	a%=mod;
	b%=mod;
	return ((a%mod)*(b%mod)%mod);
}
int main()
{
	ss
    ll a,b,c,d;
    cin>>a>>b;
    cin>>c>>d; 
    int f=0,g=0;
    int i=0;
    while(!f&&!g){
    	if(i%2==0){
    		c-=b;
    		if(c<=0) g=1;
		}
		else{
			a-=d;
			if(a<=0) f=1;
		}
		i++;
	}
	if(g){
		cout<<"Yes\n";
	}
	else cout<<"No\n";
    
    
    
    
    
   
    return  0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int n;
  string s;
  cin >> n >> s;
  
  int retval;
  for(int i =0; i < s.size(); i++){
    s[i] += n;
    if((int)s[i] > 90) s[i] -= 26;
  }
  cout << s;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
const int N=1e5+5;
vector<int> getdp[N],topoo,adj[N];
bool used[N];
int dp[N];
void buildtopo(int x){
	for(int i=0;i<adj[x].size();i++){
		if(!used[adj[x][i]]){
			used[adj[x][i]]=true;
			buildtopo(adj[x][i]);
		}
	}
	topoo.push_back(x);
}
int main(){
	int n,m,i,j,k,max1=0;
	cin>>n>>m;	
	for(i=1;i<=m;i++){
		cin>>j>>k;
		getdp[k].push_back(j);
		adj[j].push_back(k);
	}
	for(i=1;i<=n;i++){
		if(!used[i]){
			used[i]=true;
			buildtopo(i);
		}
	}
	for(i=topoo.size()-1;i>=0;i--){
		for(j=getdp[topoo[i]].size()-1;j>=0;j--){
			dp[topoo[i]]=max(dp[getdp[topoo[i]][j]]+1,dp[topoo[i]]);
		}
		max1=max(max1,dp[topoo[i]]);
	}
	cout<<max1;
}


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

const int N = 2e5+55;
int n, a[N];
long long solve(int x){
  long long res = 0;
  for(int i = 1; i <= n; ++i){
    res += abs(a[i]-x);
  }
  return res;
}
int main(){
  ios::sync_with_stdio(0), cin.tie(0);
#ifndef ONLINE_JUDGE
//  freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
  cin >> n;
  for(int i = 1; i <= n; ++i){
    cin >> a[i];
    a[i] -= i;
  }
  sort(a+1, a+n+1);
  if(n&1) cout << solve(a[(n+1)/2]) << '\n';
  else cout << min(solve(a[(n-1)/2]), solve(a[n/2])) << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
#define N 25100

int n,k,m,now,mx;
ll tot,ans,f[N][405],g[N][405],fac[N];
int a[N],v[N];

ll power(ll x,ll y) {
	ll ret=1;
	for (;y;y>>=1,x=x*x%mod)
		if (y&1) ret=ret*x%mod;
	return ret;
}

int main()
{
	scanf("%d%d%d",&n,&k,&m);
	fac[0]=1; for (int i=1;i<=k;i++) fac[i]=fac[i-1]*i%mod;
	tot=(n-m+1)*power(k,n-m)%mod;
	for (int i=1;i<=m;i++) {
		scanf("%d",&a[i]);
		now=min(now+1,i-v[a[i]]);
		v[a[i]]=i;
		mx=max(mx,now);
	}
	if (mx==k) return printf("%lld\n",tot),0;
	if (mx==m) {
		f[0][0]=1;
		for (int i=1;i<=n;i++) {
			ll s=0,t=0;
			for (int j=k-1;j;j--) {
				s=(s+f[i-1][j])%mod;
				t=(t+g[i-1][j])%mod;
				f[i][j]=(f[i][j]+f[i-1][j-1]*(k-j+1)+s)%mod;
				g[i][j]=(g[i][j]+g[i-1][j-1]*(k-j+1)+t)%mod;
				if (j>=m) g[i][j]=(g[i][j]+f[i][j])%mod;
			}
		}
		for (int i=1;i<k;i++) ans=(ans+g[n][i])%mod;
		ans=ans*fac[k-m]%mod*power(fac[k],mod-2)%mod;
		printf("%lld\n",(tot-ans+mod)%mod);
	} else {
		int lc=0,rc=0;
		memset(v,0,sizeof(v));
		for (int i=1;i<=m;i++) {
			if (!v[a[i]]) lc++; else break;
			v[a[i]]=1;
		}
		memset(v,0,sizeof(v));
		for (int i=m;i;i--) {
			if (!v[a[i]]) rc++; else break;
			v[a[i]]=1;
		}
		f[0][lc]=g[0][rc]=1;
		for (int i=1;i<=n;i++) {
			ll s=0,t=0;
			for (int j=k-1;j;j--) {
				s+=f[i-1][j],t+=g[i-1][j];
				f[i][j]=(f[i][j]+f[i-1][j-1]*(k-j+1)+s)%mod;
				g[i][j]=(g[i][j]+g[i-1][j-1]*(k-j+1)+t)%mod;
			}
		}
		for (int i=0;i<=n-m;i++) {
			ll s=0,t=0;
			for (int j=1;j<k;j++) s=(s+f[i][j])%mod,t=(t+g[n-m-i][j])%mod;
			tot=(tot-s*t%mod+mod)%mod;
		}
		printf("%lld\n",tot);
	}
	return 0;
}

Measured memory_bytes: 158976
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 998244353;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N),B(N);
    for(int i=0;i<N;i++) cin >> A[i];
    priority_queue<Pll> Q;
    for(int i=0;i<N;i++) {
        cin >> B[i];
        if(B[i]!=A[i])Q.push(Pll(B[i],i));
    }
    queue<ll> que;
    bool jg=false;
    for(int i=0;i<N;i++) {
        ll tmp;
        if(i==0){
            tmp=B[0]-(B[N-1]+B[1]);
        }
        else if(i==N-1){
            tmp=B[N-1]-(B[0]+B[N-2]);
        }
        else tmp=B[i]-(B[i-1]+B[i+1]);

        if(tmp>=A[i]) {
            jg = true;
            //que.push(i);
        }
    }
    

    if(jg==false){
        cout << "-1" << endl;
        return 0;
    }
    
    ll ans=0;
    ll ct=0;
    while(!Q.empty()){
        Pll tp = Q.top();
        Q.pop();
        ll idx = tp.second;
        ll tmp;
        if(idx==0){
            tmp=(B[N-1]+B[1]);
        }
        else if(idx==N-1){
            tmp=(B[0]+B[N-2]);
        }
        else tmp=(B[idx-1]+B[idx+1]);

        ll m = ((B[idx]-A[idx])/tmp);
        B[idx] = B[idx]-m*tmp;

        ans+=m;
        if(m==0){
            ct++;
        }
        else ct=0;
        if(ct>=N){
            cout << "-1" << endl;
            return 0;
        }
        if(B[idx]!=A[idx]) {
            Q.push(Pll(B[idx],idx));
        }
    }
    /*
    while(!que.empty()){
        ll idx = que.front();
        que.pop();
        ll tmp;
        if(idx==0){
            tmp=(B[N-1]+B[1]);
        }
        else if(idx==N-1){
            tmp=(B[0]+B[N-2]);
        }
        else tmp=(B[idx-1]+B[idx+1]);

        ll m = ((B[idx]-A[idx])/tmp);
        B[idx] = B[idx]-m*tmp;

        ans+=m;
        if(B[idx]!=A[idx]) {
            que.push(idx);
        }
        if(B[(idx+1)%N]!=A[(idx+1)%N] && B[(idx+1)%N]-(B[idx]+B[(idx+2)%N])>A[(idx+1)%N]){
            que.push((idx+1)%N);
        }
        if(B[(idx-1+N)%N]!=A[(idx-1+N)%N] && B[(idx-1+N)%N]-(B[idx]+B[(idx-2+N)%N])>A[(idx-1+N)%N]){
            que.push((idx-1+N)%N);
        }
    }*/

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9456