akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

#define int ll

signed main() {
    int N, W;
    while (cin >> N >> W) {
        map<ll, ll> dp;
        dp[0] = 0;
        rep(i, N) {
            int w, v;
            cin >> w >> v;
            map<ll, ll> ndp = dp;
            for (auto &p : dp) {
                int pw, pv;
                tie(pw, pv) = p;
                ndp[pw + w] = max(ndp[pw + w], dp[pw] + v);
            }
            dp = ndp;
        }
        int ans = 0;
        for (auto &e : dp) {
            int w, v;
            tie(w, v) = e;
            if (w <= W) {
                ans = max(ans, v);
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1024
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def main():
    N = str(int(input()))
    K = len(N)
    c = int(N[0])
    x = sum([int(i) for i in N])
    print(max(c-1+(K-1)*9, x))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int candy = 0;
        for(int i = 1; i <= n; i++){
            candy = candy + i;
        }
        System.out.println(candy);
    }
}


Measured memory_bytes: 20820
package main

import (
	"fmt"
	"math"
)

func main() {
	var X float64
	fmt.Scan(&X)

	for i := -200; i <= 200; i++ {
		for j := -200; j <= 200; j++ {
			if math.Pow(float64(i), 5)-math.Pow(float64(j), 5) == X {
				fmt.Println(i, j)
				return
			}
		}
	}
}


Measured memory_bytes: 1820
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

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

Measured memory_bytes: 256
#include <stdio.h>

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

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

  long long int mod = 1000000007;
  //printf("%d\n", mod);
  long long int sum = 1;
  for (int i = 0; i < N; i++) {
    sum = ((long long int)sum * (i + 1)) % mod;
    //printf("%d回目\n", i);
  }
  printf("%d\n", sum);
  return 0;
}


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

int main(void) {
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> sums(3, 0);
    for (int i = 0; i < N; i++) {
        int P;
        cin >> P;
        if (P <= A)
            sums[0]++;
        else if (A < P && P <= B)
            sums[1]++;
        else
            sums[2]++;
    }
    cout << min({sums[0], sums[1], sums[2]}) << endl;
    return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 130000, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -pn;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return pn * tmp;
}

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


	int N;
	N = getint();

	ll dp00 = 0;
	ll dp11 = 0;
	ll dp02 = -1e18;

	int n = N / 2;
	if (N % 2) {
		rep(i, n) {
			int a = getint();
			if (dp11 < dp00) dp11 = dp00;
			dp00 += a;
			dp02 += a;
			if (dp02 < dp11) dp02 = dp11;
			dp11 += getint();
		}
		if (dp11 < dp00) dp11 = dp00;
		dp02 += getint();
		if (dp02 < dp11) dp02 = dp11;
		printf("%lld\n", dp02);
	}
	else {
		rep(i, n) {
			if (dp11 < dp00) dp11 = dp00;
			dp00 += getint();
			dp11 += getint();
		}
		if (dp11 < dp00) dp11 = dp00;
		printf("%lld\n", dp11);
	}


	Would you please return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int count = 1;
    char pre = S.at(0);
    int len = S.length();
    int dual = 0;
    
    for(int i = 1; i < len;) {
        if(i == len-1) {
            if(S.at(i) == pre) {
                break;
            }else {
                count++;
                break;
            }
        }else {
            if(dual == 0) {
                if(S.at(i) == pre) {
                    pre = '@';
                    dual = 1;
                    i+=2;
                }else {
                    pre = S.at(i);
                    i++;
                }
            }else {
                pre = S.at(i);
                i++;
                dual = 0;
            }
        }
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll mod=1e9+7;
const ll N = 2e5+10;




void solve(){
    
    int n=0,k=0,ans=0;
    cin>>n>>k;
    int vis[n];
    memset(vis,0,sizeof(vis));
    for(int i=0;i<n;i++){
        int x=0;
        cin>>x;
        for(int j=0;j<x;j++){
            int r=0;
            cin>>r;
            r--;
            vis[r]++;
        }
    }
    for(int i=0;i<n;i++){
        if(vis[i]==0){
            ans++;
        }
    }
    cout<<ans<<"\n";
    
    
}
        
        

int main(){
    
        
        ios_base::sync_with_stdio(0);
        cin.tie(0);cout.tie(0);
        ll T=1;
        //cin>>T;
        for (ll i = 1; i <=T; i++) {
            //cout<<"Case #"<<i<<": ";
            solve();
        }
            
            
        return 0;
}



Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>

using namespace std;
long X, Y;

int main() {
  cin >> X >> Y;
  long i = X;
  long ans = 0;
  while(i <= Y) {
    ans++;
    i *= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=105;
//i_am_noob
int n,cnt=0;
set<int> st;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	while(1){
		cnt++;
		if(st.count(n)){
			print1(cnt);
			return 0;
		}
		st.insert(n);
		n=(n%2?n*3+1:n/2);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int X,K,Q,r[N],t[N],x[N],la,lb,a,b,c,t1,t2,add,tmp,diff,f;
int main() {
//	freopen("data.in","r",stdin);
	cin>>X;
	cin>>K;
	for(int i=1;i<=K;i++)
		cin>>r[i];
	cin>>Q;
	for(int i=1;i<=Q;i++)
		cin>>t[i]>>x[i];
	t1=0,t2=1;
	a=0,b=X,f=-1;
	while(t2<=Q) {
		if(t[t2]>r[t1+1]&&t1<K) {
			t1++;
			add=f*(r[t1]-r[t1-1]);
//			b=max(0ll,max(0ll,min(X,X-f*add))-c);
//			a=min(X,min(X,max(0ll,0ll-f*add))-c);
			b+=add,a+=add;
			b=max(0,min(X,b)),a=max(0,min(X,a));
			c+=add;
			f*=-1;
		}
		else {
			diff=t[t2]-r[t1];
			tmp=max(a,min(b,x[t2]+c));
			tmp+=diff*f;
			tmp=max(0,min(X,tmp));
			cout<<tmp<<endl;
			t2++;
		}
	}
	return 0;
}

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

const double EPS = 1.0e-9;

int main()
{
	vector<int> prime;
	prime.push_back(2);
	prime.push_back(3);

	for (int i = 4; i < 10000; i++) {
		bool flag = true;

		for (int j = 0; j < prime.size(); j++) {
			if (i%prime[j] == 0) {
				flag = false;
				break;
			}
		}

		if (flag == true) {
			prime.push_back(i);
		}
	}

	while (true) {
		int m, a, b;

		cin >> m >> a >> b;

		if (m == 0 && a == 0 && b == 0) {
			break;
		}

		int ansp, ansq;
		int maxarea = 0;

		rep(i, prime.size()) {
			for (int j = i; j < prime.size(); j++) {
				if (prime[i] * prime[j] <= m && ((double)a / b <= (double)prime[i] / prime[j] || fabs((double)a / b - (double)prime[i] / prime[j]) < EPS) && (double)prime[i] / prime[j] <= 1) {
					if (prime[i] * prime[j] > maxarea) {
						maxarea = prime[i] * prime[j];
						ansp = prime[i];
						ansq = prime[j];
					}
				}
			}
		}

		cout << ansp << " " << ansq << endl;
	}


	return 0;
}

Measured memory_bytes: 3160
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e5+5, LG = 17, MOD = 998244353;
const int SQ = 450;
const long double EPS = 1e-7;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
  int l, r;
  cin >> l >> r;

  if(r-l+1>=5000){
    cout<<0<<'\n';
    return 0;
  }
  ll ans = 2019;
  f(i,l,r+1)
    f(j,i+1,r+1)
      ans=min(ans,1ll*i*j%2019);

  cout<<ans<<'\n';


  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll oo=1e18;
#define mp make_pair
#define I insert
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line() cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

ll n,k;
vector<ll> a;

bool go(ll MAX)
{
    ll tot=0;
    for(ll i=0;i<n;i++){
        if(a[i] > MAX and a[i] > 0)
            break;
        if(a[i]>0){ // inc order
            ll l=i+1 , r=n-1;
            ll res=i;
            while(l<=r){
                ll mid = (l+r)/2;
                if(a[i]*a[mid]<=MAX){
                    l = mid + 1;
                    res = mid;
                }
                else r= mid-1;
            }
            tot += res-i;
        }
        else if(a[i] < 0){ // dec order
            ll l = i+1, r=n-1;
            ll res=n;
            while(l<=r){
                ll mid = (l+r)/2;
                if(a[i]*a[mid] <= MAX){
                    res = mid;
                    r = mid-1;
                }
                else l = mid + 1;
            }
            tot += n - res;
        }
        else{
            if(MAX >=0 )
                tot += n - i - 1;
        }
    }
    return tot >= k;
}

int main() 
{
    fastio();
	ll t=1;
    //cin>>t;
    while(t--){
       cin>>n>>k;
       a.resize(n);
       for(ll i=0;i<n;i++)
            cin>>a[i];
       sort(a.begin(),a.end());
       
    //   bool res = go(-6);
    //   cout << res << " ";
    //   continue;
       
       ll l = -oo , r = oo;
       ll ANS=r;
       while(l<=r){
           ll mid = (l+r)/2;
           if(go(mid)){
               ANS = mid;
               r  = mid-1;
           }
           else l = mid + 1;
       }
       cout << ANS << endl;
    }
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

struct point{
    int x, y;
};

int diff(point a, point b){
    return abs(a.x - b.x)+abs(a.y - b.y);
}

int main(){
    int H, W, D;
    int A[300][300];
    int sum[90000];
    point pts[90000];
    cin >> H >> W >> D;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> A[i][j];
            pts[A[i][j]] = (point){i+1, j+1};
        }
    }
    for(int i = 1; i <= D; i++){
        sum[i] = 0;
        for(int j = 1; j*D + i <= H*W; j++){
            sum[j*D+i] = sum[(j-1)*D+i]+diff(pts[(j-1)*D+i], pts[j*D+i]);
        }
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int L, R;
        cin >> L >> R;
        cout << sum[R] - sum[L] << endl;
    }
}

Measured memory_bytes: 2560
//============================================================================
// Name        : competitive_programing.cpp
// Author      : .Data_Nerd.
// Description : problem solving training
//============================================================================

#include <bits/stdc++.h>
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define files freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define MOD 1000000007
#define OO 0x3f3f3f3f
#define NIL -1
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector <bool> lala;
typedef pair<int, int> piaz;
typedef vector<vector<int>> board;
typedef priority_queue <piaz, vector <piaz>, greater<piaz>> wMinPQ;
typedef priority_queue <int, vector <int>, greater<int>> minPQ;
template <typename T> T GCD(T a, T b) { return !a ? b : GCD(b % a, a); }
template <typename T> T LCM(T a, T b) { return (a * b) / GCD(a, b); }
template <typename T>
T fastPower(T base, T power) {
	if(!power)
		return 1;
	T ans = fastPower(base, power >> 1);
	return power & 1 ? ans * ans * base : ans * ans;
}
template <typename T>
T modPower(T base, T power, T m = MOD) {
	if(!power)
		return 1;
	T ans = modPower(base, power >> 1) % m;
	return power & 1 ? (((ans * ans) % m) * (base % m)) % m : (ans * ans) % m;
}

string k;

int d, size;

const int N =  1e4;

int memo[N][100][2];

int add(int x, int y, int m) {
	return (x + y) % m;
}

int dp(int idx = 0, int sum = 0, bool isLess = false) {
	if(idx == size)
		return sum == 0;
	int &ans = memo[idx][sum][isLess];
	if(ans != NIL)
		return ans;
	ans = 0;
	for(int i = 0; i < 10; ++i) {
		if(not isLess and i > k[idx] - '0')
			continue;
		bool smaller;
		if(isLess)
			smaller = true;
		else if(i < k[idx] - '0')
			smaller = true;
		else
			smaller = false;
		ans = add(dp(idx + 1, add(sum, i, d), smaller), ans, MOD);
	}
	return ans;
}

int main() {
    Data_Nerd

	cin >> k >> d;
    size = k.size();
    memset(memo, NIL, sizeof memo);

    cout << (dp() - 1 + MOD) % MOD;

    return 0;
}


Measured memory_bytes: 8960
from collections import defaultdict as dd
a=dd(int)
freq=0
leng=""
seq=""
b=input().split()
for i in b:
    a[i]+=1
    if freq<a[i]:
        freq=a[i]
        seq=i
    if len(leng)<len(i):
        leng=i
print(seq,leng)

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	
  	char a; cin >> a;
  	if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o')
      cout << "vowel" << endl;
  else cout << "consonant" << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <random>
#include <iomanip>
#include <functional>
#include <list>
#include <unordered_map>
using namespace std;

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

    int max_h = 0;
    int x[100], y[100], h[100];
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
        max_h = max(max_h, h[i]);
    }

    for (int c_x = 0; c_x <= 100; c_x++)
        for (int c_y = 0; c_y <= 100; c_y++)
            for (int c_h = max_h; c_h <= max_h + 200; c_h++)
            {
                bool all_good = true;
                for (int i = 0; i < n; i++)
                {
                    all_good &= (h[i] == max(c_h - abs(x[i] - c_x) - abs(y[i] - c_y), 0));
                    if (!all_good)
                        break;
                }

                if (all_good)
                {
                    cout << c_x << ' ' << c_y << ' ' << c_h;
                    return 0;
                }
            }
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i).sort_by{|e| -e} << 0
b = gets.split.map(&:to_i).sort_by{|e| -e} << 0
c = gets.split.map(&:to_i).sort_by{|e| -e} << 0

bc = Array.new(n + 1, 0)
k = 0
n.times do |j|
    k += 1 while c[k] > b[j]
    bc[j] = bc[j - 1] + k
end

ab = Array.new(n + 1, 0)
j = 0
n.times do |i|
    j += 1 while b[j] > a[i]
    ab[i] = ab[i - 1] + bc[j - 1]
end

puts ab[n - 1]

Measured memory_bytes: 29364
e1,e2,e3,e4=map(int,input().split())
if e1==e2:
    if e3==e4:
        print("yes")
    else:
        print("no")
elif e1==e3:
    if e2==e4:
        print("yes")
    else:
        print("no")
elif e1==e4:
    if e3==e2:
        print("yes")
    else:
        print("no")
else:
    print("no")


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

#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define int long long
#define fast_io() ios::sync_with_stdio(false)
#define FOR(i, l, r) for(int i = (l); i < (r); i++)
#define H(x) cout << #x << " " << x << endl;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;
typedef double ld;
typedef pair<ld, ld> dd;

const ll INF = 1000000000000000000LL;
const int NMAX = 1e6+4;
const int mod = 1e9+7;
const ld eps = 1e-10;
const ld PI = acos(-1);

vii meals;

bool gt (ii a, ii b){
    return a.fst + a.snd > b.fst + b.snd;
}

signed main(){
    int N;
    cin >> N;
    FOR(i, 0, N){
        int a, b;
        cin >> a >> b;
        meals.pb({a,b});
    }
    sort(meals.begin(), meals.end(), gt);
    int sum = 0;
    FOR(i, 0, N) {
        if(i % 2 == 0) sum += meals[i].fst;
        else sum -= meals[i].snd;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 2420
N = int(input())
AList = list(map(int, input().split()))
BList = list(map(int, input().split()))

enemy = 0
for i in range(N):
    # a: 自分の担当で倒せる数
    a = min([AList[i], BList[i]])
    # b: 自分の担当以上に倒せる数
    b = min([AList[i + 1], max([BList[i] - AList[i], 0])])
    AList[i + 1] = max([AList[i + 1] - b, 0])
    # 合計値
    enemy = enemy + a + b
print(enemy)

Measured memory_bytes: 19244
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);



ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    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;
    }
}


#define comuse Comuse()

ll combi(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;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
  ll n,x;
  	cin>>n>>x;
  if(500*n>=x){
    cout<<"Yes\n";
  }
  else{
    cout<<"No\n";
  }
}

Measured memory_bytes: 764
(def s (clojure.string/trim (read-line)))
; (def s "redcoder")
; (def s "vvvvvv")

(defn solve [str]
  (let [matches (map = (seq str) (reverse str))
        pairs (count (filter #(= %1 false) matches))]
    (println (/ pairs 2))))

(solve s)

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

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

int main() {
        int h, w;
        cin >> h >> w;
        int ansh, answ;
        rep(i, h) rep(j, w) {
                string s;
                cin >> s;
                if (s == "snuke") {
                        ansh = i;
                        answ = j;
                        break;
                }
        }
        char ans = 'A' + answ;
        cout << ans << ansh + 1 << endl;
        return 0;
}



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

class Main
{
    static class Len
    {	
	int a[]; //= new int[2000010];
	int b[]; //= new int[2000010];
	
	Len(int n)
	{
	    a = new int[n+1];
	    b = new int[n+1];
	}
	

    }

    public static void main(String args[])
    {
	int n;
	int i, j, k;

	String line = new String();
	BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));

	//Read ----------------
	//Read n
	try{
	    line=line=bin.readLine();
	}	
	catch(IOException e){
	    System.out.println("Error");
	}

	n=Integer.parseInt(line);
	Len len = new Len(n);
	j=0;
	//Read A[]
	try{
	    line=bin.readLine();
	    //System.out.println(line);
	    StringTokenizer str = new StringTokenizer(line);   
	    for(i=0; i<n; i++)
		{
		    len.a[i]=Integer.parseInt(str.nextToken());
		    if(j<len.a[i])j=len.a[i];
		}
	}
	catch(IOException e){
	    System.out.println("Error");
	}

	//bin=null;

	//Read end------------


	//sort
	countingSort(len, j, n);

	//print
	StringBuffer s = new StringBuffer(1000);
	for(i=1; i<=n; i++)
	    {
		s.append(len.b[i]);
		if(i!=n)s.append(" ");
	    }
	System.out.println(s);

    }

    static void countingSort(Len len, int max, int n)
    {
	int i, j, k;
	int[] c = new int[max+1];

	for(i=0; i<n; i++)c[len.a[i]]++;

	for(i=0; i<=max; i++)
	    {
		if(i!=0)c[i]+=c[i-1];
	    }

	for(i=n-1; i>=0; i--)
	    {
		len.b[c[len.a[i]]]=len.a[i];
		c[len.a[i]]--;
	    }
    }
}

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

int main(){

    string n1,n2;
    int hit,blow;

    while(cin>>n1>>n2&&n1!="0"){

        hit=blow=0;
        for(int i=0;i<4;i++){
            if(n1[i]==n2[i]) hit++;
        }
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(i!=j&&n1[i]==n2[j]) blow++;
            }
        }

        cout<<hit<<" "<<blow<<endl;
    }

    return 0;
}


