akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <utility>
#include <cmath>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	outl((int) ceil(log(in()) / log(3)));
}


Measured memory_bytes: 2860
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll B=1e6+7;
const ll mod=1e9+7,mod2=998244353;
ll t_mod(ll x,ll m){
  if(x>=0) return x%m;
  else{
    ll x2=x*(-1);
    x2/=m;
    x2+=2;
    return (x+m*x2)%m;
  }
}
vector<ll> contain(string b,string a){
  int al=a.length(),bl=b.length();

  ll t=1,t2=1,t3=1;
  for(int i=0;i<al;i++) {
    t*=B;
    t%=mod;
    t2*=B;
    t2%=mod2;
//    t3*=B;
//    t3%=mod3;
  }

  ll ah=0,bh=0,ah2=0,bh2=0,ah3=0,bh3=0;
  for(int i=0;i<al;i++) {
    ah=ah*B+a[i];
    ah%=mod;
    ah2=ah2*B+a[i];
    ah2%=mod2;
//    ah3=(ah3*B)%mod3+a[i];
//    ah3%=mod3;
  }
  for(int i=0;i<al;i++) {
    bh=(bh*B)+b[i];
    bh%=mod;
    bh2=(bh2*B)+b[i];
    bh2%=mod2;
//    bh3=(bh3*B)%mod3+b[i];
//    bh3%=mod3;
  }

  vector<ll> ans;
  for(int i=0;i+al<=bl;i++){
    if(ah==bh&&ah2==bh2/*&&ah3==bh3*/) {
      ans.push_back(i);
    }
    if(i+al<bl){
      bh=bh*B+b[i+al]-b[i]*t;
      bh=t_mod(bh,mod);
      bh2=bh2*B+b[i+al]-b[i]*t2;
      bh2=t_mod(bh2,mod2);
//      bh3=(bh3*B)%mod3+b[i+al]-b[i]*t3;
//      bh3=t_mod(bh3,mod3);
    }
  }
  return ans;
}
vector<ll> all_ans[200005];
int main(){
  int n;
  cin>>n;
  vector<ll> a,b;
  for(int i=0;i<n;i++) all_ans[i].push_back(0);
  for(int i=0;i<n;i++){
    ll k;
    scanf("%lld",&k);
    a.push_back(k);
  }
  for(int i=0;i<n;i++){
    ll k;
    scanf("%lld",&k);
    b.push_back(k);
  }
  for(int bi=0;bi<30;bi++){
    string rev,nrev,goal;
    for(int i=0;i<n;i++){
      ll ft=((a[i]>>bi)&1);
      if(ft){
        rev.push_back('a');
        nrev.push_back('b');
      }
      else{
        rev.push_back('b');
        nrev.push_back('a');
      }
    }
    for(int i=0;i<n;i++){
      ll ft=((b[i]>>bi)&1);
      if(ft) goal.push_back('a');
      else goal.push_back('b');
    }
    for(int i=0;i<n;i++){
      goal.push_back(goal[i]);
    }

    vector<ll> v1=contain(goal,rev),v2=contain(goal,nrev);
    vector<ll> bv1(200005,0),bv2(200005,0);
    for(int i=0;i<v1.size();i++) bv1[v1[i]]++;
    for(int i=0;i<v2.size();i++) bv2[v2[i]]++;
    ll bt=(1<<bi);
    for(int i=0;i<n;i++){
      queue<ll> kans;
      for(int j=0;j<all_ans[i].size();j++){
        if(bv1[i]==1) kans.push(all_ans[i][j]);
      }
      for(int j=0;j<all_ans[i].size();j++){
        if(bv2[i]==1) kans.push(all_ans[i][j]+bt);
      }
      ll js=all_ans[i].size()-1;
      for(;js>=0;js--) all_ans[i].pop_back();
      while(!kans.empty()){
        all_ans[i].push_back(kans.front());
        kans.pop();
      }
    }
  }
  vector<P> ans_v;
  for(int i=0;i<n;i++){
    for(int j=0;j<all_ans[i].size();j++){
      ans_v.push_back(P((n-i)%n,all_ans[i][j]));
    }
  }
  sort(ans_v.begin(),ans_v.end());
  for(int i=0;i<ans_v.size();i++) printf("%lld %lld\n",ans_v[i].first,ans_v[i].second);
  //cout<<endl;
}


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

int main(){
int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D) cout << "Left" << endl;
  else if(A + B < C + D) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
def gcd(a,b):
	while b:
		a,b=b,a%b
	return a
n=int(input())
l = list(map(int, input().split()))
ans=1;
m=[0]*(n+1)
o=[0]*(n+1)
for i in range(n):
	m[i+1]=gcd(m[i],l[i])
	o[i+1]=gcd(o[i],l[n-i-1])
for i in range(n):
	ans=max(gcd(m[i],o[n-i-1]),ans)
print(ans)

Measured memory_bytes: 14584
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;
ll sig(ll num){
    num=(num*(num+1))/2;return num;
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n;cin>>n;ll sum=0;
        for(ll i=1;i<=n;i++){
            sum+=i*sig((n/i));
        }
        cout<<sum;
}


