akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#define ll long long
#define mid (l+r)/2
using namespace std;
const ll MOD1=1e9+9,b1=1000003,invb1=27749917;
const ll MOD2=1e9+7,b2=999983,invb2=496501444;
const ll MOD3=998244353,b3=999979,invb3=536166305;
int n;
char s[250005];
ll v1,v2,v3,v11[250005],v12[250005],v13[250005],p1[250005],p2[250005],p3[250005],v21[250005],v22[250005],v23[250005],ans;
map<pair<ll,ll>,int>mp;
void solve(int l,int r)
{
	if(l==r)
	{
		if(s[l]=='+'&&v1==1&&v2==1&&v3==1)ans++;
		if(s[l]=='-'&&v1==MOD1-1&&v2==MOD2-1&&v3==MOD3-1)ans++;
		if(s[l]=='<'&&v1==0&&v2==0&&v3==0)ans++;
		if(s[l]=='>'&&v1==0&&v2==0&&v3==0)ans++;
		return;
	}
	solve(l,mid);
	solve(mid+1,r);
	v11[mid+1]=v12[mid+1]=v13[mid+1]=0;
	v21[mid]=v22[mid]=v23[mid]=0;
	p1[mid+1]=p2[mid+1]=p3[mid+1]=1;
	for(int i=mid;i>=l;i--)
	{
		if(s[i]=='+')
		{
			v11[i]=(v11[i+1]+1)%MOD1,p1[i]=p1[i+1];
			v12[i]=(v12[i+1]+1)%MOD2,p2[i]=p2[i+1];
			v13[i]=(v13[i+1]+1)%MOD3,p3[i]=p3[i+1];
		}
		if(s[i]=='-')
		{
			v11[i]=(v11[i+1]-1+MOD1)%MOD1,p1[i]=p1[i+1];
			v12[i]=(v12[i+1]-1+MOD2)%MOD2,p2[i]=p2[i+1];
			v13[i]=(v13[i+1]-1+MOD3)%MOD3,p3[i]=p3[i+1];
		}
		if(s[i]=='<')
		{
			v11[i]=v11[i+1]*invb1%MOD1,p1[i]=p1[i+1]*b1%MOD1;
			v12[i]=v12[i+1]*invb2%MOD2,p2[i]=p2[i+1]*b2%MOD2;
			v13[i]=v13[i+1]*invb3%MOD3,p3[i]=p3[i+1]*b3%MOD3;
		}
		if(s[i]=='>')
		{
			v11[i]=v11[i+1]*b1%MOD1,p1[i]=p1[i+1]*invb1%MOD1;
			v12[i]=v12[i+1]*b2%MOD2,p2[i]=p2[i+1]*invb2%MOD2;
			v13[i]=v13[i+1]*b3%MOD3,p3[i]=p3[i+1]*invb3%MOD3;
		}
	}
	ll now1=1,now2=1,now3=1;
	for(int i=mid+1;i<=r;i++)
	{
		if(s[i]=='+')
		{
			v21[i]=(v21[i-1]+now1)%MOD1;
			v22[i]=(v22[i-1]+now2)%MOD2;
			v23[i]=(v23[i-1]+now3)%MOD3;
		}
		if(s[i]=='-')
		{
			v21[i]=(v21[i-1]-now1+MOD1)%MOD1;
			v22[i]=(v22[i-1]-now2+MOD2)%MOD2;
			v23[i]=(v23[i-1]-now3+MOD3)%MOD3;
		}
		if(s[i]=='<')
		{
			now1=now1*invb1%MOD1,v21[i]=v21[i-1];
			now2=now2*invb2%MOD2,v22[i]=v22[i-1];
			now3=now3*invb3%MOD3,v23[i]=v23[i-1];
		}
		if(s[i]=='>')
		{
			now1=now1*b1%MOD1,v21[i]=v21[i-1];
			now2=now2*b2%MOD2,v22[i]=v22[i-1];
			now3=now3*b3%MOD3,v23[i]=v23[i-1];
		}
		mp[make_pair(v21[i]*1000000000+v22[i],v23[i])]++;
	}
	for(int i=l;i<=mid;i++)
	{
		ll x1=(v1-v11[i]+MOD1)*p1[i]%MOD1;
		ll x2=(v2-v12[i]+MOD2)*p2[i]%MOD2;
		ll x3=(v3-v13[i]+MOD3)*p3[i]%MOD3;
		ans+=mp[make_pair(x1*1000000000+x2,x3)];
	}
	mp.clear();
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='+')
		{
			v1=(v1+1)%MOD1;
			v2=(v2+1)%MOD2;
			v3=(v3+1)%MOD3;
		}
		if(s[i]=='-')
		{
			v1=(v1-1+MOD1)%MOD1;
			v2=(v2-1+MOD2)%MOD2;
			v3=(v3-1+MOD3)%MOD3;
		}
		if(s[i]=='<')
		{
			v1=v1*invb1%MOD1;
			v2=v2*invb2%MOD2;
			v3=v3*invb3%MOD3;
		}
		if(s[i]=='>')
		{
			v1=v1*b1%MOD1;
			v2=v2*b2%MOD2;
			v3=v3*b3%MOD3;
		}
	}
	solve(1,n);
	printf("%lld\n",ans);
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, ans = INF;
  cin >> n;

  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      int x = n / i;
      int cntx = 0, cnty = 0;
      ;
      while (x > 0) {
        x /= 10;
        ++cntx;
      }
      int y = i;
      while (y > 0) {
        y /= 10;
        ++cnty;
      }
      chmin(ans, max(cntx, cnty));
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
string s;
int main(){
  cin>>s;
  ll ans=0,cnt=0;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]=='A')cnt++;
    else if(s[i]=='B'&&s[i+1]=='C'){
      ans+=cnt;
      i++;
    }
    else cnt=0;
    //cout<<cnt<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
