akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

const int INF = 1e9;
mt19937 rng(static_cast<uint32_t>(chrono::steady_clock::now().time_since_epoch().count()));

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

  #ifdef EntityIT
  freopen("input.txt", "r", stdin);
  #endif // EntityIT

  int n; cin >> n;
  vec<int, 2> child(n);
  for (int i = 1; i < n; ++i) {
    int p; cin >> p; --p;
    child[p].emplace_back(i);
  }
  vec<int, 1> x(n);
  for (auto& i : x) {
    cin >> i;
  }

  vec<int, 1> f(n);
  for (int u = n - 1; ~u; --u) {
    vec<int, 1> g(x[u] + 1, INF); g[0] = 0;
    for (auto& v : child[u]) {
      vec<int, 1> nxtG(x[u] + 1, INF);
      for (int i = 0; i <= x[u]; ++i) {
        if (i + x[v] <= x[u]) {
          asMn(nxtG[i + x[v]], g[i] + f[v]);
        }
        if (i + f[v] <= x[u]) {
          asMn(nxtG[i + f[v]], g[i] + x[v]);
        }
      }
      g.swap(nxtG);
    }
    f[u] = *min_element(all(g));
  }

  cout << (f[0] < INF ? "POSSIBLE" : "IMPOSSIBLE") << '\n';

  return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    long long cnt = 0;
    for (int i = 0; i < n; i++) {
        auto Iter1 = lower_bound(a.begin(), a.end(), b[i]);
        auto Iter2 = upper_bound(c.begin(), c.end(), b[i]);
        cnt += (Iter1 - a.begin()) * (c.end() - Iter2);
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 1408
n=int(input())
F=[input().split() for _ in range(n)]
P=[list(map(int,input().split())) for _ in range(n)]

ans=-float("inf")
for i in range(1,2**10):
    cnt=0
    num=format(i,"b").zfill(10)
    for j,k in enumerate(F):
        cnt +=P[j][len([v for v in range(10) if k[v]==num[v]=="1"])]
    ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 3064
/**Bismillahir Rahmanir Raheem
    Author:Refat(BSMRSTU)**/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const int M = 1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    ///scanf("%d",&test);
    for(int cs=1; cs<=test; cs++) {
        int n,ar[105];
        bool ck=true;
        scanf("%d",&n);
        for(int i=1; i<=n; i++) {
            scanf("%d",&ar[i]);
            if(ar[i]%3!=0&&ar[i]%5!=0&&ar[i]%2==0) {
                ck=false;
            }
        }
        if(ck) {
            printf("APPROVED\n");
        } else {
            printf("DENIED\n");
        }
    }
    return 0;
}



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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 105;

int N, M, a[MAXN][MAXN], f[MAXN][MAXN];