Measured memory_bytes: 3664
h,w=map(int,input().split())
l=[list(input().rstrip()) for i in range(h)]
#print(l)
dx=[1,0,-1,0]
dy=[0,1,0,-1]
for i in range(w):
    for j in range(h):
        for k in range(4):
            if l[j][i]=='#' and 0<=i+dx[k]<w and 0<=j+dy[k]<h:
                if l[j+dy[k]][i+dx[k]]!='.':
                    l[j][i]=1
#print(l)
for i in range(w):
    for j in range(h):
        if l[j][i]=="#":
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3064
a, b, h, m = map(int, input().split())

import math

pi = math.pi
omegah = (2 * pi) / (12 * 60)   #rad/min
omegam = (2 * pi) / 60 #rad/min
time_min = h * 60 + m
radh = omegah * time_min
radm = omegam * m
if abs(radh - radm) <= pi:
    rad_def = abs(radh - radm)
else:
    rad_def = 2 * pi - abs(radh - radm)

def lcos(p, q, theta):
    r = math.sqrt(p**2 + q**2 - 2*p*q*math.cos(theta))
    return r

c = lcos(a, b, rad_def)
print(c)

Measured memory_bytes: 62604
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define MAX 200005

int N,M;
ll table[MAX],count_table[MAX];

int main(){

	for(int i = 0; i < MAX; i++){

		table[i] = 0;
		count_table[i] = 0;
	}

	scanf("%d %d",&N,&M);

	ll sum = 0,tmp,minimum = BIG_NUM,maximum = -BIG_NUM;

	for(int i = 0; i < N; i++){

		scanf("%lld",&tmp);

		minimum = min(minimum,tmp);
		maximum = max(maximum,tmp);

		table[tmp]++;
		sum += tmp;
	}

	sum *= M;

	for(int i = 1; i < MAX; i++){

		table[i] += table[i-1];
	}

	ll left = BIG_NUM,right = -BIG_NUM;

	for(int i = 0; i < M; i++){

		scanf("%lld",&tmp);

		left = min(left,tmp);
		right = max(right,tmp);

		count_table[tmp]++;
	}

	for(ll i = left; i <= right; i++){

		if(count_table[i] == 0)continue;

		for(ll k = 1; i*k <= maximum; k++){

			ll L,R;

			L = i*k-1;

			if(i*(k+1)-1 >= MAX){

				R = MAX-1;
			}else {
				R = i*(k+1)-1;
			}

			sum -= (table[R]-table[L])*i*k*count_table[i];
		}
	}

	printf("%lld\n",sum);

	return 0;
}



Measured memory_bytes: 6340
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k)
    cout << s << endl;
  else {
    string sub = s.substr(0, k);
    cout << sub << "..." << endl;
  }
}

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

const int MAXN = 1e5+5;
const int INF = 1e9+7;
int a[MAXN];
// The minimum we can get from i to 0 house
int main()
{
    int n,k;cin >> n >> k;
    vector<int> dp(n,INF);
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    dp[0] = 0;
    for(int i=1;i<n;++i){
        for(int j=1;j<=k;++j){
            int now = i-j;
            if(now>=0) dp[i] = min(dp[i],dp[now]+abs(a[i]-a[now]));
        }
    }
    cout << dp[n-1];
}


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

#define rep(i,n) for(int i =0; i <n; ++i)

#define rrep(i,n) for(int i =n; i >=0; --i)

#define rep_(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

#define ll long long

//const ll MOD = 1000000007;

//const  long double PI=(acos(-1));

//const  long double EPS=0.0000000001;

int main(){
    int h,w,n;cin >> h >> w >> n;

    if(h > w){
        int ans = n/h;
        if(n%h==0)cout << ans << endl;
        else cout << ans+1 << endl;
    }
    else{
        int ans = n/w;
        if(n%w==0)cout << ans << endl;
        else cout << ans +1 << endl;
    }

    return 0;
}

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

int main() {

	string s, t;
	cin >> s >> t;
	int n = (int)s.size(), m = (int)t.size();

	vector<vector<int>> dp(n + 1, vector<int>(m + 1, -1));
	vector<vector<pair<int,int>>> dp_string(n + 1, vector<pair<int,int>>(m + 1, {-1, -1}));
	dp[0][0] = 0;

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(s[i] == t[j] && dp[i][j] + 1 > dp[i + 1][j + 1]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
				dp_string[i + 1][j + 1] = make_pair(i, j);
			}
			if(dp[i][j] > dp[i + 1][j]) {
				dp[i + 1][j] = dp[i][j];
				dp_string[i + 1][j] = make_pair(i, j);
			}
			if(dp[i][j] > dp[i][j + 1]) {
				dp[i][j + 1] = dp[i][j];
				dp_string[i][j + 1] = make_pair(i, j);
			}
		}
	}

	int mx = 0;
	pair<int,int> ans = {0, 0};

	for(int i = 0; i < n; i++) {
		if(dp[i][m] > mx) {
			ans = make_pair(i, m);
			mx = dp[i][m];
		}
	}

	for(int i = 0; i < m; i++) {
		if(dp[n][i] > mx) {
			ans = make_pair(n, i);
			mx = dp[n][i];
		}
	}

	if(dp[n][m] > mx) {
		ans = make_pair(n, m);
		mx = dp[n][m];
	}

	string s_ans = "";
	while(ans.first >= 0 && ans.second >= 0) {
		int i = ans.first, j = ans.second;
		pair<int,int> nxt_ans = dp_string[i][j];

		if(nxt_ans.first == i - 1 && nxt_ans.second == j - 1) {
			if(i - 1 >= 0) s_ans += s[i - 1];
			assert(s[i - 1] == t[j - 1]); 
		}

		ans = nxt_ans;
	}

	assert(mx == (int)s_ans.size());
	reverse(s_ans.begin(), s_ans.end());
	cout << s_ans << endl;
}