l = [[0]*n for i in range(n)]
for i in range(n):
    for j in range(n):
        l[i][j] = ((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5
a = 0
for i in range(n):
    a += sum(l[i][i:])
print(a/n*2)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=300+10,mod=1e9+7;
int p[maxn<<1];
int f[maxn<<1][maxn][maxn];
inline void add(int &x,int y){
	x+=y;
	x=(x>=mod?x-mod:x);
}
int main(){
	int n=read(),T=0;
	REP(i,1,n){
		int x=read(),y=read();
		if(x>0) p[x]=1;
		if(y>0) p[y]=1;
		if(x==-1 && y==-1) ++T;
		else if(x>0 && y>0) p[x]=p[y]=-1;
	}
	f[0][0][0]=1;
	REP(i,0,2*n-1) REP(j,0,min(i,n)) REP(k,0,min(i,n)-j) if(f[i][j][k]){
		if(p[i+1]==-1){
			add(f[i+1][j][k],f[i][j][k]);
		}
		else if(p[i+1]){
			if(j) add(f[i+1][j-1][k],(ll)j*f[i][j][k]%mod);
			add(f[i+1][j][k+1],f[i][j][k]);
		}
		else{
			if(k) add(f[i+1][j][k-1],f[i][j][k]);
			add(f[i+1][j][k+1],f[i][j][k]);
			add(f[i+1][j+1][k],f[i][j][k]);
		}
	}
	int ans=f[2*n][0][0];
	REP(i,1,T) ans=(ll)ans*i%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 225536
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;


/* range: ± 3.27 * 10^4 */
using i16 = short int;
/* range: 0 to 65535 */
using u16 = short unsigned int;
/* range: ± 2.14 * 10^9 */
using i32 = int;
/* range: 0 to 4.29 * 10^9 */
using u32 = unsigned int;
/* range: ± 9.22 * 10^18 */
using i64 = long long int;
/* range: 0 to 1.84 * 10^19 */
using u64 = long long unsigned int;


i64 knapsack(const vector<i32>& w, const vector<i32>& v, i32 capacity) {
    vector<i64> dp(capacity + 1, 0);
    for (i32 i = 0; i < w.size(); i++) {
        for (i32 curr_capacity = capacity; curr_capacity >= w[i];
             curr_capacity--) {
            dp[curr_capacity] =
                max(dp[curr_capacity], dp[curr_capacity - w[i]] + v[i]);
        }
    }

    return dp[capacity];
}

i32 main() {
    i32 items = 0, capacity = 0;
    cin >> items >> capacity;

    vector<i32> w(items), v(items);
    for (i32 i = 0; i < items; i++) {
        cin >> w[i] >> v[i];
    }

    cout << knapsack(w, v, capacity) << '\n';
}

Measured memory_bytes: 4052
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

a = I()
b = I()
h = I()

ans = (a+b)*h//2
print(ans) 


Measured memory_bytes: 68376
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
 
// ------------------------------------------------------------------------------------------------

const ll MOD = 1e9 + 7;
ll n;
vvll dp;
string s;

void update(ll i, ll j) {
    for (ll k = 0; k < 13; k++) {
        (dp[i][(k + j) % 13] += dp[i - 1][k]) %= MOD;
    }
}

int main() {
    fast_io; cout_precision;
    cin >> s;
    reverse(s.begin(), s.end());
    n = s.length();
    dp.resize(n, vll(13, 0));
    if (s[0] == '?') {
        for (ll i = 0; i < 10; i++) {
            dp[0][i]++;
        }
    } else {
        dp[0][s[0] - '0']++;
    }
    for (ll i = 1, p = 10; i < n; i++, (p *= 10) %= 13) {
        if (s[i] == '?') {
            for (ll j = 0; j < 10; j++) {
                update(i, j * p % 13);
            }
        } else {
            update(i, (s[i] - '0') * p % 13);
        }
    }
    cout << dp[n - 1][5] << endl;
}

Measured memory_bytes: 13648
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e+5+5;
const int mo = 1e+9+7;

int n;
struct edge{
	int x,nxt;
}e[N*2];
int h[N],tot;
int r[N];
bool vis[N];
int he,ta,k,sum;
int que[N],cir[N],m;
LL js[N],inv[N];
int fa[N],dep[N];
bool bz[N];
LL ans;
int xx[N],yy[N],kx,ky;
int to[N],a[N],pk;
int lef[N],rig[N];
int siz[N];

void inse(int x,int y){e[++tot].x=y;e[tot].nxt=h[x];h[x]=tot;}

void getto(int st){
	int qu[N],he=0,ta=1;
	qu[1]=st;
	while(he<ta){
		int x=qu[++he];
		for(int p=h[x];p;p=e[p].nxt)
		if (!bz[e[p].x]&&!to[e[p].x]){
			to[e[p].x]=x;
			qu[++ta]=e[p].x;
		}
	}
}

LL solve_tree(int x){
	siz[x]=1;
	LL tmp=1;
	for(int y=lef[x];y;y=rig[y]){
		tmp=tmp*solve_tree(y)%mo;
		siz[x]+=siz[y];
		tmp=tmp*inv[siz[y]]%mo;
	}
	tmp=tmp*js[siz[x]-1]%mo;
	return tmp;
}

LL solve(){
	fo(i,1,k)r[que[i]]=lef[que[i]]=rig[que[i]]=0;
	fo(i,1,k){
		int x=que[i];
		if (x<to[to[x]]){
			rig[x]=lef[to[x]];
			lef[to[x]]=x;
			r[x]=1;
		}
	}
	LL val=1;
	fo(i,1,k)
	if (!r[que[i]]){
		LL tmp=solve_tree(que[i]);
		val=val*tmp%mo*inv[siz[que[i]]]%mo;
	}
	val=val*js[k]%mo;
	return val;
}

void bfs(int st){
	he=0,ta=1;
	vis[que[1]=st]=dep[st]=1;
	sum=0;
	while(he<ta){
		int x=que[++he];
		sum+=r[x];
		for(int p=h[x];p;p=e[p].nxt)
		if (!vis[e[p].x]){
			fa[e[p].x]=x;
			dep[e[p].x]=dep[x]+1;
			vis[que[++ta]=e[p].x]=1;
		}
	}
	k=ta;
	sum/=2;
	if (sum!=k){ans=0;return;}
	int keyx=0,keyy;
	fo(i,1,k){
		int x=que[i];
		for(int p=h[x];p;p=e[p].nxt)
		if (fa[e[p].x]!=x&&fa[x]!=e[p].x)keyx=x,keyy=e[p].x;
		if (keyx)break;
	}
	kx=ky=1;
	xx[1]=keyx;yy[1]=keyy;
	while(keyx!=keyy){
		if (dep[keyx]>dep[keyy])xx[++kx]=keyx=fa[keyx];
		else yy[++ky]=keyy=fa[keyy];
	}
	pk=kx+ky-1;
	fo(i,1,kx)a[i]=xx[i];
	fo(i,1,ky)a[pk-i+1]=yy[i];
	LL tmp=0;
	fo(i,1,pk)bz[a[i]]=1;
	fo(i,1,pk){
		to[a[i]]=a[i%pk+1];
		getto(a[i]);
	}
	tmp=solve();
	fo(i,1,pk)to[a[i%pk+1]]=a[i];
	tmp=(tmp+solve())%mo;
	ans=ans*tmp%mo;
	ans=ans*inv[k]%mo;
}

int main(){
	n=get()*2;
	js[0]=inv[0]=js[1]=inv[1]=1;
	fo(i,2,n)js[i]=js[i-1]*i%mo,inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo;
	fo(i,1,n)inv[i]=inv[i]*inv[i-1]%mo;
	fo(i,1,n){
		int x=get(),y=get()+n/2;
		inse(x,y),inse(y,x);
		r[x]++,r[y]++;
	}
	ans=1;
	fo(i,1,n)
	if (!vis[i])bfs(i);
	ans=ans*js[n]%mo;
	printf("%lld\n",ans);
	return 0;
}

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

#define repi(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) repi(i, 0, a)
#define repd(i, a, b) for(int i = (a); i >= (b); i--)
#define repit(i, a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)

#define all(u) (u).begin(), (u).end()
#define rall(u) (u).rbegin(), (u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)), (u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

struct point
{
    double x, y, z;
    point(double x, double y, double z) : x(x), y(y), z(z) {}
    double abs() {
	return sqrt(x * x + y * y + z * z);
    }
    double theta(point t) {
	double d = x * t.x + y * t.y + z * t.z;
	return acos(d / abs() / t.abs());
    }
};

int n, m;
vector<point> s, t;
vector<double> psi;

int solve()
{
    int ret = 0;
    rep(i, n) {
	rep(j, m) {
	    if (s[i].theta(t[j]) < psi[j] + EPS) {
		++ret;
		break;
	    }
	}
    }
    return ret;
}

int main()
{
    while (cin >> n && n) {
	s.clear();
	t.clear();
	psi.clear();

	rep(i, n) {
	    double x, y, z;
	    cin >> x >> y >> z;
	    s.pb(point(x, y, z));
	}
	cin >> m;
	rep(i, m) {
	    double x, y, z, d;
	    cin >> x >> y >> z >> d;
	    t.pb(point(x, y, z));
	    psi.pb(d);
	}

	cout << solve() << endl;
    }

    return 0;
}

Measured memory_bytes: 1352
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
 
l= int(readline())
if l% 2 == 1:
    print(0)
else:
    l //= 2
    ans = 0
    while l:
        l //= 5
        ans += l
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<ll> A(N), B(N); ll sum = 0;
    REP(i, 0, N) {
        cin >> A[i];
        sum += A[i];
    }

    B[0] = sum;
    for (int i = 1; i < N; i += 2) B[0] -= 2 * A[i];

    cout << B[0] << " ";
    REP(i, 1, N) {
        B[i] = 2 * A[i - 1] - B[i - 1];
        cout << B[i];
        if (i != N - 1) cout << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

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

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i%3==0 || i%5==0) continue;
        ans+=i;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int total = 0;
		for (int i=0; i<3; i++) {
			total += sc.nextInt();
		}
		
		System.out.println(total > 21 ? "bust" : "win");
    }
}


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

typedef long long ll;
char Ans;

void ask(ll x) {
    cout << "? " << x << endl;
    fflush(stdout);
    cin >> Ans;
}
void ans(ll x) {
    cout << "! " << x << endl;
}

int main() {
    ask(10000000000);
    if(Ans == 'Y') {
        int p = 2;
        for(int i = 0; i <= 9; i++) {
            ask(p);
            if(Ans == 'Y') {
                ans(p/2);
                return 0;
            }
            p *= 10;
        }
    }
    else {
        int s = 0, e = 9;
        int x;
        while(s <= e) {
            int m = (s + e)>>1;

            int p=1;
            for(int i = 0; i < m; i++) p*=10;

            ask(p);

            if(Ans == 'Y') {
                x = m;
                s = m + 1;
            }
            else e = m - 1;
        }

        ll cur = 0;
        for(int i = x; i >= 0; i--) {
            s = (i == x), e = 9;
            int y;
            while(s <= e) {
                int m = (s + e)>>1;

                ll p=1;
                for(int j = 0; j < i + 1; j++) p*=10;

                ask(cur*10 + p*(m + 1) - 1);

                if(Ans == 'Y') {
                    y = m;
                    e = m - 1;
                }
                else s = m + 1;
            }

            int p = 1;
            for(int j = 0; j < i; j++) p*=10;
            cur += y*p;
        }
        ans(cur);
    }
}


Measured memory_bytes: 596
use std::io::*;//Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let k:i64 = read();
    let mut cnt = 0;
    for i in 0..2000{
        for j in -2000..2000{
            let x = i as i64;
            let y = j as i64;
            if x*x*x*x*x - y*y*y*y*y == k && cnt == 0{
                println!("{} {}",x,y);
                cnt = 1;
            }
        }
    }
}

