akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AChristmasEveEveEve {
public:
	void solve(std::istream& in, std::ostream& out)
	{
        int d;
	    in >> d;

	    string res;
	    if(d == 25) res = "Christmas";
	    else if(d == 24) res = "Christmas Eve";
	    else if(d == 23) res = "Christmas Eve Eve";
	    else res = "Christmas Eve Eve Eve";

	    out << res << endl;
	}
};


int main() {
	AChristmasEveEveEve solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define opr iterator
#define pii pair<int,int>
typedef long long ll;
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if((a+b)%2)
	{
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	cout<<(a+b)/2<<endl;
	return 0;
}

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

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

  string S;
  cin >> S;

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    if (i != 0) {
      if (S[i] == 'C' && S[i - 1] == 'A') { a[i] = 1; }
    }
  }
  vector<int> b(n + 1);
  b[0] = 0;
  for (int i = 0; i < n; i++) {
    b[i + 1] = b[i] + a[i];
  }

  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << b[r] - b[l] << endl;
  }
}

Measured memory_bytes: 1792
import numpy as np
N,K = map(int,input().split())
MOD = 10 ** 9 + 7
M = int(N**.5)

# M+1以上で、商がぢょうとxになるやつ
upper_cnt = np.zeros(M+1, dtype=np.int64)
a = np.arange(M+1, dtype=np.int64)
upper_cnt[1:] = N // a[1:] - np.maximum(M, N // (a[1:]+1))

# 数列の末端ごとの個数
# upperについては、個数にわたって合計をとる
lower = np.zeros(M+1, dtype=np.int64)
upper = np.zeros(M+1, dtype=np.int64)
# 0項目に1を置いておくとする
lower[1] = 1
for k in range(1,K+1):
    prev_lower = lower
    prev_upper = upper
    np.cumsum(prev_lower, out = prev_lower)
    np.cumsum(prev_upper, out = prev_upper)
    prev_lower %= MOD
    prev_upper %= MOD
    # 下側 to 下側
    lower = np.zeros(M+1, dtype=np.int64)
    lower += (prev_lower[-1] + prev_upper[-1])
    lower[1:] -= prev_upper[:-1] # 商がn-1以下だと受け付けない
    lower[0] = 0
    # 上側 to 上側：ないはず
    # 下側 to 上側：
    upper = prev_lower * upper_cnt
    lower %= MOD
    upper %= MOD
    
answer = (lower.sum() + upper.sum()) % MOD
print(answer)


Measured memory_bytes: 13904
N,M=map(int,input().split())
AC=[False]*N
P=[0]*N
pena=0
for i in range(M):
  p,s=map(str,input().split())
  p=int(p)-1
  if s=='WA' and AC[p]==False:
    P[p] +=1
  elif s=='AC' and AC[p]==False:
    AC[p]=True
    pena += P[p]
answer=0
for i in range(N):
  if AC[i]==True:
    answer +=1
print(answer,pena)
  

Measured memory_bytes: 4596
#include<iostream>
using namespace std;
int main(){
    int W, H, x, y, r, a=0;
    cin >> W >> H >> x >> y >>r;
    if(a <= y - r && a <= x - r && y + r <= H && x + r <= W){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int maxn = 333;

int n,m,d,q;
int g[maxn][maxn];

map<int,pair<int,int>> mp;

int dist(int x, int y) {
  return abs(mp[x].first - mp[y].first) + abs(mp[x].second - mp[y].second);
}

vector<int> dp[maxn*maxn + maxn];

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

  cin>>n>>m>>d;
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      cin>>g[i][j];
      mp[g[i][j]] = {i,j};
    }
  }

  for (int r=1; r<=d; r++) {
    dp[r].push_back(0);  dp[r].push_back(0);
    for (int x=r+d; x<=n*m; x+=d) {
      int cur = dist(x-d, x) + dp[r].back();
      dp[r].push_back(cur);
    }
  }


  cin>>q;
  while (q--) {
    int x,y; cin>>x>>y;
    int r = y%d;
    if (r==0) r+= d;
    int j = (y+d-1)/d; int i = (x+d-1)/d;
    int tot = dp[r][j] - dp[r][i];
    cout<<tot<<'\n';
  }

    

  return 0;
}


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

int ans[100005][3];

