akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<(n);i++)
using namespace std;

int main(){
	int n,m=0;
  	cin>>n;
	range(i,1,35)range(j,2,10){
     	if(pow(i,j)>n) break;
      	m=max(m,(int)pow(i,j));
    }  
    cout<<m<<endl;
	return 0;
}


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

L_list = []
R_list = []

for i in range(M):
    L_i,R_i = map(int, input().split() )
    L_list.append(L_i)
    R_list.append(R_i)

result = max([min(R_list)- max(L_list) + 1, 0])

print(str(result))

Measured memory_bytes: 11016
#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()
{
    string str;
    
    int res = 0, s = 0;
    while(cin >> str)
    {
        rep(i, str.size())
        {
            if('0' <= str[i] && str[i] <= '9')
            {
                s *= 10;
                s += str[i] - '0';
            }
            else
            {
                res += s;
                s = 0;
            }        
        }
        res += s;
        s = 0;
    }
    
    cout << res << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
using namespace std;


int main(int argc, char *argv[]){
	double x=0,y=0,th=-1,d=0,dir=90;
	while(!(d==0 && th==0)){

		cin>>d; cin.ignore();cin>>th;
		x+=d*cos(dir*M_PI/180);
		y+=d*sin(dir*M_PI/180);
		
		dir-=th;

	}
	cout<<(int)x<<endl<<(int)y<<endl;
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll dp[n][3];
  rep(i,n)rep(j,3) dp[i][j]=-MAX;
  ll a[n][3];
  rep(i,n)rep(j,3) R a[i][j];
  rep(j,3) dp[0][j]=a[0][j];
  REP(i,1,n) {
    dp[i][0]=max(dp[i][0],dp[i-1][1]+a[i][0]);
    dp[i][0]=max(dp[i][0],dp[i-1][2]+a[i][0]);
    dp[i][1]=max(dp[i][1],dp[i-1][0]+a[i][1]);
    dp[i][1]=max(dp[i][1],dp[i-1][2]+a[i][1]);
    dp[i][2]=max(dp[i][2],dp[i-1][0]+a[i][2]);
    dp[i][2]=max(dp[i][2],dp[i-1][1]+a[i][2]);
  }
  pr(max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
}

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


Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
int main(){
  int h,w;
  cin >> h>>w;
  string s[h];
string c;
  for(int i=0;i<h;i++){
      cin >> s[i];
  }
  int r[h];
  for(int i=0;i<h;i++) r[i]=-1;
  for(int i=0;i<h;i++){
    bool flag=true;
    for(int j=0;j<w;j++){
      if(s[i][j]!='.') flag=false;
    }
    if(flag) r[i]=1;
  }
  int wi[w];
  bool flag;
  for(int i=0;i<w;i++) wi[i]=-1;
  for(int i=0;i<w;i++){
    flag=true;
    for(int j=0;j<h;j++){
      if(s[j][i]!='.') flag=false;
    }
    if(flag) wi[i]=1;
  }
  //for(int i=0;i<h;i++) cout << r[i];
  flag=false;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(r[i]==-1&&wi[j]==-1){
        cout<< s[i][j];
        flag=true;
      }
    }
    if(flag) cout << endl;
    flag=false;
  }
}


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

int main() {
  vector<vector<int>> c(3, vector<int>(3)); 
  int a[3], b[3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }
  a[0] = 0;
  for (int i = 0; i < 3; i++) b[i] =  c[0][i] - a[0]; 
  for (int i = 0; i < 3; i++) a[i] =  c[i][0] - b[0]; 

  bool jug = true;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (a[i] + b[j] != c[i][j]) jug = false; 
    }
  }
  if (jug) cout << "Yes" << endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 3596
"""
Writer: SPD_9X2
https://atcoder.jp/contests/agc043/tasks/agc043_d

結局は、N個をX個の集合に、3個を最大として分ける通り数？
それを集合内降順ソートして、全体で昇順ソートしたものは構成可能

3こ取る集合の数、2個とる集合の数を決めれば、1この集合の数もわかる
→2重ループで解けそう

1ことるやつは、 全体C取る数
2ことるやつは、 残りC取るやつ　* (Π(i=1~N) 2i C 2) / (N!)
3ことるやつは　  ( Π(i=1~N) 3i C 3 ) / (N!)

Π(i=1~N) 2i C 2 = TX[i]
Π(i=1~N) 3i C 3 = TT[i]を各Nについて前計算しておく必要性あり

グループ内の最大が先頭である必要があるけど、残りは自由
→なんか違くね…

→2の個数が1の個数を超えたらダメなのか！！


もうちょっとちゃんと考察しよう
ある順列があっったとする。これが構築可能かの判定
→大小の塊をセットにする。

塊の大きさは3以下、かつ2の塊の数が1より多かったらダメ
このような分け方のとき、かならず構築できる？

1,2の大きさを組み合わせ、先頭が昇順になるように合わせればおｋ

"""
def inverse(a,mod): #aのmodを法にした逆元を返す
    return pow(a,mod-2,mod)



