akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979

typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 200000;
const int ADD = 500107;

int n;
int A[MAX];
Int R[MAX][2];

int main()
{
	//freopen("in.txt", "r", stdin);
	
	cin >> n;
	FOR (i,0,n)
	    scanf("%d", &A[i]);
	
	R[1][0] = A[0]/2;
	if (A[0])
	    R[1][1] = (A[0]-1)/2 + 1;
	
	FOR (i,1,n-1)
    	FOR (b,0,2)
    	{
    	    Int val = R[i][b];
    	    FOR (c,0,2)
    	    {
    	        Int d = A[i]-b-c;
    	        if (d < 0) continue;
    	        
    	        R[i+1][c] = max(R[i+1][c], val + d/2 + c);
    	    }
    	}
    	
    Int res = R[n-1][0] + A[n-1]/2;
    if (A[n-1])
        res = max(res, R[n-1][1] + (A[n-1]-1)/2);
        
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 2176
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll int n,m;
		cin>>n>>m;
		ll int dp[n+1];
		bool isb[n+1];
		memset(isb,0,sizeof(isb));
		while(m--)
		{
			ll int tmp;
			cin>>tmp;
			isb[tmp]=1;
		}
		dp[0]=1;
		for(ll int i=1;i<=n;i++)
		{
			if(!isb[i])
			{
				ll int tmp=dp[i-1];
				if(i-2>=0) tmp=(tmp+dp[i-2])%hell;
				dp[i]=tmp;
			}
			else
			{
				dp[i]=0;
			}
		}
		cout<<dp[n];
	}
	return 0;
}

Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0 for i in range(n + 1)]

for i in range(n, 0, -1):
    if i > n // 2:
        b[i] = a[i]
    else:
        s = 0
        for j in range(2, n // i + 1):
            if i * j > n:
                break
            s += b[i * j]
        mod = s % 2
        if mod == 0:
            b[i] = a[i]
        else:
            b[i] = 1 - a[i]

ans = sum(b)
print(ans)
if ans > 0:
    print(" ".join([str(i) for i, x in enumerate(b) if x == 1]))

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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000000

using namespace std;
#define prime 1000000007

const ll N = 300005;

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int n;


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

	printf("%d\n", 180*n-360);


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

using PII = pair<int, int>;

vector<int> dx = {1, 0, -1,  0};
vector<int> dy = {0, 1,  0, -1};

int h, w;
vector<string> s;
vector<vector<int>> memo;

void show_memo() {
	printf("\n");
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			printf("%2d ", memo[i][j]);
		}
		printf("\n");
	}
	printf("\n");
}

void walk(int sy, int sx, int num) {
	queue<PII> que;
	que.push(make_pair(sy, sx));
	memo[sy][sx] = num;

	while (!que.empty()) {
		auto p = que.front();
		que.pop();

		int y = p.first;
		int x = p.second;

		for (int i = 0; i < 4; i++) {
			int ny = y + dy[i];
			int nx = x + dx[i];


			if (nx < 0 || w <= nx || ny < 0 || h <= ny) {
				continue;
			}
// printf("(%d %d: %c %d) dir %d -> (%d %d: %c %d)\n",
// 	y, x, s[y][x], memo[y][x], i,
// 	ny, nx, s[ny][nx], memo[ny][nx]);

			if (memo[ny][nx] != 0 || s[ny][nx] == s[y][x]) {
// printf("continue\n");
				continue;
			}
// printf("push\n");

			que.push(make_pair(ny, nx));
			memo[ny][nx] = num;
		}
	}
}

int main() {
	cin >> h >> w;

	s.assign(h, "");
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	memo.assign(h, vector<int>(w, 0));

	int num = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (memo[i][j] != 0 || s[i][j] == '.') {
				continue;
			}

			num++;
			walk(i, j, num);
		}
	}

	vector<int> blacks(num+1, 0), whites(num+1, 0);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int n = memo[i][j];
			s[i][j] == '.' ? whites[n]++ : blacks[n]++;
		}
	}

	long long ans = 0;
	for (int i = 0; i < blacks.size(); i++) {
		// printf("%d: %d %d\n", i, blacks[i], whites[i]);
		ans += (long long)blacks[i] * whites[i];
	}
	cout << ans << endl;
	// show_memo();
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
//using lint = long long;

