akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

                            typedef long long ll;
                            typedef double ld;
                            #define rep(i,a,n) for(ll i=(a); i<(n); i++)
                            #define per(i,a,n) for(ll i=(n-1); i>=(a); i--)
                            #define F first
                            #define S second
                            #define maxx(a,b) a=max(a,b)
                            #define minn(a,b) a=min(a,b)
                            #define db(x) cerr<<#x<<" = "<<x<<endl
                            #define N 1111111
                            #define mod 1000000007
                            #define rt return
                            #define inf 1000000000

                            using namespace std;

                            ld p[3456],dp[3456][3456];

                            int main(){

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

                                //freopen("Ulug'bek","r",stdin);
                                //freopen("Abdimanabov","w",stdout);

                                int n; cin>>n;
                                rep(i,1,n+1)cin>>p[i];

                                dp[0][0]=1;

                                rep(i,1,n+1)
                                {
                                    rep(j,0,i+1)
                                    {
                                        dp[i][j]=(j>0?dp[i-1][j-1]*p[i]:0)+dp[i-1][j]*(1-p[i]);
                                    }
                                }
//                                rep(i,0,n+1)
//                                {
//                                    rep(j,0,n+1)
//                                    {
//                                        cout<<dp[i][j]<<' ';
//                                    }
//                                    cout<<endl;
//                                }
//
                                ld ans=0;

                                rep(j,(n+1)/2,n+1)
                                ans+=dp[n][j];
                                
                                cout.precision(10);

                                cout<<fixed<<ans;

                            rt 0;
                            }



















Measured memory_bytes: 80640
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
if you have any question about any part of my code,
please don't shy to ask anytime :)
*/


void solve()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main{

    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        int group1[]={1,3,5,7,8,10,12};
        int group2[]={4,6,9,11};
        int group3[]={2};
        int z,x;
        z=input.nextInt();
        x=input.nextInt();
        int sum1=0,sum2=0,sum3=0;
        boolean m=false;
        if(z==x)
        {
            for(int i=0;i<group1.length;i++)
            {
                if(z==group1[i])
                    sum1++;
            }
            for(int i=0;i<group2.length;i++)
            {
                if(z==group2[i])
                    sum2++;
            }
            if(z==2)
                sum3++;
            if(sum1==1||sum2==1||sum3==1)
            {
                System.out.println("Yes");
                m=true;
            }
            
        }
        else {
            for(int i=0;i<group1.length;i++)
            {
                if(z==group1[i]||x==group1[i])
                    sum1++;
            }
            for(int i=0;i<group2.length;i++)
            {
                if(z==group2[i]||x==group2[i])
                    sum2++;
            }
            
            if(sum1==2||sum2==2||sum3==2)
            {
                System.out.println("Yes");
                m=true;
            }
        }
        if(!m)
        {
            System.out.println("No");
        }
    }
    
}


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

a, b, m = map(int, input().split())
*a, = map(int, input().split())
*b, = map(int, input().split())  

mi = min(a) + min(b)
for _ in range(m):
    x, y, c = map(int, input().split())
    price = a[x-1]+b[y-1]-c
    if mi > price:
        mi = price

print(mi)

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int s_a = 0, s_b = 0;
    string a,b;
    rep(i,n) {
        cin >> a >> b;
        if(a == b) {
            s_a++;
            s_b++;
        } else if(a > b) {
            s_a += 3;
        } else {
            s_b += 3;
        }
    }
    
    cout << s_a << " " << s_b << endl;
    
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

int gcd(int x, int y)
{
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(y, x % y);
}

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

    int N, K;
    vs32 A;
    int up;
    cin >> N >> K;

    A.resize(N);
    rep (i, N)
    {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    {
        auto it = lower_bound(A.begin(), A.end(), K);
        up = it - A.begin();
    }

    bool ans = false;
    if (up < N)
    {
        int c = 0;
        rep (i, N)
        {
            c = gcd(A[i], c);
        }

        for (int i = up; i < N && !ans; ++i)
        {
            if ((A[i] - K) % c == 0) ans = true;
        }
    }

    cout << (ans ? "POSSIBLE\n" : "IMPOSSIBLE\n");
    return 0;
}



Measured memory_bytes: 640
#require 'pp'

n = gets.chomp!.to_i
a_n = gets.chomp!.split(" ").map(&:to_i)
a_n.unshift(-1)

memo = {}
1.upto(n) do |i|
    memo[i] = -1
end