Measured memory_bytes: 3220
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 1055050

main(){
    ll x=in();
    double p=in();
    ll ans=0;
    if(x%2)x++;
    double xx=x;
    xx/=2.0;
    printf("%.10f\n",xx/p*100.0);
}

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

int main() {
    string a; cin >> a;
    string b; cin >> b;
    if(a[0] == b[2] &&
       a[1] == b[1] &&
       a[2] == b[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int s1 = 0, s2 = 0, s3 = 0;
  string input_data;
  int N[3];
  int num = 0;
  cin >> input_data;

  for(int i = 0; i < 3; i++){
    N[i] = (int)(input_data[i] - '0');
  }

  s1 = N[0];
  s2 = N[1];
  s3 = N[2];

  for (int i = 0; i < 3; i++){
    if (N[i] == 1){
      num ++;
    }
  }

  cout << num << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int A = sc.nextInt();
    int count = 0;
    
    while(H>0){
      H -= A; 
      count++;
    }
      System.out.println(count);
  }
}

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

int main() {
  int N, K;
  string S;
  string s = "";
  cin >> N >> K;
  cin >> S;
  for (int i = 0; i < N; i++) {
    if (i + 1 == K) {
      s += tolower(S[i]);
    } else {
      s += S[i];
    }
  }

  cout << s << endl;
}


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

int main(void){
    string start = "01234567";
    map<string, int> d;
    queue<string> Q;
    int dx[] = {1, -1, 4, -4};
    Q.push(start);
    d[start] = 0;
    while(!Q.empty()) {
        string s = Q.front(); Q.pop();
        int x = s.find("0");
        rep(i, 4) {
            int nz = x+dx[i];
            if(nz>=0 && nz < 8 && !(x==3&&nz==4) && !(x==4&&nz==3) ){
                string tmp = s;
                swap(tmp[x], tmp[nz]);
                if(d.count(tmp) == 0) {
                    Q.push(tmp);
                    d[tmp] = d[s] + 1;
                }
            }
        }
    }

    while(true) {
        string input = "";
        char t;
        rep(i, 8) {
            if(cin >> t) input.push_back(t);
            else return 0;
        }
        cout << d[input] << endl;
    }
}

Measured memory_bytes: 3440
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = l[0], K = l[1];
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var Mod = 1000000007;

            var ans = 0L;
            for (var i = 0; i < N; i++)
            {
                var right = 0;
                var all = 0;
                for (var j = i; j < N; j++)
                    if (A[i] > A[j]) right++;
                for (var j = 0; j < N; j++)
                    if (A[i] > A[j]) all++;

                ans += right * K % Mod;
                ans %= Mod;
                ans += (K - 1) * K / 2 % Mod * all % Mod;
                ans %= Mod;
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
  
using namespace std;
  
typedef string::const_iterator State;
typedef pair<int, int> Pii;
  
#define fr first
#define sc second
  
bool is_over = false;
  
struct Parser {
  Pii expression(State &idx) {
    Pii ret = term(idx);
    //if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    while ( 1 ) {
      if ( *idx == '+' ) {
	idx++;
	Pii tmp = term(idx);
	ret.fr = ret.fr + tmp.fr;
	ret.sc = ret.sc + tmp.sc;
	if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      } else if ( *idx == '-' ) {
	idx++;
	Pii tmp = term(idx);
	ret.fr = ret.fr - tmp.fr;
	ret.sc = ret.sc - tmp.sc;
	if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      } else {
	break;
      }
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }
    
  Pii term(State &idx) {
    Pii ret = factor(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    while ( 1 ) {
      if ( *idx == '*' ) {
	idx++;
	Pii tmp = factor(idx), tmp2 = ret;
	ret.fr = tmp2.fr * tmp.fr - tmp2.sc * tmp.sc;
	ret.sc = tmp2.fr * tmp.sc + tmp2.sc * tmp.fr;
	if ( abs(ret.fr)> 10000 || abs(ret.sc) > 10000 ) is_over = true;
      } else {
	break;
      }
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }
  
  Pii factor(State &idx) {
    Pii ret;
    if ( *idx == '(' ) {
      idx++;
      ret = expression(idx);
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
      idx++;
    } else {
      ret = number(idx);
      if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    }
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    return ret;
  }
  
  Pii number(State &idx) {
    int tmp = 0;
    while ( '0' <= *idx && *idx <= '9' ) {
      tmp *= 10;
      tmp += *idx - '0';
      if ( abs(tmp) > 10000 ) is_over = true;
      idx++;
    }
    if ( abs(tmp) > 10000 ) is_over = true;
    if ( *idx == 'i' ) {
      idx++;
      return Pii(0, 1);
    }
   
    else return Pii(tmp, 0);
  }
};
  
int main()
{
  string s;
  while ( cin >> s ) {
    is_over = false;
    Parser ps;
    string tmp = s.substr(0, s.size() - 1);
    State idx = s.begin();
  
    Pii ret = ps.expression(idx);
    if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true;
    if ( is_over ) cout << "overflow" << endl;
    else if ( ret.fr == 0 && ret.sc == 0 ) cout << 0 << endl;
    else if ( ret.fr == 0 ) printf("%di\n", ret.sc);
    else if ( ret.sc == 0 ) printf("%d\n", ret.fr);
    else printf("%d%+di\n", ret.fr, ret.sc);
  }
  
  return 0;
}

Measured memory_bytes: 3180
import bisect
n, m = map(int, input().split())
p = []
y = []
py = []
categorized = [[] for i in range(n+1)]
for i in range(m):
    tmpp, tmpy = map(int, input().split())
    p.append(tmpp)
    y.append(tmpy)
    categorized[tmpp].append(tmpy)

for c in categorized:
    c.sort()
for i in range(m):
    order = bisect.bisect(categorized[p[i]], y[i])
    print('%06d%06d' % (p[i], order))


Measured memory_bytes: 24116
import sys
sys.setrecursionlimit(10**9)

N = int(input())
G = [[] for _ in range(N)]
length = {}
for _ in range(N-1):
    a, b, c = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    length[(a-1, b-1)] = c
    length[(b-1, a-1)] = c

r = 0
dist = [0]*N

prv = [None]*N
depth = [0]*N

def dfs(v):
    for u in G[v]:
        if dist[u] > 0 or u ==r: continue
        dist[u] = dist[v] + length[(v, u)]
        depth[u] = depth[v] + 1
        prv[u] = v
        dfs(u)

dfs(r)

# N: 頂点数
# G[v]: 頂点vの子頂点 (親頂点は含まない)
#
# - construct
# prv[u] = v: 頂点uの一つ上の祖先頂点v
# - lca
# kprv[k][u] = v: 頂点uの2^k個上の祖先頂点v
# depth[u]: 頂点uの深さ (根頂点は0)

LV = (N-1).bit_length()
def construct(prv):
    kprv = [prv]
    S = prv
    for k in range(LV):
        T = [0]*N
        for i in range(N):
            if S[i] is None:
                continue
            T[i] = S[S[i]]
        kprv.append(T)
        S = T
    return kprv

def lca(u, v, kprv, depth):
    dd = depth[v] - depth[u]
    if dd < 0:
        u, v = v, u
        dd = -dd

    # assert depth[u] <= depth[v]
    for k in range(LV+1):
        if dd & 1:
            v = kprv[k][v]
        dd >>= 1

    # assert depth[u] == depth[v]
    if u == v:
        return u

    for k in range(LV-1, -1, -1):
        pu = kprv[k][u]; pv = kprv[k][v]
        if pu != pv:
            u = pu; v = pv

    # assert kprv[0][u] == kprv[0][v]
    return kprv[0][u]

kprv = construct(prv)

Q, K = map(int, input().split())
K -= 1

ans = []
for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    xr = lca(x, K, kprv, depth)
    yr = lca(y, K, kprv, depth)
    a = dist[x] + dist[K] - dist[xr]*2 + dist[y] + dist[K] - dist[yr]*2
    ans.append(a)

print('\n'.join(map(str, ans)))

Measured memory_bytes: 176056
S = input()

N = len(S)
ans = 0
if S == S[::-1]:
    ans = ans + 1

tmp = S[:(N-1)//2]
if tmp == tmp[::-1]:
    ans = ans + 1

tmp = S[(N+3)//2-1:]
if tmp == tmp[::-1]:
    ans = ans + 1

print(["No", "Yes"][ans==3])


Measured memory_bytes: 3060
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
  var N = lines[0];
  var diff = [];
  for(var i=0; i<N.length-2; i++){
    var pick_num = N.slice(i, i+3);
    var sabun = Math.abs(753-pick_num);
    diff.push(sabun);
  }
  var result = Math.min(...diff)
  console.log(result);
});

Measured memory_bytes: 7628
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


int main(){
    
    string s, t;
    cin >> s >> t;
    ll flg = 0;
    for(ll i = 0; i < s.size(); i++){
        ll f = 1;
        for(ll j = 0; j < s.size(); j++){
            ll k = (i + j) % s.size();
            if(s[j] != t[k])f = 0;
        }
        if(f)flg = 1;
    }
    if(flg)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

int main() {

    int n;

    cin >> n;

    long long int a[n];

    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    sort(a,a+n);

    long long int w=-1,h=0;

    for(int i=n-1;i>0;i--){
        if(a[i] == a[i-1]){
            if(w==-1){
                w = a[i];
                i--;
            }
            else{
                h = a[i];
                break;
            }
        }
    }

    cout << w*h << endl;



    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

	      
int main(){
  int i, left, right, mid, n, m, count = 0;
  scanf("%d", &n);
  int A[n];
  for(i = 0 ; i < n ; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &m);
  int B[m];
  for(i = 0 ; i < m ; i++){
    scanf("%d", &B[i]);
  }
  i = 0;
  for(i = 0 ; i < m ; i++){
    int j;
    for(j = 0 ; j < n ; j++){
      if(A[j] == B[i]){
	count++;
	break;
      }
    }
    /* left  = 0;
    right = n;
    while(left < right){
      mid = (left + right) / 2;
      if(B[i] == A[mid]){
	count++;
	break;
      }
      else if(B[i] < A[mid]){
	right = mid;
      }
      else if(B[i] > A[mid]){
	left = mid + 1;
      }
      else break;
      }*/
  }
  printf("%d\n", count);
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    int ans=0;
    for(int x=1;x<=7;x++){
        for(int y=1;x+y<=8;y++){
            for(int z=1;x+y+z<=9;z++){
                vint v;
                REP(i,x) v.push_back(3);
                REP(i,y) v.push_back(5);
                REP(i,z) v.push_back(7);

                do{
                    int s=0;
                    REP(i,x+y+z){
                        s*=10;
                        s+=v[i];
                    }
                    if(s<=N) ans++;
                }while(next_permutation(ALL(v)));

            }
        }
    }
    cout<<ans<<endl;
 
}

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

using namespace std;

const long long INF = 1e18;

int n, i, j;
pair <int, int> a[500005];

bool cmp(pair<int, int> x, pair<int, int> y){
	return x.second < y.second;
}

long long solve(int l, int r){
	if(l == r) return INF;
	
	int mid = (l + r) / 2;
	int mv = a[mid].first;
	long long mn = min(solve(l, mid), solve(mid + 1, r));
	inplace_merge(a + l, a + mid + 1, a + r + 1, cmp);
	
	vector <pair<int, int> > p;
	
	long long curmn = mn;
	
	for(int i = l; i <= r; i++){
		if(abs(a[i].first - mv) >= mn) continue;
		for(int j = p.size() - 1; j >= 0; j--){
			long long dx = abs(a[i].first - p[j].first);
			long long dy = abs(a[i].second - p[j].second);
			if(dy >= mn) break;
			curmn = min(curmn, dx * dx + dy * dy);
		}
		p.push_back(a[i]);
	}
	
	return curmn;
}

int main(){
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	scanf("%d%d", &a[i].first, &a[i].second);
	
	sort(a, a + n);
	
	printf("%lld\n", solve(0, n - 1));
}



Measured memory_bytes: 12592
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int Gcd(int a, int b) {
    return b ? Gcd(b, a%b) : a;
}

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

    int A, B, K; cin >> A >> B >> K;

    int count = 0;
    int res = 0;
    rrep(now, min(A, B)+1, 1) {
        if (A%now == 0 and B%now == 0) ++count;
        if (count == K) {
            res = now;
            break;
        }
    }

    cout << res << endl;
}

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

int main(){
    vector<int>a(3);
    cin >> a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    cout << a[2]-a[0] << endl;
    return 0;
}


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

int main(){
  int a,b,c,x;
  int cont=0;
  cin>>a>>b>>c;

  for(int t=0;t<b;t++){
      x=((a%b)*(t%b))%b;
      if(x==c)cont++;
  }  
  if(cont==0){
      cout<<"NO"<<"\n"; 
  }else{
      cout<<"YES"<<"\n";
  }
} 



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

#define NOT_CORRECT {printf("No");return 0;}
#define ALL_CORRECT {printf("Yes");}

using namespace std;

int main(void)
{
	int n, x, y, k;
	
	scanf("%d", &n);
	while (n--)
	{
		scanf("%d%d%d", &k, &x, &y);
		x = abs(x);
		y = abs(y);
		if (x + y > k)
		{
			NOT_CORRECT
		}
		if ((x + y) % 2 != k % 2)
		{
			NOT_CORRECT
		}
	}
	
	ALL_CORRECT
	
	return 0;
}

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

int main() {
  const string vowels= "aeiou";
  char c;
  cin >> c;
  auto res= find(vowels.begin(), vowels.end(), c);
  if(res!=vowels.end()){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
long long A[300009];
long long ans = 0, mod = 1e9 + 7;
long long b[64];
int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        scanf("%lld",&A[i]);
    }
    for (long long i = 1; i <= N; i++) {
        long long p = 1;
        for (int j = 0; j <= 60; j++) {
            if ((A[i] & p) == 0) {
                ans = (ans + b[j] * (p % mod)) % mod;
            }
            else {
                ans = (ans + (i - 1 - b[j]) * (p % mod) ) % mod;
                b[j]++;
            }
            //printf("%I64d %I64d\n", ans, p);
            p = p * 2;
        }
    }
    cout << ans % mod;
    return 0;
}


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

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

#define int ll

const ll mod = 1e9 + 7;


main(){
	int n,m;
	int ans[10];
	for(int i=0;i<10;i++) ans[i] = -1;

	cin >> n >> m;
	int s,c;
	for(int i=0;i<m;i++){
		cin >> s >> c;
	
		if(ans[s-1]==-1 || ans[s-1]==c){
			ans[s-1] = c;
		}else{
			cout << -1 << endl;
			return 0;
		}
	}
	if(ans[0]==0){
		if(n==1){
			cout << 0 << endl;
		}else{
			cout << -1 << endl;
			return 0;
		}
	}else{
		for(int i=0;i<n;i++){
			if(ans[i]==-1 && i==0 && n>1) cout << 1;
			else if(ans[i]==-1) cout << 0;
			else cout << ans[i];
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3608
import itertools

N = input()
array = list(map(int, input().split()))

p = list(itertools.combinations(array, 3))

count = 0

for p_i in p:
    if p_i[0] + p_i[1] > p_i[2]:
        if p_i[1] + p_i[2] > p_i[0]:
            if p_i[2] + p_i[0] > p_i[1]:
                if p_i[0] != p_i[1] and p_i[1] != p_i[2] and p_i[2] != p_i[0]:
                    count = count + 1

print(count)

Measured memory_bytes: 20436
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
using namespace std;

int main(){
    int n,m;
    bool f = false;
    set<string> s;
    cin >> n;
    for(int i=0;i<n;i++){
        string str;
        cin >> str;
        s.insert(str);
    }
    cin >> m;
    for(int i=0;i<m;i++){
        string str;
        cin >> str;
        if(s.find(str) == s.end()) cout << "Unknown " << str << endl;
        else if(!f){
            cout << "Opened by " << str << endl;
            f = true;
        } else {
            cout << "Closed by " << str << endl;
            f = false;
        }
    }
}

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

#define pf printf
#define sc scanf
#define rep0(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repU(i,bottom,ceiling) for(int (i)=(bottom);(i)<=(ceiling);(i)++)
#define repD(i,ceiling,bottom) for(int (i)=(ceiling);(i)>=(bottom);(i)--)
#define V vector
#define vi V<int>
#define pub(v,el) v.push_back(el)
#define pob(v) v.pop_back
#define ci(a) cin>>a
#define lco(a) cout<<a<<endl
#define co(a) cout<<a
#define vco(v) rep0(i,v.size()){ co(v[i]<<' '); } co('\n')
#define P pair
#define pii P<int,int>
#define mp(a,b) make_P(a,b)
#define fir first
#define sec second

typedef long long ll;
typedef double db;

const int dir[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
const int Inf=2e9+1e8;

template <typename T,typename U>                                                   
pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir+r.fir,l.sec+r.sec};                                    
} 

template <typename T,typename U> 
pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir-r.fir,l.sec-r.sec};                                    
} 
             
/*The main code follows*/

int main(){
	int s=0,n; 
	ci(n);
	vi a(n);
	rep0(i,n){ ci(a[i]); s+=a[i]; }
	bitset<4000000> b;
	b[0]=1;
	rep0(i,n) b|=b<<a[i];
	int cnt=(s+1)/2;
	while(!b[cnt]) cnt++;
	lco(cnt);
    return 0;
}








Measured memory_bytes: 1664