int main(){
	scanf("%d", &M); N = 2;
	up (i, 1, N) up (j, 1, M) scanf("%d", &a[i][j]);
	up (i, 1, N) up (j, 1, M) {
		cmax(f[i][j], f[i - 1][j] + a[i][j]);
		cmax(f[i][j], f[i][j - 1] + a[i][j]);
	}
	printf("%d\n", f[N][M]);
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,K;
  cin>>N>>K;
  vector<int>h(N);
  for(int i=0;i<N;i++)cin>>h[i];
  ll ans=0;
  for(int i=0;i<N;i++)if(K<=h[i])ans++;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
#define DEKAI 1000000007
#define INF (1<<28)
/* ┗(^o^)┛ｗｗｗｗｗ┏(^o^)┓ﾄﾞｺﾄﾞｺﾄﾞｺﾄﾞｺｗｗｗｗｗ */


signed main(){
	int n,m;
	cin>>n>>m;
	int a[1001],ans=0;
	lp(i,1001){
		a[i]=0;
	}
	lp(i,m){
		int x;
		cin>>x;
		a[x]=1;
	}
	lp(i,m){
		if(a[i+1]==0) ans++;
	}
	cout<<ans<<endl;
  	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=2e5+10;
int tt;
int head[N],to[N*2],nxt[N*2],sz[N],fa[N],g[N],k[N],v[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void dfs(int x,int f,int d) {
    sz[x]=g[x]=d,fa[x]=f;
    for(int i=head[x];i;i=nxt[i]) {
		int y=to[i];
		if(y!=f) dfs(y,x,-d),sz[x]+=sz[y];
    }
}
inline int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int main() {
    int n,m,A,B;
    long long ans=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i<=m;i++) {
		int x=gi(),y=gi();
		if(find(x)==find(y)) A=x,B=y;
		else {
			fa[find(x)]=find(y);
			to[++tt]=y,nxt[tt]=head[x],head[x]=tt;
			to[++tt]=x,nxt[tt]=head[y],head[y]=tt;
		}
    }
    dfs(1,0,1);
    if(m==n-1) {
		if(sz[1]) return puts("-1"),0;
    }
    else if(g[A]==g[B]) {
		if(sz[1]&1) return puts("-1"),0;
		int t=sz[1]/2;
		ans+=abs(t);
		for(int i=A;i;i=fa[i]) sz[i]-=t;
		for(int i=B;i;i=fa[i]) sz[i]-=t;
    }
    else {
		if(sz[1]) return puts("-1"),0;
		for(int i=A;i;i=fa[i]) ++k[i];
		for(int i=B;i;i=fa[i]) --k[i];
		int tp=1;
		for(int i=1;i<=n;i++) {
			if(k[i]==1) v[++tp]=-sz[i];
			if(k[i]==-1) v[++tp]=sz[i];
		}
		sort(v+1,v+1+tp);
		int t=v[(tp+1)/2];ans+=abs(t);
		for(int i=1;i<=n;i++) sz[i]+=k[i]*t;
    }
    for(int i=1;i<=n;i++) ans+=abs(sz[i]);
    cout<<ans;
    return 0;
}


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

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

int dfs(int x, int y, vector<vector<bool> >& canGo){
  if(!canGo[x][y]){ return 0; }

  int ans = 1;
  canGo[x][y] = false;
  for(int i = 0; i < 4; i++)
    ans += dfs(x + dx[i], y + dy[i], canGo);
  
  return ans;
}

int main(void){
  while(true){
    int w, h;
    cin >> w >> h;
    if(w == 0 && h == 0){ break; }

    char input;
    int sx, sy;
    vector<vector<bool> > canGo(h + 2, vector<bool>(w + 2, false));
    for(int i = 1; i <= h; i++){
      for(int j = 1; j <= w; j++){
        cin >> input;
        if(input == '.' || input == '@'){ canGo[i][j] = true; }
        if(input == '@'){
          sx = i;
          sy = j;
        }
      }
    }
    
    int ans = dfs(sx, sy, canGo);
    cout << ans << endl;
    
  }
  return 0;
}

Measured memory_bytes: 3076
def main():
	A, B, C = map(int, input().split())
	even_flag = True
	count = 0

	while even_flag:
		if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
			even_flag = False
			break

		elif A == B and B == C and A == C:
			break

		A, B, C = (B // 2 + C // 2), (A // 2 + C // 2), (A // 2 + B // 2)
		count += 1

	if even_flag:
		print(-1)
	else:
		print(count)
		
if __name__ == "__main__":
	main()

Measured memory_bytes: 3064
k,m=map(int,input().split())
l=[0 for i in range(k+1)]
for i in range(m):
  a,s=map(int,input().split())
  l[a-1]+=1;l[s]-=1
ans=0
f=0
for j in range(k):
  l[j]+=f
  f=l[j]
print(len([1 for i in l if i==m]))

Measured memory_bytes: 7832
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}
use std::collections::HashMap;

fn main() {
    let S = get!(String);
    let mut map: HashMap<char, u8> = HashMap::new();
    let mut c2 = ' ';
    for c in S.chars() {
        c2 = c;
        let cnt = if let Some(&cnt) = map.get(&c) {
            cnt
        } else {
            0
        };
        map.insert(c, cnt + 1);
    }
    if map.len() == 2 && map.get(&c2) == Some(&2u8) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007
 
#define SZ 100005
using namespace std;
int n;
ll fn(ll arr[], ll x)
{
    ll ret = 0;
    for(int i=1; i<=n; i++) ret += abs(arr[i]-x);
    return ret;
}
int main()
{
    cin>>n;
    ll arr[n+1];
    ll sm = 0;
    for(ll i=1; i<=n; i++)
    {
        cin>>arr[i];
        arr[i] -= i;
    }
    sort(arr+1, arr+1+n);
    int one = (n+1)/2, two;
    if(n%2 == 0) two = one + 1;
    ll ans = LLONG_MAX, a,b,c, d, e;
    if(n%2 == 0)
    {
        a = arr[one];
        b = arr[two];
        c = (arr[one] + arr[two])/2LL;
        d = c + 1;
        e = c - 1;
    }
    else
    {
        a = arr[one];
        b = c = d = e = a;
    }
    ans = min(ans, fn(arr, a));
    ans = min(ans, fn(arr, b));
    ans = min(ans, fn(arr, c));
    ans = min(ans, fn(arr, d));
    ans = min(ans, fn(arr, e));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>

int c[1005][1005];
int lcs(char *x, int m, char *y, int n){
  int i, j;
  
  for (i = 0; i <= m; i++)  c[i][0] = 0;
  for (j = 0; j <= n; j++)  c[0][j] = 0;
  
  for (i = 1; i <= m; i++) for (j = 1; j <= n; j++) {
      if (x[i-1] == y[j-1]) c[i][j] = c[i-1][j-1] + 1;
      else if (c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
      else                             c[i][j] = c[i][j-1];
    }
  return c[m][n];
}

char x[2000], y[2000];

int main(){
  int q, lox, loy;
  char *p;
  
  fgets(x, 10, stdin);
  q = atoi(x);
  while (q--) {
    fgets(p=x, 1005, stdin);
    while (*p > ' ') p++;
    *p = 0, lox = p-x;
    
    fgets(p=y, 1005, stdin);
    while (*p > ' ') p++;
    *p = 0, loy = p-y;
    
    printf("%d\n", lcs(x, lox, y, loy));
  }
  return 0;
}



Measured memory_bytes: 5624
from collections import defaultdict
N,C = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(int,input().split())) for _ in range(N)]

strange = [defaultdict(lambda:0) for _ in range(3)]
for i in range(N):
    for j in range(N):
        for color in range(C):
            strange[(i+j)%3][color] += D[c[i][j]-1][color]

ans = 1000*N**2
for c1 in range(C):
    for c2 in range(C):
        for c3 in range(C):
            if c1 != c2 and c2 != c3 and c3 != c1:
                ans = min(ans,strange[0][c1]+strange[1][c2]+strange[2][c3])
print(ans)

Measured memory_bytes: 45020
#include <stdio.h>
int main(){
  int a,b,c,t;
  scanf("%d%d%d",&a,&b,&c);
  if(c > a){
    t=a;
    a=c;
    c=t;}
  if(c > b){
    t=c;
    c=b;
    b=t;}
  if(b > a){
    t=b;
    b=a;
    a=t;}
  printf("%d %d %d\n",c,b,a);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    ll n; cin >> n;
    ll ans=0;
    for(ll i=2; i*i<=n; i++) {
        if(n%i != 0) continue;
        ll ex=0;
        while(n%i == 0) {
            ex++;
            n/=i;
        }
        ll j=1;
        while(ex>0) {
            if(ex-j >= 0) {
                ans++;
                ex -= j;
                j++;
            }
            else if(ex-j < 0) break;
        }
    }
    if(n != 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define mod 1000000007
#define PI 3.14159265358979323
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define debug(x) cout<<"Case "<<x<<": "
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	ll n,k;
	cin>>n>>k;
	bool dp[k+5]={false};
	ll a[n+5]={0};
	rep(i,n)cin>>a[i],dp[a[i]]=true;
	sort(a,a+n);
	f(i,1,k+1)
	{
		if(dp[i]==true)
			continue;
		vll v;
		rep(j,n)
		{
			if(a[j]<=i)
				v.pb(a[j]);
			else
				break;
		}
		if(sz(v)==0)
		{
			dp[i]=false;
			continue;
		}
		bool flag=false;
		rep(j,sz(v))
		{
			if(dp[i-v[j]]==false)
			{
				dp[i]=true;
				flag=true;
				break;
			}
		}
		if(!flag)
			dp[i]=false;
	}
	if(dp[k]==true)
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
	//rep(i,k+1)cout<<dp[i]<<" ";
}


Measured memory_bytes: 384
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
p = list(map(int, input().split()))
uf = UnionFind(n)
for _ in range(m):
    x, y = map(int, input().split())
    uf.union(x-1, y-1)

ans = 0

for i, p_i in enumerate(p):
    if uf.same(i, p_i-1):
        ans += 1

print(ans)


Measured memory_bytes: 13812
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll L,R;
  cin>>L>>R;
  map<int,int>mp;
  for(ll i=L;i<=min(L+2019+2018,R);i++){
    mp[i%2019]++;
  }
  int ans=INF;
  for(int i=0;i<2019;i++){
    for(int j=0;j<2019;j++){
      if(i==j){
        if(mp[i]>=2){
          ans=min(ans,i*j%2019);
        }
      }else{
        if(mp[j]>0&&mp[i]>0){
          ans=min(ans,i*j%2019);
        }
      }
    }
  }
  cout<<ans<<endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> b(n - 1);
  for(int i = 0; i < n - 1; i++){
    cin >> b[i];
  }
  long long ans = 0;
  for(int i = 0; i < n; i++){
    if(i == 0) ans += b[0];
    else if(i == n - 1) ans += b[n - 2];
    else ans += min(b[i], b[i - 1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<string,int>
using namespace std;

#define maxn 1000010
const int inf = 0x3f3f3f3f;
const int mod = 9973;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
int max(int x,int y){if(x>y) return x;return y;}
ll powmod(ll a,ll b){
    ull ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}
ll v[105],w[105];	
ll dp[maxn],n,W,ans;
main()
{
	IO;
	cin>>n>>W;
	for(ll i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	ans=0;
	ms(dp,0x3f);
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=1e5;j>=v[i];j--){
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
			if(dp[j]<=W) ans=max(ans,(ll)j);
		}
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 8064
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int x = sc.nextInt();
    	String ans = "NO";

    	if(x == 3||x==5||x==7){
    		ans = "YES";
    	}
    	// 出力
    	System.out.println(ans);
    }
}

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

int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll val[3];
    memset(val,-1,sizeof(val));

    ll n,m;cin>>n>>m;
    for(ll i=0;i<m;i++){
        ll s,c;cin>>s>>c;
        if(val[s-1]==-1)val[s-1]=c;
        else if(val[s-1]!=c)return cout<<"-1" , 0;
    }

    if(n>1 && val[0]==0)return cout<<"-1" , 0;

    for(ll i=0;i<=999;i++){
        string s=to_string(i);
        if(s.size()!=n)continue;
        bool f=1;
        for(ll j=0;j<n;j++){
            if(val[j]==-1)continue;
            f&=(s[j]==char(val[j]+'0'));
        }

        if(f)return cout<<i , 0;
    }

    cout<<"-1";
}




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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> A(30, 0);
  REP(i, 28){
    int a; cin >> a; a--;
    A[a] += 1;
  }
  REP(i, 30){
    if(A[i] == 0) cout << i+1 << endl;
  }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define Unique(v) sort(all(v));v.erase(unique(all(v)),v.end());
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define db(x) cerr << #x <<" == "<<x << endl;
#define db2(x,y) cerr<<#x <<" == "<<x<<", "<<#y<<" == "<<y<<endl;
#define db3(x,y,z) cerr << #x<<" == "<<x<<", "<<#y<<" == "<<y<<", "<<#z<<" == "<<z<<endl; 
#define prl cerr<<"called: "<< __LINE__<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


int32_t main(){
  fastio;
  int d,t,s;
  cin>>d>>t>>s;
  if(s*t>=d){
    cout <<"Yes"<<endl;
  }else cout<<"No"<<endl;
  // math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll x;
	cin>>x;
	ll balance = 100;
	int i = 0;
	while(balance<x){
		balance += balance/100;
		i++;
	}
	cout<<i<<'\n';
	return 0;
}

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

using namespace std;

long long int knapSack(long long int W, long long int wt[], long long int val[], long long int n) 
{ 
   long long int i, w; 
   long long int K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
}

int main()
{
    long long int n,W,i;
    cin>>n>>W;
    long long int wt[n+1],val[n+1];
    for(i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    cout<<knapSack(W,wt,val,n)<<endl;
    return 0;
}

Measured memory_bytes: 79104
A, B, C, K = tuple(int(c) for c in input().split(' '))

if A >= K:
    print(K)
    exit()
else:
    bc = K - A  # A < K なのでbc >= 1
    assert bc >= 1
    if B >= bc:
        print(A)
        exit()
    else:
        # B < bc
        cc = bc - B
        assert cc >= 1
        print("{:.0f}".format(A - cc))
        exit()

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}



int main()
{
    weewoo;
    ll a , b,k;
    cin >> a >> b >> k;
    ll d = max(0ll,k-a);
    ll cur=min(a,k);
    a-=cur;
    b-=min(b,d);
    cout << a << ' ' << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<stdbool.h>

int main(void){
    int x;
    int h,m,s,a,b;
    scanf("%d",&x);
    h=x/3600;
    a=x-(h*3600);
    m=a/60;
    b=x-(h*3600+m*60);
    s=b/1;
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, string t) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << t << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T & a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T & a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T> & v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

bool in(int w, int x, int r) {
	return x - r >= 0 && x + r <= w;
}

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	Yn(in(w, x, r) && in(h, y, r));
}


Measured memory_bytes: 3068
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	ll n;
	cin >> n;
	ll a[100];
	REP(i,n){
		cin >> a[i];
	}
	REPR(i,n){
		cout << a[i];
		if(i!=0){cout << " ";}
	}cout << endl;
  return 0;
}


Measured memory_bytes: 3120
void main()
{
    long n, m, q;
    rdVals(n, m, q);

    long[] a = new long[q], b = new long[q], c = new long[q], d = new long[q];
    foreach (i; 0 .. q)
    {
        rdVals(a[i], b[i], c[i], d[i]);
        --a[i], --b[i];
    }

    long result;

    void dfs(long[] arr)
    {
        if (arr.length == n)
        {
            long point;
            foreach (i; 0 .. q)
            {
                if (arr[b[i]] - arr[a[i]] == c[i])
                {
                    point += d[i];
                }
            }
            result = max(result, point);
            return;
        }
        foreach (i; arr[$-1] .. m+1)
        {
            dfs(arr ~ i);
        }
    }

    dfs([1]);

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<String, Integer> map = new TreeMap<>();
        int max = 0;
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            map.merge(s, 1, Integer::sum);
            max = Math.max(max, map.get(s));
        }
        List<Map.Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
        list.sort(Map.Entry.comparingByValue());
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getValue().equals(max)) {
                System.out.println(list.get(i).getKey());
            }
        }
    }
}