struct P
{
    int x,y;

    bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }

};

vector<int> v[1],v1;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c,h;

int o[3111];
long long l[3111][3111];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s[222][22];
//priority_queue<P> q;
queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

//string r,r1;
char r[2222][1111];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;

}


long long f(int n,int m)
{
    if(n>m) return 0;
    if(l[n][m]>=0) return l[n][m];
    if((m-n+1)%2==a%2) return l[n][m]=max(f(n+1,m)+o[n],f(n,m-1)+o[m]);
    return l[n][m]=min(f(n+1,m),f(n,m-1));
}

int main()
{
    memset(l,-1,sizeof(l));
    scanf("%d",&a);
    for(int t=1;t<=a;x+=o[t],t++)
        scanf("%d",&o[t]);
    printf("%lld",2*f(1,a)-x);
}





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

int main(){
  int n,b,f,r,v,count[4][3][10]={};

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b>>f>>r>>v;
    count[b-1][f-1][r-1]+=v;
  }

  for(int i=0;i<4;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<10;k++){
	cout<<" "<<count[i][j][k];
      }
      cout<<endl;
    }
    if(i!=3) cout<<"####################"<<endl;
  }

return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//竸プロは楽しい！！！！！！！！
//AtCoderさんいつもありがとうございます！！！！！！！！
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int r; cin>>r;
    cout<<3*r*r<<endl;

}

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

#define f(i,a,b) for (int i = a; i < b; i++)

int gcd(int a, int b) { return a?gcd(b%a,a):b; }

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n,k; cin>>n>>k;
	int g = 0, hi = 0;
	f(i,0,n) {
		int a; cin>>a;
		hi=max(hi,a); g = gcd(g,a);
	}
	cout << (k%g==0&&hi>=k?"POSSIBLE":"IMPOSSIBLE") << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[5];
int main(){
	string s;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=="AC") a[0]++;
		else if(s=="WA") a[1]++;
		else if(s=="TLE") a[2]++;
		else if(s=="RE") a[3]++;
	}
	cout<<"AC"<<' '<<'x'<<' '<<a[0]<<endl;
	cout<<"WA"<<' '<<'x'<<' '<<a[1]<<endl;
	cout<<"TLE"<<' '<<'x'<<' '<<a[2]<<endl;
	cout<<"RE"<<' '<<'x'<<' '<<a[3]<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

int B[2000001],n;
void CountingSort(int[],int[],int);