Measured memory_bytes: 106112
#include <stdio.h>

int main(void) {
	double a, b;
	double s[7] = {35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0};
	double t[7] = {71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0};
	while (scanf("%lf %lf", &a, &b) != EOF) {
		if (a < s[0] && b < t[0])
			printf("AAA\n");
		else if (a < s[1] && b < t[1])
			printf("AA\n");
		else if (a < s[2] && b < t[2])
			printf("A\n");
		else if (a < s[3] && b < t[3])
			printf("B\n");
		else if (a < s[4] && b < t[4])
			printf("C\n");
		else if (a < s[5] && b < t[5])
			printf("D\n");
		else if (a < s[6] && b < t[6])
			printf("E\n");
		else
			printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;

#define INF (1LL<<60)
typedef pair<int, int> P;

int M, N, K;
P T[200010];
long long D[200010];
vector<int> xs[100010], ys[100010];

int main() {
  cin >> M >> N >> K;

  T[0] = P(M, N);
  xs[M].push_back(0);
  ys[N].push_back(0);

  for (int i=1; i<K+1; i++) {
    int x, y;
    cin >> x >> y;
    T[i] = P(x, y);
    if (x != M || y != N) {
      xs[x].push_back(i);
      ys[y].push_back(i);
    }
  }

  for (int i=0; i<K+1; i++) D[i] = INF;

  queue<P> q;
  for (int i : xs[1]) {
    D[i] = T[i].second - 1;
    q.push(P(i, 0));
  }

  while (!q.empty()) {
    int s = q.front().first, d = q.front().second; q.pop();
    P p = T[s];

    if (d == 1) {
      for (int i : xs[p.first]) {
        if (i == s) continue;
        P t = T[i];
        long long l = abs(t.second - p.second) + 1LL;
        if (D[i] > D[s] + l) {
          D[i] = D[s] + l;
          q.push(P(i, 0));
        }
      }
    }
    else {
      for (int i : ys[p.second]) {
        if (i == s) continue;
        P t = T[i];
        long long l = abs(t.first - p.first) + 1LL;
        if (D[i] > D[s] + l) {
          D[i] = D[s] + l;
          q.push(P(i, 1));
        }
      }
    }
  }

  cout << (D[0] != INF ? D[0] : -1) << "\n";
  return 0;
}

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

#pragma GCC optimize ("O3")
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define TIME cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<int, int> mi;
typedef map<ll, ll> ml;
#define fr(i, n) for (int i = 0; i < n; i++)

const int N = 5e5 + 5;
const int M = 998244353;
ll fact[N], inv[N];
vector<bool> prime;
vector<int> drow4{1, -1,  0,  0};
vector<int> dcol4{0,  0, -1,  1};
vector<int> drow8{0,  1,  1,  1,  0, -1, -1, -1};
vector<int> dcol8{1,  1,  0, -1, -1, -1,  0,  1};

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "debug statement : " << *it << " = " << a << endl;
    err(++it, args...);
} 

ll powerModM(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res=(res * x)%M; 
        y = y >> 1; 
        x = (x *x) % M;
    } 
    return res % M; 
}

ll power(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x*x;
    } 
    return res; 
}
 
void preCalcFactorial(int n){
    fact[0] = inv[0] = 1;
    for(ll i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % M;
        inv[i] = powerModM(fact[i], M - 2);
    }
}
 
ll nCr(ll n,ll r){
    ll ans = ((fact[n] * inv[r]) % M + M) % M;
    ans = ((ans * inv[n-r]) % M + M) % M;
    return ans;
}

void sieve(int n) { 
    prime.resize(n+1, true);
    prime[1] = false;
    for (int p = 2; p * p <= n; p++){ 
        if (prime[p] == true) {
            for (int i = p*p; i <= n; i += p) 
                prime[i] = false; 
        } 
    }
} 

class BIT{
public:
    int size;
    vector<int> v;
    BIT(int s){
        size = s;
        v.resize(s, 0);
    }
    void update(int i, int delta){
        while(i < size){
            v[i] += delta;
            i += i & (-i);
        }
    }
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += v[i];
            i -= i & (-i);
        }
        return s;
    }
};

