akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//usage
//input! {
//  h: i32;
//  v: [i32; n]
//  x: [[i32; n]; m]
//  f: chars <- Vec<char>
//}

fn eratosthenes(n: i32) -> Result<Vec<i32>, String> {
    return match n {
        n if n < 2 => {
            return Err("n is more than 2".to_owned());
        }
        _ => {
            let mut prime = Vec::new();
            let limit = (n as f64).sqrt();
            let mut table: Vec<i32> = (2..(n + 1)).collect();
            let mut p = 0;

            loop {
                p = table[0];
                if limit <= p as f64 {
                    prime.append(&mut table);
                    return Ok(prime);
                }
                prime.push(p);
                table = table.into_iter().filter(|e| e % p != 0).collect();
            }
        }
    };
}

fn main() {
    input!(x: i32);
    let mut primes = eratosthenes(x * 2);
    for i in primes.unwrap() {
        if i >= x {
            println!("{}", i);
            break;
        } else {}
    }
}

Measured memory_bytes: 4352
while 1:
    n = input()
    if n == 0: break
    card1 = sorted([input() for i in range(n)])
    card2 = [i for i in range(1,2*n+1) if i not in card1]
    ba = 0
    turn = 1
    while card1 and card2:
        card = card1 if turn else card2
        for i in range(len(card)):
            if card[i] > ba:
                ba = card.pop(i)
                break
        else:
            ba = 0
        turn ^= 1
    print len(card2)
    print len(card1)

Measured memory_bytes: 6412
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long 
#define ull unsigned long long
#define MOD 1000000007

int n,m;
ll q[200005],h[200005];
ll sum=0;

int main()
{
	read(n),read(m);
	q[0]=0,h[n+1]=0;
	for(int i=1;i<=n;i++) q[i]=q[i-1]+1ll*i;
	for(int i=n;i>=1;i--) h[i]=h[i+1]+1ll*i;
	for(int i=m;i<=n;i++) sum=(sum+h[n-i+1]-q[i-1]+1)%MOD;
	printf("%lld\n",(sum+1)%MOD);
	return 0;
} 


Measured memory_bytes: 6892
#include <stdio.h>
#include <string.h>
int main(void){
	int i;
	
	while(1){
		char number[1001]={0};
		scanf("%s",number);
		int len;
		len=strlen(number);
		int sum=0;
		for(i=0;i<len;i++){
			sum+=number[i]-'0';
		}
		if(sum==0) break;
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 536
#include <stdio.h>

int main(void)
{
        int c=0;
        char s[4];
        scanf("%s",s);

        for(int i=0;i<3;i++)
                if(s[i]=='R')c++;

        if(c==0 || c==1 || c==3)printf("%d\n",c);
        else if(c==2){
                if(s[0]==s[1] || s[1]==s[2])printf("%d\n",c);
                else printf("1\n");
        }
        return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> x1 >> y1 >> x2 >> y2;

	int x, y;
	x = x2 - x1;
	y = y2 - y1;

	x4 = x1 - y;
	y4 = y1 + x;
	x3 = x2 - y;
	y3 = y2 + x;

	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a;
  int b;
  cin >> n;
  cin >> a;
  cin >> b;
  if(n * a < b){
    cout << n * a << endl;
  }else{
    cout << b << endl;
  }
  return 0;
}

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

int main(){
	ll a,b,c,d;
  	cin >> a >> b >> c >> d;
  
  	ll mx = a*c;
    mx = max(mx, a*d);
    mx = max(mx, b*c);
   	mx = max(mx, b*d);
      
    if ( mx < 0 && (b>=0 && d>=0) ) mx = 0;
  
  	cout << mx << endl;
  
  	
}

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

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  
  int ret = 0;
  int num = log(1e9)/log(K)+5;
  for(int i=0; i<num; i++){
    if(N % K) ret = i+1;
    N = N/K;
  }

  cout << ret << endl;
  return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }
  cout << n - (k - 1) - 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

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

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	cin >> n >> s;
	string s1, s2;
	vi vs;

	REP(i, n) {
		s1 = s.substr(0, i+1);
		s2 = s.substr(i+1);

		cnt = 0;

		REP(j, s1.size()) {
			if (s2.find(s1.at(j)) != string::npos) {
				cnt += 1;
				replace(ALL(s2), s1.at(j), ' ');
			}
		}
		vs.pb(cnt);
		//cout << cnt << endl;
		//cout << s1 << endl;
		//cout << s2 << endl;
	}
	sort(ALL(vs));
	//cout << vs << endl;
	cout << vs.back() << endl;
}



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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    cin >> N;
    bool x = false;
    for (int i = 1; i <= 9; i++)
        if (N % i == 0 && N / i <= 9)
            x = true;
    cout << (x ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<long,long>
#define vi          vector<long long>
#define vii         vector<pii>
#define mi          map<long long,long long>
#define mii         map<pii,long long>
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(long long i=a;i<b;i++)
#define repr(i,a,b) for(long long i=a;i>=b;i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;

signed main()
{
	io;
	int n;
	cin >> n;
	int a[n];
	rep(i,0,n) cin >> a[i];
	int mx = a[0];
	int ans=0;
	rep(i,1,n)
	{
		if(a[i]<mx)
		{
			ans+=mx-a[i];
		}
		else
		{
			mx = a[i];
		}

	}
	cout << ans <<endl;
}
 
	
		



Measured memory_bytes: 5212
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    vector<string> deck;
    string s;
    for(int i = 0; i < 3; i++) {
        cin >> s;
        reverse(s.begin(), s.end());
        deck.push_back(s);
    }
    int idx = 0, nxt = 0;
    while(!deck[idx].empty()) {
        nxt = deck[idx].back()-'a';
        deck[idx].pop_back();   
        idx = nxt;
        // cout << idx << endl;     
    }
    cout << char('A'+idx) << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int N;
    ll A[200000];

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

    ll s = 0;
    ll v = 0;
    for(int i = N-1; 0 < i; i--){
        v += A[i];
        v %= (1000000007);
        s += A[i-1] * v;
        s %= (1000000007);
    }

    cout << s << endl; 
}