#modのn!と、n!の逆元を格納したリストを返す(拾いもの)
#factorialsには[1, 1!%mod , 2!%mod , 6!%mod… , n!%mod] が入っている
#invsには↑の逆元が入っている

def modfac(n, MOD):
 
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
    return factorials, invs


def modnCr(n,r,mod,fac,inv): #上で求めたfacとinvsを引数に入れるべし(上の関数で与えたnが計算できる最大のnになる)

    return fac[n] * inv[n-r] * inv[r] % mod


N,mod = map(int,input().split())

fac,inv = modfac(10*N+30,mod)

TX = [1]

for i in range(1,2 * N+10):
    
    TX.append(TX[-1] * modnCr(2*i,2,mod,fac,inv) % mod)

TT = [1]

for i in range(1,2 * N+10):
    
    TT.append(TT[-1] * modnCr(3*i,3,mod,fac,inv) % mod)

ans = 0

for tri in range(N+1):

    for sec in range(2*N):

        one = 3*N - 3*tri - 2*sec
        if one < 0 or one < sec:
            continue

        now = modnCr(3*N,one,mod,fac,inv)
        now *= modnCr(3*N-one,2*sec,mod,fac,inv) * TX[sec] * inv[sec]
        now *= TT[tri] * inv[tri] * pow(2,tri,mod)

        now %= mod
        ans += now
        #print (tri,sec,one,now)
        ans %= mod

print (ans)

        


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

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

    int N;
    cin >> N;
    vector<int> a(N);
    int sum = 0;

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

    int mini = sum;
    int prefix_sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        prefix_sum += a[i];
        mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
    }

    cout << mini << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  (B) <= (A) && (A) <= (C)
#define AIN(A, B, C) assert(IN(A, B, C))

void solve(){
      int n;
      cin>>n;
      int x;
      int c=0;
      f(i,1,n+1){
      	 cin>>x;
      	if(i%2 &&x%2==1)c++;
      }
      cout<<c;
}
int main() {
    ios;
	int t=1;
	//cin>>t;
	while(t--)solve();
 
    
}


Measured memory_bytes: 3624
n = int(input())
nums = list(map(int, input().split(" ")))

ans = 0
tail = 0
prev = nums[0]

for head in range(1, n):
    num = nums[head]
    if prev & num > 0:
        # これ以上伸ばせない場合、
        # ここまでの長さ(head-tail)を正解に加算し、tailを進める
        while prev & num > 0:
            ans += head - tail
            # 区間値からtailを除外
            prev = prev ^ nums[tail]
            tail += 1
        prev += num
    else:
        # まだ伸ばせるなら区間値にheadを加えてそのまま進める
        prev = prev + num

count = n - tail
# 1からcountまでの合計を足す
ans += count*(count+1)//2

print(ans)

Measured memory_bytes: 23560
#include <iostream>

int main()
{
	int a, b, c, k;
	std::cin >> a >> b >> c >> k;
	
	for (int i = 0; i < k; i++)
	{
		if ((a == b == c) || ((a == b && a > c) || (a == c && a > b)) || (a > b && a > c))
			a *= 2;
		else if ((b > c) || (b == c && b > a))
			b *= 2;
		else
			c *= 2;
	}
	
	std::cout << a + b + c << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int N;
    cin >> N;

    if(N==1) cout << ans_Yes;
    else{
        int base = 1;
        int Sn = 0;
        while(base <= N){
            base = base * 10;
            Sn +=  ( N % base ) / (base / 10);
        }

        if(N%Sn==0)    cout << ans_Yes;
        else cout << ans_No;
    }
}

Measured memory_bytes: 256
def gcd(x,y):
    while x%y:
        x%=y
        x,y=(y,x)
    return y
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
m=xlist[-1]
while xlist!=[0]*n:
    for i in range(n):
        
        xlist[i]%=m
        if xlist[i]>0:
            m=gcd(m,xlist[i])
print(m)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int N, a[109];
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	sort(a, a + N, greater<int>());
	int ret = 0;
	for (int i = 0; i < N; i++) ret += a[i] * (i & 1 ? -1 : 1);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    n = int(input())
    ans = set()
    for _ in range(n):
        q, x = [int(i) for i in input().split()]
        if q == 0:
            ans.add(x)
            print(len(ans))
        elif q == 1:
            if x in ans:
                print(1)
            else:
                print(0)
        else:
            if x in ans:
                ans.remove(x)