int main(void)
{
    int n,k;
    cin >> n >> k;
    for(int i=0;i<(n+1)/2;i++,k++) ans[i*2][0] = k;
    for(int i=0;i<n/2;i++,k++) ans[i*2+1][0] = k;
    for(int i=0;i<n/2;i++,k++) ans[i*2+1][1] = k;
    for(int i=0;i<(n+1)/2;i++,k++) ans[i*2][1] = k;
    for(int i=0;i<n;i++,k++) ans[i][2] = k;
    for(int i=0;i<n;i++)
    {
        if(ans[i][0]+ans[i][1]>ans[i][2])
        {
            cout << "-1\n";
            return 0;
        }
    }
    for(int i=0;i<n;i++)
    {
        printf("%d %d %d\n",ans[i][0],ans[i][1],ans[i][2]);
    }
    return 0;
}

Measured memory_bytes: 3456
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> K;
	vector<vector<long long int>>div(K + 1, vector<long long int>(K + 1));
	div[0][0] = 1;
	for (int i = 1; i <= K; i++) {
		long long int sum = div[i - 1][0];
		for (int j = 1; j <= K; j++) {
			div[i][j] = sum;
			sum += div[i - 1][j];
			sum %= MOD;
		}
	}
	vector<vector<long long int>>dp(K + 2, vector<long long int>(N + 1));
	dp[0][0] = 1;
	for (int i = 1; i <= K + 1; i++) {
		long long int sum = dp[i - 1][0];
		for (int j = 1; j <= N; j++) {
			dp[i][j] = sum;
			sum += dp[i - 1][j];
			sum %= MOD;
		}
	}
	vector<long long int>ans(K + 1);
	for (int i = 1; i <= K; i++) {
		ans[i] += dp[i - 1][N - K] * div[i][K];
		ans[i] %= MOD;
		ans[i] += dp[i + 1][N - K] * div[i][K];
		ans[i] %= MOD;
		ans[i] += dp[i][N - K] * div[i][K];
		ans[i] %= MOD;
		ans[i] += dp[i][N - K] * div[i][K];
		ans[i] %= MOD;
	}
	for (int i = 1; i <= K; i++)cout << ans[i] << endl;
}

Measured memory_bytes: 62976
#include <iostream>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

int main () {
	long double a,b,h,m;
	cin>>a>>b>>h>>m;
	long double pi=acos(-1);
	long double x=(h+m/60)/12;
	long double y=m/60;
	long double kut;
	if(x>y){
		if(x-y<=0.5) kut=(x-y)*2*pi;
		else kut=(1+y-x)*2*pi;
	}
	else{
		if(y-x<=0.5) kut=(y-x)*2*pi;
		else kut=(1+x-y)*2*pi;
	}
	cout<<setprecision(15)<<sqrt(a*a+b*b-2*a*b*cos(kut));



return 0;
}



Measured memory_bytes: 4164
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <time.h>

#define rep(num)      for (long long _ = 0; _ < num; _++)
#define loop(i, num)  for (long long i = 0; i < num; i++)

using namespace std;

int n;

vector<bool> vis;

vector<vector<int>> nei, dis;

void bfs(int from, int mem) {
    
    queue<int> cur;
    
    cur.push(from);
    
    dis[mem][from] = 0;
    
    while (!cur.empty()) {
        
        int c = cur.front();
        
        vis[c] = 1;
        
        cur.pop();
        
        loop (i, nei[c].size()) {
            
            if (!vis[nei[c][i]]) {
                
                cur.push(nei[c][i]);
                
                dis[mem][nei[c][i]] = min(dis[mem][nei[c][i]], dis[mem][c] + 1);
                
            }
            
        }
        
    }
    
}

int main() {
    
    cin >> n;
    
    nei.resize(n + 1);
    
    vis.resize(n + 1);
    
    dis.resize(2, vector<int>(n + 1, 1e9));
    
    loop (i, n - 1) {
        
        int p1, p2;
        
        cin >> p1 >> p2;
        
        nei[p1].push_back(p2);
        
        nei[p2].push_back(p1);
        
    }
    
    bfs(1, 0);
    
    loop (i, n + 1) {
        
        vis[i] = 0;
        
    }
    
    bfs(n, 1);
    
    int f = 0, s = 0;
    
    for (int i = 1; i <= n; i++) {
        
        if (dis[0][i] > dis[1][i]) {
            
            ++s;
            
        } else {
            
            ++f;
            
        }
        
    }
    
    if (s >= f) {
        
        cout << "Snuke" << endl;
        
    } else {
        
        cout << "Fennec" << endl;
        
    }
    
}