Measured memory_bytes: 5196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();

		if((A * B) % 2 == 0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    //string s;cin>>s;
    //bool ok=true;
    //int n;cin>>n;
    int a,b;cin>>a>>b;
    if(a<=8&&b<=8)cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    string S,A[]={"YYMM","MMYY","AMBIGUOUS","NA"};
    cin >> S;
    int aa,bb;
    aa = (S[0] - '0') * 10;
    aa += S[1] - '0';
    bb = (S[2] - '0') * 10;
    bb += S[3] - '0';

    int i=0;
    if (aa >= 1 and aa <= 12) {
        if (bb >= 1 && bb <= 12) {
            i = 2;
        } else {
            i = 1;
        }
    } else if (bb >= 1 && bb <= 12) {
        i = 0;
    } else {
        i = 3;
    }

    cout << A[i] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[105];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);
    int i;
    int cnt=0;
    for(i=0; i<n/2; i++) {
        if(str[i]!=str[n-1-i]) cnt++;
    }
    printf("%d\n", cnt);

    return 0;
}



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

struct UnionFind{
    int num;
    vector<int> par,rank;
    UnionFind(int n):num(n),par(n),rank(n,1){
        iota(par.begin(),par.end(),0);
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    bool merge(int x, int y){
        x=root(x),y=root(y);
        if (x==y) return false;
        if (rank[x]<rank[y]) swap(x,y);
        par[y]=x;
        rank[x]+=rank[y];
        --num;
        return true;
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    int size(int x){
        return rank[root(x)];
    }
    int count(){
        return num;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<ll> A(N),B(N),C(N),D(M),E(M),F(M),xs,ys;
    for (int i=0;i<N;++i){
        cin >> A[i] >> B[i] >> C[i];
        xs.emplace_back(A[i]);
        xs.emplace_back(B[i]);
        ys.emplace_back(C[i]);
    }
    for (int i=0;i<M;++i){
        cin >> D[i] >> E[i] >> F[i];
        xs.emplace_back(D[i]);
        ys.emplace_back(E[i]);
        ys.emplace_back(F[i]);
    }
    sort(xs.begin(),xs.end());
    sort(ys.begin(),ys.end());
    xs.erase(unique(xs.begin(),xs.end()),xs.end());
    ys.erase(unique(ys.begin(),ys.end()),ys.end());
    for (int i=0;i<N;++i){
        A[i]=lower_bound(xs.begin(),xs.end(),A[i])-xs.begin();
        B[i]=lower_bound(xs.begin(),xs.end(),B[i])-xs.begin();
        C[i]=lower_bound(ys.begin(),ys.end(),C[i])-ys.begin();
    }
    for (int i=0;i<M;++i){
        D[i]=lower_bound(xs.begin(),xs.end(),D[i])-xs.begin();
        E[i]=lower_bound(ys.begin(),ys.end(),E[i])-ys.begin();
        F[i]=lower_bound(ys.begin(),ys.end(),F[i])-ys.begin();
    }
    int X=xs.size()-1,Y=ys.size()-1;
    int sx=lower_bound(xs.begin(),xs.end(),0)-xs.begin()-1;
    int sy=lower_bound(ys.begin(),ys.end(),0)-ys.begin()-1;
    if (sx<0||sy<0){cout << "INF" << '\n'; return 0;}
    int s=sx*Y+sy;
    vector<vector<bool>> wy(Y+1,vector<bool>(X)),wx(X+1,vector<bool>(Y));
    for (int i=0;i<N;++i){
        for (int j=A[i];j<B[i];++j){
            wy[C[i]][j]=true;
        }
    }
    for (int i=0;i<M;++i){
        for (int j=E[i];j<F[i];++j){
            wx[D[i]][j]=true;
        }
    }
    UnionFind uf(X*Y+1);
    for (int i=0;i<=Y;++i){
        for (int j=0;j<X;++j){
            if (!wy[i][j]){
                if (i==0) uf.merge(j*Y+i,X*Y);
                else if (i==Y) uf.merge(j*Y+i-1,X*Y);
                else uf.merge(j*Y+i-1,j*Y+i);
            }
        }
    }
    for (int i=0;i<=X;++i){
        for (int j=0;j<Y;++j){
            if (!wx[i][j]){
                if (i==0) uf.merge(i*Y+j,X*Y);
                else if (i==X) uf.merge((i-1)*Y+j,X*Y);
                else uf.merge((i-1)*Y+j,i*Y+j);
            }
        }
    }
    if (uf.same(s,X*Y)){cout << "INF" << '\n'; return 0;}
    ll ans=0;
    for (int i=0;i<X*Y;++i) if (uf.same(s,i)){
        ans+=(xs[i/Y+1]-xs[i/Y])*(ys[i%Y+1]-ys[i%Y]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 76008
// abc.051.C - Back and Forth

#include <bits/stdc++.h>
using namespace std;

int main( void ) {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = abs( tx - sx );
    int dy = abs( ty - sy );

//1周目	
	//上り、右（ゴール）
    cout << string( dy, 'U' ) << string( dx, 'R' );
	
	//下り、左（スタートに戻る）
    cout << string( dy, 'D' ) << string( dx, 'L' );

// 2周目
    //左に出てから上り、右（ゴール）
    cout <<'L' << string( dy+1, 'U' ) << string( dx+1, 'R' )<<'D';

    //下り、左（スタートに戻る）
    cout <<'R'<< string( dy+1, 'D' ) << string( dx+1, 'L' )<<'U';

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
public class Hello{
    public static void Main(){
        
        var line = System.Console.ReadLine();
        string[] array = line.Split(' ');
        int a = int.Parse(array[0]);
        int b = int.Parse(array[1]);
        
        int menseki = a * b;
        int length = a*2 + b*2;
        
        System.Console.WriteLine(menseki + " " + length);
    }
}



Measured memory_bytes: 17720
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i
k = gets.chomp.to_i
x = [a, b, c, d, e]

for y in 0..3
  if x[4 - y] - x[0] > k
    puts ":("
    exit
  end
end
puts "Yay!"


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    int a[n], g[h][w];
    for (int j = 0; j < n; j++) {
        cin >> a[j];
    }
    int t = 0, p = 0;
    for (int j = 0; j < h; j++) {
        int i;
        if (j % 2) {
            i = w - 1;
            while (i >= 0) {
                while (i >= 0 && p < a[t]) {
                    g[j][i--] = t + 1;
                    p++;
                }
                if (p == a[t]) {
                    t++;
                    p = 0;
                }
            }
        }
        else {
            i = 0;
            while (i < w) {
                while (i < w && p < a[t]) {
                    g[j][i++] = t + 1;
                    p++;
                }
                if (p == a[t]) {
                    t++;
                    p = 0;
                }
            }
        }
    }
    for (int j = 0; j < h; j++) {
        for (int i = 0; i < w; i++) {
            cout << g[j][i] << " ";
        }
        cout << '\n';
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;

int main(){
    int n;  cin >> n;
    vector<ll> a(n);
    vector<ll> r(n);
    ll x=0;
    for(int i=0; i<n; i++){
        cin >> a.at(i); a.at(i) *= 2;
    }
    
    for(int i=0; i<n; i++)    x = a.at(i)-x;
    
    x /= 2;
    
    for(int i=0; i<n; i++){
        cout << x << ' ';
        x = a[i] - x;
    }
    cout << endl;


}

Measured memory_bytes: 2944
// C# program to build the smallest number 
// by removing n digits from a given number 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{

    public static void Main(String[] args)
    {
        //var n = int.Parse(Console.ReadLine());
        //var k = int.Parse(Console.ReadLine());
        //var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        //CollectBalls(n, k, arr);
        var name = Console.ReadLine();
        Contest(name);
    }

    public static void Contest(string contestName)
    {
        var ss = contestName.ToCharArray();

        if (ss.Contains('B'))
            Console.Write("ARC");
        else
            Console.Write("ABC");
    }
}




Measured memory_bytes: 18292
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] t = new int[n+1];
		int sum = 0;
		for(int i=1; i<=n; i++) {
			t[i]=scan.nextInt();
			sum+=t[i];
		}
		int m = scan.nextInt();
		int[] result = new int[m];
		int p,x;
		for(int i=0; i<m; i++) {
			p = scan.nextInt();
			x = scan.nextInt();
			result[i] = sum+(x-t[p]);
		}
		for(int r:result)System.out.println(r);

	}

}

Measured memory_bytes: 21716
use std::io::{BufRead, BufWriter, Write};

fn main() {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    solve(&mut stdin.lock(), &mut BufWriter::new(stdout.lock()));
}

fn solve<R: BufRead, W: Write>(stdin: &mut R, stdout: &mut BufWriter<W>) {
    let ell = stdin.gets().parse::<usize>().unwrap();
    let mut n = 0;
    while (1 << n) <= ell {
        n += 1;
    }
    let base = (1 << n - 1) - 1;
    let mut edges = Vec::new();
    for i in 0..n - 1 {
        edges.push((i, i + 1, 0));
        edges.push((i, i + 1, 1 << i));
    }
    let mut rem = ell - 1 - base;
    let mut i = 0;
    let mut next = base + 1;
    while rem > 0 {
        if rem % 2 == 1 {
            edges.push((i, n - 1, next));
            next += 1 << i;
        }
        rem /= 2;
        i += 1;
    }
    writeln!(stdout, "{} {}", n, edges.len()).unwrap();
    for (f, t, c) in edges {
        writeln!(stdout, "{} {} {}", f + 1, t + 1, c).unwrap();
    }
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline LL Read()
{
	LL x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;
const int mod = 1e9 + 7;

LL x, y, s[MAXN];
int n;

struct BIT
{
	vector <int> u;
	int b[MAXN];

	inline void Modify(int x, int v)
	{
		for (u.pb(++ x); x <= n; x += x & -x)
			(b[x] += v) %= mod;
	}

	inline int Query(int x)
	{
		int r = 0;
		for (x ++; x; x -= x & -x)
			(r += b[x]) %= mod;
		return r;
	}

	inline void Clear()
	{
		for (auto x : u)
			for (; x <= n; x += x & -x)
				b[x] = 0;
		u.clear();
	}
} f, g;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), x = Read(), y = Read();
	for (int i = 1; i <= n; i ++)
		s[i] = Read();
	s[0] = -max(x, y), f.Modify(0, 1);
	for (int i = 1; i <= n; i ++)
	{
		int p = g.Query(upper_bound(s, s + i, s[i] - x) - s - 1), q = f.Query(upper_bound(s, s + i, s[i] - y) - s - 1);
		if (s[i] - s[i - 1] < x)
			f.Clear();
		if (s[i] - s[i - 1] < y)
			g.Clear();
		f.Modify(i - 1, p);
		g.Modify(i - 1, q);
	}
	return printf("%d\n", (f.Query(n - 1) + g.Query(n - 1)) % mod), 0;
}


Measured memory_bytes: 2804
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
def do():
    a,b=INTM()
    print((a+b)%24)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int[] stack = new int[N + 1];
			int top = 0;
			int color = sc.nextInt();
			for (int i = 1; i < N; ++i) {
				int cur = sc.next().charAt(0) - '0';
				if (color == cur) continue;
				color = cur;
				if (i % 2 == 0) {
					stack[top++] = i;
				} else {
					if (top > 0) --top;
				}
			}
			stack[top++] = N;
			int ans = 0;
			int cur = 0;
			for (int i = 0; i < top; ++i) {
				if (i % 2 == 0) ans += stack[i] - cur;
				cur = stack[i];
			}
			if (color == 0 ^ top % 2 != 0) ans = N - ans;
			System.out.println(ans);
		}
	}

}

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

int main() {
	string s;
	cin>>s;
	int l1,l2;
	if(s.size()%2){
		l1=1;
	}else{
		l1=0;
	}
	if(s[0]==s.back()){
		l2=1;
	}else{
		l2=0;
	}
	if(l1==l2){
		cout<<"Second"<<endl;
	}else{
		cout<<"First"<<endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
ll b[505],a[505],ans=0;

rep(i,1,n-1)cin>>b[i];

a[n]=b[n-1];
ren(i,n-1,1)a[i]=min(b[i],b[i-1]);
a[1]=b[1];
rep(i,1,n)ans+=a[i];
ol(ans);
return 0;
}



Measured memory_bytes: 256
main = do
  [x, y] <- map read . words <$> getLine
  putStrLn $ solve x y

solve:: Int -> Int -> String
solve x y
  | x == 2 = "No"
  | y == 2 = "No"
  | xa && ya = "Yes"
  | not xa && not ya = "Yes"
  | otherwise = "No"
  where
    a = [1, 3, 5, 7, 8, 10, 12]
    xa = elem x a
    ya = elem y a

Measured memory_bytes: 508
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
typedef long long ll;
const long long llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,m,k,i,j,l,r,viz[801][801],ans=1e8;
pair<int,int>a[]={{1,0},{-1,0},{0,1},{0,-1}};
char c[801][801];
void solve(int i,int j)
{
	viz[i][j]=1;
	int d=min(min(i,j),min(n-i-1,m-j-1));
	ans=min(ans,(d+k-1)/k);
	for(int t=0;t<4;t++)if(i+a[t].fr>=0 && i+a[t].fr<n && j+a[t].sc>=0 && j+a[t].sc<m && !viz[i+a[t].fr][j+a[t].sc] && c[i+a[t].fr][j+a[t].sc]!='#' && abs(l-i-a[t].fr)+abs(r-j-a[t].sc)<=k)solve(i+a[t].fr,j+a[t].sc);
}
int main()
{
	//freopen("sol.in","r",stdin);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m>>k;
	for(i=0;i<n;i++)
	 for(j=0;j<m;j++)
	 {
	 	cin>>c[i][j];
	 	if(c[i][j]=='S')l=i,r=j;
	 }
	solve(l,r);
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 15744
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}


bool P[100005];
vector<ll> prime;
vector<pair<ll,ll> > PN;
ll N , M;


ll fact[200001];
void gene(){
    P[0] = true;
    P[1] = true;
    rep(i, sqrt(M+1) + 1) rep(j, sqrt(M+1) + 1){
        if(i <= 1) continue;
        if(j <= 1) continue;
        if(i * j > (sqrt(M+1)+1)) break;
        
        P[i*j] = true;
    }
    
    rep(i, sqrt(M+1)+1){
        if(P[i] == false) prime.pb(i);
    }
    
    ll a = M ;
    rep(i, prime.size()){
        if(a == 1) break;
        
        ll cnt = 0;
        while(true){
            if(a % prime[i] != 0) break;
            else{
                cnt ++;
                a /= prime[i];
            }
        }
        if(cnt != 0)PN.pb(mp(prime[i], cnt));
    }
    if(a != 1) PN.pb(mp(a, 1));
    
    
    ll now = 1;
    rep(i, N + 100000){
        if(i == 0) {
            fact[i] = 1;
            continue;
        }
        now *= i;
        now %= MOD;
        fact[i] = now;
        
    }
    return ;
}


ll comb(ll a,  ll b){
    ll ans = fact[a];
    ans *= power(fact[b], MOD-2);
    ans %= MOD;
    ans *= power(fact[a-b], MOD-2);
    ans %= MOD;
    return ans ;
}



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

    cin >> N >> M ;
    gene();
    
    ll ans = 1;
    rep(i, PN.size()){
        ans *= comb(PN[i].second + N - 1, PN[i].second);
        ans %= MOD;
    }
    cout <<  ans  << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int main(){
  long long int N, mod = 1000000007;
  cin >> N;
  long long int T[N], A[N];
  for(int i = 0; i < N; ++i)
    cin >> T[i];
  for(int i = 0; i < N; ++i)
    cin >> A[i];
  long long int H[N], L[N];
  fill(H,H+N,100000000000);
  fill(L,L+N,1);
  H[0] = T[0];
  L[0] = T[0];
  L[N-1] = A[N-1];
  H[N-1] = A[N-1];
  if(T[0] > A[0] || T[N-1] < A[N-1]){
    cout << 0 << endl;
    return 0;
  }
  for(int i = 1; i < N; ++i){
    if(T[i-1] != T[i]){
      H[i] = T[i];
      L[i] = T[i];
    }else{
      H[i] = min(H[i],T[i]);
    }
  }
  for(int i = N-2; i >= 0; --i){
    if(A[i+1] != A[i]){
      if((H[i] < A[i] || L[i] > A[i])){
	cout << 0 << endl;
	return 0;
      }
      H[i] = A[i];
      L[i] = A[i];
    }else{
      H[i] = min(H[i],A[i]);
    }
  }
  /*
  for(int i = 0; i < N; ++i){
    cout << H[i] << " ";
  }cout << endl;
  for(int i = 0; i < N; ++i){
    cout << L[i] << " ";
  }cout << endl;
  */
  long long int ans = 1LL;
  for(int i = 0; i < N; ++i){
    ans *= (H[i]-L[i]+1)%mod;
    ans %= mod;
  }
  cout << ans%mod << endl;
  return 0;
}


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

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

int main() {
    ll n,x,ans=0; cin>>n>>x;
    vector<ll> a(n,0);
    rep(i,n) cin>>a[i];
    if(a[0]>x){
        ans+=a[0]-x;
        a[0]=x;
    }
    for(ll i=1;i<n;i++){
        if(a[i-1]+a[i]>x){
        ans+=a[i-1]+a[i]-x;
        a[i]=x-a[i-1];
            }
        }
    cout<<ans<<endl;
}

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

using namespace std;
#define ll long long
const int MAX =1e5+9;





int main ()
{

    int n , m , ans=0;
    cin>>n>>m;
    for ( int i = n ;i<=m ;i++)
    {

            if (i%10==(i/10000)%10&&(i/10)%10==(i/1000)%10)
                ans++;
    }
    cout<<ans;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i, n) cin >> s[i];

  vector<int> dp(10001, 0);
  dp[0] = 1;

  rep(i, n) for (int j = 10000; j >= 0; --j) {
    if (dp[j] == 1) continue;
    if (j - s[i] >= 0) dp[j] = dp[j - s[i]];
  }

  int ans = 0;
  for (int j = 10000; j >= 0; --j) {
    if (dp[j] == 1 && j % 10 != 0) {
      ans = j;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>
#include<string.h>
 
#define N 1500000
#define L 13
   
char moji[N][L], order[7];

int main(){
    int i, j, num;
    char str[L];
    
    scanf("%d", &num);
    
    for(i = 0; i < N; i++)
      moji[i][0] = '\0';
    
    for(i = 0; i < num; i++){
        scanf("%s%s", order, str);
        if(strcmp(order, "insert") == 0)
	  insert(str);
        else{ 
            if(find(str) == 1)
	      printf("yes\n"); 
            else
	      printf("no\n");
        }
    }
     
    return 0;
}


int h1(int key){
    return key % N;
    }
 
int h2(int key){
    return  1 + (key % (N-1));
    }
   
int ctoi(char str){
    if(str == 'A')
      return 1;
    else if(str == 'C')
      return 2;
    else if(str == 'G')
      return 3;
    else if(str == 'T')
      return 4;
    else
      return 0;
}
   
int getKey(char str[]){
    int sum = 0, time = 1, i;
    
    for(i = 0; i < strlen(str); i++){
        sum += time * (ctoi(str[i]));
        time *= 4;
    }
    return sum;
}
   
void insert(char str[]){
    int i, key, h;
    
    key = getKey(str);
    
    for(i = 0;; i++){
        h = (h1(key) + i * h2(key)) % N;
        if(strcmp(moji[h], str) == 0)
	  break;
        else if(strlen(moji[h]) == 0){
            strcpy(moji[h], str);
            break;
        }
    }
}
   
int find(char str[]){
    int key, i, h;
    
    key = getKey(str);
    for(i = 0;; i++){
        h = (h1(key) + i * h2(key)) % N;
        if(strcmp(moji[h], str) == 0)
	  return 1;
        else
	  return 0;
    }
}

Measured memory_bytes: 19648
import java.util.*;
class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] b = new int[n];
        for (int i =0;i<n;i++){
            b[i] = sc.nextInt();
        }
        System.out.println(permutation(b));
        sc.close();
    }
    public static int permutation(int[] q){
        int ret = 0;
        for (int var = 0 ; var < q.length-1 ; var++) {
            for (int var2 = 0; var2 < q.length ;var2++) {
                if(var < var2) ret += q[var] * q[var2];
              
              //System.out.println(var + " " + var2 +  " " + ret);
            }
        }
        return ret;
    }
}



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

long long A, B, N, ans;
int main()
{
	scanf("%lld%lld%lld", &A, &B, &N);
	if (N >= B) ans = A - ceil(A / (long double) B);
	printf("%lld\n", max(ans, A * N / B - A * (N / B)));
	return 0;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i=0; i<(int)(n); ++i)
 
template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}