resolve()



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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int>data(n);
    rep(i,n)cin >> data[i];
    sort(all(data));
    int ans = 1000000000;
    int j,l;
    rep(i,n-k+1){
        int cnt = data[i+k-1]-data[i];
        ans = min(ans,cnt);
        if(ans == cnt){
            j = i;l = i+k-1;
        }
    }
    //cout << j << l << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
x = [int(i) for i in input().split()]

ret = float('inf')
for i in range(N-K+1) :
    l = x[i]
    r = x[i+K-1]
    if l < 0 and r < 0 :
        ret = min(ret, -l)
    elif l > 0 and r > 0 :
        ret = min(ret, r)
    else :
        m, M = min(-l, r), max(-l, r)
        ret = min(ret, m * 2 + M)
print(ret)

Measured memory_bytes: 62576
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		List<String> sl = Arrays.asList(br.readLine().trim().split(" "));
		List<Integer> il = new ArrayList<>();
		for (String s : sl) {
			il.add(Integer.parseInt(s));
		}

		insertionSort(il, n);
	}

	static void insertionSort(List<Integer> l, int n) {
		printList(l);
		for (int i=1; i<n; i++) {
			int v = l.get(i);
			int j = i - 1;
			while (j >= 0 && l.get(j) > v) {
				l.set(j + 1, l.get(j));
				j--;
			}
			l.set(j + 1, v);
			printList(l);
		}
	}
	
	static void printList(List<Integer> l) {
		Iterator<Integer> it = l.iterator();
		while(it.hasNext()) {
			System.out.print(it.next());
			if (it.hasNext()) System.out.print(" ");
		}
		
		System.out.println();
	}
}