void testCase(){
    int n;
	cin >> n;
	int val = 1000 - n % 1000;
	if(val == 1000) cout << 0 << endl;
	else cout << 1000 - n % 1000 << endl;
}

int main(){
    FAST
    int t = 1;
    //cin >> t;
    while(t--){
        testCase();
    }
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int64 n;
    cin >> n;
    int ans = INT_MAX;
    for (int64 i=1; i<=sqrt(n); i++) {
        if (n%i) continue;
        ans = min(ans, max((int)(log10((long double)n/(long double)i)+1), (int)(log10(i)+1)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3452
#!/usr/bin/env python3

def main():
    N = int(input())
    AB = [list(map(int, input().split())) for i in range(N)]
    AB.sort(key=lambda x: x[1])
    work = 0
    ans = 'Yes'
    for i in range(N):
        work += AB[i][0]
        if work > AB[i][1]:
            ans = 'No'
            break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47196
//
//  main.c
//  ITP1_9_B
//
//  Created by k16031kk on 2018/05/27.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    char str[200];
    //char str_copy[200];
    //char str_copy_copy[200];
    //char shuffle[200];
    int m=0, h=0, len=0;
    while(1) {
        scanf("%s", str);
        if(str[0]=='-') break;
        len=strlen(str);
        //strcpy(str_copy, str);
        //printf("%d\n",len);
        scanf("%d", &m);
        
        for(int i=0; i<m; i++) {//m回シャッフル
            scanf("%d", &h);//位置決め
            //printf("%d\n",h);
            char shuffle[200]={};
            char str_copy[200]={};
            strncpy(shuffle, str, h);//シャッフルする位置を決める
            //printf("%s\n",shuffle);
            /*for(int i=0; i<len-h; i++) {
                str_copy[i]=str_copy[h+i];
            }
            */
            int i,j;
            for(i=h, j=0; i<len; i++, j++) {//残ったカードを0から格納し直す
                str_copy[j]=str[i];
                //printf("%c\n",str_copy[j]);
            }
            strcat(str_copy,shuffle);//新しい並びになる
            //printf("%s\n",str_copy);
            strcpy(str, str_copy);
        }
        printf("%s\n",str);
    }
    
    return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int bas = 0;
    int tri = 0;
    int fou = 0;

    VI total;
    VI odd;

    VI ans_total(1e06, INF);
    VI ans_odd(1e06, INF);

    while (1) {
        bas++;
        tri += bas;
        fou += tri;
        if (fou >= 1e06) {
            break;
        }
        total.push_back(fou);
        ans_total[fou] = 1;
        if (fou % 2 == 1) {
            odd.push_back(fou);
            ans_odd[fou] = 1;
        }

    }
    int size_total = (int)total.size();
    int size_odd = (int)odd.size();
    int posi;

    for (int i = 0; i < size_total; i++) {
        posi = total[i];
        for (int j = posi + 1; j < 1e06; j++) {
            ans_total[j] = min(ans_total[j], ans_total[posi] + ans_total[j - posi]);
        }
    }
    for (int i = 0; i < size_odd; i++) {
        posi = odd[i];
        for (int j = posi + 1; j < 1e06; j++) {
            ans_odd[j] = min(ans_odd[j], ans_odd[posi] + ans_odd[j - posi]);
        }
    }

    int input;
    while (1) {
        cin >> input;
        if (input == 0) {
            break;
        }
        cout << ans_total[input] << " " << ans_odd[input] << endl;
    }
    return 0;
}

Measured memory_bytes: 10496
#include <iostream>
using namespace std;
string pos( long long int k )
{
	long long int sum = 0, val = 1;
	string res = "";
	while( sum + val < k )
	{
		sum += val;
		val *= 4;
		res = "01" + res;
	}
	res = "1" + res;
	sum += val - k;
	for(int i = 0; i < res.size(); i++)
	{
		if( val <= sum )
		{
			if( res[i] == '1' )
				res[i] = '0';
			else res[i] = '1';
			sum -= val;
		}
		val /= 2;
	}
	
	return res;
}

string neg( long long int k )
{
	k = -k;
	long long int sum = 0, val = 2;
	string res = "";
	while( sum < k )
	{
		sum += val;
		val *= 4;
		res = "10" + res;
	}
	val /= 4;
	sum -= k;
	for(int i = 0; i < res.size(); i++)
	{
		if( val <= sum )
		{
			if( res[i] == '1' )
				res[i] = '0';
			else res[i] = '1';
			sum -= val;
		}
		val /= 2;
	}
	
	return res;
}

int main()
{
	long long int k;
	cin >> k;
	if( k == 0 )
		cout << 0;
	else if( k > 0 )
		cout << pos(k);
	else cout << neg(k);
	
}

Measured memory_bytes: 3552
program main
implicit none
character*16 :: a
integer :: n,i,j,x,y,z,m
integer,allocatable :: p(:)

read(*,*)n
allocate(p(n))
read(*, *)(p(i), i = 1,n)
call quicksort(p,1,n)

z=0

z = p(n/2+1) - p(n/2)

write(*,*) z

contains 

recursive subroutine quicksort(a, first, last)
  implicit none
  integer  a(*)
  integer first, last
  integer i, j
  real*8  x, t
  
  x = a( (first+last) / 2 )
  i = first
  j = last
  do
     do while (a(i) < x)
        i=i+1
     end do
     do while (x < a(j))
        j=j-1
     end do
     if (i >= j) exit
     t = a(i);  a(i) = a(j);  a(j) = t
     i=i+1
     j=j-1
  end do
  if (first < i - 1) call quicksort(a, first, i - 1)
  if (j + 1 < last)  call quicksort(a, j + 1, last)
end subroutine quicksort
end program main

Measured memory_bytes: 1152
# coding: utf-8
s = input()
n = len(s)
for i in range(n//2):
    if s[i] != s[n-1-i]:
        print("No")
        quit()
for i in range(int((n-1)/2//2)):
    if s[i] != s[int((n-1)/2 - 1 - i)]:
        print("No")
        quit()
for i in range(int((n+3)/2-1),n):
    if s[i] != s[n-1-i]:
        print("No")
        quit()
print("Yes")

Measured memory_bytes: 3064
//
// Created by 李青坪 on 2018/12/30.
//

#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#define MAXN 100001
#define NIL -1
#define INIFITY 1 << 30
using namespace std;

int n;
int len = 1;
int L[MAXN];
vector<int> A;

void longetIncreasingSubsequence(){
    fill(L, L+n+1, 0);
    L[0] = A[0];
    for (int i = 0; i < n; ++i) {
        if (L[len-1] < A[i]){
            L[len++] = A[i];
        } else {
            int *j = lower_bound(L, L+len, A[i]);
            *j = A[i];
        }
    }
}

int main(){
    scanf("%d", &n);
    int a;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a);
        A.push_back(a);
    }
    longetIncreasingSubsequence();
//    for (int i = 0; i < len; ++i) {
//        printf("%d ", L[i]);
//    }
    printf("%d\n", len);
}

/*
8
5 3 1 4 8 2 9 11
 */


Measured memory_bytes: 3536
n, q = map(int, input().split())
s = "_" + input()
li = [0] * (n + 1)
for i in range(2, n + 1):
    if s[i - 1] == 'A' and s[i] == 'C':
        li[i] = li[i - 1] + 1
    else:
        li[i] = li[i - 1]
for _ in range(q):
    l, r = map(int, input().split())
    print(li[r] - li[l])


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

const int N = 2e5 + 10;

int n, a[N], f[N];
int m, b[N];

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d", a+i);
        f[i] = 0;
    }
    m = 0;
    int s;
    for(int i=n; i>=1; i--){
        s = 0;
        for(int j=i<<1; j<=n; j+=i){
            s += f[j];
        }
        s = s & 1;
        if(s == a[i]){
            f[i] = 0;
        } else {
            f[i] = 1;
            b[m++] = i;
        }
    }
    printf("%d\n", m);
    for(int i=0; i<m; i++)  printf("%d%c", b[i], i==m-1?'\n':' ');

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int x[n];
  rep(i,n) cin >> x[i];
  int minp = 1001001001;
  int sum;
  rep(i,101) {
    sum = 0;
    rep(j,n) {
      sum += (x[j]-i)*(x[j]-i);
    }
    minp = min(minp, sum);
  }
  cout << minp;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
int main(void){
	double a,s;
	int n;
	while (std::cin>>a){
		s=a;
		n=9;
		while(n--){
			if (n%2) a/=3;
			else a*=2;
			s+=a;
		}
		printf ("%.8f\n",s);
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

const double PI = acos(-1);

int main() {
    int R;
    cin >> R;
    cout << 2*R*PI << endl;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int a,b;
  cin>>a>>b;
  if(a+b==15) cout << "+" << endl;
  else if(a*b==15)cout << "*" << endl;
  else cout << "x" << endl;
  return 0;
}



Measured memory_bytes: 3600
object Main {
  val fld = Array.ofDim[Int](10)
  val ans = Array.ofDim[Int](10)

  def beam(y: Int, x: Int) = {
    val beams = 
      List((y, x), (y - 1, x), (y, x - 1), (y + 1, x), (y, x + 1))
      .filter(p => 0 <= p._1 && p._1 < 10 && 0 <= p._2 && p._2 < 10)
    for(b <- beams) {
      fld(b._1) ^= (1 << b._2)
    }
  }

  def init(orig: Array[Int]) = {
    for(y <- 0 to 9) {
      fld(y) = orig(y)
      ans(y) = 0
    }
  }

  def row_flip(y: Int, bits: Int) = {
    for(x <- 0 to 9) {
      if((bits & (1 << x)) != 0) {
        beam(y, x)
        ans(y) |= (1 << x)
      }
    }
  }

  def flip(bits: Int) = {
    row_flip(0, bits)
    for(y <- 1 to 9) row_flip(y, fld(y - 1))
  }

  def solve(orig: Array[Int]) = {
    var i = 0
    var flag = true
    while(flag) {
      init(orig)
      flip(i)
      if(fld(9) == 0) {
        ans.foreach(bits => println(
          Integer.toBinaryString(bits)
            .reverse.padTo(10, '0').split("").mkString(" ")))
        flag = false
      }
      else i += 1
    }
  }

  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    sc.nextLine
    for(_ <- 1 to n) {
      val orig = (1 to 10).toArray.map(_ => 
        Integer.parseInt(sc.nextLine.split(" ").mkString("").reverse, 2))
      solve(orig)
    }
  }
}

Measured memory_bytes: 268780
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  int free = 1;
  
  while (true) {
    if (free >= B) {
      break;
    }
    free = free + A - 1;
    ans++;
  }
  
  cout << ans << endl;
}

  

Measured memory_bytes: 256
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    ans = []
    for i in range(n-k):
        if a[i]<a[i+k]:
            ans.append('Yes')
        else:
            ans.append('No')
    for i in range(len(ans)):
        print(ans[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 31612
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using Lf = long double;
using plong = pair<ll,ll>;
const int mod = 1000000007;
int main(){
    ll H,W,N;
    cin>>H>>W>>N;
    ll a = max(H,W);
    cout<<ceil((double)N/a)<<endl;
    

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#define md double
#define LL long long
using namespace std;
const int N=1<<20;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
inline LL gL() {
	LL w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
LL e[N],sum[N],tag[N],now[N];
int dep[N];
int main()
{
	int n=gi(),Q=gi(),i,k,t,ed,siz,L,R,l,r,H=1,mid;LL q,suf,to;
	for (siz=1;siz<n+2;siz=siz<<1|1) H++;
	for (dep[1]=H,i=2;i<=(siz<<1|1);i++) dep[i]=dep[i>>1]-1;
	e[siz+1]=3e13;
#define lc (k<<1)
#define rc (lc|1)
#define pushdown tag[lc]=tag[rc]=e[lc]=e[rc]=tag[k],sum[lc]=sum[rc]=tag[k]<<dep[lc],tag[k]=0
#define update e[k]=e[rc],sum[k]=sum[lc]+sum[rc]
#define modify(k,to) tag[k]=e[k]=(to),sum[k]=(to)<<dep[k]
	while (Q--) {
		L=siz+1,R=siz+(ed=gi()+1)+1;q=gL();
		for (i=H;i;i--) {
			if (tag[k=L>>i]) pushdown;
			if ((R>>i)!=k&&tag[k=R>>i]) pushdown;
		}
		for (l=L,now[r=R]=0;l^r^1;l>>=1,r>>=1) {
			if (~l&1) now[l^1]=sum[l^1],now[l>>1]=now[l]+now[l^1]; else now[l>>1]=now[l];
			if (r&1) now[r^1]=sum[r^1],now[r>>1]=now[r^1]+now[r]; else now[r>>1]=now[r];
		}
		now[l>>1]=now[l]+now[r];
		for (k=l;(k>>=1)>1;) now[k>>1]=now[k];
		suf=0;
		for (k=l>>1,l=1,r=1<<dep[k];k<=siz;) {
			if (tag[k]) pushdown;
			if (ed<=(mid=(l+r)>>1)) k<<=1,r=mid;
			else k=k<<1|(mid=(l+r)>>1,q<=e[lc]*(ed-mid)-(r<=ed?sum[rc]:now[rc])-suf?(l=mid+1,1):(suf+=r<=ed?sum[rc]:now[rc],r=mid,0));
		}
		suf+=sum[k];
		to=(q-(e[i]*(ed-l+1)-suf))/(ed-l+1);
		q-=to*(ed-l+1)-suf;t=--k;
		l=k,r=t+q+1;
		for (i=H;i;i--) {
			if (tag[k=l>>i]) pushdown;
			if ((r>>i)!=k&&tag[k=r>>i]) pushdown;
		}
		for (;l^r^1;) {
			if (~l&1) modify(l^1,to+1);
			if (r&1) modify(r^1,to+1);
			k=l>>=1;update;
			k=r>>=1;update;
		}
		while (k=(l>>=1)) update;
		l=t+q,r=siz+ed+1;
		for (i=H;i;i--) {
			if (tag[k=l>>i]) pushdown;
			if ((r>>i)!=k&&tag[k=r>>i]) pushdown;
		}
		for (;l^r^1;) {
			if (~l&1) modify(l^1,to);
			if (r&1) modify(r^1,to);
			k=l>>=1;update;
			k=r>>=1;update;
		}
		while (k=(l>>=1)) update;
	}
	for (k=1;k<=siz;k++) if (tag[k]) pushdown;
	for (k=1;k<=n;k++) printf("%lld\n",e[k+siz+1]);
	return 0;
}


Measured memory_bytes: 10880
def main():
    import bisect
    n,m,k = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))

    A_ac = [0]
    B_ac = [0]
    a_ac = 0
    b_ac = 0
    for a in A:
        a_ac+=a
        A_ac.append(a_ac)
    for b in B:
        b_ac+=b
        B_ac.append(b_ac)
    
    i_mx = bisect.bisect_right(A_ac,k)
    i = i_mx-1
    ct = [0]

    while i >= 0:
        k_left = k-A_ac[i]
        j = bisect.bisect_right(B_ac,k_left)-1
        ct.append(i+j)
        i-=1
    

    print(max(ct))
main()

Measured memory_bytes: 49576
// finish date: 2018/2/14

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    vi h(N);
    rep(i, N) cin >> h[i];
    vi cost(N, INF);
    cost[0] = 0;
    rep(i, N - 2) {
        cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i + 1] - h[i]));
        cost[i + 2] = min(cost[i + 2], cost[i] + abs(h[i + 2] - h[i]));
    }
    //こーなけーす
    cost[N - 1] = min(cost[N - 1], cost[N - 2] + abs(h[N - 1] - h[N - 2]));
    cout << cost[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using usize = std::size_t;

constexpr i64 K = 42;
i64 dp[K][2];

auto main() -> i32 {
	i32 n;
	scanf("%d", &n);
	i64 a, b;
	i64 x = 0;
	scanf("%ld%ld", &a, &b);
	for (i32 i = 2; i < n; ++i) {
		i64 c;
		scanf("%ld", &c);
		x ^= c;
	}
	const i64 s = a + b;
	if (s - x < 0 || (s - x) % 2 != 0) {
		puts("-1");
	} else {
		const i64 d = (s - x) / 2;
		std::fill((i64*)dp, (i64*)dp + K * 2, (i64)-1);
		dp[0][0] = 0;
		for (i32 i = 1; i < K; ++i) {
			const i64 bit = i64(1) << (K - i - 1);
			auto enabled = [bit](i64 v) { return (v & bit) != 0; };
			for (i64 k = 0; k < 2; ++k) {
				i64 v = dp[i - 1][k];
				if (v == -1) {
					continue;
				}
				for (i64 ai = 0; ai < ((k != 0 || enabled(a)) ? 2 : 1); ++ai) {
					for (i64 bi = 0; bi < 2; ++bi) {
						if (enabled(d) != ((ai & bi) != 0) || enabled(x) != ((ai ^ bi) != 0)) {
							continue;
						}
						i32 nk = (k != 0) || (enabled(a) && ai == 0);
						if (dp[i][nk] < 2 * v + ai) {
							dp[i][nk] = 2 * v + ai;
						}
					}
				}
			}
		}
		i64 ans = std::max(dp[K - 1][0], dp[K - 1][1]);
		if (ans > 0) {
			printf("%ld\n", a - ans);
		} else {
			puts("-1");
		}
	}
	return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n;
    cin >> n;
    vi a(n);
    rep(i,n)cin >> a[i];

    int x = 0;
    rep(i,n) x ^= a[i];

    int ans = 0;
    for(i=35;i>=0;i--)if(x & (1<<i)){
        rep(j,n){
            int t = a[j] ^ (a[j]-1);
            if(t+1 == (1<<(i+1))){
                x ^= t;
                ans++;
                break;
            }
        }
    }

    if(x == 0)cout << ans << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

int dp[1001][1001];//from,to

const int INF=1<<28;

int main(){

	string from,to;
	cin >> from >> to;

	fill_n((int *)dp,sizeof(dp)/sizeof(int),0);
	rep(i,from.size()+1) dp[0][i]=i;
	rep(i,to.size()+1) dp[i][0]=i;

	for(int i=1;i<=to.size();i++){
		for(int j=1;j<=from.size();j++){	
			if(to[i-1]==from[j-1]){
				dp[i][j] = min(dp[i-1][j] + 1, min(dp[i][j-1] + 1, dp[i-1][j-1] + 0));
			}else{
				dp[i][j] = min(dp[i-1][j] + 1, min(dp[i][j-1] + 1, dp[i-1][j-1] + 1));
			}
		}
	}


	cout << dp[to.size()][from.size()] << endl;

	return 0;
}

Measured memory_bytes: 5100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int k = fs.nextInt();
        long nums = 0;
        long e = 0;
        boolean even = k % 2 == 0;
        for (int i = 1; i <= n; i++) {
            if (i % k == 0) {
                nums++;
            }
            if (even && i % k == k / 2) {
                e++;
            }
        }
        System.out.println(nums * nums * nums + e * e * e);
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


Measured memory_bytes: 32636
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll a, b, n, ans = 0;
  cin >> a >> b >> n;
  if (b - 1 <= n) {
    ans = (a * (b - 1)) / b;
    for (ll i = 2; i * b - 1 <= n; ++i) {
      ans = max(ans, (a * (i * b - 1)) / b - (i - 1));
      if (i >= 1000000) break;
    }
  } else {
    ans = (a * n) / b;
  }
  if (a == 1 || b == 1) ans = 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int H, W, N;
  cin >> H >> W >> N;
  int r, c;
  cin >> r >> c;
  string S, T;
  cin >> S >> T;

  int left = 1;
  int right = W;
  int up = 1;
  int down = H;
  if (S[N - 1] == 'L') ++left;
  if (S[N - 1] == 'R') --right;
  if (S[N - 1] == 'U') ++up;
  if (S[N - 1] == 'D') --down;
  for (int i = N - 2; i >= 0; --i) {
    if (T[i] == 'L') right = min(right + 1, W);
    if (T[i] == 'R') left = max(1, left - 1);
    if (T[i] == 'U') down = min(down + 1, H);
    if (T[i] == 'D') up = max(1, up - 1);

    if (S[i] == 'R') --right;
    if (S[i] == 'L') ++left;
    if (S[i] == 'D') --down;
    if (S[i] == 'U') ++up;

    if (left > right || up > down) {
      cout << "NO" << endl;
      return 0;
    }
  }

  if ((left <= c && c <= right) && (up <= r && r <= down)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b)
#define mins(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int t1,t2;
    ll a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;

    ll d1=t1*(a1-b1),d2=t2*(a2-b2),d=abs(d2)-abs(d1);

    if(d1>0&&d2>0 || d1<0&&d2<0 || d<0){
        cout<<0<<endl;
        return 0;
    }
    if(d==0){
        cout<<"infinity"<<endl;
        return 0;
    }

    if(d1<0)d1*=-1;
    if(d<0)d*=-1;

    ll c=(d1+d-1)/d;

    ll ans=2*c-1;
    if(c*d==d1)ans++;

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

Measured memory_bytes: 256
package main

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

var sc = NewScanner(os.Stdin, 1000000)

func main() {
	A := sc.readInt() // 500円玉
	B := sc.readInt() // 100円玉
	C := sc.readInt() // 50円玉
	X := sc.readInt() // 目標金額

	cnt := 0
	for a := 0; a <= A; a++ {
		for b := 0; b <= B; b++ {
			for c := 0; c <= C; c++ {
				res := a*500 + b*100 + c*50
				if res == X {
					cnt++
				}
			}
		}
	}
	fmt.Println(cnt)

}

type Scanner struct {
	*bufio.Scanner
}

func (scn *Scanner) readInt() int {
	scn.Scanner.Scan()
	i, _ := strconv.Atoi(scn.Scanner.Text())
	return i
}

func NewScanner(r io.Reader, bufSize int) *Scanner {
	buf := make([]byte, bufSize)
	scn := bufio.NewScanner(r)
	scn.Buffer(buf, bufSize)
	scn.Split(bufio.ScanWords)
	return &Scanner{scn}
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		char c = s.charAt(s.length() - 1);

		String a = "24579";
		String b = "0168";

		if (a.indexOf(c) > -1) {
			System.out.println("hon");
		} else if (b.indexOf(c) > -1) {
			System.out.println("pon");
		} else {
			System.out.println("bon");
		}

	}

}

Measured memory_bytes: 35700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int C = stdIn.nextInt();
		
		if(A+B >= C)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}

	}

}


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

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
int main(){
    int n;
    cin >> n;
    auto t=prime_table(55555);
    int i=0;
    int iter=2;
    while(i<n){
        if(t[iter]==true && iter%5==1){
            cout << iter << " ";
            i++;
        }
        iter++;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  string s; cin >> s;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    cnt += s[i] == '1';
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3576
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    vector<int> h(n);
    REP(i,n){
        cin>>h.at(i);
    }

    int mxmv = 0;
    int mv = 0;
    REP(i,n){
        if( i == 0 || h.at(i-1) < h.at(i) ){
            mxmv = max(mxmv,mv);
            mv = 0;
        } else {
            mv++;
        }
    }
    mxmv = max(mxmv,mv);
    cout<<mxmv<<endl;

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

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(void)
{
	int dice[6];
	int i, j;
    int n;
    char str[5];
    char str_t[6][7] = {"North", "East", "West", "South", "Right", "Left"};
    int sum;
    int m;
    int tmp;

    while(1){
		sum = 1;

		for (i = 0; i < 6; i++){
			dice[i] = i + 1;
		}
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
			}
		
		for (i = 0; i < n; i++){
			scanf("%s", str);
			for (j = 0; j < 6; j++){
				if (!strcmp(str_t[j], str)){
					m = j;
					break;
					}
			}
			switch (m){
				case 0:
				tmp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = tmp;
				sum += dice[0];
				break;
				
				case 1:
				tmp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = tmp;
				sum += dice[0];
				break;
				
				case 2:
				tmp = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = tmp;
				sum += dice[0];
				break;
				
				case 3:
				tmp = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = tmp;
				sum += dice[0];
				break;
				
				case 4:
				tmp = dice[1];
				 dice[1] = dice[2];
				 dice[2] = dice[4];
				 dice[4] = dice[3];
				 dice[3] = tmp;
				 sum += dice[0];
				 break;
				 
				 case 5:
				 tmp = dice[1];
				  dice[1] = dice[3];
				  dice[3] = dice[4];
				  dice[4] = dice[2];
				  dice[2] = tmp;
				  sum += dice[0];
				  break;
				  }
			}
			printf("%d\n", sum);
		}
		return (0);
}

Measured memory_bytes: 612