akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1000000000
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct edge{
	int from, to, cost;
};

const int MAX_V = 1000;

// bool used[MAX_V];
int d[MAX_V];
int r, V, E;
vector<edge> G;


int main(void){
	cin >> V >> E >> r;
	for(int i = 0; i < E; i++){
		int s, t, d; cin >> s >> t >> d;
		edge e = {s, t, d};
		G.push_back(e);
	}

	fill(d, d+V, INF);
	d[r] = 0;

	bool updated = true;
	for(int i = 0; i < V and updated; i++){
		updated = false;
		for(auto e: G){
			if(d[e.from] < INF and d[e.to] > d[e.from] + e.cost){
				updated = true;
				d[e.to] = d[e.from] + e.cost;
				if(i == V-1){
					cout << "NEGATIVE CYCLE" << '\n';
					return 0;
				}
			}
		}
	}

	for(int i = 0; i < V; i++){
		if(d[i] == INF) cout << "INF" << '\n';
		else cout << d[i] << '\n';
	}

	return 0;
}



Measured memory_bytes: 3172
n=int(input())
a=list(map(int,input().split()))
total=0
for i in range(n-1):
  total+=abs(a[i+1]-a[i])
total+=(abs(a[0])+abs(a[n-1]))
for i in range(n):
  if i==0:
    print(total-abs(a[1]-a[0])-abs(a[0])+abs(a[1]))
  elif i!=n-1:
    print(total-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1]))
  else:
    print(total-abs(a[n-1]-a[n-2])-abs(a[n-1])+abs(a[n-2]))

Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string n;
  cin >> n;
  if((n[0] == n[1] && n[1] < n[2]) || (n[0] < n[1])) n[0]++;
  cout << (n[0]-'0')*111 << newl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int calculate(int a, int b, char op)
{
    int n;
    if (op == '+')
    {
        n = a + b;
    }
    else if (op == '-')
    {
        n = a - b;
    }
    else if (op == '*')
    {
        n = a * b;
    }
    else if (op == '/')
    {
        n = a / b;
    }
    return n;
}
int main(void)
{
    while (1)
    {
        int a, b, op;
        scanf("%d %c %d", &a, &op, &b);

        if (op == '?')
        {
            break;
        }
        printf("%d\n", calculate(a, b, op));
    }
    return 0;
}


Measured memory_bytes: 2704
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
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; }

typedef struct {
    int to;
    ll cost;
} edge;

