akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

struct Nbase {
    int n;
    int sz = 1;
    long long max = 1e18;

    Nbase(int k = 2){
        n = k;
        while(max != 0){
            max /= n;
            sz++;
        }
    };

    //繰り返し二乗法
    ll EX(ll x,ll n){
        if(n == 0) return 1;
        else if(n%2 == 1) return EX(x,n-1)*x;
        else return EX(x*x,n/2);
    }

    vector<int> to_n(ll num){
        vector<int> ret(sz);
        for(int i = sz-1; i >= 0; i--){
            long long subtraction = EX(n,i);
            int quotient = num/subtraction;
            ret[i] = quotient;
            num -= ret[i]*subtraction;
        }
        return ret;
    }

    long long re_n(vector<int>& vec){
        long long ret = 0;
        vec.resize(sz);
        for(int i = 0; i < sz; i++){
            ret += vec[i]*EX(n,i);
        }
        return ret;
    }

    void supress(const vector<int>& lim,vector<int>& at){
        bool upper = true;
        for(int i = sz; i >= 0; i--){
            if(upper && lim[i] > 0) upper = false;
            if(lim[i] > at[i]) break;
            else if(upper || lim[i] < at[i]) at[i] = lim[i];
        }
    }
};

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    Nbase base = 2;
    vector<int> xnum(base.sz,0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        vector<int> num = base.to_n(a[i]);
        for(int i = 0; i < num.size(); i++){
            xnum[i] += num[i];
        }
    }
    for(int i = 0; i < xnum.size(); i++){
        if(xnum[i] <= n/2) xnum[i] = 1;
        else xnum[i] = 0;
    }
    vector<int> knum = base.to_n(k);
    base.supress(knum,xnum);
    ll x = base.re_n(xnum);
    ll ans = 0;
    for(int i = 0; i < n; i++) ans += x^a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3968
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

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

        if (i % 2 == 0) {
            tmp += a[i];
        } else {
            tmp -= a[i];
        }
    }

    for (int i = 0; i < n; i++) {
        cout << tmp << ' ';
        tmp = 2 * a[i] - tmp;
    }

    return 0;
}

Measured memory_bytes: 2048
import math
n,k = map(int, input().split())
end=min(n-k+1,k)
ans=1
for i in range(1,end+1):
    ans=math.factorial(n-k+1)*math.factorial(k-1)//(math.factorial(i)*math.factorial(n-k+1-i)*math.factorial(i-1)*math.factorial(k-i))
    print(ans%(10**9+7))
if end==n-k+1:
    for _ in range(end+1,k+1):
        print("0")

Measured memory_bytes: 3316
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
  tmp = toIntAll(tmp);
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);

  var plus = a+b;
  var minus = a-b;
  var mul = a*b;

  var max = plus > minus ? plus : minus;
  max = max > mul ? max : mul;

	//出力
	console.log('%d',max);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function toIntAll(input){
  var out = []
  for(var i=0; i<input.length; i++){
    out[i] = parseInt(input[i]);
  }
  return out;
}