Measured memory_bytes: 30880
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}
impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap(); 
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());

    let (k, a, b): (usize, usize, usize) = input!(r, usize, usize, usize);
    if a + 2 >= b || k - (a - 1) < 2 {
        println!("{}", k + 1);
    } else {
       let mut tmp = ((k - (a - 1)) / 2) * (b - a) + a;
       if (k - (a - 1)) % 2 == 1 {
           tmp += 1;
       }
       println!("{}", tmp);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int fact[1010]; 
int main() {
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++)
	{
		int x = i;
		for (int j = 2; j*j <= i; j++)
		{
			if (x % j != 0) continue;
			while (x % j == 0)
			{
				fact[j]++;
				x /= j;
			}
		}
		if (x > 1) fact[x]++;
	}
	
	ll ans = 1;
	rep(i,n+1) {
		if (fact[i] == 0) continue;
		ans *= (fact[i]+1);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

#define MAX 2000200

int n;
ll a[MAX];

#define SMAX 15
int dp[1<<SMAX];
int bf() {
  memset(dp,0,sizeof dp);
  int maxi = 0;
  rep(bit,(1<<n)) {
    rep(i,n) if( !( (bit>>i) & 1 ) ) REP(j,i+1,n) {
	if( (bit>>j) & 1 ) continue;
	if( __builtin_popcount(a[i]+a[j]) == 1 ) {
	  dp[bit|(1<<i)|(1<<j)] = max(dp[bit|(1<<i)|(1<<j)],
				      dp[bit]+1);
	  maxi = max(dp[bit|(1<<i)|(1<<j)],maxi);
	}
      }
  }
  return maxi;
}

void compute() {

}

bool debug = 0;

bool used[MAX];
int main() {

  /*
  REP(ii,1,65) {
    REP(jj,ii,65) {
      REP(kk,jj,65) {
	REP(l2,kk,65) {

	  memset(used,false,sizeof used);

	  n = 4;
	  a[0] = ii;
	  a[1] = jj;
	  a[2] = kk;
	  a[3] = l2;
  */
  
  cin >> n;
  rep(i,n) cin >> a[i];  
	  sort(a,a+n);
	  int maxi = 0;
	  vector<ll> vec;
	  rep(i,50) vec.push_back((1LL<<i));
	  reverse(ALL(vec));
	  map<ll,deque<int>> mp;
	  rep(i,n) mp[a[i]].push_back(i);
  
	  //rep(i,n) {
	  for(int i=n-1;i>=0;--i) {
	    if( used[i] ) continue;
	    int use = -1;
	    rep(j,(int)vec.size()) {
	      ll rem = vec[j] - a[i];
	      if( rem <= 0LL ) break;
	      if( mp.count(rem) ) {
		while( mp[rem].size() && used[mp[rem].back()] ) {
		  mp[rem].pop_back();
		}
		if( mp[rem].size() >= 1 && i != mp[rem].back() ) {
		  use = mp[rem].back();
		  mp[rem].pop_back();
		  break;
		}
	      }
	    }
	    //cout << i<< "-th : = " << use << endl;
	    if( use == -1 ) continue;
	    used[i] = true;
	    used[use] = true;
	    //cout << i << "," << use << endl;
	    ++maxi;
	  }

	  cout << maxi << endl;
	  if( debug ) {
	    cout << "Answer : " << bf() << endl;
	  if( maxi != bf() ) {
	    cout << n << endl;
	    rep(i,n) {
	      cout << a[i] << " ";
	    } puts("");
	    assert(false);
	  }
	  }
	  /*
	}
      }
    }
  }
  */
  compute();
  return 0;
}


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

int main() {
  int A;
  int B;
  cin >> A >> B;
  
  if (A == 1 && B == 2 || A == 2 && B == 1) {
    cout << 3 << endl;
  } else if (A == 1 && B == 3 || A == 3 && B == 1) {
    cout << 2 << endl;
  } else if (A == 2 && B == 3 || A == 3 && B == 2) {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    char op;

    while (cin >> a >> op >> b) {
        switch (op) {
            case '+':
                cout << a + b << endl;
                break;
            case '-':
                cout << a - b << endl;
                break;
            case '*':
                cout << a * b << endl;
                break;
            case '/':
                cout << a / b << endl;
                break;
            case '?':
                return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
const int N = 3087;
int a[N];
long long dp[N][N];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        dp[i][i] = a[i];
    }
    for (int w = 2; w <= n; ++w) 
        for (int l = 0, r; (r = l + w - 1) < n; ++l)
            dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
    cout << dp[0][n - 1] << endl;
}


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

int main()
{
	string S, T;
	cin >> S >> T;

	int N = -1;
	if (S.size() >= T.size())
	{
		for (int i = 0; i <= S.size() - T.size(); ++i)
		{
			bool isMatch = true;
			for (int j = 0; j < T.size(); ++j)
			{
				if (S[i+j] != '?' && S[i+j] != T[j])
				{
					isMatch = false;
					break;
				}
			}

			if (isMatch)
			{
				N = i;
			}
		}
	}

	if (N == -1)
	{
		cout << "UNRESTORABLE" << endl;
	}
	else
	{
		for (int i = 0; i < S.size(); ++i)
		{
			if (i >= N && i < N + T.size())
			{
				S[i] = T[i-N];
			}
			else if(S[i] == '?')
			{
				S[i] = 'a';
			}
		}

		cout << S << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner scan = new Scanner(System.in)) {
			
			int N = scan.nextInt();
			int[][] a = new int[N][2]; 
					
			for(int i=0; i<N; i++) {
				int h = scan.nextInt();
				a[i][0] = i+1;
				a[i][1] = h;
			}
			
			Arrays.sort(a, (x, y) -> Integer.compare(x[1], y[1]));
			
			for(int i=0; i<N; i++) {
				System.out.print(a[i][0]+" ");
			}
			
			return;
			
		}
	}
}

Measured memory_bytes: 70200
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n, m = LI()
    py = LIR(m)
    pya = py[::1]
    py.sort(key=lambda x: x[1])
    city = [1 for i in range(n)]
    dicity = {}
    for p, y in py:
        dicity[(p,y)] = city[p-1]
        city[p-1] += 1    
    for p, y in pya:
        a = "00000" + str(p)
        a = a[-6:]
        b = "00000" + str(dicity[(p, y)])
        b = b[-6:]
        print(a+b)

    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  deque<char> deq;
  deq.push_back(s[0]);
  rep(i, n) {
    char end = deq.back(); 
    if (end != s[i]) deq.push_back(s[i]);
  }
  ll ans = n - deq.size();
  cout << min(n-1, ans+2*k) << endl;
  return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<pair<int, int>> ab;
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		ab.emplace_back(B, A);
	}
	sort(ab.begin(), ab.end());
	ll sum = 0;
	bool ng = false;
	for (int i = 0; i < N; i++) {
		sum += ab[i].second;
		if (sum > ab[i].first) {
			ng = true;
			break;
		}
	}
	puts(ng ? "No" : "Yes");
	return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int k,s;
  cin >> k >> s;
  ll ans=0;
  rep(i,k+1){
    rep(j,k+1){
      if(s-i-j>=0 && s-i-j<=k)ans++;
    }
  }
  cout << ans << endl;
return 0;}

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

using namespace std;
#define taskname "A"
#define pb  push_back
#define mp  make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int n, a[maxn];
int l[maxn] , r[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
        freopen(taskname".INP", "r",stdin);
        freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    vector<int> s;
    for(int i = 1 ; i <= n ; ++i){
        while(s.size() && a[s.back()] >= a[i])s.pop_back();
        if(s.size())l[i] = s.back();
        else l[i] = 0;
        s.pb(i);
    }
    s.clear();
    for(int i = n ; i >= 1 ; --i){
        while(s.size() && a[s.back()] >= a[i])s.pop_back();
        if(s.size())r[i] = s.back();
        else r[i] = n + 1;
        s.pb(i);
    }
    ll res = 0;
    for(int i = 1 ; i <= n ; ++i){
//        cout << l[i] << " " << r[i] << endl;
        res += 1ll * (i - l[i]) * (r[i] - i) * a[i];
    }
    cout << res;
}


Measured memory_bytes: 3572
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        v: chars
    }
    println!("{}", v.iter().map(|&c| rot(c, n)).collect::<String>());
}

