akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cmath>
#define INF 1000000000000
typedef long long ll;
std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	ret.push_back(n);
	return ret;
}

bool is_integer( double x ){
  return std::floor(x)==x;
}

int main()
{
	ll N;
	ll cnt;
	ll wk;
	ll flg;
	flg=0;
	std::cin >> N;
	ll min;
	std::vector<ll> r = enum_div(N);
	min=INF;
	std::sort(r.begin(),r.end());//昇順ソート
	/*
	for(ll i=0;i<r.size();i++){
		printf("%lld\n",r[i]);
	}
	*/
	
	wk=sqrt(N);
	
	if(wk*wk==N){
		flg=1;
	}
	std::sort(r.begin(),r.end());//昇順ソート
	/*
	for(ll i=0;i<r.size();i++){
		printf("%lld\n",r[i]);
	}
	*/
	
	for(ll i=1;i<r.size();i++){
		if(min>r[i-1]+r[r.size()-i]-2){
			min=r[i-1]+r[r.size()-i]-2;
			//printf("%lld\n",r[i-1]);
			//printf("%lld\n",r[r.size()-i]);
		}

	}
	
	if(flg==1){
		if(min>sqrt(N)+sqrt(N)-2){
			min=sqrt(N)+sqrt(N)-2;
		}
	}
	
	printf("%lld",min);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
#define Endl endl
const int INF=100000000;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<(n-a)%b<<endl;
	return 0;
}

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

