akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, x, y;
	cin >> n >> x >> y;
	//print(n)
	ll dst[n+1][n+1];
	rep(i, 1, n){
		rep(j, 1, n){
			dst[i][j] = abs(i-j);
		}
	}
	
	rep(i, 1, n){
		rep(j, 1, n){
			dst[i][j] = min(dst[i][j], dst[i][x]+1+dst[y][j]);
			dst[i][j] = min(dst[i][j], dst[i][y]+1+dst[x][j]);
		}
	}
	
	ll ans[n+1];
	memset(ans, 0, sizeof(ans));
	rep(i, 0, n){
		rep(j, 1, i-1){
			ans[dst[i][j]]++;
		}
	}
	//print(n)
	rep(i, 1, n-1){
		print(ans[i])	
	}
	return 0;
}

Measured memory_bytes: 31616
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)/n
x=sum(a)//n
ans=0
if((ave-x)<=0.5):
  for i in a:
    ans += (i-x)**2
  print(ans)
else:
  for i in a:
    ans+=(i-x-1)**2
  print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
  
int main(void) {
  int age, price;
  
  cin >> age;
  cin >> price;
  
  if(13 <= age) {
    //no operation.
  } else if(6 <= age & 12 >= age ) {
    price = price / 2;
  } else {
    price = 0;
  }
  
  cout << price << "\n";
  
  return 0;
}

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