fn rot(c: char, n: usize) -> char {
    ((((c as u8 - 'A' as u8) + (n % 26) as u8) % 26) + 'A' as u8) as char
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n,k;
int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin >> n;
	int value;
	int h[n + 1];
	for(int i = 1; i <= n; i++)
	{
		cin >> value;
		h[i] = value;
	}
	int dp[n + 1];
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	// dp[i] represents the min cost to reach ith stone.
	for(int i = 3; i <= n; i++)
	{
		dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}
	int answer = dp[n];
	cout << answer << endl;
	return 0;
}

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

int main()
{
    long long int n,k,sum=0;
    cin>>n>>k;
    long long int ar[n+1];
    for(long long int i=1;i<=n;i++)
    {
        cin>>ar[i];
        if(i<=k)
        {
            sum+=ar[i];
        }
    }
    
    for(long long int i=1,j=k+1;(i<=(n-k)&& j<=n);i++,j++)
    {
        if(sum<(sum-ar[i]+ar[j]))
        {
            cout<<"Yes"<<endl;
            sum=sum-ar[i]+ar[j];
        }
        else 
        {
            cout<<"No"<<endl;
            sum=sum-ar[i]+ar[j];
        }
    }
    return 0;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int r,g;
    cin>>r>>g;
    cout<<2*g-r<<endl;
    return 0;
}

