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

int main(){
    long int N,A[100001] = {0}, Q, B, C, tmp;
    long long int sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> tmp;
        A[tmp] += 1;
        sum += tmp;
    }

    cin >> Q;
    for (int i = 0; i < Q; i++){
        cin >> B >> C;
        sum = sum - B*A[B] + C*A[B];
        A[C] += A[B];
        A[B] = 0;
        cout << sum << endl;
    }
    return 0;
}



Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
const int maxn = 30001;
vector<int>ans; 
int vis[maxn];
int main()
{
	int n;
	cin>>n;
	int cnt = 0;
	int sum = 0;
	for(int i=1;i<=maxn;i++)
	{
		if(cnt==n-1)
			break;
		if(i%2==0||i%3==0)
		{
			ans.push_back(i);
			cnt++;
			sum+=i;
			vis[i] = 1;
		}
	}
	for(int i=1;i<=maxn;i++)
	{
		if(!vis[i]&&__gcd(sum,i)!=1&&(i+sum)%2==0&&(i+sum)%3==0)
		{
			ans.push_back(i);
		}
	}
	for(int i=0;i<n;i++)
	{
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  string str, tmp="";
  string ans[1025];
  int cnt=0;
  getline(cin, str);
  
  for(int i = 0 ; i < str.size() ; i++){
    if(str[i] == ' ' || str[i] == ',' || str[i] == '.'){
      if(3 <= tmp.size() && tmp.size() <= 6){
	ans[cnt] = tmp;
	cnt++;
	tmp = "";
      }
    }
    if(str[i] == ' ' || str[i] == ',' || str[i] == '.') tmp = "";
    else tmp += str[i];
  }
  for(int i = 0 ; i < cnt ; i++){
    if(i == cnt-1) cout << ans[i] << endl;
    else cout << ans[i] << ' ';
  }
  return 0;
}

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

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long int ll;
typedef unsigned long long int ull;
#define inf INT_MAX
#define minf INT_MIN
#define watch(x)	cout<<(#x)<<"=>"<<x<<'\n';
#define sz(a) (int)(a).size()
#define all(x) x.begin(),x.end()


ll ans;
int arr[300009];
vi vr;
void solve()
{
    int n;  cin>>n;

    for(int i = 1; i < n; ++i){
        int c = i;
        int ab = n-i;
        int j = 1;
        bool ok = true;
        for(j = 1; j*j < ab; ++j){
            if( ab % j == 0){
                ok = false;
                ans += 2;
            }
        }
        if(j * j == ab)
            ans +=1; 
    }
    cout<<ans;

    cout<<'\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testc;  testc = 1;
    for(int t = 0; t < testc; ++t){
        solve();
    }
    return 0;
}

	//Sat 19 Sep 2020 05:55:38 PM IST


		/***astrainL3gi0N***/


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int n;
bool used[101010];

vector<vi> G;

int f(int v = 0) {
  if (used[v]) return -1;
  used[v] = true;

  int ret = 0;

  for (int i = 0; i < G[v].size(); ++i) {
    ret ^= f(G[v][i]) + 1;
  }

  return ret;
}

signed main() {
  cin >> n;

  G.resize(n);
  rep(i, n - 1) {
    int a = in() - 1, b = in() - 1;
    G[a].pb(b);
    G[b].pb(a);
  }

  cout << (f() ? "Alice" : "Bob") << endl;
}


Measured memory_bytes: 8960
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

typedef long long ll;

using namespace std;

char name[11];
int n,ans=0,nl;

int check(){
    char in[11];
    int l;
    
    scanf("%s",in);
    
    for(l=0;in[l]!='\0';l++);
    
    for(int j=0;j<l;j++){
        if(name[0]==in[j]){
            for(int k=1;;k++){
                if(k==nl) return 1;
                if(name[k]!=in[(k+j)%l]) break;
            }
        }
    }
    
    return 0;
}

int main(){
    
    scanf("%s%d",name,&n);
    
    for(nl=0;name[nl]!='\0';nl++);
    
    for(int i=0;i<n;i++){
        ans+=check();
    }
    
    printf("%d\n",ans);
    
    
    return 0;
}

Measured memory_bytes: 1188
N = int(input())
w = []
for i in range(N):
    w.append(input())
last_char = w[0][0]
Rule = True
for word in w:
    if last_char == word[0]:
        last_char = word[-1]
        continue
    else:
        Rule = False
        break
if Rule and len(w) == len(set(w)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
#define cons 1000000007 
using namespace std;
const int N = 200000;

int n, m;
multiset<int> available;
vector<int> job[N];
 
signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
 
    cin>>n>>m;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin>>a>>b;
      job[a].push_back(b);
    }
 
    int ans = 0;
    for (int i = m - 1; i >= 0; i--) {
      for (int x : job[m - i])
        available.insert(x);
      if (!available.empty()) {
        ans += *prev(available.end());
        available.erase(prev(available.end()));
      }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N;
int C[500], S[500], F[500];

signed main(){
	cin >> N;
	REP(i, 0, N-1) {
		cin >> C[i] >> S[i] >> F[i];
//		cout << C[i] << " " << S[i] << " " << F[i] << endl;
	}
	
	int ans = 0;
	int s;
	REP(i, 0, (N-1)) {
		s = S[i] + C[i];
//	    cout << "s = " << s << "  S[" << i << "] = " << S[i] << "  C[" << i << "] = " << C[i]  << endl;
		REP(j, (i+1), (N-1)) {
//		    cout << "  s = " << s << "  F[" << j << "] = " << F[j] << "  C[" << j << "] = " << C[j] << endl;
//		    cout << "    [" << (s/F[j]) << "]  [" << (s % F[j]  > 0 ? 1 : 0) << "]" << endl;
//		    cout << "       [" << ( (s / F[j] + (s % F[j]  > 0 ? 1 : 0)) * F[i]) << "]  [" << ((s / F[j] + (s % F[j]  > 0 ? 1 : 0)) * F[i] + C[j]) << "]" << endl;
		    if(s > S[j]) {
		        s -= S[j];
    		    s = S[j] + (s / F[j] + (s % F[j]  > 0 ? 1 : 0)) * F[j] + C[j];
		    } else {
		        s = S[j] + C[j];
		    }
		}
		cout << s << endl;
	}
	cout << 0 << endl;
	
	return 0;
}


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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}


map<char, ll> character_count(string s){
    map<char, ll> counter;
    rep(i, s.size()){
        ++counter[s[i]];
    }

    return counter;
}


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);


    int n;
    cin >> n;
    string s;
    cin >> s;

    char cc = s[0];
    bool ok = true;
    for(auto c : s){
        if(c != cc) ok = false;
    }

    if(ok){
        ppp(n);
    }
    else{
        map<char, ll> mp = character_count(s);
        ll ans = 1LL;
        for(auto x : mp){
            ans *= x.second+1;
            ans %= MOD;
        }
        ppp(ans-1);
    }





    return 0;
}


