akhauriyash/Code-Regression huggingface dataset:
if(__name__ =="__main__"):
    S = input()
    for i in range(1,len(S)):
        tmp = S[:-i]
        tmplen = len(tmp)
        #print(tmplen)
        if(tmplen % 2 == 0):
            #print(tmp[:int(tmplen/2)])
            if(tmp[:int(tmplen/2)] == tmp[int(tmplen/2):]):
                print(tmplen)
                break

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = (int)1e5 + 2;
const int LG = 20;
const ll mod = (int)1e9 + 7;
const int INF = (int)1e9 + 7;
const ll linf = 1e16;
const ld pi = acos(-1);
const int base = 10;
const ld EPS = 1e-9;

int n, a[N], dp[N];
int main ()
{
    scanf ("%d", &n);
    for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
    dp[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; ++i)
    {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    printf ("%d\n", dp[n]);
    return 0;
}


Measured memory_bytes: 1152
// dp[i][j] := i個の異なる数を用いてjを作る通り数
// 0~100までの数それぞれを使う場合について1回だけ考察する(index-i)
// index-k は使用する数の個数

#include<iostream>
using namespace std;

long long dp[10][1000] = {};

int main(){
    dp[0][0] = 1;

    for(int i = 0; i <= 100; i++){
        for(int k = 9; k >= 1; k--){
            for(int j = 0; j+i < 1000; j++){
                dp[k][j+i] += dp[k-1][j];
            }
        }
    }
    
    int n, s;
    while(cin >> n >> s){
        if(n+s == 0)    break;
        cout << dp[n][s] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
int A[500010],H;

void maxHeapify(int i){
  int l=i*2;
  int r=i*2+1;
  int largest;
  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  
  if(r<=H&&A[r]>A[largest]) largest=r;
  
  if(largest!=i) {
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

void buildHeap(){
  for(int i=H/2;i>=1;i--) maxHeapify(i);
}

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)cin>>A[i];
  H=n;
  buildHeap();
  for(int i=1;i<=n;i++)cout <<" "<<A[i];cout <<endl;
  return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
  	ll n,m,i,j,k,l;
  	cin>>n>>m;
  	map<ll,ll> mp; ll flg=0;
  	for(i=1;i<=m;i++){
  		cin>>k>>l;
  		if((mp.find(k)!=mp.end()&&mp[k]!=l)||(k==1&&l==0&&n!=1)){
  			flg=1;
  		}
  		mp[k]=l;
  	}
  	if(flg){
  		cout<<"-1";return 0;
  	}

  	vector<ll> vc;
  	for(i=1;i<=n;i++){
  		if(mp.find(i)==mp.end()){
  			if(i==1){
  				if(n==1) vc.ps(0);
  				else vc.ps(1);
  			}
  			else vc.ps(0);
  		}
  		else{
  			vc.ps(mp[i]);
  		}
  	}

  	for(auto it:vc){
  		cout<<it;
  	}
	return 0;
}

Measured memory_bytes: 256
<?php

while (true) {
    list($H, $W) = array_map("intval", explode(' ', trim(fgets(STDIN))));

    if ($H == 0 && $W == 0) break;

    $line1 = str_repeat('#', $W) . "\n";
    $line2 = '#' . str_repeat('.', $W - 2) . '#' . "\n";
    $rectangle = $line1 . str_repeat($line2, $H - 2) . $line1;

    echo $rectangle . "\n";
}


Measured memory_bytes: 9288
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
# import math
import sys
import collections

from math import gcd
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

K = int(input())
""" answer 1
ans = 0
tmp = {}
for i in range(201):
    tmp[i] = 0

for i in range(1, K +1):
    for j in range(1, K +1):
        tmp[math.gcd(i, j)] += 1

for k in range(1, K +1):
    for key in tmp.keys():
        ans += math.gcd(key, k) * tmp[key]
print(ans)

"""


"""answer 2　ぎりぎり
ans = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K +1):
            ans += gcd(gcd(i,j), k)
print(ans)

"""

ans = 0

# (1,2,3)
for i in range(1, K +1):
    for j in range(i+ 1, K + 1):
        for k in range(j + 1, K + 1):
            ans += gcd(gcd(i, j), k) * 6

# (1,2,2)
for i in range(1, K + 1):
    for j in range(i+ 1, K+1):
        ans += gcd(i, j) * 3 * 2

# (1,1,1)
for i in range(1, K +1):
    ans += i
print(ans)

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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s; int k;
    cin >> s;
    cin >> k;

    int n = s.length();

    ll ans = 0;
    int last_change = -1;
    // 1回目について
    for(int i=1;i<n;++i) {
        if(s[i-1] == s[i] && last_change != i-1) {
            ++ans;
            last_change = i;
        }
    }
    // 2回目以降について
    if(k > 1) {
        if(s[n-1] != s[0] || last_change == n-1) {
            ans *= k;
        } else {
            last_change = 0;
            ll tmp = 1;
            for(int i=1;i<n;++i) {
                if(s[i-1] == s[i] && last_change != i-1) {
                    ++tmp;
                    last_change = i;
                }
            }
            if(last_change == n-1) {
                ans = (ans+tmp) * (k/2) + (k%2?ans:0);
            } else {
                ans += tmp * (k-1);
            }
        }
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")

using namespace std;

#define int long long

vector<vector<pair<int, int>>> g;
vector<int> used;
const int INF = 1e18;

void dfs(int v, int t) {
    used[v] = t;
    for (auto it: g[v]) {
        if (used[it.first] == INF) dfs(it.first, t + it.second);
        else if (used[it.first] != t + it.second) {
            cout << "No";
            exit(0);
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m; cin >> n >> m;
    g.resize(n);
    used.assign(n, INF);
    for (int i = 0; i < m; ++i) {
        int l, r, d; cin >> l >> r >> d;
        l--; r--;
        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }
    /*for (int i = 0; i < n; ++i) {
        for (int j = 0; j < g[i].size(); ++j) cout << g[i][j].first << " " << g[i][j].second << "   ";
        cout << endl;
    }*/
    for (int i = 0; i < n; ++i) {
        if (used[i] == INF) {
            used[i] = 0;
            dfs(i, 0);
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;

 ll mod=1e9 +7;

ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll get_val(vector<ll>&ft,ll index)
{
  ll res=0;
  for(;index>=0;index=(index & (index+1))-1)
    res+=ft[index];
  return res;
}

void update(vector<ll>&ft,ll index,ll val)
{
  for(;index<(ll)ft.size();index|=index+1)
    ft[index]+=val;
}

ll mex(vector<ll>&a, ll n)
{
  ll res=0;
  // set<ll>st;
  vector<ll>b(n+1,0);
  for(auto x:a) b[x]++;
    while(res<n && b[res]>0) res++;
  return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //   #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    
    // Sieve();
   ll tests=1;
 // cin>>tests;
  // ll t=1;
    while(tests--)
    {
      ll i,j,n;
      cin>>n;
      vector<ll>a(n);
      rep(i,0,n-1) cin>>a[i];
      ll ans=0;
      ll cnt=2;
      sort(all(a));
      reverse(all(a));
      ans=a[0];
      for(i=1;i<n-1;i++)
      {
        if(cnt==n) break;
        ans+=a[i];
        cnt++;
        if(cnt==n) break;
        ans+=a[i];
        cnt++;
        // if(cnt==n) break;
      }
        cout<<ans;
    }

    return 0;
   }

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

void fnInput(string& rsSLine, string& rsTLine)
{
  cin >> rsSLine >> rsTLine;

  sort(begin(rsSLine), end(rsSLine));
  sort(begin(rsTLine), end(rsTLine), greater<char>());
}

void fnAnagramCheck(string sSLine, string sTLine)
{
  if (sSLine < sTLine) cout << "Yes" << endl;
  else                 cout << "No"  << endl;
}

int main()
{
  string sSLine;
  string sTLine;

  fnInput(sSLine, sTLine);
  fnAnagramCheck(sSLine, sTLine);

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
#define DEBUG 0
typedef long long LL;

typedef std::pair<LL, LL> Data;
int main() {
  int N; std::cin >> N;
  std::vector<Data> data(N);
  for (int i = 0; i < N; ++i) {
    auto& d = data[i];
    std::cin >> d.first >> d.second;
  }

  std::sort(data.begin(),  data.end(),
            [](const Data& l,  const Data& r) {
              return (l.first + l.second) > (r.first + r.second);
            });

#if DEBUG
  for (const auto& d : data) {
    std::cout << d.first << " " << d.second << std::endl;
  }
#endif

  LL score = 0;
  for (int i = 0; i < data.size(); i += 2) {
    score += data[i].first;
  }
  for (int i = 1; i < data.size(); i += 2) {
    score -= data[i].second;
  }
  std::cout << score << std::endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    char x;
    char y;
    scanf("%c", &x);
    scanf(" %c", &y);

    if (x < y){
        printf("<\n");
    }else if (x == y){
        printf("=\n");
    }else if (x > y){
        printf(">\n");
    }

    return 0;
}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    long ac = N - M;
    writeln((2 ^^ M) * (ac * 100 + 1900 * M));
}


Measured memory_bytes: 3668
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;


/* define */
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define REP(i, n) for ( int i = 0; i < (n) ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1000000007;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */


int main(){
	string s; cin >> s;
	REP(i, 26) if (s.find('a' + i) == string::npos) {
		cout << (char)('a' + i) << endl;
		return 0;
	}
	cout << "None" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int table[8][8] = {0};
    rep(i, 8) rep(j, 8) {
        if (i % 2 == 0 && j % 2 != 0) {
            table[i][j] = 1;
        }
    }
    //rep(i, 8) {rep(j, 8) cout << table[i][j] << " "; cout << endl;}
    //幅探で実験すればよかった
    //一手一手実験するのは愚策
    //途中間違えたら終わり
    int n; cin >> n;
    rep(i, n) {
        int ly, lx, ry, rx; cin >> ly >> lx >> ry >> rx;
        ly--; lx--; ry--; rx--;
        int c = 0;
        rrep(i, ly, ry + 1) rrep(j, lx, rx + 1) {
            if (table[i][j] == 0) c++;
        }
        cout << c << endl;
    }
    
    
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int row = 0;
    int maks = -1;
    int a[n+1], b[n+1];
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i]>>b[i];
    	if(a[i]==b[i]){
    		row ++;
    		maks = max(maks,row);
		}
		else{
			row = 0;
		}
	}
	if (maks >= 3){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

using namespace std;

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

double r0, w0, c, r;

int main() {
	while (cin >> r0 >> w0 >> c >> r&&r0 + w0 + c + r) {
		if (r0 / w0 > c) {
			cout << 0 << endl;
		}
		else {
			int cnt = 0;
			while (r0 / w0 < c) {
				r0 += r;
				cnt++;
			}
			cout << cnt << endl;
		}
	}
}

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

using namespace std;
const int N=2e5+5,INF=2e9,mod=998244353;
int nxt[N];
int dp[N];
int n;
pair<int,int> a[N];
int seg[4*N];
int solve(int idx)
{
    if(idx==n) return 1;
    int &ret=dp[idx];
    if(~ret) return ret;
    ret=solve(idx+1);
    ret+=solve(nxt[idx]);
    ret%=mod;
    return ret;
}
void update(int idx,int val,int id=1,int l=0,int r=n-1)
{
    if(l==r)
    {
        seg[id]=val;
        return;
    }
    int mid=(l+r)/2;
    if(idx<=mid) update(idx,val,id*2,l,mid);
    else update(idx,val,id*2+1,mid+1,r);
    seg[id]=max(seg[id*2],seg[id*2+1]);
}
int query(int sq,int eq,int id=1,int l=0,int r=n-1)
{
    if(r<sq||l>eq) return 0;
    if(l>=sq&&r<=eq) return seg[id];
    int mid=(l+r)/2;
    return max(query(sq,eq,id*2,l,mid),query(sq,eq,id*2+1,mid+1,r));
}
int 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].first>>a[i].second;
        a[i].second+=a[i].first;
    }
    sort(a,a+n);
    for(int i=n-1;i>=0;i--)
    {
        nxt[i]=i+1;
        int idx=lower_bound(a,a+n,make_pair(a[i].second,-INF))-a-1;
        if(idx>i) nxt[i]=query(i,idx);
        //cout<<i<<" "<<idx<<" "<<nxt[i]<<endl;
        update(i,nxt[i]);
    }
    memset(dp,-1,sizeof dp);
    cout<<solve(0)<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);

    int x[n];

    for(int i = 0; i < n; ++i) // leitura do vetor
      scanf("%d", &x[i]);

    int min = x[0], max = x[0];  /*int min = 101, max = 0;
    declarar os vetores minimos e maximos padrões é um bom exercicio
    mental. */

    for(int i = 1; i < n; ++i) { // encontrando os valores minimos e maximos
      if (x[i] > max)
        max = x[i];
      if (x[i] < min)
        min = x[i];
    }

    int melhortotal;

    for(int p = min; p <= max; ++p) { //calculando o melhor gasto de estamina
      int total = 0;
      for(int i = 0; i < n; ++i) // calculando gasto de estamina
        total += (x[i] - p)*(x[i] - p);
      if (p == min || total < melhortotal) // p == min, garante que o primeiro valor será um que se encontra na lista e não um valor aleatorio.
        melhortotal = total;
    }
    printf("%d\n", melhortotal );

    return 0;
  }
/*   5 / 2 = 2
     5.0 / 2 = 2.5

     int a;

     a = 2.5 -> a = 2   */


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,k;
    cin >> n >> k;
    int ans = 0;
    rep(i,n){
        int a = 0;
        cin >> a;
        if(a >= k)ans++;
    }
    cout << ans << endl;
}


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

int main() {
    string a, b;
    while(1){
        cin >> a >> b;
        if(a=="0")break;
        int hit=0, blow=0;
        REP(i,4){
            if(a[i]==b[i])hit++;
        }
        REP(i,4)REP(j,4){
            if(i==j)continue;
            if(a[i]==b[j])blow++;
        }
        cout << hit << " " << blow << endl;
    }
    return 0;
}



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

int main(){
    int n,m;
    bool endflag = true;
    
    while (endflag){
        cin >> n >> m;
        if((n==0)&&(m==0)){
            endflag = false;
            break;
        }
        
        if( n > m){
            cout << m <<" " << n << endl;
        }
        else {
            cout << n <<" " << m << endl;
        }
    
    }
    return 0;
}


Measured memory_bytes: 3076
import numpy as np

N = int(input())

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

A1_sum = [np.sum(A1[:N-i]) for i in range(N)]
A2_sum = [np.sum(A2[N-1-i:]) for i in range(N)]

A_sum = [A1_sum[i]+A2_sum[i] for i in range(N)]
print(np.max(A_sum))

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Rated for Me
            int r = int.Parse(Console.ReadLine());

            if (r < 1200)
            {
                Console.WriteLine("ABC");
            }
            else if (r < 2800)
            {
                Console.WriteLine("ARC");
            }
            else
            {
                Console.WriteLine("AGC");
            }
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}
int MAX = 100000+10;
long long fac[100010], finv[100010], inv[100010];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 100010; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main(){
	init();
	ll n;cin>>n;
	vector<ll>a(n+1);
	vector<ll>data(n+1);
	set<ll>set;
	ll x=-1;
	ll y=-1;
	for(int i=0;i<=n;i++){
		cin>>a[i];
		if(set.find(a[i])!=set.end()){
			x=n-i;
			y=data[a[i]];
		}
		set.insert(a[i]);
		data[a[i]]=i;
	}
	n++;
	//cout<<"y"<<y<<endl;
	//cout<<"x"<<x<<endl;
	x+=y;
	COMinit();
	for(int k=1;k<=n;k++){
		cout<<(COM(n,k)+MOD-COM(x,k-1))%MOD<<endl;
	}
}



Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=3,cnt1=0,cnt2=0,mod=1e9+7;
  string s,t;
  cin >> n >> s >> t;
  s+='.';
  for(int i=0;i<n;i++){
  	if(s[i]!=t[i]){
  	  if(s[i]==s[i+1]){
  	  	continue;
  	  }
  	  if(cnt1==0){
  	  	cnt1=2;
  	  }else{
	  	cnt1*=3;
  	  }
  	  if(cnt2>0){
	  	ans*=cnt2;
  	  }
  	  ans%=mod;
  	  cnt2=0;
  	}else{
  	  if(cnt2==0){
  	  	cnt2++;
  	  }else{
	  	cnt2*=2;
  	  }
  	  if(cnt1>0){
  	  	ans*=cnt1;
  	  }
  	  ans%=mod;
  	  cnt1=0;
  	}
  }
  if(cnt1>0){
  	ans*=cnt1;
  }else{
  	ans*=cnt2;
  }
  ans%=mod;
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector< string > t(N);
  vector< string > u(N);
  for(int i=0;i<N;i++){
    cin>>t[i];
    u[i]=t[i];
  }
  sort(t.begin(),t.end());
  for(int i=0;i<N;i++){
    int a=lower_bound(t.begin(),t.end(),u[i])-t.begin();
    int b=upper_bound(t.begin(),t.end(),u[i])-t.begin();
    cout<< b-a-1 + 3*a <<endl;
  }
  return 0;
}

Measured memory_bytes: 8540
import java.util.ArrayList;
import java.util.Scanner;
import java.lang.Math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long W = sc.nextLong();
		final int vMax = 1000 * 100;
		final long wMax = 1000000010L;
		long[][] dp = new long[N + 1][vMax + 1];
		long[] wList = new long[N];
		int[] vList = new int[N];
		for (int i = 0; i < N; i++) {
			wList[i] = sc.nextLong();
			vList[i] = sc.nextInt();
		}
		for (int i = 0; i < vMax + 1; i++) {
			dp[0][i] = wMax;
		}

		int max = 0;

		for (int i = 1; i < N + 1; i++) {
			for (int j = 0; j < vMax + 1; j++) {
				if (j <= vList[i - 1]) {
					dp[i][j] = Math.min(dp[i - 1][j], wList[i - 1]);
				}else{
					dp[i][j] = Math.min(dp[i - 1][j], dp[i - 1][j - vList[i - 1]] + wList[i - 1]);
				}
				if(dp[i][j] > wMax){
					dp[i][j] = wMax;
				}
				if(dp[i][j] <= W && max < j){
					max = j;
				}
			}
		}
		System.out.println(max);
	}

}

Measured memory_bytes: 129108
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair <int,int>
#define vpii vector< pair<int,int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
map <vector <int>, int> mp;
int main()
{
	boost;
	int n, i;
	cin >> n;
	vector <int> p(n), q(n);
	vector <int> v(n);
	fo(i, 0, n)
	cin >> p[i];
	fo(i, 0, n)
	cin >> q[i];
	fo(i, 0, n)
	v[i] = i + 1;
	int cnt = 1;
	do
	{
		mp[v] = cnt;
		cnt++;
	}while(next_permutation(all(v)));
	
	cout << abs(mp[p] - mp[q]);
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==7&&b==5&&c==5){
    cout<<"YES"<<endl;
  }
  else  if(a==5&&b==7&&c==5){
    cout<<"YES"<<endl;
  }
   else if(a==5&&b==5&&c==7){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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 int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(a,b,c);
  Yes(MID(a,c,b) || MID(b,c,a));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long long> A(N+1),B(N);
  for (int i=0;i<N+1;i++){
    cin >> A[i];
  }
  for (int i=0;i<N;i++){
    cin >> B[i];
  }
  long long sum=0;
  for (int i=0;i<N;i++){
    if (B[i]<=A[i]){
      sum+=B[i];
      A[i]-=B[i];
    }
    else if (B[i]<=A[i]+A[i+1]){
      sum+=B[i];
      A[i+1]-=B[i]-A[i];
      A[i]=0;
    }
    else {
      sum+=A[i]+A[i+1];
      A[i]=0;
      A[i+1]=0;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
//
// Created by Naman Bhalla on 2019-05-26.
//

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int dp[3003][3003];
int main(){
    memset(dp, 0, sizeof dp);
    string s;
    string t;

    cin >> s >> t;

    int n = s.size();
    int m = t.size();

    for(int i  = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            if(s[i - 1] == t[j - 1]){
                dp[i][j] = 1 + dp[i - 1][j - 1];
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
//            cout << dp[i][j] << " ";
        }
//        cout << endl;
    }

//    cout << dp[n][m] << endl;
    string answer{};

    int j = m;
    int i = n;

    while(i > 0 and j > 0){
        if(dp[i][j] == dp[i - 1][j]){
            --i;
        } else if(dp[i][j] == dp[i][j - 1]){
            --j;
        } else {
            --i;
            --j;
            answer.push_back(s[i]);
        }
    }

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

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 35456
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if (A * C > B) {
            System.out.println(B / A);
        } else {
            System.out.println(C);
        }
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
using namespace std;

typedef pair<int,int> pii;
const int N=1e5+5;
const int INF=123456789;
int n,k;
vector<int> nei[N];
int vert[N];
priority_queue<pii> pq;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) vert[i]=-INF;
	for(int i=0;i<n-1;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		nei[x].push_back(y);
		nei[y].push_back(x);
	}
	scanf("%d",&k);
	for(int i=0;i<k;i++){
		int x,val;
		scanf("%d%d",&x,&val);
		vert[x]=val;
		pq.push(pii(-val,x));
	}
	while(!pq.empty()){
		pii now=pq.top();
		pq.pop();
		int x=now.second;
		int val=-now.first;
		for(int i=0;i<nei[x].size();i++){
			int to=nei[x][i];
			if(vert[to]==-INF){
				vert[to]=val+1;
				pq.push(pii(-vert[to],to));
			}
		}
	}
	for(int i=1;i<=n;i++) for(int j=0;j<nei[i].size();j++) if(abs(vert[i]-vert[nei[i][j]])!=1){
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i=1;i<=n;i++) printf("%d\n",vert[i]);
	return 0;
}

Measured memory_bytes: 7924
import bisect
from sys import stdin
readline=stdin.readline
a,b,q=map(int,input().split())
s=sorted([int(readline()) for i in range(a)])
t=sorted([int(readline()) for i in range(b)])
for i in range(q):
    ans=999999999999
    x=int(readline())
    w=bisect.bisect_left(s,x)
    for j in range(2):
        if not 0<=w-j<len(s):
            continue
        z=bisect.bisect_left(t,s[w-j])
        for k in range(2):
            if not 0<=z-k<len(t):
                continue
            ans=min(ans,abs(x-s[w-j])+abs(s[w-j]-t[z-k]))
    w=bisect.bisect_left(t,x)
    for j in range(2):
        if not 0<=w-j<len(t):
            continue
        z=bisect.bisect_left(s,t[w-j])
        for k in range(2):
            if not 0<=z-k<len(s):
                continue
            ans=min(ans,abs(x-t[w-j])+abs(t[w-j]-s[z-k]))
    print(ans)

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

using namespace std;

const long long MOD = 1000000007;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}

vector<long long> arr;

int main(){

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

    //freopen("input.txt", "r", stdin);

    int n;
    cin >> n;

    for(int i = 0; i < n; ++i){
        long long j;
        cin >> j;
        arr.push_back(j);
    }

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

    // Case 1 - Bigger numbers are inserted in between
    // Insert small numbers in between
    // Anywhere inside is okay, as long as it's not at the sides


    long long tot = 0, tot1 = 0, prev = 0;

    int left = 0, right = n - 1, parity = 0;

    while(left < right){
        if(parity % 2 == 0){
            if(parity > 0){
                tot += abs(arr[right] - prev);
            }
            prev = arr[right--];
        } else {
            tot += abs(arr[left] - prev);
            prev = arr[left++];
        }
        ++parity;
    }

    //cout << abs(arr[n - 1] - arr[right]) << " " << abs(arr[right] - prev) << endl;

    tot = max(tot + abs(arr[right] - prev), tot + abs(arr[n - 1] - arr[right]));

    prev = 0;
    left = 0;
    right = n - 1;
    parity = 1;

    while(left < right){
        if(parity % 2 == 0){
            tot1 += abs(arr[right] - prev);
            prev = arr[right--];
        } else {
            if(parity > 1)
                tot1 += abs(arr[left] - prev);
            prev = arr[left++];
        }
        ++parity;
    }

    tot1 = max(tot1 + abs(arr[right] - prev), tot1 + abs(arr[0] - arr[right]));

    cout << max(tot, tot1);

    return 0;
}


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

using namespace std;

int main() {
    string n;
    cin >> n;
    string ans = "No";
    if ((n[0] == n[1] && n[0] == n[2]) ||
    (n[1] == n[2] && n[1] == n[3])) {
        ans = "Yes";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/*-- ILSH  --*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
//const ll mod =1e9+7;
const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}


const ll N = 2e5+5;

void solve(){
	ld a,b;
	cin>>a>>b;
	cout<< ( ll ) (a*b)<<'\n';
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
//	#ifndef ONLINE_JUDGE
//		freopen ("INPUT.txt" , "r" , stdin);
//		freopen ("OUTPUT.txt", "w" , stdout);
//	#endif

	int t=1;

	//cin>>t;

	for ( int i=1;i<=t;i++){
   // 	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

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

int main(void){
    string s;
    ll k;
    cin >> s >> k;

    ll ans = 0;
    rep(i, s.size()){
        if(s[i] == '1'){
            ans++;
            if(ans == k){
                cout << 1 << endl;
                return 0;
            }
        }else{
            cout << s[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include<utility>
#include <new>
#include <string>
#include<cmath>
#include<unordered_set>
#include<iomanip>
#include <stack>
#include<queue>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll =  long long int;
#define mod 1000000007
/*bool cmp(pair<ll,ll>a,pair<ll,ll>b){
return a.second<b.second;
}*/
int main() {
int n;
cin>>n;
ll t;
cin>>t;
ll  ans=0;
ll  ma=t;
loop(i,1,n){
    cin>>t;
    if(ma>t){
            ans+=ma-t;

    }else{
    ma=t;
    }

}
cout<<ans;
        return 0;
}


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

ll n, x, a[200];

int main() {
	while(scanf("%lld %lld", &n, &x)!=EOF){
		for(int i=0; i<n; i++){
			scanf("%lld", &a[i]);
		}
		sort(a, a+n);
		ll ans=0;
		for(int i=0; i<n; i++){
			if(a[i]<=x){
				if((i!=n-1) || ((i==n-1) && (a[i]==x))){
					ans++;
				}
				x-=a[i];
			}
			
		}
		printf("%lld\n", ans);
		
	}
	return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#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 RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n; R(n);
    VI AA(n+1);
    int ss=0;
    FOR(i,1,n){
        R(AA[i]);
        ss+=AA[i];
    }
    int T;
    R(T);
    while(T--){
        int x,y; R(x,y);
        W(ss+y-AA[x]);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve(){
	int n;
	cin>>n;
	vector<int> table(n,0);
	for(int i=0;i<n;i++){
		cin>>table[i];
	}
	for(int i=0;i<n;i++){
		if(table[i]%2==0 && table[i]%3 && table[i]%5){
			cout<<"DENIED"<<endl;
			return;
		}
	}
	cout<<"APPROVED"<<endl;
}


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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans,mx,mn=1e8,sum,cnt;

int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
		
	}
	sort(a,a+n);
	for(ll i=0; i<n; i++ ){
		cnt++;
		if(a[i]!=a[i+1] ){
			if(a[i]>cnt) ans += cnt;
			else if(a[i]<cnt) ans += cnt-a[i];
			cnt=0;
		}
		
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
void insertionSort(int *,int,int);
void shellSort(int *,int);
int cnt, m, *G;

int main()
{
  int n, i, *A; 

  scanf("%d",&n);
  A = (int *)malloc(n * sizeof(int)); 

  for(i = 0 ; i < n ; i++) scanf("%d",&A[i]);

  shellSort(A,n);

  printf("%d\n",m);
  for(i = 0 ; i < m ; i++) printf("%d ",G[i]);
  printf("\n");
  printf("%d\n",cnt);

  for(i = 0 ; i < n ; i++) printf("%d\n",A[i]);

  free(A);
  free(G);
  
  return 0;
}

void insertionSort(int *A,int n,int  g){
  int i, j, v;
  for(i = g ; i <= n-1 ; i++){ 
    v = A[i];
    j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
      A[j+g] = v; }
  }
}

void shellSort(int *A,int n){
  int i, h, count = 0;
  
  cnt =0;

  /* Gを作る */
  for(h = 1 ; h <= n ; h = 3 * h + 1) count++;
  m = count;
  G = (int *)malloc(m * sizeof(int));
  G[0] = (h - 1)/3;
  for(i = 1 ; i < m ; i++) G[i] = (G[i-1] - 1)/3;
  
  for(i = 0 ; i <= m-1 ; i++) insertionSort(A,n,G[i]);
  
}


Measured memory_bytes: 5440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N+1, 0);
    for(int i=1; i<N; i++){
        int no; cin >> no;
        a[no]++;
    }
    for(int i=1; i<=N; i++){
        cout << a[i] << endl;
    }
    return 0;
}

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

struct Edge {
    int from, to;
    long long cost;
    Edge(int _to, long long _cost) :
        from(-1), to(_to), cost(_cost) {}
    Edge(int _from, int _to, long long _cost) :
        from(_from), to(_to), cost(_cost) {}
};

template<class T>
vector<T> Dijkstra(const vector<vector<Edge>> &G, int s, T def) {
    using P = pair<T, int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    vector<T> dist((int)G.size(), def);
    pq.push({0, s});
    dist[s] = 0;
    while(!pq.empty()) {
        int cur = pq.top().second; pq.pop();
        for(auto &e : G[cur]) {
            if(dist[e.to] > dist[cur] + e.cost) {
                dist[e.to] = dist[cur] + e.cost;
                pq.push({dist[e.to], e.to});
            }
        }
    }
    return dist;
}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<vector<Edge>> G(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        long long c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }
    rep(i, N) {
        if(i) G[i].emplace_back(i - 1, 0LL);
    }
    auto dist = Dijkstra(G, 0, INF);
    if(dist[N - 1] == INF) cout << -1 << '\n';
    else cout << dist[N - 1] << '\n';
}

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


Measured memory_bytes: 12664
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define sentinel INT_MAX

int count = 0;

//straight up from the notes

void merge(int* array, int start, int end, int middle) {
	int n1 = middle - start;
	int n2 = end - middle;
	//make 2 arrays Left and Right
	int* Left;
	int* Right;

	Left = (int*)malloc((n1+1) * sizeof(int));
	Right = (int*)malloc((n2 + 1) * sizeof(int));

	for (int i = 0; i < n1; i++) {
		Left[i] = array[start + i];
	}

	for (int i = 0; i < n2; i++) {
		Right[i] = array[middle + i];
	}

	Left[n1] = sentinel;
	Right[n2] = sentinel;

	int i = 0, j = 0;
	for (int k = start; k < end; k++) {
		count++;
		if (Left[i] <= Right[j]) {
			array[k] = Left[i++];
		}
		else {
			array[k] = Right[j++];
		}
	}

}

void merge_sort(int* array, int start, int end) {
	if (start + 1 < end) {
		int middle = (start + end) / 2;
		merge_sort(array, start, middle);
		merge_sort(array, middle, end);
		merge(array, start, end, middle);
	}
}

int main() {
	int i, array_size = 0;
	scanf("%d", &array_size);

	//dynamic scan
	int* array;
	array = (int*)malloc(array_size * sizeof(int));
	for (i = 0; i != array_size; i++) {
		scanf("%d", &array[i]);
	}

	merge_sort(array, 0, array_size);

	for (int i = 0; i < array_size - 1; i++) {
		printf("%d ", array[i]);
	}
	printf("%d\n%d\n", array[array_size - 1],count);
	return 0;
}



Measured memory_bytes: 64524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main (){
    string a;
    cin >> a;
    vector<ll> c(26);
    for(int i=0;i<a.size();i++){
        c[a[i]-'a']++;
    }
    ll ans = 0;
    ll n = a.size();
    ans = (n*(n-1))/2+1;
    for(int i=0;i<26;i++){
        ans-=((c[i]*(c[i]-1))/2);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<deque>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef long long ll;
/////////////////////////////////

int const N = 2e3 + 41;
int const INF = 1e9 + 41;

int n, k;
vector<int> e[N];
int ans;

int dfs(int x, int l, int p = -1){
	if(l < 0) return 0;
	int res = 1;
	for(int y : e[x]){
		if(y == p) continue;
		res += dfs(y, l-1, x);
	}
	return res;
}

void solve(){
	ans = 0;
	fi(0, n){
		int s = 1;
		int mx = 0;
		for(int y : e[i]){
			int v0 = dfs(y, k/2-1, i);
			int v1 = dfs(y, (k+1)/2-1, i);
			s += v0;
			if(k&1) mx = max(mx, v1 - v0);
		}
		ans = max(ans, s + mx);
	}
	ans = n -	ans;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d %d",&n,&k);
	fi(0, n-1){
		int x, y;
		scanf("%d %d",&x,&y);
		--x;--y;
		e[x].pb(y);
		e[y].pb(x);
	}
	
	solve();
	
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007

ll w,e;
int main(void)
{
	CIN;
	int tc,l,k=0,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	int a,b,c;
	cin>>a>>b>>c>>x>>y;
	cout<<min(a*x+b*y,min(2*c*x+b*max(y-x,0),2*c*y+a*max(x-y,0)));

}

Measured memory_bytes: 3656