Measured memory_bytes: 9420
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll N, a[100000];
int main() {

	cin >> N;
	ll ans1 = 0, ans2 = 0;//1は正から、２は負


	FOR(i, 0, N) {
		cin >> a[i];
	}


	ll sum = 0;
	if (a[0] <= 0) { ans1 += abs(a[0])+1; sum = 1; }
	else sum = a[0];
	FOR(i, 1, N) {
		sum += a[i];
		if (i % 2 == 1) {//負
			if (sum >= 0) {
				ans1 += sum + 1;
				sum = -1;
			}
		}
		else {
			if (sum <= 0) {
				ans1 += -sum + 1;
				sum = 1;
			}

		}
	}
	sum = 0;
	if (a[0] >= 0) { ans2 += abs(a[0]) + 1; sum = -1; }
	else sum = a[0];
	FOR(i, 1, N) {
		sum += a[i];
		if (i % 2 == 0) {//正
			if (sum >= 0) {
				ans2 += sum + 1;
				sum = -1;
			}
		}
		else {
			if (sum <= 0) {
				ans2 += -sum + 1;
				sum = 1;
			}

		}
	}
	cout << min(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>

using namespace std;


int main() {

    int N, K;

    cin >> N >> K;

    vector<int> ls;

    for (int i = 0; i < N; i++) {
        int l;
        cin >> l;
        ls.push_back(l);
    }

    sort(ls.rbegin(), ls.rend());

    int sum = 0;

    for (int i = 0; i < K; i++) {
        sum += ls[i];
    }

    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)
using pll = std::pair<lld, lld>;

using namespace std;
using namespace atcoder;

#define MOD (998244353)

pll add(pll x, pll y) {
  return make_pair(x.first + y.first % MOD, x.second + y.second % MOD);
}

pll mapping(lld f, pll x) {
  if (f == 0) {
    return x;
  }
  return make_pair(x.second * f % MOD, x.second);
}

lld composition(lld f, lld g) {
  if (f == 0) {
    return g;
  }
  return f;
}

lld id() {
  return 0;
}

pll e() {
  return make_pair(0, 0);
}

int main(void) {
  lld n, q;
  cin >> n >> q;
  lazy_segtree<pll, add, e, lld, mapping, composition, id> seg(n);

  lld cum = 1;
  for (lld i = n - 1; i >= 0; i--) {
    seg.set(i, make_pair(cum, cum));
    cum = cum * 10 % MOD;
  }

  for (lld i = 0; i < q; i++) {
    lld l, r, d;
    cin >> l >> r >> d;
    seg.apply(l - 1, r, d);
    cout << seg.all_prod().first % 998244353 << "\n";
  }
}

Measured memory_bytes: 16756
import sys
INF=float('inf')
def Bellmanford(n,edges,r):
  d=[INF]*n
  d[r]=0    
  for i in range(n):
    for (u,v,c) in edges:
      if d[u]!=INF and d[u]+c<d[v]:
        d[v]=d[u]+c
        if i==n-1 and v==n-1:
          return 'inf'   
  return (-1)*d[n-1]

N,M=map(int, sys.stdin.readline().split())
Edges=[0]*M

for i in range(M):
  a,b,c=map(int, sys.stdin.readline().split())
  Edges[i]=(a-1,b-1,-c)
    
ans=Bellmanford(N,Edges,0)
print(ans)

Measured memory_bytes: 3316
#include <array>
#include <iostream>
#include <string>

template <typename T> struct Queue {
  int head{}, tail{};
  std::array<T, 100000> v;

  void enqueue(T x) {
    v[tail++] = x;
    if (tail == (int)v.size())
      tail = 0;
  }
  T dequeue() {
    T p = v[head++];
    if (head == (int)v.size())
      head = 0;
    return p;
  }
  bool empty() { return head == tail; }
};

struct Process {
  std::string name;
  int time;
};

int main() {
  Queue<Process> pq;
  int n, q;
  std::cin >> n >> q;

  for (int i = 0; i < n; i++) {
    Process p = {};
    std::cin >> p.name >> p.time;
    pq.enqueue(p);
  }

  int t = 0;
  while (!pq.empty()) {
    Process p = pq.dequeue();
    p.time -= q;
    if (p.time > 0) {
      t += q;
      pq.enqueue(p);
    } else {
      t += q + p.time;
      std::cout << p.name << " " << t << std::endl;
    }
  }
}



Measured memory_bytes: 6964
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  deque<char> dq;
  rep(i, s.size()){
    dq.push_back(s.at(i));
  }
  bool f = false;
  int q;
  cin >> q;
  rep(_q, q){
    int in;
    cin >> in;
    if(in == 1){
      f ^= 1;
    }else{
      int tr;
      char c;
      bool t;
      cin >> tr >> c;
      if(tr == 2) t = true;
      else t = false;
      // cerr << t << f << c << endl;
      if(f == false && t == true || f == true && t == false) dq.push_back(c);
      else dq.push_front(c);
    }
  }
  while(!dq.empty()){
    char c;
    if(f == false){
      c = dq.front();
      dq.pop_front();
    }else{
      c = dq.back();
      dq.pop_back();
    }
    cout << c;
  }
  cout << endl;
  return 0;
}

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

int main(void)
{
	int K;
	int A, B;

	cin >> K;
	cin >> A >> B;

	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3588
# なんか雑に書いたらサンプル3通ったしこれでよさそう
# なんかしらんけど2ケースでWAなる
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 1
d = [0] * (n + 10)
d[0] = 3
for i in range(n):
    ans *= d[a[i]]
    d[a[i]] -= 1
    d[a[i] + 1] += 1
    ans %= mod
print(ans)

Measured memory_bytes: 20700
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int num = 0;
		
		for(int i = A; i <= B; i++) {
			if(i%K == 0) {
				num = num +1;
			}
		}
		
		if(num >= 1) {
			System.out.println("OK");
		}else {
			System.out.println("NG");
		}
		sc.close();
	}
}