Measured memory_bytes: 86340
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

import Data.Ratio

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	head $ do
		a <- [ 1 .. 3500 ]
		b <- [ 1 .. 3500 ]
		let
			-- 4/n - 1/a - a/b
			bunbo = 4 * a * b - n * b - n * a
			bunshi = n * a * b 
		guard $ 0 < bunbo
		guard $ bunshi `mod` bunbo == 0
-- 		return $ n * a * b
		return $ printf "%d %d %d\n" a b ( bunshi `div` bunbo )

Measured memory_bytes: 892
s1 = []
s2 = []

str = gets
i = 0
sum = 0
str.chars do |c|
	if c == "\\"
		s1.push(i) 
	elsif c == "/" && s1.size > 0
		j = s1.pop
		sum += i - j
		a = i - j
		while s2.size > 0 && s2.last[:pos] > j
			st = s2.pop
			a += st[:area]
		end
		s2.push({:pos => j, :area => a})
	end
	i += 1
end

puts sum
printf("%d", s2.size)
printf(" %s", s2.map{|h|h[:area]}.join(" ")) if s2.size > 0
puts

Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;

int main(){
    int n;
    std::cin >> n;
    n--;
    std::cout << n/2 << std::endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(read())
	return v
}

func main() {
	sc.Split(bufio.ScanWords)
	count := 0
	max := 0
	S := read()

	s := make([]string, 10)
	for i, b := range S {
		s[i] = string(b)

		if s[i] == "A" || s[i] == "T" || s[i] == "C" || s[i] == "G" {
			count++
			if max < count {
				max = count
			}
			// fmt.Println(s[i])
		} else {
			count = 0
		}

	}
	fmt.Println(max)
}


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