Measured memory_bytes: 2116
#include <stdio.h>
int main(void) {
    int num,que,i,year[51];
    char name[51][31];
    scanf("%d %d",&num,&que);
    for (i=0; i<num; i++) {
        scanf("%d %s",&year[i],name[i]);
    }
    i=0;
    while (year[i]<=que&&i<num) {
        i++;
    }
    if (i==0) {
        printf("kogakubu10gokan\n");
    } else {
        printf("%s\n",name[i-1]);
    }
    return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one
}

int main() {

    ll n = inp1;
    vector<ll> a = inp(n - 1);

    vector<int> ans(n, 0);

    rep(i, n - 1) {
        ++ans[a[i] - 1];
    }

    rep(i, n) Cout(ans[i]);

    return 0;
}


Measured memory_bytes: 5632
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vvi vector<vi>
#define pb push_back
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
#define vd vector<double>
#define deb(x) cout<<#x<<" -> "<<x<<endl
const int inf=0x3f3f3f3f3f3f3f3f;
#define MAXN 1000005

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

void print(vi &v){
    for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<endl;
}

// <--------------------Code Begins Here-------------------->




int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--){
        int x;
        cin>>x;
        if(x>=30)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
import math
import fractions
import sys
sys.setrecursionlimit(2000000000)
a,b= list(map(int, input().split()))
ma=fractions.gcd(a,b)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
ans=1
for i in make_divisors(ma):
    if is_prime(i):
        ans+=1
print(ans)

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, ans;
string a, b, c;

int main(){
	cin >> n;
	cin >> a >> b >> c;
	for(int i=0;i<n;i++){
		int co = 0;
		if(a[i]==b[i]) co++;
		if(c[i]==b[i]) co++;
		if(a[i]==c[i]) co++;
		if(co==3) co--;
		ans += 2 - co;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
struct UnionFind{
    int n;
    set<int> dame;
    vi p;
    vi use;
    UnionFind(int N):n(N){
        p.resize(n);
        use.resize(n);
    	iota(all(p),0);
    	rep(i,n){
    	    int tmp;
    	    cin>>tmp;
    	    unite(i,tmp+i);
    	}
    }
    void unite(int a, int b){int c=root(a),d=root(b); if(c!=d) p[c]=d; else if(a!=b) dame.insert(root(a));}
    int root(int a){return p[a]=(p[a]==a?a:root(p[a]));}
    bool same(int a, int b){return root(a)==root(b);}
    void useable(){
        set<int> tmp;
        for(auto i :dame)tmp.insert(root(i));
        dame=tmp;
        rep(i,n){
            use[i]=dame.find(root(i))==dame.end();
        }
    }
};
int main(){
	int n;
	cin>>n;
	UnionFind uf(n);
	//rep(i,n)cout<<uf.p[i]<<",";cout<<endl;
	uf.useable();
    //for(auto i :uf.use)cout<<i<<",";cout<<endl;
    vi turn(n,-1);
    turn[0]=0;
    queue<int> que;
    que.push(0);
    while(turn[n-1]==-1){
        int c=que.front();que.pop();
        range(d,1,7){
            if(c+d<n && uf.use[c+d] && turn[uf.root(c+d)]==-1){
                que.push(uf.root(c+d));
                turn[uf.root(c+d)]=turn[c]+1;
            }
        }
    }
    cout<<turn[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 4580
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 20:59:27 2019

@author: doppe
"""
S = input()

zero = 0
ichi = 0
for c in S:
    if (c == '0'):
        zero += 1
    elif (c == '1'):
        ichi += 1

if (zero > ichi):
    deleteNum = ichi * 2
else:
    deleteNum = zero * 2

print(deleteNum)

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

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int[] A;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        A = new int[N];
        for (int i=0; i<N; i++) {
        	A[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private boolean solve() {
        Arrays.sort(A);
    	boolean judge = false;	//すべて異なっていればfalseのまま
        
        for (int i=1; i<N; i++) {
        	if (A[i] == A[i-1]) {
        		judge = true;
        		break;
        	}
        }
        
        return judge;
    }
    
    //出力
    public void show(boolean judge) {
        if (!judge) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
    }

}


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

ll N, A, B;

int main() {
    cin >> N >> A >> B; 

    ll ans;
    if ((B-A) % 2 == 0) {
        ans = min((B-A)/2, min(N-A, B-1));
    }
    else {
        ll tmp_A = A + (B-A-1)/2;
        ll tmp_B = N-B+1 + (N - (A+N-B+1))/2;
        ll tmp_C = N-A;
        ll tmp_D = B-1;
        ans = min(tmp_A, min(tmp_B, min(tmp_C, tmp_D)));
    }

    cout << ans << endl;

    return 0;
}

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

int main() {

    string S, T;
    cin >> S >> T;

    int ans = 0;

    for (int i = 0; i < S.size(); ++i)
    {
        if (S[i] != T[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3848
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, m, a;
prique<int> que;
signed main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> a;
		que.push(a);
	}
	rep(i, m) {
		int v = que.top();
		que.pop();
		que.push(v / 2);
	}
	int ans = 0;
	rep(i, n) {
		ans += que.top();
		que.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 1400
n,a,b=map(int,input().split())
s=input()
passed=0
abroad_passed=0
for i in s:
    if i=="a":
        if passed<a+b:
            print("Yes")
            passed+=1
        else:
            print("No")
    elif i=="b":
        if passed<a+b and abroad_passed<=b-1:
            print("Yes")
            passed+=1
            abroad_passed+=1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  int mem[N] = {};
  int temp = 0;
  for(int i = 0; i < N - 1; i++){
    cin >> temp;
    mem[temp - 1] += 1;
  }
  for(int i = 0; i < N; i++) cout << mem[i] << endl;
  return 0;
}

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

using namespace std;

typedef long long int lli;

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

    string s, t;
    int slen, tlen;
    vector<vector<int>> lcs(3001, vector<int>(3001, 0));
    vector<vector<pair<int, int>>> prev(3001, vector<pair<int, int>>(3001, make_pair(0, 0)));

    cin >> s >> t;
    slen = s.size(); tlen = t.size();
    for (int is=1; is<=slen; is++) {
        for (int it=1; it<=tlen; it++) {
            if (s[is-1] == t[it-1]) {
                lcs[is][it] = lcs[is-1][it-1] + 1;
                prev[is][it] = make_pair(is-1, it-1);
            }
            else {
                lcs[is][it] = (lcs[is-1][it] >= lcs[is][it-1]) ? lcs[is-1][it] : lcs[is][it-1];
                prev[is][it] = (lcs[is-1][it] >= lcs[is][it-1]) ? make_pair(is-1, it) : make_pair(is, it-1);
            }
        }
    }

    auto c = make_pair(slen, tlen);
    string ans = "";
    while (c.first != 0 || c.second != 0) {
        auto p = prev[c.first][c.second];
        if (c.first-p.first == c.second-p.second) {
            ans = s[c.first-1] + ans;
        }
        c = p;
    }
    cout << ans << endl;

    return 0;
}


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

//vector <long long> v[1000001];

//stack <long long> s, s2;

//queue <long long> s;

long long int  x[2000000], y[10000], m=0, szu, wy;
//char s[10000000];

int main()
{
    long long int d, e, f, i, j, q, t, n, k, a, b, c, w, p, aa, bb, cc, dd, nn, kk;
    t=1;
 //   scanf("%lld", &t);
    for(q=1; q<=t; q++)
    {
        scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

        w=max(a*c, max(a*d, max(b*c, b*d)));

        printf("%lld\n", w);
    }
    return(0);
}



Measured memory_bytes: 3820
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){
	
	ll n, a[300000], ans=0;
	cin >> n;
	for(int i=0; i<3*n; i++){
		cin >> a[i];
	}
	sort(a, a+3*n);
	for(int i=n; i<3*n; i+=2){
		ans+=a[i];
	}
	cout << ans << endl;

	return 0;
}


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

#define LL long long
#define pa pair<int,int>
using namespace std;
const int N = 5001;
const int inf = 2147483647;

int _max(int x, int y) {return x > y ? x : y;}
LL _min(LL x, LL y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int a[N]; LL f[N][N];

int main() {
	int n = read(), A = read(), B = read();
	for(int i = 1; i <= n; i++) a[i] = read();
	memset(f, 63, sizeof(f)); f[0][0] = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= n; j++) {
			if(a[i] > j) {
				f[i][j] = _min(f[i][j], f[i - 1][j] + A);
				f[i][a[i]] = _min(f[i][a[i]], f[i - 1][j]);
			} else f[i][j] = _min(f[i][j], f[i - 1][j] + B);
		}
	} LL ans = f[0][1];
	for(int i = 0; i <= n; i++) ans = _min(ans, f[n][i]);
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 195712
#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++)

const ll mod = ll(1e9) + 7;
const int INF = 1<<29;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans;
    if (abs(a-b)%2==0) ans = abs(a-b)/2;
    else ans = min(a-1,n-b) + (abs(a-b)+1)/2;
    cout << ans << endl;
    return 0;
}

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

long long int dp[105][100005];
long long int n;
long long capacity;
long long cost[102],weight[102];

long long func(long long i,long long w)
{

   long long p=0,q=0;
    if(i==n+1)
        return 0;

    if(dp[i][w]!=-1)
        return dp[i][w];


    else
    {
        if(w+weight[i]<=capacity)
        {
            p=cost[i]+func(i+1,w+weight[i]);

        }

        q=func(i+1,w);

        dp[i][w]=max(p,q);

        return dp[i][w];



    }
}
int main(){

    memset(dp,-1,sizeof(dp));


    cin>>n>>capacity;



    for(long long i=1; i<=n; i++)
    {
        cin>>weight[i]>>cost[i];
    }
      cout<<func(1,0)<<endl;



    return 0;

}


Measured memory_bytes: 82304
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int cnt = 0;
		for(int i = Math.min(a,b); i >= 1; i--){
			if(a%i == 0 && b%i == 0){
				cnt += 1;
				if(cnt == k){
					System.out.println(i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 23380
import collections

a = list(map(int,input().split()))

c = collections.Counter(a)
if c.most_common()[0][0] == 5 and c.most_common()[0][1] == 2 and c.most_common()[1][0] == 7 and c.most_common()[1][1] == 1:
    print("YES")
else:
    print("NO")


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

using namespace std;

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

	int test; cin >> test;
	if(test >= 30) cout << "Yes" << endl;
  	else cout << "No" << endl;
	

	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#define MOD 1000000007
using namespace std;
typedef long long ll;
signed main(){
  ll n,k,val=1;
  cin >> n >> k;
  for(ll i=0;i<n;i++){
    val*=k;
    val%=MOD;
  }
  cout << val << endl;
}



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

int A[1005]={};

void insertSort(int a[], int n){
    int v,j;
    for(int i=1; i<n; i++){
        for(int i=0; i<n; i++){
            if(i)cout<<" ";
            cout<<a[i];
        }
        cout<<endl;
        v=a[i];
        j=i-1;
        while(j>=0&&a[j]>v){
            a[j+1]=a[j];
            j--;
            a[j+1]=v;
        }
    }
    for(int i=0; i<n; i++){
        if(i)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
}

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

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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int ans;
int indeg[1000005]; //入次数
int d[1000005];
vector<int> g[1000005];
map<P, int> m;
int num = 1;
int days = 0;

bool topological_sort(int _n, vector<int>& topo) {
    queue<int> q;

    for (int i=1; i<=_n; i++) {
        if (indeg[i]==0) {
            q.push(i);
            d[i] = 1;
        }
    }
    while(!q.empty()) {
        int u = q.front(); q.pop();
        topo.push_back(u);
        for (int v : g[u]) {
            indeg[v]--;
            if (indeg[v]==0) {
                q.push(v);
                d[v] = d[u] + 1;
            }
        }
    }
    return (int)topo.size() == _n;
}



int main(void) {
    int n;
    cin >> n;
    for (int i=1; i<=n; i++) {
        int s, u, v;
        cin >> s;
        P p = mp(i, s);
        if (s<i) swap(p.first, p.second);
        if (m.count(p)==0) m[p] = num++;
        u = m[p];

        for (int j=2; j<=n-1; j++) {
            int t;
            cin >> t;
            P q = mp(i, t);

            if (t<i) swap(q.first, q.second);
            if (m.count(q)==0) m[q] = num++;
            v = m[q];
            g[u].push_back(v);
            indeg[v]++;
            u = v;
        }

    }

    vector<int> v;
    bool dag = topological_sort(num-1, v);

    if (dag) {
        rep(i, 1, num) {
            ans = max(ans, d[i]);
        }
    } else {
        ans = -1;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 79988
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int s[11];
int main(){
	scanf("%d%d%d",&s[1],&s[2],&s[3]);
	sort(s+1,s+4);
	if(s[3]-s[2]==s[2]-s[1]) printf("YES");
	else printf("NO");
	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A_ = {}

for a in A:
  if a not in A_:
    A_[a] = 1
  else:    
    A_[a] += 1
    break
if len(A) == len(A_):
  print("YES")
else:
  print("NO")



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

int main(){
	int a,b,c,d;cin>>a>>b>>c>>d;
	if(a+b>c+d)puts("Left");
	else if(a+b<c+d)puts("Right");
	else puts("Balanced");
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
	let n = read!(usize);
	let mut s = read!(String;n);
	s.sort();
	s.dedup();
	println!("{}", s.len());
}

fn run() {
    solve();
}


Measured memory_bytes: 13824
s = raw_input().strip()
n = len(s)

ok = 1
for i in xrange(n):
    if i & 1:
        if s[i] not in "LUD":
            ok = 0
            break
    else:
        if s[i] not in "RUD":
            ok = 0
            break

if ok:
    print "Yes"
else:
    print "No"

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

int main()
{
  int n,i,j,ta=0,ha=0;
  string a,b;
  cin >> n;
  for(i=0;i<n;i++){
    cin >>a >>b;
    for(j=0;j<100;j++){
        if(a==b){ta++; ha++; break;}
        else if(a[j]>b[j]){ ta+=3; break;}
        else if(b[j]>a[j]){ ha+=3; break;}
    } 
  }
  cout << ta << " " << ha << endl;
  
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int a,b; cin >> a >> b;
	cout << a*b << endl;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> b(n);
	vector<int> ans;
	for( auto &k : b ){
		cin >> k;
		--k;
	}
	for( int i = 0; i < n; ++i ){
		int maxindex = -1;
		for( int j = 0; j < n-i; ++j ){
			if( b[j] == j ){
				maxindex = max( j, maxindex );
			}
		}
		if( maxindex == -1 ){
			cout << maxindex << endl;
			return 0;
		}
		ans.push_back( maxindex );
		b.erase( b.begin() + maxindex );
	}
	reverse( ans.begin(), ans.end() );
	for( auto k : ans ){
		cout << k+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int func(int x);

int main() {
	int x;
	while (true) {
		cin >> x;
		if (x == 0) { break; }
		cout << func(x) / 3650 + 1 << endl;
	}
	
	return 0;
}

int func(int x) {
	if (x == 1) {
		return 1;
	}
	else if (x == 2) {
		return 2;
	}
	else if (x == 3) {
		return 4;
	}
	else {
		return func(x - 1) + func(x - 2) + func(x - 3);
	}
}

Measured memory_bytes: 1160
"""
ユークリッドの互除法により最大公約数を求めます
int a,b
return int
"""
def divisor(a,b):
    if a < b : #bのほうが大きければ入れ替え
        b += a
        a = b - a
        b -= a

    r = a % b
    while(r != 0):
        a = b
        b = r
        r= a % b
    return b

"""
最小公倍数を最小公約数から求めます
int a,b
return int
"""
def multiple(a,b):
    c = divisor(a,b)
    return int(a*b/c)

a,b = map(int,input().split())

print(multiple(a,b))


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  vector<vector<int64_t>> dp(n + 1, vector<int64_t>(n + 1));
  for (int s = n - 1; s >= 0; s--) {
    for (int i = 0; i <= s; i++) {
      dp.at(i).at(s - i) = max(a.at(i) - dp.at(i + 1).at(s - i),
                               a.at(n - 1 - (s - i)) - dp.at(i).at(s - i + 1));
    }
  }
  cout << dp.at(0).at(0) << endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    int i;
    int c[500];
    int j=0;
    for(i=1;i<=max(a,b);i++)
    {
        if(a%i==0&&b%i==0)
        {
            //cout<<i<<" ";
            c[j]=i;
            j++;
        }
    }
    sort(c,c+j,cmp);
    cout<<c[k-1];
}


Measured memory_bytes: 256
k, s = map(int, input().split())

ans = 0
for x in range(0, k+1):
    if s-x < 0 or s-x > 2*k:
        # no answer (y,z)
        continue
    elif 0 <= s-x <= k:
        ans += 1+s-x
    else:
        ans += k - (s-x-k) + 1

print(ans)


Measured memory_bytes: 2940