akhauriyash/Code-Regression huggingface dataset:
#再起関数の上限を変更
import sys
sys.setrecursionlimit(2**20)

#クラスの定義
class Node:
    def __init__(self,parent,left,right):
        self.parent = parent
        self.left = left
        self.right = right

def get_depth(T: dict, u: int):
    #Tは木の構造と見立てたdictで、uはTのノード
    d = 0
    while T[u].parent is not None:
        u = T[u].parent
        d += 1

D = {} #深さを保存しておくためのdict

def get_all_depth(T: dict, u: int, p: int):
    #一度に全てのノードの深さを取得する関数(再帰的に処理を行う)。
    #一気に深さを取得するならば、こちらの方がオーダーが小さい
    #pは現在扱う深さ

    D[u] = p
    if T[u].right is not None:
        #まずは兄弟のノードから入れていく
        get_all_depth(T,T[u].right,p)
    if T[u].left is not None:
        # 兄弟を入れ終わったら次は下の深さへ
        get_all_depth(T, T[u].left, p+1)

def ret_children(T,u):
    children = []
    c = T[u].left
    while c is not None:
        children.append(c)
        c = T[c].right

    return children

#答えの出力用

def print_for_a_node(T: dict, node: int, D: dict):
    node_type = 'internal node' if T[node].left is not None else 'leaf'
    #parentを決める
    if T[node].parent == None:
        parent = -1
        node_type = 'root'
    else:
        parent = T[node].parent
    #子を決める
    children = ret_children(T,node)
    print(f'node {node}: parent = {parent}, depth = {D[node]}, {node_type}, {children}')

n = int(input())

#初期化
T = {k: Node(None, None, None) for k in range(n)}
#全てのleft,right,parentを決める
for _ in range(n):
    tmp = list(map(int,input().split()))
    if tmp[1] == 0: #もし子ノードが無ければ次へ
        continue
    T[tmp[0]].left = tmp[2]#子供のノードが分かる
    T[tmp[2]].parent = tmp[0] #子供の親のノードも即座に分かるだろう
    prev_sibiling = tmp[2] #前のノードを覚えておくよう
    #print (tmp)
    for sib in tmp[3:]:
        #print (prev_sibiling,sib)
        T[prev_sibiling].right = sib
        T[sib].parent = tmp[0]  # 子から親を与えている
        prev_sibiling = sib

#print(T[1].right)

for node in range(n):
    #rootからｋ考えなければいけない
    if T[node].parent == None:
        get_all_depth(T,node,0)
        break
    #Dに深さが入った

for node in range(n):
    print_for_a_node(T, node, D)



Measured memory_bytes: 142156
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

  string S; cin >> S;
  int res = 0, nACGT = 0;
  rep(i, 0, S.size()) {
    if (S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T') ++nACGT;
    else {
      res = max(res, nACGT);
      nACGT = 0;
    }
  }
  res = max(res, nACGT);
  
  cout << res << endl;
}


Measured memory_bytes: 256
import sys
import math
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

n, k = map(int, input().split())

