akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define ITR(x, c) for(__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
struct Gragh {
    vector<vector<ll>> G;
    ll N;
    vl visited;
    void init(ll n) {
        N = n;
        G.resize(N);
        visited = vl(N, 0);
    }

    void add(ll a, ll b) { G[a].push_back(b); }

    void resetv(void) { visited = vl(N, 0); }

    vl active;
    ll isloop = 0;
    vl toposo;

    vl TOPOSO(void) {
        active.resize(N);
        active = vl(N, 0);
        visited = vl(N, 0);
        rep(i, N) {
            if(visited[i] == 0)
                dfs(i);
        }
        reverse(all(toposo));
        return toposo;
    }

    void dfs(ll x) {
        visited[x] = 1;
        active[x] = 1;
        for(ll i : G[x]) {
            if(visited[i] == 0) {
                dfs(i);
            } else {
                if(active[i] == 1)
                    isloop = 1;
            }
        }
        active[x] = 0;
        toposo.push_back(x);
    }

    vl dag;
    vector<vector<ll>> G2;
    vl DAG(void) {
        resetv();
        G2.resize(N);
        dag.resize(N);
        rep(i, N) {
            for(ll j : G[i]) {
                G2[j].push_back(i);
            }
        }
        ll v = 1;
        rep(i, N) {
            ll j = toposo[i];
            if(visited[j] == 0)
                dfs_dag(j, v);
            v++;
        }
        return dag;
    }

    void dfs_dag(ll x, ll v) {
        dag[x] = v;
        visited[x] = 1;
        for(ll j : G2[x]) {
            if(visited[j] == 0)
                dfs_dag(j, v);
        }
    }
};
int main() {
    cin >> n >> m;
    Gragh G;
    G.init(n);
    rep(i, m) {
        cin >> x >> y;
        G.add(x, y);
    }

    G.TOPOSO();
    vl A = G.DAG();

    cin >> q;
    rep(i, q) {
        cin >> x >> y;\
        cout << (A[x] == A[y] ? 1 : 0) << endl;
    }
}


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

int main(void) {
  int N;
  cin >> N;
  vector<string> pencil = {"pon", "pon", "hon", "bon", "hon",
                           "hon", "pon", "hon", "pon", "hon"};
  cout << pencil[N % 10] << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    string s; cin>>s;
    if(s[0]==s[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cassert>//"assert(cond);": error if cond doesn't hold.
using namespace std;
typedef long long ll;
void chmax(ll &x, ll y){	x=max(x,y);	return;	}

#define MAX_N 100000
ll b[MAX_N+1];//true if it can be used many times

int main(){
	int n;
	ll h,a=0;
	scanf("%d %lld",&n,&h);
	for(int i=0;i<n;++i){
		ll x;
		scanf("%lld %lld",&x,&b[i]);
		chmax(a,x);
	}
	b[n]=a;
	sort(b,b+n+1,greater<ll>());
	ll ans=0;
	for(int i=0;i<=n&&h>0;++i){
		if(b[i]==a){
//			printf("%lld\n",a);
			ans+=h/a;
			if(h%a!=0) ++ans;
			break;
		}else{
//			printf("%lld\n",b[i]);
			++ans;
			h-=b[i];
		}
	}
	printf("%lld\n",ans);
}


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

using namespace std;

constexpr int INF = 1e8;

int main(){
    ios::sync_with_stdio(false);
    int n,m,s,g1,g2;
    while(cin>>n>>m>>s>>g1>>g2,n){
        --s;
        --g1;
        --g2;
        vector<vector<int>>dist(n,vector<int>(n,INF));
        for(int i=0;i<m;++i){
            int u,v,cost;
            cin>>u>>v>>cost;
            dist[u-1][v-1]=cost;
        }
        for(int k=0;k<n;++k){
            for(int i=0;i<n;++i){
                for(int j=0;j<n;++j){
                    if(dist[i][j] > dist[i][k]+dist[k][j]){
                        dist[i][j] = dist[i][k]+dist[k][j];
                    }
                }
            }
        }
        for(int i=0;i<n;++i)dist[i][i]=0;
        int ans=1e9;
        for(int i=0;i<n;++i){
            ans=min(ans,dist[s][i]+dist[i][g1]+dist[i][g2]);
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3140
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var tmp = new int[n];
            for (var i = 0; i < tmp.Length; i++)
            {
                if (s[i] == 'W') tmp[i] = 0;
                else tmp[i] = 1;
            }
            var agg = CumulativeSum(tmp).ToArray();
            var answer = n;
            for (var i = 0; i < agg.Length; i++)
            {
                var left = i - agg[i];
                var right = agg[agg.Length - 1] - agg[i];
                answer = Math.Min(answer, left + right);
            }
            Console.WriteLine(answer);
        }

        public static IEnumerable<int> CumulativeSum(IEnumerable<int> items)
        {
            if (items == null) throw new ArgumentNullException();
            var count = items.Count();
            if (count < 1) throw new ArgumentException();
            var array = new int[count + 1];
            array[0] = 0;
            for (var i = 1; i < array.Length; i++)
            {
                var index = i - 1;
                array[i] = items.ElementAt(index) + array[index];
            }
            return array;
        }
    }
}


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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

int n;
char ton(char c){
  if(c+n<'Z')return c+n;
  if(c+n=='Z')return 'Z';
  else return ('A'+(n-('Z'-c+1)));
}

signed main(void){
  cin >>n;
  string s;cin >> s;
  string ans;ans.resize(s.size());
  rep(i,s.size()){
    ans[i] = ton(s[i]);
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
typedef long long ll;
using namespace std;
const int MAX = 101;


struct E{
	E(int from, int to, int cost, int time):from(from), to(to){
		ct[0] = cost;
		ct[1] = time;
	}
	int from, to;
	int ct[2];	//ct[0]がcost、ct[1]がtime
};

void bf(int s, int e, int mode, vector<E> &tb, int *d){
	d[s] = 0;
	while(1){
		bool update = false;
		for(int i = 0; i < tb.size(); i++){
			if(d[tb[i].to] > d[tb[i].from] + tb[i].ct[mode]){
				d[tb[i].to] = d[tb[i].from] + tb[i].ct[mode];
				update = true;
			}
		}
		if(!update) break;
	}
}

int main(){
	int n, m;	//nが線路数、mが駅数
	while(cin >> n >> m && n|m){
		vector<E> tb;
		for(int i = 0; i < n; i++){
			int a, b, cost, time;
			cin >> a >> b >> cost >> time;
			tb.push_back(E(a, b, cost, time));
			tb.push_back(E(b, a, cost, time));
		}

		int minv[101];

		int k;
		cin >> k;
		for(int i = 0; i < k; i++){
			int s, e, mode;
			cin >> s >> e >> mode;

			fill(minv, minv+101, 1<<29);
			bf(s, e, mode, tb, minv);

			cout << minv[e] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1328
import math
#####sorting a dictionary#####
def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
def is_prime(n,k):
    if n==1:
        return 0
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            res=i
            break
    return res
def inp():
    ls=list(map(int,input().split()))
    return ls
n,m=map(int,input().split())
ls=inp()
ans=0
for i in range(n):
    if ls[i] >= sum(ls)/(4*m):
        ans+=1
if ans>=m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
        
        String l1 = bi.readLine();
        String[] params = l1.split(" ");
        int N = Integer.parseInt(params[0]);
        int Q = Integer.parseInt(params[1]);

        Node[] nodes = new Node[N];
        for (int i = 0; i < N; ++i) {
            nodes[i] = new Node();
        }
        for (int i = 0; i < N - 1; ++i) {
            String l2 = bi.readLine();
            String[] params2 = l2.split(" ");
            
            int a = Integer.parseInt(params2[0]) - 1;
            int b = Integer.parseInt(params2[1]) - 1;
            
            Node nodeA = nodes[a];
            Node nodeB = nodes[b];
            
            nodeA.children.add(nodeB);
        }
        
        for (int i = 0; i < Q; ++i) {
            String l2 = bi.readLine();
            String[] params2 = l2.split(" ");
            int n = Integer.parseInt(params2[0]) - 1;
            int score = Integer.parseInt(params2[1]);
            
            nodes[n].value += score;
        }
        
        search(nodes[0]);

        String result = Arrays.stream(nodes).map(n -> Integer.toString(n.value)).collect(Collectors.joining(" "));
        System.out.println(result);
    }
    
    public static void search(Node node) {
        for (Node c : node.children) {
            c.value += node.value;
            search(c);
        }
    }
    
    
    static class Node {
        int value;
        List<Node> children = new ArrayList<>();
    }
}


Measured memory_bytes: 132204
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;


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

	ll N, M;
	cin >> N >> M;
	vector<vector<ll>> m(N+1);
	vector<ll> P(M), Y(M);
	rep(i, M) {
		cin >> P[i] >> Y[i];
		m[P[i]].push_back(Y[i]);
	}
	
	map<ll, ll> juni;
	repk(i, 1, N) {
		sort(m[i].begin(), m[i].end());
		rep(j, m[i].size()) {
			juni[m[i][j]] = j + 1;
		}
	}

	rep(i, M) {
		printf("%06lld%06lld\n", P[i], juni[Y[i]]);
	}

	return 0;
}


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

#define fori( tt,aa)      for(long long i= tt; i<aa; i++)
#define forj( yy,bb)      for(long long j=yy; j<bb; j++)
#define fork( uu,cc)      for(long long k=uu; k<cc; k++)
#define sz(v)    v.size()
#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define EPS 1e-7
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE; fast();

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string String;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;


void accuSum2D(vector<vector<int>>&a){
    //accumulate each row
    fori(1, 101)
     forj(1, 101)
        a[i][j] +=a[i][j-1];

    //accumulate each col
    forj(1, 101)
     fori(1, 101)
        a[i][j] +=a[i-1][j];
}

int sum_range(int i, int j, int k, int l, vector<vector<int>>&s){
    return s[k][l] - s[k][j-1] - s[i-1][l] + s[i-1][j-1];
}

void fast(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
}

ld pow (ll a, ll b);
ll numOfDigits(ll n);
int freq[128];
int main()
{
    THINK_TWICE_CODE_ONCE;
    //freopen("great Vova Wall1.txt", "r", stdin);
    int n; cin>>n;
    int arr[n];
    fori(0,n) cin>>arr[i];
    sort(arr, arr+n);
    reverse(arr, arr+n);
    int alice =0, bob = 0;
    fori(0,n){
        if(!(i%2)) alice+=arr[i];
        else bob +=arr[i];
    }
    cout<<alice-bob;
    return 0;
}
ld pow (ll a, ll b){
    ld pow = 1;
    fori(0,b)
        pow *=a;
    return pow;
}

ll numOfDigits(ll n){
    if(!n) return 1;
    return (ll)(log10(n)+1);
}


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

int main(){
  int A,B,x,y;
  cin >> A >> B;
  x = B / (A-1);
  y = B % (A-1);
  if (A == 2) {
    cout << B-1 << endl;
  } else if (A == 3){
    cout << B / 2 << endl;
  } else if (y == 0 || y == 1){
    cout << x << endl;
  } else {
    cout << x+1 << endl;
  }
}


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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

// kmp をやるための前計算
vector<int> makeTable(const string& s) {
  int n = s.size();
  vector<int> ret(n+1);
  ret[0] = -1;
  int j = -1;
  for (int i = 0; i < n; i++) {
    while (j >= 0 && s[i] != s[j]) j = ret[j];
    ret[i+1] = ++j;
  }
  return ret;
}

// str の中に word とマッチする場所のリストを返す
// ret のそれぞれの要素 el は, 「str[el] からの文字列が word と一致する」ことを示す
vector<int> kmp(const string& str, const string& word) {
  vector<int> table = makeTable(word), ret;
  int m = 0, i = 0, n = str.size();
  while (m+i < n) {
    if (word[i] == str[m+i]) {
      if (++i == (int)(word.size())) {
        ret.push_back(m);
        m = m+i-table[i];
        i = table[i];
      }
    } else {
      m = m+i-table[i];
      if (i > 0) i = table[i];
    }
  }
  return ret;
}

int solve(){
  int n;cin>>n;
  string s;cin>>s;
  dump(n, s);


  int left = 0;
  int right = n/2+2;
  auto isright = [&](int x) {  // x:長さ
    rep(st, 0, (n-1)-x+1){
      string sub = s.substr(st, x);
      vi res = kmp(s.substr(st+x), sub);
      if (sz(res)>=1) return false;
    }
    return true;
  };
  while (right-left>1){
    int mid = (right+left)/2;
    if (isright(mid)) { right = mid;}
    else{ left = mid; }
  }

  cout << right-1 << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 384
#include <stdio.h>

void ans(char s)
{
  if(s == 'b')
    puts("b");

  else 
    puts("w");

}

int main(void)
{
  while(1) {
    int count = 0;
    char s[3][4] = {};
    int i = 0;
    for(i = 0; i < 3; i++)
      fgets(s[i], 5, stdin);

    if(s[0][0] == '0')
      break;
    for(i = 0; i < 3; i++){
      if(s[0][i] != '+' && s[0][i] == s[1][i] && s[1][i] == s[2][i]){
	ans(s[0][i]);
	break;
      }

      if(s[i][0] != '+' && s[i][0] == s[i][1] && s[i][1] == s[i][2]){
	ans(s[i][0]);
	break;
      }
  
      if(s[0][0] != '+' && s[0][0] == s[1][1] && s[1][1] == s[2][2]){
	ans(s[0][0]);
	break;
      }

      if(s[0][2] != '+' && s[0][2] == s[1][1] && s[1][1] == s[2][0]){
	ans(s[0][2]);
	break;
      }

      if(i == 2) count++;
    }

    if(count)
      puts("NA");
  }
  return 0;
}

Measured memory_bytes: 524
#include<iostream>
using namespace std;
long long dp[109][100009];

long long solve_napsack(int w[],int val[], int W, int n)
{
	if(W==0 || n==0)
		return 0;

	if(dp[n][W]!=-1)
		return dp[n][W];

	if(w[n-1]<=W)
	{
		return dp[n][W]=max(val[n-1]+solve_napsack(w,val,W-w[n-1],n-1), solve_napsack(w,val,W,n-1));
	}
	else 
	{
		return dp[n][W]=solve_napsack(w,val,W,n-1);
	}
}

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

	int w[n],val[n];

	for(int i=0;i<n;++i)
	{
		cin>>w[i]>>val[i];
	}
	for(int i=0;i<109;++i)
	{
		for(int j=0;j<100009;++j)
			dp[i][j]=-1;
	}

	cout<<solve_napsack(w,val,W,n)<<"\n";

}

Measured memory_bytes: 85376
n, m = map(int, input().split())

l_max, r_min = 0, n
for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l, l_max)
    r_min = min(r, r_min)

ans = max(0, r_min - l_max + 1)
print(ans)


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
ans1, ans2 = 0, 0
cnt1, cnt2 = 0, 0
cur = 1
for i in a:
    cnt1 += i
    if cnt1 * cur <= 0:
        ans1 += abs(cnt1 - cur)
        cnt1 = cur
    cur *= -1
cur = -1
for i in a:
    cnt2 += i
    if cnt2 * cur <= 0:
        ans2 += abs(cnt2 - cur)
        cnt2 = cur
    cur *= -1
print(min(ans1, ans2))

Measured memory_bytes: 19996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int h, w ;
  cin >> h >> w ;
  vector<string> S(h) ;
  rep(i,h) cin >> S.at(i) ;
  rep(i,h){
    rep(j,w){
	  if( S[i][j] == '#' ){
		if( i-1 >= 0 ){
       	  if(S[i-1][j] == '#' )continue ;
        }
        if( j-1 >= 0 ){
          if(S[i][j-1] == '#' )continue ;
        }
        if( i+1 < h ){
          if(S[i+1][j] == '#' )continue ;
        }
        if( j+1 < w ){
          if(S[i][j+1] == '#' )continue ;
        }
        cout << "No" << endl;
        return 0 ;
      }
    }
  }
  cout << "Yes" << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

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

  int m;
  cin >> m;

  for (int i = 0; i < m; i++) {
    int tmp;
    cin >> tmp;
    tmp -= 1;

    if (v[tmp] == 2019) continue;
    if (v[tmp] + 1 == v[tmp + 1]) continue;
    v[tmp]++;
  }

  for (auto e : v) {
    cout << e << endl;
  }
}



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

int main()
{
    string S;
    cin >> S;
    int topping = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'o') {
            topping++;
        }
    }
    cout << 700 + (100 * topping) << endl;
}

Measured memory_bytes: 3632
N, M = map(int,input().split())

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if N > 1 and M > 1:
	print(cmb(N, 2) + cmb(M, 2))
elif N > 1:
    print(cmb(N, 2))
elif M > 1:
    print(cmb(M, 2))
else:
    print(0)

Measured memory_bytes: 3064
function Main(input) {
  input = input.split("\n");
  var A = parseInt(input[0].split(" ")[0]);
  var B = parseInt(input[0].split(" ")[1]);
  if((A+B)%2==0){
    var ans = (A+B)/2;
  }else{
    var ans = "IMPOSSIBLE";
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 20168
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//typedef int ll;
typedef long double ld;
//#define int ll
#define pb push_back
using vint = vector<int>;
using pii = pair<int,int>;
using pdd = pair<ld,ld>;
using vpii = vector<pii>;
#define F first
#define S second
const int N = 2e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int mod = 998244353;
const int Inf = 1e9+7;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif
 
void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("game.in", "r", stdin);
//	freopen("game.out", "w", stdout);
//  cout << setprecision(10) << fixed;
}
 
int n;//, k, a[N];

signed main()
{
	io();
	cin >> n;
	cout << n + n * n + n * n * n;

}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  ll r,g,b,n;
  cin >> r >>g >> b >> n ;
  //ll a, b, c;
  //cin >> a >> b;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  ll buf;
  for(i=0;i<=3000;i++){
    for(j=0;j<=3000;j++){
      buf = n-(r*i+g*j);
      if(buf>=0&& buf%b==0)
      result++;

    }
  }
  cout<<result<<endl;





  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class C
{
	public static void Main()
	{
		int N = GetInt();
		int[] numPerColor = new int[8];
		int numFreeColor = 0;
		for(int i = 0; i < N; i++)
		{
			int a = GetInt();
			if(a >= 3200)
			{
				numFreeColor++;
			}
			else
			{
				numPerColor[a/400]++;
			}
		}

		int numBaseColor = 0;
		for(int i = 0; i < 8; i++)
		{
			if(numPerColor[i] > 0)
				numBaseColor++;
		}
		int min = Math.Max(1, numBaseColor);

		int max = numBaseColor + numFreeColor;
		Console.WriteLine("{0} {1}", min, max);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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


int main(int argc, char *argv[])
{
  int x;
  vector<int> freq;
  int X[120] ={0};
  while(cin >>x){
    freq.push_back(x);
}
    int maxf = 0;
  for(int i = 0;i < freq.size();i++){
    X[freq[i]]++;
      maxf = max(maxf,X[freq[i]]);
    }
  for(int j = 0;j < 100;j++){
    if(X[j] == maxf){
      cout << j << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1216
using System;
using System.Collections.Generic;
using System.Linq;

public class MainClass
{
	public static void Main(string[] args)
	{
		string[] inputs = Console.ReadLine().Split(' ');
		int N = int.Parse(inputs[0]);
		int M = int.Parse(inputs[1]);
		int C = int.Parse(inputs[2]);
		
		int[] b = new int[M];
		inputs = Console.ReadLine().Split(' ');
		for(int i = 0; i < b.Length; i++)
		{
			b[i] = int.Parse(inputs[i]);
		}
		int result = 0;
		//int[,] a = new int[N, M];
		for(int i = 0; i < N; i++)
		{
			int r = C;
			inputs = Console.ReadLine().Split(' ');
			for(int j = 0; j < M; j++)
			{
				r += int.Parse(inputs[j]) * b[j];
			}

			if(r > 0)
				result++;
			
		}


		Console.WriteLine(result);
	}
}

Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;
  
  vector<long long>p(N);
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  
  sort(p.begin(),p.end());
  
  long long ans = 0;
  
  if(N <= K) cout << 0 << endl;
  else{
    for(int i=0;i<N-K;i++){
      ans += p[i];
    }
    cout << ans << endl;
  }
  
  return 0;
}


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

int main(void)
{
	int A,B;
	cin>>A>>B;
	if((A+B)%3==0||A%3 == 0 ||B % 3 ==0)
		cout<<"Possible"<<endl;
	else
		cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
	Name: None
	Copyright: zhangjingcanËùÓÐ£¬Î´¾­ÔÊÐí²»µÃ×ªÔØ
	Author: zhangjingcan
	Date:
	Description: C++ÎÄ¼þ
*/
#include <bits/stdc++.h>
using namespace std;
const int A=90;
int n;
unsigned long long fib[A];
int main(int argc, char** argv) {
	ios::sync_with_stdio(false);
	cin>>n;
    fib[0]=2;
    fib[1]=1;
    for(int i=2;i<=n;i++){
    	fib[i]=fib[i-1]+fib[i-2];
	}
	cout<<fib[n]<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    auto p_def = p;
    vector<int> q(n);
    rep(i, n) cin >> q[i];
    auto q_def = q;
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    int cnt_p = 0;
    int cnt_q = 0;
    do {
        bool flg = true;
        rep(i, n) {
            if (p_def[i] != p[i]) {
                flg = false;
            }
        }
        if (flg) {
            break;
        }
        ++cnt_p;
    } while(next_permutation(p.begin(), p.end()));
    do {
        bool flg = true;
        rep(i, n) {
            if (q_def[i] != q[i]) {
                flg = false;
            }
        }
        if (flg) {
            break;
        }
        ++cnt_q;
    } while(next_permutation(q.begin(), q.end()));
    cout << abs(cnt_p - cnt_q) << endl;
    return 0;
}

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

using namespace std;

#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int x,y;
    cin>>x>>y;
    for(int i = 0;i<=x;i++){
        for(int j = 0;j<=x;j++){
            if(i + j == x){
                if(i * 2 + j * 4 == y){
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    int n,a[101],s=0,t=0,x=0,y=0,sum=0; cin>>n;
    for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
    s=sum/n; t=ceil((double)sum/n);
    //cout<<s<<" "<<t<<endl;
    for(int i=0;i<n;i++) x+=(s-a[i])*(s-a[i]);
    for(int i=0;i<n;i++) y+=(t-a[i])*(t-a[i]);
    cout<<min(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 50+10
//typedef std::pair<int,int> P;


    ll ans=-INF;
    ll N,Y;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>Y;
    REP(i,N+1){
        REP(j,N+1){
            if(i+j<=N){
                if(i*1000+j*5000+(N-(i+j))*10000==Y){
                    cout<<N-(i+j)<<" "<<j<<" "<<i<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int main(int argc, char const* argv[])
{
	int x,y;
	cin >> x >> y;
	cout << x + y/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define REP(i, k, n) for(int i = k; i< n; i++)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int h, w;

bool can(int y, int x) {
	if(0 <= y && y < h && 0 <= x && x < w) return true;
	return false;
}

int main() {
	cin >> h >> w;
	
	vector<string> v(h);
	rep(i, h) cin >> v[i];

	int ans = 0;
	REP(i, 1, h) {
		rep(j, w) {
			if(v[i][j]  != '-') continue;
			bool flag = true;
			REP(k, -1, 2) {
				int x = j + k;
				if(can(i, x) && v[i][x] == 'o') flag = false;
			}
			REP(k, -1, 2) {
				REP(l, -1, 2) {
					int y = i + k;
					int x = j + l;
					if(can(y, x) && v[y][x] == 'x') flag = false;
				}
			}

			if(flag) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int N;

int main() {
	//freopen("test.inp", "r", stdin);
	while (cin >> N, N) {
		int count = 0;
		for (int i = 1; i <= N; i++) {
			int sum = i;
			for (int j = i + 1; j <= N; j++) {
				sum += j;
				if (sum == N) count++;
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>

typedef struct Words
{
    char	word[31];
    int		page[100];
} WORDS;

WORDS	wordArray[100];

void printMinWord(WORDS*);
void printMinPage(WORDS*);

int main()
{
    char	tempWord[31];
    int		tempPage;
    int		wordCnt;
    int		pageCnt;
    int		inputCnt = 0;
	
    while (scanf("%s %d", &tempWord, &tempPage) != EOF)
    {
        wordCnt = 0;
        /*sort page to each words*/
        while(1)
        {
            if(!strcmp(tempWord, wordArray[wordCnt].word))
            {
                for(pageCnt = 1; pageCnt < 100; pageCnt++)
                {
                    if(!(wordArray[wordCnt].page[pageCnt]))
                    {
                        break;
                    }
                }
                wordArray[wordCnt].page[pageCnt] = tempPage;
                break;
            }
            else if(!strcmp("", wordArray[wordCnt].word))
            {
                strcpy(wordArray[wordCnt].word, tempWord);
                wordArray[wordCnt].page[0] = tempPage;
                break;
            }
            wordCnt++;
        }
    }
	
    printMinWord(wordArray);

	return 0;
} 

void printMinWord(WORDS* word_array)
{
	int		word_cnt;
	char	min_word[31]	= "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
	int		min_word_index	= -1;
	
	/*find min word and its index*/
	for(word_cnt = 0; word_cnt < 100; word_cnt++)
	{
		if(!strcmp(word_array[word_cnt].word, ""))
		{
			continue;
		}
		if(strcmp(word_array[word_cnt].word, min_word) <= 0)
		{
			strcpy(min_word, word_array[word_cnt].word);
			min_word_index = word_cnt;
		}
	}
	
	/*no recursion if no word content*/
	if(min_word_index != -1)
	{
		printf("%s\n", word_array[min_word_index].word);
		printMinPage(&word_array[min_word_index]);
		strcpy(word_array[min_word_index].word, "");
		printMinWord(word_array);
	}
}

void printMinPage(WORDS* word_array)
{
	int		page_cnt;
	int		min_page = 1001;
	int		min_page_index	= -1;
		
	/*find min page and its index*/
	
	
	for(page_cnt = 0; page_cnt < 100; page_cnt++)
	{
		if(word_array->page[page_cnt] == 0)
		{
			continue;
		}
		if(word_array->page[page_cnt] < min_page)
		{
			min_page = word_array->page[page_cnt];
			min_page_index = page_cnt;
		}
	}
	
	/*no recursion if no page content*/
	if(min_page_index == -1)
	{
		printf("\n");
		return word_array;
	}
	printf("%d", word_array->page[min_page_index]);
	word_array->page[min_page_index] = 0;
	
	for(page_cnt = 0; page_cnt < 100; page_cnt++)
	{
		if(word_array->page[page_cnt] == 0)
		{
			continue;
		}
		printf(" ");
		return printMinPage(word_array);
	}
	
	return printMinPage(word_array);
}

Measured memory_bytes: 644
#include <iostream>
#include <cctype>
using namespace std;
int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)toupper(s1[0])
         << (char)toupper(s2[0])
         << (char)toupper(s3[0]) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int n;
	cin >> n;
	int A[n];
	rep(i,n){
		cin >> A[i];
	}
	sort(A,A+n);
	pair<int,int> a[n];
	int p=0;
	for(int i=0; i<n; i++){
		int tmp=A[i];
		//cout << i << endl;
		int j=i;
		int cnt=0;
		while(j<n && A[j]==tmp){
			cnt++;
			j++;
			//cout << j << " ";
			//cout << A[j] << endl;
 		}
		i=j-1;
		a[p]=make_pair(tmp,cnt);
		//cout << a[p].first << a[p].second << endl;
		p++;
	}
	//cout << endl;
	int ans=0;
	rep(i,p){
		if(a[i].second<a[i].first) ans+=a[i].second;
		else ans+=a[i].second - a[i].first;
		//cout << a[i].first << endl;
	}
	cout << ans << endl;
	return 0;
}
/*
//素因数分解した結果をres[]に入れる
for(int i=2; i<=num; i++){
	while(c%i==0){
		res[i]++;
		c/=i;
	}
}
*/

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int k;
    cin >> k;
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout << a[k-1] << endl;

    return 0;
}


Measured memory_bytes: 256
N, K = map(int,input().split())

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

if (0 in X):
  K = K-1
  N = N-1
  X.remove(0)

trial = []

if X != []:
  for i in range(N-K+1):
    if (X[i] < 0) and (X[K+i-1] < 0):
      trial.append(abs(X[i]))
    if (X[i] > 0 ) and (X[K+i-1] > 0):
      trial.append(abs(X[K+i-1]))
    go = abs(X[i])*2+abs(X[K+i-1])
    back = abs(X[i])+abs(X[K+i-1])*2
    trial.append(min(go,back))
  
if trial != []:
  print(min(trial))
else:
  print(0)

Measured memory_bytes: 14480
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        HashSet<Integer> set = new HashSet<>();
        HashMap<Integer, Integer> map = new HashMap<>(); 
        int penalty = 0;
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            String result = sc.next();
            if ("AC".equals(result)) {
                set.add(x);
            } else {
                if (!set.contains(x)) {
                    if (map.containsKey(x)) {
                        map.put(x, map.get(x) + 1);
                    } else {
                        map.put(x, 1);
                    }
                }
            }
        }
        for (int x : set) {
            if (map.containsKey(x)) {
                penalty += map.get(x);
            }
        }
        System.out.println(set.size() + " " + penalty);
    }
}

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

int main(){
    int N, K;
    cin >> N >> K;
    map<int, vector<int>> mp;
    for(int i=0; i<N; i++){
        int t, d;
        cin >> t >> d;
        mp[t].push_back(d);
    }

    vector<int> maxes, others;
    for(auto& p : mp){
        auto nums = p.second;
        sort(nums.rbegin(), nums.rend());
        maxes.push_back(nums[0]);
        for(int i=1; i<nums.size(); i++) others.push_back(nums[i]);
    }

    sort(maxes.rbegin(), maxes.rend());
    sort(others.rbegin(), others.rend());

    vector<int64_t> maxes_s(N+1, 0), others_s(N+1, 0);
    for(int i=0; i<maxes.size(); i++) maxes_s[i+1] = maxes_s[i] + maxes[i];
    for(int i=0; i<others.size(); i++) others_s[i+1] = others_s[i] + others[i];

    int kmax = min(K, (int) mp.size());
    int64_t ans = 0;
    for(int64_t k=1; k<=kmax; k++){
        int64_t result = maxes_s[k] + others_s[K-k] + k*k;
        ans = max(ans, result);
    }
    cout << ans << endl;
    return 0;
}

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

//WAを4つほど生やす結果となる。

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i = 0; i < N; i++)cin >> p.at(i);
  double maxv = 0;
  double tmpsum = 0;
  double pretmpsum = 0;
  for(int j = 0; j < N-K+1; j++){
    tmpsum = 0;
    if(j==0){
      for(int i = 0; i < K; i++){
        tmpsum += (p.at(j+i)+1)/2.0;
      }
    }else{
      tmpsum = pretmpsum - (p.at(j-1)+1)/2.0 + (p.at(j+K-1)+1)/2.0;
    }
    maxv = max(maxv,tmpsum);
    pretmpsum = tmpsum;
  }
  cout << setprecision(12)<< maxv << endl;
}


Measured memory_bytes: 1024
x,y=map(int,input().split())
z=[300000,200000,100000]

if x==1 and y==1:
    print(1000000)
else:
    k,l=0,0
    if 1<=x<=3:
         k=z[x-1]
    if 1<=y<=3:
         l=z[y-1]
    print(k+l)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
            int h = sc.nextInt();
            if(h==0)break;
            int[][] f = new int[h][5];
            for (int i = 0; i < f.length; i++) {
                for (int j = 0; j < 5; j++) {
                    f[f.length-1-i][j]=sc.nextInt();   
                      
                }
            }
            System.out.println(calc(f));
        }
    }
    static int calc(int[][] f){
        int res = 0;
        while(true){
            boolean[][] checked = new boolean[f.length][5];
            int point = 0;
            for (int i = 0; i < f.length; i++) {
                for (int j = 0; j < 3; j++) {
                    for (int j2 = 1; j2 <= 9; j2++) {
                        boolean flg =true;
                        for (int k = 0; k < 3; k++) {
                            if(f[i][j+k]!=j2){
                                flg=false;
                            }
                        }
                        if(flg){
                            for (int k = 0; k < 3; k++) {
                                checked[i][j+k]=true;
                            }
                        }
                    }
                }
            }
            for (int i = 0; i < checked.length; i++) {
                for (int j = 0; j < 5; j++) {
                    if(checked[i][j]){
                        point+=f[i][j];
                        f[i][j]=0;
                    }
                }
            }
            
            if(point==0)break;
            res+=point;
            fall(f);
        }
        return res;
    }
    static void fall(int[][] f){
        for (int i = 0; i < f.length; i++) {
            for (int j = 0; j < 5; j++) {
                while(f[i][j]==0 && above(f,i,j)){
                    for (int j2 = i; j2 < f.length-1; j2++) {
                        f[j2][j] = f[j2+1][j];
                    }
                    f[f.length-1][j]=0;
                }
            }
        }
    }
    static boolean above(int[][]f,int y,int x){
        for (int i = y+1; i < f.length; i++) {
            if(f[i][x]>0)return true;
        }
        return false;
    }
   
}

Measured memory_bytes: 52076
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

int N,A[100010];
int dp[100010];

int DP(int a){
	if(dp[a]!=-1)return dp[a];
	int res=INF,res2=INF;
	if(a==N-1){
		return 0;
	}
	res=DP(a+1)+abs(A[a]-A[a+1]);
	if(a<N-2){
		res2=DP(a+2)+abs(A[a+2]-A[a]);
	}
	return dp[a]=min(res,res2);
}

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,100010){
		dp[i]=-1;
	}
	cout<<DP(0)<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int unsigned long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    //only 10s
    int n;
    cin >> n;
    if (n & 1) {
    	cout << 0 << endl;
    	return 0;
    }
    int cnt2 = 0;
    for (int pw = 2; pw <= n; pw *= 2) {
    	cnt2 += n / pw;
    }
    int cnt5 = 0;
    
    for (int pw = 5; pw <= n; pw *= 5) {
    	cnt5 += (n / 2) / pw;
    }
    
    cout << min(cnt2, cnt5) << endl;
}


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> location(N+1);
  for (int i = 0; i < N; i++) cin >> location[i];
  location[N] = X;
  sort(location.begin(), location.end());
  vector<int> sub(N);
  for (int i = 0; i < N; i++) sub[i] = location[i+1] - location[i];
  sort(sub.begin(), sub.end());
  int D = 0;
  for (int i = sub[0]; i > 0; i--) {
    bool can = true;
    for (int j = 0; j < N; j++) {
      if (sub[j] % i != 0) {
        can = false;
        break;
      }
    }
    if (can) {
      D = i;
      break;
    }
  }
  cout << D << endl;
}


Measured memory_bytes: 1024
def solve(n, y):

    a = 0
    ans = "-1 -1 -1"
    while a <= n :
        
        c = (y - 5000*(a+n)) // (-4000) if (y - 5000*(a+n)) % (-4000) == 0 else -1
        
        b = n - a - c
        if b >= 0 and c >= 0:
            ans = "{0} {1} {2}".format(a, b, c)
            break
        else:
            a += 1

    return ans

if __name__ == "__main__":
    n,y = [int(i) for i in input().split()]
    print(solve(n, y))

Measured memory_bytes: 3064
#include <stdio.h>
int N[6]={1,5,2,3,0,4},S[6]={4,0,2,3,5,1};
int E[6]={3,1,0,5,4,2},W[6]={2,1,5,0,4,3},O[6]={0,1,2,3,4,5};
int PT[4]={2,4,1,3};
void cpy(int *a,int *b,char dir){
    int i,*d;
    if (dir=='N'){d=N;}
    else if (dir=='S'){d=S;}
    else if (dir=='E'){d=E;}
    else if (dir=='W'){d=W;}
    else {d=O;}
    for(i=0;i<6;i++){b[i]=a[d[i]];}
}

int main(void){
    int i,j,q,ia,ib,buf,d[6],c[6];char od[101];
    for(i=0;i<6;i++){scanf("%d",&d[i]);}
    scanf("%d",&q);
    int ary[q];
    
    for(j=0;j<q;j++){
        scanf("%d %d",&ia,&ib);
        while(1){
            if (d[1]==ia || d[4]==ia || d[5]==ia){cpy(d,c,'O');cpy(c,d,'N');}
            else if (d[3]==ia || d[2]==ia){cpy(d,c,'O');cpy(c,d,'E');}
            else {
                for(i=1;i<=4;i++){
                    if(d[i]==ib){ary[j]=d[PT[i-1]];break;}
                }
                break;
            }
        }
    }
    for(i=0;i<q;i++){printf("%d\n",ary[i]);}
    return 0;
}


Measured memory_bytes: 2036
#include <stdio.h>

int main() {
  int n, max = 0, smax = 0, maxi;
  scanf("%d", &n);
  int a[n];
  for (size_t i = 0; i < n; i++) {
    scanf("%d", a+i);
    if (max<a[i]) {
      smax = max;
      max = a[i];
      maxi = i;
    }else if (smax<a[i]) {
      smax = a[i];
    }
  }
  for (size_t i = 0; i < n; i++) {
    if (i == maxi) {
      printf("%d\n", smax);
    }else {
      printf("%d\n", max);
    }
  }
  return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define S_MAX 100
#define N_MAX 100000
#define M_MAX 200000
#define INF 10000000
#define MOD 1000000007
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

int n, m;
int i, j, k;
ull a, b;

ull x[N_MAX];
char s[S_MAX + 1];

typedef struct {
	int in;
	int out;
} twoway;

void deb(){
	return;
}

void solve(){
	ull result = 0;
	int p = 0;

	if (n) {
		puts("No");
	} else {
		puts("Yes");
	}

	return;
}

int main (void) {
	char *t;
	bool x[26] = {0};
	scanf("%s", s);
	for (t = s; *t; t++) x[*t - 'a'] ^= 1;

	for (i = 0; i < 26; i++) if (x[i]) n++;
	solve();
	return 0;
}




Measured memory_bytes: 128