// ll a[100010][3];
// ll dp[110][100010];  // [品物][重さ] としたときの価値の最大値
// ll weight[110], value[110];

int main() {
  ll X, Y; cin >> X >> Y;
  vector<ll> ansv;
  while(1){
    if(Y>=X){
      ansv.emplace_back(X);
      X *= 2;
    } else {
      break;
    }
  }
  cout << ansv.size() << endl;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
//  pair<int,int>pa;
//  vector<pair<int,int>>vec;

int main(){
 int N,M,han,ans=0;
  cin >>N;
  vector<int>v(N);
  
  for(int i=0;i<N;i++){
    cin>>v.at(i);
  }
  
  sort(v.begin(),v.end());  
  M=v.at(1);
  
  for(int i=M;i>0;i--){
    han=0;
    for(int j=0;j<N;j++){
      if(han>=2){
        break;
      }
      if(v.at(j)%i!=0){
        han++;
      }
    }
    if(han>=2){
      continue;
    }
    ans = i;
    if(ans!=0){
      break;
    }
  }
  
  cout <<ans<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double num = sc.nextDouble();
		int count = 0;

		for(int i = 1;i<=num;i++) {
			if(i % 2 == 1) {
				count++;
			}
		}

		System.out.println(count / num);
	}

}

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

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-01-27 14:25:45
# @Description: You build it. You run it
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int main()
{
    string s;
    pair<int , int >ans = make_pair(-2,-2);
    cin >> s;
    int len = s.length();
    for(int i = 1; i < len; i++){
        if(s[i] == s[i-1]){
            ans.first = i-1, ans.second = i;
            break;
        }
    }
    for(int i = 2; i < len; i++){
        if(s[i] == s[i-2]){
            ans.first = i-2, ans.second = i;
            break;
        }
    }
    /*if(ans.second == -1 && ans.first == -1){
        cout << "-1 -1\n";exit(0);
    }*/
    cout << ans.first + 1<< " " << ans.second +1<< endl;
    //system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  int N , M; cin >> N >> M;
  vector<P1> a(M); rep(i,M) cin >> a.at(i).fi >> a.at(i).sc.fi; rep(i,M) a[i].sc.sc = i;
  SORT(a);

  vector<int> num(M);
  int cnt = 1;
  num[0] = cnt;
  rep(i,M - 1){
    if(a[i].fi == a[i + 1].fi) num[i + 1] = ++cnt;
    else{
      cnt = 1;
      num[i + 1] = cnt;
    }
  }

  vector<P1> b(M);
  rep(i,M){
    b[i].fi = a[i].sc.sc;
    b[i].sc.fi = a[i].fi;
    b[i].sc.sc = num[i];
  }
  SORT(b);

  rep(i,M){
    printf("%06d", b[i].sc.fi);
    printf("%06d", b[i].sc.sc);
    cout << endl;
  }
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

//Union-Find Tree
class UnionFind{
public:
    int N;              //頂点数
    vector<int> par;    //par[i]:iの親の番号
    vector<int> size;   //size[i]:iが属するグループと同じグループに属する頂点数

    UnionFind(int n) : N(n), par(n), size(n, 1){  //初期化時はすべて根とする
        for(int i=0; i<n; i++){
            par.at(i) = i;
        }
    }

    int root(int x){    //データxが属する木の根を再帰で得る
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = root(par.at(x)); //経路圧縮を同時に実行
        }
    }

    void unite(int x, int y){   //xの属する木とyの属する木を併合
        int rx = root(x), ry = root(y);
        if(rx != ry){   //xとyの属する木が異なるとき
            par.at(rx) = ry;    //xの木の根をyの根につける
            size.at(ry) += size.at(rx);   //sizeを更新
        }
    }

    int getSize(int x){         //xの属する木のサイズを返す
        return size.at(x) = size.at(root(x));
    }

    bool same(int x, int y){    //x,yが同じ木に属するときtrue, そうでなければfalse
        return root(x) == root(y);
    }
};