Measured memory_bytes: 6540
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  ll n, k; cin >> n >> k;
  vll a(n), f(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  ll l = -1, r = a[n-1]*f[0]+1;
  while (r-l > 1) {
    ll c = (l+r)/2;
    ll s = 0;
    rep(i, n) s += max(0ll, a[i] - c/f[i]);
    if (s <= k) r = c;
    else l = c;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll A,B,N;
    cin>>A>>B>>N;
    /*for(ll i=0;i<=N;i++){
        printf("%d:%lld\n",A*i/B-i/B*A);
    }*/
    if(N<B){
        cout<<A*N/B<<endl;
    }else{
        cout<<A*(B-1)/B<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
main(){
	int n,m,p,q,r,x,y;
	vector<int>::iterator v,w,z;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int>t(1),u;
		
		for(t.push_back(r);m--;u.clear()){
			cin>>x>>y;
			v=upper_bound(t.begin(),t.end(),x);
			w=upper_bound(t.begin(),t.end(),y);
			
			if(w-t.begin()+1&1)u.push_back(0);
			u.push_back(0);
			for(z=w;z<t.end();++z)
				u.push_back(*z-y);
			
			if(t.end()-v&1)u.push_back(n-y);
			for(z=v;z<w;++z)
				u.push_back(*z-x+n-y);
			
			z=t.begin();
			if(w-t.begin()&1)++z;
			if(!z[1])z+=2;
			if(*z+n-x==u.back())++z,u.pop_back();
			for(;z<v;++z)
				u.push_back(*z+n-x);
			
			t.swap(u);
		}
		t.insert(upper_bound(t.begin(),t.end(),p-1),2,p-1);
		t.insert(lower_bound(t.begin(),t.end(),q),q);
		t.push_back(n);
		z=upper_bound(t.begin(),t.end(),p-1);
		if(z-t.begin()&1)--z;
		for(x=0;*z<q;
			x+=*z++-m)
			m=*z++;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <ctime>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	double x, y;
	cin >> x >> y;
	if (x > y) swap(x,y);
	double ans;
	if (y - x < 180){
		ans = (x + y) / 2;
	}else{
		ans = (360 + x + y) / 2;
		if (ans > 360) ans -= 360;
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int n;
vector<int> G[100001];


long long int dfs(int x){
  long long int ret=0;
  vector<long long int> temp;
  for(int i=0;i<G[x].size();i++){
    int u=G[x][i];
    temp.push_back(dfs(u));
  }
  sort(temp.begin(),temp.end(),greater<int>());
  for(int i=0;i<temp.size();i++){
    ret=max(temp[i]+i+1,ret);
  }
  return ret;
}
int main(){
  cin >> n;
  for(int i=2;i<=n;i++){
    int a;
    cin >> a;
    G[a].push_back(i);
  }
  cout << dfs(1) << endl;
  return 0;
}


Measured memory_bytes: 13568
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        
        
        
        
        
        
        public static void main(String[]args){
                int N=sc.nextInt();
                if(N>=195){
                        System.out.println(5);
                }else if(N>=189){
                        System.out.println(4);
                }
                else if(N>=165){
                        System.out.println(3);
                }
                else if(N>=135){
                        System.out.println(2);
                }else if(N>=105){
                        System.out.println(1);
                }else{
                        System.out.println(0);
                }
                
                


                
        }
        
        
        

		
	
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
int n,a[N],buc1[N],buc2[N];
int pre[N],suf[N],Ans=2e9;

int main() {
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i+=2)
		buc1[a[i]]++;
	for(int i=2;i<=n;i+=2)
		buc2[a[i]]++;
	for(int i=1;i<=100000;i++)
		pre[i]=max(pre[i-1],buc1[i]);
	for(int i=100000;i>=1;i--)
		suf[i]=max(suf[i+1],buc1[i]);
	//for(int i=1;i<=10;i++) cout<<pre[i]<<' ';puts("");
	for(int i=1;i<=100000;i++) {
		int ret=n/2-max(pre[i-1],suf[i+1]);
		Ans=min(Ans,ret+n/2-buc2[i]);
	}
	printf("%d\n",Ans);
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    
    vector<int> p(N);
    int cnt  = 0;
    rep(i, N)
    {
        cin >> p[i];
        if (p[i] != i +1)
        {
            ++cnt;
        }
    }
    
    if (cnt <= 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    
    
    return 0;
}


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


class Main {
    static ArrayList<Integer>[]g;
    static boolean[]vis;
    static int p;
    static int[]ans;
    static boolean dfs(int v){
        if(vis[v])return false;
        vis[v]=true;
        ans[p++]=v;
        for(int w:g[v]){
            boolean r=dfs(w);
            if(r)return true;
        }
        return true;
    }
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int m=sc.nextInt();
        g=new ArrayList[n];
        Arrays.setAll(g,x->new ArrayList<Integer>());
        for(int i=0;i<m;++i){
            int a=sc.nextInt()-1;
            int b=sc.nextInt()-1;
            g[a].add(b);
            g[b].add(a);
        }
        vis=new boolean[n];
        ans=new int[n];
        dfs(0);
        int[]ans2=Arrays.copyOf(ans,p);
        vis[0]=false;
        ans=new int[n];
        p=0;
        dfs(0);
        int[]ans3=Arrays.copyOf(ans,p);
        int[]outa=new int[ans2.length+ans3.length-1];
        for(int i=0;i<ans3.length;++i){
            outa[ans3.length-1-i]=ans3[i];
        }
        for(int i=1;i<ans2.length;++i)
            outa[ans3.length+i-1]=ans2[i];
        out.println(outa.length);
        for(int i=0;i<outa.length;++i)
            out.print((outa[i]+1)+(i==outa.length-1?"\n":" "));
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 74840
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

    int n,m;
	cin>>n>>m;
	vi in(n+1);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		in[a-1]++;
		in[b]--;
	}
	rep(i,n)in[i+1]+=in[i];
	int c=0;
	rep(i,n)if(in[i]==m)c++;
	cout<<c<<endl;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	
    public static void main(String args[]) throws Exception
    {
		int[] cnt=new int[105];
		
		int l1=sc.nextInt(),r1=sc.nextInt();
		
		for(int i=l1+1;i<=r1;i++)
		{
			cnt[i]++;
		}
		
		int l2=sc.nextInt(),r2=sc.nextInt(),res=0;
		
		for(int i=l2+1;i<=r2;i++)
		{
			if(cnt[i]>0)
			{
				res++;
			}
		}
		
		out.println(res);out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 21204
using System;
using System.IO;

class Program
{
	static void Main(string[] args)
	{
		int ans = 0;
		string S = Console.ReadLine();
		string T = Console.ReadLine();

		for (int i = 0; i < 3; i++) {
			if(S[i] == T[i]) {
				if(S[i] == 'C' || S[i] == 'S' || S[i] == 'R'){
					ans++;
				}
			}
		}

		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Membership Management
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);
			if (n == 0) break;

			Map<String, Set<String>> groups = new HashMap<>();
			String first = "";

			for (int i = 0; i < n; i++) {
				words = br.readLine().split("[:,.]");
				groups.put(words[0], new HashSet<>());
				for (int j = 1; j < words.length; j++) {
					groups.get(words[0]).add(words[j]);
				}
				if (i == 0) first = words[0];
			}

			//solve
			boolean changed;
			do {
				changed = false;
				for (String group : groups.keySet()) {
					if (!group.equals(first) && groups.get(first).contains(group)) {
						groups.get(first).remove(group);
						groups.get(first).addAll(groups.get(group));
						changed = true;
					}
				}
			} while (changed);

			System.out.println(groups.get(first).size());
		}
	}
}

Measured memory_bytes: 36048
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int x, a; cin >> x >> a;
	if(x < a) println("0");
	else println("10");
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 100;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    vector<int> v;
    for (int i = 1; i <= MAX; ++i) v.emplace_back(i);
    while (1) {
        int n, x;
        cin >> n >> x;

        if (n == 0 && x == 0) return 0;

        int ans = 0;
        rep(i,n)rep(j,i)rep(k,j) {
            if (v[i] + v[j] + v[k] == x) ans++;
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3140
# 371 ms, 27032 KB
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
 
for _ in range(q):
    bi, ci = list(map(int, input().split()))
    b.append(bi)
    c.append(ci)
#bc = [map(int, input().split()) for _ in range(q)]
#b, c = [list(i) for i in zip(*bc)]
 
dic = {}
for aa in a:
    dic[aa] = dic.get(aa, 0) + 1
 
s = sum(a)
for i in range(q):
    if b[i] not in dic:
        print (str(s))
        continue
    s += (c[i]-b[i]) * dic[b[i]]
    dic[c[i]] = dic.get(c[i], 0) + dic[b[i]]
    del dic[b[i]]
    print(s)

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

using namespace std;
using ll = long long;

void solve(ll A, ll B, ll C) {
  ll ans = max(0ll, C - A + B);
  cout << ans << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll C;
  cin >> C;
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long dp[10001][100][2];
int main()
{
    string K; cin >> K;
    vector<int> N;
    for (char c : K) N.push_back(c-'0');
    reverse(begin(N), end(N));
    int D; cin >> D;
    for (int i = 0; i < 10; i++) dp[0][i%D][0]++;
    for (int i = 0; i <= N[0]; i++) dp[0][i%D][1]++;
    for (int i = 1; i < N.size(); i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < D; k++) {
                (dp[i][(k+j)%D][0] += dp[i-1][k][0]) %= MOD;
            }
        }
        for (int j = 0; j <= N[i]; j++) {
            for (int k = 0; k < D; k++) {
                (dp[i][(k+j)%D][1] += dp[i-1][k][j==N[i]]) %= MOD;
            }
        }
    }
    cout << (dp[K.size()-1][0][1] + MOD - 1) % MOD << endl;
    return 0;
}

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

int main(){
  int k;
  cin>>k;
  vector<int>vec(32);
  vec ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<vec[k-1]<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 3007;
ll dp[MAXN][MAXN], a[MAXN];
int main()
{
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), dp[i][1] = a[i];
    for (int j = 2; j <= n; j++)
        for (int i = 1; i + j - 1 <= n; i++)
            dp[i][j] = max(-dp[i + 1][j - 1] + a[i], -dp[i][j - 1] + a[i + j - 1]);
    printf("%lld\n", dp[1][n]);
    return 0;
}

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

int main() {
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      int Z = S - (X + Y);
      if (Z >= 0 && Z <= K) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int n, k, q; cin >> n >> k >> q;
    vector<int> p(n);
    for (int i = 0; i < q; ++i) {
        int a; cin >> a;
        ++p[a - 1];
    }
    for (auto e : p) {
        if (0 < k - q + e) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}



Measured memory_bytes: 3788
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

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

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
	bool operator<(const Edge& e)const{return weight<e.weight;}
	bool operator>(const Edge& e)const{return weight>e.weight;}
};
typedef vector<vector<Edge> > Graph;

int Prim(const Graph& g,vector<Edge>& tree,int root=0)
{
	tree.clear();
	
	vi vis(g.size());
	priority_queue<Edge,vector<Edge>,greater<Edge> > pq;
	pq.push(Edge(-1,root,0));
	int res=0;
	while(pq.size()){
		Edge cur=pq.top(); pq.pop();
		if(vis[cur.dst])
			continue;
		vis[cur.dst]=true;
		res+=cur.weight;
		if(cur.src!=-1)
			tree.push_back(cur);
		foreach(e,g[cur.dst])
			pq.push(*e);
	}
	return res;
}

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n|m;){
		Graph g(n);
		rep(i,m){
			int s,d,w; scanf("%d%d%d",&s,&d,&w);
			g[s].push_back(Edge(s,d,w));
			g[d].push_back(Edge(d,s,w));
		}
		
		vector<Edge> tree;
		int res=Prim(g,tree);
		printf("%d\n",res);
	}
	
	return 0;
}

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

int main() {
  string s;
  int sum=0;
  cin >> s;
  
  for(int i=0; i < s.size(); i++){
    if(s.at(i) == '1')
      sum++;
  }
  
  cout << sum << endl;
  
	return 0;
}


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

unsigned long long gcd(unsigned long long a, unsigned long long b);
unsigned long long lcm(unsigned long long a, unsigned long long b);

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<unsigned long long> a(N);
  unsigned long long half_LCM = 1;
  bool exist = true;
  for (int i = 0; i < N; i++)
  {
    std::cin >> a.at(i);
    a.at(i) /= 2;
    half_LCM = lcm(half_LCM, a.at(i));
    if ((half_LCM / a.at(i)) % 2 == 0)
    {
      exist = false;
      break;
    }
    if (half_LCM > M)
    {
      exist = false;
      break;
    }
  }
  if (exist)
  {
    std::cout << (M - half_LCM) / (2*half_LCM) + 1 << std::endl;
  }
  else std::cout << 0 << std::endl;
}

/* ++++++++++ function ++++++++++ */
unsigned long long gcd(unsigned long long a, unsigned long long b)
{
  if(a < b) return gcd(b, a);
  unsigned long long r;
  while ((r=a%b))
  {
    a = b;
    b = r;
  }
  return b;
}

unsigned long long lcm(unsigned long long a, unsigned long long b)
{
  unsigned long long gcd_ab = gcd(a, b);
  return a/gcd_ab * b;
}


Measured memory_bytes: 1024
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var param = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var n = param[0];
    var c = param[1];
    var k = param[2];
    var t = Enumerable.Range(0, n).Select(_ => int.Parse(ReadLine()))
      .OrderBy(i => i).ToArray();

    var cnt = 0;
    var time = 0;
    var ride = 0;
    for(var i = 0; i < n; i++)
    {
      if(ride == 0)
      {
        time = t[i];
      }
      if(t[i] - time <= k)
      {
        ride++;
      }
      else
      {
        cnt++;
        time = t[i];
        ride = 1;
      }

      if(ride == c)
      {
        cnt++;
        ride = 0;
      }
    }

    var ans = cnt + (ride > 0 ? 1 : 0);
    WriteLine(ans);
  }
}