int n;
vector<long long> a, b;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	readVector(n, a);
	readVector(n, b);
	long long cnt = 0;
	for(int i=0; i<n-1; ++i){
/*		long long mi = min(a[i], b[i]);
		a[i] -= mi;
		b[i] -= mi;
		long long t = max(0ll, (b[i] - a[i] + 1) / 2);
		a[i] += 2 * t;
		b[i+1] += t;
		t = max(0ll, a[i] - b[i]);
		b[i] += t;
		a[i+1] += 2*t;
*/		long long d = b[i] - a[i];
		if(d > 0){
			cnt += (d + 1) / 2;
			d -= (d + 1) / 2 * 2;
		}
		if(d < 0){
			cnt += d;
		}
	}
	if(cnt > 0) b[n-1] += cnt;
	else b[n-1] += 2 * cnt;
	cout << (a[n-1] <= b[n-1] ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 512
A,B,H,M=$stdin.read.chomp.split(" ").map(&:to_i)

a_kakudo = (360/12 * (H + (M/60.0)))
b_kakudo = (360/60 * M)
kakudo = (a_kakudo - b_kakudo).abs
puts Math.sqrt(A**2 + B**2 - 2 * A * B * Math.cos(kakudo * Math::PI / 180))


Measured memory_bytes: 14724
package main

import (
	"fmt"
)

func main() {
	var a string
	fmt.Scan(&a)

	ans := ""
	if a == "A" {
		ans = "T"
	} else if a == "C" {
		ans = "G"
	} else if a == "G" {
		ans = "C"
	} else if a == "T" {
		ans = "A"
	}
	fmt.Printf("%s\n", ans)
}


Measured memory_bytes: 512
N = int(input())
c = list(input())
color = [i == 'R' for i in c]
ans = 0
checked = 0
for right in range(N - 1, -1, -1):
    if color[right]:
        for left in range(checked, right):            
            if not color[left]:
                color[right], color[left] = color[left], color[right]
                ans += 1
                checked = left
                break
        checked = left
print(ans)                

Measured memory_bytes: 12340
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 #include <iomanip>
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

vector<int> nxt[222222];

void solve(istream& cin, ostream& cout) {
	int n,m;
	cin >> n>>m;
	vector<int> H(n);
	cin >>H;
	REP(i, m) {
		int u,v;
		cin>>u>>v;
		u--;v--;
		nxt[u].pb(v);
		nxt[v].pb(u);
	}
	int ans = 0;
	REP(u, n) {
		bool good = true;
		for(int v : nxt[u]) {
			if(H[u] <= H[v])
				good = false;
		}
		if(good) ans++;
	}
	cout <<ans<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 11272
a = [int(input())for _ in range(6)]
print(
    max(
        (a[0] + a[1] - 1) // a[1]
        , (a[0] + a[2] - 1) // a[2]
        , (a[0] + a[3] - 1) // a[3]
        , (a[0] + a[4] - 1) // a[4]
        , (a[0] + a[5] - 1) // a[5]
    ) + 4
)


Measured memory_bytes: 3064
//it was hard to write
//so it should be hard to read
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define last(x) (x).size() - 1
#define mp make_pair

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef double ld;

const int MAXN = 1e5 + 5;
const ll INF = 1e18 + 7;
const int inf = 1e9 + 7;
const double EPS = 1e-9;

int n, a[105];

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int mn = inf;
    for (int x = -100; x <= 100; x++) {
        int resx = 0;
        for (int i = 1; i <= n; i++) {
            resx += pow((a[i] - x), 2);
        }
        mn = min(mn, resx);
    }
    cout << mn;
    return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> a(100);
  
  for (int i=0;i<H;i++) {
    cin >> a.at(i);
  }
  
  for (int i=0;i<W+2;i++) {
    cout << '#';
  }
  cout << endl;
  
  for (int i=0;i<H;i++) {
    cout << "#" << a.at(i) << "#" << endl;
  }
  
  for (int i=0;i<W+2;i++) {
    cout << '#';
  }
  cout << endl;
}


Measured memory_bytes: 3600
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N, K = (int(_) for _ in input().split())
    A = list(int(_) for _ in input().split())
    
    print(math.ceil((N-1)/(K-1)))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 14504
#include<bits/stdc++.h>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define pb(i) push_back(i)
#define mk(x,y) make_pair(x,y)
#define F first
#define S second
#define accu(i) fixed<<setprecision(i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
using namespace std;


int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
    multiset<ll,greater<ll> > s;
    ll n,m,a,sum=0;cin>>n>>m;
    while(n--){
    	cin>>a;s.insert(a);
	}
    while(m--){
    	ll t = *s.begin();s.erase(s.begin());
    	t=t/2;s.insert(t);
	}
	while(!s.empty()){
		sum+=*s.begin();s.erase(s.begin());
	}
	cout<<sum<<"\n";
	return 0;
}