int main(){
    int i,k=0;
    scanf("%d",&n);
    int A[2000001];
    for(i = 1 ; i <= n ; i++){
        scanf("%d",&A[i]);
        if(k < A[i]) k = A[i];
    }

    CountingSort(A,B,k);

    for(i = 1 ; i <= n ; i++){
        printf("%d",B[i]);
        if(i != n){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}

void CountingSort(int A[],int B[], int k){
    int i,C[k+1];
    for(i = 0 ; i <= k ; i++){
        C[i] = 0;
    }
    for(i = 1 ; i <= n ; i++){
        C[A[i]]++;
    }
    for(i = 1 ; i <= k ; i++){
        C[i] = C[i] + C[i-1];
    }
    for(i = n ; i >= 0; i--){
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }
}



Measured memory_bytes: 17444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
  string s;
  ll q;
  cin >> s >> q;
  
  deque<char> ans;
  for (int i = 0; i < s.size(); i++) ans.push_back(s.at(i));

  bool flag = true; // trueでは正方向、falseで逆さ方向
  
  for (ll i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 1) flag = (flag ? false : true);
    else {
      int f;
      char c;
      cin >> f >> c;

      if (f == 1) {
          if (flag) ans.push_front(c);
          else ans.push_back(c);
      } else {
          if (flag) ans.push_back(c);
          else ans.push_front(c);
      }

    }
  }
  if (flag) {
      while(ans.size()) {
          cout << ans.front();
          ans.pop_front();
      }
      //for (ll i = 0; i < ans.size(); i++) cout << ans.at(i);
  } else {
      while (ans.size()) {
          cout << ans.back();
          ans.pop_back();
      }
      //for (ll i = ans.size() - 1; i >=0; i--) cout << ans.at(i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

int T, t[40];
int N;
int M[200];
int last, dp[200];

int rec(int x){
    if(x >= last) return 0;
    int & res = dp[x];
    if(res != -1) return res;
    res = 1<<29;
    bool ok = true;
    for(int i=x; i<=last; i++){
        if(M[i] < t[(i-x)%T]) ok = false;
    }
    if(ok) res = 0;
    for(int i=x+1; i<=last; i++){
        res = min(1+rec(i) , res);
        if(M[i] < t[(i-x)%T]) break;
    }
    return res;
}

int main(){
    while(cin>>T && T){
        memset(dp,-1,sizeof(dp));
        rep(i,200) M[i] = 24;
        rep(i,T) cin >> t[i];
        cin >> N;
        rep(i,N){
            int x,y;
            cin >> x >> y;
            M[x] = min(M[x],y);
            last = max(last, x);
        }
        cout << rec(1) << endl;
    }
}

Measured memory_bytes: 1164
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        this.H = inpt[0];
        this.W = inpt[1];
        this.Map = new bool[this.H, this.W];
        for (int i = 0; i < this.H; i++) {
            bool[] tmp = Reader.ReadLine().Select(a => a == '.').ToArray();
            for (int j = 0; j < tmp.Length; j++) {
                if(tmp[j]) {
                    this.WhiteCount++;
                } else {
                    this.BlackCount++;
                }
                Map[i, j] = tmp[j];
            }
        }

        Queue<int[]> q = new Queue<int[]>();
        Nullable<int>[,] step = new Nullable<int>[this.H, this.W];
        q.Enqueue(new int[] { 0, 0 });
        step[0, 0] = 1;
        while(q.Count>0) {
            int[] pos = q.Dequeue();
            int curY = pos[0];
            int curX = pos[1];
            int nextStep = step[curY, curX].Value + 1;
            for (int i = Math.Max(0, curY - 1); i<= Math.Min(this.H - 1, curY + 1); i++) {
                for (int j = Math.Max(0, curX - 1); j <= Math.Min(this.W - 1, curX + 1); j++) {
                    if(i!=curY&&j!=curX) {
                        continue;
                    }
                    if(i==curY&&j==curX) {
                        continue;
                    }
                    if(!Map[i,j]) {
                        continue;
                    }
                    if(step[i,j]!=null&&step[i,j]<=nextStep) {
                        continue;
                    }
                    step[i, j] = nextStep;
                    q.Enqueue(new int[]{i,j});
                }
            }
        }
        if(step[this.H-1, this.W-1] == null) {
            Console.WriteLine(-1);
            return;
        }

        int minStep = step[this.H - 1, this.W - 1].Value;
        int ans = Math.Min(WhiteCount - 2, WhiteCount - minStep);
        Console.WriteLine(ans);
    }

    private bool[,] Map;

    private int WhiteCount;
    private int BlackCount;

    private int H;
    private int W;



    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


3 3
..#
#..
...

";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main() {
  int n,t;
  int ans = 0;
  int a = 1;
  cin >> n;

  rep(i,1,n+1){
    t = i;
    int c = 0;
    while(t%2 == 0){
      t = t/2;
      c++;
    }
    ans = max(c,ans);
  }

  rep(i,0,ans){
    a *= 2;
  }
  printf("%d\n",a);
	return 0;
}

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

int main(){
    int64_t X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vector<int64_t> P(A),Q(B),R(C);
    rep(i,A) cin >> P.at(i);
    rep(i,B) cin >> Q.at(i);
    rep(i,C) cin >> R.at(i);

    sort(P.begin(), P.end());
    reverse(P.begin(), P.end());
    sort(Q.begin(), Q.end());
    reverse(Q.begin(), Q.end());

    rep(i,X) R.push_back(P.at(i));
    rep(i,Y) R.push_back(Q.at(i));

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

    int64_t sum =0;
    rep(i,X+Y) sum += R.at(i);

    cout << sum << endl;
}   