n.downto(1) do |baisu|
    x = baisu
    count = 0
    while x <= n
        if memo[x] == 1
            count += 1
        end
        x += baisu
    end
    
    if count % 2 == 0
        memo[baisu] = a_n[baisu]
    else
        memo[baisu] = (a_n[baisu] + 1) % 2
    end
    #pp count
    #pp memo
end

sum = 0
answer = []
memo.each do |k, v|
    if v == 1
        sum += 1
        answer << k
    end
end

puts sum
answer_str = answer.join(" ")
if answer_str != ""
    puts answer_str
end



Measured memory_bytes: 34184
#include <bits/stdc++.h>
    #define Mod 1000000007
    #define INF 1e9
    #define INFL 9e18
    #define EPS 1e-9
    #define pb push_back
    #define mp make_pair
    #define SET(a) memset(a,-1,sizeof(a))
    #define CLR(a) memset(a,0,sizeof(a))
    #define CPY(a,b) memcpy(a,b,sizeof(a))
    #define all(a) (a).begin(),(a).end()
    #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define N 100005
    #define fs first
    #define sc second
    using namespace std;

    typedef  long long int ll;
    typedef pair<ll,ll> ii;
    typedef vector <ii> vii;
    typedef vector <ll> vi;
  
    ll arr[N];
 
    int main()
    {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
   ios;
   ll a,b,c,n,m;
   ll ans=0,cnt=0,adi=0,flag=0;
   string str;

   cin>>n;
   cout<<24-n+24<<endl;



    return 0;


    }

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 100010;
vector<int> graph[limit];


int opr(vector<int> val){
	int last = -1;

	rep(i, 30){
		if(val[i] >= 2){
			last = i;
		}
	}

	int start = 30;
	rep(i, last + 1, 30){
		if(val[i] == 0){
			start = i;
			break;
		}
	}

	val[start] = 1;
	rrep(i, start){
		val[i] = 0;
	}

	int ret = 0;
	rep(i, 30) if(val[i] > 0) ret |= (1 << i);
	return ret;
}

int dfs(int v, int p){
	vector<int> res(30, 0);

	for(auto &v2: graph[v]){
		if(v2 == p) continue;
		const int val = dfs(v2, v);
		rep(i, 30) if(val >> i & 1) res[i]++;
	}

	return opr(res);
}