Measured memory_bytes: 256
q=[int(i) for i in input().split()]
n=int(input())*4
ans=max(q)*n*4
for i in range(4):
    for j in range(4):
        if i==j and i<3:
            ans=min(ans,[q[0]*n,q[1]*n//2,q[2]*n//4][i])
        elif i==j==3 and n%8==0:
            ans=min(ans,q[3]*n//8)
        elif i==3 and n%8 and j<3:
            t=[q[0]*4,q[1]*2,q[2]][j]
            ans=min(ans,q[3]*(n//8)+t)
print(ans)


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

void PRINT(int* A,int Len){
    for(int i = 0;i<Len-1;i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[Len-1]);
    return;
}

void bubbleSort(int* A,int N){
    bool flag = true;
    while(flag){
        flag = false;
        for(int j = N-1;j>=1; j--){
            if(A[j] < A[j-1]){
                int buff = A[j];
                A[j] = A[j-1];
                A[j-1] = buff;
                flag = true;
            }
        }
    }
    return;
}

void bubbleSort(int* A,int N,int* count){
    *count = 0;
    //printf("  %d\n",*count);
    bool flag = true;
    while(flag){
        flag = false;
        for(int j = N-1;j>=1; j--){
            if(A[j] < A[j-1]){
                int buff = A[j];
                A[j] = A[j-1];
                A[j-1] = buff;
                flag = true;
                *count += 1;
                //printf("  %d\n",*count);
            }
        }
    }
    return;
}


int main(){
    
    int Len,count;
    scanf("%d",&Len);
    int Num[Len];

    for(int i = 0;i<Len;i++){
        scanf("%d",&Num[i]);
    }


    bubbleSort(Num,Len,&count);
    PRINT(Num,Len);
    printf("%d\n",count);


    return 0;
}



Measured memory_bytes: 2684
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

int main(){
  ll X,Y;
  cin >> X >> Y;
  ll ans = 0;
  vector<ll> p(3000010,1);
  for(int i = 1;i < 3000010;i++){
    p[i] = (p[i-1]*i)%MOD;
  }
  for(int i = 0;i <= X/2;i++){
      int j = X-2*i;
      if(Y == i+(2*j)){
        ans += comb(i,j,p);
        //cout << ans << endl;
      }else{
      continue;
      }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 26724
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

#define MAX_N 1000

using namespace std;

int p[MAX_N + 1];
vector<int > lat;

int N;
int M;

int solve(){
	int res = 0;
	int fake;

	sort(p,p + N + 1);
	for(int i = 0;i <= N;i++){
		for(int j = i;j <= N;j++){
			lat.push_back(p[i] + p[j]);
		}
	}

	sort(lat.begin(),lat.end());
	vector<int >::iterator ite;

	for(int i = 0;i <= N;i++){
		for(int j = 0;j <= N;j++){
			fake = M - (p[i] + p[j]);
			if(fake < 0) break;
			ite = upper_bound(lat.begin(),lat.end(),fake);
			res = max(res,p[i] + p[j] + *(ite - 1));
		}
	}

	return res;
}
			
			

int main(){

	while(true){
	scanf("%d%d",&N,&M);
	if(N == 0 && M == 0) break;
	lat.clear();
	for(int i = 1;i <= N;i++){
		scanf("%d",p + i);
	}

	int ans = solve();

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

	}
}

Measured memory_bytes: 3148
PROGRAM-ID.                      ABC_072_B.
ENVIRONMENT                      DIVISION.
INPUT-OUTPUT                     SECTION.
FILE-CONTROL.
    SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.
DATA                             DIVISION.
FILE                             SECTION.
FD  SYSIN.
    01 INDATA PIC X(100000).
WORKING-STORAGE                  SECTION.
    01 i      PIC 9(6) BINARY.

    01 s1.
        03 s PIC X(1) OCCURS 100000.

    01 len    PIC 9(6).

    01 m      PIC 9(1).
    01 ln     PIC X(50000).
    01 p      PIC 9(5) BINARY.
PROCEDURE                        DIVISION.
    OPEN INPUT SYSIN.

    READ SYSIN INTO s1.

    CLOSE SYSIN.

    MOVE 1 TO p.

    COMPUTE len = FUNCTION STORED-CHAR-LENGTH(s1).

    PERFORM VARYING i FROM 1 BY 1 UNTIL len < i
        COMPUTE m = FUNCTION MOD(i, 2)
        IF m = 1 THEN
            STRING
                s(i)
                INTO ln WITH POINTER p
            END-STRING
        END-IF
    END-PERFORM

    DISPLAY ln(1:FUNCTION STORED-CHAR-LENGTH(ln)).
    STOP RUN.


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 4e3 + 5;

char s[MAXN];
int a[MAXN],sum[MAXN][3+5];

int main(void)
{
	int n;
	scanf("%d%s",&n,s+1);
	
	for(int i=1; i<=n; ++i)
	{
		if(s[i]=='R') a[i]=0;
		if(s[i]=='G') a[i]=1;
		if(s[i]=='B') a[i]=2;
	}
	for(int i=1; i<=n; ++i)
	{
		for(int j=0; j<3; ++j) sum[i][j] = sum[i-1][j];
		++sum[i][a[i]];
	}
	
	ll ans=0;
	for(int i=2; i<=n; ++i)
		for(int j=i+1; j<=n; ++j)
		{
			if(s[i]==s[j]) continue;
			int x = 3 - a[i] - a[j];
			ans += sum[i-1][x];
			if(i-(j-i) >= 1 && a[i-(j-i)]==x) --ans;
		}
	printf("%lld",ans);
	return 0;
}

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

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

int main() { 
    
    int N,X,Y;
    cin >> N >> X >> Y;
    X--; Y--;

    vector<int> ans(N);
    

    //N回BFSやる
    for(int sv= 0; sv < N; sv++){
        vector<int> dist(N, -1);
        queue<int> que;
        auto push = [&](int v, int d){
            if(dist[v] != -1) return;
            dist[v] = d;
            que.push(v);
        }; 
        //一番初めに見るノードを頂点として初期化する 
        push(sv,0);


        while(!que.empty()){
            int v = que.front();
            que.pop();
            int d = dist[v]; 
            if(v-1 >= 0) push(v-1,d+1);
            if(v+1 < N) push(v+1,d+1);
            if(v == X) push(Y,d+1);
            if(v == Y) push(X,d+1);
//             if(v-1 >= 0 ){
//                 if(dist[v-1] == -1){
//
//                dist[v-1] = dist[v] + 1;
//                que.push(v-1);  
//                 }
//             }else if(v+1 < N){
//                 if(dist[v+1]==-1){
//
//                 dist[v+1] = dist[v] + 1;
//                 que.push(v+1);
//                 }
//             }
//
//             if(v == X){
//                 if(dist[Y]==-1){
//                 dist[Y] = dist[v] + 1;
//                que.push(Y); 
//                 }
//             }
//
//             if(v == Y){
//                 if(dist[X] == -1){
//                 dist[X] = dist[v] + 1;
//                que.push(X); 
//                 }
//             }
        }

        for(int j = 0; j < N; j++){
            ans[dist[j]]++;
        }
    }

    for(int i = 0; i < N; i++){
        ans[i] /= 2;
    }

    for(int i = 1; i <= N-1; i++){
        cout << ans[i] << endl;
    }


    return 0; 
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int N, M;
	int limit;
	int gcd = 1;

	cin >> N >> M;

	for (int i = M / N; i > 1; i--) {
		if (M % i == 0) {
			gcd = i;
			break;
		}
	}

	cout << gcd << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }     //最小公倍数

void yes(){
    cout << "Yes" << endl;
}
void no(){
    cout << "No" << endl;
}
//-----------------------------------------

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

    string t ;
    cin >> t ;
    REP(i,SZ(t)){
        if(t[i]=='?'){
            t[i] = 'D' ;
        }
    }

    cout << t <<endl ;
    

    return 0;
}



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

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

    vector<int> vec(N),check(N,0);

    for(int i = 0 ; i < N; i++) {
        cin >> vec.at(i);
        check.at(vec.at(i) - 1)++;
    }

    int ans = 0,num = 0;
    sort(check.begin(),check.end());

    for(int i = 0; i < N; i++) {
        if(check.at(i) != 0) num++;
    }

    num -= K;
    int i = 0;
    while(num > 0) {
        if(check.at(i) != 0) {
            ans += check.at(i);
            num--;
        }
        i++;
     }

    cout << ans << endl;

}


Measured memory_bytes: 1792
"use strict";
const main = arg => {
  let K = arg.split(" ")[0];
  let S = arg.split(" ")[1];
  let cnt = 0;
  for(let x = 0; x <= K; x++){
    for(let y = 0; y <= K; y++){
      // 3重ループだと計算量がひどかったので修正
      let z = S - (x + y);
      // 負の数を考慮するの忘れてたので追加
      if((z <= K) && (z >=0)){
      	cnt++;
      }
    }
  }
  console.log(cnt);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 11468
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back

using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll A, ll B, ll C, ll K){
    ll ans = (K % 2) ? (B - A) : (A - B);
    if (abs(ans) <= ll(1e18)) printf("%lld", ans);
    else printf("Unfair\n");
}

int main() {
    ll A;
    ignore_ret(scanf("%lld",&A));
    ll B;
    ignore_ret(scanf("%lld",&B));
    ll C;
    ignore_ret(scanf("%lld",&C));
    ll K;
    ignore_ret(scanf("%lld",&K));
    solve(A, B, C, K);
    return 0;
}

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

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

int main() {
	int i, j;
	int n;
	cin >> n;
	int p[n];
	for (i = 0; i < n; i++) {
		cin >> p[i];
	}
	int count = 0;
	for (i = 0; i < n; i++) {
		if (p[i] != i + 1) {
			count++;
		}
	}
	if (count <= 2) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	
	return 0;
}

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

int main(int argc, char *argv[]){
    int K,N,min;
    int i;
    int j=1;
    int array[100000];
    char buf[256];
    char num[10];
    scanf("%d %d",&K,&N);
    K=K-N;
    while(K>=1){
        K=K-(N-1);
        j++;
    }
    printf("%d",j);
}

Measured memory_bytes: 128
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            tmp=gcd(i,j)
            ans+=gcd(tmp,k)

print(ans)

Measured memory_bytes: 68848
#include <stdio.h>
 
int n,S[500001];
int a=0;
 
void merge(int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
   
  int L[n1+1], R[n2+1];
   
  int i, j, k;
   
  for(i=0; i<n1; i++)
    L[i] = S[left+i];
   
  for(i=0; i<n2; i++)
    R[i] = S[mid+i];
     
  L[n1] = 1000000001;
  R[n2] = 1000000001;
   
  i = 0;
  j = 0;
   
  for(k=left; k<right; k++){
    a++;
    if(L[i] <= R[j])
      S[k] = L[i++];
    else
      S[k] = R[j++];
  }
}
 
void mergeSort(int left, int right)
{
  int mid;
   
  if(right -left <= 1)
    return;
     
  mid = (left+right)/2;
  mergeSort(left, mid);
  mergeSort(mid, right);
   
  merge(left, mid, right);
}

int main(){
int i,left,right;
scanf("%d", &n);
for(i=0; i<n; i++)
scanf("%d", &S[i]);
left = 0;
right = n;
mergeSort(left, right);
for(i=0; i<n; i++){
if(i>0)
printf(" ");
printf("%d", S[i]);
  }
printf("\n");
printf("%d\n", a);
return 0;
}

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

void mincost(vector<vector<int>> c, vector<int> &cost, int i, int nowi, int nowcos, set<int> st){
  for(int j=0; j<10; j++){
    if ((nowi==j) || (st.find(j) != st.end())) continue;
    else if (j==1) {cost[i] = min(cost[i],c[nowi][j]+nowcos);
      //cout << "i:" << i << "  nowi:" << nowi << "  cost:" << cost[i] << endl;
    }
    else if (nowcos+c[nowi][j] < cost[i]){
      st.insert(nowi);
      //cout << "i:" << i << "  nowi:" << nowi << endl;
      mincost(c,cost,i,j,nowcos+c[nowi][j],st);
    }
  }
}

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int> > c(10, vector<int>(10,0));
  for (int i=0; i<10; i++){
    for (int j=0; j<10; j++) cin >> c[i][j];
  }
  vector<vector<int> > A(H, vector<int>(W));
  vector<int> cost(10);
  for (int i=0; i<10; i++) cost[i] = c[i][1];
  for (int i=0; i<10; i++){
    set<int> st;
    mincost(c,cost,i,i,0,st);
  }
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++) cin >> A[i][j];
  }
  long long ans = 0;
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++){
      if (A[i][j]>=0) ans += cost[A[i][j]];
    }
  }
  cout << ans << endl;
  //for (int i=0; i<10; i++) cout << cost[i] << endl;
}


