akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n];
	int b[100000]={0};
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[a[i]]++;
	}
	int kind=0;
	for(int i=0;i<100000;i++){
		if(b[i]>0){
			kind++;
		}
	}
	if(kind%2==1){
		cout<<kind<<endl;
	}
	else{
		cout<<kind-1<<endl;
	}
			
}		

Measured memory_bytes: 1024
def main(input = STDIN)
    maxv, minv = -1.0 / 0.0, 1.0 / 0.0
    input.gets.to_i.times do
        i = input.gets.to_i
        maxv = i - minv if (i - minv) > maxv
        minv = i if i < minv
    end
    puts maxv
end
main


Measured memory_bytes: 6868
#include"bits/stdc++.h"
#include<math.h>
#include<stdio.h>
using namespace std;

struct point {
	double x, y;
};

void kochCurve(int N, point p1, point p2);

int main(void) {

	int N;
	cin >> N;

	point p1, p2;
	p1.x = 0.0;
	p1.y = 0.0;
	p2.x = 100.0;
	p2.y = 0.0;

	printf("%.8f %.8f\n", p1.x, p1.y);
	kochCurve(N, p1, p2);
	printf("%.8f %.8f\n", p2.x, p2.y);

	return 0;
}

void kochCurve(int N, point p1, point p2)
{
	if (N == 0) return;

	double th = M_PI * 60.0 / 180.0;
	point s, u, t;
	s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
	s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
	t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
	t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	kochCurve(N - 1, p1, s);
	printf("%.8f %.8f\n", s.x, s.y);
	kochCurve(N - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	kochCurve(N - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	kochCurve(N - 1, t, p2);

}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
//#define long long long
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    string N(4, '#');
    for(int i = 0; i < 4; i++){
        cin >> N[i];
    }
    sort(all(N));
    YES(N == "1479");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;

ll dp[110][100100];//n番目に入れた入れてない価値vのナップサック、中身はそれの最小の重さw

int main(){
  ll n,w;
  cin >> n >>w;
  ll wl[110],v[110];
  rep(i,n)cin >> wl[i] >> v[i];
  
  rep(i,110){
    rep(r,100100){dp[i][r]=10000000000000;}
  }
  dp[0][0]=0;

  rep(i,n){
    rep(r,100100){
      if(v[i]<=r){chmin(dp[i+1][r],dp[i][r-v[i]]+wl[i]);}
      chmin(dp[i+1][r],dp[i][r]);
    }
  }
  ll res=0;
  rep(i,100100){
    if(dp[n][i]<=w)res=i;
  }

  cout << res << endl;
}

Measured memory_bytes: 86272
N=int(input())
lenga=list(map(int,input().split()))

cnt =0
index =1
i=0
while i <N:
    if lenga[i]!=index:
        cnt+=1
    else:
        index+=1

    i+=1

if cnt>N-1:
    print('-1')
else:
    print(cnt)

Measured memory_bytes: 26140
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
c=0
for i in range(N):
    if B[i]<=A[i]:
        A[i]-=B[i]
        c+=B[i]
    elif B[i]<=A[i]+A[i+1]:
        A[i+1]+=A[i]-B[i]
        c+=B[i]
    else:
        c+=A[i]+A[i+1]
        A[i+1]=0
print(c)

Measured memory_bytes: 24184
n = int(input())
ma = 100003
prime = [True] * (ma + 1)
prime[0] = False
prime[1] = False
for i in range(2, int(ma ** 0.5) + 1):
    if not prime[i]:
        continue
    for j in range(i * 2, ma + 1, i):
        prime[j] = False
if prime[n]:
    print(n)
else:
    for i in range(n + 1, len(prime)):
        if prime[i]:
            print(i)
            break

Measured memory_bytes: 3828
#include <stdio.h>
#include <math.h>

int main(int argc, char const *argv[]) {
    int N;
    //入力
    scanf("%d", &N );
    //計算
    int ans = N;
    for (size_t i = 0; i <= N; i++) {
        int count = 0;
        int t = i;
        while ( t > 0) {
            count += t %6;
            t = t/6;
        }
        t = N-i;
        while ( t > 0) {
            count += t%9;
            t = t/9;
        }
        if ( ans > count) {
            ans = count;
        }
    }
    //出力
    printf("%d\n", ans );
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
typedef vector<int> Vector;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}
LL mfrac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}
LL mcomb(LL n, LL r) {

    if(n == 0 and r == 0) {
        return 1;
    } else if(n < r || n < 0) {
        return 0;
    }

    LL res = mfrac(n) * mpower(mfrac(r), MOD - 2) % MOD;
    res *= mpower(mfrac(n - r), MOD - 2) % MOD;

    return res;
}

int main(void) {
    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    for(int i = 0; i <= 999; i++) {
        char buf[4];
        sprintf(buf, "%03d", i);
        string pw = string(buf);

        vector<bool> is_correct_pw(3);
        int checking_digit = 0;
        for(int i = 0; i < S.size(); i++) {
            if(S[i] == pw[checking_digit]) {
                is_correct_pw[checking_digit] = true;
                checking_digit++;
                if(checking_digit == 3){
                    break;
                }
            }
        }

        for(int i = 0; i < 3; i++) {
            if(!is_correct_pw[i]) {
                break;
            }

            if(i == 2) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
int main()
{
    ll n,sum=0;
    cin>>n;
    ll a[5];
    for(int i=0;i<5;i++)
    {
         cin>>a[i];
    }
    ll mn = *min_element(a,a+5);
    ll val = n/mn;
    ll mod = n%mn;
    if(mod>0)
        val++;
    cout<<4+val<<'\n';
}


Measured memory_bytes: 256
#C問題
L,R = map(int,input().split())
r = R%2019
l = L%2019
if R-L>=2019:
    print(0)
else:
    if r < l:
        print(0)
    else:
        MIN = 2018
        for i in range(r-l):
            I = i+l
            for j in range(r-l):
                J = j+l+1
                kari = (I*J)%2019
                MIN = min(MIN,kari)
        print(MIN)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string S;
int p,ch[1<<8];

ll getNum(){
  ll res=0;
  while(isdigit(S[p])) res=res*10+S[p++]-'0';
  return res;
}

ll get(ll &a,ll b,char c){
  if(c=='+')a+=b;
  if(c=='-')a-=b;
  if(c=='*')a*=b;
  return a;
}

ll calc(int c){
  ll res,t;
  if(S[p]=='(') p++,res=calc(-1),p++;
  else res=getNum();
  while(ch[S[p]]>c)t=S[p++],get(res,calc(ch[t]),t);
  return res;
}

int main(){
  cin>>S; 
  ch[0]=ch[')'] = -1000;
  ll res=calc(-1);
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++) {
	ch['+']=i,ch['-']=j,ch['*']=k;
	p=0;
	res=max(res,calc(-1));
      }
  
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3188
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


N,M = nm()
print(N*(N-1)//2 + M*(M-1)//2 )


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>


typedef struct strData {
	char string[64];
	int alphabet[27]; /* a:1, z:26 */
} STRDATA;


int main(){
	
	int n;
	scanf("%d", &n);
	
	STRDATA stringList[n+1];
	int i;
	for( i = 1; i < n+1; i++ ){
		scanf( "%s", &(stringList[i].string) );
	}
	
	for( i = 1; i < n+1; i++ ){
		
		int j;
		for( j = 0; j < 27; j++ ){
			stringList[i].alphabet[j] = 0;
		}
		
		j = 0;
		char currentChar = stringList[i].string[0];
		while( currentChar != '\0' ){
			
			stringList[i].alphabet[ currentChar - 96 ]++;
			j++;
			currentChar = stringList[i].string[j];
			
		}		
		
	}
	
	
	for( i = 1; i < 27; i++ ){
		
		int min = stringList[1].alphabet[i];
		int j;
		for( j = 2; j < n+1; j++ ){
			
			if( stringList[j].alphabet[i] < min ){
				min = stringList[j].alphabet[i];
			}
			
		}
		
		for( j = 0; j < min; j++ ){
			printf("%c", i + 96 );
		}
		
	}
	
	printf("\n");	
	
	return 0;
	
}

Measured memory_bytes: 128
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define int long long
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 1000005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[li];
int cev;
string s;
vector<int> v;

inline int f(int sira){
	int cevv=0;
	if(sira>n)return 0;
	if(sira==n)return 1;
	if(~dp[sira])return dp[sira];
	cevv=max(f(sira+100),cevv);
	cevv=max(f(sira+101),cevv);
	cevv=max(f(sira+102),cevv);
	cevv=max(f(sira+103),cevv);
	cevv=max(f(sira+104),cevv);
	cevv=max(f(sira+105),cevv);
	return dp[sira]=cevv;
}

main(void){
	memset(dp,-1,sizeof(dp));
	scanf("%lld",&n);
	cev=f(0);
	if(cev>0)printf("1\n");
	else printf("0\n");
	return 0;
}



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

using namespace std;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n;
	cin >> n;

	vector<int> h(n + 1), dp(n + 1);

	for(int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	
	dp[2] = abs(h[2] - h[1]);

	for(int i = 3; i <= n; i++) {
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	}

	cout << dp[n];

	return 0;
}

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

typedef long long ll;

using namespace std;

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define II pair <int,int>
#define fi first
#define se second

const int maxn=1e5+10;
const ll maxN=1e18+10;
const int MOD=1e9;

bool cmp(II a, II b)
{
    return a.se<b.se;
}

int main()
{
    //freopen("IN.INP","r",stdin);
    //freopen("OUT.OUT","w",stdout);
    int a,b,c;
    cin >> a >> b >> c;
    if (a==b&&b==c) cout << "No";
    else if (a==b||a==c||b==c) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    for (ll i = 1; i < 10; i++)
    {
        ll temp = n / i;
        if (n % i == 0 && 1 <= temp && temp <= 9)
        {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n , k ;
  	cin >> n >> k ;
  	if(k == 1){
      cout << 0 ;
      return 0 ;
    }
  	cout << n - k ;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
w = list(input())

word_counter = {}
for i in w:
  if i in word_counter:
    word_counter[i] += 1
  else:
    word_counter[i] = 1

for wc in word_counter.values():
  if wc % 2 != 0:
    print('No')
    exit(0)
    
print('Yes')

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

#define maxn 100005

using namespace std;
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(0);

  vector < pair < int, int > > ret;
  
  int n;
  cin >> n;
  
  ll suma(0), sumb(0);
  
  for (int i = 0; i < n; ++i) {
  	int a, b;
	cin >> a >> b;
	
	suma += a;
	sumb += b;
	
	ret.push_back({a, i});
	ret.push_back({b, i});	
  }
  
  sort(ret.begin(), ret.end());
  
  vector < int > cnt(n);
  
  ll ans = 0, flag = 0;
  
  for (int i = 0; i < n; ++i) {
  	ans += ret[i].first;
  	cnt[ret[i].second] ++;
  	if (cnt[ret[i].second] == 2) flag = 1;
  }
  
  if (flag) {
    cout << ans;
    return 0;
  }
    
  if (ret[n - 1].second == ret[n].second) 
  	ans += min(ret[n].first - ret[n - 2].first, ret[n + 1].first - ret[n - 1].first);
  else
  	ans += ret[n].first - ret[n - 1].first;
  	
  cout << min(ans, min(suma, sumb));
  
  return 0;
}

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

pair<long long, long long> func(long long N){
    long long M,m;
    m = N % 10;
    long long tmp=0;
    while(N){
        tmp = N;
        N /= 10;
    }
    M = tmp;
    return make_pair(m,M);
}

int main(){
    long long N;
    vector<vector<long long>> A(10,(vector<long long> (10,0)));
    //vector<vector<int>> B(10,(vector<int> (10,0)));
    cin >> N;
    //cout << func(N).first <<' '<<func(N).second <<endl;
    //return 0;
    for(long long i=1; i<=N; i++){
        pair<long long,long long> p = func(i);
        A[p.first][p.second]++;
    }
    long long cnt=0;
    rep(i,10){
        rep(j,10){
            long long tmp = A[i][j] * A[j][i];
            cnt += tmp;
            
    
        }
    }
    /*rep(i,10){
        cout << A[i][i] <<' ';
    }
    cout << endl;
    */
    cout << cnt << endl;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x,k,d;
    cin >> x >> k >> d;
    if(x<0) x=-x;
    ll c=(x+d-1)/d;
    if((x%d)==0) c++;
    c--;
    x-=d*min(c,k);;
    k-=min(c,k);
    k%=2;
    if(k==1) x-=d;
    cout << abs(x) << "\n";
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 1LL << 60;

int main() {
    int N; int64_t K;
    cin >> N >> K;
    vector<int64_t> A(N);
    for(auto &e : A) cin >> e;
    sort(A.begin(), A.end());
    int64_t L = -INF, R = INF;
    while(R - L > 1) {
        int64_t x = (L + R) / 2;
        int64_t total = 0;
        for(int i = 0; i < N; ++i) {
            int l = i, r = N;
            while(r - l > 1) {
                int c = (l + r) / 2;
                (A[i] * A[c] < x) ^ (A[i] >= 0) ? r = c : l = c;
            }
            total += A[i] >= 0 ? l - i : N - r;
        }
        total < K ? L = x : R = x;
    }
    cout << L << '\n';
    return 0;
}


Measured memory_bytes: 4832
////#include <bits/stdc++.h>
////
////using namespace std;
////
////int main() {
////    int n,k;
////    while(cin >> n >> k){
////            if(n % k) cout << 1 << endl;
////    else cout << 0 << endl;
//////        cout << n / k - n % k << endl;
////    }
////    return 0;
////}
//
////
////#include <bits/stdc++.h>
////
////using namespace std;
////
////const int maxn = 200000;
////bool vis[maxn];
////int main() {
////    int n;
////    while(cin >> n) {
////        memset(vis,0,sizeof(vis));
////        for(int i = 0; i < 100; i++) {
////            int sum = i * 4;
////            for(int j = 0; j < 100; j++) {
////                sum += j * 7;
////                vis[sum] = 1;
////            }
////        }
////    if(vis[n]) printf("Yes\n");
////    else printf("No\n");
////    }
////    return 0;
////}
//
//
//
////
////
////#include <bits/stdc++.h>
////
////using namespace std;
////
////const int maxn = 200000;
////bool vis[maxn];
////long long s[maxn];
////long long n;
////
////int main() {
////    int n;
////    while(cin >> n) {
////        string ans = "";
//////        if(n == 0) cout << 0 << endl;
////        while(n) {
////            int m = n;
////            int x = abs(n) % 2;
////            char c = x + '0';
////            ans += c ;
////            n /= -2;
////            if(m < 0 && abs(m) & 1)
////                n++;
////        }
////        reverse(ans.begin(),ans.end());
////        cout << ans << endl;
////    }
////    return 0;
////}
////
//
//
//
//
//
//
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    while(cin >> n) {
        int p[] = {111,222,333,444,555,666,777,888,999};
        for(int i = 0;i < 20;i++){
            if(p[i] >= n){
                 printf("%d\n",p[i]);
                 break;
            }
        }
    }
    return 0;
}




//#include <bits/stdc++.h>
//using namespace std;
//
//const int p[] = {1,2,3,4,5,6,7,8,9,11,22,33,44,55,66,77,88,99,111,222,333,444,555,666,777,888,999,1111,2222,3333,4444,5555,6666,7777,8888,9999};
//
//int main() {
//	int n;
//	cin >> n;
//	for (int i = 0; ; ++ i) {
//		if (p[i] >= n) {cout << p[i];return 0;}
//	}
//}
//

//
//
//
////#include <bits/stdc++.h>
////
////using namespace std;
////
////const int maxn = 200000;
////map<long long,long long>mm;
////int n;
////long long m;
////int main() {
////    while(cin >> n >> m) {
////        long long num,sum = 0,ans = 0;
////        mm.clear();
////        mm[0]++;
////        for(int i = 1; i <= n; i++) {
////            cin >> num;
////            sum += num;
////            sum %= m;
////            ans += mm[sum];
////            mm[sum]++;
//////            cout << sum <<"   " << ans << endl;
////        }
////        cout << ans << endl;
////    }
////    return 0;
////}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, s[3007][3007], fac[3007], inv[3007], res, mod;
int fpow(int a, int x, int mod)
{
	int res = 1;
	while (x)
	{
		if (x & 1)res = 1LL * res * a % mod;
		a = 1LL * a * a % mod;
		x >>= 1;
	}
	return res;
}
int main()
{
	cin >> n >> mod;
	s[0][0] = 1;
	for (int i = 1; i <= n + 1; i++)
		for (int j = 1; j <= n + 1; j++)
			s[i][j] = (1LL * s[i - 1][j] * j % mod + s[i - 1][j - 1]) % mod;
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i <= n; i++)
		fac[i] = 1LL * fac[i - 1] * i % mod;
	for (int i = 2; i <= n; i++)
		inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = 2; i <= n; i++)
		inv[i] = 1LL * inv[i - 1] * inv[i] % mod;
	for (int i = 0; i <= n; i++)
	{
		int tot = 0;
		int a = fpow(2, fpow(2, n - i, mod - 1), mod);
		int b = fpow(2, n - i, mod);
		for (int j = 0, k = 1; j <= i; j++, k = 1LL * k * b % mod)
			tot = (tot + 1LL * s[i + 1][j + 1] * a % mod * k % mod) % mod;
		res = (res + 1LL * (i & 1 ? mod - 1 : 1) * fac[n] % mod * inv[i] % mod * inv[n - i] % mod * tot % mod) % mod;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll int n,i,ans,l,a;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n;
	cin >> l;
	ans=l;
	for(i=0;i<n-2;i++){
		cin >> a;
		ans+=min(l,a);
		l=a;
	}
	cout<<ans+l;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 // cout << (char)(z + 1);

int main(){
  string S;
  int frag;
  cin >> S;
  for (char c = 'a'; c != '{'; c = (char)(c + 1)){
    frag = 0;
    for (int i = 0; i < S.size(); i++){
      if(S.at(i) == c){
        frag = 1;
      }
    }
    if(frag == 0){
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const ll INF = 1e18;
const int MX = 305;

int N,K,MOD, dp[MX][MX], cum[MX][MX], comb[MX][MX];
// i terms, mx = j
// i terms, mx >= j 

int ad(int a, int b) { return (a+b)%MOD; }
int mul(int a, int b) { return (ll)a*b%MOD; }

void solve(int num, int mx) {
    if (num == 0) {
        dp[num][mx] = 1;
        return;
    }
    
    FOR(i,1,num+1) 
        // num-1 choose i-1 
        dp[num][mx] = ad(dp[num][mx],mul(comb[num-1][i-1],
                    mul(dp[num-i][mx],cum[i-1][mx+1])));
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> K >> MOD;
    comb[0][0] = 1;
    FOR(i,1,MX) F0R(j,i+1) {
        comb[i][j] = comb[i-1][j];
        if (j) comb[i][j] = ad(comb[i][j],comb[i-1][j-1]);
    }
    F0R(i,N+1) {
        F0R(j,K+1) solve(i,j);
        F0Rd(j,K+1) cum[i][j] = ad(cum[i][j+1],dp[i][j]);
    }
    cout << dp[N][0];
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 1408
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 200001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
int N;
LL T;
LL t[MaxN];
void solve()
{
    LL ans = 0;
    LL s = 0, e = 0;
    for(int i=1;i<=N;i++)
    {
        if(t[i]>e) 
        {
            ans += (e-s);
            s = t[i]; 
            e = t[i]+T;
        }
        else e = t[i]+T;
    }
    ans += e-s;
    printf("%lld\n", ans);
}
int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%d%lld",&N, &T);
    for(int i=1;i<=N;i++) scanf("%lld", &t[i]);
    solve();
    //system("pause");
}


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

int main()
{
  char AT[100000];
  gets(AT);
  unsigned long long int len=strlen(AT)-2;
  char a,b;
  a=AT[0];
  b=AT[strlen(AT)-1];
  cout<<a<<len<<b;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define y1 cgbngfgn
#define pb push_back
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fir first
#define m_p make_pair
#define sec second
#define files(name) freopen(name".dat","r",stdin); freopen (name".sol","w",stdout);
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#define time pdojegoritg
typedef long long ll;
typedef long double ld;
const int arr=500000;
short int dp[5010][5010];
signed main()
{
    int n;
    cin>>n;
    map<int,int> mp;
    for (int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        mp[a]++;
    }

    int res=0;
    for (auto i:mp)
    {
        if (i.sec>=i.fir)
            res+=i.fir;
    }

    cout<<n-res;
}


Measured memory_bytes: 4736
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

int main() {
  ll x,y,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1e9,Min=1e9+1;
  string s,t,u;
  bool ok = false;
  cin >> s >> t >> x >> y >> u;
  if(s == u) {
    cout << x-1 << " " << y <<endl;
  }
  else if (t==u){
    cout << x << " " << y-1 <<endl;
  }

  

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main() {
/*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,w;
    cin>>n>>w;
    ll a[n][2];
    for(int i=0;i<n;i++){
        cin>>a[i][0]>>a[i][1];
    }
    pair<bool,ll> dp[n][100001];
    for(int i=0;i<n;i++){
        dp[i][0].first=true; dp[i][0].second=0;
    }
    
    for(int j=1;j<=100000;j++){
        if(j==a[0][1] && a[0][0]<=w) dp[0][j]={true,a[0][0]};
        else dp[0][j]={false,-1};
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<=100000;j++){
            bool ans=false;
            ll l=1e15;
            if(dp[i-1][j].first && dp[i-1][j].second<=w){
                ans=true; l=dp[i-1][j].second;
            }
            if(a[i][1]<=j){
                if(dp[i-1][j-a[i][1]].first && dp[i-1][j-a[i][1]].second<=w-a[i][0]){
                    ans=true; l=min(l,dp[i-1][j-a[i][1]].second+a[i][0]);
                }
            }
            dp[i][j]={ans,l};
        }
    }
    for(int j=100000;j>=0;j--){
        if(dp[n-1][j].first){
            cout<<j; return 0;
        }
    }
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main ()
{
  prep();
  int h, n;
  cin >> h >> n;
  int sum = 0;
  for (int i=0; i<n; i++){
      int num;
      cin >> num;
      sum += num;
  }
  if (sum < h){
      cout << "No";
  }else{
      cout << "Yes";
  }
  return 0; 
}


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

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 1e5 + 5;
ll n , k;
ll p[N] , c[N] , vis[N];
vector<ll> adj[N];
vector<ll> s;
ll score;
void dfs(ll parent){
    vis[parent] = 1;
    score += c[parent];
    s.pb(score);
    for(auto child : adj[parent]){
        if(!vis[child]){
            dfs(child);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;
    for(int i = 1; i <= n; i++){
        cin>>p[i];
        adj[i].pb(p[i]);
    }
    for(int i = 1; i <= n; i++){
        cin>>c[i];
    }
    ll ans = -(ll)1e18;
    for(int i = 1; i <= n; i++){
        score = 0;
        memset(vis , 0 , sizeof(vis));
        dfs(i);
        ll moves = k / sz(s);
        ll mx = -(ll)1e18;
        if(s.back() > 0 && k >= sz(s)){
            if(moves >= 1){
                for(int j = 0; j < sz(s); j++){
                    mx = max(mx , s[j]);
                }
                ans = max(ans , (moves - 1)*s.back() + mx);
            }
                mx = 0;
                ll rem = k % sz(s);
                for(int j = 0; j < rem; j++){
                    mx = max(mx , s[j]);
                }
                ans = max(ans , moves*s.back() + mx);
        }else{
            for(int j = 0; j < k; j++){
                if(j < sz(s)){
                    ans = max(ans , s[j]);
                }else{
                    break;
                }
            }

        }
        s.clear();
    }
    cout<<ans;
}

Measured memory_bytes: 7332
NULL = 10000
TOWN_COUNT = 10

while True:

    input_count = int(input())

    if input_count == 0:
        break

    adjacency_matrix = [[NULL] * TOWN_COUNT for _ in range(TOWN_COUNT)]

    for lp in range(TOWN_COUNT):
        adjacency_matrix[lp][lp] = 0

    need_range = 0

    for _ in range(input_count):
        start, end, time = [int(item) for item in input().split(" ")]

        adjacency_matrix[start][end] = time
        adjacency_matrix[end][start] = time

        need_range = max(need_range, start, end)

    for a in range(need_range + 1):
        for b in range(need_range + 1):
            for c in range(need_range + 1):
                adjacency_matrix[b][c] = min(adjacency_matrix[b][a] + adjacency_matrix[a][c], adjacency_matrix[b][c])

    min_time = NULL
    min_index = -1

    for index, item in enumerate(adjacency_matrix):
        need_element = [item2 for item2 in item if 0 < item2 < NULL]

        if 0 < len(need_element):
            time = sum(need_element)

            if time < min_time:
                min_time = time
                min_index = index

    print(min_index, min_time)



Measured memory_bytes: 5604
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  int K;
  std::cin >> K;
  bool find = false;
  int amari = 7%K;
  int ans;
  for (int i=1; i<K+5; i++) {
    if (amari==0) {
      find=true;
      ans = i;
      break;
    }
    amari = (amari*10+7)%K;
  }
  if (!find) {
    std::cout << -1 << std::endl;
  } else {
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    int N;
    string S;
    cin>>N;
    cin>>S;
    int blaL = 0;
    int whiR = 0;
    for(int i = 0; i<N; i++){
        if(S[i]=='.'){
            whiR++;
        }
    }
    int ans = whiR;
    for(int i = 0; i<N; i++){
        if(S[i]=='.'){
            whiR--;
        }else{
            blaL++;
        }
        ans = min(ans,whiR+blaL);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define int long long
#define F first
#define S second
#define sz(x) ((int)x.size())
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'

const int mod = 1e9 + 7;
const int N = 3e5 + 5;

int a[N];
 
inline void solve() {
	int n, ans(0);
	cin >> n;
	rep(i, 1, n) {
		cin >> a[i];
	}
	rep(i, 2, n-1) {
		if ((a[i] > a[i-1] && a[i] < a[i+1]) || (a[i] < a[i-1] && a[i] > a[i+1])) {
			++ans;
		}
	}
	cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t; while(t--)
                solve();
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
h.insert(0,0)
good = [0] + [1] * n
for i in range(m):
    x,y = map(int,input().split())
    if h[x] > h[y]:
        good[y] = 0
    elif h[x] < h[y]:
        good[x] = 0
    else:
        good[x] = 0
        good[y] = 0

print(sum(good))


Measured memory_bytes: 20120
import string

N = int(input())
S = input()

up_s = string.ascii_uppercase

def caesar(s, shift_num):
    index = up_s.index(s)
    shifted_index = index + shift_num

    if shifted_index <= 25:
        return up_s[shifted_index]
    
    else:
        return up_s[shifted_index - 26]


print(''.join([caesar(s, N) for s in S]))

Measured memory_bytes: 3772
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
ll gcd (ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
main(){
    int N;
    cin >> N;
    ll ans = 1;
    for(int i = 0;i < N;i++){
        ll a;
        cin >> a;
        ans = ans / gcd(a, ans) * a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    if (a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)){
        cout << "YES" << endl;
        return 0;
    } else {
        cout << "NO" << endl;
        return 0;
    }
}

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

#define FOR(i, a, b)  for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long

using namespace std;

int out[110][110];
int arr[10100];

int main() {
  ios_base::sync_with_stdio(false);

  int h, w, n;
  cin >> h >> w >> n;
  REP(i, n) {
    cin >> arr[i];
  }
  int ind = 0;
  int cou = 0;
  REP(i, h) {
    if (i % 2 == 0) {
      REP(j, w) {
        out[i][j] = ind + 1;
        cou++;
        if (arr[ind] == cou) {
          cou = 0;
          ind++;
        }
      }
    }
    else {
      FORd(j, w - 1, 0) {
        out[i][j] = ind + 1;
        cou++;
        if (arr[ind] == cou) {
          cou = 0;
          ind++;
        }
      }
    }
  }

  REP(i, h) {
    REP(j, w) {
      cout << out[i][j] << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
N, M = map(int,input().split())
A = [int(a) for a in input().split()]
BC = [[0,0] for _ in range(M)]

for i in range(M):
    B,C = map(int,input().split())
    BC[i] = [B,C]

a_use = sorted(A)
bc_use = sorted(BC, reverse=True, key=lambda x: x[1])

low_index = 0
for i in range(M):
    if low_index > N-1:
        break
    if a_use[low_index] > bc_use[i][1]:
        break
    else:
        for j in range(bc_use[i][0]):
            if j + low_index > N-1:
                break
            if a_use[j+low_index] < bc_use[i][1]:
                a_use[j+low_index] = bc_use[i][1]
        low_index += bc_use[i][0]

print(int(sum(a_use)))

Measured memory_bytes: 27128
#include <iostream>
#include <algorithm>
#include <list>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cfloat>
#include <climits>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <numeric>
#include <functional>
#include <utility>
#include <iomanip>
#include <iterator>
#include <stack>
#include <limits>
#include <sstream>
#include <fstream>
#include <ostream>
#include <bitset>
#include <queue>
#include <ctime>
#include <utility>

#define ms(a,n) (memset(a,n,sizeof(a)))
#define msv(a,v,n) for(int _a;_a<=n;_a++) a[_a]=v;
#define all(res) res.begin(),res.end()
#define mp(a,b) (make_pair(a,b))
#define pb(n) push_back(n)
#define mod 1000000007

using namespace std;

template<class T1> void deb(T1 e){cout<<e<<'\n';}
template<class T1,class T2> void deb(T1 e1,T2 e2){cout<<e1<<" "<<e2<<'\n';}
template<class T1,class T2,class T3> void deb(T1 e1,T2 e2,T3 e3){cout<<e1<<" "<<e2<<" "<<e3<<'\n';}
template<class T1,class T2,class T3,class T4> void deb(T1 e1,T2 e2,T3 e3,T4 e4){cout<<e1<<" "<<e2<<" "<<e3<<" "<<e4<<'\n';}
template<class T> inline T gcd(T a,T b) {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

typedef long long ll;
typedef pair< int, int> PII;
typedef vector< int> VI;
typedef vector< vector<int> > VVI;
typedef map< string, int> MSI;

ostream_iterator<int> screen(cout," ");
//copy(all(res),screen);

const int  sz=2*1000*100+10;
const int inf=INT_MAX>>1;
const ll big=(1LL<<62);
const double pi =acos(-1.0);
int dx[]={0,0,1,-1,1,1,-1,-1},dy[]={1,-1,0,0,1,-1,1,-1};
VI res;

ll powermod(ll n,ll p)
{
    ll x=1,y=n%mod;
    while(p)
    {
        if(p&1LL)
            x=(y*x)%mod;
        y=(y*y)%mod;
        p=p>>1LL;
    }
    return x;
}

int main()
{
    //std::ios_base::sync_with_stdio(false);
    ll n,m;
    while(cin>>n>>m)
    {
        cout<<gcd(n,m)<<' '<<lcm(n,m)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
const int sz=1e5+9;
long long a[sz];
int n;
long long sum;
long long ans[sz];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%I64d",&a[i]);
        a[i]<<=1;
        if(i&1) sum+=a[i];
        else sum-=a[i];
    }
    ans[1]=sum>>1;
    for(int i=1;i<=n;i++) ans[i+1]=a[i]-ans[i];
    for(int i=1;i<=n;i++) printf("%I64d ",ans[i]);
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

int main(void)
{
    LL N;
    cin >> N;
    vector<LL> A(N);
    LL s = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        s += A[i];
    }
    LL mind = 2020202020.;
    LL minda;
    LL a = 0;
    for (int i = 0; i < N; i++) {
        a += A[i];
        LL d = ceil(abs(s/2.0 - a));
        if (d < mind) {
            mind = d;
            minda = a;
        }
    }
    cout << abs(2*minda - s) << endl;

    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  vector<pair<int64_t,int64_t>>C(N);
  for(int i=0;i<N;i++){
  int64_t x,y;
    cin>>x>>y;
    C.at(i).first=x;
    C.at(i).second=y;
  }
  sort(C.begin(),C.end());
  int64_t ans=0;
  int64_t rest=M;
  for(int i=0;i<N;i++){
  if(C.at(i).second<=rest){
  ans+=C.at(i).first*C.at(i).second;
    rest-=C.at(i).second;
  }else{
  ans+=C.at(i).first*rest; break;
  }
    }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	int n; std::cin >> n;
	std::cout << n * n * n << std::endl;
}

Measured memory_bytes: 888
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num=0;
        ArrayList<Integer> List = new ArrayList<>();
        for(int a=0;a<4;a++) List.add(sc.nextInt());
        if(List.contains(1)==true) num++;
        if(List.contains(9)==true) num++;
        if(List.contains(7)==true) num++;
        if(List.contains(4)==true) num++;

        if(num==4) System.out.println("YES");
        else System.out.println("NO");
    }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> Takoyaki(N);
    for (int i=0; i<N; i++) cin >> Takoyaki.at(i);
    int sum = 0;

    for (int i=0; i<N; i++){
        for (int j=i+1; j<N; j++){
            // Nから2個えらぶ組み合わせを全探索
            sum += Takoyaki.at(i)*Takoyaki.at(j);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3552
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants ---------- */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    ll N;
    cin >> N;

    string ret = "";
    ll div = 2;
    ll elem = 1;
    while (N != 0) {
        if (N % div == 0) {
            ret += '0';
        } else {
            ret += '1';
            N -= elem;
        }

        div *= 2;
        elem *= -2;
    }

    reverse(ret.begin(), ret.end());

    if (ret.size() == 0) {
        ret = "0";
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
# 先頭N個に完全に含まれるループの数
complete_roop = N//(A+B)
ans = complete_roop*A
# あとは端数の中に青いボールがいくつあるかを数える
fraction = min(N%(A+B), A)
ans += fraction
print(ans)


Measured memory_bytes: 2940
/*
AizuOnline A1200
Title Goldbach's Conjecture

*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n;


int primes[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
	      101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,
	      211,223,227,229,233,239,241};


//
int isprime(int n)
{
  int i;
  for(i=0;i<sizeof(primes)/sizeof(int);i++)
    if(n == primes[i])
      return(-1);
  else if(n % primes[i] ==0)
      return(0);
  return(-1);
}
main()
{
  int i,c;
  while(EOF != scanf("%d",&n) && n)
    {     
      c=0;
      for(i=2;i<=n/2;i++)
	{
	  if(isprime(i) && isprime(n-i))
	    c++;	    
	}
      printf("%d\n",c);
    }
return(0);
}

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

int main()
{ 
  int k, x;
  
  cin >> k >> x;
  for (int i = x - k + 1; i < x + k; i++)
  {
    cout << i;
    if (i < x + k - 1)
      cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256