signed main(){
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(3));
    REP(i, n){
        v[i][0] = i;
        cin >> v[i][1] >> v[i][2];
    }

    typedef tuple<int,int,int> TP;
    auto c = [](TP a, TP b){return get<2>(a) > get<2>(b);};
    priority_queue<TP, vector<TP>, decltype(c)> p(c), q(c);
    sort(all(v), [](auto a, auto b){return a[1] < b[1];});
    REP(i, n-1){
        p.push(make_tuple(v[i][0], v[i+1][0], v[i+1][1] - v[i][1]));
    }
    sort(all(v), [](auto a, auto b){return a[2] < b[2];});
    REP(i, n-1){
        q.push(make_tuple(v[i][0], v[i+1][0], v[i+1][2] - v[i][2]));
    }

    ll ans = 0;
    UnionFind UF(n);
    while(UF.getSize(0) < n){
        TP t1 = p.top(), t2 = q.top();
        if(get<2>(t1) < get<2>(t2)){
            p.pop();
            if(!UF.same(get<0>(t1), get<1>(t1))){
                UF.unite(get<0>(t1), get<1>(t1));
                ans += get<2>(t1);
            }
        }else{
            q.pop();
            if(!UF.same(get<0>(t2), get<1>(t2))){
                UF.unite(get<0>(t2), get<1>(t2));
                ans += get<2>(t2);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  ll L,R; cin >> L >> R;
  ll d; cin >> d;

  int ans = 0;
  for(ll i = L; i <= R; i++){
    if(i%d==0) ans++;
  }
  cout << ans << endl;
}


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

typedef pair<string, string> P;
map<P, ll> f(string s){
	map<P, ll> ret;
	int L = s.size();
	for(int i = 0; i < 1 << L; i++){
		string l, r;
		for(int j = 0; j < L; j++){
			if(i >> j & 1){
				l += s[j];
			}
			else{
				r += s[j];
			}
		}
		ret[{l, r}]++;
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	string s;
	cin >> N >> s;

	N *= 2;
	string ls = s.substr(0, N / 2);
	string rs = s.substr(N / 2, N);
	auto lres = f(ls);
	auto rres = f(rs);

	ll ans = 0;
	for(auto v : lres){
		P p = v.first;
		reverse(p.first.begin(), p.first.end());
		reverse(p.second.begin(), p.second.end());
		swap(p.first, p.second);
		if(rres.count(p)){
			ans += v.second * rres[p];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 91904