Measured memory_bytes: 4992
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod;
    } 
    return res%mod; 
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int a;
    string s;
    cin>>a>>s;
    if(a < 3200) {
        cout<<"red\n";
    }
    else
        cout<<s<<"\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define MOD 1000000000000000000

LL gcd(LL a, LL b){
	LL tmp;
	while (b != 0) {
	       tmp = a;
	       a = b;
	       b = tmp % b;
	   }
	return a;
}

// LL lcm(LL a, LL b){
// 	LL ans=((a)*(b))/gcd(a,b);
// 	return ans;
// }

int main() {
	int n;
	cin>>n;
	LL t[109];
	for(int i=0;i<n;i++){
		cin>>t[i];
	}
	LL ans=1;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			LL x= gcd(t[i],t[j]);
			if(x>1){
				ans=ans*x;
				for(int k=0;k<n;k++){
					LL y=gcd(t[k],x);
					if(y>1){
						t[k]=t[k]/y;
					}
				}
			}
		}
	}
	
	// lcm using gcd
	// LL ans = t[0];
	// for(int i=1;i<n;i++){
	// 	ans= lcm(ans,t[i]);
	// }
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
a = int(input())
while True:
    if (a == 2):
        break
    if (a % 2 != 0):
        for i in range(3, int(a ** 0.5 + 1), 2):
            if a % i == 0:
                a += 1
                break
        else:
                break
    else:
        a += 1
        continue