Measured memory_bytes: 384
s = input()
n = len(s)

for i in range(n//2):
    if s[i] != s[-i-1]:
        print('No')
        exit()
s_ = s[:(n-1)//2]
for i in range(len(s_)//2):
    if s_[i] != s_[-i-1]:
        print('No')
        exit()
s__ = s[(n+3)//2-1:]
for i in range(len(s__)//2):
    if s__[i] != s__[-i-1]:
        print('No')
        exit()
print('Yes')

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

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


int sum[2][4000][4000];

void solve(ll N, ll K, vector<ll> x, vector<ll> y, vector<string> c) {
    int M = 2 * K;
    for (int i = 0; i < N; i++) {
        x[i] %= M;
        y[i] %= M;

        sum[c[i] == "W"][x[i] + M][y[i] + M]++;
        sum[c[i] == "W"][x[i]][y[i]]++;
        sum[c[i] == "W"][x[i] + M][y[i]]++;
        sum[c[i] == "W"][x[i]][y[i] + M]++;

    }
    for (int k = 0; k < 2; k++) {
        for (int i = 0; i < 2 * M; i++) {
            for (int j = 1; j < 2 * M; j++) {
                sum[k][i][j] += sum[k][i][j - 1];
            }
        }
    }
    for (int k = 0; k < 2; k++) {
        for (int i = 1; i < 2 * M; i++) {
            for (int j = 0; j < 2 * M; j++) {
                sum[k][i][j] += sum[k][i - 1][j];
            }
        }
    }
    auto f = [&](int k, int x, int y, int X, int Y) {
        int ans =
                sum[k][Y - 1][X - 1] - (y ? sum[k][y - 1][X - 1] : 0) - (x ? sum[k][Y - 1][x - 1] : 0) +
                (x && y ? sum[k][y - 1][x - 1] : 0);
        return ans;
    };
    int ans = 0;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
            int topLeft = f(0, i, j, i + K, j + K);
            int topRight = f(1, i, j + K, i + K, j + 2 * K);
            int bottomLeft = f(1, i + K, j, i + 2 * K, j + K);
            int bottomRight = f(0, i + K, j + K, i + 2 * K, j + 2 * K);
//            cout << topLeft << " " << topRight << " " << bottomLeft << " " << bottomRight << "(" << i << "," << j << ")"
//                 << endl;
            int sub = topLeft + topRight + bottomLeft + bottomRight;


            ans = max(ans, sub);
        }
    }
    cout << ans << endl;
}


void main_(istream &cin) {
    ll K;
    ll N;
    cin >> N;
    vector<string> c(N - 1 + 1);
    vector<ll> y(N - 1 + 1);
    vector<ll> x(N - 1 + 1);
    cin >> K;
    for (int i = 0; i <= N - 1; i++) {
        cin >> x[i];
        cin >> y[i];
        cin >> c[i];
    }
    solve(N, K, x, y, c);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 134656