akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
	
using namespace std;
 
#define int long long
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define LOCAL
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)
 
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;
 
const int INF = LONG_LONG_MAX/2;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;

int cnt[1000000];

int32_t main() {
	FAST_IO;
	
	int n;
	cin >> n;
	
	const int N = 101;
	for (int x = 1; x <= N; x++) {
		for (int y = 1; y <= N; y++) {
			for (int z = 1; z <= N; z++) {
				if (x*x + y*y + z*z + x*y + y*z + z*x < 100000)
					cnt[x*x + y*y + z*z + x*y + y*z + z*x]++;
			}
		}
	}
	
	for (int i = 1; i <= n; i++) {
		cout << cnt[i] << endl;
	}
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17


Measured memory_bytes: 4040
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import Counter
from itertools import product

def main():
    N = II()
    dp = Counter()
    dp['000'] += 1
    for _ in range(N):
        pre = dp
        dp = Counter()
        for (p3, p2, p1), n in pre.items():
            for cur in 'AGCT':
                if p2 + p1 + cur in ['AGC', 'GAC', 'ACG']:
                    continue
                if p3 + p1 + cur == 'AGC':
                    continue
                if p3 + p2 + cur == 'AGC':
                    continue
                new = p2 + p1 + cur
                dp[new] = (dp[new] + n) % MOD
    ans = sum(dp.values())

    return ans % MOD

print(main())

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

int main()
{
    int r, g, b;
    scanf("%d%d%d", &r, &g, &b);
    if ((r * 100 + g * 10 + b) % 4 == 0)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[][] d = new boolean[n][2];
        for(int i=0; i<m; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            if(a == 0) d[b][0] = true;
            if(b == n-1) d[a][1] = true;
        }
        sc.close();

        boolean ans = false;
        for(int i=0; i<n; i++){
            if(d[i][0] && d[i][1]) ans = true;
        }

        if(ans){
            System.out.println("POSSIBLE");
        }else{
            System.out.println("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 105264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();

		int count = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != t.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 41216
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  vector<double> P(N);
  vector<double> E(N),Q(N + 1);
  
  for(int i = 0; i < N; i++) cin >> P[i];
  Q[0] = 0;
  for(int i = 0; i < N; i++) E[i] = (1 + P[i])/2; 
  for(int i =  1; i < N + 1; i++){
      Q[i] += Q[i-1] + E[i-1];
  }
  double S_MAX = 0;
  for(int i = 0; i < N - K + 1; i++){
    if(S_MAX < Q[i+K] - Q[i]) S_MAX =  Q[i+K] - Q[i];
  }
  cout << fixed << setprecision(12);
  cout << S_MAX << endl;
}


Measured memory_bytes: 4992
#include<iostream>

using namespace std;




int main(){
    int n;
    cin >> n;
    int s[n];
    int count=0;
    for(int i=0;i<n;i++){
        cin >> s[i];
        if(i>1){
            if( (s[i-1]>s[i-2]) && (s[i]>s[i-1])  || (s[i-2]>s[i-1]) && (s[i-1]>s[i]) ) count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
S = [input() for i in range(h)]

ans = -1

for si in range(h):
    for sj in range(w):
        if S[si][sj] == ".":
            V = [[-1] * w for i in range(h)]
            Q = [[si, sj, 0]]
            s = 0
            V[si][sj] = 0
            while s < len(Q):
                i = Q[s][0]
                j = Q[s][1]
                d = Q[s][2]
                for t in [[-1,0], [1,0], [0,-1], [0,1]]:
                    di = t[0]
                    dj = t[1]
                    if 0 <= i+di < h and 0 <= j+dj < w and V[i+di][j+dj] == -1 and S[i+di][j+dj] == ".":
                        V[i+di][j+dj] = d+1
                        Q.append([i+di, j+dj, d+1])
                s += 1

            # print(V)

            ans = max(ans, max([max(V[i]) for i in range(h)]))
print(ans)

Measured memory_bytes: 47836
#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
using namespace std;
int main()
{
	LL a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	if(a+b<=c*2)
	{
		cout<<a*x+b*y;
		rt0;
	}
	LL mx=max(x,y),mn=min(x,y);
	LL ans1=mn*2*c,ans2=mx*2*c;
	if(mx==x) ans1+=(x-y)*a;
	else ans1+=(y-x)*b;
	cout<<min(ans1,ans2);
    rt0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int k,t;
    cin>>k>>t;
    int a[t];
    int max=0;
    int sum=0;
    for(int i=0;i<t;i++){
        cin>>a[i];
        sum+=a[i];
        if(max<a[i]){
            max=a[i];
        }
    }
    if(max-1>sum-max){
        cout<<max-1-sum+max<<endl;
    }else{
        cout<<"0"<<endl;
    }
    return 0;
}


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

int main() {
    int h, w, k;
    char c[6][6];
    cin >> h >> w >> k;
    for (int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin >> c[i][j];
        }
    }
    int ret=0;
    for(int i=0; i<(1<<h); ++i){
        for(int j=0;j<(1<<w);++j){
            int cnt=0;
            for(int ii=0;ii<h;++ii){
                if(i&(1<<ii)){
                    for(int jj=0;jj<w;++jj){
                        if(j&(1<<jj) && c[ii][jj]=='#')cnt++;
                    }
                }
            }
            if (cnt==k)++ret;
        }
    }
    cout << ret;
    return 0;
}

Measured memory_bytes: 3628
//#define MyDebug
#include <bits/stdc++.h>

#define rep(i, first, to) for(int i = first; i < to; ++i)
#define REP(i, first, to) for(int i = first; i <= to; ++i)

#ifdef MyDebug
	#define debug(x) cerr << #x << " : " << x << endl
	#define debugP(x) cerr << x << endl
#else
	#define debug(x)
	#define debugP(x)
#endif

using namespace std;
typedef long long ll;

ll odd, even;
ll c[2][51];
ll sum1(int n) {
	c[0][0] = 1;
	REP (i, 1, n) {
		c[i % 2][0] = 1;
		c[i % 2][i] = 1;
		REP(j, 1, i - 1) {
			c[i%2][j] = c[(i + 1) % 2][j - 1] + c[(i + 1) % 2][j];
			//cerr << c[(i + 1) % 2][j] << " " << c[(i + 1) % 2][j + 1] << " " << endl;
			//cerr << c[i % 2][j] << " ";
		}
		//cerr << endl;
	}
	ll ret = 0;
	REP(i, 0, n) {
		ret += c[n%2][i];
	}
	return ret;
}
ll sum_odd(int n) {
	c[0][0] = 1;
	REP (i, 1, n) {
		c[i % 2][0] = 1;
		c[i % 2][i] = 1;
		REP(j, 1, i - 1) {
			c[i%2][j] = c[(i + 1) % 2][j - 1] + c[(i + 1) % 2][j];
			//cerr << c[(i + 1) % 2][j] << " " << c[(i + 1) % 2][j + 1] << " " << endl;
			//cerr << c[i % 2][j] << " ";
		}
		//cerr << endl;
	}
	ll ret = 0;
	REP(i, 0, n) {
		if (i % 2 == 1) {
			ret += c[n%2][i];
		}
	}
	return ret;
}
ll sum_even(int n) {
	c[0][0] = 1;
	REP (i, 1, n) {
		c[i % 2][0] = 1;
		c[i % 2][i] = 1;
		REP(j, 1, i - 1) {
			c[i%2][j] = c[(i + 1) % 2][j - 1] + c[(i + 1) % 2][j];
			//cerr << c[(i + 1) % 2][j] << " " << c[(i + 1) % 2][j + 1] << " " << endl;
			//cerr << c[i % 2][j] << " ";
		}
		//cerr << endl;
	}
	ll ret = 0;
	REP(i, 0, n) {
		if (i % 2 == 0) {
			ret += c[n%2][i];
		}
	}
	return ret;
}

void solve() {
	int n, p;
	cin >> n >> p;
	rep(i, 0, n) {
		ll v;
		cin >> v;
		if (v % 2 == 0) even++;
		else odd++;
	}
	if (p == 1) {
		cout << sum1(even) * sum_odd(odd) << endl;
	} else {
		cout << sum1(even) * sum_even(odd) << endl;
	}
	debug(even);
	debug(odd);
}
void test() {
	debug(sum1(3));
}

int main() {
	solve();
	//test();
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A, B = [0]*N, [0]*N
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b
ans = 0
for j in range(N-1, -1, -1):
    ans += B[j] - ((A[j]+ans) % B[j]) if (A[j]+ans) % B[j] != 0 else 0
print(ans)

Measured memory_bytes: 10868
#include <stdio.h>
#include <limits.h>
int main(void)
{
    int k, a, b;
    long int ans=1;

    scanf("%d%d%d", &k, &a, &b);
   int i=k;

    if(b-a<=2){
        ans=ans+k;
        printf("%ld\n", ans);
        return 0;
    }

    while(i>0){
        if(ans>=a && i>=2){
            ans=ans+b-a;
            i=i-2;
        }
        else{
            ans=ans+1;
            i--;
        }
    }

    printf("%ld\n", ans);
       
    return 0;
}


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

int N;
int A[4];
bool CK[310][310][310];
double DP[310][310][310];

double get_DP(int x, int y, int z){
    if(CK[x][y][z]) return DP[x][y][z];
    CK[x][y][z] = 1;
    if(x == 0 && y == 0 && z == 0) return DP[x][y][z] = 0;
    double &ret = DP[x][y][z] = 0;
    if(x > 0) ret += get_DP(x - 1, y, z) * (double)x / (x + y + z);
    if(y > 0) ret += get_DP(x + 1, y - 1, z) * (double)y / (x + y + z);
    if(z > 0) ret += get_DP(x, y + 1, z - 1) * (double)z / (x + y + z);
    ret += (double)N / (x + y + z);

    return ret;
}
int main(void)
{
    cin >> N;
    for(int x, i = 1 ; i <= N ; i++) cin >> x, A[x]++;

    cout << fixed << setprecision(10);
    cout << get_DP(A[1], A[2], A[3]);
    return 0;
}

Measured memory_bytes: 254208
n, k = map(int, input().split())
h = list(int(input()) for i in range(n))
h.sort(reverse=True)

val = 1000000000

for i in range(n - k + 1):
	if val >= h[i] - h[i + k - 1]:
		val = h[i] - h[i + k - 1]
print(val)




Measured memory_bytes: 7496
#include<bits/stdc++.h>
using namespace std;
#define maxn 705
bool dis[maxn][maxn];
int fa[maxn*2],size[maxn*2],f[2][maxn*2];
int Find(int x){
	return fa[x]==x?x:fa[x]=Find(fa[x]);
}
int main(){
	int n,m;scanf("%d%d",&n,&m);
	int x1=n>>1,x2=n-x1,u,v;
	if(m<((x1-1)*x1+(x2-1)*x2)/2){
		puts("-1");return 0;
	}
	for(int i=0;i<m;i++){
		scanf("%d%d",&u,&v),dis[u][v]=dis[v][u]=1;
	}
	for(int i=1;i<=(n<<1);i++)fa[i]=i;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(!dis[i][j]){
				x1=Find(i),x2=Find(j);
				if(x1==x2){
					puts("-1");return 0;
				}
				int y2=Find(j+n),y1=Find(i+n);
				fa[y2]=x1,fa[y1]=x2;
			}
		}
	}
	for(int i=1;i<=n;i++){x1=Find(i),size[x1]++;}
	f[0][maxn]=1;
	for(int i=1;i<=n;i++){
		x1=Find(i),x2=Find(i+n);
		if(!size[x1]){
			memcpy(f[i&1],f[(~i)&1],sizeof(f[i&1]));
			continue;
		}
		int k=i&1,w=size[x1]-size[x2];size[x1]=size[x2]=0;
		memset(f[k],0,sizeof(f[k]));
		for(int i=0;i<maxn*2;i++){
			if(f[k^1][i])
			f[k][i-w]=f[k][i+w]=1;
		}
	}
	for(int i=maxn;;i++){
		if(f[n&1][i]){
			x1=(n-i+maxn)>>1,x2=n-x1;break;
		}
	}
	printf("%d",((x1-1)*x1+(x2-1)*x2)>>1);
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
#define Sort(a) sort(a.begin(), a.end())

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int c[n] = {0};
  int now = 1;
  int sycle = 0;
  c[0] = 1;
  for (ll i = 2; i < k+1; i++) {
    now = a[now-1];
    if (c[now-1] != 0) {
      sycle = i - c[now-1];
      k -= i;
      k %= sycle;
      for (int j = 0; j < k; j++) {
        now = a[now-1];
      }
      cout << a[now-1] << '\n';
      return 0;
    }
    c[now-1] = i;
  }
  cout << a[now-1] << '\n';
  return 0;
}

Measured memory_bytes: 5220
#include<stdio.h>

struct Queue{
	char s[15];
	int time;
};
Queue name[1000000];
int main(){
	int i,n,j,k,q;
	
	scanf("%d",&n);
	scanf("%d",&q);
	getchar();
	int cur=0;
	for(i=0;i<n;i++){
		scanf("%s",name[i].s);
		scanf("%d",&name[i].time);
		getchar();
	}
	for(i=0;i<n;i++){
		if(name[i].time>q){
			name[i].time-=q;
			cur+=q;
			name[n]=name[i];
			n++;
		}
		else{
			cur+=name[i].time;
			printf("%s %d\n",name[i].s,cur);
		}
	}
} 


Measured memory_bytes: 6456
a,b,c = map(int, input().split())
k = int(input())

time = 0

while True:
  if time >= k:
    print("No")
    break
    
  if a >= b:
    b *= 2
  elif b >= c:
    c *= 2
  time += 1
  
  if a < b and b < c:
    print("Yes")
    break

Measured memory_bytes: 61576
N = int(input())
H = list(map(int,input().split()))
flg = False
for i in range(N-1):
  if H[i] < H[i+1]:
    flg = False
  elif H[i] == H[i+1]:
    pass
  else:
    if H[i] - 1 == H[i+1]:
      if flg == True:
        print("No")
        exit()
      else:
        flg = True
    else:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=100005,C=5,mod=1e9+7;
int n,a[N],ans[N];
set<int> res;
map<int,int> s;
int check(){
	if(s.size()==2){
		for(auto i:s)if(i.se==res.size()-1&&res.count(i.fi))return i.fi;
		return 0;
	}else{
		return 0;
	}
}
void GG(){
	puts("-1"); exit(0);
}
void dfs(int p,int lst,set<int> res){
	if(p>n){
		For(i,1,n)wri(ans[i]); exit(0); 
	}
	for(auto i:res)if(i!=lst){
		ans[p]=i; set<int> re=res; re.erase(i);
		dfs(p+1,a[i],re);
	}
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read();
	For(i,1,n){
		a[i]=read(); res.insert(i); s[a[i]]++; 
	}
	if(n==2)GG();
	int lst=0; 
	For(i,1,n-C){
		int t=check();
		if(t){
			ans[i]=t; 
		}else{
			auto it=res.begin();
			if(*it==lst)it++;
			ans[i]=*it;
		}
		if(--s[a[ans[i]]]==0)s.erase(a[ans[i]]);
		res.erase(ans[i]);
		//cout<<ans[i]<<" "<<s[10]<<" "<<res.size()<<" "<<t<<endl;
		lst=a[ans[i]];
	}
	dfs(max(1,n-C+1),lst,res);
	GG();
}


Measured memory_bytes: 13712
import java.util.Scanner;

/**
 *
 * @author must
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] Map= new char[H][W];
        
        for (int i=0;i<H;i++){
            String tmp = sc.next();
            Map[i] = tmp.toCharArray();
        }
        
        for (int i=0;i<H;i++){
            for (int k=0;k<W;k++){
                char c = Map[i][k];
                if (c != '#'){
                    int cnt=0;
                    if (i-1>=0){
                        for (int m=k-1;m<=k+1;m++){
                            if (m>=0 && m<W){
                                char check = Map[i-1][m];
                                if (check=='#'){
                                    cnt++;
                                }
                            }
                        }
                    }
                    if (i+1<H){
                        for (int m=k-1;m<=k+1;m++){
                            if (m>=0 && m<W){
                                char check = Map[i+1][m];
                                if (check=='#'){
                                    cnt++;
                                }
                            }
                        }
                    }
                    if (k-1>=0){
                        char check = Map[i][k-1];
                        if (check=='#'){
                            cnt++;
                        }
                    }
                    if (k+1<W){
                        char check = Map[i][k+1];
                        if (check=='#'){
                            cnt++;
                        }
                    }
                    Map[i][k] = (char)('0'+cnt);
                }
            }
            System.out.println(Map[i]);
        }
        
    }
    
}


Measured memory_bytes: 23124
#include<iostream>
using namespace std; 
int main(){
    int a[100],n,v,j;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i]; 
    
    for(int i=0;i<n-1;i++)cout<<a[i]<<' ';
    cout<<a[n-1]<<endl;
    
    for(int i=1;i<n;i++){
        v=a[i];
        j=i-1;
        while(j>=0 && a[j]>v){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        for(int i=0;i<n-1;i++)cout<<a[i]<<' ';
        cout<<a[n-1]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#define _DEBUG
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//デバッグ
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug1(x1) cout<<#x1<<": "<<x1<<endl
#define debug2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug5,debug4,debug3,debug2,debug1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    ll N;
    cin>>N;
    ll cnt=0;
    bool ok=false;
    REP(i,N){
        ll d1,d2;
        cin>>d1>>d2;
        if(d1==d2){
            cnt++;
        }else{
            cnt=0;
        }
        if(cnt>=3){
            ok=true;
        }
    }
    if(ok){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3624
N = int(input())
a_list = list(map(int, input().split()))
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

s = []
s.append(0)

for i, a in enumerate(a_list):
    tmp = a + s[i]
    s.append(tmp)

s.sort()

s_dict = {}
for si in s:
    if si in s_dict.keys():
        s_dict[si] += 1
    else:
        s_dict[si] = 1
count = 0
for c in s_dict.values():
    if c >= 2:
        count += combinations_count(c, 2)
print(count)



Measured memory_bytes: 41076
N = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
A.append(0)

dA = []
for i in range(N+1):
    dA.append(A[i+1]-A[i])

sum = sum([abs(i) for i in dA])

for i in range(N):
    if dA[i] * dA[i+1] < 0:
        print(sum - abs(dA[i+1]) - abs(dA[i]) + abs(dA[i+1] + dA[i]))
    else:
        print(sum)

Measured memory_bytes: 13792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  if(N<2)
    cout<<1<<endl;
  else if(N<4)
    cout<<2<<endl;
  else if(N<8)
    cout<<4<<endl;
  else if(N<16)
    cout<<8<<endl;
  else if(N<32)
    cout<<16<<endl;
  else if(N<64)
cout<<32<<endl;
  else cout<<64<<endl;
}

Measured memory_bytes: 3548
// A - Sandglass2

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int X, t;
	cin >> X >> t;

	int ans = max(0, X - t);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int res = 0;

		for (int i = 1; i <= n; i++) {
			int target = i;
			int x = 0;
			while(target > 0) {
				x += target % 10;
				target /= 10;
			}
			if (x >= a && x <= b) {
				res += i;
			}
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21840
#include <bits/stdc++.h>
		using namespace std;
		#define ll long long
		#define INF 100000000LL
		#define mod 998244353
		#define pll pair<long,long>
		#define se second
		#define fi first
		#define pb push_back
		#include <ext/pb_ds/assoc_container.hpp>
		#include <ext/pb_ds/tree_policy.hpp>
		using namespace __gnu_pbds;

		typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
		typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;

		vector<int> parent;
		vector<int> rank1;
		
		void make_set(int u)
		{
			parent[u]=u;
			rank1[u]=0;
		}
		
		int find_set(int u)
		{
			if(u==parent[u])
				return u;
			return parent[u]=find_set(parent[u]);
		}
		
		void union_set(int a,int b)
		{
			a=find_set(a);
			b=find_set(b);
			if(b!=a)
			{
				if(rank1[a]<rank1[b])
					swap(a,b);
				parent[b]=a;
				if(rank1[a]==rank1[b])
					rank1[a]++;
			}
		}
		
		int main()
		{
			ll n;
			cin>>n;
			parent.resize(n+1);
			rank1.resize(n+1);
			vector<ll> x(n+1);
			vector<ll> y(n+1);
			vector<pll> x1;
			vector<pll> y1;
			vector<tuple<ll,ll,ll> > edges;
			for(ll i=1;i<=n;i++)
			{
					cin>>x[i];
					cin>>y[i];
					x1.pb({x[i],i});
					y1.pb({y[i],i});
			}
			sort(x1.begin(),x1.end());
			sort(y1.begin(),y1.end());
			
			for(ll i=1;i<x1.size();i++)
			{
				edges.pb(make_tuple(x1[i].fi-x1[i-1].fi,x1[i].se,x1[i-1].se));
				edges.pb(make_tuple(y1[i].fi-y1[i-1].fi,y1[i].se,y1[i-1].se));
			}
			
			for(ll i=1;i<=n;i++)
				make_set(i);
			sort(edges.begin(),edges.end());
			ll cost=0;
			for(auto i:edges)
			{
				ll w=get<0>(i);
				ll u=get<1>(i);
				ll v=get<2>(i);
			
				if(find_set(u)!=find_set(v))
				{
					//cout<<u<<" "<<v<<" "<<w<<endl;
					cost+=w;
					union_set(u,v);
				}
			}
			cout<<cost;		
					
					
		}


Measured memory_bytes: 15456
import java.math.BigInteger;
import java.util.Scanner;

@SuppressWarnings({"unused", "WeakerAccess"})
public class Main {
    // 最大公約数
    long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    // 階乗(n!)
    BigInteger fact(BigInteger n, BigInteger ans) {
        if(n.compareTo(BigInteger.ONE) < 1) return ans;
        return fact(n.subtract(BigInteger.ONE), ans.multiply(n));
    }

    // フィボナッチ数
    BigInteger fib(BigInteger n, BigInteger a, BigInteger b) {
        if(n.equals(BigInteger.ONE)) return a;
        return fib(n.subtract(BigInteger.ONE), b, a.add(b));
    }

    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        
        int res = 0;
        for(int i = 0; i < s.length; i++) {
            if(s[i] == t[i]) res++;
        }
        
        System.out.println(res);
    }
}


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

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

    int ansx = -1, ansy = -1, ansz = -1;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            if (10000 * i + 5000 * j + (n - i - j) * 1000 == y) ansx = i, ansy = j, ansz = n - i - j;
        }
    }

    cout << ansx << " " << ansy << " " << ansz << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int N; 
vector<int> in, color, ans;
vector<vector<pair<int, int>>> graph;

void dfs(int v, int p = -1){
  int c = 1;
  for(auto u : graph[v]){
    if(u.first == p) continue;
    if(p != -1 && color[p] == c) c++;
    ans[u.second] = c;
    color[v] = c++;
    dfs(u.first, v);
  }
}

signed main() {
  cin >> N;

  in.resize(N, 0);
  graph.resize(N);
  REP(i, N-1){
    int u, v;
    cin >> u >> v;
    u--; v--;
    graph[u].emplace_back(v, i);
    graph[v].emplace_back(u, i);
    in[u]++; in[v]++;
  }

  int MAX = 0;
  REP(i, N) chmax(MAX, in[i]);
  
  ans.resize(N);
  color.resize(N, 1);
  dfs(0);

  cout << MAX << "\n";
  REP(i, N-1){
    cout << ans[i] << "\n";
  }

  return 0;
}

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

int main(){
    long H, W, N;
    cin >> H >> W >> N;
    long sr, sc;
    cin >> sr >> sc;
    string S, T;
    cin >> S >> T;

    long u = sr, d = sr, r = sc, l = sc;
    for(unsigned long i = 0; i < N; ++i){
        if(S[i] == 'U')--u;
        if(S[i] == 'D')++d;
        if(S[i] == 'R')++r;
        if(S[i] == 'L')--l;
        if(u == 0 || l == 0 || d > H || r > W)return 0 & puts("NO");
        if(T[i] == 'U')--d;
        if(T[i] == 'D')++u;
        if(T[i] == 'R')++l;
        if(T[i] == 'L')--r;
        d = max(1L, d);
        u = min(H, u);
        l = min(W, l);
        r = max(1L, r);
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double n,x;
    int a,b;
    cin>>n;
    std::deque<double> deq;
    for (int i=0;i<n;i++) {
        cin>>x;
        deq.emplace_back(x);
        if (i==0) {
            a=x;
        } else {
            b=x;
            while (a%b!=0) {
                int tmp=b;
                b=a%b;
                a=tmp;
            }
            a=(a*b)/b;
        }
    }
    double sum=0;
    for (int j=0;j<n;j++) {
        sum+=a/deq[j];
    }
    printf("%.14f",a/sum);
    cout<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int MAX_M=2000,MAX_N=2000;

int M,N;
char S[MAX_M+1],T[MAX_N+1];

int s[MAX_M+1],t[MAX_N+1];
int dp[MAX_M+2][MAX_N+2][2];

int main(){
	scanf("%d %d",&M,&N);
	scanf("%s",S);
	scanf("%s",T);
	for (int i=0;i<M;i++){
		s[i]= (S[i]=='I' ? 1 : 0);
	}
	s[M]=-1;
	for (int i=0;i<N;i++){
		t[i]= (T[i]=='I' ? 1 : 0);
	}
	t[N]=-1;
	for (int i=M;i>=0;i--){
		for (int j=N;j>=0;j--){
			//dp[i][j][0]を埋める
			int a;
			if (s[i]==0 && t[j]==0){
				a=max(dp[i][j+1][1]+1,dp[i+1][j][1]+1);
			}
			else if (t[j]==0){
				a=dp[i][j+1][1]+1;
			}
			else if (s[i]==0){
				a=dp[i+1][j][1]+1;
			}
			else{
				a=0;
			}
			dp[i][j][0]=a;
			//dp[i][j][1]を埋める
			if (s[i]==1 && t[j]==1){
				a=max(dp[i][j+1][0]+1,dp[i+1][j][0]+1);
			}
			else if (t[j]==1){
				a=dp[i][j+1][0]+1;
			}
			else if (s[i]==1){
				a=dp[i+1][j][0]+1;
			}
			else{
				a=0;
			}
			dp[i][j][1]=a;
		}
	}
	//最も大きいdp[i][j][1]を求める
	int ma=0;
	for (int i=0;i<M;i++){
		for (int j=0;j<N;j++){
			if (dp[i][j][1]%2==1){
				ma=max(ma,dp[i][j][1]);
			}
			else{
				ma=max(ma,dp[i][j][1]-1);
			}
		}
	}
	printf("%d\n",ma);
	return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

struct data{
	llong place;
	llong cost;

	data(){};
	data(llong place, llong cost) :
		place(place),
		cost(cost)
	{}

	bool operator<(const data &ri) const{
		return cost < ri.cost;
	}
	bool operator>(const data &ri) const{
		return cost > ri.cost;
	}
};

vector<vector<P> > edges;
vector<llong> dis;
llong Dijkstra(int start){
	priority_queue<data, vector<data>, greater<data> > q;
	dis[start] = 0;

	q.push(data(start, 0));
	while(q.size()){
		data now = q.top(); q.pop();
		if(dis[now.place] < now.cost) continue;

		for(int i = 0; i < edges[now.place].size(); i++){
			P edge = edges[now.place][i];
			data next(edge.first, now.cost + edge.second);
			if(dis[next.place] <= next.cost) continue;
			dis[next.place] = next.cost;
			q.push(next);
		}
	}

	return -1;
}

int main(){
	llong N, Q, K;
	vector<llong> ans;

	cin >> N;
	edges.resize(N+1);
	dis.resize(N+1,inf);
	int a,b,c;
	for(int i = 0; i < N-1; i++){
		cin >> a >> b >> c;
		edges[a].push_back(P(b,c));
		edges[b].push_back(P(a,c));
	}

	cin >> Q >> K;
	Dijkstra(K);
	int x,y;
	for(int i = 0; i < Q; i++){
		cin >> x >> y;
		ans.push_back(dis[x] + dis[y]);
	}

	for(auto x : ans)
		cout << x << endl;

	return 0;
}

Measured memory_bytes: 11120
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = ii()
    A = [list(mi()) for _ in range(2)]
    m = -1
    for i in range(N):
        m = max(m, sum(A[0][:i+1])+sum(A[1][i:]))
    print(m)

if __name__ == '__main__':
    main()

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

int main() {
  int n;
  cin>>n;
  if(n<105) cout<<0;
  else if(n<135) cout<<1;
  else if(n<165) cout<<2;
  else if(n<189) cout<<3;
  else if(n<195) cout<<4;
  else cout<<5;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 3e5 + 5;
const int mod = 1e9 + 7;
int mp[8][2] = {3,1,5,2,2,2,4,7,3,3,6,1,5,5,3,1};
int dp[maxn][8],len;
char s[maxn];
int main(int argc, char const *argv[])
{
	scanf("%s",s);
	int len = strlen(s);
	dp[len][1] = dp[len][2] = 1;
	for(int i = len - 1;i >= 0; --i)
	{
		for(int j = 0;j < 8; ++j)
		{
			if(s[i] != '0')
			{
				dp[i][j] += dp[i + 1][mp[j][1]];
			}
			if(s[i] != '1')
			{
				dp[i][j] += dp[i + 1][mp[j][0]];
			}
			dp[i][j] %= mod;
		}
	}
	printf("%d\n",dp[0][0]);
	return 0;
}

Measured memory_bytes: 9856
N, M, Q = map(int, input().split())
S = [[0] * (N+1) for _ in range(N+1)]

for m in range(M):
  L, R = map(int, input().split())
  S[L][R] += 1
for l in range(1, N+1):
  for r in range(1, N+1):
    S[l][r] += S[l-1][r] + S[l][r-1] - S[l-1][r-1]

for i in range(Q):
  p, q = map(int, input().split())
  print(S[q][q] - S[p-1][q] - S[q][p-1] + S[p-1][p-1])

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

int main() 
{  int i,n,m,sum=0,a[100000];
   cin>>n>>m;
   for(i=0;i<m;i++)
   {
       cin>>a[i];
       sum+=a[i];
   }
   if(sum>n)
   cout<<-1;
   else
   cout<<n-sum;
	return 0;
}


Measured memory_bytes: 3680
n = int(input())
for i in range(n):
    B = 0
    C = 0
    A = [int(i) for i in input().split()]
    ans = 'YES'
    for v in A:
        if B > v and C > v:
            ans = 'NO'
            break
        elif B < v and C < v:
            if B > C:
                B = v
            else:
                C = v
        elif B < v:
            B = v
        else:
            C = v
    print(ans)





Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A , B , C;
    cin >> A >> B >> C;

    if(B >= C){
        cout << B + C << endl;
    }

    else {
        if(A >= C - B){
            cout << B + C << endl;
        }

        else {
            cout << A + B * 2 + 1 << endl;
        }

    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPR2(i, m, n) for(int i = n; i >= m; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  set<int> s;
  FOR(i, a, b + 1) {
    if(cnt < k)
      s.insert(i);
    else
      break;
    cnt++;
  }
  cnt = 0;
  REPR2(i, a, b) {
    if(cnt < k)
      s.insert(i);
    else
      break;
    cnt++;
  }
  for(auto ans : s) {
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long oo=1e9;
long long dem,denta,n,m,s,t,C[100005],kt[10005];
struct dung{
    long long v,c,f;
};
vector <dung> e;
vector <long long> a[100005];
void nhap()
{
    scanf("%lld %lld",&n,&m);
    s=0;t=n-1;
    long long x,y,z;
    for (long long i=1;i<=m;i++){
        scanf("%lld %lld %lld",&x,&y,&z);
        a[x].push_back(e.size());
        dung tam;
        tam.v=y;
        tam.c=z;
        tam.f=0;
        C[e.size()]=z;
        e.push_back(tam);
        a[y].push_back(e.size());
        tam.v=x;
        tam.c=0;
        tam.f=0;
        e.push_back(tam);
    }
}
void dfs(long long u,long long kq)
{
    kt[u]=dem;
    if (u==t){
        denta=kq;
        return;
    }
    for (long long i=0;i<a[u].size();i++){
        long long id=a[u][i];
        long long v=e[id].v;
        if (kt[v]==dem||e[id].f==e[id].c) continue;
        dfs(v,min(e[id].c-e[id].f,kq));
        if (denta>0){
            e[id].f+=denta;
            if (id%2==0) e[id+1].f-=denta;
            else e[id-1].f-=denta;
            return;
        }
    }
}
void xuli()
{
    long long res=0;
    while (1){
        dem++;denta=0;
        dfs(s,oo);
        res+=denta;
        if (denta==0) break;
    }
    printf("%lld\n",res);
}
int main()
{
    nhap();
    xuli();
}



Measured memory_bytes: 5744
<?php
$n = trim(fgets(STDIN));
$aArray = explode(" ", trim(fgets(STDIN)));
$bArray = explode(" ", trim(fgets(STDIN)));
$cArray = explode(" ", trim(fgets(STDIN)));

sort($aArray);
sort($bArray);
sort($cArray);

$sum = 0;
$pa = 0;
$pc = 0;
for($i = 0; $i < $n; $i++){
    $b = $bArray[$i];
    while($pa < $n && $aArray[$pa]<$b)$pa++;
    while($pc < $n && $cArray[$pc]<=$b)$pc++;
    $sum += $pa*($n-$pc);
}
echo $sum;


Measured memory_bytes: 29420
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = LLONG_MAX;

int main(){
  int a,b,c;

  cin>>a>>b>>c;

  if (b-a == c-b) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n;
int a[400];
long long dp[400][400];
long long sum[401];


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

	cin >> n;
	rep(i, n)cin >> a[i];

	rep(i, n)sum[i + 1] = sum[i] + a[i];

	for (int len = 2; len <= n; len++) {
		rep(i, n - len + 1) {
			auto ret = 1LL << 60;
			for (int j = 1; j < len; j++) {
				ret = min(ret, dp[i][i + j - 1] + dp[i + j][i + len - 1]);
			}
			dp[i][i + len - 1] = ret + sum[i + len] - sum[i];
		}
	}
	cout << dp[0][n - 1] << endl;



	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

vector<vector<int> > bfs(vector<vector<int> > black, int H, int W,vector<vector<int> > dist ){
    queue<tuple<int,int,int>> Q;
    tuple<int,int,int> t;
    int d;
    int x,y;
    REP(h,H)REP(w,W){
        if (black[h][w]==1)Q.push(make_tuple(h, w, 0));
    }

    while(!Q.empty()){
        t = Q.front();Q.pop();
        x = get<0>(t);y = get<1>(t);d = get<2>(t);
        if (dist[x][y] <= d)continue;
        dist[x][y] = d;
        for (int i=0;i<4;i++){
            if (0<=x+DX[i] && x+DX[i]<dist.size() && 0<=y+DY[i] && y+DY[i]<dist[0].size()){
                int d_next = d+1;
                
                if (dist[x+DX[i]][y+DY[i]]>d_next)
                    Q.push(make_tuple(x+DX[i],y+DY[i],d_next));
            }
        }
    }
    return dist;
}

void print_vector(vector<vector<int> > vector){
    for (int i = 0; i < vector.size(); i++){
        for (int j = 0; j < vector[i].size(); j++)
            cout << vector[i][j] << " ";
        cout << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W;
    cin >> H >> W;
    string S;
    vector<vector<int> > black(H, vector<int> (W, 0) );
    for (int h=0; h<H;h++){
        cin >> S;
        for (int w=0; w<W; w++){
            if (S[w]=='#'){
                black[h][w]=1;
            }
        }   
    }
    vector<vector<int> > dist(H, vector<int> (W, INTINF) );
    dist=bfs(black,H ,W, dist);
    
    int mx = 0;
    REP(h,H)REP(w,W){
        
        mx = max(dist[h][w],mx);
    }
    cout << mx << endl;
}


Measured memory_bytes: 40372
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(void){

    long long N , A , B , C , D , E;
    cin >> N >> A >> B >> C >> D >> E;

    cout << max({(N - 1) / A , (N - 1) / B , (N - 1) / C , (N - 1) / D , (N - 1) / E}) + 5 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int k;
  string s;
  cin>>k;
  cin>>s;
  if(k>=len(s)){
    cout<<s<<endl;
    return 0;
  }
  cout<<s.substr(0,k)<<"..."<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

vector<bool> ans(4, false);
int a; cin >> a;
ans[a] = true;
cin >> a;
ans[a] = true;

rep(i, 1, 4) if (!ans[i]) cout << i << endl;


}

// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){
  int a, b;

  cin >> a >> b;

  // ????????????
  int d = a / b;
  int r = a % b;
  double f = (double)a / b;

  //cout << d << " " << r << " " << f << endl;
  // cout << (a / b) << " " << (a % b) << " " << ((double)a / b) << endl;
  printf("%d %d %lf\n", d, r, f);
  
  return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

#define NMAX 500001
#define SMAX 1000000000

int L[(NMAX/2)+2],R[(NMAX/2)+2];
int c;

void merge(int A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int i,j,k;
	for (i = 0; i < n1; i++){
		L[i] = A[left + i];
	}
	for (i = 0; i < n2; i++){
		R[i] = A[mid + i];
	}
	L[n1] = SMAX;
	R[n2] = SMAX;
	i = 0;
	j = 0;
	for(k = left; k < right; k++){
		c++;
		if(L[i] <= R[j]){
      		A[k] = L[i];
      		i = i + 1;
		}
		else{
      		A[k] = R[j];
      		j = j + 1;
		}
	}
}

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

int main(void){
	int i,n,zero=0;
	int S[NMAX];
	scanf("%d" ,&n);
	for(i = 0; i < n; i++){
		scanf("%d" ,&S[i]);
	}
	mergeSort(S,n,zero,n);
	for(i = 0; i < n; i++){
		if(i < n-1){
			printf("%d ",S[i]);
		}
		else{
			printf("%d\n",S[i]);
		}
	}
	printf("%d\n",c);
	
	return 0;
}


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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	string s;
	int ans = 700;
	cin >> s;
	for (string::iterator it = s.begin(); it != s.end(); it++) {
		if (*it == 'o') {
			ans += 100;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a, b;
  int i;
  int diff[7];

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

  for (i = 0; i < 7; i++) {
    printf("%d\n", diff[i]);
  }

  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN = 100001;
typedef long long ll;
ll n, a[MAXN], s[MAXN], L, R, f[MAXN * 2 + 10], b[MAXN], c[MAXN * 2 + 10];

void add(ll x) {
	while (x <= 2 * MAXN)f[x]++, x += x & -x;
}
ll query(ll x) {
	ll tot = 0;
	while (x > 0)tot += f[x], x -= x & -x;
	return tot;
}
bool check(ll x) {
	memset(f, 0, sizeof f);
	for (ll i = 1; i <= n; i++) {
		if (a[i] >= x)c[i] = 1; else c[i] = -1;
		c[i] += c[i - 1];
	}
	ll ans = 0;
	for (ll i = 0; i <= n; i++)ans += (query(c[i] + MAXN)), add(c[i] + MAXN);
	return ans >= n * (n + 1) / 4 ? true : false;
}

int main() {
	cin >> n;
	for (ll i = 1; i <= n; i++)cin >> a[i], s[i] = a[i];
	sort(s + 1, s + n + 1);
	L = 1, R = n;
	while (L <= R) {
		ll mid = L + R >> 1;
		if (check(s[mid]))L = mid + 1; else R = mid - 1;
	}
	cout << s[R] << endl;

	return 0;
}

Measured memory_bytes: 4480
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
	string s1,s2,s3;
	cin >> s1>>s2>>s3;
	cout << (char)(s1[0]-32) << (char)(s2[0]-32) << (char)(s3[0]-32) <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	string s; cin >> s;
	if(s[0] == '9' || s[1] == '9') puts("Yes");
	else puts("No");
}


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

int main() {
  // ここにプログラムを追記
  int R, G;
  double M;
    
  cin >> R;
  cin >> G;
  
  //G = (R+M)/2
  M = G*2 - R;
  
  cout << M << endl;
}

Measured memory_bytes: 256