Measured memory_bytes: 512
import numpy as np
N,M,X=map(int, input().split())  
y=[list(map(int,list(input().split()))) for i in range(N)]

tmp = sum([y[k][0] for k in range(N)]) + 1
ans = tmp
#print(ans)
for i in range(2**N):
  c = 0
  A=[0]*M
  A = np.array(A)
  for j in range(N):
    if ((i >> j) & 1):
      c += y[j][0]
      A += np.array(y[j][1:M+1])
  #print(A)
  if np.all(A>=X):
    ans = min(ans, c)

if ans==tmp:
  ans = -1

print(ans)

Measured memory_bytes: 27348
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main()
{
    long long a, b, ans = 0;
    cin >> a >> b;
    for (long long i = 1; i <= (1LL << 40); i <<= 1)
    {
        long long bs = (i << 2);
        long long kek = b / bs * bs + (a % bs);
        if (kek > b) kek -= bs;
        long long l = max(a, kek);
        vector<pair<long, long> > konk;
        for (; l <= b; )
        {
            long long r = l / i * i + i - 1;
            if (r > b) r = b;
            konk.push_back({l, r});
            //cout << l << " " << r << endl;
            l = r + 1;
        }
        ll cnt = 0;
        //cout << i << endl;
        for (int j = 0; j < konk.size(); j++)
        {
            long long len = konk[j].second - konk[j].first + 1;
            //cout << konk[j].first << " " << konk[j].second << endl;
            if (konk[j].second & i)
                cnt += len;
        }
        if (cnt % 2) ans += i;
        //cout << cnt << " " << endl;
    }
    cout << ans;
}

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

int main(){
    int a;
    cin >> a;
    int b;
    cin >> b;
    int c[b];
    int d = 0;
    for(int i = 0; i < b; i++){
        cin >> c[i];
        d += c[i];
    }
    if(d >= a)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = (base + base) % mod;
    }
    return tot;
}

long long adj[301][301];

bitset<301> ree[301]; // usE tHis fOr O9n^2) flOWudY wRashALl

int main(){

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

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

    // nani just fw on the graph lmao

    int n; cin >> n;

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

    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                if(adj[i][k] + adj[k][j] < adj[i][j]){
                    cout << "-1\n";
                    return 0;
                }
                if(adj[i][k] + adj[k][j] == adj[i][j] && i != k && j != k){
                    // useless edge, second part is to avoid stupid stuff like self loops
                    ree[i][j] = 1;
                }
            }
        }
    }

    long long tot = 0;

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < i; ++j)
            if(!ree[i][j])
                tot += adj[i][j];

    cout << tot << "\n";

    return 0;

}


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