int main() {
    int N;
    scanf("%d", &N);
    vector<edge> tree[N];
    rep(i, N-1){
        int a,b,c;
        scanf("%d%d%d", &a, &b, &c);
        a--; b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }
    int Q, K;
    scanf("%d%d", &Q, &K);
    K--;
    stack<edge> s;
    s.push({K, 0});
    ll depth[N];
    rep(i, N) depth[i] = -1;
    while(!s.empty()){
        edge from = s.top();
        s.pop();
        depth[from.to] = (ll)from.cost;
        for(auto &to : tree[from.to]){
            if(depth[to.to] == -1) s.push({to.to, to.cost + from.cost});
        }
    }
    rep(i, Q){
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << depth[x] + depth[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 10736
#include <iostream>
#include <algorithm>
#define INF 10000000000

using namespace std;
int main(void){
    int N;
    cin>>N;
    int P[N+1]; P[0]=0;
    for(int i=1;i<=N;i++){
        cin>>P[i];
    }
    int ans=0;
    for(int i=1;i<N;i++){
        if(i==P[i]){swap(P[i],P[i+1]); ans++;}
    }
    if(N==P[N]){ans++;}
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
  
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int L = sc.nextInt();
    
    int ans;
    if (L > 0) {
      ans = sum(2, N, L);
    } else if (L+N-1 < 0) {
      ans = sum(1, N-1, L);
    } else {
      ans = sum(1, N, L);
    }
    
    System.out.println(ans);
  }
  
  private static int sum(int start, int end, int L) {
    int ret = 0;
    for (int i = start; i <= end; i++) {
      ret += L+i-1;
    }
    return ret;
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    string ans="No";
    ll N;
    cin >> N;
    int n=0;
    rep(i,N) {
        int d,e;
        cin >> d >> e;
        if (d == e)
            ++n;
        else
            n = 0;
        if (n >= 3) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}


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

typedef long long STATES;

int main( void )
{
	STATES free_days[31], dp[51];
	STATES goal_state, next;
	register int i, j;
	int n, answer, free_day, k;

	while ( scanf( "%d", &n ) == 1 && n )
	{
		memset( free_days, 0, sizeof(STATES)*31 );
		memset( dp, 0, sizeof(STATES)*n );

		goal_state = 0;
		for ( i = 0; i < n; i++ ) goal_state |= 1LL << i;

		for ( i = 0; i < n; i++ )
		{
			scanf( "%d", &k );
			for ( j = 0; j < k; j++ )
			{
				scanf( "%d", &free_day );
				free_days[free_day] |= 1LL << i;
			}
		}

		answer = -1;
		for ( i = 0; i < n; i++ ) dp[i] = 1LL << i;
		for ( i = 1; answer == -1 && i <= 30; i++ )
		{
			next = 0;
			for ( j = 0; j < n; j++ ) if ( free_days[i] & ( 1LL << j ) ) next |= dp[j];
			for ( j = 0; j < n; j++ ) if ( free_days[i] & ( 1LL << j ) ) dp[j] |= next;
			if ( next == goal_state ) answer = i;
		}

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

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    int n,k,d,x;
    cin >> n >> k;
    map<int,int> mp;
    rep(i,k){
        cin >> d;
        rep(i,d){
            cin >> x;
            mp[x]++;
        }
    }
    
    cout << n-mp.size() << endl;

    return 0;
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
/*                   وتزودوا فإن خير الزاد التقوى                    */
/*       وما تدري نفس ماذا تکسب غدا وما تدري نفس باي ارض تموت      */
#include <bits/stdc++.h>
#include<unordered_set>
using namespace std;
#define endl '\n'
#define ll long long
#define PI acos(-1)
#define watch(x) cerr<<#x<<" = { "<<x<<" }\n"
#define sz(n) n.size()
#define Mo7med_Sayed fast();
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define RT(v) return cout<<v,0;
const double EPS = (1e-7);
const ll OO = INT_MAX, mod = 1e9 + 7;
void run() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
#endif
}
void fast() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); }
ll n, m, k, t;
vector<ll>v;
int dp[100005];
int solve(int x) {
	if (x < 0)return 1;
	int& ret = dp[x];
	if (~ret)return ret;
	ret = 0;
	for (int i = 0; i < n; i++) {
		ret |= (solve(x - v[i]) ^ 1);
	}
	return ret;
}

int main()
{
	//run();
	Mo7med_Sayed;

	cin >> n >> m;
	string ar[] = { "Second","First" };
	v.resize(n);
	memset(dp, -1, sizeof dp);
	for (int i = 0; i < n; i++)cin >> v[i];
	for (int i = 0; i < v[0]; i++)dp[i] = 0;
	cout << ar[solve(m)] << "\n";

}



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

using namespace std;

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

const ll max_n = 52;
const ll max_s = 2500;
vector<ll> c, d;
vector<pl3> g[max_n];

ll n, m;
ll s;

const ll INF = 1e15;
ll dp[max_n+1][max_s + 1];

void dijkstra(){
	s = min(s, max_s);
	rep(i, n) rep(j, max_s + 1) dp[i][j] = INF;
	dp[0][s] = 0;

	priority_queue<pl3,vector<pl3>,greater<pl3> > que;
	que.push({0, {0, s}});

	while(!que.empty()){
		pl3 p = que.top();
		que.pop();

		ll time = p.first;
		ll v = p.second.first;
		ll ns = p.second.second;

		if(dp[v][ns] < time) continue; //後から最短パスが見つかった場合、先にqueに入っているものはここではじかれる

		if(ns + c[v] <= max_s && dp[v][ns + c[v]] > time + d[v]){
			dp[v][ns + c[v]] = time + d[v];
			que.push({time + d[v], {v, ns + c[v]}});
		}

		for(pl3 x : g[v]){
			ll w = x.first;
			ll a = x.second.first;
			ll b = x.second.second;

			if(ns < a || dp[w][ns - a] <= time + b) continue;
			dp[w][ns - a] = time + b;
			que.push({time + b, {w, ns - a}});
		}
	}
}

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

	cin >> n >> m >> s;
	rep(i, m){
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		g[u].push_back({v, {a, b}});
		g[v].push_back({u, {a, b}});
	}

	c.resize(n);
	d.resize(n);
	rep(i, n) cin >> c[i] >> d[i];

	dijkstra();

	rep(i, n-1){
		ll ans = INF;
		rep(j, max_s + 1) ans = min(ans, dp[i+1][j]);
		cout << ans << "\n";
	}
}


Measured memory_bytes: 7360
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,ans=0;
lol s[511100]={};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol c,d=0,e=0,f=0,g=0,h=0;
  string w;
  cin >>w;
  for(int n=0;n<w.size();n++){
      if(w[n]=='<'){
	  s[n+1]=max(s[n+1],s[n]+1);
      }
  }
  for(int m=w.size()-1;m>=0;m--){
      if(w[m]=='>'){
	  s[m]=max(s[m],s[m+1]+1);
      }
  }
  f=0;
  for(int n=0;n<=w.size();n++) f+=s[n];
  cout <<f<<'\n';
  return (0);
}


Measured memory_bytes: 4764
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  
  if (N == 1 || N % 2 != 0) {
    cout << "No"; return 0; 
  }
  
  int len = N / 2;
  for (int i = 0; i < len; i++) {
    if(S[i] != S[i+len]) {
      cout << "No"; return 0; 
    }
  }
  cout << "Yes";
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int n,m,a[N],par[N],ans;

int find(int x){
	if (x==par[x]){
		return x;
	}
	return par[x]=find(par[x]);
}

void merge(int x, int y){
	x=find(x);
	y=find(y);
	par[x]=y;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (int i=1;i<=n;i++){
		cin >> a[i];
		par[i]=i;
	}
	int x,y;
	while (m--){
		cin >> x >> y;
		merge(x,y);
	}
	for (int i=1;i<=n;i++){
		ans+=find(a[i])==find(i);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int a,b,k,i,p=0;
    scanf("%d %d %d",&k,&a,&b);
    for(i=a;i<=b;i++){
   if(i%k==0){
    printf("OK\n");
    p++;
    break;
    }
    }
    if(p==0){
        printf("NG\n");
    }



   return 0;

}


Measured memory_bytes: 1624
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static int getInt(){
		return Integer.parseInt(s.next());
	}
	static IntStream REPS(int l) {
		return IntStream.range(0,l);
	}
	public static void main(String[]__){
		int n=getInt(),m=getInt(),t=getInt(),ar[]=new int[t];
		
		for(int i=0;i<n;i++) {
			int in=getInt();
			ar[in-m]++;
			if(in+m<t)
				ar[in+m]--;
		}
		Arrays.parallelPrefix(ar,Integer::sum);
		System.out.println(Arrays.stream(ar).filter(i->i==0).count());
	}
}

Measured memory_bytes: 33728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mypow(ll x, ll y)
{
    ll ret = 1;
    rep(i, y)
    {
        ret *= x;
    }
    return ret;
}

signed main()
{
    int n, p;
    cin >> n >> p;
    vi cnt(2);
    rep(i, n)
    {
        int a;
        cin >> a;
        if (a % 2 == 0)
        {
            cnt[0]++;
        }
        else
        {
            cnt[1]++;
        }
    }
    ll ans = 0;
    if (cnt[1] == 0)
    {
        if (p == 1)
        {
            cout << 0 << endl;
        }
        else
        {
            printf("%lld\n", mypow(2, n));
        }
    }
    else
    {
        printf("%lld\n", mypow(2, n - 1));
    }
    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#define ll long long
#define MAXN 2005
using namespace std;
ll a[MAXN];
ll sabs(ll x) {
    if(x < 0) return -x;
    else return x;
}
int main() {
    ll n, z, w;
    cin >> n >> z >> w;
    
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    if(n == 1) {
        cout << sabs(w-a[1]);
        return 0;
    }else {
        if(sabs(a[n]-a[n-1]) > sabs(a[n] - w))
            cout << abs(a[n]-a[n-1]) << "\n";
        else
            cout << abs(a[n] - w) << "\n";
    }
    return 0;
}

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

int main() {

  int N ;
  cin >> N;
  if (N%10 == 2 ||N%10 == 4 || N%10 == 5 || N%10 == 7 || N%10 == 9)   {
    cout << "hon" << endl;
  }
  if (N%10 == 0 ||N%10 == 1 || N%10 == 6 || N%10 == 8 )   {
    cout << "pon" << endl;
  }
  if (N%10 == 3)  {
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3560
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+10;
int n, a[N];
vector<pii> s;

int chk(int x) {
	s.clear();
	s.pb(pii(1,a[1]));
	REP(i,2,n) {
		if (a[i]>a[i-1]) { 
			s.pb(pii(1,a[i]-a[i-1]));
			continue;
		}
		int len = a[i-1]-a[i];
		while (len) {
			if (s.back().y<=len) len-=s.back().y,s.pop_back();
			else {
				s.back().y -= len;
				if (!s.back().y) s.pop_back();
				break;
			}
		}
		while (s.size()>1) {
			pii u = s.back(), v = s[s.size()-2];
			if (u.x==v.x) {
				s.pop_back();
				s.back().y += u.y;
			}
			else break;
		}
		if (s.back().x==x) {
			if (s.size()==1) return 0;
			else {
				pii u = s.back();
				s.pop_back();
				int t = s.back().x;
				if (!--s.back().y) s.pop_back();
				s.pb(pii(t+1,1));
				s.pb(pii(1,u.y));
			}
		}
		else {
			int t = s.back().x;
			if (!--s.back().y) s.pop_back();
			s.pb(pii(t+1,1));
		}
	}
	return 1;
}

int main() {
	scanf("%d", &n);
	REP(i,1,n) scanf("%d",a+i);
	int l=1,r=n,ans;
	while (l<=r) {
		if (chk(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3188
n = int(input())
count = 0
recount = -1
h = list(map(int,input().split()))
for i in range(n-1):
    if h[i] >= h[i + 1]:
        count += 1
    else:
        recount = max(recount,count)
        count = 0
print(max(recount,count))


Measured memory_bytes: 14252
//Created by Aminul on 9/19/2020.

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        int n = in.nextInt();
        int x[] = new int[n], y[] = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = in.nextInt();
            y[i] = in.nextInt();
        }

        boolean flag = false;
        for (int i = 2; i < n; i++) {
            flag |= (x[i] == y[i] && x[i - 1] == y[i - 1] && x[i - 2] == y[i - 2]);
        }

        pw.println(flag ? "Yes" : "No");


        pw.close();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}

Measured memory_bytes: 36128
import java.util.Scanner;

public  class Main{

  public static void main(String[] args) {

    try ( Scanner sin = new Scanner(System.in) ){

      StringBuilder str = new StringBuilder();
      int h = sin.nextInt();
      int w = sin.nextInt();

      while(true){
        if( h == 0 )
          if( w == 0 )
            break;

        for( int j = 1; j <= w; j++)
          str.append("#");
        for( int i = 1; i <= h; i++)
          System.out.println(str);
        System.out.println();

        str.setLength(0);
        h = sin.nextInt();
        w = sin.nextInt();
      }
    }
  }
}


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

#define sd(mark) scanf("%d",&mark)
#define s2d(mark,marx) scanf("%d%d",&mark,&marx)
#define s3d(mark,marx,marz) scanf("%d%d%d",&mark,&marx,&marz)
#define sf(mark) scanf("%f",&mark)
#define slf(mark) scanf("%lf",&mark)
#define sst(mark) scanf("%s",&mark)
#define sld(mark) scanf("%lld",&mark)
#define s2ld(mark,marx) scanf("%lld%lld",&mark,&marx)
#define s3ld(mark,marx,marz) scanf("%lld%lld%lld",&mark,&marx,&marz)
#define sline(mline) scanf("%[^\n]%*c",&mline)

#define pi(n) printf("%d\n",n)
#define pf(n) printf("%f\n",n)
#define plf(n) printf("%lf\n",n)
#define pst(n) printf("%s\n",n)
#define pl(n) printf("%lld\n",n)

#define pis(n) printf("%d ",n)
#define pfs(n) printf("%f ",n)
#define plfs(n) printf("%lf ",n)
#define pss(n) printf("%s ",n)
#define pls(n) printf("%lld ",n)

#define sff fflush(stdout)
#define decimal(n) cout.precision(n)
#define fix cout<<fixed
#define debug(mark) printf("check%d\n",mark)
#define in(a) cin>>a
#define out(a) cout<<a<<'\n'
#define clr(mark) memset(mark,0,sizeof(mark))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ll long long int
#define mod 1000000007ll
#define llu unsigned long long int
#define endl '\n'
#define INF 1123456789
#define eps 1e-9
#define fo(i,a,b) for(int i=a;i<b;++i)
#define foll(i,a,b) for(ll i=a;i<b;++i)
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)

#define UL 100000		//5
#define MAXN 1000000	//6
#define MAXL 10000000	//7

typedef vector< vector<int> > vvi;
typedef vector< vector<ll> > vvl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< pair<ll,ll> > vll;
typedef pair<char,char> pcc;
typedef vector< pair<int, int> > vii;


// bool mark[MAXN+5];

// int sieve()
// {
// 	int ULL = MAXN;
// 	for(int i=0;i<=ULL;i++) mark[i]=true;
// 	for(int i=2;i*i<=ULL;i++) if(mark[i]) for(int j=i*i;j<=ULL;j+=i) mark[j]=false;
// 	for(int i=2;i<=ULL;i++) if(mark[i]) p.pb(i);
// 	return p.size();
// }

ll gcd(ll a, ll b) {if(!b) return a; return gcd(b,a%b);}

ll modexp(ll a,ll b, ll m)
{
	if(b==0) return 1;
	if(b==1) return a%m;
	ll temp = modexp(a,(b>>1),m);
	temp = (temp*temp)%m;
	return (temp*modexp(a,b&1,m))%m;
}

ll modinv(ll a, ll p)
{
	return modexp(a,p-2,p);
}

int main()
{
	int k; sd(k);
	int ans = (k/2)*((k+1)/2);
	pi(ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int64_t Lo = 2,Li = 1;
    int n;
    cin >> n;
    int64_t L = 3;
    if(n>=3){
        for(int i=3;i<=n;i++){
            Lo = Li;
            Li = L; 
            L = Li + Lo;   
        }
    }
    if(n==1){
        cout << 1 << endl;
    }else if(n==2){
        cout << 3 << endl;
    }else{
        cout << L << endl;
    }
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{    
            
    class Program
    {

        static int[] omori;

        static List<int> Weight(int obj)
        {

            var list = new List<int>();

            while (true)
            {

                
                for (int i = 0; i < 11; i++)
                {
                    if(obj - omori[i] < 0)
                    {
                        obj -= omori[i - 1];
                        list.Add(omori[i - 1]);
                        break;
                    }
                }

                if(obj == 0)
                {
                    break;
                }

            }            

            return list;

        }



        
        static void Main(string[] args)
        {

            omori = new int[11];  
            var resutl = new List<int>();

            for(int i = 0; i < 11; i++)
            {
                omori[i] = (int)Math.Pow(2, i);
            }

            while (true)
            {
                string str = Console.ReadLine();

                if (string.IsNullOrEmpty(str))
                {
                    break;
                }

                int obj = int.Parse(str);

                var ans = Weight(obj);

                for(int i = ans.Count - 1; i >= 0; i--)
                {
                    if(i == 0)
                    {
                        Console.WriteLine(ans[i]);
                    }
                    else
                    {
                        Console.Write($"{ans[i]} ");
                    }
                }

            }

        }
    }
}



Measured memory_bytes: 16024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int[] city = new int[num + 1];
        int[] brave = new int[num];
        for (int i = 0; i <= num; i++) {
            city[i] = Integer.parseInt(in.next());
        }
        for (int i = 0; i < num; i++) {
            brave[i] = Integer.parseInt(in.next());
        }
        long total = 0;
        int capa = 0;
        int capb = city[0];
        for (int i = 0; i < num; i++) {
            capa = capb;
            capb = city[i + 1];
            if (brave[i] <= capa) {
                total += brave[i];
                continue;
            } else {
                total += capa;
                int diff = brave[i] - capa;
                if (diff <= capb) {
                    capb -= diff;
                    total += diff;
                } else {
                    total += capb;
                    capb = 0;
                }
            }
        }
        System.out.println(total);
    }
}


Measured memory_bytes: 49972
import java.util.Scanner;

public class Main {
    public static void main(String...args){
        Scanner sc= new Scanner(System.in);
        int A= sc.nextInt();
        int B= sc.nextInt();
        int C= sc.nextInt();
        int BJ= A+B+C;
        if(BJ<=21){
            System.out.println("win");
        }
        else{
            System.out.println("bust");
        }
    }
}


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

int main() {
  int N, M; cin >> N >> M;
  int res[M];
  for (int i = 0; i < M; i++) {
    res[i] = 0;
  }
  
  for (int i = 0; i < N; i++) {
    int K; cin >> K;
    for (int j = 0; j < K; j++) {
      int x; cin >> x; x--; res[x]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (res[i] == N) {ans++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

	vector<int> Ai(N, 0);
	map<ll, ll> v_map;

	int t;
	rep(i, N)
	{
		cin >> t;
		Ai.at(i) = t;
		v_map[t]++;
	}
	
	ll all = 0;
	for (auto it : v_map)
	{
		all += (it.second) * (it.second - 1) / 2;
	}

	ll ans;
	int before, after, val;
	for (int i = 0; i < N; ++i)
	{
		val = v_map[Ai[i]];
		before = val * (val - 1) / 2;
		after = (val -1) * (val - 2) / 2;

		ans = all - before + after;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 11980
import itertools
N,M = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
note = []
for x,y,z in info:
    X = [x,-x]; Y = [y,-y]; Z = [z,-z]
    tmp = []
    for c in itertools.product(X,Y,Z):
        tmp.append(sum(c))
    note.append(tmp)

ans = -float('inf')
for j in range(8):
    res = []
    for i in range(N):
        res.append(note[i][j])
    res = sorted(res,reverse=True)
    value = sum(res[:M])
    if value > ans:
        ans = value
print(ans)

Measured memory_bytes: 3700
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define FOR(i,a,b) for(int i=(a), i##_len=(b);i< i##_len; ++i)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N;

int prime[300005];
bool is_prime[300015];

int sieve(int n)
{
    int p = 0;
    REP(i, n) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; ++i)
    {
        if (is_prime[i])
        {
            prime[p++] = i;
            for (int j = 2*i; j <= n; j+=i) is_prime[j] = false;
        }
    }
    return p;
}

signed main()
{
    cin >> N;
    sieve(300000);

    int index = 0;
    REP(i, N)
    {
        if (i != 0) cout << " ";
        while (prime[index] % 5 != 1) ++index;
        cout << prime[index];
        ++index;
    }
    cout << endl;

    return 0;
}

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

int main()
{
	int N; cin >> N;
	vector<int>p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}

	int ans = 0;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (p[i] == i + 1) {
			cnt++;
		}
		else {
			ans += ceil(cnt / 2.);
			cnt = 0;
		}
	}
	ans += ceil(cnt / 2.);

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p;

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

int main()
{
  ll N,M;
  cin >> N >> M;
  if(N==M){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

const int MAX_N=1000000;

int n;
ll a[MAX_N];
ll st[2*MAX_N-1];

void init(int _n){
    n=1;
    while(n<_n){
        n*=2;
    }
    for(int i=0;i<_n;i++) st[i+n-1]=a[i];
}

void update(int i,ll x){
    i+=n-1;
    st[i]=x;
    while(i>0){
        i=(i-1)/2;
        st[i]=__gcd(st[2*i+1],st[2*i+2]);
    }
}

ll gcd(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return 0;
    if(a<=l&&r<=b) return st[k];
    int m=(l+r)/2;
    ll u=gcd(a,b,2*k+1,l,m);
    ll v=gcd(a,b,2*k+2,m,r);
    return __gcd(u,v);
}

int main(){
    int N;
    cin>>N;
    rep(i,N) cin>>a[i];
    init(N);
    priority_queue<ll> que;
    rep(i,N){
        update(i,a[i]);
    }
    rep(i,N){
        update(i,0);
        que.push(gcd(0,N,0,0,N));
        update(i,a[i]);
    }
    cout<<que.top()<<endl;
}

Measured memory_bytes: 7032
N,M=gets.split.map(&:to_i)

was = Array.new(N+1,0)

ac = wa = 0
M.times do
  p,s = gets.split
  p = p.to_i
  if s == 'WA' && was[p] != -1
    was[p] += 1
  elsif s == 'AC' && was[p] != -1
    ac += 1
    wa += was[p]
    was[p] = -1
  end
end

puts [ac, wa].join(' ')


Measured memory_bytes: 2556
def f(n):
    # prime factorization of n!
    pf = [0 for _ in range(n + 1)]
    for i in range(2, n + 1):
        cur = i
        for j in range(2, i + 1):
            while cur % j == 0:
                pf[j] += 1
                cur //= j
    return pf


def num(m, pf):
    return len(list(filter(lambda x: x >= m - 1, pf)))


def main():
    N = int(input())
    pf = f(N)
    ans = num(75, pf)
    ans += num(25, pf) * (num(3, pf) - 1)
    ans += num(15, pf) * (num(5, pf) - 1)
    ans += num(5, pf) * (num(5, pf) - 1) * (num(3, pf) - 2) // 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;
 
public class Main{
    public static void main(String[] aaa){
        Scanner s = new Scanner(System.in);
        int[] count = new int[26];
        String st;
        char m,c;
        int i;
        while(s.hasNext()){
            st = s.next();
            for(i=0;i<st.length();i++){
                c=st.charAt(i);
                if('a' <= c && c <= 'z') count[c-'a']++;
                else if('A' <= c && c <= 'Z') count[c-'A']++;
            }
        }
        for(i=0;i<26;i++){
            m = (char)('a'+i);
            System.out.println(m+" : "+count[i]);
        }
    }
}


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

using namespace std;

int main(){

	int N;
	cin >> N;
	vector<int> a;
		
	for(int i=0;i<N;i++){
		int x;
		cin >> x;			
		a.push_back(x);	
	}

	sort(a.begin(),a.end(),greater<int>());

	int sum_A=0;
	int sum_B=0;

	for(int i=0;i<N;i++){
		if(i%2==0){
			sum_A +=a[i];		
		}
		else{	sum_B += a[i];}

	}

	cout << sum_A-sum_B<<endl;


	return 0;

}

Measured memory_bytes: 256
s = list(input())
k = int(input())
n=len(s)
if n!=1:
    cnt=[]
    tmp=1
    for i in range(1,n):
        if s[i]==s[i-1]:
            tmp+=1
        else:
            cnt.append((s[i-1], tmp))
            tmp=1
        if i==n-1:
            cnt.append((s[i], tmp))

    ans=0
    if len(cnt)==1:
        ans=cnt[0][1]*k//2
    elif cnt[0][0]!=cnt[-1][0]:
        for x,y in cnt:
            ans+=y//2
        ans*=k
    else:
        for x,y in cnt:
            ans+=y//2
        ans*=k
        if (cnt[0][1]+cnt[-1][1])%2==0:
            ans+=k-1
    print(ans)

else:
    print(k//2)

Measured memory_bytes: 38256
from collections import Counter

def getDivisor(x):
    ans = []
    for d in range(1, int(x**0.5)+1):
        if x % d == 0:
            ans.append(d)
            if x//d != d:
                ans.append(x//d)
    return sorted(ans)

N = int(input())
As = list(map(int, input().split()))

divisors = getDivisor(As[0]) + getDivisor(As[1])
cnt = Counter(divisors)

for i, A in enumerate(As[2:], 2):
    for d, num in list(cnt.items()):
        if A%d == 0:
            cnt[d] += 1

    for d, num in list(cnt.items()):
        if num < i:
            del cnt[d]

print(max(cnt.keys()))


Measured memory_bytes: 63984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int X, Y;
    cin >> X >> Y;
    printf("%d\n", X+Y/2);
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {set_intersection(ALL(a),ALL(b),inserter(c,c.end()));}
template<class T> void getor(const T &a,const T &b,T &c) {set_union(ALL(a),ALL(b),inserter(c,c.end()));}

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

const int MOD=1e9+7;

int main() {
  // 防止の色の組み合わせの数(MOD)
  // 防止は3種類
  int N;cin>>N;
  vector<int> AS(N);
  REP(i,N) cin>>AS[i];

  // dp[i]を左からiまでの場合のパターン数とすると、
  vector<ll> dp(N+1,0);
  dp[0]=1;
  int c1=0,c2=0,c3=0;
  REP(i,N) {
    int a=AS[i];
    int cnt=0;
    if (c1==a) cnt++;
    if (c2==a) cnt++;
    if (c3==a) cnt++;

    // ありえない
    if (cnt==0) {
      OUT(0);
      return 0;
    }

    if (cnt==3) {
      c1++;
    } else if (cnt==2) {
      if (c1==a) c1++;
      else c2++;
    } else {
      if (c1==a) c1++;
      else if (c2==a) c2++;
      else c3++;
    }
    dp[i+1] = dp[i]*cnt%MOD;
  }
  OUT(dp[N]);

  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
int num[111111],x,y,n,q;
vector<int> g[111111];
priority_queue<pair<int,int> > pq;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++) 
	{
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);  
	}
	scanf("%d",&q);
	for (int i=1;i<=n;i++) num[i]=-1e9;
	while(q--)
	{
		scanf("%d%d",&x,&y);
		num[x]=y;
		pq.push(make_pair(-y,x));
	}
	while(!pq.empty())
	{
		x=pq.top().second;
		pq.pop();
		for (int i=0;i<g[x].size();i++)
		{
			int to=g[x][i];
			if (num[to]==-1e9) 
			{
				num[to]=num[x]+1;
				pq.push(make_pair(-num[to],to)); 
			}
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<g[i].size();j++)
		{
			int to=g[i][j];
			if (abs(num[to]-num[i])!=1)
			{
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	for (int i=1;i<=n;i++) 
	printf("%d\n",num[i]);
	return 0;
}

Measured memory_bytes: 8180
/*input
5
2 4 4 0 2

*/
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 

using namespace std;
long long mod=1e9+7;
long long INF=1e7;
typedef long long int lld;
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define popcount __builtin_popcountll
typedef pair<lld,lld> PA;
#define lim 1000010
#define lim2 4023
#define numNodes 210
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

lld B[lim],A[lim],C[lim];
// PA P[lim],Q[lim];
lld n,m,p,q;
// string S[lim],R[lim];
vector<lld> V[lim];
// unordered_map<lld,lld> Ind;


lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}

bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}



int main(){
    lld T,i,j,h,l,r,b,k,c,a,d,w,x,y,v,z,t,curr,prev,sum,ans,pos,val,countA,secondMin,indicator;
    sc(n);
    rep(i,1,n){
        sc(j);
        B[j]++;
    }
    t=1;
    k=n-1;
    while(k>=-(n-1)){
        p=abs(k);
        if(B[p]<=0) t=0;
        B[p]--;
        k-=2;
    }
    rep(i,0,n-1) if(B[i]!=0) t=0;
    prL(powP(2,n/2)*t);
    return 0;
}

Measured memory_bytes: 24448
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
/*---------------------------------------------------------*/
int n,m;

int main(){
	in2(n,m);
	int i=1;
	while(n--){
		i=min(i*2,i+m);
	}
	out(i);
		
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
using namespace std;

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

const long long INF = 1LL << 60;

int main()
{
	int c[3][3];
	for (int i = 0;i < 3;i++) {
		cin >> c[i][0] >> c[i][1] >> c[i][2];
	}

	bool ans = false;

	int a[3];int b[3];
	for (int i = 0;i <= 100;i++) {
		for (int j = 0;j <= 100;j++) {
			for (int k = 0;k <= 100;k++) {
				a[0] = i;a[1] = j;a[2] = k;
				if ((c[0][0] - a[0] == c[1][0] - a[1]&& c[1][0] - a[1]==c[2][0] - a[2])&&
					(c[0][1] - a[0] == c[1][1] - a[1]&& c[1][1] - a[1]==c[2][1] - a[2])&&
					(c[0][2] - a[0] == c[1][2] - a[1]&& c[1][2] - a[1]==c[2][2] - a[2])) {
					ans = true;
				}
			}
		}
	}
	string res = "No";
	if (ans) {
		res = "Yes";
	}

	cout << res << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooLL 0x3f3f3f3f3f3f3f3f
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
 
int main(){
    fastio();
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";
    return 0;
}

Measured memory_bytes: 3608
package main

import "fmt"

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

	bucket := make([]int, 26)
	for _, i := range s {
		bucket[i - 97]++
	}

	for i, v := range bucket {
		if v == 0 {
			fmt.Println(string(i + 97))
			return
		}
	}

	fmt.Println("None")
}


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

int main()
{
    int N, W;
    int w[105], v[105];
    long dp[105][100005];
    cin >> N >> W;
    REP(i, N)
        cin >> w[i] >> v[i];
    REP(i, N+1)
        dp[i][0] = 0;
    REP(i, W+1)
        dp[0][i] = 0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=W;j++){
            if(j < w[i-1])
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j-w[i-1]] + v[i-1], dp[i-1][j]);
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 80896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;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 main(){
    int k,a,b;cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<"\n";
            return 0;
        }
    }
    cout<<"NG"<<"\n";
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), m = in();
	vector<pair<ll, ll>>v(n);
	REP(i, n) {
		ll a = in(), b = in();
		v[i] = make_pair(a, b);
	}

	sort(ALL(v));

	ll now = 0;
	ll res = 0;
	REPC(i, v) {
		if (i.second + now >= m) {
			res += i.first * (m - now);
			now = m;
		} else {
			res += i.first * i.second;
			now += i.second;
		}
		if (now == m) {
			break;
		}
	}
	cout << res << endl;
}

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

using namespace std;


int main () {
  int H, N;
  cin >> H;
  cin >> N;
 
  int sum = 0;
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    sum += a;
  }
  
  if(sum >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 764
n=int(input())
h=list(map(int,input().split()))
dp=[0]*(n+1)
dp[1]=0
dp[2]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i+1]=min(dp[i]+abs(h[i]-h[i-1]),dp[i-1]+abs(h[i]-h[i-2]))
print(dp[n])

Measured memory_bytes: 13928
#include <stdio.h>
#include <string.h>
 
typedef struct{
  int surface[6];
}Dice;

int surface_point(Dice d,int surface){
  for(int i = 0; i < 6; i++){
    if(d.surface[i] == surface)return i;
  }
  return -1;
}

int main(void){
  Dice dice;
  for(int i = 0; i < 6; i++)scanf("%d",&dice.surface[i]);
  int wide[3][5] = {{1,2,4,3,1},{0,3,5,2,0},{0,1,5,4,0}};
  int question,upside,front,UpPoint,FrPoint;
  scanf("%d",&question);
  for(int i = 0; i < question; i++){
    scanf("%d",&upside); scanf("%d",&front);
    UpPoint = surface_point(dice,upside);
    FrPoint = surface_point(dice,front);

    if(UpPoint <= 2){
      for(int j = 0; j < 4; j++){
        if(wide[UpPoint][j] == FrPoint){
          printf("%d\n",dice.surface[wide[UpPoint][j + 1]]);
          break;
        }
      }
    }
    else{
      for(int j = 4; j > 0; j--){
        if(wide[5 - UpPoint][j] == FrPoint){
          printf("%d\n",dice.surface[wide[5 - UpPoint][j - 1]]);
          break;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2052
using System;

namespace C___Next_Prime
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine().Trim());
            int ans = 0;
            for (int i = X; ; i++)
            {
                if (IsPrime(i) == true)
                {
                    ans = i;
                    break;
                }
            }
            Console.WriteLine(ans);
        }
        static bool IsPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    // 素数ではない
                    return false;
                }
            }

            // 素数である
            return true;
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
int N;
long long A[100];
int main() {
	std::cin >> N;
	A[0] = 2;
	A[1] = 1;
	for (int i = 2; i <= N; i++) {
		A[i] = A[i - 1] + A[i - 2];
	}
	std::cout << A[N] << std::endl;
	return 0;
}

Measured memory_bytes: 256