Measured memory_bytes: 6512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long k = sc.NextLong();

        if (k == 1)
        {
            Console.WriteLine(n * n * n);
            return;
        }

        long answer = 0;
        long count = n / k;
        answer += count * count * count;

        if (k % 2 == 0)
        {
            long count2 = n / k;
            if (n % k >= k / 2)
            {
                count2++;
            }
            answer += count2 * count2 * count2;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27520
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;

int h, w;
string s[26][26];

void output(int i, int j) {
	cout << (char)(j + 'A') << i + 1 << endl;
}

signed main() {
	int i, j;
	
	cin >> h >> w;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			cin >> s[i][j];
			if (s[i][j] == "snuke") {
				output(i, j);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MAXN = 301;

int main(){
    int N, K; cin >> N >> K;
    int MAX = ((N-1)*(N-2))/2;
    if(K > ((N-1) * (N-2)) / 2){
        cout << -1 << endl;
        return 0;
    }
    if(N == 2){
        if(K == 1) cout << -1 << endl;
        else if(K == 0) {cout << 1 << endl; cout << 1 << " " << 2 << endl;}
        return 0;
    }
    cout << N-1+MAX-K << endl;
    //この時点で(N-1)*(N-2) / 2こ
    for(int i = 1; i < N; i++) cout << i << " " << N << endl;;
    //あとMAX-Kこ消す
    int cnt = 0;
    if(cnt==MAX-K) return 0;
    for(int i = 1; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            cout << i << " " << j << endl;
            cnt++;
            if(cnt==MAX-K) return 0;
        }
    }
}


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

int main(void){
    int N;
    cin >> N;
    set<string> ans;
    rep(i,N){
        string S;
        cin >> S;
        ans.insert(S);
    }
    cout << ans.size() << endl;
}

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

struct stdd
{
    int stno, no;  
};

bool comp(stdd A, stdd B)
{
    return A.stno < B.stno;
}
int main()
{
    int n, k;
    cin>>n;
    stdd s[n];
    for(int i=0;i<n;i++){
        cin>>s[i].stno;
        s[i].no = i+1;
    }
    sort(s, s+n, comp);
    for(int i=0;i<n;i++)
        cout<<s[i].no<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n,k;cin>>n>>k;

  ll mi=0,ma=n+1,ans=0;
  for(int i = 1;i <= n;++i){
    mi += i;
    ma += n-i;
    if(i >= k-1)ans += ma-mi;
    ans %= INF;
  }

  if(k == 1)(ans+=n+1)%=INF;
  print(ans);
  return 0; 
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int X;
    cin >> X;
    vector<int> items {100, 101, 102, 103, 104, 105};
    vector<int> dp(X+1, 0);
    dp[0] = 1;
    for (int i = 0; i <= X; ++i) {
        for (int j = 0; j < 6; ++j) {
            int to = i + items[j];
            dp[to] |= dp[i];
        }
    }
    cout << dp[X] << endl;
    return 0;
}

Measured memory_bytes: 3704
N,M = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
b = 0
c = len(A)
for i in range(c):
    if A[i] >= S/(4*M):
        b += 1

if M <=b :
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.util.*;
import javax.lang.model.util.ElementScanner6;
import java.lang.Math;

public class Main {

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

        // 入力
        //String t = sc.next();
        int n = sc.nextInt();

        // 
        long out = 1;
        long[] a = new long[n];
        boolean zeroflg = false;
        for(int i = 0; i < n; i++){
            a[i] = sc.nextLong();
            if (a[i] == 0){
                zeroflg = true;
                break;
            }
        }
        if(zeroflg == true){
            out = 0;
        } else{
            for(int i = 0; i < n; i++){
                if(Math.log10(out) + Math.log10(a[i]) > 18 ||
                    out * a[i] > 1000000000000000000L ){
                    out = -1;
                    break;
                } else {;           
                    out *= a[i];
                }
            }
        }

        // 出力
        System.out.println(out);
    }    
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int x[n];
  rep(i,n) cin >> x[i];
  int ans = 0;
  rep(i,n) {
    if (2*x[i] < k) ans += 2*x[i];
    else ans += 2*(k-x[i]);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

string s ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>s ;
	int x = 0 ;
	for(auto &c : s)
		x += (c - '0') ;
	if(x % 9 == 0)
		cout<<"Yes\n" ;
	else
		cout<<"No\n" ;
	return 0 ;
}

Measured memory_bytes: 3768
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import sys
import math

n = int(input())
result = 0

for i in range(n):
    result = 0
    x = int(input())
    y = int(input())

    result = x + y
    length = len(str(result))
    if length > 80:
        print("overflow")
    else:
        print(result)

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}



struct UnionFind
{

  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }

  int root(int x) {
    if (x == par[x]) return x;
    return par[x] = root(par[x]); 
  }

  bool unite(int x, int y) {

    x = root(x);
    y = root(y);

    if (x == y) return false;

    if (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];

    return true;
  }

  bool find(int x,int y){
    return root(x)==root(y);
  }

  int size(int x) {
    return sizes[root(x)];
  }
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  
  vi a(n),b(n);
  vector<P> aa(n),bb(n);
  rep(i,n){
    cin>>a[i];
    aa[i]=P(a[i],i);
  }
  rep(i,n){
    cin>>b[i];
    bb[i]=P(b[i],i);
  }

  sort(all(aa));
  sort(all(bb));

  rep(i,n){
    if(aa[i].F>bb[i].F){
      Yes(false);
      return 0;
    }
  }

  
  UnionFind uf(n);
  rep(i,n){
    uf.unite(aa[i].S,bb[i].S);
  }

  int cnt=0;
  rep(i,n){
    if(uf.root(i)==i) cnt++;
    if(cnt>1){
      Yes(true);
      return 0;
    }
  }
  

  rep(i,n-1){
    if(aa[i].F<=bb[i+1].F&&aa[i+1].F<=bb[i].F){
      Yes(true);
      return 0;
    }
  }

  Yes(false);



}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{   
       int n;
        cin>>n;
        vector<int> dp(3);
        vector<int> dp1(3);
       int a , b,c;
       cin>>a>>b>>c;
       dp[0] = a;
       dp[1] = b;
       dp[2] = c;
      //  cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<endl;
       for(int i = 1 ; i < n ; i++)
       {
           cin>>a>>b>>c;
           dp1[0] = (a + max(dp[1],dp[2]));
           dp1[1] = (b + max(dp[0],dp[2]));
           dp1[2] = (c + max(dp[0],dp[1]));
           dp[0] = dp1[0];
           dp[1] = dp1[1];
           dp[2] = dp1[2];
          // cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<endl;
       }
       cout<<max(dp[0],max(dp[1],dp[2]))<<endl;
        
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;cin>>n;
    long long cnt_t=0,cnt_a=0;
    cin>>cnt_t>>cnt_a;
    for(int i=1;i<n;i++){
        int t,a;cin>>t>>a;
        
        long long x = max(cnt_t/t,cnt_a/a);
        while(1){
            if(t*x>=cnt_t && a*x>=cnt_a){
                cnt_t=t*x;cnt_a=a*x;
                break;
            }else x++;
        }
    }
    
    cout<<cnt_t+cnt_a<<endl;
    
    return 0;
}


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