int main() {
    
	int n;
	cin >> n;
	int arr[n];
	for (int i=0; i<n; i++) cin >> arr[i];
	sort(arr, arr+n);
	cout << arr[n-1] - arr[0] << endl;
	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
 
class DandA {
    static void Main(string[] args) {
        int[] nm = ReadLineIntArray();
        var myTable = new Dictionary<string, int[]>();
        string[][] ps = ReadMLineStrArray(nm[1]);
        int wcCnt = 0;
        int acCnt = 0;
        for (int i = 0;i < nm[1];i++) {
            if (ps[i][1] == "AC") {
                if (myTable.ContainsKey(ps[i][0])) {
                    if (myTable[ps[i][0]][1] == 0) {
                        acCnt++;
                        wcCnt += myTable[ps[i][0]][0];
                    }
                    myTable[ps[i][0]][1] = 1;
                } else {
                    acCnt++;
                    myTable[ps[i][0]] = new int[2]{0,1};
                }
            } else {
                if (myTable.ContainsKey(ps[i][0])) {
                    myTable[ps[i][0]][0]++;
                } else {
                    myTable[ps[i][0]] = new int[2]{1,0};
                }
            }
        }
        Console.WriteLine(acCnt + " " + wcCnt);
    }
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
}

Measured memory_bytes: 35896
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  map<ll, int> mp;
  ll ans = 0;
  for (int j = 0; j < N; j++)
  {
    ans += mp[j - A[j]]; // まず答えに足す
    mp[j + A[j]]++;      // j + A[j] = XとなるXの数を更新する
  }
  cout << ans << endl;
  return 0;
}

// 変形するとj - A[j] = i + A[i]となる．これで条件を満たすiというのはi < jかつj - A[j] = i + A[i]を満たすiとなる．この時，cnt[x]:=i + A[i]を満たすiの個数をjを全探索しながら更新していくことでjを評価するときは，cnt配列はi < jのものが作られている状態が作れる．これでcnt[j - A[j]]を答えに足し合わせていくと答えが得られる．


Measured memory_bytes: 27432
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 100005
using namespace std;
typedef long long ll;
struct P{
	int l,r,w;
	P(){}
	P(int a,int b,int c){l=a;r=b;w=c;}
}a[N<<1],b[N<<1];
int n,m,c[N];
ll ans=1e15,sum=0;
bool cmpl(P a,P b){
	return a.l<b.l;
}
bool cmpr(P a,P b){
	return a.r<b.r;
}
ll w[N];
int main(){
	scanf("%d%d",&n,&m);
	int tot=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&c[i]);
		if(i>1){
			if(c[i]>c[i-1]){
				sum+=c[i]-c[i-1];
				a[++tot]=P(c[i-1]+1,c[i],0);
			}else{
				sum+=c[i]+m-c[i-1];
				a[++tot]=P(c[i-1]+1,m,0);
				a[++tot]=P(1,c[i],m-c[i-1]);
			}
		}
	}
	for(int i=1;i<=tot;i++) b[i]=a[i];
	sort(a+1,a+tot+1,cmpl);
	sort(b+1,b+tot+1,cmpr);
	w[0]=sum;
	for(int i=1,p=0,j=0,h=0;i<=m;i++){
		w[i]=w[i-1]-h;
		while(p<tot&&a[p+1].l==i){
			p++;
			w[i]-=a[p].w;
			h++;
		}
		ans=min(ans,w[i]);
		while(j<tot&&b[j+1].r==i){
			j++;
			w[i]+=b[j].w;
			w[i]+=b[j].r-b[j].l;
			h--;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N,D,X;
  cin >> N >> D >> X;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  int ans = 0;
  rep(i,N){
    for(int j=1;j<=D;j++){
      if((j-1)%A[i]==0) ans++;
    }
  }
  cout << ans+X << endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])
mod=1000000007
dp=[1,1]
if 1 in a:
  dp[1]=0
for i in range(2,n+1):
  if i in a:
    dp.append(0)
  else:
    dp.append((dp[-1]+dp[-2])%mod)
print(dp[-1]%mod)