inv_list = [1]  # 0で割るというのは定義されないので無視。
for i in range(n):
    inv_list.append(int(MOD - inv_list[(MOD % (i + 2)) - 1] * (MOD // (i + 2)) % MOD))
if k >= n:
    ans = 1
    for i in range(2 * n - 1):
        ans *= (i + 1)
        ans %= MOD
    for i in range(n):
        ans *= inv_list[i]
        ans *= inv_list[i]
        ans %= MOD
    ans *= n
    ans %= MOD
    print(ans)
else:
    ans = 1
    nCm = 1
    nmHm = 1
    for i in range(k):
        nCm *= n - i
        nCm *= inv_list[i]
        nCm %= MOD
        nmHm *= (n - 1) - i
        nmHm *= inv_list[i]
        nmHm %= MOD
        ans += nCm * nmHm
        ans %= MOD
    print(ans)


Measured memory_bytes: 11452
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll m,n,p,a,b;
    ll d[40][40];
    ll t[40];
    double dp[(1<<10)][40];
    while(true){
        double res=MAX;
        cin>>n>>m>>p>>a>>b;
        if(n==0) break;
        a--;b--;
        rep(i,40)rep(j,(1<<10))dp[j][i]=MAX;
        rep(i,40)rep(j,40) d[i][j]=LLINF;
        rep(i,n) cin>>t[i];
        rep(i,p){
            ll x,y,z;
            cin>>x>>y>>z;
            d[x-1][y-1]=z;
            d[y-1][x-1]=z;
        }
        dp[(1<<n)-1][a]=0;
        for(ll bit=(1<<n)-1;bit>=0;bit--){
            res=min(res,dp[bit][b]);
            rep(v,m){
                rep(i,n){
                    if(bit&(1<<i)){
                        rep(u,m){
                            if(d[v][u]!=LLINF){
                                dp[bit&~(1<<i)][u]=
                                min(dp[bit&~(1<<i)][u],
                                    dp[bit][v]+(double)d[v][u]/t[i]);
                            }
                        }
                    }
                }
            }
        }
        if(res==MAX){
            cout<<"Impossible"<<endl;
        }
        else{
            cout<<res<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
	vector<int> s;
	vector<int> t;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		s.push_back(tmp);
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int tmp;
		cin >> tmp;
		t.push_back(tmp);
	}

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	int s_place = 0; // sの現在位置
	int ans = 0;     // 答え
	int t_place = 0; // tの現在位置
	int late = -1;
	while (s_place < n && t_place < q) {
		  // sのほうが大きいならtを増やす
		if (s[s_place] > t[t_place]) {
			t_place++;
		} else if (s[s_place] < t[t_place]) {
		  // tのほうが大きいならsを増やす
			s_place++;
		} else {
			// 同じかつ違う整数がヒットしたならカウントしてsを増やす
			if (late != t[t_place]) {
				ans++;
				late = t[t_place];
			}
			s_place++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

long long N;
long long x[1005];
long long y[1005];

int main(){
	cin >> N;
	bool ok = true;
	for(long long i = 0; i < N; i++){
		cin >> x[i] >> y[i];
		if(i != 0){
			if((abs(x[0]) + abs(y[0]))%2 != (abs(x[i]) + abs(y[i]))%2){
				ok = false;
			}
		}
	}
	if(!ok){
		cout << -1 << endl;
		return 0;
	}

	vector<long long> arm;
	for(long long len = pow(2, 32);  len>=1; len/=2){
		arm.push_back(len);
	}
	if((abs(x[0]) + abs(y[0]))%2 == 0){ 
		arm.push_back(1);
	}

	cout << arm.size() << endl;
	for(long long i = 0; i < arm.size(); i++){
		cout << arm[i];
		if(i == arm.size() - 1){
			cout << endl;
		}else{
			cout << " ";
		}
	}
	for(long long i = 0; i < N; i++){
		long long tarx = x[i];
		long long tary = y[i];
		long long curx = 0;
		long long cury = 0;
		string ans = "";
		for(long long j = 0; j < arm.size(); j++){
			long long diffx = tarx - curx;
			long long diffy = tary - cury;
			if(abs(diffx) > abs(diffy)){
				if(diffx >= 0){
					ans+="R";
					curx += arm[j];
				}else{
					ans+="L";
					curx -= arm[j];
				}
			}else{
				if(diffy >= 0){
					ans+="U";
					cury += arm[j];
				}else{
					ans+="D";
					cury -= arm[j];
				}
			}
		}
		cout << ans << endl;
	}
}


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

int main()
{
  //int A, B, C, X, Y;
//  int m[101]={};
  int A, B, C, D;
  int ans=1;
  int po;
//  int sosu[20000]={};
  int i,j,k;
  int flag=0;  
//    int k=0;

  scanf("%d", &A);
  //printf("%d\n", A);

  for(i=1;i<1001;i++){
    for(j=2;j<1001;j++){
//      po=(int)pow((double)i,(double)j);
      po=(int)pow((double)i,(double)j);
      //printf(" %d %d\n",j, (int)pow(i,j));
      if(A>=po){
        if(ans<po) ans = po;
      }
      else break;
    }
  }
   printf("%d\n", ans);
  
return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main ()
{
	int h,r;

	cin >> h >> r;

	if (h + r == 0)
	{
		cout << '0' << endl;
	}
	else if (h + r < 0)
	{
		cout << "-1" << endl;
	}
	else
	{
		cout << '1' << endl;
	}
}



Measured memory_bytes: 3116
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

	static int h;
	static int w;
	static int[][] xWall;
	static int[][] yWall;
	static boolean[][] isVisited;
	//右、左、下、上
	static int[][] steps = {{0,1},{0,-1},{1,0},{-1,0}};
	static int ans;


	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {

			 w= sc.nextInt();
			 h = sc.nextInt();

			if((w|h) == 0) {
				break;
			}

			xWall = new int[h][w-1];
			yWall = new int[h][w];

			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w-1; j++) {
					xWall[i][j] = sc.nextInt();
				}
				if(i!=h-1) {
					for(int j = 0; j < w; j++) {
						yWall[i][j] = sc.nextInt();
					}
				}
			}


			isVisited = new boolean[h][w];
			isVisited[0][0] = true;

			ArrayDeque<int[]> q = new ArrayDeque<int[]>();
			int[] start = {0,0,1};
			q.add(start);

			ans= 0;

			while(!q.isEmpty()) {
				int[] nowSquare = q.poll();

				int nowH = nowSquare[0];
				int nowW = nowSquare[1];

				if(nowH == h-1 && nowW == w-1) {
					ans = nowSquare[2];
					break;
				}

				for(int i = 0; i < 4; i++) {
					if(! isAvailable(nowSquare, i) || isVisited[nowH + steps[i][0]][nowW + steps[i][1]] == true) {
						continue;
					}
					isVisited[nowH + steps[i][0]][nowW + steps[i][1]] = true;
					int distance = nowSquare[2];
					int[] nextSquare = {nowH + steps[i][0], nowW + steps[i][1], distance+1 };

					q.add(nextSquare);
				}
			}

			System.out.println(ans);
		}

	}

	static boolean isAvailable(int[] nowSquare, int idx) {
		boolean isAvalable = false;
		int nowH = nowSquare[0];
		int nowW = nowSquare[1];

		switch(idx) {
		//右
		case 0:
			if(nowW +1 > w-1 || xWall[nowH][nowW] ==1) {
				return false;
			}else{return true;}
			//左
		case 1:
			if(nowW -1 < 0 || xWall[nowH][nowW-1] ==1) {
				return false;
			}else{return true;}
			//下
		case 2:
			if(nowH +1 > h-1 || yWall[nowH][nowW] ==1) {
				return false;
			}else{return true;}
			//上
		case 3:
			if(nowH -1 < 0 || yWall[nowH-1][nowW] ==1) {
				return false;
			}else{return true;}

		default: return false;
		}
	}
}


Measured memory_bytes: 67792
#include <iostream>

using namespace std;

int main() {

    ios::sync_with_stdio(false);

    long long n, a, b, c, d;

    cin >> n >> a >> b >> c >> d;

    for (long long i = 0; i < n; ++i) {
        long long from = a + c * i - d * (n - i - 1);
        long long to = a + d * i - c * (n - i - 1);


        if (from <= b && b <= to) {
            cout << "YES";
            return 0;
        }
    }

    cout << "NO";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pb push_back
#define vl vector<ll>
#define vs vector<string>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define vii vector<pii>
#define F first
#define S second
using namespace std;
const int N=2e5+5;
ll n,k,h[N],ans;
signed main()
{
	std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>k;
	rep(i,n)
	{
		cin>>h[i];
	}
	sort(h,h+n);
	reverse(h,h+n);
	for(int i=k;i<n;i++)
	{
		ans+=h[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

signed main(){
  ll x,y;cin>>x>>y;
  if(abs(x-y)<2)cout<<"Brown"<<endl;
  else cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> void chmax(T& a, U b) { if (a < b) a = b; }
const int MAX_N = 110;
const int MAX_W = 11000;
const int INF = 1e9;

int main() {
    int n, w;
    cin >> n >> w;
    long long dp[MAX_N][MAX_W] = {0};
    vector<int> val(n), wei(n);
    for (int i = 0; i < n; i++) cin >> val[i] >> wei[i];
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < MAX_W; j++) {
            chmax(dp[i+1][j], dp[i][j]);
            if (0 <= j - wei[i]) chmax(dp[i+1][j], dp[i][j - wei[i]] + val[i]);
        }
    }
    
    cout << dp[n][w] << endl;
    return 0;
}


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

int main()
{
  int x, n, input;
  cin >> x;
  cin >> n;
  int l = x;
  int u = x;
  vector<int> v;
  for(int i=0;i<n;i++) {
    cin>>input;
    v.push_back(input);
  }
  sort(v.begin(), v.end());
  bool present = true;
  while(present == true) {
    if( ! binary_search(v.begin(), v.end(), l)) {
      cout << l << endl;
      present = false;
    }
    else if( ! binary_search(v.begin(), v.end(), --l)) {
      cout << l << endl;
      present = false;
    }
    else if( ! binary_search(v.begin(), v.end(), ++u)) {
      cout << u << endl;
      present = false;
    }
    else if (l == 1) {
      cout << "0" << endl;
      present = false;
    }
  }
}

Measured memory_bytes: 3628
def s():
 import sys
 r=sys.stdin.readline
 I=float('inf')
 for e in iter(r,'0 0\n'):
  n,k=map(int,e.split())
  F=[[I]*-~n for _ in[0]*-~n]
  for i in range(1,n+1):F[i][i]=0
  for _ in[0]*k:
   f=r();g=map(int,f[2:].split())
   if'0'==f[0]:a,b=g;A=F[a][b];print([A,-1][A==I])
   else:
    c,d,e=g
    if e<F[c][d]:
     for i in range(2,n+1):
      for j in range(1,i):
       F[i][j]=F[j][i]=min(F[i][j],F[i][c]+e+F[d][j],F[i][d]+e+F[c][j])
s()


Measured memory_bytes: 6244
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int a;
	cin>>a;
	vector<int> b;
	int c;
	for(int i=0;i<2*a;i++){
		cin>>c;
		b.push_back(c);
	}
	sort(b.begin(),b.end());
	int d=0;
	for(int i=0;i<(int)b.size()-1;i++){
		if(b[i]==b[i+1]){
			d+=b[i];
			b.erase(b.begin()+i);
			b.erase(b.begin()+i);
		}
	}
	for(int i=0;i<b.size();i++){
		d+=b[i];
		i++;
	}
	cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from bisect import bisect_left as bi_l

def sieve_of_eratosthenes(n=5 * 10 ** 6):
  sieve = [1] * (n + 1); sieve[0] = sieve[1] = 0
  for i in range(2, int(n ** 0.5) + 1):
    if not sieve[i]: continue
    for j in range(i * 2, n + 1, i): sieve[j] = 0
  prime_numbers = [i for i in range(2, n + 1) if sieve[i]]
  return sieve, prime_numbers

is_prime, prime_numbers = sieve_of_eratosthenes()

def prime_factorize(n):
  res = dict()
  if n < 2: return res
  border = int(n ** 0.5)
  for p in prime_numbers:
    if p > border: break
    while n % p == 0: res[p] = res.get(p, 0) + 1; n //= p
    if n == 1: return res
  res[n] = 1
  return res

def prime_factorize_factorial(n):
  res = dict()
  for i in range(2, n + 1):
    for p, c in prime_factorize(i).items(): res[p] = res.get(p, 0) + c
  return res

x = int(sys.stdin.readline().rstrip())

def main():
    i = bi_l(prime_numbers, x)
    print(prime_numbers[i])

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 56112
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
int n;
ll a[200100];
ll p[200100];
ll q[200100];
map<ll,ll>mp;
int main()
{
  cin>>n;
  rep(i,n)cin>>a[i];
  rep(i,n)p[i]=a[i]-i;
  rep(i,n)q[i]=a[i]+i;
  rep(i,n)mp[p[i]]++;
  ll cnt=0;
  rep(i,n)cnt+=mp[-q[i]];
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 30840
#include <bits/stdc++.h>
using i64 = long long;

int n;
std::vector<std::vector<int>> ret;

void rec(std::vector<int> v, int d) {
    std::deque<int> w;
    for (int i = 0; i < n; i++) if (v[i] == -1) w.push_back(i);
    if (w.empty()) {
        ret.push_back(v);
        return;
    }

    v[w.front()] = d;
    w.pop_front();
    int c = w.size();
    for (int bit = 0; bit < (1 << c); bit++) {
        for (int j = 0; j < c; j++) if (bit & (1 << j)) v[w[j]] = d;
        rec(v, d + 1);
        for (int j = 0; j < c; j++) if (bit & (1 << j)) v[w[j]] = -1;
    }
}

int main() {
    std::cin >> n;
    std::vector<int> v;
    while (v.size() < n) v.push_back(-1);

    rec(v, 0);

    std::sort(ret.begin(), ret.end());
    for (auto &e : ret) {
        for (int d : e) std::cout << (char)(d + 'a');
        std::cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 9776
#include<iostream>
using namespace std;
 
int main() {
  int a,b,c,x;
  cin >> a;
  cin >> b;
  c = a + b;
  x = (a + b) / 2;
  if (c % 2 == 0)
  {
      cout << x << endl;
  } else {
      cout << x + 1 << endl;
  }
  
  
  return 0;
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll a,b;
    cin >> a >> b;

    ll ans = 0;
    if(a>b)
    {
    	ans = a;
    	a--;
    }
    else
    {
    	ans = b;
    	b--;
    }
    if(a>b)
    {
    	ans = ans+a;
    	a--;
    }
    else
    	ans = ans + b;

    cout << ans << endl;
}


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

int main() {

	int n, k, m, s = 0;

	vector<int> l(50);

	cin >> n >> k;

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (l[j] < l[j + 1]) {
				m = l[j];
				l[j] = l[j + 1];
				l[j + 1] = m;
			}
		}
	}

	//for (int i = 0; i < n; i++) {
		//cout << l[i] << endl;
	//}

	for (int i = 0; i < k; i++) {
		s = s + l[i];
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cctype>
#include<algorithm>
#include <stdio.h>
#include<cstdlib>
#include<math.h>
#include<complex>

using namespace std;

int main() {
	int r = 700;
	char a, b, c;
	cin >> a >> b >> c;
	if (a == 'o')r = r + 100;
	if (b == 'o')r = r + 100;
	if (c == 'o')r = r + 100;
	cout << r << endl;

}

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

#define ANS  //for answer
#define CMP  //for compe

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x,(x)
#define ncv(x) #x,":",(x)
#define ncvc(x) #x,":",(x),","
using ll = long long;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>void pPRINT(std::ostream& ost,const T t,const U... u) {ost<<t<<" ";pPRINT(ost, u...);}
template <class... T>void PRINT(const T... t) {pPRINT(std::cout, t...);}
template <class... T>void PRINTl(const T... t){pPRINT(std::cout,t...);std::cout<<"\n";}
template <class T>void PRINTa(const T* const t,const ll size){REP(i,size)PRINT(t[i]);PRINTl();}
template <class T>void PRINTal(const T* const t,const ll size){REP(i,size)PRINTl(i,":",t[i]);}
#ifdef ANS
#define DEBUG(...)
#else
#define DEBUG(...) PRINTl("##DEBUG##","file :",__FILE__,", line :",__LINE__,"\n##DEBUG##",__VA_ARGS__)
#endif
#ifdef CMP
using namespace std;
#else
#endif

void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

void solve();

int main(int argc, char *argv[]) {

  init();

  solve();

  return 0;
}

void solve(){

  ll n,k;
  cin>>n>>k;

  //log_2(k/p+(k&p>0))より大きい直近の整数が表が出るべき回数mp
  //2^(-mp)が目がpの時に勝つ確率P
  //SUM(P,i=1,i<N)/n={2^(-m(1))+2^(-m(2))+...+2^(-m(n))}/nが回答
  double sum=0;
  ll lim = k>n?n+1:k;
  DEBUG(ncv(lim));
  if(lim==k){sum=n-k+1;}
  FOR(i,1,lim){
    double ddmp = log(k/i+(k%i>0));
    double dmp = ddmp/log(2.0);
    ll mp = dmp+((ll)dmp!=dmp);
    sum+= pow(0.5,mp);
    DEBUG(ddmp,dmp,mp,sum);
  }
  auto ans = sum/(double)n;
  cout<<setprecision(9)<<ans;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;
const double PI = acos(-1);

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
  vector<int> p;
  vector<int> s;
  void init(int n) {
    p.resize(n, -1);
    s.resize(n, 1);
  }
  int find(int n) {
    if(p[n] == -1) return n;
    else return find(p[n]);
  }
  int size(int n) {
    return s[find(n)];
  }
  void unite(int n, int m) {
    int pn = find(n);
    int pm = find(m);
    if(pn == pm) return;
    if(s[pn] > s[pm]) {
      s[pn] = s[pn] + s[pm];
      p[pm]= pn;
    } else {
      s[pm] = s[pm] + s[pn];
      p[pn] = pm;
    }
  }
};

long long gcd(long long a, long long b) {
  if(a % b == 0) return b;
  else return gcd(b, a % b);
}
int main() {
  ll n;
  cin >> n;
  int h, w, x;
  for(ll i=1;i<3501;i++) for(ll j=i+1;j<3501;j++) {
    ll a = 4 * i * j - n * (i + j);
    if(a <= 0) continue;
    if(i * j * n % a == 0) {
      h = i;
      w = j;
      x = i * j * n / a;
      break;
    }
  }
  cout << h << " " << w << " " << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s; cin>>s;
	ll n=s.length();
	for (ll c=0;c<26;c++) {
		char ch='a'+c;
		ll h=0;
		pair<ll,ll> lo=MP(0LL,0LL);
		for (ll x=0;x<n;x++) {
			h--;
			if (s[x]==ch) h+=2;
			if (h>lo.first&&lo.second!=x) {
				printf("%lld %lld\n",lo.second+1,x+1);
				return 0;
			}
			chkmin(lo,MP(h,x+1));
		}
	}
	printf("-1 -1\n");
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  if (n >= 2) ans += n * (n - 1) / 2;
  if (m >= 2) ans += m * (m - 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j,k;
	int N;
	int maxmoji = 0;//最大数更新用
	string S;
	cin >> N;
	cin >> S;
	int moji[120] = {};//文字コード格納
	int mojiX[120] = {};
	int mojiY[120] = {};
	int count = 0;
	for (i = 0; i < N; ++i) {
		mojiX[S[i]-97] = 1;
		
		for (j = i+1; j < N; ++j) {
			mojiY[S[j]-97] = 1;
		}

		for (k = 0; k < 26; ++k) {
			if ((mojiX[k] ==1)&& (mojiY[k] == 1)&&(mojiX[k]==mojiY[k])) {
				moji[k] = 1;
			}
		}

		for (k = 0; k < 26; ++k) {
			if (moji[k] == 1) {
				++count;
			}
		}

		maxmoji = max(count, maxmoji);
		//cout << maxmoji << endl;
		count = 0;
		for (k = 0; k < 26; ++k) {
			moji[k] = 0;
			mojiY[k] = 0;
			}
		
	
	}


	cout <<maxmoji << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <map>
#define rep(i,n) for(long long i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll MOD = 1000000007;

int m, n1, n2;
int p[200];

void solve(){
	rep(i,m) cin >> p[i];
	sort(p,p+m,greater<int>());
	int ans = 0;
	int gap = 0;
	for(int i = n1-1; i < n2; i++) if(gap <= p[i]-p[i+1]){ gap = p[i]-p[i+1]; ans = i+1; }
	cout << ans << endl;
}

int main(){
	while(cin >> m >> n1 >> n2){
		if(m == 0 && n1  == 0 && n2 == 0) break;
		solve();
	}	
}

Measured memory_bytes: 1176
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let r: u32 = it.next().unwrap().parse().unwrap();
    let d: u32 = it.next().unwrap().parse().unwrap();
    let mut x: u32 = it.next().unwrap().parse().unwrap();
    for _ in 0..10 {
        x = r * x - d;
        println!("{}", x);
    }
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e15 + 7;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main() {
  string s;
  cin >> s;
  rep(i,3) cout << s[i];
  cout << endl;
  return 0;
}


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

int main(){
    int n,to[128]={1};
    int di[8]={0,1,6,2,3,5,4};
    string mo;
    int cnt=0;
    while(scanf("%d",&n),n){
        for(int i=0;i<n;i++){
            cin>>mo;
            if(mo=="North"){
                di[0]=di[1];
                di[1]=di[3];
                di[3]=di[2];
                di[2]=di[5];
                di[5]=di[0];
                to[cnt]+=di[1];
            }else if(mo=="East"){
                di[0]=di[1];
                di[1]=di[6];
                di[6]=di[2];
                di[2]=di[4];
                di[4]=di[0];
                to[cnt]+=di[1];
            }else if(mo=="West"){
                di[0]=di[1];
                di[1]=di[4];
                di[4]=di[2];
                di[2]=di[6];
                di[6]=di[0];
                to[cnt]+=di[1];
            }else if(mo=="South"){
                di[0]=di[1];
                di[1]=di[5];
                di[5]=di[2];
                di[2]=di[3];
                di[3]=di[0];
                to[cnt]+=di[1];
            }else if(mo=="Right"){
                di[0]=di[3];
                di[3]=di[4];
                di[4]=di[5];
                di[5]=di[6];
                di[6]=di[0];
                to[cnt]+=di[1];
            }else if(mo=="Left"){
                di[0]=di[3];
                di[3]=di[6];
                di[6]=di[5];
                di[5]=di[4];
                di[4]=di[0];
                to[cnt]+=di[1];
            }
        }cnt++;
        to[cnt]=1;
        di[0]=0;
        di[1]=1;
        di[2]=6;
        di[3]=2;
        di[4]=3;
        di[5]=5;
        di[6]=4;
    }
    for(int i=0;i<cnt;i++){
        printf("%d\n",to[i]);
    }
    return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	long long x, y;
	
	cin >> x >> y;

	if (x == y) {
		printf("-1\n");
	}
	else if(x < y){
		printf("%d\n", x);
	}
	else {
		if (x % y == 0) {
			printf("-1\n");
		}
		else {
			printf("%d\n", x);
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#define INFTY 1000000001
void merge(int [],int,int,int);
void mergeSort(int [],int,int);
int count=0;
int main(){

  int i,n,A[500000];

  int left,right;


  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){

    scanf("%d",&A[i]);

  }
  left=0;
  right=n;
  mergeSort(A,left,right);


  for(i=0;i<n-1;i++){
      printf("%d ",A[i]);
    
  }
  printf("%d\n%d\n",A[n-1],count);

  return 0;

}

void merge(int A[],int left,int mid,int right){


  int n1,n2;

 int j=0;
    int i;
  n1=mid-left;
  n2=right-mid;

  int L[n1],R[n2];

  for(i=0;i<=n1-1;i++){

    L[i]=A[left+i];

  }
  
  for(i=0;i<=n2-1;i++){

    R[i]=A[mid+i];

  }
  
    L[n1]=INFTY;
    R[n2]=INFTY;
     i=0;
     j=0;
    for(int k=left;k<=right-1;k++){

      if(L[i]<=R[j]){
	A[k]=L[i];
	i=i+1;
	count++;
      }
      else{

	A[k]=R[j];
	j=j+1;
	count++;
      }

    }

}

void mergeSort(int A[],int left,int right){

  int mid;
  
  if (left+1 < right){
    mid = (left + right)/2;
   mergeSort(A, left, mid);
   mergeSort(A, mid, right);
   merge(A, left, mid, right);
  }
}



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

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    int count=0;
    int res;
    for(int i=min(a,b);k>0;i--){
        if(a%i==0 && b%i==0){
            k--;
            res=i;
        }
    }
    p(res)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define CYES cout<<"Yes"<<"\n";
#define CNO cout<<"No"<<"\n";
#define CFS cin.tie(nullptr);ios::sync_with_stdio(false);
#define CST(x) cout<<fixed<<setprecision(x);
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const int IINF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = (int) 1e9 + 7;
const string MM = " ";

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    int ans = 0;
    int min_v = v[0];
    for (size_t i = 0; i < n; i++)
    {
        if (v[i] <= min_v) {
            ans++;
            min_v = v[i];
        }
    }
    cout << ans << "\n";
}

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(a - b >= 0){
        cout << "delicious" << endl;
    }else{
        if(x < (b - a)){
            cout << "dangerous" << endl;
        }else{
            cout << "safe" << endl;
        }
    }
}

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

using namespace std;

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

	vector<int> nums(n);

	for (int i = 0; i < n; i++) cin >> nums[i];

	for (int i = 1; i < n; i++) {
		if (nums[i - 1] < nums[i]) nums[i]--;
	}

	for (int i = 1; i < n; i++) {
		if (nums[i - 1] > nums[i]) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";
}

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

using namespace std;

int V, E, o;
int dis[16][16], dp[16][1<<16];

int solve(int s, int state)
{
	if (~dp[s][state])
	{
		return dp[s][state];
	}
	if (state == (1<<V)-1)
	{
		return dp[s][state] = dis[s][o];
	}
	int res = INT_MAX;
	for (int i = 0; i < V; i++)
	{
		if (state >> i & 1) continue;
		res = min(res, solve(i, state | 1 << i) + dis[s][i]);
	}
	return dp[s][state] = res;
}

int main()
{
	cin >> V >> E;
	memset(dis, -1, sizeof(dis));
	while(E--)
	{
		int s, t, w;
		cin >> s >> t >> w;
		dis[s][t] = w;
	}
	for (int s = 0; s < V; s++)
	{
		for (int t = 0; t < V; t++)
		{
			if (dis[s][t] == -1)
			{
				dis[s][t] = 1000000;
			}
		}
	}
	int ans = INT_MAX;
	memset(dp, -1, sizeof(dp));
	ans = min(ans, solve(0, 1));
	if (ans > 1000000)
	{
		ans = -1;
	}
	cout << ans << endl;
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 7204
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = pow(10, 9) + 7;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    bool f = true;
    int ite = 1, ans = 1, start = 0;
    if(a[0] == 0){
        start = 1;
        ite = 2;
    }
    for(int i = start; i < n; i += 2){
        if(ite == a[i]){
            ans *= 2;
            ans %= mod;
            ite += 2;
        }
        else{
            f = false;
            break;
        }
    }
    if(f) cout << ans << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 4028
#include <iostream>
#include <map>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    long long K;
    cin >> N >> K;
    map <int, long long> count;
    for(int i = 0 ; i < N ; ++i){
        int a, b;
        cin >> a >> b;
        count[a] += b;
    }
    long long pos = 0;
    for(const auto &elem : count){ // elem.first - value, elem.cond - frequency
        pos += elem.second;
        if(K <= pos){
            cout << elem.first << '\n';
            break;
        }
    }
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    size_t n=s.length();
    int res,a=n,z=0;
    for(int i=0;i<n;i++){
        if(s[i]=='A' && i<a)a=i;
        if(s[n-i]=='Z' && n-i>z)z=n-i;
    }
    cout << z-a+1 << endl;
}

Measured memory_bytes: 640
#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 argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    int flag=0;
    rep(i,9){
        rep(j,9){
            if(n==(i+1)*(j+1))flag=1;
        }
    }
    if(flag==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	for (int i = 0;i<100000; i++) {
		C = C - B;
		if (C <= 0) {
			cout << "Yes" << endl;
			break;
		}
		A =A- D;
		if (A <= 0) {
			cout << "No" << endl;
			break;
			 }

	}
	return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
using namespace std;

int n;
char *s;

void assign(char **ans, char a0, char a1) {
    char a[n+2];
    a[0] = a0;
    a[1] = a1;
    for (int i = 2; i < n + 2; i++) {
        if ((a[i-1] == 'S') == (s[i-1] == 'o')) {
            a[i] = a[i-2];
        } else {
            if (a[i-2] == 'S') {
                a[i] = 'W';
            } else {
                a[i] = 'S';
            }
        }
    }

    if (a[0] == a[n] && a[1] == a[n+1]) {
        strncpy(*ans, a, n);
    }
    return;
}

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

    s = new char[n+2];
    scanf("%s", s);
    s[n] = s[0];
    s[n+1] = s[1];
    
    char *ans = new char[n];

    char sw[] = "SW";

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (*ans == 0) {
                assign(&ans, sw[i], sw[j]);
            }
        }
    }

    if (*ans == 0) { strcpy(ans, "-1"); }

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

    return 0;
}

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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#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 ll  long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi      vector<int>
#define pii     pair<int,int>
#define piii    pair<pair<int,int>,int>
#define all(v)  v.begin(), v.end()

int mod = 1000000007;
const int N = 1005;

// gcd
ll gcd(ll a , ll b)
{
    if ( b == 0)
    return a;
    return gcd( b, a % b);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int r, g;
	cin >> r >> g;
	cout << 2 * g - r << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int v,i,j,k,n,a[100];

  scanf("%d",&n);

  for(i=0;i<=n-1;i++){
    scanf("%d",&a[i]);
  }

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

    v=a[i];
    j=i-1;
    
    while(j>=0&&a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    
    a[j+1]=v;

    for(k=0;k<=n-1;k++){
      printf("%d",a[k]);
      if(k!=n-1)printf(" ");
    }

    printf("\n");
    
  }
return 0;
}


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

int main() {
	vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K;
	cin >> K;
	cout << a.at(K - 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

int main()
{
	double r;
	double area, circum;

	cin >> r;

	area = r * r* M_PI;

	circum = 2 * r *M_PI;

	cout << fixed 
		 << setprecision(20)
		 << area << " "
	  	 << setprecision(20)
		 << circum << endl;

    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 1e9;
using namespace std;

typedef pair<int, int> Edge; // to,  weight

vector<Edge> node[110000];
int color[110000];

void dfs(int id){
  for(auto it=node[id].begin();it!=node[id].end();it++){
    Edge e = *it;
    int dest = e.first;
    int weight = e.second;
    if(color[dest]==INF){
      //printf("[dfs] id=%d (color=%d) dest->%d weight->%d\n",id,color[id], dest, weight);
      if(weight%2==1) color[dest] = -color[id];
      else color[dest] = color[id];
      dfs(dest);
    }
  }
}
int main()
{
  int N;
  cin >> N;

  int ii=0;
  int u, v, w;
  while(cin>>u>>v>>w){
    u--;v--;
    Edge e = make_pair(v, w);
    node[u].push_back(e);
    e = make_pair(u, w);
    node[v].push_back(e);
  }

  rep(i,N) color[i]=INF;

  rep(i,N){
    if(color[i]==INF) {
      color[i] = 1;
      dfs(i);
    }
  }
  
  rep(i,N){
    int res=0;
    if(signbit(color[i])) res=1;
    cout << res << endl;
  }
}


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

int main(){
	vector<int> X(3);
	rep(i, 3) cin >> X.at(i);
	sort(X.begin(), X.end());
	cout << (X.at(0) % 2 != 0 && X.at(1) % 2 != 0 && X.at(2) % 2 != 0 ? (int64_t)X.at(0) * X.at(1) : 0) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var N = (int)vals[0];
        var K = vals[1];
        var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var max = (int)Math.Log(K, 2) + 1;
        var AA = A.Concat(A).ToArray();
        // nexts[j][i] : iから2^j回分移動した位置

        var next = new long[N];
        var indexs = new Dictionary<int, int>(); // a -> index
        for (int i = 0; i < N * 2; i++)
        {
            var a = AA[i];
            if (indexs.ContainsKey(a))
            {
                var prev = indexs[a];
                if (prev < N)
                {
                    next[prev] = i + 1 - prev;
                }
            }
            indexs[a] = i;
        }

        var nexts = new long[max][];
        nexts[0] = next;
        for (int j = 1; j < max; j++)
        {
            nexts[j] = new long[N];
            for (int i = 0; i < N; i++)
            {
                var t = nexts[j - 1][i % N];
                nexts[j][i] = t + nexts[j - 1][(i + t) % N];
            }
        }

        long p = 0;
        for (var k = N * K - 1; k > N;)
        {
            for (int j = max - 1; j >= 0; j--)
            {
                if (nexts[j][p % N] < k)
                {
                    k -= nexts[j][p % N];
                    p += nexts[j][p % N];
                    break;
                }
            }
        }

        var list = new List<int>();
        indexs.Clear();
        for (p = (p == N * K) ? p : p % N; p < N; p++)
        {
            var a = A[p];
            if (!indexs.ContainsKey(a))
            {
                indexs[a] = list.Count;
                list.Add(a);
            }
            else
            {
                var index = indexs[a];
                foreach (var aa in list.Skip(index))
                {
                    indexs.Remove(aa);
                }
                list.RemoveRange(index, list.Count - index);
            }
        }

        Console.WriteLine(string.Join(" ", list));
    }
}

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

int main(void) {
  int num,kind,total=0;
  cin>>num>>kind;
  vector<int> sunuke(num,0);
  for(int i=0;i<kind;i++){
    int d_num,a_num;
    cin>>d_num;
    for(int j=0;j<d_num;j++){
      cin>>a_num;
      sunuke.at(a_num-1)+=1;
    }
  }
  for(int i=0;i<num;i++){
    if(sunuke.at(i)==0) total++;
  }
  cout<<total<<endl;
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> p(N);
    REP(i, N) cin >> p[i];

    ll res = 0;
    REP(i, N){
    	if(p[i]!=i+1) continue;
    	int j = i;
    	while(j<N && p[j]==j+1){
    		j++;
    	}
    	int len = j-i;
    	res += (len+1)/2;
    	i = j-1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define OUT(x) cout<<(x)<<endl;
const int INF = 114514;


int main(){
    int h, w;
    cin>>h>>w;
    rep(i,h){
        string s;
        cin >> s;
        rep(j,2) OUT(s);
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	if( s[5] == '0' && s[6] - '0' < 5 ) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list>
#include <unordered_set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define _GLIBCXX_DEBUG
using namespace std;
struct __INIT { __INIT() {cin.tie(nullptr); ios::sync_with_stdio(false);} } __init;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<ll,ll> pair_t;
bool PSecComp(const pair_t& a, const pair_t& b) {
	if (a.second == b.second)return  a.first > b.first;
	else {
		return a.second > b.second;
	}
}

int main(){
	ll n, cnt=0;
	cin >> n;
	for (ll i = 1; i <= n; i++) {
		if (getDigit(i) % 2 == 1)cnt++;
	}
	cout << cnt << endl;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    if(a == 3 || a == 5 || a == 7)
      System.out.println("YES");
    else
      System.out.println("NO");
  }
}

Measured memory_bytes: 21844