Measured memory_bytes: 35700
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
#define F first
#define S second
const int N=1e6+5;
int mod = 1e9+7;
void pairsort(int a[], int b[], int n){
    pair<int, int> pairt[n];
    for (int i = 0; i < n; i++) 
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
    sort(pairt, pairt + n);
    for (int i = 0; i < n; i++) 
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
ll pow1(ll n,ll p)
{
    if(p==0)    return 1;
    ll x=pow1(n, p/2);
    x=(x*x)%mod;
    if(p%2==0)
        return x;
    else
        return (x*n)%mod;
}
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
}
bool compare(const pair<ll, ll>&p1, const pair<ll,ll>&p2)
{
    if(p1.F < p2.F) return true;
        if(p1.F == p2.F) return p1.S < p2.S;
        return false;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
int isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
long long C(int n, int r) {
    if(r>n-r) 
        r=n-r;
    long long ans=1;
    for(int i=1;i<=r;i++){
        ans*=n-r+i;
        ans/=i;
    }
    return ans;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int32_t main()
{
    IOS;

    int n,m,f=0,flag=0;
    cin>>n>>m;
    vector<vector<char>> a(n+1,vector<char>(m+1));
    for(int i=0;i<n;i++){
    	for(int j=0;j<m;j++)
        cin>>a[i][j];
    }

   	vector<vector<int>>dp(n+1, vector<int>(m+1));
   	for(int i=0;i<n;i++){
   		for(int j=0;j<m;j++){
   			if(a[i][j]=='#')dp[i][j] = -1;
   		}
   	}
   	if(dp[0][0]==-1){cout<<0<<endl; return 0;}
   	for(int i=0;i<n;i++){
   		if(a[i][0]=='.')
   		dp[i][0] = 1; 
   		else break;
   	}
   	for(int i=0;i<m;i++){
   		if(a[0][i]=='.')
   		dp[0][i] = 1; 
   		else break;
   	}

   	for(int i=1;i<n;i++){
   		for(int j=1;j<m;j++){
   			if(a[i][j]=='.'){
   				if(a[i-1][j]=='.'){
   					dp[i][j] += (dp[i-1][j]+mod)%mod ;
   				}
   				if(a[i][j-1]=='.'){
   					dp[i][j] += (dp[i][j-1]+mod)%mod ;
   				}
   				dp[i][j]%=mod;
   			}
   		}
   	}
   	if(a[n-1][m-1]=='.'){
   		cout<<dp[n-1][m-1]<<endl;
   	} 
   	else cout<<0<<endl;

    return 0;
   	
}


Measured memory_bytes: 9216
#include <iostream>

using namespace std;

int main() {
	
	int exp;
	
	cin >> exp;
	
	bool ok = false;
	
	while (exp!=0) {
		
		int num = exp%10;
		if (num==7){
			ok = true;
			break;
		}
		exp -=num;
		exp/=10;
		
	}
	
	if(ok) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
	
}

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

/*
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/



//************** StrAnge.R *********************

#define ll              long long int
#define ull             unsigned long long
#define ld              long double
#define lll             __int128
#define vi              vector<int>
#define vl              vector<ll>
#define vvi             vector<vector<int> >
#define pii             pair<int,int>
#define piii            pair<int,pair<int,int> >
#define pll             pair<ll,ll>
#define vii             vector<pii>

#define sz(v)           ((int)(v).size())
#define all(s)          s.begin(),s.end()
#define allr(s)         s.rbegin(),s.rend()
#define unq(c)          (sort(all(c)), c.resize(distance(c.begin(),unique(all(c)))))
#define get_pos(c,x)    (lower_bound(all(c),x)-c.begin())

#define MS0(v)          memset((v), 0, sizeof((v)))
#define MS1(v)          memset((v), -1, sizeof((v)))
#define LEN(v)          strlen(v)

#define MP              make_pair
#define pb              push_back
#define pob             pop_back
#define ff              first
#define ss              second
#define sc              scanf
#define pf              printf
#define endl            "\n"

#define TEST_CASE       int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define PRINT_CASE      printf("Case %d: ",cs)

#define vpf(v)          for(int i=0;i<v.size();i++){cout<<v[i];if(i!=v.size()-1)cout<<" ";else cout<<"\n";}
#define vsc(v)          for(int i=0;i<v.size();i++)cin>>v[i];

#define REP(i, n)       for (int i = 0; i < (n); i++)
#define REPP(i, a, b)   for (int i = (a); i < (b); i++)
#define FOR(i, a, b)    for (int i = (a); i <= (b); i++)
#define FORS(i, s)      for (int i = 0; s[i]; i++)

#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileio          freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)

#define intlim          2147483648
#define infinity        (1LL<<50)
#define intmx           INT_MAX
#define PI              3.14159265358979323846264338327950L // acos(-1.0)

#define gcd(a, b)       __gcd(a, b)
#define lcm(a, b)       ((a)*((b)/gcd(a,b)))


int on_bit(int N,int pos){return N = N | (1<<pos);}
int off_bit(int N,int pos){return N = N & ~(1<<pos);}
bool check_bit(ll N,int pos){return (bool)(N & (1<<pos));}


#define start_clock     clock_t tStart = clock()
#define end_clock       printf("\n>>Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC)

template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}


//******************* my code starts here **********************************


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

    vector<string> v(n);

    vsc(v);
    unq(v);
    cout<<v.size()<<"\n";

    return 0;
}


Measured memory_bytes: 9572
#include<algorithm> // sort,reverse,min,lower_bound(.begin(),.end(),find)
#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  vector<int> d;
  rep(i,n){
    int a; cin >>a;
    d.push_back(a);
  }
  sort(d.begin(),d.end());
  if(df){
    for(auto x: d){
      printf("%d ",x);
    }
    printf(": size\n");
  }
  li exc=0;
  rep(i,n-1){
    repa(j,i+1,n){
      auto itr=lower_bound(d.begin(),d.end(),d.at(i)+d.at(j));
      exc+=d.end()-itr;
      if(df)printf("%d,%d:%d\n",d.at(i),d.at(j),d.end()-itr);
    }
  }
  printf("%ld",(li)n*(n-1)*(n-2)/6-exc);
}

/// confirm df==0 ///


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, j, k;
  bool b[4][13] = {};
  char c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c >> k;
    if (c == 'S') j = 0;
    if (c == 'H') j = 1;
    if (c == 'C') j = 2;
    if (c == 'D') j = 3;
    b[j][k - 1] = true;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (!b[i][j]) {
        switch (i) {
          case 0:
            cout << "S " << j + 1 << '\n';
            break;
          case 1:
            cout << "H " << j + 1 << '\n';
            break;
          case 2:
            cout << "C " << j + 1 << '\n';
            break;
          case 3:
            cout << "D " << j + 1 << '\n';
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3104
def main():
    num = list(map(int, input().split()))
    total_sum = 0
    for i in range(1,num[0]+1):
        current = i
        current_sum=0
        while i >=1:
            current_sum += int( i %10)
            i = i//10
        if ((current_sum >= num[1]) and (current_sum <= num[2])):
            total_sum += current
    print(total_sum)
main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0){
		c-=b;
		if(c<=0){
			cout<<"Yes";
			return 0;
		}
		a-=d;
		if(a<=0){
			cout<<"No";
			return 0;
		}
	}
	
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define ve(i) vector<i>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define pr(n) cout << fixed << setprecision(n)
#define ci(n) cin >> n
#define ci2(n, o) cin >> n >> o
#define ci3(n, o, p) cin >> n >> o >> p
#define co(n) cout << n << endl
#define mp(n, o) map<n, o>

int main() {
  st S, a = "No";
  ci(S);
  if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) {
    a = "Yes";
  }
  if(S[0] == S[2] && S[1] == S[3] && S[0] != S[1]) {
    a = "Yes";
  }
  if(S[0] == S[3] && S[1] == S[2] && S[0] != S[2]) {
    a = "Yes";
  }
  co(a);
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  string w;
  cin>>w;
  vector<int>xs(256);
  for(auto x:w)++xs[x];
  for(auto x:xs){
    if(x%2){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  
  if (n % 2 == 0) {
    vector<int> d(n);
    REP(i, n) {
      cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    
    ans = d.at(n / 2) - d.at(n / 2 - 1);
  }
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[101010];
i64 dp[101010], dp2[101010];
void solve(){
	cin >> n;
	for(int i = 0; i <= n; i++){
		cin >> a[i];
	}
	
	bool ok = 1;
	i64 next = 1;
	for(int i = 0; i <= n; i++){
		if(a[i] > next){
			ok = 0;
			break;
		}
		next = min((next-a[i])*2,LINF);
	}
	if(!ok){
		cout << -1 << endl;
		return;
	}
	
	next = 1;
	for(int i = 0; i <= n; i++){
		dp[i] = next;
		next = min((next-a[i])*2,LINF);
	}
	
	next = a[n];
	for(int i = n; i >= 0; i--){
		dp2[i] = next;
		next += a[i-1];
	}
	
	i64 ans = 0;
	for(int i = 0; i <= n; i++){
		ans += min(dp[i], dp2[i]);
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int n,m,a[110],b[110],res;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&a[i]);
		res+=a[i]&1;
	}
	if(m==1)
	{
		printf("%d\n",a[1]);
		if(a[1]>1)
		{
			printf("2\n");
			printf("%d %d",a[1]-1,1);
		}
		else printf("1\n1");
		return 0;
	}
	if(res>=3)
	{
		printf("Impossible");
		return 0;
	}
	for(int i=1;i<=m;i++)
		if(a[i]&1)
			swap(a[1],a[i]);
	for(int i=m;i>=1;i--)
		if(a[i]&1)
			swap(a[i],a[m]);
	for(int i=1;i<=m;i++)
	{
		printf("%d ",a[i]);
		if(a[i]==1&&i==1)continue;
		b[++b[0]]=a[i];
		if(i==1)b[1]--;
	}
	++b[b[0]];
	printf("\n%d\n",b[0]);
	for(int i=1;i<=b[0];i++)
		printf("%d ",b[i]);
}

Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = min(a) + min(b)

for i in range(M):
    tmp = a[xyc[i][0] - 1] + b[xyc[i][1] - 1] - xyc[i][2]
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 38560
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 3005;
//
//
int r, c;
ll g[MAX][MAX];
ll dp[MAX][MAX][4]; // 0 1 2 3

ll check(int x, int y, int type){
    if(x > r || y > c || x <= 0 || y <= 0 || type < 0)
        return LONG_LONG_MIN;

    ll &ans = dp[x][y][type];
    if(ans != -1)
        return ans;
    if(x == 1 && y == 1){
        if(type  != 0)
            return g[1][1];
        // else if(type == 0)
        return 0;
    }

    ans = max({max({check(x-1, y, 3), check(x-1, y, 2), check(x-1, y, 1), check(x-1, y, 0)}) + ((type > 0)? g[x][y]:0), check(x, y-1, type), check(x, y-1, type-1)+g[x][y]});
    return ans;
}
void solve(){
    cin>>r>>c;
    int k;
    cin>>k;
    memset(g, 0, sizeof(g));
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < k; i++){
        int x, y, val;
        cin>>x>>y>>val;
        g[x][y] = val;
    }

    cout<<max({check(r, c, 0) ,check(r, c, 1), check(r, c, 2), check(r, c, 3)})<<"\n";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

typedef long long ll;

const int P = 1e9 + 7;
const int MAXN = 1e6 + 10;

int n, prod[MAXN], inv[MAXN];

ll qpower(int a, int x) {
    ll ret = 1;
    for (; x; x >>= 1, a = 1ll * a * a % P) x & 1 ? ret = 1ll * ret * a % P : 0;
    return ret;
}

int main() {
    IO::read(n);
    printf("%lld\n", ((qpower(10, n) - 2 * qpower(9, n) % P + qpower(8, n)) % P + P) % P);
    return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
struct unionfind{
  int par[100010]; // 親ノード  必要に応じて要素数を変えよう
  int rank[100010]; // ランク　必要に応じて要素数を変えよう
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<n;i++){
      par[i]=i;
      rank[i]=0;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      par[x]=y;
    }
    else{
      par[y]=x;
      if(rank[x]==rank[y]){
        rank[x]++;
      }
    }
  }
};
int main(){
  int n,m,a[100010],x,y,ans=0,i;
  scanf("%d %d\n",&n,&m);
  unionfind tree(n);
  for(i=1;i<=n;i++){
    scanf("%d ",&a[i]);
  }
  for(i=0;i<m;i++){
    scanf("%d %d\n",&x,&y);
    tree.unite(x,y);
  }
  for(i=1;i<=n;i++){
    if(a[i]==i){
      ans++;
    }
    else if(tree.same(i,a[i])==1){
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

struct Edge
{
    long long to;
    long long cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<long, int>;
const long long INF = 1LL <<60;

void dijkstra(const Graph &G, int s, vector<long long> &dis)
{
    int N = G.size();
    dis.resize(N, INF);
    priority_queue<P, vector<P>, greater<P>> pq; //「仮の最短距離，頂点」が小さい順に並ぶ
    dis[s] = 0;
    pq.emplace(dis[s], s); // priority_queueの要素型のコンストラクタ引数をとり直接構築でpriority_queueに要素を追加する
    while (!pq.empty())
    {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) continue;
        for (auto &e : G[v])
        {
            if (dis[e.to] > dis[v] + e.cost)
            {
                dis[e.to] = dis[v] + e.cost;
                pq.emplace(dis[e.to], e.to);
            }
        }
    }

}

int main()
{
    int v, e, r;
    cin >> v >> e >> r;
    // 入力よりグラフの作成
    Graph g(v);
    for (int i=0; i<e; i++)
    {
        int s, t, d;
        cin >> s >> t >> d;
        Edge edge;
        edge.cost = d;
        edge.to = t;
        g[s].push_back(edge);
    }
    vector<long long> dis(v, INF);
    dijkstra(g, r, dis);
    for (int i=0; i<v; i++)
    {
        if (dis[i]<INF) cout << dis[i] << endl;
        else cout << "INF" << endl;
    }
}


Measured memory_bytes: 19400
from operator import itemgetter


def main():
    n = int(input())

    rest = []
    for i in range(1, n + 1):
        s, p = input().split()
        p = int(p)
        rest.append((i, s, p))

    rest = sorted(rest, key=itemgetter(2), reverse=True)
    rest = sorted(rest, key=itemgetter(1))
    for i, _, _ in rest:
        print(i)


main()

Measured memory_bytes: 3060
N,Q = map(int,input().split())
S = list(input())
ac_counter = [0]
counter = 0
for i in range(1,N):
    if S[i-1] == 'A' and S[i] == 'C':
        counter += 1
    ac_counter.append(counter)
for j in range(Q):
    l,r = map(int,input().split())
    print(ac_counter[r-1]-ac_counter[l-1])


Measured memory_bytes: 6872
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(int argc, const char * argv[]) {
    int N, R; cin >> N >> R;
    cout << (N >= 10 ? R : R + 100 * (10 - N)) << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn gcd(a: usize, b: usize) -> usize {
    if a == 0 {
        b
    } else {
        gcd(b % a, a)
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!([usize]);

    let mut l = a.iter().scan(0, |g, &e| {
        *g = gcd(*g, e);
        Some(*g)
    }).collect::<Vec<_>>();
    l.insert(0,0);

    let mut r = a.iter().rev().scan(0, |g,&e| {
        *g = gcd(*g,e);
        Some(*g)
    }).collect::<Vec<_>>();
    r.insert(0,0);
    let r = r.into_iter().rev().collect::<Vec<_>>();

    let mut mx = 0;
    for i in 0..n {
        mx = max!(mx, gcd(l[i],r[i+1]));
    }
    println!("{}", mx);
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    return gcd(b, a % b);
}

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

void solve()
{
    ll N, X; cin >> N >> X;
    vll x(N+1); REP(i, N) cin >> x[i];
    x[N] = X;
    sort(ALL(x));
    ll m = INF;
    REP(i, N)
    {
        ll l = x[i+1] - x[i];
        m = min(m, l);
    }
    ll ans = m;
    REP(i, N)
    {
        ll l = x[i+1] - x[i];
        ans = min(ans, gcd(m, l));
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int main() {
    vector <char> S(3);

    cin>>S.at(0)>>S.at(1)>>S.at(2);

    if(S.at(0)==S.at(1)&&S.at(0)==S.at(2)){
        cout << "No" <<endl;
    }else{

        cout << "Yes" << endl;
    }
    
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	auto b = vector<bool>(n + 1);
	int ans = n;
	for(int i = 0; i < k; ++i){
		int d;
		cin >> d;
		for(int j = 0; j < d; ++j){
			int a;
			cin >> a;
			if(!b[a]){
				b[a] = true;
				--ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int a=0,b=0,c=0;
    char ch;
    while(cin>>ch){
        if(ch=='a')a++;
        if(ch=='b')b++;
        if(ch=='c')c++;
    }
    cout<<((fabs(a-b)<=1&&fabs(b-c)<=1&&fabs(c-a)<=1)?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
def partition(A,p,r):
    x = A[r]
    i = p 
    for j in range(p,r):
        if A[j] <= x:
            A[i],A[j] = A[j],A[i]
            i += 1

    A[i],A[r] = A[r],A[i]

    return i

n = int(input())
a = [int(s) for s in input().split()]
t = partition(a,0,n-1)
print(*(str(x) if i != t else "[%d]"%x for i,x in enumerate(a)))


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

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

    int c[50] = {0,};

    for (int i=0; i<M; i++) {
        int a, b;
        cin >> a >> b;
        c[a-1]++;
        c[b-1]++;
    }

    for (int i=0; i<N; i++) {
        cout << c[i] << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

const int md=998244353;
int n;
char s[200001];
char ss[200001];
int z[400001];
void cc(int w){
	for(int i=0;i<n;i++)
		if(i<w)ss[i]=s[i];
		else ss[i]=ss[i-w]^1;
	int ok=1;
	for(int i=0;i<n;i++)
		if(s[i]!=ss[i]){
			if(s[i]<ss[i])ok=0;
			break;
		}
	int ans=0;
	for(int i=0;i<w;i++){
		ans=(ans*2+(s[i]=='1'))%md;
	}
	//printf("%d %d\n",w,ans+ok);
	z[w]=ans+ok;
}
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	int w=1;
	while(n%(2*w)==0)w*=2;
	for(int i=1;i*i<=n;i++)
		if(n%i==0){
			if(i&1)cc(i*w);
			if(i!=n/i&&n/i&1)cc(n/i*w);
		}
	for(int i=1;i<=n/w;i++)
		if(z[i*w])
			for(int j=i+i;j*w<=n;j+=i)
				if(j&1&&n%j==0)
					z[j*w]=(z[j*w]-z[i*w]+md)%md;
	int ans=0;
	for(int i=1;i<=n;i++){
	//	printf("%d %d\n",i,z[i]);
		if(z[i])ans=(ans+2ll*z[i]*i)%md;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 2164
#include <iostream>
#include <vector>
#include <set>
using namespace std;

template <class T>
T next()
{
    T x;
    cin >> x;
    return (x);
}

int main()
{
    auto s = next<int>();
    vector<int> dp;
    dp.push_back(s);

    set<int> st;
    st.emplace(s);

    for (int i = 0;; i++)
    {
        int n = dp[i];
        if (n % 2 == 0)
        {
            dp.push_back(n / 2);
        }
        else
        {
            dp.push_back(3 * n + 1);
        }
        int m = i + 1;
        if (st.count(dp[m]) > 0)
        {
            cout << m + 1 << endl;
            return 0;
        }
        st.emplace(dp[m]);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stdio.h>
#include <string>
#include <typeinfo>
#define REP(i, n) for (int i = 1; i <= n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
using namespace std;

int main()
{
  int i, x, N;
  cin >> N;
  //約数の数をカウント
  int tmp = 0;
  //約数の数
  int answerCount;

  REP(i, N)
  {
    if (i % 2 != 0)
    {
      REP(x, N)
      {
        if (i % x == 0)
        {
          tmp++;
        }
      }
    }
    if (tmp == 8)
      answerCount++;
    tmp = 0;
  }
  cout << answerCount << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

int main() {
  ll A, B, N;
  cin >> A >> B >> N;

  ll x = min(B - 1, N);
  cout << (A * x) / B - A * (x / B) << endl;

  return 0;
}

Measured memory_bytes: 3520
function main()
  
  (A,B,K) = map(x -> parse(Int,x), split(readline()))
  
  A -= K
  if A < 0
    B -= abs(A)
    A = 0
  end
  
  if B < 0
    B = 0
  end
  
  println(string(A)*" "*string(B))
  
end

main()

Measured memory_bytes: 111588
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end(), l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower
  return R-L;
}
int n,a[200000],sm1[200000],sm2[200000],x1[200000],x2[200000];

signed main(){
 
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i],sm1[i]=a[i],sm2[i]=a[i];
  }

  for(int i=1;i<n;i++)sm1[i]+=sm1[i-1];
  for(int i=n-2;i>=0;i--)sm2[i]+=sm2[i+1];
  
  for(int i=n-1;i>=0;i--){
    int y=(i+1<n?x1[i+1]:0);
    if(a[i]==0)x1[i]=min(y+2,sm2[i]);
    else x1[i]=min(y+a[i]%2,sm2[i]);
  }

  for(int i=0;i<n;i++){
    int y=(i-1>=0?x2[i-1]:0);
    if(a[i]==0)x2[i]=min(y+2,sm1[i]);
    else x2[i]=min(y+a[i]%2,sm1[i]);
  }
  

  
  int ans=1e9,c=0,f=1;

  for(int i=0;i<n;i++){
    if(f&&a[i]==0)continue;
    f=0;
    ans=min(ans,x1[i]+c);
    if(a[i]%2==0)c=min(c+1,x2[i]);
  }

  ans=min(ans,c);

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


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;

int main()
{
    int x; cin >> x;
    int ans = 0;
    int num = x%100;
    int val = x/100;
    if(val*5>=num) ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

n,m = map(int, input().split())

lights = []
for i in range(m):
    a = list(map(int, input().split()))
    lights.append(a[1:])
ps = list(map(int, input().split()))

def check(status, switches, p):
    cnt = 0
    for s in status:
        if s in switches:
            cnt += 1
    return cnt % 2 == p

total = 0
for status in range(2**n):
    on = []
    for i in range(n):
        if status & 2**i:
            on.append(i+1)
    all_light = True
    for i in range(m):
        if not check(on, lights[i], ps[i]):
            all_light = False
            break
    if all_light:
        total += 1
print(total)

    



Measured memory_bytes: 44892
using System;
class Program{
	private int min(int x, int y){
		return x > y ? y : x;
	}
	public static void Main(){
		string[] str = Console.ReadLine().Split(' ');
		int N = int.Parse(str[0]);
		int Y = int.Parse(str[1]);
		
		Program Prog = new Program();
		
		int Z = Y / 1000 - N;
		
		int a = -1;
		int b = -1;
		int c = -1;
		int p = Prog.min(Z / 4, N);
		
		for (int q = 0 ;q <= p ;q++ ){
			for (int r = 0 ;r <= p-q ;r++ ){
				if (4 * q + 9 * r == Z){
					a = r;
					b = q;
					c = (Y - 5000 * b - 10000 * a) / 1000;
				}
			}
		}
		
		Console.WriteLine("{0} {1} {2}", a, b, c);
	}
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define int long long
#define fi first
#define se second
using namespace std;
const long long INF=1e18;
const long long MD=1e9+7;
int n,a[1003],sum;
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for (int i=0; i<n; i++){
        cin>>a[i];
        sum+=a[i];
    }
    double av=(double)sum/n;
    double razn=1e9;
    int ans=0;
    for (int i=0; i<n; i++){
        double newrazn=abs(a[i]-av);
        if (newrazn<razn){
            ans=i;
            razn=newrazn;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
def main():
    N = int(input())
    works = []
    for i in range(N):
        A, B = map(int, input().split())
        works.append((A, B))
    
    works.sort(key=lambda x: x[1])

    time = 0
    for i in range(N):
        a, b = works[i]
        time += a
        if time > b:
            print('No')
            return
    print('Yes')

if __name__ == "__main__":
    main()


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

int main(){
    string s; cin>>s;
    int i=0,cnt=0;
    string bef=" ";
    
    while(i < s.size()){
        string cmp=" ";
        cmp += s[i];
        if(bef == cmp){
            i++;
            if(i == s.size()){
                break;
            }
            cmp += s[i];
        }
        bef = cmp;
        i++;
        cnt++;
    }

    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 640
s = input()
n = len(s)
ans = 0

for bit in range(1 << (n - 1)):
    temp = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            temp += '+'
        temp += s[i + 1]

    ans += sum(map(int, temp.split('+')))

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int X = sc.nextInt();
   
   int[] x=new int[N];
   for(int i=0;i<N;i++) x[i] = Math.abs(X-sc.nextInt());

   int tmpgcd =x[0];
   for(int i=1;i<N;i++) tmpgcd= gcd(tmpgcd,x[i]);
   
   System.out.println(tmpgcd);
 }
  static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
}

Measured memory_bytes: 49420
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a,b,sum=0;
		a = sc.nextInt();
		b = sc.nextInt();
		
		
		
		System.out.println((a-1)*(b-1));
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
 
#define       pb(a)             push_back((a))
#define       mp(a,b)           make_pair((a),(b))
#define       REP(a,b)          for(ll i=(a);i<(b);i++)
#define       REP2(a,b)         for(ll j=(a);j<(b);j++)
#define       REPE(a,b,c,d)     REP(a,b)for(ll j=(c);j<(d);j++)
#define       REPV(a,b,c)       for(ll (a)=b;(a)<(c);(a)++)
#define       IREP(a,b)         for(ll i=(a);i>=(b);i--)
#define       IREP2(a,b)        for(ll j=(a);j>=(b);j--)
#define       IREPV(a,b,c)      for(ll (a)=b;(a)>=(c);(a)--)
#define       all(v)            (v).begin(),(v).end()
#define       Trvs(c)           for (auto it = (c).begin(); it != (c).end(); it++)
#define       INF               INT_MAX
#define       sz(x)             x.size()
#define       flash             ios_base::sync_with_stdio(false);cin.tie(NULL);
#define       F                 first
#define       S                 second
#define       MOD               1000000007
 
using         ll     = long long;
using         vi     = vector<int>;
using         vvi    = vector<vi>;
using         vll    = vector<ll>;
using         vvll   = vector<vll>;
using         vb     = vector<bool>;
using         vd     = vector<double>;
using         vs     = vector<string>;
using         pii    = pair<int, int>;
using         pll    = pair<ll, ll>;
using         pdd    = pair<double, double>;
using         vpii   = vector<pii>;
using         vvpii  = vector<vpii>;
using         vpll   = vector<pll>;
using         vvpll  = vector<vpll>;
using         vpdd   = vector<pdd>;
using         vvpdd  = vector<vpdd>;
 
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

void solve(){
    ll x;
    vll a(4,0);
    cin>>x;//cout<<x<<endl;
    a[x]=1;
    cin>>x;//cout<<x<<endl;
    a[x]=1;
    REP(1,4){
        if(a[i]== 0){cout<<i<<endl;return;}
    }
}
 
 
int main(){
 
	flash
	/*
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("output.txt","w",stderr);
	#endif
 	*/
   
	//ll t;cin>>t;while(t--)
	solve();
 
 
	return 0;
}

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

using namespace std;

const int MOD = 10000;

const int MAX_N = 100;
int plan[MAX_N + 1];
int memo[MAX_N + 1][4][4];
int N, K;

int search(int n, int b1, int b2)
{
    if(n == N + 1) return 1;
    if(memo[n][b1][b2] != -1) return memo[n][b1][b2];
    if(plan[n] != 0)
    {
        if(b1 == b2 && b1 == plan[n])
        {
            return 0;
        }
        else
            return search(n + 1, plan[n], b1) % MOD;
    }
    int t = 0;

    for(int i = 1; i <= 3; i++)
    {
        if(b1 == b2 && b1 == i) continue;
        t += search(n + 1, i, b1) % MOD;
    }

    return memo[n][b1][b2] = t % MOD;
    

}

int main()
{
    cin >> N >> K;
    for(int i = 0;i < K; i++)
    {
        int d, k;
        cin >> d >> k;
        plan[d] = k;
    }

    for(int i = 0; i <= N; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            for(int k = 0; k < 4; k++)
            {
                memo[i][j][k] = -1;
            }
        }
    }

    cout << search(1, 0, 0) << endl;
    return 0;
}


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

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

using namespace std;

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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll result = (n / (a + b)) * a + min((n % (a + b)), a);

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from math import sqrt

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

sum = 0

for i in range(N):
    for j in range(N):
            sum += ((A[i][0] - A[j][0]) ** 2 + (A[i][1] - A[j][1]) ** 2) ** 0.5

print(sum/N)

Measured memory_bytes: 3060