Measured memory_bytes: 20700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n <= 2) {
        cout << "-1\n";
    } else if (n % 3 == 0) {
        rep (i, n) {
            rep (j, n) {
                if (i / 3 == j / 3 && ((i % 3 == 0) ^ (j % 3 == 0))) cout << 'a';
                else cout << '.';
            }
            cout << "\n";
        }
    } else if (n == 7) {
        cout << "abb...a\n"
             << "a.a...a\n"
             << "bba...c\n"
             << "...abbc\n"
             << "...a.ab\n"
             << "...bbab\n"
             << "bbaacc.\n";
    } else if (n == 11) {
        cout << "bccaabbccaa\n"
             << "babb...abbc\n"
             << "ca.a...a.ac\n"
             << "cbba...bbab\n"
             << "baccbcc...b\n"
             << "ba.ab.b...a\n"
             << "accaccb...a\n"
             << "a...baacaab\n"
             << "b...b.bc.cb\n"
             << "b...aabaaca\n"
             << "ccaabbccbba\n";
    } else {
        int a, b;
        for (int i = n / 5; i >= 0; i--) {
            if ((n - 5 * i) % 4 == 0) {
                a = i;
                b = (n - 5 * i) / 4;
                break;
            } 
        }
        // eprintf("a=%d, b=%d\n", a, b);
        vector<string> s4 = {"aaca", "bbca", "acbb", "acaa"},
                       s5 = {"aacca", "c.bba", "cb..c", "ab..c", "accaa"};
        rep (i, n) {
            rep (j, n) {
                if (i / 5 == j / 5 && i / 5 < a) {
                    // cout << 1;
                    cout << s5[i % 5][j % 5];
                } else if ((i - 5 * a) / 4 == (j - 5 * a) / 4 && i - 5 * a >= 0 && j - 5 * a >= 0) {
                    // cout << 2;
                    cout << s4[(i - 5 * a) % 4][(j - 5 * a) % 4];
                } else {
                    // cout << 3;
                    cout << '.';
                }
            }
            cout << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
using ll = long long;
using namespace std;
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 2000020;
ll fac[MAX], inv[MAX], finv[MAX];

ll comb(int n, int k) {
	return (fac[n] * finv[n - k] % MOD) * finv[k] % MOD;
}

int r1, r2, c1, c2;

int main()
{
	cin >> r1 >> c1 >> r2 >> c2;
	fac[0] = inv[0] = finv[0] = 1;
	fac[1] = inv[1] = finv[1] = 1;
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}

	cout << (comb(r2 + c2 + 2, c2 + 1) - comb(r1 + c2 + 1, c2 + 1) - comb(r2 + c1 + 1, c1) + comb(r1 + c1, c1) + MOD) % MOD;
	return 0;
}

Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<((ll)n);i++)
#define rep1(i,n) for(ll i=1;i<=((ll)n);i++)
#define pb push_back
#define mp make_pair
#define int ll
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define meow(a) cout<<a<<" meow\n";
typedef pair<long long,long long> pii;
typedef vector<pii> vii;
const ll maxn=200005;
const ll MOD=998244353;
double mypow(ll a,ll b){
	double res=1;
	while(b){
		if(b&1) res=res*a;
		a=a*a;

		b>>=1;
	}
	return res;
}
ll t,n,m,k;