int main() {
    int N,K;
    cin>>N>>K;
    if(2*K-1<=N){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    
    
    
    
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var R int

	fmt.Scan(&R)

	if R < 1200 {
		fmt.Println("ABC")
	} else if R < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N;
  cin >> N;
  vector<ll> A(N, 0);
  rep(i, N) cin >> A[i];
  ll high = A[0], ans = 0;
  rep(i, N){
    ans += max(high - A[i], 0LL);
    chmax(high, A[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4792
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
using namespace std;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=1e5+5,Mo=1e9+7;

void inc(int &x,int y) {x=x+y>=Mo?x+y-Mo:x+y;}

int n,m,x[N],y[N],b[N],f[N],o;
vector< pair<int,int> > p;

int tr[N];
void I(int x,int y) {for(;x<=o;x+=x&-x) inc(tr[x],y);}
int Q(int x) {int r=0;for(;x;x-=x&-x) inc(r,tr[x]);return r;}

int main() {
	n=read();m=read();
	fo(i,1,n) x[i]=read();
	fo(i,1,m) y[i]=read();
	int j=0;
	fo(i,1,n) {
		while (j<m&&y[j+1]<x[i]) j++;
		if (j>0&&j<m) p.pb(mp(x[i]-y[j],y[j+1]-x[i]));
	}
	sort(p.begin(),p.end());
	int sz=unique(p.begin(),p.end())-p.begin();
	for(int i=0;i<sz;i++) b[++o]=p[i].second;
	sort(b+1,b+o+1);o=unique(b+1,b+o+1)-b-1;
	for(int i=0;i<sz;i++) p[i].second=lower_bound(b+1,b+o+1,p[i].second)-b;
	for(int l=0,r;l<sz;l=r+1) {
		for(r=l;r+1<sz&&p[r+1].first==p[l].first;r++);
		fo(i,l,r) f[i]=(Q(p[i].second-1)+1)%Mo;
		fo(i,l,r) I(p[i].second,f[i]);
	}
	int ans=1;
	for(int i=0;i<sz;i++) inc(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2804
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int R, C, N;
vector<pii> segs[4];

int get_id(int x, int y) {
    if(x == 0) return 1;
    if(x == R) return 2;
    if(y == 0) return 3;
    if(y == C) return 4;
    return 0;
}

void add_point(int x, int y, int idx) {
    int id = get_id(x, y); id--;
    if(id == 0 || id == 1) {
        // y
        segs[id].push_back(make_pair(y, idx));
    }
    else {
        // x
        segs[id].push_back(make_pair(x, idx));
    }
}
 
signed main() {
    cin >> R >> C >> N;
    rep(i,0,N) {
        int xl, yl, xr, yr; cin >> xl >> yl >> xr >> yr;

        int id_l = get_id(xl, yl);
        int id_r = get_id(xr, yr);

        if(id_l && id_r) {
            add_point(xl, yl, i);
            add_point(xr, yr, i);
        }
    }

    sort(segs[0].begin(), segs[0].end());
    sort(segs[1].begin(), segs[1].end(), greater<pii>());
    sort(segs[2].begin(), segs[2].end(), greater<pii>());
    sort(segs[3].begin(), segs[3].end());

    stack<int> S;
    int func[] = {0, 3, 1, 2};
    rep(i,0,4) rep(k,0,segs[ func[i] ].size()) {
        pii elem = segs[ func[i] ][k];
        int id = elem.second;
        if(!S.empty() && S.top() == id) S.pop();
        else S.push(id);
    }

    if(S.size()) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

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

    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    }else if(s=="Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    int min = a + b;
    if (min > (a + c)) min = a + c;
    if (min > (b + c)) min = b + c;
    
    cout << min << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;

#define INF 1000000010

int main(){
	int n, q;
	char qtype[16] = "";
	int x;
	
	scanf("%d%d", &n, &q);
	vector<int> s0(n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &s0[i]);
	}
	vector<int> s = s0;
	sort(s.begin(), s.end());

	map<int,int> lds;
	map<int,int>::iterator it;
	while(q--){
		scanf("%s%d", qtype, &x);

		if(qtype[0] == 'A'){
			++lds[s0[x - 1]];
		}
		else if(qtype[0] == 'R'){
			it = lds.find(s0[x - 1]);
			if(it == lds.end())throw 0;
			if(!--it->second){
				lds.erase(it);
			}
		}
		else{
			int left = 0, right = INF + 3;
			while(left < right){
				int r = (left + right) >> 1;
				
				int c = n;
				int p = INT_MIN;
				
				for(it = lds.begin(); it != lds.end(); ++it){
					int lim = max(p, it->first - r);
					c -= upper_bound(s.begin(), s.end(), it->first) -
						 lower_bound(s.begin(), s.end(), lim);
					p = it->first + 1;
				}
				
				if(c > x){
					left = r + 1;
				}
				else{
					right = r;
				}
			}
			
			printf(left > INF ? "NA\n" : "%d\n", left);
		}
	}
}

Measured memory_bytes: 8856
#include <stdio.h>
#include <string.h>
#include <deque>
#include <iostream>
using namespace std;
int main()
{
	deque<int> d;
	int n;
	int a;
	int flag = 0;
	cin >> n;
	while (cin >> a)
	{
		if (n % 2 == 0)
		{
			if (flag % 2 == 0) d.push_back(a);
			else d.push_front(a);
		}
		else
		{
			if (flag % 2 == 0) d.push_front(a);
			else d.push_back(a);
		}
		++flag;
	}
	auto it = d.begin();
	while (it != d.end())
	{
		cout << *it << " ";
		++it;
	}
}

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

int main(){
    int H,W;
    cin >> H >> W;
    
    //フィールドとキュー
    vector<vector<char>> nurinuri(H,vector<char>(W));
    vector<vector<int>> step(H,vector<int>(W,-1));
    queue<pair<int,int>> que;
    
    //入力
    rep(i,H){
        rep(j,W){
            cin >> nurinuri[i][j];
            if(nurinuri[i][j] == '#'){
                que.push(pair(i,j));
                step[i][j] = 0;
            }
        }
    }
    
    vector<int> shui={-1,0,1};
    int ans=0;
    while(!que.empty()){
        auto q = que.front(); que.pop();
        int x=q.first, y=q.second;
        
        for(int i:shui){
            for(int j:shui){
                if(i*j != 0) continue;
                if(x+i<0 || x+i>=H || y+j<0 || y+j>=W) continue;
                if(step[x+i][y+j] != -1) continue;
                //if(nurinuri[x+i][y+j] == '#') continue;
                
                step[x+i][y+j] = step[x][y] + 1;
                ans = max(ans, step[x+i][y+j]);
                que.push(pair(x+i,y+j));
                
            }
        }
    }
    
    cout << ans << endl;
    
    /*
    rep(i,H){
        rep(j,W){
            cout << step[i][j] << " ";
            
        }
        cout << endl;
    }
    */
    
}


Measured memory_bytes: 16216
A, B, K = map(int,input().split())

def calc(a, b):
    if a %  2 != 0:
        a -= 1
    a //= 2
    b += a
    return a, b


for i in range(K):
    if i % 2 == 0:
        A, B = calc(A, B)
    else:
        B, A = calc(B, A)

print(A, B)




Measured memory_bytes: 3064
N = int(input())
S = list(input())
R = []
G = []
B = []

cnt = 0

for i in range(N):
  if S[i] == "R":
    R.append(i)
  elif S[i] == "G":
    G.append(i)
  else:
    B.append(i)

B = set(B)
b = len(B)  

for i in R:
  for j in G:
    check = 0
    m = min(i, j)
    M = max(i, j)
    r = M - m
    left = m - r
    right = M + r
    if r % 2 == 0:
      center = m + r//2
      if center in B:
        check += 1
    if left in B:
      check += 1
    if right in B:
      check += 1
    cnt += b - check

print(cnt)

Measured memory_bytes: 68804
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = 0;
        for (long m = 1; m * m < n; m++) {
            if ((n - m) % m == 0) {
                if ((n - m) == 1) {
                    continue;
                }
                long tmp = (n - m) / m;
                if (tmp > m) {
                    ans += tmp;
                }

            }
        }
        System.out.println((ans));
        sc.close();
    }
}

Measured memory_bytes: 21716
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sortBy)
import Data.Function (on)

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  xls <- sequence . replicate n $ unsafeListToTuple . map unsafeSignedDecimal . T.words <$> T.getLine :: IO [(Int, Int)]
  let
    lrs :: [(Int, Int)]
    lrs = sortBy (compare `on` snd) . map bound $ xls
    step :: (Int, Int) -> (Int, Int) -> (Int, Int)
    step acc@(s, r0) (l, r) | r0 <= l   = (succ s, r)
                            | otherwise = acc
  print . fst . foldl step (0, -(10 ^ 9)) $ lrs

bound :: (Int, Int) -> (Int, Int)
bound (x, l) = (x - l, x + l)

unsafeListToTuple :: [Int] -> (Int, Int)
unsafeListToTuple (x : y : _) = (x, y)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 54652
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	int N;
	cin >> N;
	vector<vector<int>> tree(N);
	rep(i, N-1){
		int a,b; cin >> a >> b; a--, b--;
		tree[a].emplace_back(b);
		tree[b].emplace_back(a);
	}

	vector<int> color(N, 3);
	color[0] = 0;
	int red = 1, black = 0;
	auto paint = [&](auto&& dfs, int v) -> void {
		for(auto& nxt : tree[v]){
			if(color[nxt] != 3) continue;

			color[nxt] = color[v] ^ 1;
			if(color[nxt] == 0) red++;
			else black++; 

			dfs(dfs, nxt);
		}
		return;
	};

	auto ans = [&](int r0, int r1, int r2){
		for(int i = 0; i < N; i++){
			if(color[i] == 0 && r1 <= N) {
				cout << r1 << " ";
				r1 += 3;
			}
			else if(color[i] == 1 && r2 <= N) {
				cout << r2 << " ";
				r2 += 3;
			} else {
				if(r0 <= N){
					cout << r0 << " ";
					r0 += 3;
				} else {
					if(r1 % 3 == 0) {
						cout << r1 << " ";
						r1 += 3;
					} else {
						cout << r2 << " ";
						r2 += 3;
					}
				}
			}
		}
		cout << endl;
	};	

	paint(paint, 0);
	if(red <= N/3) ans(1, 3, 2);
	else if(black <= N/3) ans(2, 1, 3);
	else ans(3, 1, 2);
}


Measured memory_bytes: 14336
using static System.Console;
using System.Linq;
class A
{
    static public void Main()
    {
        var p=ReadLine().Split(' ').Select(e=>int.Parse(e)).ToList();
        var L=Enumerable.Repeat(0, p[0]).Select(_=>int.Parse(ReadLine())).OrderBy(e=>e).ToList();
        WriteLine(L.Zip(L.Skip(p[1]-1),(a,b)=>b-a).Min());
    }
}


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

typedef long long ll;
typedef unsigned long long llu;

int main(int argc, char *argv[]) {
  ll n, z, w;
  cin >> n >> z >> w;

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }

  if (n == 1) {
    cout << abs(a[0] - w) << endl;
    return 0;
  }

  ll c1 = abs(a[n-2] - a[n-1]);
  ll c2 = abs(a[n-1] - w);
  
  cout << max(c1, c2) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    ll N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];

    vector<ll> nums(3, 0);
    ll total = 1;
    rep(i, 0, N)
    {
        ll cnt = 0;
        rep(j, 0, 3)
            if (nums[j] == A[i]) ++cnt;
        total *= cnt;
        total %= MOD;
        rep(j, 0, 3)
            if (nums[j] == A[i])
            {
                ++nums[j];
                break;
            }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val L = nextDouble()
    val s = L / 3
    val ans = (s * s * s).toDouble()
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun nextLong() = java.lang.Long.parseLong(next())
fun nextLong(offset: Long = 0L) = nextLong() + offset
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }
fun listOfLong(offset: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + offset }
fun listOfDouble() = listOfString().map { it.toDouble() }


Measured memory_bytes: 31488
#include<cstdio>
#define N 100001
int a[N],i,j,k,m,n;long long b[N],x;
int main()
{
	for(scanf("%d%d",&n,&m),i=1;i<=n;i++)scanf("%d%lld",a+i,b+i);
	for(k=0;k<n&&a[k+1]<=m;k++);
	for(i=1,j=n;i<=k&&k<j;)
	if(b[i]<b[j])for(x+=a[j]-a[i];i<=k&&b[i]<b[j];b[j]+=b[i++]);
	else for(x+=a[j]-a[i];k<j&&b[j]<=b[i];b[i]+=b[j--]);
	return 0*printf("%lld\n",x+(i<=k?m-a[i]:a[j]-m));
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

int N;
int X, Y;
llvec v[3000];

/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  cin >> N >> X >> Y;
  llvec dist(N+1, 0);
  for(ll i=1;i<=N;i++){
    for(ll j=i+1;j<=N;j++){
      ll tmp = j - i;
      tmp = min(tmp, abs(X - i) + abs(Y - j) + 1);
      dist[tmp]++;
    }
  }

  for(int i = 1; i < N;i++){
    cout << dist[i] << endl;
  }
  return 0;
}


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

using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,m,l;
    cin >>n>>m>>l;

    if(n+m+l<=21){
        flag=true;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag)cout << "win" <<endl;
    else cout << "bust" <<endl;
    
    return 0;
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


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

    char c;
    cin >> c;

    if ('a' <= c && c <= 'z') cout << "a" << endl;
    else cout << "A" << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << (v.size() == n ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<vi> as(n, vi(m));
	trav(v, as) trav(x, v) cin >> x, --x;
	vector<bool> alive(m, 1);
	int ans = n;
	rep(_,0,m){
		vi cnt(m);
		rep(i,0,n){
			rep(j,0,m) if(alive[as[i][j]]){
				++cnt[as[i][j]];
				break;
			}
		}
		pii mx(-1,0);
		rep(i,0,m) mx = max(mx, {cnt[i], i});
		ans = min(ans, mx.first);
		alive[mx.second] = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#define INF 1e+9
using namespace std;

int main(){
	int n,s[15],d[15],v[15];
	int prev[1 << 15][15];
	double cost[1 << 15][15];
	cin >> n;
	for(int i = 0;i < n;i++) cin >> s[i] >> d[i] >> v[i];
	for(int i = 0;i < 1 << n;i++) for(int j = 0;j < n;j++){
		cost[i][j] = INF;
		prev[i][j] = -1;
	}
	for(int i = 0;i < n;i++){
		cost[1 << i][i] = 0;
	}
	for(int i = 0;i < 1 << n;i++){
		for(int j = 0;j < n;j++){
			if(i >> j & 1){
				int w = -v[j];
				for(int k = 0;k < n;k++){
					if(i >> k & 1) w += v[k];
				}
				for(int k = 0;k < n;k++){
					if(cost[i][j] > cost[i & ~(1 << j)][k] + (double)abs(d[j] - d[k]) * (70.0 + (double)w) / 2000.0){
						cost[i][j] = cost[i & ~(1 << j)][k] + (double)abs(d[j] - d[k]) * (70.0 + (double)w) / 2000.0;
						prev[i][j] = k;
					}
				}
			}
		}
	}
	int route[15],S = (1 << n) - 1,p;
	double mi = INF;
	for(int i = 0;i < n;i++){
		if(cost[S][i] < mi) {
			mi = cost[S][i];
			p = i;
		}
	}
	route[0] = p;
	for(int i = 1;i < n;i++){
		route[i] = prev[S][p];
		S = S & ~(1 << p);
		p = route[i];
	}
	for(int i = n - 1;i >= 0;i--){
		cout << s[route[i]];
		if(i != 0) cout << " ";
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 8720
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

#define o(x) cout << x << '\n'
#define o2(x, y) cout << x << ' ' << y << '\n'
#define on() cout << '\n'
#define os(x) cout << x << ' '

#define i(x) cin >> x
#define i2(x, y) cin >> x >> y

#define DBG = 1

using ll = long long;


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

    int N, W;
    i2(N, W);

    vector<ll> prev_dp(W + 1, 0);
    vector<ll> dp(W + 1, 0);

    for (int i = 0; i < N; ++i) {
        int w, v;
        i2(w, v);

        for (int cw = w; cw <= W; ++cw) {
            dp[cw] = max(prev_dp[cw], v + prev_dp[cw - w]);
        }

        prev_dp = dp;
    }

    o(dp[W]);

    return 0;
}

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

vector<int>x={1,0,-1,0},y={0,-1,0,1};

void solve(vector<string>&s,vector<vector<bool>>&v,int i,int j){
	if(s.at(i).at(j)=='#'){
		for(int k=0;k<4;++k){
			int X=j+x.at(k),Y=i+y.at(k);
			if(X>=0&&X<s.at(i).size()&&Y>=0&&Y<s.size()){
				if(s.at(Y).at(X)=='#'){
					v.at(i).at(j)=true;
				}
			}
		}
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int h,w; cin>>h>>w;
	vector<string>s(h); for(auto&i:s)cin>>i;
	vector<vector<bool>>v(h,vector<bool>(w,false));
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			solve(s,v,i,j);
		}
	}
	string ans="Yes"s;
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			if(s.at(i).at(j)=='#'&&v.at(i).at(j)==false){
				ans="No"s;
			}
		}
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
import scala.io.Source

object Main{
  def main(args: Array[String]){
    var list = List[String]()
    for(in <- Source.stdin.getLines.toList){
      list = in :: list
    }

    var count = 0
    for(in <- 1 to list.length){
      val num = list(list.length - in).split(" ").map(_.toInt)

      for(i <- 1 to num(0)){
        for(j <- i+1 to num(0)){
         for(k <- j+1 to num(0)){
           if(i + j + k == num(1)){
              //println(i + " " + j  +" " + k)
              count += 1
            }
          }
        }
      }

      if(num(0) > 0){
        println(count)
        count = 0
      }
    }
  }
}

Measured memory_bytes: 46760
h,w,m=list(map(int,input().split()))
s=[]
t=[]

for i in range(m):
  H,W=list(map(int,input().split()))
  s.append(H)
  t.append(W)
  
from collections import Counter
u=Counter(s)
v=Counter(t)
max_u=max(u.values())
max_u_set = set([kv[0] for kv in u.items() if kv[1]==max_u])
max_v=max(v.values())
max_v_set = set([kv[0] for kv in v.items() if kv[1]==max_v])
check=len(max_u_set)*len(max_v_set)

ans=0
for i in range(m):
  if u[s[i]]==max_u and v[t[i]]==max_v:
    ans=ans+1

if check-ans==0:
  print(max_u+max_v-1)
else:
  print(max_u+max_v)
    

Measured memory_bytes: 79808
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
using namespace std;
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }

bool solve(int n, int m, int q, const vector<int> & a) {
    // make the final sequence
    vector<int> used(m);
    vector<int> b;
    REP_R (i, q) {
        if (not used[a[i]]) {
            used[a[i]] = true;
            b.push_back(a[i]);
        }
    }
    REP (i, m) {
        if (not used[i]) {
            b.push_back(i);
        }
    }

    // remove the tail
    int r = m - 1;
    while (r - 1 >= 0 and b[r - 1] < b[r]) {
        -- r;
    }
    if (r == 0) return true;

    // count queries
    vector<int> next(m, m);
    REP (i, r) {
        next[b[i]] = (i + 1 < r ? b[i + 1] : m);
    }
    vector<int> cnt(m + 1);
    cnt[b[0]] = n;
    REP_R (i, q) {
        if (cnt[a[i]]) {
            -- cnt[a[i]];
            ++ cnt[next[a[i]]];
        }
    }
    return cnt[m] == n;
}

int main() {
    int n, m; cin >> n >> m;
    int q; cin >> q;
    vector<int> a(q);
    REP (i, q) {
        cin >> a[i];
        -- a[i];
    }
    cout << (solve(n, m, q, a) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int n;
set<string> S;
void rec (int i, string s) {
    if (s.size() == n) {
        S.insert (s);
        return;
    }
    rep (j, 0, i + 2) {
        s += ('a' + j);
        // cout << s << "\n";
        rec (max (i, j), s);
        s.erase (s.size() - 1);
    }
}
int main() {
    string s = "a";
    cin >> n;
    rec (0, s);
    for (auto p : S) {
        cout << p << "\n";
    }
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
ll MOD = 1000000007;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main()
{   
    int n,m; cin >> n >> m;
    map<int,int> a;
    rep(i,n){
        int k; cin >> k;
        rep(j,k){
            int b; cin >> b;
            a[b]++;
        }
    }
    int ans = 0;
    for(auto res:a){
        if(res.second == n)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;
template<class T> inline bool Cmin(T &x,T y) {return x>y?x=y,1:0;}
typedef long long ll;
const ll INF=1e18;
const int maxN=1e5+50;
int N;
int A[maxN];
ll sum[maxN];
int main() {
	scanf("%d",&N);
	for(int i=0;i<=N;++i) scanf("%d",&A[i]);
	for(int i=N;i>=0;--i) sum[i]=sum[i+1]+A[i];
	ll an=0,now=1;
	for(int i=0;i<=N;++i) {
		if(now<A[i]) {
			puts("-1"); return 0;
		}
		an+=now;
		now-=A[i];
		now<<=1;
		Cmin(now,sum[i+1]);
	}
	printf("%lld\n",an);
	return 0;
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define inf 1000000007
#define N 1000005
using namespace std;

int n, a[N], dp[N];

int f(int x){
	if(dp[x] != -1)
		return dp[x];
	if(x > n)
		return inf;
	if(x == n)
		return 0;
	return dp[x] = min(abs(a[x + 2] - a[x]) + f(x + 2), abs(a[x + 1] - a[x]) + f(x + 1));
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	memset(dp, -1, sizeof dp);
	scanf("%d",&n);
	for(int i = 1; i <= n; i++)
		scanf("%d",a + i);
	printf("%d\n", f(1));
	return 0;
}

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

int main()
{
char a[110000];
//memset(b,0,sizeof(b));

scanf("%s",a);
int p=strlen(a);
/*for(int i=1;i<p-1;i++)
{
   b[a[i]-'a']++;
}*/
if(a[0]==a[p-1])
{
    if(p%2!=0)
    {
        printf("Second\n");
    }
    else
    {
         printf("First\n");
    }
}
else
{
      if(p%2==0)
    {
        printf("Second\n");
    }
    else
    {
         printf("First\n");
    }
}

   return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define l(i,a,b) for(ll i=a;i<b;i++)
int main(){
	char lam;
	scanf("%c",&lam);
	if(lam>=65 && lam<=90) printf("A\n");
	else printf("a\n");
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  while(s.size()>4){
    if(s.substr(0,5)=="esare"){
      s=s.substr(5);
    }
    else if(s.substr(0,5)=="maerd"){
      s=s.substr(5);
    }
    else if(s.substr(0,6)=="resare"){
      s=s.substr(6);
 
    }
    else if(s.substr(0,7)=="remaerd"){
      s=s.substr(7);
 
    }
    else break;
  }
  if(s.size()==0){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int X, Y, Z, K;
int A[1010], B[1010], C[1010];

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

    cin >> X >> Y >> Z >> K;
    REP (i, X) cin >> A[i];
    REP (i, Y) cin >> B[i];
    REP (i, Z) cin >> C[i];
    vector<int> AB;
    REP (i, X) REP (j, Y) AB.push_back(A[i] + B[j]);
    sort(AB.rbegin(), AB.rend());
    vector<int> ABC;
    REP (i, min((int)AB.size(), K)) REP (j, Z) {
        ABC.push_back(AB[i] + C[j]);
    }
    sort(ABC.rbegin(), ABC.rend());
    REP (i, K) cout << ABC[i] << endl;
}

Measured memory_bytes: 42980
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



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

stack<char> c;
for(char k : s)
{
    if(k=='B'&&!c.empty())
        c.pop();
    else if(k!='B')
        c.push(k);
}
string ans ="";

while(!c.empty())
{
    ans+=c.top();
    c.pop();
}
reverse(ans.begin(),ans.end());
cout<<ans<<endl;
 return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll h, n, a, tmp;

    cin >> h >> n;
    a = 0;
    for(ll i = 0; i < n; i++) {
        cin >> tmp;
        a += tmp;
    }
    if(h > a) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _006_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            string ps = Read();
            string ss = Read();
            for(int i = 0; i < n; i++)
            {
                bool canMake = true;
                for (int j = 0; j < n - i; j++)
                {
                    if (ps[i + j] != ss[j])
                    {
                        canMake = false;
                        break;
                    }
                }
                if (canMake)
                {
                    Console.WriteLine(i + n);
                    return;
                }
            }
            Console.WriteLine(n * 2);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cassert>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;
string digit[9][7]={
  "#######",
  "#.....#",
  "#...|.#",
  "#.....#",
  "#...|.#",
  "#..-..#",
  "#######",
  "#######",
  "#..-..#",
  "#...|.#",
  "#..-..#",
  "#.|...#",
  "#..-..#",
  "#######",
  "#######",
  "#..-..#",
  "#...|.#",
  "#..-..#",
  "#...|.#",
  "#..-..#",
  "#######",
  "#######",
  "#.....#",
  "#.|.|.#",
  "#..-..#",
  "#...|.#",
  "#.....#",
  "#######",
  "#######",
  "#..-..#",
  "#.|...#",
  "#..-..#",
  "#...|.#",
  "#..-..#",
  "#######",
  "#######",
  "#..-..#",
  "#.|...#",
  "#..-..#",
  "#.|.|.#",
  "#..-..#",
  "#######",
  "#######",
  "#..-..#",
  "#...|.#",
  "#.....#",
  "#...|.#",
  "#.....#",
  "#######",
  "#######",
  "#..-..#",
  "#.|.|.#",
  "#..-..#",
  "#.|.|.#",
  "#..-..#",
  "#######",
  "#######",
  "#..-..#",
  "#.|.|.#",
  "#..-..#",
  "#...|.#",
  "#..-..#",
  "#######"
};

vector<string> rotate(vector<string> in){
  int r=in.size(),c=in[0].size();
  vector<string> ret(r,string(c,' '));
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      ret[i][j]=in[c-j-1][i];
      if (ret[i][j] == '-')ret[i][j]='|';
      else if (ret[i][j] == '|')ret[i][j]='-';
    }
  }
  return ret;
}

vector<string> lrReverse(vector<string> in){
  int r=in.size(),c=in[0].size();
  for(int i=0;i<r;i++){
    for(int j=0;j<c/2;j++){
      swap(in[i][j],in[i][c-1-j]);
    }
  }
  return in;
}

vector<string> udReverse(vector<string> in){
  int r=in.size(),c=in[0].size();
  for(int j=0;j<c;j++){
    for(int i=0;i<r/2;i++){
      swap(in[i][j],in[r-1-i][j]);
    }
  }
  return in;
}

vector<string> getcube(string *in,int y,int x){
  vector<string> ret;
  for(int i=0;i<7;i++){
    string tmp = in[y+i].substr(x,7);
    ret.push_back(tmp);
  }
  return ret;
}

int getdata(vector<string> &in,int pos){
  for(int i=0;i<9;i++){
    vector<string> tmp;
    for(int j=0;j<7;j++)tmp.push_back(digit[i][j]);
    if (pos == 1){
      tmp=rotate(tmp);
    }else if (pos == 3){
      for(int i=0;i<3;i++)tmp=rotate(tmp);
    }else if (pos == 5){
      tmp=udReverse(tmp);
    }
    tmp=lrReverse(tmp);
    if (tmp == in)return i+1;
  }
  assert(false);
}

main(){
  const int py[3]={0,7,14};
  const int px[3][4]={
    {7,-1,-1,-1},
    {0,7,14,21},
    {7,-1,-1,-1}
  };
  const int p[3]={1,4,1};
  string in[21];
  while(cin>>in[0]){
    if (in[0] == "0")break;
    for(int i=1;i<21;i++)cin>>in[i];
    vector<int> d[2];
    for(int l=0;l<2;l++){
      int basex=l*29;
      int cnt=0;
      for(int i=0;i<3;i++){
	for(int j=0;j<p[i];j++){
	  vector<string> tmp = getcube(in,py[i],basex+px[i][j]);
	  d[l].push_back(getdata(tmp,cnt++));
	}
      }
    }
    assert(d[0] != d[1]);
    int high=0,low=0;
    for(int i=0;i<6;i++){
      for(int j=0;j<6;j++){
	if (d[0][i] > d[1][j])high++;
	else if (d[0][i] < d[1][j])low++;
      }
    }
    cout << (high>=low?"HIGH":"LOW") << endl;
  }
  return false;
}

Measured memory_bytes: 912
#coding:utf-8
import sys
n, m = map(int, input().split())
a = list(map(int, input().split()))
vote = sum(a)
rank = sorted(a, reverse=True)
border = vote / (4*m)
#print(border, rank)
count = 0

for i in range(0, n):
    if rank[i] >= border:
        count += 1

    if count == m:
        print('Yes')
        sys.exit()

print('No')


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

int main(){
    int k,s; cin >> k >> s;
    int cnt=0;
    for(int x=0;x<=k;++x){
        for(int y=0;y<=k;++y){
            int z= s-x-y;
            if(z >=0 && z <=k) ++cnt;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a,b,sum=0;
   cin>>a>>b;
   int ar[a+5];
   for(int i=0;i<a;i++)
   {
       cin>>ar[i];
   }
   sort(ar,ar+a);
   for(int i=0;i<b;i++)
   {
       sum+=ar[i];
   }
   cout<<sum;

}


Measured memory_bytes: 3636
n = gets.to_i
h = gets.chomp.split(" ").map(&:to_i)
pre_h = h[n-1]
(n-2).downto(0) do |i|
  h[i] -= 1 if pre_h < h[i]
  if pre_h < h[i]
    puts "No"
    exit
  end
  pre_h = h[i]
end
puts "Yes"

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

using namespace std;

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

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = acos(-1.0); //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    ll n;
    cin >> n;
    if (n == 3) {
        cout << "2 5 63" << endl;
        return 0;
    } else if (n == 4) {
        cout << "2 5 20 63" << endl;
        return 0;
    } else if (n == 5) {
        cout << "2 3 4 6 9" << endl;
        return 0;
    }

    set<ll> st;
    ll six;

    repll2(i, 30000) {
        if (i % 2 == 0 || i % 3 == 0) st.insert(i);
        if (i % 2 == 0 && i % 3 == 0) six = i;
        if (st.size() == n) break;
    }

    auto itr = st.begin();
    ll sum = 0;

    repll(i, n) {       
        sum += *itr;
        itr++;
    }

    if (sum % 6 == 2) {
        st.erase(8);
        st.insert(six + 6);
    } else if (sum % 6 == 3) {
        st.erase(9);
        st.insert(six + 6);
    } else if (sum % 6 == 5) {
        st.erase(9);
        st.insert(six + 4);
    }

    itr = st.begin();

    rep(i, st.size()) {
        cout << *itr << ((i != st.size() - 1) ? " " : "\n");
        itr++;
    }

    return 0;
}


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

public class Main {
	static class P implements Comparable<P>{
		int idx;
		long val;
		public P(int i , long v) {
			idx = i;
			val = v;
		}
		@Override
		public int compareTo(P o) {
			return Long.compare(o.val, val);
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		P A[] = new P[N];
		for(int i = 0 ; i < N ; ++i){
			long a = sc.nextLong();
			A[i] = new P(i , a);
		}
		Arrays.sort(A);
		long dp[] = new long[N + 1];
		Arrays.fill(dp, -1);
		dp[0] = 0;
		for(int i = 0 ; i < N ; ++i){
			P p = A[i];
			long next[] = new long[N + 1];
			Arrays.fill(next, -1);
			for(int l = 0 ; l <= i ; ++l){
				if(dp[l] < 0){
					continue;
				}
				int r = i - l;
				long lv = p.val * Math.abs(p.idx - l);
				long rv = p.val * Math.abs(N - 1 - r - p.idx);
				next[l] = Math.max(dp[l] + rv, next[l]);
				next[l + 1] = Math.max(next[l + 1] , dp[l] + lv);
			}
			dp = next;
//			System.out.println(Arrays.toString(dp));
		}
		long ret = 0;
		for(long d : dp){
			ret = Math.max(d, ret);
		}
		System.out.println(ret);
	}
}


Measured memory_bytes: 54808
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

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

  bool ok = true;
  rep(i, n) {
    int a = vec[i];
    if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0) {
      ok = false;
      break;
    }
  }

  string ans = ok ? "APPROVED" : "DENIED";
  cout << ans << endl;
}


Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline

import math
from collections import defaultdict,deque
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""
n=ii()
d=defaultdict(int)
for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            w=i*i+j*j+k*k+i*j+i*k+j*k
            d[w]+=1
for i in range(1,n+1):
    print(d[i])

Measured memory_bytes: 79524
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	string s;
	int K;
	cin>>s>>K;
	int ssize=s.size();
	set<string>strset;
	for(int i=1;i<=K;++i){
		for(int j=0;j<=ssize-i;++j){
			string sub=s.substr(j,i);
			strset.insert(sub);
		}
	}
	auto itr=strset.begin();
	for(int i=0;i<K-1;++i)++itr;
	cout<<*itr<<"\n";
	return 0;
}

Measured memory_bytes: 1664
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------

        string s, t;
        cin >> s >> t;
        // 塊として等しいことが必要。
        // ただし、文字のペアは一つだけ。(map[s[i]] = t[i]で管理)
        map<char, char> mp_s;
        map<char, char> mp_tt;
        for(int i=0; i<s.length(); i++){
            mp_s[s[i]] = '0';
            mp_tt[t[i]] = '0';
        }

        int flag = 0;
        for(int i=0; i<s.length(); i++){
            /*if(s[i] != s[i+1] && t[i] == t[i+1]){
                flag = 1;
            }
            else if(s[i] == s[i+1] && t[i] != t[i+1]){
                flag = 1;
            }
*/
            // ただし、文字のペアは一つだけ。(map[s[i]] = t[i]で管理)
            if(mp_s[s[i]] == '0'){
                mp_s[s[i]] = t[i];
            }
            else if(mp_s[s[i]] != t[i]){
                flag = 1;
            }

            if(mp_tt[t[i]] == '0'){
                mp_tt[t[i]] = s[i];
            }
            else if(mp_tt[t[i]] != s[i]){
                flag = 1;
            }
        }

        if(flag == 0) cout << "Yes";
        else cout << "No";

    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 916
#include <stdio.h>

int main(void) {
    int a, b, answer;
    char op;
    
    while (1) {
        scanf("%d %c %d" , &a, &op, &b);
        
        if (op == '+') answer = a + b;
        else if (op == '-') answer = a - b;
        else if (op == '*') answer = a * b;
        else if (op == '/') answer = a / b;
        else break;

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

    return 0;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n;
  cin >> n;
  if(n == 3){
    cout << "2 5 63\n";
    return 0;
  }
  int sum = 0;
  for(int i = 1; n; i++){
    if(i % 2 == 0 || i % 3 == 0){
      if(n == 1 && (sum + i) % 6)continue;
      if(n == 2 && ((sum + i) % 6 == 1 || (sum + i) % 6 == 5))
        continue;
      sum += i;
      n--;
      cout << i << " ";
    }
  }
  cout << "\n";
//   if(n <= 4){
//     else{
//       cout << "2 5 20 63\n";
//     }
//   }else{
//     cout << "2 2 2 3 3 ";
//     R(i,n-5){
//       cout << "6 ";
//     }
//     cout << "\n";
//   }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll D, N;
    cin >> D >> N;
    
    if(N == 100){
        N++;
    }
    cout << ll(pow(100,D)*N) << endl;
    return 0;
}

Measured memory_bytes: 3780