int main(void){
	int n;
	cin >> n;

	rep(i, n - 1){
		int a, b;
		cin >> a >> b;
		a--, b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	const int val = dfs(0, -1);

	rrep(ans, 30){
		if(val >> ans & 1) {
			cout << ans << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 20480
n=int(input())
s=list(map(int,input().split()))


t=sorted(s)

if t[0]==0:
  print(0)
  exit()
count=1
for i in range(0,n):
  count=count*t[i]
  if count>10**18:
    print(-1)
    exit()

print(count)

Measured memory_bytes: 21780
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<int> to[101010];
bool visited[101010] = {};
ll ans=1; int n, k;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void DFS(int a, int p, int depth){
  int child = 0;
  visited[a] = true;
  for(auto o: to[a]){
    if(o==p) continue;
    if(visited[o]) continue;
    child++;
    DFS(o, a, depth+1);
  }
  if(depth==0) ans*=(COM(k-1, child)*fac[child]%mod);
  else ans*=(COM(k-2, child)*fac[child]%mod);
  ans%=mod;
}



int main(){
  cin >> n >> k;
  rep(i, n-1){
    int a, b; cin >> a >> b; a--; b--;
    to[a].push_back(b); to[b].push_back(a);
  }
  ans = k; COMinit();
  DFS(0, -1, 0);
  cout << ans << endl;
}

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

typedef long long ll;

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

    ll a,b;
    ll x=1,y=1;

    for(int i=0;i<n;i++){ 
        cin >> a >> b;
        ll k=max((x+a-1)/a,(y+b-1)/b);
        x=a*k;
        y=b*k;
    }

    cout << x + y << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
#define CO(x) cout<<(x)<<endl;
#define COSP(x) cout<<(x)<<" ";
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

  int X, Y, Z;
  ll K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X), B(Y), C(Z);
  REP(i,X) cin>>A[i];
  REP(i,Y) cin>>B[i];
  REP(i,Z) cin>>C[i];

  vector<ll> AB;
  REP(i,X) REP(j,Y) AB.push_back(A[i]+B[j]);
  sort(ALL(AB), greater<ll>());
  AB.resize(K);

  vector<ll> ABC;
  REP(i,K) REP(j,Z) ABC.push_back(AB[i]+C[j]);
  sort(ALL(ABC), greater<ll>());

  REP(i,K) cout<<ABC[i]<<endl;

  return 0;
}


Measured memory_bytes: 43240
//52
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

int main(){
  int a[100];
  int cr[17]={};
  queue<int> que;
  for(int t=0;t<600;t++){
    if(t%5==0&&t/5<100){
      que.push(t/5);
    }
    for(int i=0;i<17;i++){
      cr[i]--;
    }
    int fc=0;
    for(int i=0;i<17;i++){
      if(cr[i]<=0){
	fc++;
	if(!que.empty()){
	  int gn=que.front();
	  int ng=(gn%5==1)?5:2;
	  if(fc==ng){
	    for(int j=0;j<ng;j++){
	      cr[i-j]=17*(gn%2)+3*(gn%3)+19;
	    }
	    a[gn]=t-gn*5;
	    que.pop();
	    i=-1;
	    fc=0;
	  }
	}
      }else{
	fc=0;
      }
    }
  }
  for(int n;cin>>n;){
    cout<<a[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;

#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define loop for(int i=0;i<n;++i)
#define LOOP_IT(s) for(auto it=(s).begin();it!=(s).end();++it)


int main(int argc,char* argv[])
{
    ZOOM

    int arr[]={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 k;
    cin>>k;
    cout<<arr[k-1];



    return 0;
}



Measured memory_bytes: 256
import math
from collections import deque
N, K = map(int, input().split())
A = list(map(int, input().split()))
S =sum(A)
cut = []
for k in range(N):
  cut.append(K*A[k]//S)

length = []
for k in range(N):
  length.append([A[k] / (cut[k]+1), k])

length.sort(key = lambda x: x[0], reverse=True)

def nibun_insert(lis, item):
  end = len(lis)
  start = 0
  now = (end+start)//2
  while end > start+1:
    if lis[now][0] > item[0]:
      start = 0 + now
      now = (now + end)//2
    else:
      end = 0 + now
      now = (now + start)//2
  return deque(lis[:now+1] + [item] + lis[now+1:])
  

C = sum(cut)
res = min(K - C, N)
length = length[:res+1]
length = deque(length)
for k in range(res):
  a = length.popleft()
  cut[a[1]] += 1
  a[0] = a[0]*cut[a[1]]/(cut[a[1]]+1)
  if a[0] <= length[-1][0]:
    length.append(a)
  elif a[0] >= length[0][0]:
    length.appendleft(a)
  else:
    length = nibun_insert(list(length), list(a))
  length.pop()

print(math.ceil(length.popleft()[0]))


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

using namespace std;
using ll = long long;
using ld = long double;

struct shop{
    ll price;
    ll count;
};

int main() {

    ll N,M;
    vector<shop> AB;
    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        ll a,b;
        cin >> a >> b;
        shop s;
        s.price =a;
        s.count = b;
        AB.push_back(s);
    }

    sort(AB.begin(),AB.end(),[](const shop& a, shop& b){ return (a.price < b.price);});

    ll result = 0;
    for (int i = 0; i < AB.size(); ++i) {
        if(M > AB[i].count){
            M -= AB[i].count;
            result += AB[i].count * AB[i].price;
        }else{
            result += M * AB[i].price;
            break;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

ll n;
ll a[100100];

int main(){
	cin >> n;
	ll cnt[2] = {};
	REP(i, n){
		cin >> a[i];
		cnt[a[i] % 2]++;
	}
	if (cnt[1] % 2 == 1)cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
          

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    string s1 = s.substr(1, sz(s) - 2);
    cout << s[0] << sz(s1) << s[sz(s) - 1];
}


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

int main(){
    int N,L;
    vector<string> dir;

    cin >> N >> L;
        
    for (int i=0; i<N; i++) {
        string S;
        cin >> S;
        dir.push_back(S);
    }   
    sort(dir.begin(), dir.end());
    vector<string>::iterator ite = dir.begin();
    while (ite != dir.end()) {
        cout << *ite;
        ite++;
    }   
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        ll a,b,c;
        cin >> a >> b >> c;
        if(a%2==0||b%2==0||c%2==0) {
                cout << 0 << endl;
        }else{
                cout << min({a*b,b*c,c*a})<< endl;
        }

        return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vs = vector<string>;
using ii = vector<vector<long long>>;
int main() {
	ll a;
	cin >> a;
	ll count = 0;
	vl x(a);
	for (int i = 0; i < a; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < a; i++) {
		if (x[i] == count + 1) {
			count++;
		}
	}
	if (count != 0) {
		cout << a - count << endl;
	}
	else {
		cout << -1 << endl;
	}
}


Measured memory_bytes: 4848
import java.util.*;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] ps = new int[m], ys = new int[m];
        HashMap<Integer, ArrayList<V>> input = new HashMap<>();
        int[] pc = new int[n + 1];

        for (int i = 0; i < m; i++) {
            ps[i] = sc.nextInt();
            ys[i] = sc.nextInt();
            pc[ps[i]] += 1;
        }

        for (int i = 0; i < m; i++) {
            if (input.containsKey(ps[i])) {
                ArrayList<V> l = input.get(ps[i]);
                l.add(new V(i, ys[i]));
            } else {
                ArrayList<V> l = new ArrayList<>(pc[ps[i]]);
                l.add(new V(i, ys[i]));
                input.put(ps[i], l);
            }
        }

        String[] ans = new String[m];

        for (Map.Entry<Integer, ArrayList<V>> entry: input.entrySet()) {
            ArrayList<V> l = entry.getValue();
            Collections.sort(l, Comparator.comparingLong(o -> o.y));
            int i = 1;
            for (V v: l) {
                ans[v.idx] = String.format(String.format("%012d", 1L * entry.getKey() * 1000000 + i));
                i++;
            }
        }
        for (int i = 0; i < m; i++) {
            System.out.println(ans[i]);
        }
    }

    class V {

        int idx;
        long y;
        V(int idx, long y) {
            this.idx = idx;
            this.y = y;
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int f(string s)
{
    int n=sz(s);
    ffor(i,0,n) if(s[i]!=s[n-i-1]) return 0;
    return 1;
}

int main()
{
    

    string s;
    cin>>s;
    int n=sz(s);
    string a="",b="";
    ffor(i,0,(n-1)/2) a.pb(s[i]);
    ffor(i,((n+3)/2)-1,n) b.pb(s[i]);

    if(f(s)&&f(a)&&f(b))
    {
        cout<<"Yes";
    }
    else cout<<"No";
    
    return 0;
}



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

public class Main {
    int count = 0;
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    
    private void solve() {
        Scanner scanner = new Scanner(System.in);
        
        int factors = scanner.nextInt();
        int[] S = new int[factors];
        
        for(int i = 0; i < factors; i++) S[i] = scanner.nextInt();
        
        count = 0;
        mergeSort(S, 0, S.length);
        print(S);
        System.out.println(count);
    }
    
    private void merge(int[] X, int Xleft, int Xmid, int Xright) {
        int index_1      = Xmid - Xleft;
        int index_2      = Xright - Xmid;
        int[] leftArray  = new int[index_1 + 1];
        int[] rightArray = new int[index_2 + 1];
        
        for(int k = 0; k < index_1; k++) {
            leftArray[k] = X[Xleft + k];
        }
        
        for(int k = 0; k < index_2; k++) {
            rightArray[k] = X[Xmid + k];
        }
        
        leftArray[index_1]  = Integer.MAX_VALUE;
        rightArray[index_2] = Integer.MAX_VALUE;
        
        int i =0, j = 0;
        for(int k = Xleft; k < Xright; k++) {
            count++;
            if(leftArray[i] <= rightArray[j]) {
                X[k] = leftArray[i++];
            } else {
                X[k] = rightArray[j++];
            }
        }
    }
    
    private void mergeSort(int[] X, int Xleft, int Xright) {
        if(Xleft + 1 < Xright) {
            int Xmid = (Xleft + Xright) / 2;
            mergeSort(X, Xleft, Xmid);
            mergeSort(X, Xmid , Xright);
            
            merge(X, Xleft, Xmid, Xright);
        } 
    }
    
    private void print(Object[] xArray) {
        StringBuilder answer = new StringBuilder();
        for(Object x : xArray) answer.append(x.toString()).append(' ');
        System.out.println(answer.toString().trim());
    }
    
    private void print(int[] xArray) {
        StringBuilder answer = new StringBuilder();
        for(int x : xArray) answer.append(x).append(' ');
        System.out.println(answer.toString().trim());
    }
    
    private static class Scanner {
        BufferedReader br;
        StreamTokenizer tokenizer;
        
        public Scanner(InputStream ins) {
            br = new BufferedReader(new InputStreamReader(ins));
            tokenizer = new StreamTokenizer(br);
        }
        
        public String next() {
            nextToken();
            return tokenizer.sval;
        }
        
        public Integer nextInt() {
            nextToken();
            return (int) tokenizer.nval;
        }
        
        private int nextToken() {
            int token = tokenizer.TT_EOF;
            
            try {
                token = tokenizer.nextToken();
            } catch(IOException e) {
                ;
            }
            return token;
        }
    }
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b;
	cin >>a >>b;
	
	cout << (a-1)*(b-1)<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
int A1,A2,A3,sum;
scanf("%d %d %d",&A1,&A2,&A3);//Ai should be in the range of 1 to 13
sum=A1+A2+A3;
if(sum>=22)
{printf ("bust\n");}
else{printf ("win\n");}
    return 0;
}

Measured memory_bytes: 128
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
A,B,C,D=map(int,input().split())
def div(x):
    num=x
    num-=x//C
    num-=x//D
    num+=x//lcm(C,D)
    return num
print(div(B)-div(A-1))

Measured memory_bytes: 9200
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;

    long long l0 = 2, l1 = 1;
    for (int i = 0; i < n - 1; i++) {
        long long w = l0 + l1;
        l0 = l1;
        l1 = w;
    }

    cout << l1 << endl;
}


Measured memory_bytes: 256
n=int(input())
pair={}
nodes=[0]*n
for _ in range(n-1):
    a,b=map(int,input().split())
    pair.setdefault(a, [])
    pair.setdefault(b, [])
    pair[a]+=[b]
    pair[b] += [a]
c=list(map(int,input().split()))
c.sort()
kei=sum(c[:-1])
cnt=0
nodes[0]=c.pop()
tugi=pair[1]
while c:
    ntugi=[]
    for i in tugi:
        nodes[i-1]=c.pop()
        for ii in pair[i]:
            if nodes[ii-1]>0:continue
            ntugi+=[ii]
    tugi=ntugi
print(kei)
print(*nodes)


Measured memory_bytes: 6224
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <cmath>
using namespace std;
#pragma warning (disale: 4996)
string S; int n, x, y, cnt, flag; bool dp[8009][32009]; vector<int>v1, v2, v3;

bool solve(vector<int>vec, int g) {
	for (int i = 0; i <= vec.size(); i++) { for (int j = 0; j <= 32000; j++)dp[i][j] = false; }
	dp[0][16000] = true;
	for (int i = 0; i < vec.size(); i++) {
		for (int j = 0; j <= 32000; j++) {
			if (dp[i][j] == false)continue;
			dp[i + 1][j + vec[i]] = true;
			dp[i + 1][j - vec[i]] = true;
		}
	}
	return dp[vec.size()][16000 + g];
}

int main() {
	cin >> S >> x >> y;
	for (int i = 0; i <= S.size(); i++) {
		if (i != S.size() && S[i] == 'F')cnt++;
		else {
			if (flag == 0)v1.push_back(cnt);
			if (flag == 1)v2.push_back(cnt);
			cnt = 0; flag ^= 1;
		}
	}
	x -= v1[0];
	for (int i = 1; i < (int)v1.size(); i++) { v3.push_back(v1[i]); }

	if (solve(v3, x) == true && solve(v2, y) == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 125312
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int d2y[2] = {1, 0};
int d2x[2] = {0, 1};

int main(){
	int H,W,K; cin>>H>>W>>K;
	vector<vector<char>> input(H+4, vector<char> (W+4,'#'));
	vector<vector<int>> ans(H+4, vector<int> (W+4,inf));
	REP(i,H)REP(j,W)cin>>input[i][j];
	int e_ans = 1;
	REP(i,H)REP(j,W){
		if(input[i][j] != '#')continue;
		ans[i][j] = e_ans;
		int width = 1, height = 1, top = i, left = j;
		while(1){
			bool ok = false;
			rep(k,4){
				int sy, sx;
				if(k == 0){
					sy = top; sx = left-1;
				}else if(k == 1){
					sy = top-1; sx = left;
				}else if(k == 2){
					sy = top; sx = left + width;
				}else{
					sy = top + height; sx = left;
				}
				int dy = d2y[k%2], dx = d2x[k%2];
				int loop_cnt = ((k%2 == 1) ? width : height);
				bool can = true;
				rep(m,loop_cnt){
					int ty = sy + dy*m, tx = sx + dx*m;
					if(input[ty][tx] == '#' || ans[ty][tx] != inf)can = false;
				}
				if(can){
					rep(m,loop_cnt){
						int ty = sy + dy*m, tx = sx + dx*m;
						ans[ty][tx] = e_ans;
					}
					ok = true;
					if(k%2 == 1){
						if(k == 1) --top;
						++height;
					}else{
						if(k == 0) --left;
						++width;
					}
					break;
				}
			}
			if(!ok)break;
		}
		++e_ans;
	}
	REP(i,H){REP(j,W)cout<<ans[i][j]<<' '; cout<<endl;}
	return 0;
}

Measured memory_bytes: 1280
package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	n := ScanInt()
	a := ScanInt64Slice(n)
	stem := int64(math.MaxInt64)
	l, r := MnMx(a...)
	for p := l; p <= r; p++ {
		stemSum := int64(0)
		for j := 0; j < n; j++ {
			stemSum += ((a[j] - p) * (a[j] - p))
		}
		if stemSum < stem {
			stem = stemSum
		}
	}

	fmt.Println(stem)
}

/*********************** I/O ***********************/

var in *bufio.Scanner

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer writer.Flush()

	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := MX_INT, MN_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int n,t,a;
    cin >> n >> t >> a;
    int h[100000];
    float c[100000];
    for(int i = 0; i<n;i++){
        cin >> h[i];
        c[i] = fabs(t - h[i]*0.006 - a);
    }
    int ans = 0;
    for(int i = 1; i<n;i++){
        if(c[ans]>c[i]){
            ans = i;
        }
    }
    cout << ans+1;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	vector<char>v;
	while(n)
	{
		n--;
		v.push_back(n%26+'a');
		n/=26;
	}
	reverse(v.begin(),v.end());
	for(char c:v)
		cout<<c;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll n, m, q;
ll ans;
vector<tuple<ll, ll, ll, ll>> g;

void rec(int num, int ko, vector<ll> A) {
    if (num > 0) A.push_back(num);

    if (ko == n) {
        //計算する
        ll sum = 0;
        for (ll i = 0; i < q; ++i) {
            ll a = get<0>(g[i]);
            ll b = get<1>(g[i]);
            ll c = get<2>(g[i]);
            ll d = get<3>(g[i]);

            if (A[b] - A[a] == c) {
                sum += d;
            }
        }
        ans = max(ans, sum);
        return;
    }

    for (ll i = num; i <= m; ++i) {
        if (i == 0) continue;

        rec(i, ko + 1, A);
    }
}

int main() {

    cin >> n >> m >> q;

    for (ll i = 0; i < q; ++i) {
        ll a, b, c, d; cin >> a >> b >> c >> d;
        --a; --b;
        g.push_back(make_tuple(a, b, c, d));
    }

    ans = 0;
    vector<ll> tmp;
    rec(0, 0, tmp);

    cout << ans << endl;
}

Measured memory_bytes: 3636
L = list(map(int, input().split()))
max_index = L.index(max(L))

X = 0
S = 0

for i in range(3):
    if i == max_index:
        X = L[i]
    else:
        S += L[i]

if X == S:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3192
#include<stdio.h>

int main()
{
  int n;
  int count;
  int i,j,k;
  int s = 0;

  while(1){
    count = 0;

    scanf("%d",&n);
    if(n == 0){
      break;
    }
    else if(n == 1){
      count++;
    }
    k = 2*n;

    n = n+1;

    if(n%2 == 0){
      n = n+1;
    }

    for(i = n;i <= k;i = i+2){
      for(j = 3;j*j <= i;j = j+2){
        if(i%j == 0){
          s = 1;
          break;
        }
      }
      if(s == 0){
        count++;
      }
      s = 0;
    }

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

Measured memory_bytes: 600
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    a = inputList()
    ans = {}
    
    for i, val in enumerate(a):
        if val in ans:
            ans[val] += 1
        else:
            ans[val] = 1
            
        if val+1 in ans:
            ans[val+1] += 1
        else:
            ans[val+1] = 1
            
        if val-1 in ans:
            ans[val-1] += 1
        else:
            ans[val-1] = 1
            
    tmp = 0
    for i in ans.values():
        if tmp < i:
            tmp = i
            
    print(tmp)
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 64816
import java.util.Scanner;

/**
 * @author ??\???
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		scanner.close();
		
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 26240
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define BITSEARCH(i,n) for(int i=0;i<(1<<(n));++i)
#define BITCHK(i,j) (i) & (1<<(j))

/* BITSEARCH 使い方
 
BITSEARCH(i,n){
  vector<int> h;
  REP(j,n){
    if (BITCHK(i,j)){
      h.push_back(j+1);
    }
  }
}

*/

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t n;
  cin >> n;
  vector<int> a(n);
  REP(i,n){
    cin >> a.at(i);
  }
  int t = 0;
  REP(i,n){
    t = a.at(i) - t;
  }
  cout << t << " ";
  REP(i,n-1){
    t = (a.at(i) - t/2) * 2;
    if (i == n-2){
      cout << t << endl;
    }else{
      cout << t << " ";
    }
  }
  return 0;
}



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

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug(fmt, ...) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 30;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;

// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
    prepare() {
        cout.setf(ios::fixed, ios::floatfield);
        cout.precision(8);
        ios_base::sync_with_stdio(false);
    }
} _prepare;

int main() {
    int N, A;
    cin >> N >> A;
    vi x(N);
    rep(i, N)cin >> x[i];

    vector<vvll> dp(N + 1, vvll(N + 1, vll(N*A + 10, 0)));
    dp[0][0][0] = 1;
    rep(i, N) {
        rep(j, N) {
            rep(k, N * A) {
                if (k + x[i] <= N * A) {
                    dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
                }
                dp[i + 1][j][k] += dp[i][j][k];
            }
        }
    }

    ll ans = 0;
    REP(i, 1, N+1) {
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;

    return 0;
}


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

// dp[i][j][f] = index iまでにd(i)個選んだときの最大値
// f==0 index i は選ばない f==1 index i を選ぶ
// d(0) = i/2
// d(1) = i/2 + 1
 
long long dp[200010][2][2];
constexpr long long INF = -10000000000000;


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

    vector<int> As;

    for(int i=0;i<N;++i){
        dp[i][0][0] = INF;
        dp[i][0][1] = INF;
        dp[i][1][0] = INF;
        dp[i][1][1] = INF;
    }
    
    for(int i=0;i<N;++i){
        cin >> a;
        As.push_back(a);
    }
    
    for(int i=0;i<N;++i){
        if(N%2==0){
            if(i==0){
                dp[i][0][0] = 0;
                dp[i][1][1] = As[0];
            }else if(i%2==0){
                dp[i][0][0] = max( dp[i-1][1][0], dp[i-1][1][1]);
                // dp[i][0][1]
                // dp[i][1][0] 
                dp[i][1][1] = dp[i-1][1][0] + As[i];                
            }else{
                // dp[i][0][0]
                // dp[i][0][1]
                dp[i][1][0] = dp[i-1][1][1];
                dp[i][1][1] = dp[i-1][0][0] + As[i]; 
            }
        }else{
            if(i==0){
                dp[i][0][0] = 0;
                dp[i][1][1] = As[0];
            }else if(i%2==0){
                dp[i][0][0] = max( dp[i-1][1][0], dp[i-1][1][1]);
                dp[i][0][1] = dp[i-1][0][0] + As[i];
                // dp[i][1][0] 
                dp[i][1][1] = dp[i-1][1][0] + As[i];                
            }else{
                dp[i][0][0] = max( dp[i-1][0][0], dp[i-1][0][1] );
                // dp[i][0][1] 
                dp[i][1][0] = dp[i-1][1][1];
                dp[i][1][1] = dp[i-1][0][0] + As[i];
            }
        }
    }

    if(N%2==0){
        cout << max( dp[N-1][1][0], dp[N-1][1][1]) << endl;
    }else{
        cout << max( dp[N-1][0][0], dp[N-1][0][1]) << endl;
    }

    // for(int i=0;i<N;++i){
    //     printf("dp[%d][0] = %lld, dp[%d][1] = %lld\n", i, dp[i][0], i, dp[i][1]);
    // }
    
    return 0;
}


Measured memory_bytes: 10516
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	
	int N, W;
	cin >> N >> W;
	
	vector<int> w(N);
	vector<int> v(N);
	for(int i = 0; i < N; i++)
	{
		cin >> w[i] >> v[i];
	}
	
	vector<vector<ll>> dp(W  + 1, vector<ll>(N  + 1, 0));
	
	for(int i = 1; i <= W; i++)
	{
		for(int j = 1; j <= N; j++)
		{
			dp[i][j] = max((i - w[j - 1]) >= 0 ? dp[i - w[j - 1]][j - 1] + v[j - 1] : 0, dp[i][j - 1]);
		}
	}
	cout << dp[W][N] << endl;
		
	return 0;
}


Measured memory_bytes: 85284
#include<iostream>
#include<cstdio>
using namespace std;
int n,sz;
int a[10101],d[10101];
long long an[1010][1010];
void init(int N)
{
	for(int i=2;i<=N;i++)
	{
		if(!d[i])a[++sz]=i;
		for(int j=1;j<=sz&&a[j]*i<=N;j++)
		{
			d[i*a[j]]=1;
			if(i%a[j]==0) break;
		}
	}
}
long long gcd(long long x,long long y){ return y?gcd(y,x%y):x;}
long long lcm(long long x,long long y)
{
	if(!x||!y) return x+y;
	return x/gcd(x,y)*y;
}
int main()
{
	scanf("%d",&n);
	init(10000);
	if(n==2)
	{
		an[1][1]=4;an[1][2]=7;an[2][1]=23;an[2][2]=10;
	}
	else
	{
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
			if((i+j)&1)
				an[i][j]=1LL*a[(i+j)/2]*a[(i-j+n)/2+1+n];
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
			if(((i+j)&1)^1)
				an[i][j]=lcm(lcm(an[i-1][j],an[i+1][j]),lcm(an[i][j-1],an[i][j+1]))+1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		printf("%lld ",an[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int C = sc.nextInt();
    	System.out.println(A + B >= C ? "Yes" : "No");
    }
}


Measured memory_bytes: 22996
#include<iostream>
#include<vector>
#include<stack>
#include<string.h>
#include<string>
#include<algorithm>
#include<math.h>
#define LL long long int
using namespace std;
const int maxn = 120000;
struct CITY
{
	int x,y;
	int num;
};
vector<CITY> city;

bool cmp1(CITY a, CITY b)
{
	return a.x < b.x;
}

bool cmp2(CITY a, CITY b)
{
	return a.y<b.y;
}
int n;

int fa[maxn];
int findset(int x)
{
	if(x != fa[x])
	{
		fa[x] = findset(fa[x]);
	}
	return fa[x];
}

struct Edge
{
	int u,v;
	int w;
	bool operator < (Edge tar) const
	{
		return w < tar.w;
	}
};

vector<Edge> E;

void init()
{
	city.clear();
	E.clear();
	for(int i = 0;i<maxn;i++) fa[i] = i;
}





int main()
{
	while(cin >> n)
	{
		init();
		for(int i = 0;i<n;i++)
		{
			int xx,yy;
			scanf("%d %d",&xx,&yy);
			CITY tmp;
			tmp.x = xx;
			tmp.y = yy;
			tmp.num = i;
			city.push_back(tmp);	
		}	
		sort(city.begin(),city.end(),cmp1);
		for(int i = 0;i<city.size() - 1;i++)
		{
			Edge tmp;
			tmp.u = city[i].num;
			tmp.v = city[i+1].num;
			tmp.w = abs(city[i].x - city[i+1].x);
			E.push_back(tmp);
		}
		sort(city.begin(),city.end(),cmp2);
		for(int i = 0;i<city.size() - 1;i++)
		{
			Edge tmp;
			tmp.u = city[i].num;
			tmp.v = city[i+1].num;
			tmp.w = abs(city[i].y - city[i+1].y);
			E.push_back(tmp);
		}
		
		LL ans = 0;
		sort(E.begin(),E.end());
		for(int i = 0;i<E.size();i++)
		{
			int u = E[i].u;
			int v = E[i].v;
			int w = E[i].w;
			int x = findset(u);
			int y = findset(v);
			if(x == y) continue;
			else 
			{
				fa[x] = y;
				ans = ans + w;
				findset(x);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 6644
from scipy.misc import comb
 
n,m = map(int, input().split())
 
if n>1:
  even = comb(n,2, exact=True)
else:
  even = 0
 
if m>1:
  odd = comb(m,2, exact=True)
else:
  odd = 0
 
ans = even + odd
print(str(int(ans)))

Measured memory_bytes: 13204
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,kotae=0;
    cin>>n;
    vector<int> tamesi1(n-1),tamesi2(n);
    for(int i=0;i<n-1;i++){
        cin>>tamesi1[i];
    }
    tamesi2[0]=tamesi2[1]= tamesi1[0];
    for(int i=1;i<n-1;i++){
        if(tamesi1[i]<tamesi1[i-1]){
            tamesi2[i] = tamesi1[i];
        }
        tamesi2[i+1] = tamesi1[i];
    }
    kotae = accumulate(tamesi2.begin(),tamesi2.end(),0);
    cout<<kotae<<endl;
    return 0;
}

Measured memory_bytes: 256
with open(0) as f:
    N,  *S = map(int, f.read().split())
Score = [True if i == 0 else False for i in range(10000)]
for s in S:
    for i in reversed(range(s, 10000)):
        if Score[i-s]:
            Score[i] = True

for i in reversed(range(10000)):
    if Score[i] and i % 10 != 0:
        print(i)
        break
else:
    print(0)

Measured memory_bytes: 9204