print(a)

Measured memory_bytes: 3060
#include "iostream"

using namespace std;

int nes(int n, int w[10000], int m ) {
	int ne = 1;
	int x = 0;

	for (int i = 0; i < n; i++) {
		if( x+w[i] <= m ) x += w[i];
		else {
			ne++;
			x = w[i];
		}
	}
	return ne;
}

int main() {

	int n, k;
	int w[100000], max;

	cin >> n;
	cin >> k;
	max = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		if (w[i] > max) max = w[i];
	}

	int head, mid, tail;

	head = max;
	tail = max * n / k + 1;
	mid = (head + tail) / 2;
	int ne;
	while(tail - head > 0 ) {

		mid = (head + tail) / 2;
		ne = nes(n, w, mid);
		if (ne <= k) tail = mid;
		else head = mid+1;

	}/*
	do {
		mid--;
		ne = nes(n, w, mid);
	} while (ne <= k && mid >= max);
	*/
	cout << tail << endl;

	return 0;
}

Measured memory_bytes: 1552
<?php

$A = trim(fgets(STDIN));
$B = trim(fgets(STDIN));
$C = trim(fgets(STDIN));
$D = trim(fgets(STDIN));

$total = 0;

if ($A > $B)
{
    $total += $B;
}
else
{
    $total += $A;
}

