akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

int gcd(int p,int q){
    if(p%q == 0){
        return q;
    }
        return gcd(q,p%q);
}

int main(){
    int k; cin >> k;
    int64_t sum = 0;
    int d;

    for(int a=1; a<=k; a++){
        for(int b=1; b<=k; b++){
            for(int c = 1; c<=k; c++){
                sum += gcd(a,gcd(b,c));
            }
        }
    }

    cout << sum << endl;
    
}



Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int H, W;
    cin >> H >> W;
    int inf = 1e9;
    vector<vector<int>> dist(10, vector<int>(10, inf));
    rep(i, 10){
        rep(j, 10){
            cin >> dist[i][j];
        }
    }
    rep(k, 10){
        rep(i, 10){
            rep(j, 10){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = 0;
    rep(i, H){
        rep(j, W){
            int a;
            cin >> a;
            if(a >= 0){
                ans += dist[a][1];
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <time.h>
#include <string>
#include <iomanip>
#include <algorithm>
#include <map>


using namespace std;

int main(){
  int a;
  map<int,string> mp;
  mp[25]="Christmas";
  mp[24]="Christmas Eve";
  mp[23]="Christmas Eve Eve";
  mp[22]="Christmas Eve Eve Eve";
  cin>>a;
  cout<<mp[a]<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

if sum(a) < sum(b):
    print("-1")
    exit()
yobun_sum = []

for i in range(N):
    if a[i] > b[i]:
        yobun_sum.append(a[i]-b[i])

yobun_sum.sort()
yobun_sum.reverse()
yobun_cum_sum=[]
cum_sum=0
for i in yobun_sum:
    cum_sum+=i
    yobun_cum_sum.append(cum_sum)

lack_num=0
lack_sum=0

for i in range(N):
    if a[i] < b[i]:
        lack_num+=1
        lack = abs(a[i] - b[i])
        lack_sum+=lack

for i in range(len(yobun_cum_sum)):
    if yobun_cum_sum[i] >= lack_sum:
        break

if lack_sum==0:
    print(0)
else:
    print(lack_num+i+1)

Measured memory_bytes: 18524
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    L = len(S)

    def rec(i, vec, smaller):
        if i == L:
            s = set(vec)
            if 3 in s and 5 in s and 7 in s:
                return 1
            else:
                return 0

        ans = 0
        if not vec:
            ans += rec(i + 1, vec, True)
        if smaller:
            for n in (3, 5, 7):
                vec.append(n)
                ans += rec(i + 1, vec, True)
                vec.pop()
        else:
            for n in (3, 5, 7):
                if n > int(S[i]):
                    break
                vec.append(n)
                if n < int(S[i]):
                    ans += rec(i + 1, vec, True)
                else:
                    ans += rec(i + 1, vec, False)
                vec.pop()

        return ans

    ans = rec(0, [], False)

    print(ans)
    return


if __name__ == '__main__':
    main()


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

int modPow(ll a, ll n, ll p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    ll p=1000000007;
    ll x=1,y=1;
    for(int i = 0; i < a; i++) {
        x *= n-i;
        x %= p;
    }
    for(int i = 0; i < a; i++) {
        y *= i+1;
        y %= p;
    }
    ll s=1,t=1;
    for(int i = 0; i < b; i++) {
        s *= n-i;
        s %= p;
    }
    for(int i = 0; i < b; i++) {
        t *= i+1;
        t %= p;
    }
    ll ans=modPow(2,n,p)-1-x*modPow(y,p-2,p)-s*modPow(t,p-2,p);
    if(ans >=0){
        ans %= p;
    }
    else{
        ans *= -1;
        ans %= p;
        ans = p-ans;
        ans %= p;
    }

    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int n,m,res=0;



int main() {
	cout << fixed << setprecision(10);
    cin>>n>>m;
    n=min(n,4LL);
    m=min(m,4LL);
    if(n==m&&n==1){
        cout<<1000000<<endl;
    }else{
        cout<<(8-n-m)*100000<<endl;
    }
} 


Measured memory_bytes: 256
/*
Coin Changing Problem(https://onlinejudge.u-aizu.ac.jp/#/problems/DPL_1_A)
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

const int INF = 1<<29;

int dp[32][50050];

void solve(void){
    int N, M;
    cin >> N >> M;
    rep(M+1, m) rep(N+1, n) dp[m][n] = INF;
    dp[0][0] = 0;
    rep(M, m) {
        int c;
        scanf("%d\n", &c);
        rep(N+1, n) {
            dp[m+1][n] = min(dp[m+1][n], dp[m][n]);
            if (n+c<=N) dp[m+1][n+c] = min(dp[m][n+c], dp[m+1][n]+1);
        }
    }
    cout << dp[M][N] << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}



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

const int INF = 1001001001;

int main()
{
    int N, X, Y;
    cin >> N >> X >> Y;
    --X; --Y;

    vector<int> ans(N);
    rep(sv, N) {
        queue<int> q;
        vector<int> dist(N, INF);
        auto push = [&](int v, int d) {
            if (dist[v] != INF) return;
            q.push(v);
            dist[v] = d;
        };
        push(sv, 0);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            int d = dist[v];
            if (v-1 >= 0) push(v-1, d+1);
            if (v+1 < N) push(v+1, d+1);
            if (v == X) push(Y, d+1);
            if (v == Y) push(X, d+1);
        }
        rep(v, N) ans[dist[v]]++;
    }
    rep(v, N) ans[v] = ans[v] / 2;

    rep(i, N-1) {
        cout << ans[i+1] << endl;
    };

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int a, b, c;
   cin >> a >> b >> c;
   if(a==b&&b==c) {
       cout << 1 << endl;
       return 0;
   } else if(a==b||b==c||c==a) {
       cout << 2 << endl;
   } else {
       cout << 3 << endl;
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

vector<ll>par(2e5+10);
void init(ll n) {
  for(ll i=0;i<n;i++) {
    par[i]=i;
  }
}

ll root(ll x) {
  if(par[x]==x) {
    return x;
  }
  else {
    return par[x]=root(par[x]);
  }
}

bool same(ll x, ll y) {
  return root(x)==root(y);
}

void unite(ll x, ll y) {
  if(same(x,y)) return;
  par[root(x)]=root(y);
}

int main() {
  ll n,m;
  cin >> n >> m;
  init(2*n);
  for(ll i=0;i<m;i++) {
    ll x,y,z;
    cin >> x >> y >> z;
    unite(x-1,y-1);
  }
  set<ll> count;
  for(ll i=0;i<n;i++) {
    count.insert(root(i));
  }
  cout << count.size() << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	ll x,y,z,k; cin >> x >> y >> z >> k;
	ll a[x], b[y], c[z];
	FOR(x) cin >> a[i];
	FOR(y) cin >> b[i];
	FOR(z) cin >> c[i];
	
	sort(c, c+z, greater<ll>());
	
	vector<ll> ab_sums;
	FOR(i,x) FOR(j,y) ab_sums.pb(a[i] + b[j]);
	sort(all(ab_sums), greater<ll>());	
		
	vector<ll> ans;
	ll n = min(k,(ll)ab_sums.size());
	FOR(i,n){
		FOR(j,z){
			ans.pb(ab_sums[i] + c[j]);
		}
	}
	
	sort(all(ans), greater<ll>());
		
	FOR(k) cout << ans[i] << '\n';
		
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 44064
#define ll long long
#define ull unsigned long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ull po(ull base, ull powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
//   tes(t)
//   {
    
//   }
int n;
cin>>n;
int cnt=0;
int flag=0;
rep(i,0,n-1)
{
  int x,y;
  cin>>x>>y;
  if(x==y)
  cnt++;
  else cnt=0;
  if(cnt==3)
  flag=1;
}
if(flag==1)
cout<<"Yes";
else cout<<"No";

}
	

  


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    int H,W,h,w;
    
    cin >> H >> W;
    cin >> h >> w;
    
    cout << H*W-(h*W+w*H-h*w) << endl;
    
    
    
    
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int arr[] =  new int[]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int n = sc.nextInt();
        System.out.println(arr[n-1]);
    }

}


Measured memory_bytes: 23252
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <time.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <math.h>
//#include <bits/stdc++.h>
#define ll long long
#define int64 long long
#define mem(x,y) memset(x,y,sizeof(x))
#define ull unsigned long long
#define pb push_back
#define INF 0x3f3f3f3f
#define lson l, mid, rt<<1
#define rson mid+1, r, rt<<1|1
#define pi 3.141592653589793238462

using namespace std;

const int maxn = 2e5 + 5;
const int maxm = 3e5 + 5;
const int mod = 1e9 + 7;
const int seed = 10007;
const double eps = 1e-5;
int n;

int main() {
    scanf("%d",&n);
    printf("ABC%d\n",n);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
const int INF = 2e9 + 7;

int main() {
    fastio();
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) { cin >> h[i]; }
    sort(all(h));
    int diff = INF;
    for (int i = 0; i + K - 1 < N; i++) {
        diff = min(diff, h[i + K - 1] - h[i]);
    }
    co(diff);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1e18 : 1e9;
const int MOD = 1000000007;
const long double EPS = 1e-8;

int n, a[1010];

int main() {
	while (cin >> n, n) {
		rep (i, n) cin >> a[i];
		int mini = INF;
		rep (i, n) range (j, i + 1, n) mini = min(mini, abs(a[i] - a[j]));
		cout << mini << endl;
	}
	return 0;
}



Measured memory_bytes: 3056
import scala.io.StdIn._
 
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val g = sc.next
  val r = sc.next
  if(g(0)==r(2) && g(1)==r(1) && g(2)==r(0)){
    println("YES")
  }
  else{
    println("NO")
  }
}

Measured memory_bytes: 25412
#include <bits/stdc++.h>
using namespace std;
int linear(vector<int> S,int n, int key) {
    int i = 0;
    S.at(n) = key;
    while (S.at(i) != key) {
        i++;
    }
    return (n-i);
    
}
int main() {
    int n,q;
    cin >> n;
    vector<int> S(n+1);
    for(int i = 0; i < n; i++) {
        scanf("%d", &S.at(i));
    }
    cin >> q;
    vector<int> T(n);
    for(int i = 0; i < q; i++) {
        scanf("%d", &T.at(i));
    }
    int sum = 0;
    for(int i = 0; i < q; i++) {
        if(linear(S,n,T.at(i))) sum++;
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 3396
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl(); a.sort()
ok = a[0] + a[0] - 1
ng = a[-1] + a[-1] + 1
def sol(x):
    res = 0
    for i in range(n):
        y = x-a[i]
        res += n-bisect_left(a,y)
    return True if res >= m else False
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    if sol(mid):
        ok = mid
    else:
        ng = mid
b = [0]
for i in range(n)[::-1]:
    b.append(b[-1]+a[i])
res = 0
cnt = 0
# print(b,ok)
for x in a:
    ind = n-bisect_left(a,ok-x)
    cnt += ind
    res += b[ind] + x*ind
print(res-(cnt-m)*ok)


Measured memory_bytes: 93312
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        
        int gcd = GCD(A, B);
        
        int div = 2;
        int cnt = 1;
        while( cnt < K ){
            if( gcd % div == 0 ){
                cnt++;
            }
            div++;
        }
        
        System.out.println( gcd/(div-1) );

    }
    
    static int GCD(int x, int y){
        if( y == 0) return x;
        return GCD(y, x % y);
    }
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;




int main(){

  vector<int> jx(12);
  jx[0]=-1;
  jx[1]=0;
  jx[2]=1;
  jx[3]=-2;
  jx[4]=2;
  jx[5]=-2;
  jx[6]=2;
  jx[7]=-2;
  jx[8]=2;
  jx[9]=-1;
  jx[10]=0;
  jx[11]=1;

  vector<int> jy(12);
  jy[0]=-2;
  jy[1]=-2;
  jy[2]=-2;
  jy[3]=-1;
  jy[4]=-1;
  jy[5]=0;
  jy[6]=0;
  jy[7]=1;
  jy[8]=1;
  jy[9]=2;
  jy[10]=2;
  jy[11]=2;

  vector<int> px(9);
  px[0]=-1;
  px[1]=0;
  px[2]=1;
  px[3]=-1;
  px[4]=0;
  px[5]=1;
  px[6]=-1;
  px[7]=0;
  px[8]=1;

  vector<int> py(9);
  py[0]=-1;
  py[1]=-1;
  py[2]=-1;
  py[3]=0;
  py[4]=0;
  py[5]=0;
  py[6]=1;
  py[7]=1;
  py[8]=1;



  int x,y;
  while(cin>>x>>y){
    if(x==0&&y==0)break;
    int n;
    cin>>n;
    vector<int> sx(n+1);
    vector<int> sy(n+1);
    for(int i=0;i<n;i++)cin>>sx[i]>>sy[i];
    vector<int> X[n+1];
    vector<int> Y[n+1];
    X[0].push_back(x);
    Y[0].push_back(y);

    for(int i=0;i<n;i++){
      for(int l=0;l<X[i].size();l++){
        int nx=X[i][l];
        int ny=Y[i][l];
        for(int j=0;j<12;j++){
          for(int k=0;k<9;k++){
            if(nx+jx[j]>0&&sx[i]+px[k]>0&&
            ny+jy[j]>0&&sy[i]+py[k]>0&&
            nx+jx[j]==sx[i]+px[k]&&ny+jy[j]==sy[i]+py[k]&&
            nx+jx[j]<10&&ny+jy[j]<10){
              X[i+1].push_back(nx+jx[j]);
              Y[i+1].push_back(ny+jy[j]);
            }
          }
        }
      }
    }

    if(X[n].size()!=0){
      cout<<"OK"<<endl;
    }else{
      cout<<"NA"<<endl;
    }

  }
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define pb  push_back
#define mod 1000000007
#define INF 1e18
typedef  long long ll;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	int a[n],b[n],c=0,f=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i]>>b[i];
	}
	for (int i = 0; i < n; ++i)
	{
		if(c>=0&&a[i]==b[i]){
			c++;
			if(c>=3)
				f=1;
		}
		else
			c=0;
	}
	if(f==1)
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
}

Measured memory_bytes: 3652
#include<algorithm>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,w[11],k[11];
	for(i=0;i<10;i++) cin>>w[i];
	for(j=0;j<10;j++) cin>>k[j];
	sort(w,w+10,greater<int>()); sort(k,k+10,greater<int>());
	cout<<w[0]+w[1]+w[2]<<" "<<k[0]+k[1]+k[2]<<endl;
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

#define INF 99999999
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(void){
    int64_t N,K;
    cin >> N >> K;
    
    vector<int> v;
    map<int,int64_t> nn;   // nn[i]は数字iの個数
    
    
    REP(i,N){
        int a,b;
        cin >> a >> b;
        
        if( nn.find(a) == nn.end() ){
            // なかった
            nn[a] = b;
            v.push_back(a);
        }else{
            nn[a] += b;
        }
    }
    
    sort(v.begin(),v.end());
    
    int64_t t=0;
    REP(i,v.size()){
        t += nn[v[i]];
        if( t >= K ){
            cout << v[i] << endl;
            return 0;
        }
    }
    
    
    /*
    
  // データを追加する
  que.push(3);
  que.push(1);
  que.push(4);

  // 中身の出力
  while (!que.empty()) {
    std::cout << que.top() << std::endl;
    que.pop();
  }*/
    return 0;
}


Measured memory_bytes: 4476
import sys
input = sys.stdin.readline

# A - Colorful Slimes 2
N = int(input())
a = list(input().split())
prev = a[0]

for i in range(1, N):
	if a[i] == prev:
		a[i] = 'changed'
	
	prev = a[i]

print(a.count('changed'))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    ll K;
    K = min(4 * Q, S);
    K = min(K, 2 * H);
    ll ans = min(N/2 * D + (N%2) * K, N*K);

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

}

Measured memory_bytes: 3728
from itertools import combinations_with_replacement
import numpy as np 
N,M,Q = (int(x) for x in input().split())
abcd =np.zeros((Q,4),dtype=int)
for i in range(Q):
    abcd[i] = list(map(int, input().split()))
abcd[:,0] -=1 #添え字にするから、-1
abcd[:,1] -=1 #添え字にするから、-1

#リストAを要素数N,最大値Mで全列挙
ans =[]
#for i in range(1,N+1):
for a in combinations_with_replacement (range(1,M+1),N):
    A =np.array(a,dtype=int)
    X = np.where( A[abcd[:,1] ] -A[abcd[:,0]] ==abcd[:,2] )
    ans.append(np.sum(abcd[X,3]))
print(max(ans))

Measured memory_bytes: 30896
#include<queue>
#include<cstdio>
#include <stdio.h>
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX_N 16
#define LL long long
using namespace std;
const LL INF = (LL)1e16;
typedef pair<int, int> P;

int N,T[MAX_N][MAX_N + 1];
LL m,k,l;
int main(){
  while(true){
    cin >> N;
    if(N == 0) break;
    rep(i,N)rep(j,N+1) cin >> T[i][j];
    m = (1<<N);//m=2^N
    LL dp[m],p[N];
    rep(i,m) dp[i] = INF;//初期化
    rep(i,N){
      p[i] = (1<<i);//1,2,4,8,...
      dp[p[i]] = T[i][0];//p[i]は1が1つでその1はクリアしたゲーム番号に対応している
    }
    rep(i,m){//iは各ゲームをクリアしているかどうか
      rep(j,N){//jはゲームの番号
        if(!(i&p[j])){//bit積(1つも1と1が一致しないなら)(ゲームjをクリアしてないなら)
          l = (i|p[j]);//bit和(ゲームjをクリア済みにする)
          dp[l] = min(dp[l],dp[i] + T[j][0]);//ゲームjをアイテムなしでクリア
          rep(k,N){//kはゲームの番号
            if(i&p[k]){//ゲームkをクリアしているなら
              if (dp[l] > dp[i] + T[j][k+1]) dp[l] = dp[i]+T[j][k+1];//ゲームkのアイテムを使ってjをクリアしたほうが良いなら更新
            }
          }
        }
      }
    }
    cout << dp[m-1] << endl;//全てクリア済み(111...)の状態
  }
  return 0;
}


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

int main() {
  int N , K , a ;
  cin>>N>>K;
  a=1;
  for(int i=0 ; i<N ; i++){
    if(a*2>=a+K){
      a=a+K;
    }
   else{
     a=a*2;
   }
  }
  cout<< a <<endl;
}
  

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

#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define orta ((l+r)>>1)
#define sol (node+node)
#define sag (node+node+1)
#define inf 1000000009
#define infll 1000000000000000009
#define eps 1e-9
#define ppair(x)  "(" << x.first << ", " << x.second << ") "
#define bas(x) #x << ": " << x << " "
#define prarr(x, n); {cout << #x << ": "; for(ll qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << "\n";}
#define prarrv(x); {cout << #x << ": "; for(ll qsd: x) cout << qsd << " "; cout << "\n";}
#define ii pair<int, int>
#define mod 1000000007 // 998244353
using namespace std;
typedef long long ll;

int main(int argc, char* argv[]){
//    freopen("/home/cahid/CLionProjects/main/in", "r", stdin);
//    freopen("burunsuz.gir", "r", stdin);
//    freopen("burunsuz.cik", "w", stdout);
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> arr(n);
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    if (n == 1) cout << abs(b-arr[0]);
    else {
        cout << max(abs(b-arr[n-1]), abs(arr[n-1] - arr[n-2]));
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b;

int main(){
  cin >> a >> b;
  int ans = a+b;
  if(ans>=10){
    cout<< "error" << endl;
    return 0;
  }
  cout << ans << endl;
  
  return 0;
}



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

using namespace std;

constexpr long long INF64 = 1e18;

using Weight = long long;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};

auto operator<(const Edge &e, const Edge &f) {
  if (e.weight != f.weight)
    return e.weight > f.weight;
  else if (e.src != f.src)
    return e.src < f.src;
  else
    return e.dst < f.dst;
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;
//経路復元可能
bool BellmanFord(const Graph &g, int s, vector<Weight> &dist,
                 vector<int> &prev) {
  const int V = g.size();
  dist[s] = 0;
  bool negative_cycle = false;
  for (int i = 0; i < V; ++i) {
    for (int j = 0; j < V; ++j) {
      for (auto e : g[j]) {
        if (dist[e.src] != INF64 && dist[e.dst] > dist[e.src] + e.weight) {
          dist[e.dst] = dist[e.src] + e.weight;
          prev[e.dst] = e.src;
          if (i == V - 1) {
            dist[e.dst] = -INF64;
            negative_cycle = true;
          }
        }
      }
    }
  }
  return negative_cycle;
}

int main() {
  cin.sync_with_stdio(false);
  int V, E, r = 0;
  cin >> V >> E;
  Graph g(V);
  for (int i = 0; i < E; ++i) {
    int s, t, d;
    cin >> s >> t >> d;
    --s;
    --t;
    d = -d;
    g[s].emplace_back(s, t, d);
  }
  vector<Weight> dist(V, INF64); //ここまでの距離が入る
  vector<int> prev(V, -1);       //最短路の親が入る
  if (BellmanFord(g, r, dist, prev)) {
    if (dist[V - 1] <= -INF64)
      cout << "inf" << endl;
    else
      cout << -dist[V - 1] << endl;
  } else {
    cout << -dist[V - 1] << endl;
  }
}

Measured memory_bytes: 384
# coding: utf-8
# Your code here!

S = input()

A = int(S[0:2])
B = int(S[2:])
f1,f2 = False,False
if A > 0 and A <= 12:
    f1 = True
if B > 0 and B <= 12:
    f2 = True

if f1 and f2:
    print("AMBIGUOUS")
elif f1:
    print("MMYY")
elif f2:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
#define MAXN 2000000
#define LL long long
#define MOD 998244353
int T,n,a,b,c,d,F;
char s[MAXN+5];
LL read(){
   	LL x=0,F=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
   	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*F;
}
bool check(int l,int r){
	for(int i=l+1;i<=r;i++)
	if(s[i]==s[i-1]&&s[i]=='#')
		return 1;
	return 0;
}
int main()
{
	n=read(),a=read(),b=read(),c=read(),d=read();
	scanf("%s",s+1);
	if(c<b){
		if(check(a,c)||check(b,d)){
			printf("No\n");
		}else printf("Yes\n"); 
		return 0;
	}
	if(check(min(a,c),max(b,d)))printf("No\n");
	else{
		if(a>c)swap(a,c),swap(b,d);
		if(a<b&&d<c){
			for(int i=b;i<=d;i++)
			if(s[i]=='.'&&s[i-1]=='.'&&s[i+1]=='.')
			{s[i]='X';F=1;break;}
			if(F)printf("Yes\n");
			else printf("No\n");
		}else printf("Yes\n");
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cerr << ", "; cetak(v...);}
 
#define debug(x...) cout<< '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())

const int MOD = 1e9 + 7;
const int mx = 1e5 + 10;

int n;
string ss[mx];
vector<pair<int, int>> g[18][(1 << 16) + 10];
int isi[18][(1 << 16) + 10];
int dist[18][(1 << 16) + 10];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> ss[i];
    for(int i = 0; i < n; i++){
        int ret = 0;
        for(int j = 0; j < sz(ss[i]); j++){
            ret *= 2;
            ret += ss[i][j] - '0';
            int sisa = 0;
            for(int k = j + 1; k < sz(ss[i]); k++){
                sisa *= 2;
                sisa += ss[i][k] - '0';
            }
            // debug(i, j + 1, ret, sz(ss[i]) - j - 1, sisa);
            g[j + 1][ret].pb({sz(ss[i]) - j - 1, sisa});
        }
        isi[sz(ss[i])][ret] = 1;
    }
    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pq;
    reset(dist, -1);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(sz(ss[i]) <= sz(ss[j])) continue;
            int ya = 1;
            for(int k = 0; k < sz(ss[j]); k++){
                if(ss[i][k] != ss[j][k])
                    ya = 0;
            }
            if(!ya) continue;
            ya = 1;
            int ret = 0;
            for(int k = sz(ss[j]); k < sz(ss[i]); k++){
                ret *= 2;
                ret += ss[i][k] - '0';
            }
            // debug(i, j, ret);
            pq.push({sz(ss[i]), {sz(ss[i]) - sz(ss[j]), ret}});
            dist[sz(ss[i]) - sz(ss[j])][ret] = sz(ss[i]);
        }
    }
    while(!pq.empty()){
        auto now = pq.top().s;
        auto dis = pq.top().f;
        pq.pop();
        if(dis > dist[now.f][now.s]) continue;
        int jadi = 0;
        for(int i = 1; i <= now.f; i++){
            jadi *= 2;
            if(now.s & (1 << (now.f - i))) jadi += 1;
            if(isi[i][jadi]){
                int sisa = now.s - (jadi << (now.f - i));
                if(dist[now.f - i][sisa] == -1 || dist[now.f - i][sisa] > dis){
                    dist[now.f - i][sisa] = dis;
                    pq.push({dis, {now.f - i, sisa}});
                }
            }
        }
        for(auto i : g[now.f][now.s]){
            // debug(i.f)
            int nex = dis + i.f;
            if(dist[i.f][i.s] == -1 || dist[i.f][i.s] > nex){
                dist[i.f][i.s] = nex;
                pq.push({nex, i});
            }
        }
    }
    if(dist[0][0] == -1) dist[0][0] += 1;
    cout << dist[0][0] << endl;
}  


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

int main()
{
  int n,m;
  cin>>n>>m;
  int a[n],i,keep;
  long long ans=0;
  priority_queue<int> que;
  for(i=0;i<n;i++){
    cin>>a[i];
    ans+=a[i];
    que.push(a[i]);
  }
  for(i=0;i<m;i++){
    keep=que.top();
    ans-=keep-keep/2;
    que.pop();
    que.push(keep/2);
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	int cnt = 0;
	string ans = "No";
	rep (i, n) {
		int a,b;
		cin >> a >> b;
		if (a == b)cnt++;
		if (cnt == 3) ans = "Yes";
		if (a != b) cnt = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long gcd(int a, int b)
{
  if(b==0)
    return a;
  return gcd(b,a%b)  ;
}

int main()
{
	long long a,b;
  cin >> a >> b;
 	cout << (a*b)/gcd(a,b);
  
  return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int a, b;
  std::cin >> a >> b;
  if ((a * b) & 1)
    std::cout << "Odd" << std::endl;
  else
    std::cout << "Even" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>

using namespace std;

int main()
{
   long long n,a,b,k;
    while (scanf("%lld %lld %lld",&n,&a,&b)!=EOF){
    if (a>b)
        cout<<'0'<<endl;
    else if(n == 1&&a!=b)
        cout<<'0'<<endl;
    else {
        if (a==b)
            cout<<'1'<<endl;
        else {
            k = ((n-1)*b+a)-((n-1)*a+b)+1;
            cout<<k<<endl;
        }
    }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    int h,w;
    cin >> h >> w;

    vector<vector<char>> pic(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> pic[i][j];
        }
    }

    vector<vector<char>> ans(2*h,vector<char>(w));
    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            ans.at(i).at(j)=pic.at(i/2).at(j);
        }
    }

    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
int main(){
	int cook[5];
	int simo_1[5];
	int total=0;
	int t=0;
	int flag=0;
	
	//調理時間とその下1桁を求める
	for(int i=0;i<5;i++){
		cook[i]=0;
	    scanf("%d",&cook[i]);
	    simo_1[i]=cook[i]%10;
    }
    
    //次の注文までの待ち時間が最も長い	料理を選ぶ
    //次の注文までの待ち時間が最も長い	料理は最後に選ぶので調理時間だけ加算
    //次の注文までの待ち時間が0の料理は調理時間だけ加算
    //それ以外の料理は調理時間と待ち時間(10-調理時間の下一桁)を加算
    
   	 for(int i=0;i<10;i++){
   	     for(int j=0;j<5;j++){
   	         if(i != 0 && flag==0 && i==simo_1[j]){
   	             flag=1;
   	             //printf("kita1 %d ¥n",cook[j]);
   	             total +=cook[j];
   	         }
   	         else if(i != 0 && i==simo_1[j]){
   	         	//printf("kita2 %d ¥n",cook[j]);
   	         	//printf("%d ¥n",10-simo_1[j]);
   	             total +=cook[j]+(10-simo_1[j]);
   	         }
   	         else if(i==0 && i==simo_1[j]){
   	         	//printf("kita3 %d ¥n",cook[j]);
   	         	total +=cook[j];
   	         }
   	     }
   	 }
   	 
   	 printf("%d",total);
   	 
   	 return 0; 
}

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

#define MOD (1000000000+7)

int main()
{
	long long m, n;
	cin >> m >> n;

	long long ans = 1;
	while( n ) {
		if( n % 2 ) ans = ans * m % MOD;
		m = m * m % MOD;
		n /= 2;
	}

	cout << ans << endl;
}



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

N, M = map(int, input().split())
B = {}
for i in range(1, N+1):
    B[i] = []

for i in range(M):
    a, b = map(int, input().split())
    if b == N or a == 1:
        B[a].append(b)
for sima in B[1]:
    if N in B[sima]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


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

int main ()
{
    int i,j,n,temp=-1;
    cin>>n;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                temp=1;
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    if(temp==-1)
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
import sys
from collections import defaultdict

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()
    L = max(A)
    ad = defaultdict(int)
    for a in A: ad[a] += 1

    ans = 0
    B = [True] * (L + 1)
    for a in A:
        if B[a]:
            if ad[a] == 1: ans += 1
        k = 2 * a
        while k <= L:
            B[k] = False
            k += a

    print(ans)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 120588
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

void swap(int a,int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main(void) {
	int n,k,c;
	cin >> n>>k>>c;
	string s;
	cin >> s;

	vector<int>a(n);
	vector<int>b(n);

	int count = 0;
	int day = 0;

	while (count != k) {
		if (s[day]=='o') {
			a[count] = day;
			count++;
			day += c + 1;
		}
		else {
			day++;
		}
	}

	count = 0;
	day = n-1;

	while (count != k) {
		if (s[day] == 'o') {
			b[k-count-1] = day;
			count++;
			day -= c + 1;
		}
		else {
			day--;
		}
	}

	for (int i = 0; i < k;i++) {
		if (a[i]==b[i]) {
		cout << a[i]+1 << endl;
		}
	}


	return 0;
}

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

#define INF 100000000
#define MOD9(a) (a%1000000009)
#define MOD7(a) (a%1000000007)
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  long long int a,b,x;
  cin >> a >> b>> x;
  long long int count;
  cout << b/x - a/x + (a%x==0?1:0) << endl;

}



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

vector<vector<int> > data;
int h,w,goal;

void dfs(vector<int> v,int depth){
	
	if(w == depth){
		data.push_back(v);
	}else{
		vector<int> vv = v,vvv=v;
		vv.push_back(0);
		dfs(vv,depth+1);
		if(v.size() == 0 || v[v.size()-1] == 0){
			vvv.push_back(1);
			dfs(vvv,depth+1);
		}
	}	
}
int dp[101][10] = {0};
const long long int MOD = 1000000007;

int main(){
	unsigned long long int res = 0;
	cin >> h >> w >> goal;
	for(int i=0;i<=h;++i){
		for(int j=0;j<w;++j){
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	dfs(vector<int>(),1);
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			for(int k=0;k<data.size();++k){
				
				if(j-1 >= 0 && data[k][j-1] == 1){
				//	cout <<"left "<< i << " " << j <<endl;
					dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j]) % MOD;
				}else if(j+1 < w && data[k][j] == 1){
				//	cout <<"right "<< i << " " << j <<endl;
					dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % MOD;
				}else
					dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
			}
		}
	}
	/*
	cout << data.size() <<endl;
	for(int i=0;i<=h;++i){
		for(int j=0;j<w;++j){
			cout << dp[i][j];
		}cout <<endl;
	}
	cout <<endl;
	*/
	cout << dp[h][goal-1] <<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long LL;
const int N = 1e5+5;
 
struct dat{
	int b,l,u;
	LL d;
}a[N];
LL n,full;
LL diff=0,add,sub,s[N];
 
bool check(LL x){
	LL r = x % full, q = x / full, add;
	if(q>=n) return true;
	rep(i,1,n){
		if(r<=a[i].b) add = 1ll * a[i].l * r;
		else add = 1ll * a[i].l * a[i].b + 1ll * a[i].u * (r-a[i].b);
 
		if(i<=q) add += s[q+1] - 1ll * a[i].d;
		else add += s[q];
		if(diff+add>=0ll)return true;
	}
	return false;
}
 
int main(){
	scanf("%d%lld",&n,&full);
	rep(i,1,n){
		scanf("%d%d%d",&a[i].b,&a[i].l,&a[i].u);
		add = 1ll*a[i].u*(full-a[i].b);
		sub = 1ll*a[i].l*a[i].b;
		a[i].d = add + sub;
		diff -= sub;
	}
	sort(a+1,a+n+1,[](dat x, dat y){return x.d>y.d;});
	s[0]=0;
	rep(i,1,n)s[i]=s[i-1]+a[i].d;
	LL l=0,r=1e15,ans=1e15;
	while(l<=r){
		LL mid = l+r>>1;
		if(check(mid)){
			ans = min(ans, mid);
			r = mid - 1;
		}else{
			l = mid + 1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
import java.io.*;
import java.math.*;
import java.util.*;
class Main
{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));			        
  int n,k,i=0;
  BigInteger s;
  s=BigInteger.ZERO;
  String[] strs=br.readLine().trim().split("\\s+");
  n=Integer.parseInt(strs[0]);
  k=Integer.parseInt(strs[1]);
  int a[]=new int[n];

  String[] strsa=br.readLine().trim().split("\\s+");
  
  for(i=0;i<n;i++)                 
{                                              
a[i]=Integer.parseInt(strsa[i]);
}
  if((k-n)>=0)
    System.out.println("0");
  else if((k-n)<0)
  {
    Arrays.sort(a);
    for(i=0;i<n-k;i++)
      s=s.add(BigInteger.valueOf(a[i]));
    System.out.println(s);
  }
  /*else
  {
  for(i=0;i<n;i++)
      s=s.add(BigInteger.valueOf(a[i]));
    System.out.println(s);
  }*/
}
}


Measured memory_bytes: 66028
#include<iostream>
using namespace std;
int main(){
int a,num[100];
cin >> a;
for(int z=0; z<a; z++){
cin >> num[z];
}
for(int z=a-1; z>=0; z--){
if(z!=a-1) cout << " ";
cout << num[z];
}
cout <<endl;
return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m);

    if (n >= m){
        cout << 0 << endl;
        return 0;
    }

    int min_x = 1000*1000;
    int max_x = - 1000*1000;
    for (int i=0; i<m; i++){
        cin >> x[i];

        if (x[i]<=min_x){
            min_x = x[i];
        }
        if (max_x<=x[i]){
            max_x = x[i];
        }

    }

    sort(x.begin(), x.end());

    int diff = max_x - min_x;

    vector<int> y(m-1);
    for (int i=1; i<m; ++i){
        y[i-1] = x[i] - x[i-1];
    }

    sort(y.begin(), y.end(), greater<int>());
    int ans = diff;
    for (int i=0; i<n-1; i++){
        ans -= y[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>

using namespace std;
typedef pair<int, string> p;

void solve()
{
	int n;
	while(cin >> n)
	{
		map<p, int> list;
		for(int i = 0; i < n; ++i)
		{
			string product;
			cin >> product;
			int num;
			cin >> num;
			list[p(product.size(), product)] += num;
		}
		map<p, int>::iterator it = list.begin();
		while(it != list.end())
		{
			cout << it->first.second << " " << it->second << endl;
			++it;
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i=1;i<=n;i+=2){
        int cnt = 0;
        for(int j=1;j<=i;j++){
            if(i%j==0){
                cnt++;
            }
        }
        if(cnt == 8){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <list>
using namespace std;
int V,E;
vector<int> G[100000];
int visited[10000];
int L[100000];
int s=0;
void visit(int n){
  if(visited[n]==0){
    visited[n]=1;
    for(int i=0;i<G[n].size();i++){
      visit(G[n][i]);
    }
    L[s++]=n;
  }
}
void topological(){
  for(int i=V-1;i>=0;i--){
    visit(i);
  }
}
int main(){
  scanf("%d %d",&V,&E);
  for(int i=0;i<E;i++){
    int s,t;
    scanf("%d %d",&s,&t);
    G[s].push_back(t);
  }
  topological();
  for(int i=V-1;i>=0;i--)printf("%d\n",L[i]);
  return 0;
}

Measured memory_bytes: 5988
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int n;
	int a[111111*2];
	a[0]=0;
	cin>>n;
	for(int i=1;i<n+1;i++){
	    int b;
	    cin>>b;
	    a[i]=a[i-1]+b;
	}
	sort(a,a+n+1);
	a[n+1]=-1;
	int co=0,ans=0;
	rep(i,n+1){
	    if(a[i]==a[i+1])co++;
	    else{
	        co++;
	        ans+=co*(co-1)/2;
	        co=0;
	    }
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 1792
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int count = Integer.parseInt(std.nextLine());
        Stream<Integer> meals = IntStream.range(0, count).map(it -> std.nextInt()).boxed();
        Stream<Integer> satisfactionLevels = IntStream.range(0, count).map(it -> std.nextInt()).boxed();
        Stream<Integer> extraSatisfactionLevels = IntStream.range(0, count - 1).map(it -> std.nextInt()).boxed();

        System.out.println(totalSatisfaction(meals.collect(Collectors.toList()),
                satisfactionLevels.collect(Collectors.toList()),
                extraSatisfactionLevels.collect(Collectors.toList())));
    }

    private static int totalSatisfaction(List<Integer> meals,
                                         List<Integer> levels,
                                         List<Integer> extraLevels) {
        int totalLevel = IntStream.range(0, meals.size())
                .reduce(0, (acc, index) -> {
                    Integer meal = meals.get(index);
                    Integer level = levels.get(meal - 1);
                    acc += level;
                    if (index > 0) {
                        Integer beforeMeal = meals.get(index - 1);
                        if (meal - beforeMeal == 1) {
                            Integer extraLevel = extraLevels.get(beforeMeal - 1);
                            acc += extraLevel;
                        }
                    }

                    return acc;
                });

        return totalLevel;
    }
}


Measured memory_bytes: 27220