signed main()
{
    //IOS;
    //cin>>t;
    while(cin>>n>>k)
    {
        vector<ll> v;
        rep(i,n)
        {
            ll x;cin>>x;
            v.pb(x);
        }
        ll ans=0;
        rep(l,n+1)
        {
            rep(r,n+1)
            {
                if(l+r>min(n,k)) break;
                vector<int> choose;
                ll sum=0;
                for(int i=n-1;i>=n-r;i--)
                {
                    choose.pb(v[i]);
                    sum+=v[i];
                }
                for(int i=0;i<l;i++)
                {
                    choose.pb(v[i]);
                    sum+=v[i];
                }
                sort(choose.begin(),choose.end());
                ll cost=l+r;
                //cout<<sum<<"\n";
                for(auto i:choose)
                {
                    if(i<0&&cost<=k-1) {sum=sum-i;cost+=1;}
                    else break;
                }
                //cout<<l<<" "<<r<<" "<<sum<<"\n";
                ans=max(ans,sum);
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}


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

int main()
{
    ll N,K;
    cin >> N >> K;
    vector<ll> H(N);
    for(ll i = 0; i < N; i++)
    {
        cin >> H.at(i);
    }

    sort(H.begin(),H.end());
    reverse(H.begin(),H.end());

    ll count = 0;

    if(H.size() <= K)
    {
        cout << 0 << endl;
        return 0;
    }

    for(ll i = K; i < H.size(); i++)
    {
        count += H.at(i);
    }

    cout << count << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String [] args) {
		Scanner in = new Scanner(System.in);
		StringBuilder n = new StringBuilder(in.next());
		
		int count = 0;
		for(int i=n.length()-2;i>=0;i--) {
			if(n.charAt(i)!=n.charAt(i+1)) {
				count++;
				n.delete(i,i+2);
				if(i==n.length()) {
					i--;
				}
				
				
			}
		
	}
		
		System.out.println(count*2);
		
		
		
		
		
	}
	

}


Measured memory_bytes: 26172
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort()
cost = 0
for i in range(N):
    M -= AB[i][1]
    cost += AB[i][1]*AB[i][0]
    if M<=0:
        store_num = i
        break
if M<0:
    m = abs(M)
    cost -= m*AB[store_num][0]
print(cost)

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

const int N=1e5+20;

int h,n,a[N];

int main()
{
	scanf("%d%d",&h,&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);

	if(accumulate(a,a+n,0)>=h) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 640
import java.io.* ;

class Main {
	public static void main(String args[]) throws IOException {
		int number[];
		number = new int[2];

		BufferedReader input = 
			new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine();
		String strNum[]= str.split(" ");
 		
		for(int i = 0; i < 2; i++){
			number[i] = Integer.parseInt(strNum[i]);
			if(number[i] == 1) number[i] += 13; 
		}


	if(number[0] > number[1]){
		System.out.println("Alice");
	} else if (number[0] < number[1]) {
		System.out.println("Bob");
	}else if (number[0] == number[1]){
		System.out.println("Draw");
	}

	return ;
	}
}


Measured memory_bytes: 8148
N, M = map(int, input().split())

cities = {}
output = []
for i in range(M):
    x, y = map(int, input().split())
    cities[i+1] = [x,y]
    output.append(y)

ID = {}
county_old = 0
sorted_counties_years = sorted(cities.values())
for county,year in sorted_counties_years:
    if county_old == 0:
        county_old = county
        count = 1
        ID[year] = '{:06}{:06}'.format(county, count)
        count += 1
        continue
    elif county_old == county:
        ID[year] = '{:06}{:06}'.format(county, count)
        count += 1
    else:
        county_old = county
        count = 1
        ID[year] = '{:06}{:06}'.format(county, count)
        count += 1
for i in output:
    print(ID[i])

Measured memory_bytes: 49732
#include<stdio.h>
int main()
{
  int a=0,b=0,coin=0,i=0;
  
  scanf("%d %d",&a,&b);
  for(i=0;i<2;i++){
    if(b<a){
      coin=coin+a;
      a--;
    }
    else{
      coin=coin+b;
      b--;
    }
  }
  printf("%d\n",coin);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[1000],n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int p;
  cin>>p;
  for(int i=0;i<p;i++){
    int x,y,z;
    cin>>x>>y>>z;
    swap_ranges(a+x,a+y,a+z);
  }
  for (int i=0;i<n;i++){
    if(i!=0) cout<<" ";
    cout<<a[i];
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 3048
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

D, G = na()
p = []
c = []

for i in range(D):
    x, y = na()
    p.append(x)
    c.append(y)

ans = 9999999999999
for i in range(1<<D):
    score = 0
    ct = 0
    for j in range(D):
        if i >> j & 1:
            score += (p[j] * (j+1) * 100 + c[j])
            ct += p[j]
    for j in range(D-1, -1, -1):
        if i >> j & 1: continue
        if score >= G: break
        g = (j + 1) * 100
        got = (G - score) // g
        score += min(got, p[j]) * g
        ct += min(got, p[j])
    ans = min(ans, ct)
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll i,arr[5];
  for(i=0;i<5;i++){
    cin>>arr[i];
  }
  for(i=0;i<5;i++){
    if(arr[i]==0){
      cout<<i+1;
    }
  }
}

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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

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

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  } 
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}

void chmax(ll &a,const ll &b){
    if(a<b) a=b;
}
void chmin(ll &a,const ll &b){
    if(a>b) a=b;
}


int main()
{

    ll A,V,B,W,T;
    cin >>A >> V >> B >> W >>T;

    if(A<B){
        A += V*T;
        B += W*T;
        if(A<B){
            cout << "NO" <<endl;
        }else{
            cout <<"YES" << endl;
        }
    }else{
        A -= V*T;
        B -= W*T;
        if(A>B){
            cout << "NO" <<endl;
        }else{
            cout <<"YES" << endl;
        }
    }

  




    return 0;


}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;
template <typename T>
struct BIT {
  vector<T> bit;
  int size;
  BIT(int _size) : bit(vector<T>(_size + 1, 0)), size(_size) {}
  void add(int index, T value) {
    for (int i = index + 1; i <= size; i += (i & -i)) bit[i] += value;
  }
  T sum(int a, int b) {  //sum of[a,b)
    return sum(b) - sum(a);
  }
  T sum(int a) {  // sum of[0,a) = sum of bit[0]~bit[a]
    T ret = 0;
    for (int i = a; i > 0; i -= (i & -i)) ret += bit[i];
    return ret;
  }
};
class Solver {
 public:
  int n;
  vector<int> pw, pb;
  Solver(LL n) : n(n), pw(n), pb(n){};

  void solve() {
    for (int i = 0; i < 2 * n; ++i) {
      char c;
      int a;
      cin >> c >> a;
      if (c == 'B') {
        pb[--a] = i;
      } else {
        pw[--a] = i;
      }
    }
    vector<vector<int>> dp(n + 1, vector<int>(n + 1));
    vector<BIT<int>> bits(n + 1, BIT<int>(2 * n));
    BIT<int> tmp(2 * n);
    bits[0] = tmp;
    int cnt = 0;
    for (int w = 1; w <= n; ++w) {
      cnt += tmp.sum(pw[w - 1], 2 * n);
      tmp.add(pw[w - 1], 1);
      dp[0][w] = cnt;
      bits[w] = tmp;
    }
    for (int b = 1; b <= n; ++b) {
      dp[b][0] = dp[b - 1][0] + bits[0].sum(pb[b - 1], 2 * n);
      bits[0].add(pb[b - 1], 1);
      for (int w = 1; w <= n; ++w) {
        dp[b][w] = dp[b][w - 1] + bits[w - 1].sum(pw[w - 1], 2 * n);
        dp[b][w] = min(dp[b][w], dp[b - 1][w] + bits[w].sum(pb[b - 1], 2 * n));
        bits[w].add(pb[b - 1], 1);
      }
    }
    cout << dp[n][n] << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 47360
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n; cin >> n;
	string S[n];
	rep(i, n) cin >> S[i];
	int cnt[n][26] = {};
	rep(i, n) {
		rep(j, S[i].length()) {
			cnt[i][S[i][j] - 'a']++;
		}
	}
	rep(i, 26) {
		int tmp = 1000;
		rep(j, n) {
			tmp = min(tmp, cnt[j][i]);
		}
		while (tmp--) cout << (char)('a' + i);
	}
	cout << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  vector<int> height(n, 0);
  vector<int> maxh(n, 0);
  for(int i = 0; i < n; ++i) {
    cin >> height[i];
    if(i == 0) {
      maxh[i] = height[i];
    } else {
      maxh[i] = max(maxh[i - 1], height[i]);
    }
  }
  int result = 0;
  for(int i = 0; i < n; ++i) {
    if(maxh[i] <= height[i]) {
      result += 1;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256