akhauriyash/Code-Regression huggingface dataset:
//................ DON'T WISH IT WERE EASIER, WISH YOU WERE BETTER........................
//............ WHEN LIFE PUTS YOU IN TOUGH SITUATIONS, DONT SAY "WHY ME" SAY "TRY ME".......
 
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pb emplace_back
#define endl "\n"
#define f first
#define mp make_pair
#define s second
#define delrep  v.erase(unique(v.begin(),v.end()),v.end());
#define all(a)  (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define sz(x)   (int)x.size()
#define lll __int64
const int N=1e6+10;
const int mod=998244353;
using namespace std;
typedef long long ll;
int get_second( pair<int, int> i ){ return i.second; } 
ll power(ll x,ll y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int trail_zero(int n){while (n % 10 == 0) n /= 10 ; return n;}
map<ll,ll> m1;
set<ll>set1; set<ll>st;
multiset<ll>s1;
map<pair<ll,ll>,ll> mx;
//vector<ll>a(N);
vector<pair<ll,ll>>vx;
vector<pair<pair<ll,ll>,ll>>vz;
vector<ll>val;
vector<pair<ll,ll>>val2;
map<char,int>m2;
char s111[N];
ll p2[N],p3[N];
bool vis[N]; string s[N];
ll h,k,g,x,ans=1,q,t,cnt=0,d=0,ansx=1e18,n,m;
stack<int>sx; queue<int>qx;
inline bool in (int x , int y) { return 1 <= x && x <n+1 && 1<= y && y <m+1; }
inline bool in2 (int x , int y) { return 0 <= x && x <n && 0<= y && y <m; }
bool check(int i,int j) { if(s[i][j]=='.') return true; else return false;   }
ll count_divisor(ll a)
{
  ll cnt=0;
  for(ll i=1;i*i<=a;i++)
  {
    if(a%i==0) { if(a/i!=i) cnt+=2; else cnt+=1; }
 
  }
  return cnt;
}
void primeFactors(ll n)
{
    while (n%2 == 0) { st.insert(2); n = n/2; }
    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)  { st.insert(i);  n = n/i; }
    }
    if(n>2)  st.insert(n);
}
int pref[N],suff[N];
int a[2][505][505];
int main() 
{
   int n; cin>>n; float a[n]; for(int i=0;i<n;i++) cin>>a[i]; sort(a,a+n); float ans=a[0];
   for(int i=1;i<n;i++) { ans=(ans+a[i])/2;   } cout<<ans;






    return 0;
}
  

Measured memory_bytes: 10624
#!/usr/bin/env python

VALUE = 500

stdin = input()
args = stdin.split(' ')

num = int(args[0])
if num < 1 or num > 100:
    assert False, 'Invalid value'

threshold = int(args[1])
if threshold < 1 or threshold > 10**5:
    assert False, 'Invalid value'

result = 'Yes' if num * VALUE >= threshold else 'No'
print(result)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int a,b;
    int S,T;
    
    scanf("%d %d",&a,&b);
    if( (1<=a&&a<=100) && (1<=b&&b<=100)){
        S=a*b;
        T=2*a+2*b;
        printf("%d %d\n",S,T);
    }
    else{
        printf("error\n");
    }
    
    return 0;
}


Measured memory_bytes: 2044
d1 :: [Double] -> [Double] -> Double
d1 [] [] = 0
d1 (x : xs) (y : ys) = abs (x - y) + d1 xs ys

d2 :: [Double] -> [Double] -> Double
d2 [] [] = 0
d2 (x : xs) (y : ys) = (x - y)^2 + d2 xs ys

d3 :: [Double] -> [Double] -> Double
d3 [] [] = 0
d3 (x : xs) (y : ys) = (abs (x - y))^3 + d3 xs ys

dinf :: [Double] -> [Double] -> [Double]
dinf [] [] = []
dinf (x : xs) (y : ys) = abs (x - y) : dinf xs ys


main = getContents >>= mapM_ print . (\[x,y] -> [d1 x y, sqrt (d2 x y), (d3 x y)**recip 3, maximum $ dinf x y]) . map (map read . words) . tail . lines

Measured memory_bytes: 4464
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input1 = Console.ReadLine().Split(' ');
		string[] input2 = Console.ReadLine().Split(' ');

		int m1 = int.Parse(input1[0]);
		//int d1 = int.Parse(input1[1]);
		int m2 = int.Parse(input2[0]);
		//int d2 = int.Parse(input2[1]);
      
		var ret = 0; 
		if (m1+1==m2)
        {
          ret = 1;
        }
      
      Console.WriteLine(ret);
	}
}