Measured memory_bytes: 13216
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=35;
int n,m;
int mask[MAX_N];
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int tot;
		cin>>tot;
		for(int j=0;j<tot;j++)
		{
			int x;
			cin>>x;
			mask[x]|=(1<<i);
		}
	}
	int ans=0;
	for(int i=1;i<=m;i++)
	{
		if(mask[i]==(1<<n)-1)ans++;
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


#define rep(i,r,l) for(int i = r; i < l; i++)
#define elif else if

int nextint(void){int n;scanf("%d",&n);return n;}
void printint(int d){printf("%d\n",d);}


int main(void){ 

    int a,b,c,k;
    scanf("%d %d %d",&a,&b,&c); 
    k = nextint();
    for(;a>=b&&k!=0;k--)b*=2;
    for(;b>=c&&k!=0;k--)c*=2;
    (a<b&&b<c)?(puts("Yes")):(puts("No"));
    return 0;
}



Measured memory_bytes: 1660
#include <stdio.h>

int main () {
	int healthTaka;
	int attackTaka;
	int healthAoki;
	int attackAoki;
	scanf("%d %d %d %d",&healthTaka,&attackTaka,&healthAoki,&attackAoki);
	while(1)
	{
		healthAoki = healthAoki - attackTaka;
		if(healthAoki < 1)
		{
			printf("Yes");
			break;
		}
		healthTaka = healthTaka - attackAoki;
		if(healthTaka < 1)
		{
			printf("No");
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
 
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }
 
#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif
 
// ********************** CODE ********************** //
 
const int N = 1e5 + 7;
 
LL n, A[N], B[N], C[N], dp[N][3];
 
int main()
{
    _upgrade
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> A[i]; sort(A + 1, A + n + 1);
    for(int i = 1; i <= n; i++) cin >> B[i]; sort(B + 1, B + n + 1);
    for(int i = 1; i <= n; i++) cin >> C[i]; sort(C + 1, C + n + 1);
    for(int i = 1; i <= n; i++) dp[i][0] = i;
    for(int i = 1; i <= n; i++)
    {
        dp[i][1] = dp[i - 1][1];
        auto it = lower_bound(A + 1, A + n + 1, B[i]);
        dp[i][1] += dp[it - A - 1][0];
    }
    for(int i = 1; i <= n; i++)
    {
        dp[i][2] = dp[i - 1][2];
        auto it = lower_bound(B + 1, B + n + 1, C[i]);
        dp[i][2] += dp[it - B - 1][1];
    }
    cout << dp[n][2] << "\n";
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define MAXN 505
using namespace std ;	int n ;

int gph[MAXN][MAXN] ;
int cnt_col[MAXN], cnt_row[MAXN] ;

int cc = 0 ;

char s[MAXN] ;

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

	for (int i=1; i<=n; ++i) {
		scanf("%s",s+1) ;
		for (int j=1; j<=n; ++j)
			gph[i][j] = s[j] == '#', cnt_black += gph[i][j],
			cnt_col[j] += gph[i][j], cnt_row[i] += gph[i][j] ;
	}

	for (int i=1; i<=n; ++i)	cc += cnt_col[i] == n ;

	if (!cnt_black)	return puts("-1"), 0 ;

	int ans = n << 1 ;

	for (int i=1; i<=n; ++i) {
		if ( cnt_row[i] == n )	ans = min ( ans, n - cc ) ;
		if ( ! cnt_col[i] )
			ans = min ( ans, n - cc + 1 + n - cnt_row[i] ) ;
		else	ans = min ( ans, ( n << 1 ) - cnt_row[i] - cc ) ;
	}

	printf("%d\n",ans) ;

	return 0 ;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;

    if((x>=r)&&(x<=W-r)&&(y>=r)&&(y<=H-r))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 3100
N, Y = map(int, input().split())

max_10000 = Y // 10000
for x in range(max_10000 + 1):
    if x > N:
        continue

    rem = Y - 10000 * x

    max_5000 = rem // 5000
    for y in range(max_5000 + 1):
        if x + y > N:
            continue

        rem_2 = rem - 5000 * y
        if x + y + rem_2 // 1000 == N:
            print('{} {} {}'.format(x, y, rem_2 // 1000))
            exit()


print('{} {} {}'.format(-1, -1, -1))


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

int main(){
  ll n;cin>>n;
  int a[1000000];
  map<ll,ll> num;
  rep(i,n){
    cin>>a[i];
  }
  ll sum = 0;
  rep(i,n){
    num[a[i]]++;
  }
  for (auto p : num){
    ll b = p.first;
    ll c = p.second;
    if (b != c){
      if (b>c){
        sum+=c;
      }
      else {
        sum+=c-b;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 6656
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] a = sc.next().split("", 0);
        int result = 0;
        for (int i = 0; i < a.length; i++) {
            result += (Integer.parseInt(a[i]) == 1) ? 1 : 0;
        }

        System.out.println(result);
    }
}

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

using namespace std;

int main() {
#ifndef ONLINE_JUDGE
  // freopen("Test2.in", "r", stdin);

 // cout << "\033[2J\033[1;1H";
#endif
  long double H, A;
  cin >> H >> A;
  cout << ceil(H / A) << endl;

  return 0;
}


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

int main() {

  int N;
  cin >> N;

  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);
  for (int i = 0; i < N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  string result = "Yes";

  for (int i = 0; i < N; i++) {
    int distance = x[i] + y[i];
    if (t[i] < distance) {
      result = "No";
      break;
    } else if (distance % 2 != t[i] % 2) {
      result = "No";
      break;
    }
  }

  cout << result << endl;

}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int a, b;
  cin >> a >> b;
  cout <<  max(a+b,max(a-b,a*b)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N=1000010;
LL n,l,x[N],t[N],a[N],b[N],ans=0,rmv[N];
stack <int> q[2];
int main(){
	scanf("%lld%lld",&n,&l);
	for(LL i=1; i<=n; ++i)scanf("%lld",&x[i]);
	for(LL i=1; i<=n; ++i)scanf("%lld",&t[i]),ans+=((t[i]-1)/(2*l))*2*l,t[i]=(t[i]-1)%(2*l)+1;
	for(LL i=1; i<=n; ++i)a[i]=(t[i]>2*(l-x[i])),b[i]=(t[i]>2*x[i]);
	for(LL i=1; i<=n; ++i)if(a[i]&&b[i])rmv[i]=1,ans+=2*l;
	for(LL i=1; i<n; ++i){
		if(rmv[i])continue;
		if(!a[i]&&b[i]){
			if(q[0].empty()&&q[1].empty())continue;
			LL tmp=q[1].empty()?0:1;
			rmv[q[tmp].top()]=1; q[tmp].pop(); rmv[i]=1; ans+=2*l;
		}else if(!b[i])q[a[i]].push(i);
	}
	while(!q[0].empty())q[0].pop(); while(!q[1].empty())q[1].pop();
	for(LL i=1; i<n; ++i){
		if(rmv[i]||(!a[i]&&b[i]))continue;
		if(!a[i]){
			if(q[0].empty()&&q[1].empty())q[0].push(i);
			else{
				LL tmp=q[1].empty()?0:1;
				rmv[q[tmp].top()]=1; q[tmp].pop(); rmv[i]=1; ans+=2*l;
			}
		}else q[1].push(i);
	}
	if(!a[n]&&!rmv[n]){
		for(LL i=1; i<n; ++i)
			if(!b[i]&&!rmv[i]){
				rmv[i]=1; rmv[n]=1; ans+=2*l;
				break;
			}
	}
	for(LL i=1; i<=n; ++i)if(!rmv[i])ans+=2*l;
	if(!rmv[n])ans+=(a[n]&&!b[n])?2*l:0;
	else ans+=2*l;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 21836
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>

#define ll long long

using namespace std;

inline ll read() {
	ll x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

const int N=2e5+5;

ll a[N],b[N];

int main() {
	int n=(int)read();
	for (int i=1;i<=n;i++) {
		a[i]=read();
		b[a[i]]++;
	}
	ll tot=0;
	for (int i=1;i<=n;i++) {
		tot+=b[i]*(b[i]-1)/2;
	}
	for (int i=1;i<=n;i++) {
		cout<<tot-(b[a[i]]-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>
#include<algorithm>

using namespace std;

int main(){
	int n,a,b,c;
	int m=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int a[3];
		for(int j=0;j<3;j++)scanf("%d",&a[j]);
		std::sort(a,a+3);
		
		m=max(m,a[2]);
		
		if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2])puts("YES");
		else{
			if(m<=11)puts("NO");
			else puts("YES");
		}
	}
}

Measured memory_bytes: 0
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        //input
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a[] = new long[n];
        long aSum = 0;
        for (int i=0;i<n;++i)
        {
            a[i]=sc.nextLong();
            aSum+=a[i];
        }
//        System.out.println(aSum);
//        System.out.println(aSum/2);

        long half = aSum/2;

        long halfSum = 0;
        int ind = 0;
        for (int i=0;i<n;++i)
        {
            halfSum+=a[i];

            if (halfSum >= half)
            {
                long cand1 = Math.abs(half-halfSum);
                long cand2 = Math.abs(half-(halfSum-a[i]));

                if (cand1 <= cand2) ind = i;
                else if (cand1 > cand2)
                {
                    halfSum-=a[i];
                    ind = i-1;
                }

                break;
            }
        }

        long halfSum2 = 0;
        for (int i=ind+1;i<n;++i)
        {
            halfSum2 += a[i];
        }

        long ans = Math.abs(half-halfSum);
        ans += Math.abs(half-halfSum2);

        System.out.println(ans);

        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

Measured memory_bytes: 91808
#include<iostream>
using namespace std;
#define ll long long

void solve()
{
	int a,b;
	cin>>a>>b;
	if(a>b)
	{
		if(a%b)
		cout<<a/b+1;
		else
		cout<<a/b;
	}
	else
	cout<<1;
}
int main()
{
	//int t;cin>>t;
	//while(t--)
	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#define fi first
#define se second
using namespace std;
const int maxn = 1e5 + 100;
typedef long long LL;
typedef pair<int, long long> PLI;
typedef pair<int, int> PII;
vector<PLI> G[maxn];
set<PII> S;
int son[maxn], sz[maxn];
int tree[maxn*4];
int n, tot;
LL ANS = 0, Min = 1e18;
void dfs0(int x, int fa){
    sz[x] = 1;
    for(auto e : G[x]){
        if(e.fi == fa) continue;
        dfs0(e.fi, x);
        sz[x] += sz[e.fi];
        son[x] = max(son[x], sz[e.fi]);
    }
    son[x] = max(son[x], n - sz[x]);
}

void dfs(int x, int fa, LL v){
    sz[x] = 1;
    for(auto e : G[x]){
        if(e.fi == fa) continue;
        dfs(e.fi, x, e.se+v);
        sz[x] += sz[e.fi];
    }
    ANS += v;
}

int main(){
    cin>>n;
    for(int i = 1; i < n; i++){
        int x, y, w;
        cin>>x>>y>>w;
        G[x].push_back({y, w});
        G[y].push_back({x, w});
    }
    int X;
    dfs0(1, 1);
    for(int i = 1; i <= n; i++) if(son[i] <= n/2) X = i;
    dfs(X, X, 0);
    for(auto e : G[X]){
        if(sz[e.fi] == (n+1)/2) { Min = e.se; break; }
        Min = min(e.se, Min);
    }
    cout<<ANS*2 - Min<<endl;
}

Measured memory_bytes: 13952
#include <cstdio>
#include <math.h>

int main() {
	int n,a,c=0;
	bool b;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		b = true;
		for (int j = 2; j <= sqrt(a); j++) {
			if (a%j == 0) {
				b = false;
				break;
			}
		}
		if (b) c++;
	}
	printf("%d\n", c);
	return 0;
}

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

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

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

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

  ll N = B - A + 1; // 6
  ll cm = B/C - (A-1)/C;
  ll dm = B/D - (A-1)/D;
  ll cdm = B/lcm(C, D) - (A-1)/lcm(C, D);

  cout << N - (cm + dm - cdm) << endl;
}


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

typedef long long int ll;
const double EPS1 = 1e-8;
const double EPS = 1e-7;

int main () {
    ll x; cin >> x;
    for (ll b = -200; b <= 200; b++) {
        ll b5 = b * b * b * b * b;
        double ad = pow(b5 + (double)x, 0.2);
        if (ad < 0) {
            ad -= EPS1;
        } else {
            ad += EPS1;
        }
        ll a = (ll)ad;
        if (ad - EPS < (double)a && (double)a < ad + EPS) {
            cout << a << " " << b << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, M;

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

  cout << N*(N-1)/2+M*(M-1)/2 << "\n";
  return 0;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int h = ri();
	int w = ri();
	if (h == 1 || w == 1) {
		puts("1");
		return 0;
	}
	printf("%lld\n", ((int64_t) h * w + 1) / 2);
	return 0;
}




Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define fdto(i, r, l) for(int i = r; i >= l; --i)
#define fto(i, l, r) for(int i = l; i <= r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,i,arr[200005];
    cin>>n>>k;
    for(i=0;i<n;i++)
    cin>>arr[i];

    sort(arr,arr+n);
    ll sum=0;
    for(i=0;i<k;i++)
    {
        sum+=arr[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<int> make_imos(vector<int> &v)
{
    vector<int> res;
    res.push_back(0);
    for (int i = 0; i < v.size(); i++)
    {
        res.push_back(res[i] + v[i]);
    }
    return res;
}

//v[f, l)
int get_imos(vector<int> &imos, int f, int l)
{
    l = min(l, (int)imos.size() - 1);
    f = max(0, f);
    return imos[l] - imos[f];
}

int main()
{
    int N, K;
    string S;
    cin >> N >> K >> S;
    // vz => the number of zero in the section
    // S should start with one
    vector<int> vz, vo;
    if (S[0] != '1')
    {
        vo.push_back(0);
    }

    while (!S.empty())
    {
        int count = 0;
        char c = S[0];
        while (S[count] == c)
        {
            count++;
        }
        if (c == '0')
        {
            vz.push_back(count);
        }
        else
        {
            vo.push_back(count);
        }
        S.erase(S.begin(), S.begin() + count);
    }

    vector<int> imoso = make_imos(vo);
    vector<int> imosz = make_imos(vz);

    int ans = 0;
    for (int i = 0; i < vo.size(); i++)
    {
        int tmp_ans = get_imos(imosz, i, i + K) + get_imos(imoso, i, i + K + 1);
        ans = max(ans, tmp_ans);
    }
    printf("%d\n", ans);
}

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

using namespace std;

const int N = 1e5 + 50;
const int INF = 0x3f3f3f3f;

int n;
int a[N], b[N], c[N];
int dp[N][3];

void load() {
    scanf("%d", &n);

    for(int i = 0; i < n; ++i)
            scanf("%d%d%d", a + i, b + i, c + i);
}

void solve() {
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1; i < n; ++i) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }

    printf("%d\n", max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])));
}

int main() {
    memset(dp, -INF, sizeof dp);

    load();
    solve();

    return 0;
}


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

using namespace std;

int main()
{
    int n;
    long long sum=0;

    cin >> n;
    
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0)sum += i;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3528
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data',function(chunk){

var line = chunk.split(' ');
var W = Number(line[0]);
var H = Number(line[1]);
var x = Number(line[2]);
var y = Number(line[3]);
var r = Number(line[4]);

if(W >= x+r && H >= y+r && 0 <= x-r && 0 <= y-r){
console.log("Yes")
}else{
console.log("No")
}
});

Measured memory_bytes: 15540
S = input()
acgt = 'ACGT'
count = 0
for i,s in enumerate(S):
    if s in acgt:
        acount = 0
        for j in range(i,len(S)):
            if not(S[j] in acgt):
                break
            acount+=1
        count = max(count,acount)
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, C;
    cin >> A >> B >> C;
    if (C >= A && C <= B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int n,x,y;
vector <int> v[100005];
long long d[100005]={0},t[100005]={0};
const int INF=1000000005;
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
	    d[i]=INF;
	d[1]=0;
	queue <int> q;
	q.push(1);
	while(q.size())
	{
		int u=q.front();q.pop();
		for(int i=0;i<v[u].size();i++)
		{
			int f=v[u][i];
			if(d[f]>d[u]+1)
			{
				d[f]=d[u]+1;
			    q.push(f);
			}    
		}
	}
	//for(int i=1;i<=n;i++)
	    //cout<<i<<' '<<d[i]<<endl;
	for(int i=1;i<=n;i++)
	    t[i]=INF;
	t[n]=0;
	queue <int> qu;
	qu.push(n);
	while(qu.size())
	{
		int u=qu.front();qu.pop();
		for(int i=0;i<v[u].size();i++)
		{
			int f=v[u][i];
			if(t[f]>t[u]+1)
			{
				t[f]=t[u]+1;
			    qu.push(f);
			}    
		}
	}
	//for(int i=1;i<=n;i++)
	    //cout<<i<<' '<<t[i]<<endl;
	int f=0,s=0,e=0;
	for(int i=1;i<=n;i++)
	{
		//cout<<i<<' '<<d[i]<<' '<<t[i]<<endl;
		if(d[i]<t[i])
		    f++;
		if(d[i]>t[i])
		    s++;
		if(d[i]==t[i])
		    e++;
	}
	f+=e;
	//cout<<f<<' '<<s<<' '<<e<<endl;
	if(f>s)
	    cout<<"Fennec";
	else
	    cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 7424
"""
author : halo2halo
date : 2, Feb, 2020
"""

import sys
import itertools

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A= list(map(int, readline().split()))

print('Yes' if max(A) == sum(A)-max(A) else 'No')


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

using namespace std;

template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec){
    os << "[";
    for(int i=0;i<vec.size();i++){
        os << (i==0?"":" ") << vec[i];
    }
    os <<  "]";
    return os;
}


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

    vector<int> cnt(n, 0);
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        cnt[a]++, cnt[b]++;
    }
    bool flag = true;
    for(int i=0;i<n;i++){
        if(cnt[i] % 2){
            flag = false;
            break;
        }
    }
    cout << (flag?"YES":"NO") << endl;

    return 0;
}


Measured memory_bytes: 640
import sys
S = input()

asc = [0]*26
for s in S:
    asc[ord(s)-97] = 1


if len(S) == 26:
    for i in range(26):
        for j in range(ord(S[25-i])-97,26): 
            if asc[j] == 0:
                print(S[:(25-i)]+chr(j+97))
                sys.exit()
        asc[ord(S[25-i])-97] = 0
    print(-1)
else:
    for i in range(26):
        if asc[i] == 0:
            S += chr(97+i)
            break
    print(S)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  map<ll, ll> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }

  string ans = "No";
  if (m.size() > 3) {
    ans = "No";
  } else if (m.size() == 3) {
    bool ok = true;
    ll t = 0;
    for (auto p : m) {
      ll v = p.first;
      ll cnt = p.second;
      if (cnt != n / 3) {
        ok = false;
        break;
      }
      t ^= v;
    }

    if (t != 0) {
      ok = false;
    }

    ans = ok ? "Yes" : "No";
  } else if (m.size() == 2) {
    ans = m[0] == n / 3 ? "Yes" : "No";
  } else {
    ans = m.find(0) != m.end() ? "Yes" : "No";
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (long long i = (s); i < (long long)(n); i++)

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

    vector<int>dl(10);
    rep(i,0,k){
        int d;
        cin>>d;
        dl[d]++;
    }

    for (int i=n;i<100000;i++) {
        int x=i;
        bool jdg=true;
        while(x>0){
            if(dl[x%10]==1){
                jdg=false;
            }
            if(jdg==false){
                break;
            }
            x/=10;
        }
        if(jdg){
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
import math
import pprint
import fractions
import collections
import itertools
from decimal import *
A,B=map(str,input().split())
A=int(A)
B=str(B)
num=int(B[0])*100+int(B[2])*10+int(B[3])
#print(A,num)
print((A*num)//100)


Measured memory_bytes: 72692
import java.util.HashMap;
import java.util.*;
import java.util.Scanner;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        Map <Integer,Integer> lightMap = new HashMap<>();
        Set<Integer> removeSet = new HashSet<>();

        int n = sc.nextInt();
        int m = sc.nextInt();

        for(int i = 0; i < n; i++){//n回繰り返し
            int lightNum = i + 1;
            int lightHeight = sc.nextInt();
            lightMap.put(lightNum,lightHeight); //灯台番号と高さの入ったリスト作る
        }

        for(int i = 0; i < m;i++){ //m回繰り返し
            int a = sc.nextInt();
            int b = sc.nextInt(); //道の両サイドの灯台のkey
            int aHeight = lightMap.get(a);
            int bHeight = lightMap.get(b);

            if(aHeight < bHeight){//高さが低い方をリストに入れる（良い展望台ではない）
                removeSet.add(a);
            }else if(aHeight > bHeight){
                removeSet.add(b);
            }else{
                removeSet.add(a);
                removeSet.add(b);
            }
        }
        System.out.print(n - removeSet.size());
    }
}


Measured memory_bytes: 76272
#include <bits/stdc++.h>
using namespace std;
//GCD
long long gcd(long long x, long long y){
	if( y == 0 ) return x;
	return gcd(y, x % y);
}
int main() {
	// your code goes here
	long long n,x;
	cin >> n >> x;
	cout << 3*(n-gcd(n,x)) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N;
  cin >> N;
  int A[N];
  rep(i,N) cin >> A[i];
  int inde[N];
  rep(i,N) inde[A[i]-1]=i+1;
  int count=1,ans=0;
  rep(i,N-1){
    if(inde[i]<inde[i+1]) count++;
    else count=1;
    ans=max(ans,count);
   }
   if(N==1) cout << 0 << endl;
   else cout << N-ans << endl;
}

Measured memory_bytes: 1792
def main():
    """
    1 <= N <= 10^5
    """
    N = int(input())

    ans = rec(N)
    print(ans)


def test_ans():
    N_ans = [
        (127, 4),
        (3, 3),
        (44852, 16),
    ]
    for N, ans in N_ans:
        assert rec(N) == ans


def rec(N):
    import sys
    sys.setrecursionlimit(10 ** 7)
    memo = [-1] * (N+1)

    def _rec(i):
        if i == 0:
            return 0
        if memo[i] != -1:
            return memo[i]

        ans = N
        p = 1
        while p <= i:
            #print(6, i, i-p)
            ans = min(ans, _rec(i-p) + 1)
            p *= 6
        p = 1
        while p <= i:
            #print(9, i, i-p)
            ans = min(ans, _rec(i-p) + 1)
            p *= 9

        memo[i] = ans

        return ans

    ans = _rec(N)
    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 108404
h,n=map(int,input().split())
a=[]
b=[]
for i in range(n):
  aa,bb=map(int,input().split())
  a.append(aa)
  b.append(bb)
inf=10**10
f=h+max(a)+1
#dp[i][j]=i番目までの魔法を使えるとき、体力をj減らす最小魔力
dp=[f*[inf]for _ in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
  dp[i][0]=0
  for j in range(f):
    dp[i][j]=dp[i-1][j]
    if j-a[i-1]>=0:dp[i][j]=min(dp[i][j],dp[i][j-a[i-1]]+b[i-1])
print(min(dp[-1][h:]))

Measured memory_bytes: 126832
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7;
int n,f[N][2];
char s[N];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	if(s[i]=='.')
	{
		f[i][0]=f[i-1][0];
		f[i][1]=min(f[i-1][0],f[i-1][1])+1;
	}
	else{
		f[i][0]=f[i-1][0]+1;
		f[i][1]=min(f[i-1][0],f[i-1][1]);
	}
	printf("%d\n",min(f[n][0],f[n][1]));
}

Measured memory_bytes: 2048
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}



use input::*;

fn next_753(v: &mut Vec<usize>, n: usize) {
    if v[n] == 0 {
        v[n] = 3;
    } else if v[n] == 3 {
        v[n] = 5;
    } else if v[n] == 5 {
        v[n] = 7;
    } else {
        v[n] = 3;
        next_753(v, n - 1);
    }
}

fn is_753(v: &Vec<usize>) -> bool {
    let (mut f3, mut f5, mut f7): (bool, bool, bool) = (false, false, false);
    for z in v {
        if *z == 3 {
            f3 = true;
        }
        if *z == 5 {
            f5 = true;
        }
        if *z == 7 {
            f7 = true;
        }
        if f3 && f5 && f7 {
            return true;
        }
    }
    false
}

fn convert(v: &Vec<usize>) -> usize {
    let mut ans = 0;
    for z in v {
        ans *= 10;
        ans += *z;
    }
    ans
}

fn main() {
    let n: usize;
    let mut ans = 0;
    input!(n);

    let mut v = vec![0; n.to_string().len() + 1];

    while convert(&v) <= n {
        if is_753(&v) {
            ans += 1;
        }
        next_753(&mut v, n.to_string().len());
    }
    p(ans);
}

Measured memory_bytes: 4352