if ($C > $D)
{
    $total += $D;
}
else
{
    $total += $C;
}


echo $total . "\n";


Measured memory_bytes: 3828
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
string s;

while(n){
    if(n % 26){
    s = s +char((ll)('a')  - 1 + n % 26);
    n /= 26;
    }
    else{
        s = s + 'z';
        n = n / 26 - 1;
    }
}
reverse(s.begin(),s.end());
cout << s << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <numeric>
#include <set>
#include <cmath>
using namespace std;
#define ll long long

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    ll n, a, b;
    cin >> n >> a >> b;
    if (b < a || (n == 1 && b != a)){
        cout << 0;
        return 0;
    }
    if (b == a || n == 2){
        cout << 1;
        return 0;
    }
    ll midNums = n - 2;
    ll dist = b - a;
    ll ans = 1 + midNums * dist;
    cout << ans;
}


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

const int MAXN = 3e5+10;
const ll inf = 0x3f3f3f3f3f3f3f3f;
ll a[MAXN], b[MAXN], c[MAXN];

int main(void){
    int n;
    ll cnt1=inf, cnt2=-inf, ans1=0, ans2=0, ans=-inf;
    scanf("%d", &n);
    for(int i=1; i<=3*n; i++){
        scanf("%lld", &a[i]);
    }
    priority_queue<ll, vector<ll>, greater<ll> > q1;
    for(int i=1; i<=2*n; i++){
        if(i <= n){
            q1.push(a[i]);
            ans1 += a[i];
            b[i] = ans1;
            continue;
        }
        ll cnt = q1.top();
        if(cnt < a[i]){
            q1.pop();
            q1.push(a[i]);
            ans1 -= cnt;
            ans1 += a[i];
        }
        b[i] = ans1;
    }
    priority_queue<ll, vector<ll>, less<ll> > q2;
    for(int i=3*n; i>n; i--){
        if(i > 2*n){
            q2.push(a[i]);
            ans2 += a[i];
            c[i] = ans2;
            continue;
        }
        ll cnt = q2.top();
        if(cnt > a[i]){
            q2.pop();
            q2.push(a[i]);
            ans2 -= cnt;
            ans2 += a[i];
        }
        c[i] = ans2;
    }
    for(int i=n; i<=2*n; i++){
        ans = max(ans, b[i]-c[i+1]);
    }
    cout << ans << endl;
    return 0;
}

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

using uli = unsigned long int;
using lli = long long int;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define repa(a,i,x) for(int i=a;i<=x;i++)

int main(){
	int N;
	cin >> N;
	
	int A[N];
	rep(i,N-1)cin>>A[i];
	
	int ans[N];
	rep(i,N)ans[i]=0;
	rep(i,N-1)ans[A[i]-1]++;
	
	rep(i,N)cout << ans[i] << endl;
	
}

Measured memory_bytes: 5204
#include <iostream>
using namespace std;
int main(){
  int K,S;
  cin >> K >> S;
  int res=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) res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256