Measured memory_bytes: 13140
n = int(input())
a = [int(aa) for aa in input().split()]

def add_entry(hist, aa):
    if aa in hist:
        hist[aa] += 1
    else:
        hist[aa] = 1


def make_hist(a):
    even_hist = {}
    odd_hist = {}

    for i in range(len(a)//2):
        add_entry(even_hist, a[2*i])
        add_entry(odd_hist, a[2*i+1])

    return even_hist, odd_hist


def get_sorted_hist(hist):
    return sorted(hist.items(), key=lambda x: -x[1])

eh, oh = make_hist(a)
seh = get_sorted_hist(eh)
soh = get_sorted_hist(oh)


if seh[0][0] != soh[0][0]:
    print(len(a) - seh[0][1] - soh[0][1])
else:
    if len(seh) == 1 and len(soh) == 1:
        print(len(a)//2)
    elif len(seh) == 1:
        print(len(a) - seh[0][1] - soh[1][1])
    elif len(soh) == 1:
        print(len(a) - soh[0][1] - seh[1][1])
    else:
        print(min(len(a) - seh[0][1] - soh[1][1], len(a) - soh[0][1] - seh[1][1]))


Measured memory_bytes: 20764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n) for(ll i=0;i<n;i++)
#define fa(i,a,b) for(ll i=a;i<=b;i++)
#define fr(i,n) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ms(array,value) memset(array,value,sizeof(array))
#define test(t) ll t;cin>>t;while(t--)
#define en cout<<endl;
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define pb push_back
#define all(a) a.begin(),a.end()
#define pi pair<int,int>
#define mod2  998,244,353

int main()
{
    int n; cin>>n;
    bool c=0;
    while(n)
    {
        int x=n%10;
        if(x==7) {c=1; break;}
        n/=10;
    }
    if(c) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(void)
{
	int n, i, max, min;
	int s[n];
scanf("%d", &n);
for (i=0; i < n; i++){
    scanf("%d", &s[i]);
}
 min = s[0];
  max = s[0];
   for(i = 0; i < n; i++)
   {
      if(s[i] < min) min = s[i];
      if(s[i] > max) max = s[i];
   }

  printf("%d", max-min);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  	string s;
	  cin >> s;
  	if(s[s.length()-1] == '2' || s[s.length()-1] == '4' || s[s.length()-1] == '5' ||s[s.length()-1] == '7' || s[s.length()-1] == '9'){
    	cout << "hon" << endl;
    }else if(s[s.length()-1] == '3'){
		  cout << "bon" << endl;
    }else{
    	cout << "pon" << endl;
    }
}

Measured memory_bytes: 3572
X = int(input())
As = [0]*121
for i in range(1,121):
  As[i] = i**5

flag = 0
for i in range(1,121):
  a = As[i]
  for j in range(i+1):
    b = As[j]
    if a + b == X:
      print(i,-j)
      flag = 1
      break
    elif a - b == X:
      print(i, j)
      flag = 1
      break
  if flag == 1:
    break

Measured memory_bytes: 63428
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

ll fact[800000], fact_inv[800000];

ll power(ll a, ll n) {//繰り返し二乗法
  ll res = 1;
  while(n > 0) {
    if(n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll comb(ll n, ll r) {
  if(n < r) return 0;
  if(n < 0 || r < 0) return 0;
  return fact[n] * fact_inv[r] % mod * fact_inv[n-r] % mod;
}

int main() {
  ll x, y; cin >> x >> y;
  if((x+y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  ll a = (2 * x - y) / 3;
  ll b = (2 * y - x) / 3;

  ll n = 700000;

  fact[0] = 1;
  for(ll i=0; i<n; i++) fact[i+1] = fact[i] * (i+1) % mod;

  fact_inv[n] = power(fact[n], mod-2);

  for(ll i=n-1; i>=0; i--) fact_inv[i] = fact_inv[i+1] * (i+1) % mod;

  cout << comb(a+b, b) << endl;
}

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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 99999999999

using namespace std;

int32_t main(){
    int n, k;
    cin >> n >> k;
    int a;
    REP(i, n) cin >> a;

    int cnt=0;
    n-=k;
    k--;
    cnt++;

    while(n>0){
        n-=k;
        cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())

keys = [i for i in range(1, N+1)]
values = [0] * N
count_dict = dict(zip(keys, values))

for x in range(1, N//6+7):
    for y in range(x, N//6+7):
        for z in range(y, N//6+7):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if n > N:
                break
            if x == y and y == z:
                count_dict[n] += 1
            elif x != y and x != z and y != z:
                count_dict[n] += 6
            else:
                count_dict[n] += 3

for v in count_dict.values():
    print(v)

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

int main(){
    int l,r,d;
    cin >> l >> r >> d;
    if (l%d ==0){
        cout << r/d - l/d +1 << endl;
    }
    else{
        cout << r/d - l/d << endl;
    }
}


Measured memory_bytes: 3632
N = int(input())
 
prev = 0
ans = 0
able = True
for i in range(N):
	now = int(input())
	
	if now - prev > 1 or (i == 0 and now != 0):
		print(-1)
		able = False
		break
	elif now - prev == 1:
		ans += 1
	elif now:
		ans += now
	prev = now

if able:
	print(ans)

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

using ll = long long;

using namespace std;

int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll sum = 0;
  A = min(A, K);
  sum += A;
  K -= A;
  B = min(B, K);
  K -= B;
  C = min(C, K);
  sum -= C;
  cout << sum;
  return 0;
}


Measured memory_bytes: 3620
function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10);

    var plices = [];
    var max = 0;

    for(var i = 1; i <= N; i++) {
        plices[i] = parseInt(args[i]);
        if(max < plices[i]) {
            max = plices[i];
        }
    }

    var seel = true;
    var ans = 0;

    for (var i = 1; i <= N; i++) {
        if(plices[i] === max && seel) {
            plices[i] = plices[i] / 2;
            seel = false;
        }
        ans += plices[i];
    }

    console.log(ans);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;
//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,4){
    if(s.at(i) == '+'){
      cnt++;
    }else{
      cnt--;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  int ans=0;
  
  for(int i=0;i<4;i++){
    if(a[i]=='+')
      ans++;
    else
      ans--;
  }
  cout<<ans<<endl;

}



Measured memory_bytes: 256
/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll n;
	cin>>n;
	if(n%2!=0)
		cout<<0<<nl;
	else
		{
			ll k=10;
			ll ans=0;
			while(k<=n)
			{
				ans+=n/k;
				k*=5;
			}
			cout<<ans<<nl;
		}
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll a,b,c,d;
	ll ans=0LL;
	cin >>a>>b>>c>>d;
	ll cd=c*d/__gcd(c,d);
	ll Cc=0LL,Cd=0LL,Ccd=0LL;
	Cc=b/c - (a-1)/c;
	clog<<Cc<<endl;
	Cd = b / d - (a-1) / d;
	clog << Cd << endl;
	Ccd = b / cd - (a-1) / cd;
	clog << Ccd << endl;
	ans=b-(a-1)-Cc-Cd+Ccd;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

long long gcd(long long a, long long b){ // Ååöñ
    if(a == 0 || b == 0)
        return 0;
    if(b > a)
        swap(a, b);
    long long tmp;
    while((tmp = a % b) != 0){
        a = b;
        b = tmp;
    }
    return b;
}

long long lcm(long long a, long long b){ // Å¬ö{
    return a / gcd(a, b) * b;
}

char add(char a, char b)
{
    int c;
    if('0' <= a && a <= '9')
        c = a - '0';
    else
        c = a - 'A' + 10;
    if('0' <= b && b <= '9')
        c += b - '0';
    else
        c += b - 'A' + 10;
    if(c < 10)
        return '0' + c;
    else
        return 'A' + c - 10;
}

int main()
{
    int t;
    cin >> t;
    while(--t >= 0){
        int n;
        cin >> n;
        vector<string> s(n);
        for(int i=0; i<n; ++i){
            string tmp;
            cin >> tmp;
            int a = tmp.size()/2;
            for(int j=1; j<tmp.size()/2; ++j){
                if(tmp[2*j] != '0' || tmp[2*j+1] != '0'){
                    if(a == -1)
                        a = j;
                    else
                        a = gcd(a, j);
                }
            }
            for(unsigned j=0; j<tmp.size()/2; j+=a){
                s[i] += tmp[j*2];
                s[i] += tmp[j*2+1];
            }
        }

        int len = 1;
        for(int i=0; i<n; ++i){
            len = lcm(len, s[i].size()/2);
            if(len > 1024)
                break;
        }
        if(len > 1024){
            cout << "Too complex." << endl;
            continue;
        }

        string ret(len*2, '0');
        for(int i=0; i<n; ++i){
            int a = len / (s[i].size()/2);
            for(unsigned j=0; j<s[i].size()/2; ++j){
                ret[2*j*a] = add(ret[2*j*a], s[i][2*j]);
                ret[2*j*a+1] = add(ret[2*j*a+1], s[i][2*j+1]);
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 944
#include<stdio.h>

int isPrime(int x)
{
  int 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, x, i;
  int cnt = 0;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ )
  {
    scanf("%d", &x);
    if ( isPrime(x) ) cnt++;
  }
  printf("%d\n", cnt);
  
  return 0;
}



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

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define SZ 100010
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define INF 1000000000
#define F first
#define S second
#define MP make_pair
#define LL long long


/************************* disjoint set start ***************************************/
int par[SZ];
int rank_of[SZ];
LL sz[SZ];
void make_set(int nein)	{
    for (int i = 0; i <= nein; i++)	{
        par[i] = i;
        sz[i] = 1;
    }
}
int find_rep(int i)	{
    if (i != par[i])	{
        par[i] = find_rep(par[i]);
    }
    return par[i];
}
bool is_uni(int u, int v)	{// is it union
    int par_u = find_rep(u);
    int par_v = find_rep(v);
    if (par_u == par_v)	{
        return true;
    }
    return false;
}
int union_node(int u, int v)	{

    int par_u = find_rep(u);
    int par_v = find_rep(v);
    if (par_u == par_v)	{   //this means they are in same set
        return 0;
    }

    LL ans = sz[par_u] * sz[par_v];

    if (rank_of[par_u] == rank_of[par_v])	{
        rank_of[par_u]++;
        par[par_v] = par_u;

        sz[par_u] = sz[par_u] + sz[par_v];
    }
    else if (rank_of[par_u] > rank_of[par_v])	{
        par[par_v] = par_u;

        sz[par_u] = sz[par_u] + sz[par_v];
    }
    else	{
        par[par_u] = par_v;

        sz[par_v] = sz[par_u] + sz[par_v];
    }
    return ans;
}
/************************* disjoint set end ***************************************/

class Data  {
public:
    int u, v;
    Data()  {}
    Data(int u, int v)  {
        this->u = u;
        this->v = v;
    }
};

Data ara[SZ];

int main()  {
//    freopen("in.txt", "r", stdin);
    LL n;
    int m;
    cin >> n >> m;
    FOR(i, 0, m - 1)   {
        int u, v;
        cin >> u >> v;
        ara[i] = Data(u, v);
    }
    reverse(ara, ara + m);

    LL ans = (n * (n - 1)) / 2;

    vector<LL> pr;pr.PB(ans);

    make_set(n);

    FOR(i, 0, m - 2)   {
        if(is_uni(ara[i].u, ara[i].v))    {
        }
        else    {
            ans -= union_node(ara[i].u, ara[i].v);
        }
//        cout << ans << "\n";
        pr.PB(ans);
    }

    reverse(pr.begin(), pr.end());

    FOR(i, 0, (int)pr.size() - 1)   {
        cout << pr[i] << "\n";
    }
    return 0;
}
/**
*/


Measured memory_bytes: 4596
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


N,W = map(int, sys.stdin.readline().rstrip().split())
w = [0] * N
v = [0] * N
for i in range(N):
  w[i], v[i] = list(map(int, sys.stdin.readline().rstrip().split()))

dp = [0 for _ in range(W+1)]

for i in range(N):
  for j in range(W,w[i]-1,-1):
    dp[j] = max(dp[j], dp[j-w[i]]+v[i])
print(max(dp))


Measured memory_bytes: 45040
#include<stdio.h>
int selectionSort(int A[], int N){
  int i, j, t, sw =0,mini;
  for( i = 0; i < N -1; i++){
    mini = i;
    for( j =i ; j < N ; j++){
      if( A[j] < A[mini] ) mini =j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
    if( i != mini )sw++;
  }
  return sw;
}

int main(){
  int A[100], N, i, sw;

  scanf("%d",&N);
  for( i = 0; i < N; i++)scanf("%d",&A[i]);

  sw = selectionSort(A,N);

  for( i = 0; i < N; i++ ){
    if( i > 0 )printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",sw);

  return 0;
}
			  



Measured memory_bytes: 2144
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod=1e9+7;
const int INF=0x3f3f3f3f;

int n,a[111111];
ll ans;

int main()
{
	cin>>n;
	rept(i,1,n+1)
	{
		cin>>a[i];
		if (a[i-1] && a[i])
		{
			a[i-1]--;
			a[i]--;
			ans++;
		}
		ans+=(ll)a[i]/2;
		a[i]&=1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>


int main(){
  int i;
  double a,sum;
  while(scanf("%lf",&a)!=EOF){
    sum=a;
    for(i=1;i<10;i++){
      a=a*(i%2==0?1.0/3.0:2.0);
      sum+=a;
    }
    printf("%.8lf\n",sum);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000000000000303030
#define MOD 1000000007
#define N 200005
#define MAX 5000000
#define LOG 100
#define KOK 333
using namespace std;

int n,a,b;
ll pre[N];
ll ans=inf;
vector<pair<int,pair<int,int> > > gen;
vector<int> pos[N];

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d",&n);

	gen.pb({-1,{-1,-1}});

	for(int i=1;i<=n;i++) {

		scanf("%d %d",&a,&b);

		gen.pb({a,{i,0}});
		gen.pb({b,{i,1}});

	}

	sort(all(gen));

	int ty=-1;
	bool flag=0;

	for(int i=1;i<=sz(gen)/2;i++) {

		if(ty==-1) ty=gen[i].nd.nd;
		else if(ty!=gen[i].nd.nd) flag=1;

	}

	if(!flag) {

		ll sum=0;

		for(int i=1;i<=sz(gen)/2;i++) sum+=gen[i].st;

		umin(ans,sum);

	}

	for(int i=1;i<sz(gen);i++) {

		pos[gen[i].nd.st].pb(i);

		pre[i]=pre[i-1]+gen[i].st;

	}

	for(int i=1;i<=n;i++) {

		int fi=pos[i][0]-1;
		int se=pos[i][1]-pos[i][0]-1;
		int th=2*n-pos[i][1];

		if(fi+2>=n) {

			umin(ans,pre[n-2]+1ll*gen[fi+1].st+1ll*gen[fi+se+2].st);

		}
		else if(fi+se+2>=n) {

			umin(ans,pre[n-1]+1ll*gen[fi+se+2].st);

		}
		else {

			umin(ans,pre[n]);

		}

	}

	printf("%lld",ans);

}

Measured memory_bytes: 12528
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    vector<int> n(3);
    for (int i = 0; i < 3; ++i) cin >> n[i];
    sort(n.begin(), n.end(), greater<int>());
    int ans = n[0] * 10 + n[1] + n[2];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n , x , arr[N] , g;
int main(){
   cin >> n >> x;
  for(int i = 0 ; i < n ; i++){
    cin >> arr[i];
  	g = __gcd(abs(x - arr[i]) , g);
  }
  cout << g << endl;
  return 0;
}

Measured memory_bytes: 640
def find(A):
    nums=[0]*(10**6+1)
    bad = [0]*(10**6+1)
    count = 0
    for x in A:
        nums[x] += 1
    for i in range(1,10**6+1):
        if nums[i]==0:
            continue
        for j in range(2,10**6+1):
            temp = i*j
            if temp<10**6+1:
                bad[temp] = 1
            else:
                break
    
    ans = 0
    for x in A:
        if bad[x] == 0 and nums[x] == 1:
            ans +=1
    return ans

input()
A = list(map(int,input().strip().split()))
print(find(A))            
    

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

int n, m, a[1001], nr, sum;

int main() {
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    for(int i = 1; i <= n; i++) {
        if(a[i] * 4 * m >= sum) {
            nr++;
        }
    }
    if(nr >= m) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll inf = 1e18;
ll mod=1e9+7;
//LLONG_MIN

/*
AC
自分自身とのxorは0
*/

ll a,b,ans=0,a2=0;

//O(log(x))解法
// ll xor_sum(ll s){
// 	ll sum=0;
// 	rep(i,40){
// 		bool ok=false;
// 		ll x=(ll)1<<i;
// 		if(i==0){//最下位だけ個別処理（塊の大きさが2の倍数でないため）
// 			if((s+1)/2%2==1)ok=true;
// 		}else if((s/x)%2 == 1 && ((s+1)%x)%2 == 1){
// 			ok=true;
// 		}
// 		if(ok)sum+=x;
// 	}
// 	return sum;
// }

//O(1)別解
ll xor_sum(ll s){
	ll ans;
	switch((s+1)%4){
		case 0:
			ans=0;
			break;
		case 1:
			ans=s;
			break;
		case 2:
			ans=1;
			break;
		case 3:
			ans=s^1;
			break;
	}
	return ans;
}

int main(void){
	cin>>a>>b;
	cout<<(xor_sum(b)^xor_sum(a-1))<<endl;
	return 0;
}

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

const int N=3e5+20;

int n,m,k,x,y,mxr,mxc,r[N],c[N];
vector <int> rows,cols;
set <pair <int,int>> s;

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<k;i++)
	{
		scanf("%d%d",&x,&y);
		r[x]++;
		c[y]++;
		s.insert({x,y});
	}

	for(int i=1;i<=n;i++) mxr=max(mxr,r[i]);
	for(int j=1;j<=m;j++) mxc=max(mxc,c[j]);

	for(int i=1;i<N;i++)
		if(r[i]==mxr) rows.push_back(i);
	for(int j=1;j<=m;j++)
		if(c[j]==mxc) cols.push_back(j);

	for(auto i:rows)
		for(auto j:cols)
			if(s.find({i,j})==s.end()) return 0 * printf("%d",mxr+mxc);
	printf("%d",mxr+mxc-1);
}

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

int a, b, acards[5001], bcards[5001], mx = 0, mxcards[5001], dp1[5001], dp2[5001];

int main()
{
	cin >> a >> b;
	for (int i = 1; i <= a; i++) cin >> acards[i];
	for (int i = 1; i <= b; i++) cin >> bcards[i];

	for (int i = 1; i <= a; i++){
		for (int j = 1; j <= b; j++){
			if (acards[i] == bcards[j]){
				dp2[j] = mxcards[j - 1] + 1;
				mx = max(mx, dp2[j]);
			}
		}
		for (int j = 1; j <= b; j++){
			dp1[j] = dp2[j];
			mxcards[j] = max(mxcards[j], dp2[j]);
		}
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

int main() {
    int h, w;
    cin(h); cin(w);

    vector<vector<char>> a(h, vector<char>(w));
    rep2(i, h) rep2(j, w) cin(a[i][j]);

    vector<vector<int>> dp(h, vector<int>(w, 0));
    queue<pair<int, int>> q;

    dp[0][0] = 1;
    q.push(make_pair(0, 1));
    q.push(make_pair(1, 0));

    while (!q.empty()) {
        int first = q.front().first, second = q.front().second;
        q.pop();

        if (a[first][second] == '#' || dp[first][second] > 0) continue;

        int up = first == 0 ? 0 : dp[first - 1][second];
        int left = second == 0 ? 0 : dp[first][second - 1];

        dp[first][second] = (up + left) % 1000000007;

        // 下のブロックをキューに追加
        if (first + 1 < h) {
            q.push(make_pair(first + 1, second));
        }

        // 右のブロックをキューに追加
        if (second + 1 < w) {
            q.push(make_pair(first, second + 1));
        }
    }

    print(dp[h - 1][w - 1]);
    return 0;
}

Measured memory_bytes: 5248
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    
    vector<vector<ll>> dp(n + 1, vector<ll>(5));
    REP(i, n){
        ll mn = dp[i][0];
        dp[i + 1][0] = mn + a[i];
        mn = min(mn, dp[i][1]);
        dp[i + 1][1] = mn + ((a[i] == 0)? 2 : a[i] % 2);
        mn = min(mn, dp[i][2]);
        dp[i + 1][2] = mn + ((a[i] + 1) % 2);
        mn = min(mn, dp[i][3]);
        dp[i + 1][3] = mn + ((a[i] == 0)? 2 : a[i] % 2);
        mn = min(mn, dp[i][4]);
        dp[i + 1][4] = mn + a[i];
    }
    cout << min({dp[n][0], dp[n][1], dp[n][2], dp[n][3], dp[n][4]}) << endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    vector <int> h(n);
    for(int i=0;i<n;i++)
    {
        cin >> h.at(i);
    }
    stable_sort(h.begin(),h.end());
    int ans=h.at(k-1)-h.at(0);
    for(int i=0;i<n-k+1;i++)
    {
        int a=h.at(i+k-1)-h.at(i);
        ans=min(ans,a);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 768
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Already 2018
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);

  printf("2018/%02d/%02d\n", m, d);
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let (h, w, d): (usize, usize, usize) = (read(), read(), read());
    let mut ans: Vec<Vec<char>> = vec![vec!['R'; w]; h];
    for i in 0..h {
        for j in 0..w {
            let wa = (i + j + 2 * d) % (2 * d);
            let sa = (i + 2 * d * 500 - j) % (2 * d);
            ans[i][j] = if wa < d {
                if sa < d {
                    'R'
                } else {
                    'Y'
                }
            } else {
                if sa < d {
                    'B'
                } else {
                    'G'
                }
            };
        }
    }
    for i in 0..h {
        for j in 0..w {
            print!("{}", ans[i][j]);
        }
        println!();
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


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

const int MAX_N = 1000005;

char s[MAX_N];
int len, num[MAX_N], cnt;

void work() {
  int x = 1;
  cnt -= num[x], num[x] += 9;
  while (num[x] >= 10 && x <= len) {
    cnt -= num[x + 1], num[x + 1] += num[x] / 10;
    num[x] %= 10;
    x++;
  }
  while (num[len + 1]) {
    len++, cnt -= num[len + 1], x++;
    num[len + 1] += num[len] / 10, num[len] %= 10;
  }
  for (int i = 1; i <= x; ++i) cnt += num[i];
}
  
int main() {
  scanf("%s", s + 1), len = strlen(s + 1);
  
  for (int i = 1; i <= len; ++i) num[len - i + 1] = s[i] - '0';
  for (int i = 1; i <= len; ++i) num[i] = num[i] * 9;
  for (int i = 1; i <= len; ++i) {
    num[i + 1] += num[i] / 10;
    num[i] %= 10;
  }
  while (num[len + 1]) {
    len++, cnt -= num[len + 1];
    num[len + 1] += num[len] / 10, num[len] %= 10;
  }
  
  for (int i = 1; i <= len; ++i) cnt += num[i];

  int res = 1;
  
  for ( ; ; res++) {
    work();
    if (cnt <= res * 9) break;
  }

  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 4608
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
    // assert(freopen("output.txt", "w", stdout));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

void solve(bool __attribute__((unused)) read) {
    li n, k;
    cin >> n >> k;
    if (k == 1)
        cout << 0 << endl;
    else
        cout << n - k << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<int> ans;
    for (int i = 0; i < n; i++)
    {
        int b;
        cin >> b;
        if (b - 1 > ans.size())
        {
            cout << -1 << endl;
            return;
        }
        ans.insert(ans.begin() + b - 1, b);
    }
    for (int x : ans)
    {
        cout << x << '\n';
    }
}

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

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[n-1] - a[0]);
  }
}

/*
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String blank = sc.nextLine();
String s = sc.nextLine();
System.out.println();
System.exit(0)
*/


Measured memory_bytes: 21076
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		boolean c = true;

		if (a.length() > 2 && a.length() % 2 == 0) {
			for (int i = 0; i < a.length(); i += 2) {
				String b = a.substring(i, i + 2);
				if (!b.equals("hi"))
					c = false;
				break;
			}
		} else {
			if (!a.equals("hi"))
				c = false;
		}
		System.out.println(c ? "Yes" : "No");
	}
}

Measured memory_bytes: 22608
#include <iostream>
#include <string>
#include <bitset>

using namespace std;
typedef long long ll;

int H,W,K;
string s[10];

int power(int n){
    int t = 1;
    for(int i=0;i<n;i++) t *= 2;
    return t;
}

int main(){
    cin >> H >> W >> K;
    for(int i=0;i<H;i++){
        cin >> s[i];
    }
    int mincut = 1e8;
    for(int i=0;i<power(H-1);i++){
        int cutnum = 0;
        bitset<9> bt(i);
        int team[10];
        team[0] = cutnum;
        for(int j=1;j<H;j++){
            if(bt[j-1]) cutnum++;
            team[j] = cutnum;
        }
        int counter[10];
        int mem[10];
        bool outflag = false;
        for(int t=0;t<10;t++) mem[t] = 0;
        for(int j=0;j<W;j++){
            bool cutflag = false;
            for(int t=0;t<10;t++) counter[t] = 0;
            for(int k=0;k<H;k++){
                if(s[k][j] == '1') counter[team[k]]++;
            }
            for(int t=0;t<10;t++){
                if(counter[t] > K) outflag = true;
            }
            if(outflag) break;
            for(int t=0;t<10;t++){
                if(mem[t] + counter[t] > K) cutflag = true;
            }
            if(cutflag){
                cutnum++;
                for(int t=0;t<10;t++) mem[t] = counter[t];
            }else{
                for(int t=0;t<10;t++) mem[t] += counter[t];
            }
        }
        if(outflag) continue;
        if(cutnum < mincut) mincut = cutnum;
    }
    cout << mincut << endl;
    return 0;
}

Measured memory_bytes: 256
let () = Printf.printf "%d\n" @@
  Scanf.scanf "%d %d %d %d %d" @@ fun a b c d e ->
  let h, s = List.fold_left (fun (x, s) y -> max x ((10 - y mod 10) mod 10), s + (y + 9) / 10 * 10) (0, 0) [a;b;c;d;e] in
  s - h


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    void run() {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for (int i = 0; i < n; i++) {
            int t = scan.nextInt();
            int x = scan.nextInt();
            int y = scan.nextInt();
            if (t < x + y || t % 2 != (x + y) % 2) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 87112
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+5;
int a[N*3],f[N][N],ma[N],t,mx;
struct Node{int x,y,z;}op[N<<2];
int main(){
	int n,n1,ans1=0;scanf("%d",&n),n1=3*n-1;
	for(int i=0;i<=n1;i++)scanf("%d",a+i);
	memset(f,0x8f,sizeof(f)),memset(ma,0x8f,sizeof(ma));
	ma[a[0]]=ma[a[1]]=f[a[0]][a[1]]=f[a[1]][a[0]]=0;
	for(int i=2;i<n1;i+=3){
		if(a[i]==a[i+1]&&a[i]==a[i+2]){ans1++;continue;}
		if(a[i]==a[i+2])swap(a[i+1],a[i+2]);
		if(a[i+1]==a[i+2])swap(a[i+2],a[i]);
		if(a[i]==a[i+1]){
			for(int j=1;j<=n;j++)op[t++]={a[i+2],j,f[j][a[i]]+1},op[t++]={j,a[i],ma[j]},op[t++]={j,a[i+2],ma[j]};
			op[t++]={a[i],a[i],max(f[a[i+2]][a[i+2]]+1,mx)};
		}
		else{
			for(int j=1;j<=n;j++)op[t++]={j,a[i],ma[j]},op[t++]={j,a[i+1],ma[j]},op[t++]={j,a[i+2],ma[j]};
			op[t++]={a[i],a[i+1],max(f[a[i+2]][a[i+2]]+1,mx)};
			op[t++]={a[i],a[i+2],max(f[a[i+1]][a[i+1]]+1,mx)};
			op[t++]={a[i+2],a[i+1],max(f[a[i]][a[i]]+1,mx)};
		}
		while(t--){
			int x=op[t].x,y=op[t].y,z=op[t].z;
			f[x][y]=f[y][x]=max(z,f[x][y]);
			ma[x]=max(ma[x],z),ma[y]=max(ma[y],z),mx=max(mx,z);
		}t++;
	}
	printf("%d",max(mx,f[a[n1]][a[n1]]+1)+ans1);
	return 0;
}

Measured memory_bytes: 19552
#include <stdio.h>

int main(void){
	
	int in = 0;
	
	scanf("%d",&in);
	
	if(in%2 == 0){
		printf("0.5000\n");
	}else{
		printf("%f\n",((double)(in-1)/2.0+1.0) / (double)in);
	}
	
	return 0;
}


Measured memory_bytes: 128
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353



X, N = list(map(int, sys.stdin.buffer.readline().split()))
P = list(map(int, sys.stdin.buffer.readline().split()))


ans = -INF
m = INF
for i in reversed(range(-1000,1000)):
    if i not in P:
        if abs(X - i) <= m:
            m = abs(X-i)
            ans=i
print(ans)


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    int ans;
    ans = x * min(n, k) + y * max((n-k), 0);
    cout << ans << endl;
    return 0;
}


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

int main(){
      int ans = INT_MIN;
      int n;cin >> n;
      int arr[n];
      for(int i = 0;i < n;i++)cin >> arr[i];
      for(int i = 0;i < n - 1;i++){
            for(int j = 1;j < n;j++){
                  ans = max(ans, abs(arr[i] - arr[j]));
            }
      }
      cout << ans;
}

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

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

    int ans = 0, tmp = 0;
    rep(i, s.size()) {
        if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T')
            tmp++;
        else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }

    ans = max(ans, tmp);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import *
from heapq import *
from itertools import *
from fractions import gcd

from decimal import *
import copy
from bisect import *
import time
import sys
import math
input=lambda :sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
N=input()
#A,B=map(int,input().split())
#A=list(map(int,input().split()))
if "7" in N:
    print ("Yes")
else:
    print("No")


Measured memory_bytes: 72732
#include <iostream>

using namespace std;
int N;

int main(){
    cin>>N;
    for(int i=0;7*i<=N;i++){
        if((N-7*i)%4==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main()
{
  int m,a,b;
  int p[401];

  while(1){
    cin>>m>>a>>b;
    if(m+a+b==0)break;
    for(int i=0;i<m;i++)cin>>p[i];
    sort(p,p+m);
    reverse(p,p+m);

    int ans=0,tmp=0;
    for(int i=a;i<=b;i++){
      if(tmp<=p[i-1]-p[i]){
	ans=i;
	tmp=p[i-1]-p[i];
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1176
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    if(s2[0] == s1[s1.length() - 1] && s3[0] == s2[s2.length() - 1]){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

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

int main() {
	string A;
  	cin >> A;
  	string B;
  	cin >> B;
  
  	if(A.at(0) == B.at(2) && A.at(1) == B.at(1) && A.at(2) == B.at(0))
    cout << "YES" << endl;
  	else cout << "NO" << endl;
    
}

Measured memory_bytes: 256