akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi ans(n+1);
    for(int x = 1; x*x <= n; x++) {
        for(int y = 1; y*y <= n; y++) {
            for(int z = 1; z*z <= n; z++) {
                int now = x*x+y*y+z*z+x*y+y*z+z*x;
                if(now > n) continue;
                ans[now]++;
            }
        }
    }
    rep2(i,1,n+1) {
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 3608
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
s = [STR() for _ in range(n)]
lst = ['AC', 'WA', 'TLE', 'RE']
for i in lst:
    print(i, 'x', s.count(i))

Measured memory_bytes: 80188
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <complex>

using namespace std;

#define mod 1000000007

vector<long long int> factinv(2001);
vector<long long int> product_from_d(2001);

void setfactinv()
{
	vector<vector<long long int> > tmpv(30, vector<long long int>(2001));
	tmpv[0][0] = 1;
	for(int i = 1; i <= 2000; i++){
		tmpv[0][i] = (tmpv[0][i - 1] * i) % mod;
	}
	for(int i = 1; i < 30; i++){
		for(int j = 0; j <= 2000; j++){
			tmpv[i][j] = (tmpv[i - 1][j] * tmpv[i - 1][j]) % mod;
		}
	}
	for(int i = 0; i <= 2000; i++){
		long long int rest = mod - 2;
		long long int res = 1;
		for(int j = 29; j >= 0; j--){
			if(rest >= (1 << j)){
				rest -= (1 << j);
				res *= tmpv[j][i];
				res %= mod;
			}
		}
		factinv[i] = res;
	}
}

void setproduct(long long int d)
{
	product_from_d[0] = 1;
	for(int j = 1; j <= 2000; j++){
		product_from_d[j] = (product_from_d[j - 1] * ((d - j + 1) % mod)) % mod;
		// cout << j << " " << product_from_d[j] << endl;
	}
}

long long int comb(int i)
{
	// cout << product_from_d[d][i] << endl;
	return (product_from_d[i] * factinv[i]) % mod;
}

long long int dp[2001][2001] = {};

int main()
{
	long long int n, d, x;
	setfactinv();
	while(1){
		cin >> n >> d >> x;
		if(n == 0) break;
		setproduct(d);
		// dp[i][j] : i日かけてj枚のクッキーを食べる
		for(int i = 0; i < 2001; i++){
			for(int j = 0; j < 2001; j++){
				dp[i][j] = 0;
			}
		}
		for(int i = 1; i < x; i++){
			dp[1][i] = 1;
		}
		for(int i = 2; i <= min(d, n); i++){
			for(int j = 1; j <= n; j++){
				dp[i][j] = (dp[i - 1][j - 1] + dp[i][j - 1]) % mod;
				if(j >= x) dp[i][j] -= dp[i - 1][j - x] - mod;
				dp[i][j] %= mod;
				// cout << i << " " << j << " " << dp[i][j] << endl;
			}
		}
		long long int ans = 0;
		for(int i = 1; i <= min(d, n); i++){
			ans += (comb(i) * dp[i][n]) % mod;
			ans %= mod;
			// cout << i << " " << ans << endl;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 34524
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	int n;
	cin>>n;
	vecS st(n);
	rep(i,0,n)cin>>st[i];
	bool ok=true;
	rep(i,1,n)
	{
		rep(j,0,i)
		{
			if(st[j]==st[i])ok=false;
		}
		if(st[i][0]!=st[i-1].back())ok=false;
	}
	puts(ok?"Yes":"No");
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int mod=1e9+7;
int n,cnt;
ll modpow(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main(){
    map<pair<ll,ll>,pair<int,int> >m;
    cin>>n;
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        if(!a&&!b){cnt++;continue;}
        
        ll g=__gcd(a,b);
        a/=g,b/=g;
        
        if(b<0) a=-a,b=-b;
        
        if(a<=0) m[{b,-a}].second++;
        else m[{a,b}].first++;    
    }
    ll ans=1;
    for(auto u:m){
        ans=(ans*(modpow(2,u.second.first)+modpow(2,u.second.second)-1+mod)%mod)%mod;
    }
    cout<<(mod+ans+cnt-1)%mod;
    return 0;
}  

Measured memory_bytes: 15924
import math
n, d = map(int, input().split())
x = []
for _ in range(n):
    x.append(list(map(int, input().split())))

def is_int(x1, x2):
    dist = 0
    for i, j in zip(x1, x2):
        dist += (i-j)**2
    if round(math.sqrt(dist))**2==dist:
        return True
    else:
        return False

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        if is_int(x[i], x[j]):
            ans += 1

print(ans)

Measured memory_bytes: 3064
import math , sys

N , M = list(map(int, input().split()))
H = list(map(int, input().split()))
Es = [[] for _ in range(N)]
for i in range(M):
    A , B = list(map(int, input().split()))
    A -=1 ; B-=1
    Es[A].append(B)
    Es[B].append(A)
ans = 0
for i in range(N):
    Es[i] = list(set(Es[i]))
for i in range(N):
    if len(Es[i]) == 0:
        ans+=1
    else:
        Max = max( [ H[Es[i][j]] for j in range( len(Es[i]) ) ] )
        if H[i] > Max:
            ans+=1
print(ans)

Measured memory_bytes: 106508
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  string s = to_string(n);

  bool ans = false;
  if (s[0] == '7') ans = true;
  if (s[1] == '7') ans = true;
  if (s[2] == '7') ans = true;

  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3720
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		a[0] = Integer.parseInt(sc.next());
		a[1] = Integer.parseInt(sc.next());
		a[2] = Integer.parseInt(sc.next());
		int count = 0;
		while (true) {
			int max = 0;
			for (int i = 0; i < 3; i++)
				max = Math.max(max, a[i]);
			int c = 0;
			int[] index = new int[2];
			int i = 0;;
			for (int j = 0; j < 3; j++)
				if (a[j] == max)
					c++;
				else
					index[i++] = j;
			if (c == 3) {
				break;
			}
			else if (c == 2) {
				a[index[0]] += 2;
			}
			else {
				a[index[0]]++;
				a[index[1]]++;
			}
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

long long mgcd(long long x,long long m){
    if(x==m) return m;
    return mgcd(m,x%m);
}

int main(){
    string s;
    cin>>s;
    stack<char> sta;
    int ans=0;
    rep(i,s.size()){
        if(!sta.empty()){
            char a=sta.top();
            if(s[i]==a) sta.push(s[i]);
            else{
                sta.pop();
                ans++;
            }
        }
        else sta.push(s[i]);
    }
    cout<<2*ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>

using namespace std;
string hage, ginger;
int jiss, mojis;
int aho(string A)
{
	while (1)
	{
		for (int i = 1; i < mojis; i++)
		{
			string S;
			for (int k = A.find(hage.at(0), 0); k < mojis; k += i)
			{
				if (k == string::npos)return 0;
				S.append(1, A.at(k));
				if (S == hage)return 1;
			}
		}
		A[A.find(hage.at(0), 0)] = '*';
	}
	return 0;
}


int main()
{
	int n;

	cin >> n >> hage;
	jiss = hage.size();
	int ans=0;
	while (n--)
	{
		cin >> ginger;
		mojis = ginger.size();
		ans += aho(ginger);
	}
	cout << ans << endl;
	return 0;

}

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

int main(){
  int N;cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A.at(i);
  sort(A.begin(),A.end());
  
  int n=A.at(N-1);
  A.pop_back();
  
  vector<pair<int,int>>p(N-1);
  for(int i=0;i<N-1;i++){
    if(n/2<A.at(i)){
      p.at(i).first=n-A.at(i);
    }
    else
      p.at(i).first=A.at(i);
    
    p.at(i).second=A.at(i);
  }
  
  sort(p.begin(),p.end());
  
  int r=p.at(N-2).second;
  
  cout<<n<<" "<<r;
}

Measured memory_bytes: 1408
A,B=map(int,input().split())
if A%2==0:
  X=int(A/0.08)
else:
  X=int(A/0.08)+1
Y=int(B/0.10)
if (A+1)%2==0:
  P=int((A+1)/0.08)
else:
  P=int((A+1)/0.08)+1
Q=int((B+1)/0.10)
if X<Y:
  if Y<P:
    print(Y)
  else:
    print(-1)
else:
  if X<Q:
    print(X)
  else:
    print(-1)

Measured memory_bytes: 3064
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,sub;
    ll h,w;
    string str1;
    ll dp[230000];
    rep(i,220000) dp[i]=INF;
    ll k;
    cin>>n>>k;
    vector<ll> v(n+1);
    rep(i,n) cin>>v[i+1];
    //v[0]=0;
    dp[0]=INF;
    dp[1]=0;
    v[0]=INF;
    for(ll i=2;i<=k;i++){
        for(ll j=0;j<i;j++){
        dp[i]=min(dp[i],abs(v[i]-v[i-j])+dp[i-j]);
        //dp[i]=min(dp[i],abs(v[i]-v[i-j])+dp[i-j]);
        }
        //cout<<i<<" "<<dp[i]<<" "<<endl;
    }
    for(ll i=k+1;i<=n;i++){
        for(ll j=i-k;j<i;j++){
        dp[i]=min(dp[i],abs(v[i]-v[j])+dp[j]);
        //dp[i]=min(dp[i],abs(v[i]-v[i-j])+dp[i-j]);
        }
        //cout<<i<<" "<<dp[i]<<" "<<endl;
    }

    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 2816
n = int(input())
a = []
#print('n a',n,a)
for i in range(n):
        a.append(int(input()))
#print('As',a)
max1 = max(a)
location1 = a.index(max1)
#print('1st MAX',max1,'INDEX',location1)
a.remove(a[location1])
max2 = max(a)
#print('2nd MAX',max2)
if max1 == max2:
        #print('1=2')
        for i in range(n):
                print(max1)
else:
        #print('1!=2')
        for i in range(n):
                if i == location1:
                        #print('max2')
                        print(max2)
                else:
                        #print('max1')
                        print(max1)


Measured memory_bytes: 12520
/*
[abc166] E - This Message Will Self-Destruct in 5s
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 2e5;

int N;
int A[MAX_N];

ll solve() {
    ll ans = 0;
    map<int, int> cnt;
    for (int i = 0; i < N; i++) {
        ans += cnt[i - A[i]];
        cnt[i + A[i]]++;
    }
    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 21436
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int n; // countはやめてみる
	cin >> n;
	int a[n];

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

	sort(a, a+n);

	for (int i = n % 2; i < n - 1; i += 2) // これさえあれば
	{
		if (a[i] - a[i + 1] != 0) // 合わなかったときだけ判定すればいい
		{
			cout << 0 << endl;
			exit(0);
		}
	}
	// 求めたい数は2の(n/2)乗
	// n = 2n' の時のn/2と n = 2n'+1 の時の(n-1/2)は同義なので省略
	long long result = 1;
	for (int i = 0; i < n/2; ++i)
	{
		result *= 2;
		result %= 1000000007;
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

    int x = in.nextInt();
    for (int i = 3; i <= x; i++) {
      if (i % 3 == 0) {
        System.out.print(" " + i);
      }
      else {
        int t = i;
        while (true) {
          if (t % 10 == 3) {
            System.out.print(" " + i);
            break;
          }
          else if (t < 3) {
            break;
          }
          t /= 10;
        }
      }
    }
    System.out.println();
  }
}

Measured memory_bytes: 28716
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int IMPOSSIBLE = -1;
        boolean isPossible = false;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int unbreakNum = 1;
        int unbreakCount = 0;

        for (int i = 0; i < n; i++) {
            if (sc.nextInt() == unbreakNum) {
                isPossible = true;
                unbreakCount++;
                unbreakNum++;
            }
        }

        if (!isPossible) {
            System.out.println(IMPOSSIBLE);
        } else {
            System.out.println(n - unbreakCount);
        }
    }
}

Measured memory_bytes: 63664
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
long long dp[101][100001],mx;
int main(void)
{
	int i,j,n,ww,w[101],v[101],w1;
	scanf("%d %d",&n,&ww);
	for(i=0;i<n;i++)	scanf("%d %d",&w[i],&v[i]);
	for(i=0;i<=n;i++)	{
		for(j=0;j<=ww;j++)	{
			dp[i][j]=-1;
		}
	}
	dp[0][0]=0;
	for(i=0;i<n;i++)	{
		for(j=0;j<=ww;j++)	{
			if(dp[i][j]!=-1)	{
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				w1=j+w[i];
				if(w1<=ww)	{
					dp[i+1][w1]=max(dp[i+1][w1],dp[i][j]+v[i]);
				}
			}
		}
	}
	mx=-1;
	for(i=0;i<=ww;i++)	mx=max(mx,dp[n][i]);
	printf("%lld\n",mx);
	return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

const int P = 1000000007; //shuoud be prime

typedef unsigned long long LL;

LL Combination(LL n, LL r){
	if(n < 0 || r < 0 || r > n) return 0;

	if(n - r < r) r = n - r;
	if(r == 0) return (LL)1;
	if(r == 1) return (LL)n;

	LL *numerator   = (LL*)calloc(r, sizeof(LL));
	LL *denominator = (LL*)calloc(r, sizeof(LL));
	if(numerator == NULL || denominator == NULL) return 0;

	for(LL i=0; i<r; i++){
		numerator[i] = n - r + 1 + i;
		denominator[i] = i + 1;
	}

	for(LL p=2; p<=r; p++){
		LL pivot = denominator[p-1];
		if(pivot > 1){
			LL offset = (n - r) % p;
			for(LL k=p-1; k<r; k+=p){
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	LL res = 1;
	for(LL i=0; i<r; i++){
		if(numerator[i]){
			res *= numerator[i];
			res = res % P;
		}
	}
	res = res % P;
	if(res < 0) res += P;
	return res;
}

long long n, a, b;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n >> a >> b;

	long long C = 100000;
	long long powC = 1;
	for(int i=1; i<=C; i++){
		powC = powC * 2;
		powC = powC % P;
	}
	long long q = n / C;
	long long r = n % C;
	// n = q*C + r
	long long ans = 1;
	for(int i=0; i<q; i++){
		ans = ans * powC;
		ans = ans % P;
	}
	for(int i=0; i<r; i++){
		ans = ans * 2;
		ans = ans % P;
	}
	ans -= 1;

	ans -= Combination(n, a);
	ans = ans % P;
	if(ans < 0) ans += P;

	ans -= Combination(n, b);
	ans = ans % P;
	if(ans < 0) ans += P;

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9900
#include <bits/stdc++.h>
#define rep( i, n ) for (ll i = 0; i < ( ll )(n); i++)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;



int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    rep(i,k){
        if(b<=a) b*=2;
        else if(c<=b) c*=2;
    }
    if(a<b&&b<c)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3628
#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(int 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 <int,int> P;
typedef long double ld;

constexpr int MOD = 1000000007;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 200001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_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;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    com_init();
    int n, m, k, x;
    cin >> n >> m >> k;
    x = n * m;
    int sum = 0, s = 0, t = 0;
    rep (i, n) {
        int a = com_mod(n - i, 2), b = com_mod(i + 1, 2);
        eprintf("%d %d\n", a, b);
        s = mod(s + mul_mod(mul_mod(m, m), mod(a + b)));
    }
    rep (i, m) {
        int a = com_mod(m - i, 2), b = com_mod(i + 1, 2);
        eprintf("%d %d\n", a, b);
        t = mod(t + mul_mod(mul_mod(n, n), mod(a + b)));
    }
    sum = div_mod(mod(s + t), 2);
    eprintf("%d %d %d\n", s, t, sum);
    eprintf("%lld*%lld/%lld\n", com_mod(k, 2), com_mod(x, k), com_mod(x, 2));
    cout << div_mod(mul_mod(sum, mul_mod(com_mod(k, 2), com_mod(x, k))), com_mod(x, 2)) << "\n";
    return 0;
}

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

int main()
{
  int s;
  cin >> s;
  if (s == 25) {
    cout << "Christmas" << endl;
  } else if (s == 24) {
    cout << "Christmas Eve" << endl;
  } else if (s == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else {
    cout << "Christmas Eve Eve Eve" << endl;
  }
}


Measured memory_bytes: 888
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		long k = Long.parseLong(sc.next());
		
		int []a = new int [n+1];
		
		for(int i = 0 ; i < n ;i++) {
			a[i+1] = Integer.parseInt(sc.next());
		}	
		int now = 1;
		List <Integer> list = new ArrayList <Integer>();
		Set <Integer> set = new HashSet<Integer>();
		list.add(now);
		set.add(now);
		
		while(true) {
			int next = a[now];
			if(set.contains(next)) {
				list.add(next);
				break;
			}
			set.add(next);
			list.add(next);
			now = next;
			if(set.size() == k+1) {
				System.out.println(next);
				return;
			}
		}
		
		int m = list.size();
		int id = -1;
		int last = list.get(m-1);
		
		
		for(int i = 0 ; i < m ; i++) {
			if(last == list.get(i)) {
				id = i;
				break;
			}
		}
		
		int mod = m - id - 1;
		int []ren = new int [m - id - 1];
		for(int i = id ; i < m-1  ;i++) {
			ren[i-id] = list.get(i);
		}
		
		int p = (int)((k-id) % mod);
		
		System.out.println(ren[p]);
		
	}

}


Measured memory_bytes: 63084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,count=0;
  cin>>a;
  vector<int> data(a);
  
  for(int i=0;i<a;i++){
    cin>>data.at(i);
  }
  
  bool ending=false;
  
  while(true){
    
    for(int j=0;j<a;j++){
      if(data.at(j)%2==1){
        ending=true;
        break;
      }
      else if(data.at(j)%2==0){
      data.at(j)/=2;      
      if(j==a-1){
        count++;
      }
      }
    }  
    
    if(ending==true){
      break;      
    }
  }
  
    cout<<count<<endl;
}

Measured memory_bytes: 3660
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#ifdef BOI
#include "debug.h"
#else
#define debug(args...)
#endif
#define endl '\n'
using ll = long long;
using namespace std;

int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  ll n; cin >> n;
  if(n&1) {
    cout << "0";
  } else {
    ll ans = 0;
    n /= 2;
    while(n != 0) {
      ans += n/5;
      n /= 5;
    }
    cout << ans;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

long Euclid(long num,long C,long D){
  
  long temp = 0;
  temp += num / C;
  temp += num / D;
  
  long x = C * D;
  if(C < D){
    long tmp = C;
    C = D;
    D = tmp;
  }
  
  long r = C % D;
  while(r != 0){
    C = D;
    D = r;
    r = C % D;
  }

  temp -= num / (x/D);
  
  return temp;
}

int main(){
 
  long A,B,C,D;
  cin >> A >> B >> C >> D;
  
  long temp1 = Euclid(B,C,D);
  long temp2 = Euclid(A - 1,C,D);
  
  cout << (B - A + 1) - (temp1 - temp2) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<string>
#include<sstream>
#include<algorithm>
#include<iterator>
using namespace std;

string get_str(const int& n) {
	ostringstream buff;
	if(n % 3 != 0 && n % 5 != 0) {
		buff << n;
	}
	else {
		if(n % 3 == 0) {
			buff << "Fizz";
		}
		if(n % 5 == 0) {
			buff << "Buzz";
		}
	}
	return buff.str();
}

int main() {
	bool mem[1000];
	string buff;
	int m, n, ite, bf;

	while(cin >> m >> n) {
		if(m == 0 && n == 0) break;
		
		for(int i = 0; i < m; ++i) { mem[i] = true; }
		ite = 0;
		bf = 1;
		for(int i = 1; i <= n; ++i){
			cin >> buff;
			buff != get_str(i) && ite != bf ? mem[ite] = false : bf = ite;

			while(++ite < m ? !mem[ite] : !mem[ite = 0]);
		}
		ite = 0;
		while(!mem[ite]) { ++ite; }
		while(1) {
			cout << ite + 1;
			while(!mem[++ite]);
			if( !(ite < m) ) { break; }
			cout << " ";
		}
		cout << endl;
	}


}

Measured memory_bytes: 1228
from numba import njit
import numpy as np
s = np.array(list(map(lambda x: -1 if x == '?' else int(x), input())))
@njit
def test(c):
    # current point can be seen as xth smallest val, where x can be any value in [a, b] (subset of [0, c])
    # a <= b
    a, b = 0, c
    ok = True
    discrete = False # when True x = a, a+2, ..., b-2, b
    for si in s:
        if si == 1:
            if a == b == c:
                return False
            a += 1
            b += 1
            if b > c:
                b = c - 1 if discrete else c
        elif si == 0:
            if a == b == 0:
                return False
            a -= 1
            b -= 1
            if a < 0:
                a = 1 if discrete else 0
        else:
            if a == b == 0:
                a = b = 1
            elif a == b == c:
                a = b = c - 1
            elif a == b:
                discrete = True
                a -= 1
                b += 1
            else:
                a -= 1
                b += 1
                if a < 0:
                    a = 1 if discrete else 0
                if b > c:
                    b = c - 1 if discrete else c
    return True

l, r = 0, s.size
while r - l > 1:
    c = (l + r) // 2
    if test(c):
        r = c
    else:
        l = c
print(r)


Measured memory_bytes: 117868
#include<stdio.h>
#define Max 100

int main()
{

  int i,j,x,N,A[Max],count=0,minj=0;

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

  for(i=0;i<=N-1;i++){
    minj = i;
    for(j=i;j<=N-1;j++){
      if(A[j]<A[minj]) minj = j;
    }
    if(i!=minj){
      x = A[i];
      A[i] = A[minj];
      A[minj] = x;
      count++;
    }
  }
  
  
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1) printf(" ");
  }
  
  printf("\n%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int mod = 1e9+7;
const int N = 2e5+1;
int fact[N], inv[N];

int mul(int a, int b) { return 1ll*a*b % mod; }

int expmod(int b, int e, int m = mod) {
    int ans = 1;
    while (e) {
        if (e&1) ans = mul(ans, b);
        b = mul(b, b);
        e /= 2;
    }
    return ans;
}

int ncr(int n, int r, int m = mod) {
    return mul(fact[n], mul(inv[r], inv[n-r]));
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    fact[0] = inv[0] = 1;
    forn(i, 1, N) {
        fact[i] = mul(fact[i-1], i);
        inv[i] = expmod(fact[i], mod-2);
    }
    
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    
    int ans = ncr(n+m-2, m-1);
    
    int i = n-a-1;
    forn(j, 0, b) {
        int tot = mul(ncr(i+j, j), ncr(a+m-j-2, m-j-1));
        ans = (ans-tot+mod) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5204
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

s = input()

ans = inf
tmp = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] != '0':
            tmp+=1
    else:
        if s[i] != '1':
            tmp+=1
ans = min(ans, tmp)
tmp=0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] != '1':
            tmp+=1
    else:
        if s[i] != '0':
            tmp+=1
ans = min(ans, tmp)
print(ans)

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

const int MAX_N = 200005;
int N;
std::pair<int64_t, int64_t> coords[MAX_N];



int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld %lld", &coords[i].first, &coords[i].second);
  }
  std::vector<std::pair<int64_t, int64_t>> rem;
  std::sort(coords, coords + N, [](const auto& a, const auto& b) {
    if (a.first + a.second != b.first + b.second) return a.first + a.second < b.first + b.second;
    if (a.first != b.first) return a.first < b.first;
    return a.second < b.second;
  });
  rem.push_back(coords[0]);

  std::sort(coords, coords + N, [](const auto& a, const auto& b) {
    if (a.first + a.second != b.first + b.second) return a.first + a.second > b.first + b.second;
    if (a.first != b.first) return a.first < b.first;
    return a.second < b.second;
  });
  rem.push_back(coords[0]);

    std::sort(coords, coords + N, [](const auto& a, const auto& b) {
    if (a.first - a.second != b.first - b.second) return a.first - a.second < b.first - b.second;
    if (a.first != b.first) return a.first < b.first;
    return a.second < b.second;
  });
  rem.push_back(coords[0]);

    std::sort(coords, coords + N, [](const auto& a, const auto& b) {
    if (a.first - a.second != b.first - b.second) return a.first - a.second > b.first - b.second;
    if (a.first != b.first) return a.first < b.first;
    return a.second < b.second;
  });
  rem.push_back(coords[0]);


  int64_t best = 0;
  for (auto a : rem) {
    for (int i = 0; i < N; ++i) {
      auto b = coords[i];
      int64_t dist = std::abs(a.first - b.first) + std::abs(a.second - b.second);
      best = std::max(dist, best);
    }
  }
  printf("%lld\n", best);
}


Measured memory_bytes: 6912
#include <iostream>

using namespace std;

int main()
{
   int S, h, m, s;
   cin >> S;
   h = S / 3600;
   m = (S - h*3600)/60;
   s = S - h*3600 - m*60;
   cout << h << ":" << m << ":" << s <<endl; 
   
   return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    ll n, d;
    cin >> n >> d;
    vector<ll> x(n);
    vector<ll> y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }

    ll ans = 0;
    rep(i, n) {
       ll dist2 = x[i] * x[i] + y[i] * y[i];
        if (dist2 <= (d*d)) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6420
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>


int main(void)
{
	int a, b, c, min, cen, max;

	scanf("%d %d %d", &a, &b, &c);

	if (a >= b && a >= c){
		max = a;
	}
	if (b >= a && b >= c){
		max = b;
	}
	if (c >= a && c >= b){
		max = c;
	}
	
	if (a <= b && a <= c){
		min = a;
	}
	if (b <= a && b <= c){
		min = b;
	}
	if (c <= a && c <= b){
		min = c;
	}

	if ((a >= b && a <= c) || (a >= c && b >= a)){
		cen = a;
	}
	if ((b >= c && a >= b) || (b >= a && c >= b)){
		cen = b;
	}
	if ((c >= a && b >= c) || (a >= c && c >= b)){
		cen = c;
	}

	printf("%d %d %d\n", min, cen, max);

	return 0;
}

Measured memory_bytes: 1024
import sys
import heapq
import copy
import numpy as np
from collections import deque

md=10**9+7

def modinv(a,m):
    return pow(a,m-2,m)

def modFact(n,k):
    ret=1
    for i in range(k):
        enum=(n-i)%md
        denum=modinv(i+1,md)

        ret=(ret*(enum*denum)%md)%md
    
    return (ret+md)%md
        

n,a,b=list(map(int,input().strip().split()))

print((pow(2,n,md)-1-modFact(n,a)-modFact(n,b)+md)%md)



Measured memory_bytes: 14472
#include<cstdio>
#include<cmath>

bool isPrime(int n){
    if(n == 2) return true;
    if(n < 2 || n%2==0) return false;
    for(int i = 3; i <= sqrt(n); i+=2){
        if(n%i == 0) return false;
    }
    return true;
}

int main(){
    int count=0;
    int n, a; scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a);
        if(isPrime(a)){ count++;}
    }
    printf("%d\n", count);
}



Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,n;
    cin>>a>>b>>n;
    if(a==1||b==1)
    {
    	cout<<0<<endl;
	}
    else
    {
    	if(b<=n)
    	{
    		ll x=b-1;
    		cout<<a*x/b-a*(x/b)<<endl;
		}
    	else
    	{
    		ll x=n;
    		cout<<a*x/b-a*(x/b)<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(a);
        llin(p);
        sal((a*3+p)/2)
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=0; cin>>n;
    vector<ll> a(3*n,0);
    rep(i,3*n) cin>>a[i];
    sort(al(a)); reverse(al(a));
    rep(i,n) ans+=a[2*i+1];
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<(max({a,b,c})!=c&&min({a,b,c})!=c?"Yes":"No");}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = [[] for _ in range(N + 1)]

for i in range(M):
    p, y = map(int, input().split())
    a[p].append((y, i))

ans = [None for _ in range(M)]
for p in range(1, N + 1):
    for e, (y, i) in enumerate(sorted(a[p], key=lambda x: x[0]), 1):
        ans[i] = str(p).zfill(6) + str(e).zfill(6)

for i in range(M):
    print(ans[i])


Measured memory_bytes: 35940
#include <stdio.h>
const int N = 15;

int main()
{
	int a[N]={0};
	for(int i = 0; i <= 9; i++)
	{
		scanf("%d", &a[i]);
	}
	for(int i = 0; i <= 9; i++)
	{
		for(int j = i; j <= 9; j++)
		{
			if(a[i] < a[j])
			{
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	for(int i = 0; i < 3; i++)
	{
		printf("%d\n", a[i]);
	}
	
	return 0;
}


Measured memory_bytes: 2616
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		double a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
		double x = 0, y = 0;
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			a = scan.nextDouble();
			b = scan.nextDouble();
			c = scan.nextDouble();
			d = scan.nextDouble();
			e = scan.nextDouble();
			f = scan.nextDouble();
			y = (a * f - c * d) / (-b * d + e * a);
			x = (c - b * y) / (a);
			//y???????±????????????¨??¨??????

			System.out.println(String.format("%.3f", x) + " "
					+ String.format("%.3f", y));
		}
	}
}

Measured memory_bytes: 20544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};



int main() {
    ll X,Y;

    cin>>X>>Y;
    ll ans=0;
    while(1){
        ans++;
        X*=2;
        if(X>Y) break;
    }

    cout<<ans<<endl;
    return 0;
    

}


Measured memory_bytes: 3640
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<stack>
#include<set>
using namespace std;
int a[200005],b[200005],n,m,p1,p2,ans;
long long k,c[200005],d[200005];
int main()
{
	cin>>n>>m>>k;
	p1=n;
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		c[i]=c[i-1]+a[i];
		if (c[i]>k && p1==n)
			p1=i-1;
	}
	for (int i=1;i<=m;++i)
	{
		scanf("%d",&b[i]);
		d[i]=d[i-1]+b[i];
	}
	for (int i=p1;i>=0;--i)
	{
		while (c[i]+d[p2]<=k && p2<=m) ++p2;
		--p2;
		ans=max(ans,p2+i);
	}
	cout<<ans;
	return 0;
}

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

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int h, w; cin >> h >> w;
    vector<vector<int> > lis(h, vector<int>(w, 0));
    vector<string> ans;
    REP(i, 0, h){REP(l, 0, w){cin >> lis[i][l];}}
    REP(i, 0, h){
        REP(l, 0, w-1){
            if(lis[i][l] % 2 == 1){
                lis[i][l+1]++;
                lis[i][l]--;
                string s = to_string(i+1) + " " + to_string(l+1) + " " +to_string(i+1) + " " + to_string(l+1+1);
                ans.pb(s);
            }
        }
    }
    REP(i, 0, h-1){
        if(lis[i][w-1] % 2 == 1){
            lis[i][w-1]--;
            lis[i+1][w-1]++;
            string s = to_string(i+1) + " " + to_string(w) + " " +to_string(i+1+1) + " " + to_string(w-1+1);
            ans.pb(s);
        }
    }
    int N = ans.size();
    cout << N << endl;
    REP(i, 0, N){
        cout << ans[i] << endl;
    }
}

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

int main(){
	
	int N;
    vector<int> A,B,C;

    cin >> N;
    for (int i = 0 ; i < N; i++){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    for (int i = 0 ; i < N; i++){
        int tmp;
        cin >> tmp;
        B.push_back(tmp);
    }
    for (int i = 0 ; i < N-1; i++){
        int tmp;
        cin >> tmp;
        C.push_back(tmp);
    }

    int sum = 0;
    int tmp = -1;
    for (int i = 0 ; i < N; i++){
        sum+=B[i];
        
        if (i>=1&&A[i]-A[i-1]==1){
            sum+=C[A[i-1]-1];
           // cout << i << endl;
        }
       
    }
    cout << sum << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 998244353;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

int fact[MAX_N];
int ifact[MAX_N];

int power(int x, int n) {
	int res = 1LL;
	while (n > 0) {
		if (n & 1) (res *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}
	return res % MOD;
}

int inv(int x) {
	return power(x, MOD - 2);
}

int nCr(int n, int r) {
	if (n < 0 || r < 0 || r > n) return 0;
	if (r > n / 2) r = n - r;
	return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}


// ABC066 D
signed main() {
  INIT;
	VAR(int, n, a, b, k);
	
	fact[0] = ifact[0] = 1LL;
  FOR(i, 1, MAX_N) {
    fact[i] = (fact[i - 1] * i) % MOD;
		ifact[i] = inv(fact[i]);
  }
	int ans = 0;
	REP(i, n + 1) {
		int t = (k - a * i) % b;
		if (t != 0) continue;
		int p = i, q = (k - a * i) / b;
		/*
		debug(p);
		debug(q);
		debug(nCr(n, p));
		debug(nCr(n, q));
		*/
		(ans += nCr(n, p) * nCr(n, q)) %= MOD;
	}
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
	private static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {
		String w = scanner.next();
		int length = w.length();
		if (1 <= length && length <= 100) {
			char[] chars = w.toCharArray();
			for (int i = 0; i < chars.length; i++) {
				if (chars[i] == 'A') continue;
				for (int j = i + 1; j < chars.length; j++) {
					if (chars[i] == chars[j]) {
						chars[i] = 'A';
						chars[j] = 'A';
						break;
					}
				}
			}
			for (int i = 0; i < chars.length; i++) {
				if (chars[i] != 'A') {
					System.out.println("No");
					return;
				}
			}
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 9424