using namespace std;

//int smaps[100000][10];

int main(void)
{
	int n;
	cin >> n;
	long long ans = 0;
	vector<vector<int>> smaps;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		vector<int> ar(10);
		for (int j = 0; j < 10; ++j)
		{
			ar[j] = s[j] - 'a';
		}
		sort(ar.begin(), ar.end());
		smaps.push_back(ar);
	}
	sort(smaps.begin(), smaps.end());
	/* for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 10; ++j)
		{
			cout << smaps[i][j];
		}
		cout << endl;
	}*/
	long long buf = 0;
	for (int i = 0; i < n - 1; ++i)
	{
		if (smaps[i] == smaps[i + 1])
		{
			buf++;
			ans += buf;
		}
		else
		{
			buf = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7216
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  for (int i = 0; i < N - 2; i++) {
    string abc = "";
    abc += S[i];
    abc += S[i + 1];
    abc += S[i + 2];
    if (abc == "ABC") {
      count += 1;
    }
  } 
  cout << count << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int par[212345], rnk[212345];
int n, k, l, p[112345], q[112345], r[112345], s[112345], a[212345], b[212345];

void init()
{
    REP(i, n)
    {
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x)
{
    if (par[x] == x)
        return x;
    else
        return par[x] = find(par[x]);
}

void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;

    if (rnk[x] < rnk[y])
    {
        par[x] = y;
    }
    else
    {
        par[y] = x;
        if (rnk[x] == rnk[y])
            rnk[x]++;
    }
}

int main()
{
    cin >> n >> k >> l;
    map<P, int> mp;
    init();
    REP(i, k)
    {
        cin >> p[i] >> q[i];
        unite(p[i] - 1, q[i] - 1);
    }
    REP(i, n)
    {
        a[i] = find(i);
    }

    init();

    REP(i, l)
    {
        cin >> r[i] >> s[i];
        unite(r[i] - 1, s[i] - 1);
    }
    REP(i, n)
    {
        b[i] = find(i);

        mp[make_pair(a[i], b[i])]++;
    }

    /*
    REP(i, n)
    {
        cout << a[i] << (i == n - 1 ? "\n" : " ");
    }

    REP(i, n)
    {
        cout << b[i] << (i == n - 1 ? "\n" : " ");
    }
    */

    REP(i, n)
    {
        cout << mp[make_pair(a[i], b[i])] << (i == n - 1 ? "\n" : " ");
    }

    return 0;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  std::string S;
  std::cin >> S;

  if(S[0] == S[1] && S[1]== S[2]) {
    std::cout << "No" << '\n';
  } else {
    std::cout << "Yes" << '\n';
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

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

signed main() {
    int ans = 0;
    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        if(tmp > k - tmp){
            ans += (k - tmp) * 2;
        }else{
            ans += 2 * tmp;
        }
    }
    cout << ans;
}



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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(15);
    string S, T;
    cin >> S >> T;
    map<char, char> f, r;
    for (int i = 0; i < S.size(); ++i) {
        if (f.find(S[i]) == f.end()) {
            f[S[i]] = T[i];
        } else if (f[S[i]] != T[i]) {
            cout << "No\n";
            return 0;
        }
        if (r.find(T[i]) == r.end()) {
            r[T[i]] = S[i];
        } else if (r[T[i]] != S[i]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}



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

using namespace std;


class Solution{

public:
    char winner(const vector<string>& s){

        char cur = 'a';
        vector<int> p(3, 0);
        while(p[cur - 'a'] < s[cur - 'a'].size())
            cur = s[cur - 'a'][p[cur - 'a'] ++];
        return cur - 'a' + 'A';
    }
};

int main() {

    vector<string> s(3);
    for(int i = 0; i < 3; i ++) cin >> s[i];
    printf("%c\n", Solution().winner(s));

    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007

int main(){
    int a[3][3];
    bool ch[3][3];
    rep(i,0,3)rep(j,0,3)cin>>a[i][j];
    rep(i,0,3)rep(j,0,3)ch[i][j]=false;
    int n;
    cin>>n;
    rep(i,0,n){
        int t;
        cin>>t;
        rep(j,0,3){
            rep(k,0,3){
                if(a[j][k]==t){
                    ch[j][k]=true;
                }
            }
        }
    }
    bool f=false;
    rep(i,0,3)if(ch[i][0]&&(ch[i][1]&&ch[i][2]))f=true;
    rep(i,0,3)if(ch[0][i]&&(ch[1][i]&&ch[2][i]))f=true;
    if(ch[0][0]&&(ch[1][1]&&ch[2][2]))f=true;
    if(ch[0][2]&&(ch[1][1]&&ch[2][0]))f=true;
    if(f)cout<<"Yes\n";
    else cout<<"No\n";
    
}

Measured memory_bytes: 256
//============================================================================
// Name        : s
// Date        : Tue Mar  5 16:14:07 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define jam(x, n) cout << "Case #" << x << ": " << n << "\n"
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"

#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int mod = (int) 1e9 + 7;

// Digit dp problem

void add(int &a, int b) {
    a += b;
    if (a >= mod) {
        a -= mod;
    }
}

void solve() {
    string k; int d;
    cin >> k >> d;

    int n = sz(k);
    vvi dp(d, vi(2));
    dp[0][0] = 1;
    fori (i, 0, n) {
        vvi new_dp(d, vi(2));
        fori (sum, 0, d) {
            for (bool sm_already : {false, true}) {
                for (int digit = 0; digit < 10; ++digit) {
                    if (digit > k[i] - '0' && !sm_already) {
                        break;
                    }
                    bool small = sm_already || (digit < k[i] - '0');
                    // trace(sum, i, digit, sm_already, small);
                    add(new_dp[(sum + digit) % d][small], dp[sum][sm_already]);
                }
            }
        }
        dp = new_dp;
    }
    int ret = (dp[0][0] + dp[0][1] - 1 + mod) % mod;
    output(ret);
}

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



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <numeric>
#include <string>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    map<int,ll> mp;
    ll sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mp[a[i]]++;
    }
    for(auto p:mp){
        sum+=(p.second)*(p.second-1)/2;
    }
    for(int i=0;i<n;i++){
        printf("%lld\n",sum-mp[a[i]]+1 );
    }
}


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

int main(){
	int k, s, count = 0;
	cin >> k >> s;
	for(int i=0; i <= k; i++) {
		for(int j=0; j <= k; j++) {
			int z = s - i - j;
			if(z >= 0 && z <= k)
				count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
(defun calc (m L &optional (cnt 0) (cost 0))
  (cond
    ((= cnt m) cost)
    ((null L) -1)
    (t
     (when (= (rest (first L)) 0)
       (pop L))
     (decf (rest (first L)))
     (calc m L (1+ cnt) (+ cost (first (first L)))))))

(defun solve(m l)
    (let* ((L (sort l #'(lambda (a b) (<= (first a) (first b))))))
      (calc m L)))


(defun main ()
  (let* ((n (read))
	 (m (read))
	 (l nil))
	   (dotimes (i n)
	     (push (cons (read) (read)) l))
    (princ (solve m l))
    (fresh-line)))

(main)


Measured memory_bytes: 79916
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
#include <tuple>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int n, m;
    cin >> n >> m;
    tuple<int, int, int> data[m]; // Y_i, P_i, i
    for (int i = 0; i < m; i++) {
        int p, y;
        cin >> p >> y;
        data[i] = make_tuple(y, p, i);
    }
    sort(data, data + m); // sort by Y_i
    int cnt[n + 1];
    fill(cnt, cnt + n + 1, 0);

    pair<int, int> id[m]; // P_i, order
    
    for (int i = 0; i < m; i++) {
        int y, p, idx;
        tie(y, p, idx) = data[i];
        cnt[p]++;
        id[idx] = make_pair(p, cnt[p]);
    }

    for (int i = 0; i < m; i++) {
        cout << setw(6) << setfill('0') << id[i].first;
        cout << setw(6) << setfill('0') << id[i].second << endl;
    }
}


Measured memory_bytes: 3840
import sys
input = sys.stdin.readline

n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n

for i in range(n):
    x[i], y[i], h[i] = map(int, input().split())

for i in range(n):
    if h[i] != 0:
        s = i
        break
        
for cx in range(101):
    for cy in range(101):
        H = h[s] + abs(x[s] - cx) + abs(y[s] - cy)
        Flag = True
        for k in range(n):
            if h[k] != max(H - abs(x[k] - cx) - abs(y[k] - cy), 0):
                Flag = False
                break  
        if Flag:
            print(cx, cy, H)
            exit()

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n;cin >> n;
	string str;cin >> str;
	ll ans = 0;
	string seica = "ABC";

	REP(i, n - 2){
		bool flag = true;
		REP(j, 3){
			if(str[i+j] != seica[j])flag = false;
		}
		if(flag)ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int h, w, K;
    cin >> h >> w >> K;

    ll b = 0, x[12] = {};
    for (int i = 0; i < h; i++) {
        char c[7];
        cin >> c;
        for (int j = 0; j < w; j++) {
            ll m = 1LL << (i * w + j);
            if (c[j] == '#') b ^= m;
            x[i] ^= m;
            x[h + j] ^= m;
        }
    }

    int r = 0;
    int n = h + w;
    vector<ll> dp(1 << n);
    dp[0] = 0LL;
    for (int i = 0; i < n; i++) {
        dp[1 << i] = x[i];
    }

    for (int k = 0; k < 1 << n; k++) {
        int l = k & -k;
        dp[k] = dp[k & ~l] | dp[l];
        r += __builtin_popcountll(b & ~dp[k]) == K;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,count=0;
  char a[1000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  if(n%2){
    cout<<"No"<<endl;
  }else{
    for(int k=0;k<n/2;k++){
      if(a[k]==a[k+n/2])count++;
    }
    if(count==n/2){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int aScore = 0;
    int bScore = 0;
    for (int i = 0; i < n; i++) {
      String a = s.next();
      String b = s.next();
      if (a.compareTo(b) > 0) {
        aScore += 3;
      } else if (a.compareTo(b) < 0) {
        bScore += 3;
      } else {
        aScore += 1;
        bScore += 1;
      }
    }
    s.close();
    System.out.println(aScore + " " + bScore);
  }
}



Measured memory_bytes: 28992
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=15,mod=1e9+7;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}

	int f[1<<N],n,m,g[N+1][1<<N],e[N+1][N+1],pw[N*N];
	int main(){
		n=read<int>(),m=read<int>();
		for(int i=1;i<=m;i++){
			int u=read<int>(),v=read<int>();
			e[u][v]++;
		}
		pw[0]=1;
		for(int i=1;i<=m;i++) pw[i]=2LL*pw[i-1]%mod;

		for(int i=0;i<n;i++){
			for(int s=0;s<(1<<n);s++)
				for(int j=0;j<n;j++)
					if((s>>j)&1 && e[i+1][j+1]) g[i][s]++;
		}

		for(int S=0;S<1<<n;S++) if((S&3)==3){
			f[S]=1;
			for(int T=S;T;--T&=S) if((T&1)==(T>>1&1)){
				if(T&1){
					int ret=1;
					for(int i=0;i<n;i++) if(S>>i&1){
						if(T>>i&1) ret=1LL*ret*sub(pw[g[i][S^T]],1)%mod;
						else ret=1LL*ret*pw[g[i][T]]%mod;
					}
					f[S]=(1LL*f[T]*ret+f[S])%mod;
				}else{
					int ret=1;
					for(int i=0;i<n;i++) if(S>>i&1){
						if(T>>i&1) ret=1LL*ret*sub(pw[g[i][S^T]],1)%mod*pw[g[i][T]]%mod;
						else ret=1LL*ret*pw[g[i][T]]%mod;
					}
					f[S]=add(ret,f[S]);
				}
			}
		}
		printf("%d\n",sub(pw[m],f[(1<<n)-1]));
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 5584
#!/usr/bin/env python3

h,w = map(int,input().split())
c = [list(input()) if i % 2 == 0 else [] for i in range(2*h)]

for i in range(h):
    c[2*i+1] = c[2*i]
for i in range(2*h):
    print(''.join(c[i]))


Measured memory_bytes: 38256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    for(int i = 1; i <= 9; i++)
	{
		for(int j = 1; j <= 9; j++)
		{
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}

Measured memory_bytes: 0