int main() {
  string str;
  
  cin >> str;
  

  if(str == "RRR"){
    cout << 3 << endl;
  }
  else if (str == "RRS"){
    cout << 2 << endl;
  }
  else if (str == "SRR"){
    cout << 2 << endl;
  }
  else if (str == "SSS") {
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
}
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    ll N;
    cin >> N;
    ll shou;
    ll amari;
    string ans;
    while(true) {
        amari = N%26;
        shou = (N-amari)/26;
        if (amari == 0) {
            ans += 'z';
            shou--;
        }
        else {
            ans += (char)('a' + amari-1);
        }
        if(shou <= 26) {
            break;
        }
        N = shou;
    }
    if(shou == 0) {
        cout << ans << endl;
        return 0;
    }
    ans += (char)('a' + shou-1);
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int dx[8] = {1,1,0,-1,-1,-1,0,1};
int dy[8] = {0,-1,-1,-1,0,1,1,1};
int map[52][52];

void foo(int y,int x,int n){
  int i;

  if(map[y][x] == -1){
    map[y][x] = n;
    for(i = 0;i < 8;i++){
      foo(y+dy[i],x+dx[i],n);
    }
  }
}

int main(){
  int w,h,i,j,ans;

  while(1){
    scanf("%d %d",&w,&h);
    if(w == 0 && h == 0){
      break;
    }
    ans = 0;

    for(i = 0;i < h;i++){
      map[i][0] = 0;
      map[i][h+1] = 0;
    }
    for(j = 0;j < w;j++){
      map[0][j] = 0;
      map[w+1][j] = 0;
    }

    for(i = 1;i <= h;i++){
      for(j = 1;j <= w;j++){
	scanf("%d",&map[i][j]);
	map[i][j] *= -1;
      }
    }

    for(i = 1;i <= h;i++){
      for(j = 1;j <= w;j++){
	if(map[i][j] == -1){
	  ans++;
	  foo(i,j,ans);
	}
      }
    }

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

  return 0;
}

Measured memory_bytes: 716
#include <bits/stdc++.h>
using namespace std;
// g++ -std=c++17 -Wshadow -Wall sol.cpp -o  s -DLOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using ld = long double;
using vvi = vector< vi > ;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3fll;
const ll mod = 1e9 + 7ll;
template<typename T> T abs (T x) { return x < 0 ? -x : x; }
template<typename T> void max_self(T &a, T b) {  a = max(a, b); }
template<typename T> void min_self(T &a, T b) {  a = min(a, b); }
const int MAX = 310;
double dp[MAX][MAX][MAX];
double ev[MAX][MAX][MAX];
void solve(int tc) {
  int n, x;
  cin >> n;
  int c1 = 0, c2 = 0, c3 = 0;
  memset(dp, 0 ,sizeof(dp));
  memset(ev, 0, sizeof(ev));
  for(int i = 0; i < n; ++i) {
    cin >> x;
    if(x == 1)++c1;
    else if(x == 2)++c2;
    else ++c3;
  }

  dp[c1][c2][c3] = 1;
  for(int k = n; k >= 0; --k) {
    for(int j = n; j >= 0; --j) {
      for(int i = n; i >=0; --i) {
        //eat none
        int total = i+j+k;
        if(i == 0 && j == 0 && k == 0)continue;
        if(total > n)continue;

        double p_waste = (double)(n - total) / n;
        double ev_waste = p_waste / (1 - p_waste);
        ev[i][j][k] += ev_waste * dp[i][j][k];
        debug() << imie(i) << imie(j) << imie(k) << imie(dp[i][j][k]) << imie(p_waste);
        //eat c3
        
        if(k - 1 >= 0) {
          dp[i][j + 1][k - 1] += dp[i][j][k] * k / total;
          ev[i][j + 1][k - 1] += ev[i][j][k] * k / total;
        }
        //eat c2
        if(j - 1 >= 0) {
          dp[i + 1][j - 1][k] += dp[i][j][k] * j / total;
          ev[i + 1][j - 1][k] += ev[i][j][k] * j / total;
        }
        //eat c1
        if(i - 1 >= 0) {
          dp[i - 1][j][k] += dp[i][j][k] * i / total;
          ev[i - 1][j][k] += ev[i][j][k] * i / total;
        }
      }
    }
  }
  cout << std::fixed << std::setprecision(12) << ev[0][0][0] + c1 + 2*c2 + 3*c3 << endl;
}
 
int main() {
  int tc = 1;
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cin >> tc;
  for(int i = 1; i <= tc; ++i)solve(i);
  return 0;
}

Measured memory_bytes: 465792
# coding: utf-8


n = int(input())

scores = [0,0]

for i in range(n):
    card = input().split()
    first_card = card[0]
    card.sort()
    if (card[0] == card[1]):
        scores[0] += 1
        scores[1] += 1
    elif(first_card == card[0]):
        scores[1] += 3
    else:
        scores[0] += 3

print(scores[0], scores[1])

Measured memory_bytes: 7696
#include<iostream>
#include<cmath>
//#include<algorithm>
using namespace std;

int main(){
	int n;
	int t;
	int a;
	int temp;
	int mininum;
	float tempsa;

	float mini = 1000;

	cin >> n >> t >> a;

	for (int i = 0; i < n; i++){
		cin >> temp;
		tempsa = abs(a - (t - temp * 0.006));
		if (tempsa < mini){
			mini = tempsa;
			mininum = i + 1;
		}
	}

	cout << mininum << endl;

	return 0;
}

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

using namespace std;

int main(){
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;
    string m = "";
    for (int i = 0; i < n; i++){
        m += s.substr(i,1) + t.substr(i,1);
    }
    cout << m;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <iostream>
 
using namespace std;
 
typedef long long ll;
 
ll A[200005];
 
int main(){
 
	int N;
 
	scanf("%d",&N);
 
	int i;
 
	for(i=0;i<N;i++){
		scanf(" %lld",&A[i]);
	}
 
	for(i=1;i<N;i++){
		A[i]+=A[i-1];
	}
 
	ll ans=1ll<<60;
 
	for(i=1;i<=N-3;i++){
 
		ll sum_l=A[i];
		ll sum_r=A[N-1]-A[i];
 
		int l,r,mid;
 
		l=1;
		r=i;
 
		while(l<r){
			mid=(l+r)/2;
			if(A[mid]>sum_l-A[mid]){
				r=mid;
			}
			else{
				l=mid+1;
			}
		}
		ll s11,s12,s21,s22;
 
		s11=llabs(A[l-1]-(sum_l-A[l-1]));
		s12=llabs(A[l]-(sum_l-A[l]));
 
		ll ma;
		ll mi;
 
		if(s11<s12){
			ma=max(A[l-1],sum_l-A[l-1]);
			mi=min(A[l-1],sum_l-A[l-1]);
		}
		else{
			ma=max(A[l],sum_l-A[l]);
			mi=min(A[l],sum_l-A[l]);
		}
 
		l=i+2;
		r=N-1;
 
		while(l<r){
			mid=(l+r)/2;
			if(A[mid]-A[i]>sum_r-(A[mid]-A[i])){
				r=mid;
			}
			else {
				l=mid+1;
			}
		}
 
		s21=llabs(A[l-1]-A[i]-(sum_r-(A[l-1]-A[i])));
		s22=llabs(A[l]-A[i]-(sum_r-(A[l]-A[i])));
 
		if(s21<s22){
			ma=max(ma,max(A[l-1]-A[i],sum_r-(A[l-1]-A[i])));
			mi=min(mi,min(A[l-1]-A[i],sum_r-(A[l-1]-A[i])));
		}
		else{
			ma=max(ma,max(A[l]-A[i],sum_r-(A[l]-A[i])));
			mi=min(mi,min(A[l]-A[i],sum_r-(A[l]-A[i])));
		}
		if(ans>ma-mi){ans=ma-mi;}
	}
 
	printf("%lld\n",ans);
 
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
//a+bがkで割り切れる->a%k+b%kがkで割り切れる
int main(){
    int N,K;cin >> N >> K;
    vector<ll> num(K,0);
    for(int i = 1; i <= N; i++)num[i%K]++;
    ll res = 0;
    rep(a,K){
        int b = (K-a)%K;//b = (K-a), bをKで割った余り
        int c = (K-a)%K;//c = (K-a), cをKで割った余り
        if ((b+c) % K != 0)continue;
        res += num[a] * num[b] * num[c];
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    string s;
    cin >> s;

    /*
     * TLE
    int res=0;

    while(1){
        bool flag=false;

        FOR(i,0,(int)s.sz()-1){
            string a,b;
            a=s[i],b=s[i+1];

            if(a!=b){
                s.erase(i,2);
                flag=true;
                res+=2;
                break;
            }
        }

        if(!flag)
            break;
    }

    cout << res << endl;
    */

    stack<char> S;
    int res=0;
    for(auto c: s){
        if(c=='0'){
            if(S.sz() && S.top()=='1'){
                res+=2;
                S.pop();
            }else{
                S.push(c);
            }
        }else{
            if(S.sz() && S.top()=='0'){
                res+=2;
                S.pop();
            }else{
                S.push(c);
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	int N, ans;

	cin >> N;

	ans = 0;

	for(;N>0;N/=10){
		if(N % 10 == 2){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 202020;

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

    vector<int> c(MAX_N);
    rep(i, n) {
        cin >> c[i];
        c[i]--;
    }

    vector<ll> dp(MAX_N);
    vector<int> last(MAX_N, -1);

    dp[0] = 1;
    rep(i, n) {
        dp[i+1] = dp[i];
        if(last[c[i]] != -1 && last[c[i]] != i-1) {
            dp[i+1] += dp[last[c[i]] + 1];
            dp[i+1] %= mod;
        }
        last[c[i]] = i;
    }

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

Measured memory_bytes: 3456
#include <iostream>
#include <iomanip>
#include <array>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <numeric>
#include <cassert>
#include <functional>
using namespace std;

typedef unsigned long long int llui;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
constexpr double pi = 3.141592653589793238462643383279502884L;

// TODO: Mod class

const int sz = 1e5;

int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  set<int> a;
  vector<int> b;
  for (int i = 0; i < m; ++i) {
    pii x;
    cin >> x.first >> x.second;
    if (x.first > x.second) {
      swap(x.first, x.second);
    }
    if (x.first == 1) {
      a.insert(x.second);
    }
    if (x.second == n) {
      b.push_back(x.first);
    }
  }
  for (int bb : b) {
    if (a.find(bb) != a.end()) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 5368
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)
	for _, r := range n {
		if r == '1' {
			fmt.Print("9")
			continue
		}
		if r == '9' {
			fmt.Print("1")
			continue
		}
		fmt.Print(string(r))
	}
	fmt.Print("\n")
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  string s;
  int i = 0;
  cin >> s;
  if (s.length() % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  while (i < s.length()) {
    if (s[i] != 'h' || s[i + 1] != 'i') {
      cout << "No" << endl;
      return 0;
    }
    i += 2;
  }
  cout << "Yes" << endl;
  return 0;
}

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

#include <vector>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
int main() {
    string x;
    cin >> x;
    long long count_0 = 0;
    long long count_1 = 0;
    for(int i=0;i<x.length();i++){
        if(x[i]=='0'){
            count_0 += 1;
        }else if(x[i]=='1'){
            count_1 += 1;
        }
    }
    cout << min(count_0,count_1)*2 << endl;
}


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

int n,m,k,xx,yy,d[3005],ans;
bool e[3005][3005];

void rec(int x){
	if (x>min(ans,k)) return;
	if (!*max_element(d+1,d+n+1)){
		ans=min(ans,x); return;
	}
	bool ok=true; int ret=0,sz,neg=0;
	vector<pair<int,int>> v1,v2;
	v1.clear(); v2.clear();
	while (ok){
		ok=false;
		for (int i=1;i<=n;i++){
			if (d[i]==1){
				ok=true;
				for (int j=1;j<=n;j++){
					if (e[i][j]){
						for (int k=1;k<=n;k++){
							if (e[j][k]){
								v1.push_back(make_pair(j,k));
								e[j][k]=e[k][j]=0;
								d[k]--;
							}
						}
						d[j]=0; ret++;
					}
				}
			}
		}
	}
	if (!*max_element(d+1,d+n+1)){
		sz=v1.size();
		for (int i=0;i<sz;i++){
			e[v1[i].first][v1[i].second]=1;
			e[v1[i].second][v1[i].first]=1;
			d[v1[i].first]++; d[v1[i].second]++;
		}
		ans=min(ans,x+ret); return;
	}
	for (int i=1;i<=n;i++){
		if (d[i]){
			for (int j=1;j<=n;j++){
				if (e[i][j]){
					d[j]--;
					e[i][j]=e[j][i]=0;
					v2.push_back(make_pair(i,j));
				}
			}
			d[i]=0;
			rec(x+ret+1);
			sz=v2.size();
			for (int i=0;i<sz;i++){
				e[v2[i].first][v2[i].second]=1;
				e[v2[i].second][v2[i].first]=1;
				d[v2[i].first]++; d[v2[i].second]++;
			}
			v2.clear();
			for (int j=1;j<=n;j++){
				if (e[i][j]){
					neg++;
					for (int k=1;k<=n;k++){
						if (e[j][k]){
							d[k]--;
							e[j][k]=e[k][j]=0;
							v2.push_back(make_pair(j,k));
						}
					}
					d[j]=0;
				}
			}
			rec(x+ret+neg);
			sz=v2.size();
			for (int i=0;i<sz;i++){
				e[v2[i].first][v2[i].second]=1;
				e[v2[i].second][v2[i].first]=1;
				d[v2[i].first]++; d[v2[i].second]++;
			}
			break;
		}
	}
	sz=v1.size();
	for (int i=0;i<sz;i++){
		e[v1[i].first][v1[i].second]=1;
		e[v1[i].second][v1[i].first]=1;
		d[v1[i].first]++; d[v1[i].second]++;
	}
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> k;
	while (m--){
		cin >> xx >> yy;
		e[xx][yy]=e[yy][xx]=1;
		d[xx]++; d[yy]++;
	}
	ans=1000000000; rec(0);
	if (ans>k) cout << "Impossible\n";
	else cout << ans << "\n";
}

Measured memory_bytes: 12192
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000000000000001
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,x,y;
    ll f=0;
    cin>>x>>y;
    for(i=0;i<=x;i++)
    {
        if(i*2 + (x-i)*4==y)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;

}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
    int j,v,N;
    int A[100];
    
    scanf("%d\n",&N);

    for (int i=0; i<N; i++) {
        scanf("%d",&A[i]);
    }
    for (int q=0; q < N-1; q++) {
            printf("%d ",A[q]);
        }
    printf("%d\n",A[N-1]);
    
    for (int i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		
		while (j >= 0 && A[j] > v) {
		    A[j+1] = A[j];
		    j--;
		}
		A[j+1] = v;
		
		for (int k=0; k < N-1; k++) {
            printf("%d ",A[k]);
        }
        printf("%d\n",A[N-1]);
    }
    return 0;
}


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

#define int long long
#define f first

#define s second
using namespace std;

template<typename T> using vc = vector<T>;
using pii=pair<int, int>;

void xmax(int & a, int b){
    a=max(a, b);
}
void xmin(int& a, int b){
    a=min(a, b);
}

void print(vc <int> & a, string s){
    cerr << s << " : ";
    for (int i=0; i<a.size(); i++){
        cerr <<a[i] << " ";
    }
    cerr << endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifdef LOCAL_RUN
    freopen("input.txt", "r", stdin);
    int ttt;
    cin >> ttt;
    while(ttt--){
    #endif // LOCAL_RUN
    int k, q;
    cin >> k >> q;
    vc <int> d (k);
    for (int i=0; i<k; i++){
        cin>> d[i];
    }
    for (int t =0 ; t<q; t++){
        int n, x, m;
        cin >> n >> x >> m;
        n--;
        vc <int> sum (k+1);
        for (int i=0; i<k; i++){
            if (d[i]%m == 0){
                sum[i+1]=sum[i]+m;
            }else{
                sum[i+1] = sum[i]+(d[i]%m);
            }
        }
        //print(sum, "sum");
        //cout << sum.back() << " sum back " << " anz ganz" << n/k << " mod " << n%k << " " << sum[n%k] << endl;
        int end_sum =x%m+(n/k)*sum.back() + sum[n%k];
        int res = n - end_sum/m;
        cout << res << "\n";
    }


    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
}


Measured memory_bytes: 384
#include<cstdio>
using namespace std;
const int maxn=2005,TT=924844033;
int n,m,K,a[maxn];
long long F[maxn][maxn][2],ans;
int main(){
	scanf("%d%d",&n,&K);m=K<<1;
	for (int i=1;i<=m;i++)
	for (int j=i;j<=n;j+=m) a[++a[0]]=j;
	F[0][0][0]=1;
	for (int i=1;i<=n;i++)
	for (int j=0;j<=n;j++){
		F[i][j][0]=F[i-1][j][0]+F[i-1][j][1];
		F[i][j][0]+=(a[i]>K)*(F[i-1][j-1][0]+(a[i]-a[i-1]!=m)*F[i-1][j-1][1]);
		F[i][j][1]=(a[i]+K<=n)*(F[i-1][j-1][0]+F[i-1][j-1][1]);
		F[i][j][0]%=TT,F[i][j][1]%=TT;
	}
	long long fct=1;
	for (int i=n;~i;i--){
		if(n-i) fct=fct*(n-i)%TT;
		ans+=(F[n][i][0]+F[n][i][1])*fct%TT*(i&1?-1:1);
	}
	printf("%lld\n",(ans%TT+TT)%TT);
	return 0;
}

Measured memory_bytes: 62848
#include <stdio.h>

/* プロセスに適した構造体 */
typedef struct {
    char name[11];
    int time;
} Queue;


int main()
{
    //入力
    int n, q;
    scanf("%d%d", &n, &q);

    int size = 2 * n;
    Queue Queue[size];
    int pre = 0, rear = 0, cnt = 0;
    for( rear = 0; rear < n; ++rear )
        scanf("%s %d", Queue[rear].name, &Queue[rear].time);


    //処理と出力
    while( pre != rear ){
        if( Queue[pre].time <= q ){
            cnt += Queue[pre].time;
            printf("%s %d\n", Queue[pre].name, cnt);
        } else {
            cnt += q;
            Queue[pre].time -= q;
            Queue[rear] = Queue[pre];
            rear = (rear + 1) % size;
        }

        //次の指す先
        pre = (pre + 1) % size;
    }


    return 0;
}

Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k;
	cin>>k;
	int n=50;
	cout<<n<<endl;
	vector<ll> a(n);
	rep(i,n){
		a[i]=i+k/n;
	}
	//cout<<a<<endl;
	k%=n;
	rep(i,k){
		a[i]+=n;
		rep(j,n){
			if(j==i) continue;
			a[j]--;
		}
		/*cout<<i<<endl;
		cout<<a<<endl;*/
	}
	cout<<a<<endl;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
P = np.array(input().split(), dtype=float)

dp = np.zeros(N + 1, dtype=float)
dp[0] = 1 - P[0]
dp[1] = P[0]

for i in range(N - 1):
    newDP = dp * (1 - P[i + 1])
    newDP[1:] += dp[:-1] * P[i + 1]
    dp = newDP.copy()

n = (N + 1) // 2
ans = dp[n:].sum()
print(ans)


Measured memory_bytes: 22404
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
int rows, columns;
vector<vector<char>> matrix;
vector<vector<int>> dp;
ll int mod = 1000000007;
int x[] = { 1, 0};
int y[] = { 0, 1};
int dfs(int row, int col)
{
    //cout<<row<<" "<<col<<endl;
    if (row >= rows || row < 0 || col >= columns || col < 0)
    {
        return 0;
    }
    if (row == rows - 1 && col == columns - 1)
    {
        return 1;
    }
    if(dp[row][col] != -1) return dp[row][col];
    int sum = 0;
    for (int i = 0; i < 2; i++)
    {
        int newRow = row + y[i];
        int newCol = col + x[i];
        if (newRow >= rows || newRow < 0 || newCol >= columns || newCol < 0 || matrix[newRow][newCol] == '#')
            continue;

        sum += dfs(newRow, newCol);
    }
    dp[row][col] = sum % mod;
    return dp[row][col];
}

int main()
{
    cin >> rows >> columns;
    matrix = vector<vector<char>>(rows, vector<char>(columns));
    dp = vector<vector<int>>(rows, vector<int>(columns,-1));
    
    for (int i = 0; i < rows; i++)
    {
        for (int j = 0; j < columns; j++)
        {
            cin >> matrix[i][j];
        }
    }
    cout << dfs(0, 0);
}

Measured memory_bytes: 8628
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll a,b,q;cin>>a>>b>>q;
    ll s[a+2];
    ll t[b+2];
    ll xx[q];
    s[0]=-1*pow(10,11);
    rep(i,1,a){
        cin>>s[i];
    }
    s[a+1]=pow(10,11);
    t[0]=-1*pow(10,11);
    rep(i,1,b){
        cin>>t[i];
    }
    t[b+1]=pow(10,11);
    rep(i,0,q-1){
        cin>>xx[i];
    }
    ll x;
    ll l,r,mid;
    ll ss;
    ll tt;
    ll ans[q];
    rep(i,0,q-1){
        x=xx[i];
        l=0;
        r=a+1;
        while(r-l>1){
            mid=(r+l)/2;
            if(s[mid]<=x){
                l=mid;
            }else{
                r=mid;
            }
        }
        ss=r;
        
        l=0;
        r=b+1;
        while(r-l>1){
            mid=(r+l)/2;
            if(t[mid]<=x){
                l=mid;
            }else{
                r=mid;
            }
        }
        tt=r;
        ans[i]=inf;
        ans[i]=min(ans[i],max(t[tt],s[ss])-x);
        ans[i]=min(ans[i],x-min(t[tt-1],s[ss-1]));
        ans[i]=min(ans[i],min(t[tt]-x,x-s[ss-1])*2+max(t[tt]-x,x-s[ss-1]));
        ans[i]=min(ans[i],min(s[ss]-x,x-t[tt-1])*2+max(s[ss]-x,x-t[tt-1]));
        cout<<ans[i]<<endl;
    }
    
    
    return 0;
}




Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define pint pair<int,int>
#define pdouble pair<double,double>
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(20);
    a[0] = 1;
    int p;
    double ans = 0;
    int m;
    rep(i,n){
        int count = 0;
        p = i+1;
        while(p < k){
            p = p*2;
            count++;
            if(a[count] == 0) a[count] = a[count-1]*2;
        }
        if(i == 0){
            m = a[count];
        }
        ans += m/a[count];
    }
    printf("%.10f\n", ans/(m*n));
    return 0;
}

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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */

int main()
{
    _fastio
    ll n;
    cin>>n;
    ll tl=0,mx,a;
    for1(i,n)
    {
        cin>>a;
        if(i==1)
        {
            mx=a;
        }
        else
        {
            if(a>=mx)
            {
                mx=a;
            }
            else
            {
                tl+=(mx-a);
            }
        }
    }
    cout<<tl<<en;
}


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

#define N 100000

int main(void){
    vector<bool> prime(N+1,true);
    prime[0]=prime[1]=false;
    for (size_t i = 2; i*i <= N; i++)
    {
        if (prime[i])
        {
            for (size_t j = 2; i*j <= N; j++)
            {
                prime[i*j]=false;
            }
        }
    }
    int likeCnt[N];
    for (size_t i = 1; i <= N; i++)
    {
        likeCnt[i]=likeCnt[i-1];
        if (i%2==1&&prime[i]&&prime[(i+1)/2]) likeCnt[i]++;
    }
    /**************************************/
    int q;
    scanf("%d", &q);
    int l,r;
    for (size_t i = 0; i < q; i++)
    {
        scanf("%d%d", &l, &r);
        printf("%d\n", likeCnt[r] - likeCnt[l-1]);
    }
    return 0;
}

Measured memory_bytes: 1024
import  java.util.*;

class Main{

 public static void main(String[] args){

     Scanner  sc = new Scanner(System.in);
     int a = sc.nextInt();
     int b = sc.nextInt();

if((a*b)%2 == 0)
   System.out.println("Even");
else
 System.out.println("Odd");
    }
}    


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++){
    cout<<"node "<<i+1<<": key = "<<a[i]<<", ";
    if(i) cout<<"parent key = "<<a[(i-1)/2]<<", ";
    if(i*2+1<n) cout<<"left key = "<<a[i*2+1]<<", ";
    if(i*2+2<n) cout<<"right key = "<<a[i*2+2]<<", ";
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string s;cin>>s;
    int sai = 0;
    int k = 0;
    for(int i = 0;i<s.length();i++){
      if(s[i] == 'A'){
        sai++;
        k = max(sai,k);
      }
      else if(s[i] == 'T'){
        sai++;
        k = max(sai,k);
      }
      else if(s[i] == 'C'){
        sai++;
          k = max(sai,k);
      }
      else if(s[i] == 'G'){
        sai++;
          k = max(sai,k);
      }
      else {
        k = max(sai,k);
        sai = 0;
      }
    }
    cout<<k;
    return 0;
}

Measured memory_bytes: 256
class PERM_COMB_MOD():
    # http://drken1215.hatenablog.com/entry/2018/06/08/210000
    def __init__(self, max_n=510000, mod=10**9+7):
        self.fac = [0]*max_n
        self.finv = [0]*max_n
        self.inv = [0]*max_n
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        self.max = max_n
        self.mod = mod
        self._maesyori()

    def _maesyori(self):
        for i in range(2,self.max):
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def comb(self, n, k):
        if n < k : return 0
        if n < 0 or k < 0:return 0
        return self.fac[n] * (self.finv[k] * self.finv[n-k] % self.mod) % self.mod

n,m,k = map(int, input().split())
if n==1:
    print(m)
    exit()

mod = 998244353

PCM = PERM_COMB_MOD(n+10, mod)

ans = 0
for i in range(k+1):
    ans += m * pow(m-1, n-1-i, mod) * PCM.comb(n-1, i)
    ans %= mod

print(ans)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    map<ll,int>mp;
    int ans=0;
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        mp[a[i]]++;
        mp[a[i]-1]++;
        mp[a[i]+1]++;
    }
    for(auto e:mp){
        ans=max(ans,e.second);
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
 using namespace std;  
ll t,n,c,c3,sum,m,mn,k,r,avg;
std::vector<int >v,v2;
std::map<int, int> mp;
bool isPrime(int x)
{
for (int i=2;i*i<=x;i++)
if (x%i==0)
return false;
return true;
}
 
int main(void)
 
{
int a,b;
cin>>a>>b;
bool f=false;

    for (int j=1;j<=1250;j++)
    if (floor(j*0.08)==a && floor(j*0.1)==b){
    cout<<j;
    f=true;
    break;}
    if (!f)cout<<-1;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
const int N = 1e5 + 10;

char s[5][5];

int main(){
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			cin >> s[i][j];
		}
	}
	printf("%c%c%c\n",s[0][0],s[1][1],s[2][2]);
}


Measured memory_bytes: 256
#include<stdio.h>
int gcd(int, int);

int gcd(int m, int n){
    if (n==0) {
        return m;
    }else {
        return gcd(n, (m%n));
    }
}

int main(){
    int m, n;
    scanf("%d%d",&m,&n);
    printf("%d\n",gcd(m, n));
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define ul unsigned long
#define ui unsigned int
#define pb push_back
#define ul unsigned long
#define show(x) ;//cerr << #x << ':' << x << endl;
ll dp[100000][4];

using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "[";
    for (int i = 0; i < v.size(); ++i)
    {
        os << v[i];
        if (i != v.size() - 1)
            os << ", ";
    }
    os << "]";
    return os;
}

template <typename T, typename S>
ostream &operator<<(ostream &os, const map<T, S> &m)
{
    os << "\n{\n";
    for (auto i : m)
    {
        os << i.first << ':' << i.second << " ,";
        os << "\n";
        os << "\n}\n";
        return os;
    }
}
long long func(long n, int k, vector<vector<ll>> &v)
{
    long long sum = 0;
    // show(n);
    // show(k);
    if (dp[n][k] != -1)
    {
        return dp[n][k];
    }
    if (n == v.size() - 1)
    {
        show(v[n][k]);
        return v[n][k];
    }
    else
    {
        ll maxi1 = 0;
        ll maxi2 = 0;
        ll maxi3 = 0;
        if (dp[n][k] == -1)
            for (int i = 0; i < 3; i++)
            {
                if (i != 0)
                    maxi1 = max(maxi1, v[n][0] + func(n + 1, i, v));
                if (i != 1)
                    maxi2 = max(maxi2, v[n][1] + func(n + 1, i, v));
                if (i != 2)
                    maxi3 = max(maxi3, v[n][2] + func(n + 1, i, v));
            }
        dp[n][0] = maxi1;
        dp[n][1] = maxi2;
        dp[n][2] = maxi3;
        show(n);
        show(k);
        show(dp[n][k]);
        sum += dp[n][k];
    }
    // if (k == 0)
    // {
    //     if (dp[n][k] == -1)
    //         dp[n][k] = std::max(func(n + 1, 1, v), func(n + 1, 2, v));
    //     sum += dp[n][k];
    // }
    // else if (k == 1)
    // {
    //     if (dp[n][k] == -1)
    //         dp[n][k] = max(func(n + 1, 0, v), func(n + 1, 2, v));
    //     sum += dp[n][k];
    // }
    // else if (k == 2)
    // {
    //     if (dp[n][k] == -1)
    //         dp[n][k] = max(func(n + 1, 1, v), func(n + 1, 0, v));
    //     sum += dp[n][k];
    // }
    // show(n);
    // show(k);
    // show(sum);
    // show(v[n][k]);
    return sum;
}

int main(int argc, const char **argv)
{
    cin.tie(0);
    cout.tie(0);
    vector<vector<ll>> v;
    memset(dp, -1, sizeof(dp));
    long n;
    cin >> n;
    for (ul j = 0; j < n; j++)
    {
        vector<ll> x;
        for (ull i = 0; i < 3; i++)
        {
            ull t;
            cin >> t;
            x.push_back(t);
        }
        v.push_back(x);
    }
    show(v);
    ll maxi = 0;
    for (ll i = 0; i < 3; i++)
        maxi = max(maxi, func(0, i, v));
    cout << maxi << endl;
}

Measured memory_bytes: 18992
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n, ans = 0;
    cin >> n;
    char s[n];
    cin >> s;
    for(int i = 0; i < n - 2; i++)
    {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i + 2] == 'C')
            ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <numeric>

int main() {
  unsigned int N;
  std::cin >> N;

  std::vector<unsigned int> A_array;
  for (unsigned int i = 0; i < N; ++i) {
    unsigned int A;
    std::cin >> A;
    A_array.push_back(A);
  }

  std::vector<unsigned int> B_array(N, 0);
  std::vector<unsigned int> index_array;

  for (long long m = N - 1; m >=0; --m) {
    const unsigned int candidate_num = N / (m + 1);
    unsigned int sum = 0;
    for (unsigned int i = candidate_num; i >= 1; --i) {
      sum += B_array.at(i * (m + 1) - 1);
    }
    if (sum % 2 == A_array.at(m)) {
      B_array.at(m) = 0;
    } else {
      B_array.at(m) = 1;
      index_array.push_back(m + 1);
    }
  }

  const unsigned int M = std::accumulate(B_array.begin(), B_array.end(), 0);

  std::cout << M << std::endl;
  if (M == 0) {
    return 0;
  }

  for (unsigned int i = M; i >= 1; --i) {
    if (i != 1) {
      std::cout << index_array.at(i - 1) << " ";
    } else {
      std::cout << index_array.at(i - 1) << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3444
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}


//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var check = JSON.parse(JSON.stringify(list));
	check.sort(function(a,b){
		return a - b;
	});
	if(myconv(list, 8) == myconv(check, 8)){
		myout("YES");
		return;
	}
	for(var i = 0; i < N - 1; i++){
		for(var j = i + 1; j < N; j++){
			var sw = JSON.parse(JSON.stringify(list));
			var tmp = sw[i];
			sw[i] = sw[j];
			sw[j] = tmp;
			if(myconv(sw, 8) == myconv(check, 8)){
				myout("YES");
				return;
			}
		}
	}
	myout("NO");
}


Measured memory_bytes: 31644
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include<iostream>
#include<stack>
using namespace std;
#define ll long long
const ll maxn = 1005;
const ll mod = 1e9 + 7;
const ll inf = 1 << 30;
int main()
{
	ll n,k;
	scanf("%lld%lld",&n,&k);
	ll x=n%k;
	printf("%lld",min(x,abs(x-k)));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

int main() {
  string s;
  cin >> s;
  int res = count(s.begin(), s.end(), 'o');
  if (15-s.size()+res >= 8) {
    cout << "YES" << "\n";
  } else {
    cout << "NO" << "\n";
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, A: "List[int]"):
    data = [(a, i) for i, a in enumerate(A)]
    data.sort()
    print(*[a+1 for i, a in data], sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<vector<int>> E;

pair<int,int> farthest(vector<vector<int>>& E, int cur,int pre,int d,vector<int>& D) {
	D[cur]=d;
	pair<int,int> r={d,cur};
	FORR(e,E[cur]) if(e!=pre) r=max(r, farthest(E,e,cur,d+1,D));
	return r;
}

vector<pair<int,int>> diameter(vector<vector<int>>& E) { // diameter,center
	vector<int> D[2];
	D[0].resize(E.size());
	D[1].resize(E.size());
	auto v1=farthest(E,0,0,0,D[0]);
	auto v2=farthest(E,v1.second,v1.second,0,D[0]);
	farthest(E,v2.second,v2.second,0,D[1]);
	
	vector<pair<int,int>> R;
	//重心を取る場合
	for(int i=E.size()-1;i>=0;i--) if(D[0][i]+D[1][i]==v2.first) R.push_back({D[0][i],i});
	sort(ALL(R));

	return R;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	E.resize(N);
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	auto R=diameter(E);
	vector<int> A,B;
	int num=0;
	FOR(i,R.size()) {
		A.push_back(E[R[i].second].size());
		A.back()--;
		if(i>0 && i<R.size()-1) A.back()--;
		num+=1+A.back();
	}
	B=A;
	reverse(ALL(B));
	if(num!=N) return _P("-1\n");
	A=min(A,B);
	
	int nex=0;
	FOR(i,A.size()) {
		FOR(x,A[i]) cout<<nex+2+x<<" ";
		cout<<nex+1<<" ";
		nex+=1+A[i];
	}
	cout<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main()
{
	int a,b;
	cin>>a>>b;
	int cnt=0;
	
	for(int i=1; i<=(b+1)/0.1; i+=1)
	{
		if(int(i*0.08)==a && int(i*0.1)==b)
		{
			cnt++;
			cout<<i<< endl;
			break;
		}
	}
	
	if(cnt==0)
		cout<<"-1"<< endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main(){
	/*#ifndef ONLINE_JUDGE
	freopen("/home/yash/Desktop/CPP/input.txt","r",stdin);
    freopen("/home/yash/Desktop/CPP/output.txt","w",stdout);
	#endif*/
	char c ;
	cin >> c ;

	int x = (int)c ;

	

	if( x >= 65 && x <= 90 ){
		cout<<"A"<<endl;
	}
	else{
		cout<<"a"<<endl;
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define forinc(a,b,c) for(int a=b;a<=c;++a)
#define fordec(a,b,c) for(int a=b;a>=c;--a)
#define forv(a,b) for(auto &a:b)
#define ii pair<int,int>
#define fi first
#define se second
#define reset(f,x) memset(f,x,sizeof(f))
#define all(a) a.begin(),a.end()
#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
const int N=1e5+5;
int n,cnt;
pair<int,ii> ed[3*N];
struct oo{
    int x,y,id;
};
oo a[N];
int id[N];
int root(int i){return id[i]<0?i:id[i]=root(id[i]);}
bool mer(int u,int v){
    u=root(u),v=root(v);
    if(u==v) return 0;
    id[u]+=id[v];
    id[v]=u;
    return 1;
}
main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n;
    forinc(i,1,n){
        cin>>a[i].x>>a[i].y;
        a[i].id=i;
    }
    reset(id,-1);
    sort(a+1,a+n+1,[](oo x,oo y){
        return x.x<y.x;
    });
    forinc(i,1,n-1){
        ed[++cnt]={a[i+1].x-a[i].x,make_pair(a[i].id,a[i+1].id)};
    }
    sort(a+1,a+n+1,[](oo x,oo y){
        return x.y<y.y;
    });
    forinc(i,1,n-1){
        ed[++cnt]={a[i+1].y-a[i].y,make_pair(a[i].id,a[i+1].id)};
    }
    int ans=0;
    sort(ed+1,ed+cnt+1);
    forinc(i,1,cnt){
        if(mer(ed[i].se.fi,ed[i].se.se)){
            ans+=ed[i].fi;
        }
    }
    cout<<ans;

}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli x, ans = 0;
    cin >>x;
    ans += (x / 500) * 1000;
    x %= 500;
    ans += (x / 5)*5;
    out(ans);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
unordered_map<string,int> m;
vector<string> ans;
int main(){
    int n;cin>>n;
    string s;
    int mx=0;
    for(int i=1;i<=n;i++){
        cin>>s;
        m[s]++;
        mx=max(mx,m[s]);
    }
    for(auto &x:m){
        if(x.second<mx) continue;
        else ans.push_back(x.first);
    }
    sort(ans.begin(),ans.end());
    for(auto x:ans) cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 26692
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int x, a, b;

int main()
{
	cin >> x >> a >> b;
	cout << (x - a) % b << endl;

	return 0;
}


Measured memory_bytes: 256