akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
int n;
signed main() {
	cin >> n;
	if (n % 2 == 1) {
		cout << 0 << endl;
	}
	else {
		n /= 2;
		int sum = 0, res = 5;
		for (int i = 1; res <= n; i++) {
			if (i % 2 == 1) {
				sum += n / res;
			}
			else {
				sum += n / res;
			}
			res *= 5;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
k,a,b = map(int,input().split())
from decimal import *
if b-a<=2 or k <= a:
    print(k+1)
else:
    if (k-a+1) % 2 == 0:
        print (Decimal(b-a)*Decimal(k-a+1)/2  + a )
    else:
        print (Decimal(b-a)*Decimal(k-a)/2  + a  + 1)

Measured memory_bytes: 5204
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    long long int a,b,c,d,i,j,k,n,x[10];
    char C1,C2;
    string s;

    cin >> a >> s;
    if(a>=3200) cout << s;
    else cout << "red";


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,m,l;
  cin >> n >> m >> l;
  vector<vector<ll>> dist(310, vector<ll>(310,longinf));
  rep(i,m){
    int a,b;ll c; cin >> a >> b >> c; a--; b--;
    dist[a][b]=c;
    dist[b][a]=c;
  }
  rep(k,n)rep(i,n)rep(j,n){ dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]); }
  vector<vector<int>> times(310, vector<int>(310,inf+10));
  rep(i,n)rep(j,n)if(dist[i][j]<=l){ times[i][j]=1; }
  rep(k,n)rep(i,n)rep(j,n){ times[i][j] = min(times[i][j],times[i][k]+times[k][j]); }

  int q; cin >> q;
  while(q--){
    int s,t; cin >> s >> t; s--; t--;
    int ans = times[s][t]-1;
    if(ans>=inf) ans = -1;
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double X; cin >> X;
    long double money=100;
    for (int i=1;;++i){
        money=floor(money*1.01);
        if (X<=money){cout << i << '\n'; return 0;}
    }
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,a,A[N];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    A[a]++;
  }
  int sum=0;
  for(int i=0;i<N-1;i++)
    if(A[i])sum+=A[i]-1;
  if(sum%2)cout<<n-sum-1<<endl;
  else cout<<n-sum<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define pb push_back

#define INF int(1e9)
#define EPS 1e-9
#define MOD int(1e9 + 7)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	int arr[n], left[n], right[n];
	left[0] = -1;
	right[n - 1] = -1;
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for(int i = 1; i < n; i++) {
		left[i] = max(left[i - 1], arr[i - 1]);
		right[n - 1 - i] = max(right[n - 1 - i + 1], arr[n - 1 - i + 1]);
	}
	for(int i = 0; i < n; i++)
		cout << max(left[i], right[i]) << '\n';
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)

int main()
{
  string s;
  cin >> s;
  int flag = 0;
  rep(i, s.length())
    {
      if(flag == 0 && s[i] == 'C')
	{
	  flag = 1;
	}
      if(flag == 1 && s[i] == 'F')
	{
	  cout << "Yes" << endl;
	  return 0;
	}
    }
  cout << "No" << endl;
  return 0;
}


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

int main(void){
	int n,a,b,c,x,y;
	int frame;

	while(cin>>n>>a>>b>>c>>x && n){
		frame = -1;
		while(n--){
			cin>>y;

			while(x!=y && frame<=10000){
				x = (a * x + b) % c;
				frame++;
			}
			x = (a * x + b) % c;
			frame++;
		}

		if(frame > 10000) frame = -1;
		cout<<frame<<endl;
	}

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    vector<bool> a(26, false);
    for (int j = 0; j < n; j++) {
      if (j <= i) {
        a[s[j] - 'a'] = true;
      }
      else {
        if (a[s[j] - 'a']) {
          tmp++;
          a[s[j] - 'a'] = false;
        }
      }
    }
    if (tmp > ans) {
      ans = tmp;
    }
    for (int j = 0; j < 26; j++) {
      a[j] = false;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int a, b;
		cin >> a >> b;
		cout <<  a / b << endl;
		cout <<  a%b << endl;
		cout << fixed << setprecision(5) << ((double)a) / b << endl;
	return 0;
}

Measured memory_bytes: 1240
main = do
  [n, x] <- fmap (map read . words) getLine
  if [n, x] == [0, 0] then return ()
  else do
    print (length [(a,b,c) | a <- [1..n], b <- [1..n], c <- [1..n],
                             (a+b+c == x) && ((a < b) && (b < c))])
    main

Measured memory_bytes: 4892
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#define rep(i,a,b) for(long long i = a; i <= b; i++)
using namespace std;

int main(){
	//cout << 809*810%2019 << endl;
	long long l,r;
	cin >> l >> r;
	long long m1= 2000000004;
	rep(i,l,min(l+2020, r)){
		rep(j,i+1,min(i+2020, r)){
			m1= min(m1, (i*j)%2019);
		}
	}
	
	cout << (m1)%2019 << endl;
	
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int A[20], B[20], bit[20];

void bitAdd(int n, int a){
	for(int i=n; i<20; i += i&(-i)){
		bit[i] += a;
	}
}

int bitSum(int n){
	int res=0;
	for(int i=n; i>0; i -= i&(-i)){
		res += bit[i];
	}
	return res;
}

int main() {
	int N;
	cin >> N;
	for(int i=1; i<=N; ++i) cin >> A[i];
	for(int i=1; i<=N; ++i) cin >> B[i];
	int ans=-1;
	for(int now=0; now<(1<<N); ++now){
		int cnt=0;
		for(int d=0; d<N; ++d){
			if(now&(1<<d)) ++cnt;
		}
		if(cnt==N/2){
			pair<int, int> ev[10], od[10];
			int k=0;
			for(int d=0; d<N; ++d){
				if(now&(1<<d)){
					if(d%2) od[k]=make_pair(A[d+1], d+1);
					else od[k]=make_pair(B[d+1], d+1);
					++k;
				}else{
					if(d%2) ev[d-k]=make_pair(B[d+1], d+1);
					else ev[d-k]=make_pair(A[d+1], d+1);
				}
			}
			sort(ev, ev+((N+1)/2));
			sort(od, od+(N/2));
			int sum=0, prev=0;
			bool flag=true;
			for(int i=0; i<20; ++i) bit[i]=0;
			for(int i=0; i<N; ++i){
				if(i%2==0){
					if(prev<=ev[i/2].first){
						prev=ev[i/2].first;
						bitAdd(ev[i/2].second, 1);
						sum += ev[i/2].second-bitSum(ev[i/2].second);
					}
					else flag=false;
				}else{
					if(prev<=od[i/2].first){
						prev=od[i/2].first;
						bitAdd(od[i/2].second, 1);
						sum += od[i/2].second-bitSum(od[i/2].second);
					}
					else flag=false;
				}
			}
			if(flag){
				if(ans<0) ans=sum;
				else ans=min(ans, sum);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// Problem : D - Flat Subsequence
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define N 300005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int n,k;
int dp[4*N];
int query(int p,int l,int r,int i,int j)
{
	if(i > r || j < l)
		return 0;
	if(i <= l and r <= j)
		return dp[p];
	int m =(l+r)/2;
	return max(query(2*p,l,m,i,j),query(2*p+1,m+1,r,i,j));
}
void update(int p,int l,int r,int i,int val)
{
	if(i < l || i >r)
		return;
	if(l == r)
	{
		dp[p]=max(dp[p],val);
		return;
	}
	int m =(l+r)/2;
	update(2*p,l,m,i,val);
	update(2*p+1,m+1,r,i,val);
	dp[p]=max(dp[2*p],dp[2*p+1]);
}
void solve()
{
	int n,k;
	cin >>  n>> k;
	int ans=0;
	while(n--)
	{
		int x;
		cin >> x;
		int mx = query(1,0,N,max((int)0,x-k),min((int)N,x+k));
		ans = max(ans,mx+1);
		update(1,0,N,x,mx+1);
	}
	cout << ans;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 11836
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int[] w = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            w[i] = scanner.nextInt();
        }
        Arrays.parallelPrefix(w, Integer::sum);
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            ans = Math.min(ans, Math.abs(w[n] - w[i] - w[i]));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 29512
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second

#define ALL(V)  V.begin(),V.end()

#define MX1     100000LL
#define MX2     1000000LL
#define Inf     1000000000000000LL
#define mod		1000000007LL
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli N,i,H,Sum=0;
    cin>>N>>H;

    vlli a(N),b(N);
    rep(i,0,N)
    {
        cin>>a[i]>>b[i];
    }

    lli Max=*max_element(a.begin(),a.end());

    sort(b.begin(),b.end());

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

    lli cnt=0;
    rep(i,0,N)
    {
        if(b[i]>=Max)
        {
            H-=b[i];
            cnt++;
        }

        if(H<=0LL)
        {
            cout<<cnt;
            exit(0);
        }
    }

    if(H%Max)
    {
        cnt++;
    }

    lli Ans=cnt+H/Max;

    cout<<Ans;



 return 0;
}


Measured memory_bytes: 1792
#!python3

def iim():
    return map(int, input().rstrip().split())

from fractions import gcd

def nbit(x):
    if x == 0: return 0

    n = 0
    while x & 1 == 0:
        x >>= 1
        n += 1
    return n

def resolve():
    N, M = iim()
    a = list(iim())

    y = a[0]
    nb = nbit(y)
    for x in a[1:]:
        if nbit(x)  != nb:
            print(0)
            return

        y *= x // gcd(y, x)


    print((M+y//2)//y)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 16308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll> >;

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

int main(){
    ll n; string s;
    cin >> n >> s;
    ll R = 0,G = 0,B = 0, cnt = 0;
    rep(i, n){
        if(s[i] == 'R') R++;
        else if(s[i] == 'G') G++;
        else if (s[i] == 'B') B++;
    }

    for(int i = 0; i < n-2; i++){
        for(int j = 1; i + j * 2 < n; j++){
               if(s[i] != s[i+j] && s[i+j] != s[i+j*2] && s[i] != s[i+j*2]) cnt++;
        }
    }

    cout << R*G*B - cnt << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int main(){
	ll a,b,ans;
	cin>>a>>b;
	if(a==1||b==1) ans=1;
	else if(a%2==1&&b%2==1) ans=(a*b+1)/2;
	else ans=a*b/2;
	cout<<ans;
	return 0;
} 

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

int main(){
  
  int N; cin >> N;
  vector<int> H(N);
  for (int i=0;i<N;i++) cin >> H.at(i);
  
  int ans = 1;
  int max = H.at(0);
  
  for (int i=1;i<N;i++){
    if (H.at(i) >= max){
      max = H.at(i);
      ans ++;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, k;
  cin >> n >> k;
  ll arr[n + 5];
  for (ll i = 1; i <= n; i++)
    cin >> arr[i];

  map<ll, ll> par;

  ll dp[n + 5];
  dp[n + 1] = 0;
  arr[n + 1] = inf;
  ll max1 = 0;
  for (ll i = n; i >= 1; i--) {
    if (arr[i] < arr[i + 1])
      dp[i] = dp[i + 1] + 1;
    else
      dp[i] = 1;
    max1 = max(max1, dp[i]);
  }

  for (ll i = 1; i <= k; i++)
    par[arr[i]];

  ll res = 0;
  if (dp[1] < k)
    res++;
  for (ll i = k + 1; i <= n; i++) {

    if (arr[i - k] == par.begin()->first) {
      if (arr[i] > par.rbegin()->first) {
      } else {
        if (dp[i - k + 1] < k)
          res++;
      }

    } else {
      if (dp[i - k + 1] < k)
        res++;
    }
    par.erase(arr[i - k]);
    par[arr[i]];
  }

  if (max1 >= k)
    res++;

  cout << res << en;

  return 0;
}

Measured memory_bytes: 15872
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include "bits/stdc++.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    ost;
#define rep(i,l,r)   for (int i = (l); i < (r); i++)
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
template <typename T>
void etch(T V) {
	for (auto x : V)	cout << x << ' ' ;
	cout << '\n';
}
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;

int32_t main()
{
	SYNC
	int n; cin >> n;
	vi v(n);
	rep(i,0,n) {
		cin >> v[i];
	}
	sort(all(v));
	int ans = 0;
	rep(i,0,n) {
		rep(j,i+1, n) {
			rep(k,j+1, n) {
				if (v[i]+v[j] > v[k] && v[j] > v[i] && v[k] > v[j]) {
					ans++;
				}
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>

#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INPUT1(n, a) for(int i##n = 0; i##n < n; i##n++) {cin >> a[i##n]; } //n = count, a = vector 
#define OUTPUT1(n, a) cout << "---count---" << endl << n << endl << "---content---" << endl; for(const auto b : a){cout << b << endl; }
#define INPUT2(x, y, field) for(int i##x = 0; i##x < y; i##x++) { for(int j##x = 0; j##x < x; j##x++) { cin >> field[i##x][j##x]; } }
#define OUTPUT2(x, y, field) cout << "---count---" << endl << x << " " << y << endl <<"---content---" << endl; for(int i##x = 0; i##x < y; i##x++) { cout << i##x << "   "; for(int j##x = 0; j##x < x; j##x++) { cout << field[i##x][j##x] << " "; } cout << endl; }

using namespace std;
using ll = long long;

const int INF = 1001001001;

int main()
{
	int a(0), b(0), x(0), y(0);
	
	cin>>a>>b;
	
	if(a>b)cout<<"-1";
	else{
	    rep(i, 1001){
	        x = i * 0.08;
	        y = i * 0.1;
	        
	        if(a == x && b == y){
	            cout<<i;
	            return 0;
	        }
	    }
	}
	
	cout<<"-1";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

class UnionFind{
  public:
    vector<int> par;
    vector<int> rank;
    vector<int> cnt;
    UnionFind(int N): par(N), rank(N), cnt(N){
      for(int i = 0; i < N; i++){
        par[i] = i;
        rank[i] = 0;
        cnt[i] = 1;
      }
    }
    void init(int N){
      par.resize(N); rank.resize(N); cnt.resize(N);
      for(int i = 0; i < N; i++){
        par[i] = i;
        rank[i] = 0;
        cnt[i] = 1;
      }
    }
    int Findroot(int x){
      if(par[x] == x)return x;
      return par[x] = Findroot(par[x]);
    }
    void merge(int x, int y){
      x = Findroot(x);
      y = Findroot(y);
      if(x == y) return;
      if(rank[x] < rank[y]){
        par[x] = y;
        cnt[y] += cnt[x];
      }
      else{
        par[y] = x;
        cnt[x] += cnt[y];
        if(rank[x] == rank[y]) rank[x]++;
      }
    }
    bool is_same(int x, int y){
      return Findroot(x) == Findroot(y);
    }
    int size(int x){
      return cnt[Findroot(x)];
    }
};

int main()
{
  int n, m, k; cin >> n >> m >> k;
  UnionFind uf(n);
  vector<int> v(n, 0);
  rep(i, m){
    int a, b; cin >> a >> b;
    a--; b--;
    uf.merge(a, b);
    v[a]++; v[b]++;
  }
  rep(i, k){
    int a, b; cin >> a >> b;
    a--; b--;
    if(uf.is_same(a, b)){
      v[a]++;
      v[b]++;
    }
  }
  rep(i, n){
    cout << uf.size(i)-1-v[i] << " ";
  }
  cout << endl;
  system("pause");
}


Measured memory_bytes: 2680
N = int(input())
S = input()
T = input()
mod = int(1e9) + 7
L = []
cnt = 0
while cnt != N:
  if S[cnt] == T[cnt]:
    L.append(1)
    cnt += 1
  else:
    L.append(2)
    cnt += 2
dp = [0 for _ in range(55)]
dp[0] = 1
for i in range(len(L)):
  if i == 0:
    dp[i+1] = 3 * L[i]
  else:
    if L[i] != L[i-1]:
      dp[i+1] = (dp[i] * L[i]) % mod
    else:
      dp[i+1] = (dp[i] * (1 + L[i])) % mod
print(dp[len(L)])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
 
int main(){
    int h, a;
    cin >> h >> a;

    if (h % a ==0) cout << h / a << endl;
    if (h % a !=0) cout << h / a + 1 << endl;
 
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 105
using namespace std;
int n,x,ans=0,a[N];
int main(){
	scanf("%d%d",&n,&x);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++){
		if (i==n){
			if (a[i]==x) ans++;
			break;
		}
		if (a[i]<=x) ans++,x-=a[i];
	} 
	printf("%d\n",ans);
} 

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
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; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main ()
{
  int N,K;cin>>N>>K;
  vector<ll> h(N);
  REP(i,N) cin>>h[i];
  vector<ll> ans(N,INF);
  ans[0] = 0;
  for(int i = 1;i < N;i++){
      for(int j = max(i-K,0);j<i;j++){
          ll comp = ans[j] + abs(h[i]-h[j]);
          ans[i] = min(ans[i],comp);
      }
  }
  //REP(i,N) cout<<ans[i]<<endl;
  cout<<ans[N-1]<<endl;
  return 0;
}

Measured memory_bytes: 1792
<?php
    $building = array_fill(1,4, array_fill(1,3, array_fill(1,10,0)));
    $record_num = trim(fgets(STDIN));
    
    for($i = 0; $i < $record_num; $i++){
        list($b, $f, $r, $v) = explode(" ",trim(fgets(STDIN)));
        $building[$b][$f][$r] += $v;    
    }
    
    foreach($building as $key1 => $value1){
        foreach($value1 as $key2 => $value2){
            print " ".implode(" ",$value2)."\n";
        }
        if($key1 < 4) print str_repeat("#",20)."\n";
    }

Measured memory_bytes: 15424
#include <bits/stdc++.h>
using namespace std;
int dp[200005][2];
char ss[200005];
int main(){
	cin>>ss+1;
	int Len=strlen(ss+1);
	dp[0][0]=0;
	dp[1][0]=1;
	//cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<endl;
	for (int i=2;i<=Len;i++){
		dp[i][0]=max(dp[i-1][1]+1,dp[i][0]);
		if (ss[i]!=ss[i-1]) dp[i][0]=max(dp[i-1][0]+1,dp[i][0]);
		dp[i][1]=max(dp[i-2][0]+1,dp[i][1]);
		if (ss[i]!=ss[i-2]&&ss[i-1]!=ss[i-3]) dp[i][1]=max(dp[i-2][1]+1,dp[i][1]);
	}
	cout<<max(dp[Len][0],dp[Len][1]);
	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
using namespace std;
int main(){
  int a,b;
  int day[12] = {0,3,4,0,2,5,0,3,6,1,4,6};
  while(cin >>a>>b,a||b){
    b+=day[a-1];
    switch(b%7){
    case 0:
      cout <<"Wednesday"<<endl;
      break;
    case 1:
      cout <<"Thursday"<<endl;
      break;
    case 2:
      cout <<"Friday"<<endl;
      break;
    case 3:
      cout <<"Saturday"<<endl;
      break;
    case 4:
      cout <<"Sunday"<<endl;
      break;
    case 5:
      cout <<"Monday"<<endl;
      break;
    case 6:
      cout <<"Tuesday"<<endl;
      break;
    }
  }
}

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

template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

/*
 * 2次元幾何ライブラリ
 *
 *
 * 誤差の対応
 * a < 0 --> a < -eps
 * a <= 0 --> a < eps
 * a == 0 -> abs(a) < eps
 */

//---------- Copy from here ----------

// 必要なければ0にする
constexpr double eps = 1e-10;


template<typename T=int>
struct Point{
    T x,y;
    Point(){}
    Point(T x, T y) : x(x), y(y){} 

    friend ostream& operator << (ostream& os, const Point<T> &p){
        return os << "(" << p.x << "," << p.y << ")";
    }
};

// 比較
template<typename T>
inline bool operator < (const Point<T> &p1, const Point<T> &p2){
    return abs(p1.x-p2.x) > eps ? (p1.x < p2.x)
                                : (p1.y < p2.y);
}

// ベクトル
template<typename T> using Vector = Point<T>;

// 基本演算
template<typename T>
inline Vector<T> operator - (const Vector<T> &v1, const Vector<T> &v2){
    return Vector<T>(v1.x-v2.x, v1.y-v2.y);
}

// 外積 v1 x v2
template<typename T> 
T cross(const Vector<T> &v1, const Vector<T> &v2){
    return v1.x * v2.y - v1.y * v2.x;
}


// 凸包
// 第2引数の contain_on_the_line は凸包上の3点 a->b->cが直線上にある場合に、
// bを凸法に含むかどうかを決める. trueの場合はbも凸包に含み、falseの場合は含まない
template<typename T>
vector<Point<T>> convex_hull(vector<Point<T>> ps, bool contain_on_the_line = true){
    int n = ps.size();
    sort(ps.begin(), ps.end());

    // cvは外積の値
    auto judge = [contain_on_the_line](const T cv) -> bool {
        if(is_floating_point<T>::value){ // 型Tが不動小数点の場合は誤差に注意にする
            if(contain_on_the_line){ // 直線上の点を含む
                return cv < -eps; // cv < 0 に誤差を追加
            }else{
                return cv < eps;
            }
        }else{
            if(contain_on_the_line){
                return cv < 0;
            }else{
                return cv <= 0;
            }
        }
    };

    vector<Point<T>> res(2*n);
    int k = 0;
    for(int i=0;i<n;i++){
        while(k>=2 && judge(cross(res[k-1]-res[k-2], ps[i]-res[k-1]))){
            k--;
        }
        res[k++] = ps[i];
    }

    for(int i=n-2, t=k; i>=0;i--){
        while(k > t && judge(cross(res[k-1]-res[k-2], ps[i]-res[k-1]))){
            k--;
        }
        res[k++] = ps[i];
    }
    res.resize(k-1);
    return res;
}

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

int main(){
    int n; cin >> n;
    vector<Point<int>> ps(n);
    for(int i=0;i<n;i++){
        int x,y; cin >> x >> y;
        ps[i] = Point<>(x,y);
    }

    auto convex = convex_hull(ps);

    int startid = -1;
    int x,y;
    x = 100000;
    y = 100000;

    int m = convex.size();
    for(int i=0;i<m;i++){
        auto &p = convex[i];
        if(p.y < y){
            startid = i;
            x = p.x;
            y = p.y;
        }else if(p.y == y && p.x < x){
            startid = i;
            x = p.x;
            y = p.y;
        }
    }

    cout << m << endl;
    for(int i=0;i<m;i++){
        int id = (startid + i) % m;
        cout << convex[id].x << " " << convex[id].y << endl;
    }
}



Measured memory_bytes: 4576
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(i, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    int A = In<int>();
    int B = In<int>();
    int C = In<int>();
    cout << max(0, C - A + B)  << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll x, y; cin >> x >> y;
    cout << x+(y/2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int A,B;
  char op;
  cin>>A>>op>>B;

  if(op=='+'){
    cout<<A+B<<endl;
  }else{
    cout<<A-B<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
shop = []
for _ in range(n):
    a, b = map(int, input().split())
    shop.append([a, b])

shop = sorted(shop)
ans, num = 0, 0
for i in range(n):
    a, b = shop[i]
    num += b
    ans += a*b
    if num>=m:
        ans -= (num-m)*a
        break

print(ans)

Measured memory_bytes: 20832
n, d = map(int, input().split())
xy_list = [list(map(int, input().split())) for i in range(n)]

d = d ** 2

d_list = []
for i in range(n):
  d_list.append(xy_list[i][0] ** 2 + xy_list[i][1] ** 2)
  
a = 0
  
for i in range(n):
  if d_list[i] <= d:
    a += 1
    
print(a)

Measured memory_bytes: 56332
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
#define sp cout<<"---------------------------------------------------"<<endl;
#define foreach(i,dat) for(__typeof(dat.begin()) i = dat.begin();i!=dat.end();++i)
const int inf=1e9+7;
struct node {
	  int p,b,c;
};
inline bool operator < (node x,node y){return x.c>y.c;}
map<int,vector<int> >e[100100];
vector<int>v[100100];
map<int,int>d[100100];
priority_queue<node>q;
int main(){
      int n,m,i,x,y,z;
      scanf("%d%d",&n,&m);
	  for(i=1;i<=m;i++){
	  	scanf("%d%d%d",&x,&y,&z);
	  	x--,y--;
	  	e[x][z].push_back(y);
	  	e[y][z].push_back(x);
	  	v[x].push_back(z);
	  	v[y].push_back(z);
	  }
	  q.push({0,0,0});;
	  d[0][0]=0;
	  while(!q.empty()){
	  	node p=q.top();
	  	q.pop();
	  	if(d[p.p][p.b]!=p.c)continue;
	  	if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){
	  	  d[p.p][0]=p.c;
	  	  q.push({p.p,0,p.c});
	    }
	    if(!p.b){
	      for(i=0;i<(int)v[p.p].size();i++)
	        if(d[p.p].find(v[p.p][i])==d[p.p].end()||d[p.p][v[p.p][i]]>p.c+1){
	          d[p.p][v[p.p][i]]=p.c+1;
	          q.push({p.p,v[p.p][i],p.c+1});
	        }
	      continue;
	    }
	    for(i=0;i<(int)e[p.p][p.b].size();i++)
	      if(d[e[p.p][p.b][i]].find(p.b)==d[e[p.p][p.b][i]].end()
		     ||d[e[p.p][p.b][i]][p.b]>p.c){
	      	d[e[p.p][p.b][i]][p.b]=p.c;
	      	q.push({e[p.p][p.b][i],p.b,p.c});
	      }
	  }
	  int ans=inf;
	  for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++)
	    ans=min(ans,it->second);
	  if(ans==inf)puts("-1");
	    else printf("%d\n",ans);
	  return 0;
}


Measured memory_bytes: 84912
#include <iostream>
#include <cstdio>
#define REP(i,n) for (i=0; i<n; i++)
using namespace std;
int main () {
  int n, i;
  cin >> n;
  int a[10000];
  REP(i,n) {
    cin >> a[i];
  }

  int min = 10000000;
  int max = -10000000;
  long long total = 0;
  REP(i,n) {
    if (min > a[i]) {
      min = a[i];
    }
    if (max < a[i]) {
      max = a[i];
    }
    total += a[i];
  }
  cout << min << " " << max << " " << total << endl;

  return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    long double n, k; cin >> n >> k;
    vector<ll> len(n);
    REP(i, n){
        int j = i + 1;
        int count = 0;
        while (true)
        {   
            count++;
            if(j >= k) break;
            else j *= 2;
        }
        len[i] = count;
    }

    long double ans = 0, a = 1 / n;
    REP(i, n){
        long double preans = 0.5;
        REP(j, len[i] - 1) preans *= 0.5; 
        ans += (1 / n) * preans;
    }
    cout << setprecision(10) << ans * 2 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i(0);i<n;i++)
const int INF = 1001001001;

using namespace std;
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	if(n%2==0 && s.substr(0,n/2) == s.substr(n/2)) cout << "Yes" << endl;
	else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
signed main(){
    int a,c;
    char b;
    while(cin>>a>>b>>c,b!='?'){
	switch(b){
	    case '+':printf("%d\n",a+c);break;
	    case '-':printf("%d\n",a-c);break;
	    case '*':printf("%d\n",a*c);break;
	    default:printf("%d\n",a/c);break;
	    }
	}
}

Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    #ifdef LOCAL_DEBUG
    freopen("text.in","r",stdin);
    freopen("text.out","w",stdout);
    #endif // LOCAL_DEBUG
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        if(s[i]=='1')
            cout<<'9';
        else
            cout<<'1';
    cout<<endl;
    return 0;
}


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

#define ll long long
#define vll vector<ll>
#define vvll vector<vll>
#define rep(i, n) for(i = 0; i < n; i++)

int main(){
    string s;
    string k = "keyence";
    cin >> s;
    int i, j;
    if (s.size() < 7) {
        cout << "NO" << '\n';
        return 0;
    }
    bool flg = true;
    rep(i, 8) {
        flg = true;
        rep(j, i) {
            flg = flg and (k[j] == s[j]);
            // if (i == 7) cout << flg << endl;
        }
        rep(j, 7 - i) {
            flg = flg and (k[6-j] == s[s.size() - j - 1]);
        }
        
        if (flg) {
            cout << "YES" << '\n';
            return 0;
        }
    }

    cout << "NO" << '\n';

    return 0;
}

Measured memory_bytes: 3616
package main

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

func main() {
	sc := NewScanner()

	const MaxA = 1_000_000

	n := sc.ReadInt()
	uniqueN := n
	isPairwise := true
	aHas := make([]bool, MaxA+1)
	for i := 0; i < n; i++ {
		ai := sc.ReadInt()
		if aHas[ai] {
			// dup
			uniqueN--
			if ai > 1 {
				isPairwise = false
			}
		} else {
			aHas[ai] = true
		}
	}

	sieve := make([]bool, MaxA+1)
	for i := 2; i <= MaxA/2; i++ {
		if sieve[i] {
			continue
		}

		count := 0
		for j := i; j <= MaxA; j += i {
			sieve[j] = true
			if aHas[j] {
				count++
			}
		}

		if count > 1 {
			isPairwise = false
		}
		if count >= uniqueN {
			fmt.Println("not coprime")
			return
		}
	}

	if isPairwise {
		fmt.Println("pairwise coprime")
	} else {
		fmt.Println("setwise coprime")
	}
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 6164
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

vector<int> MakePrimeNumber(int);
int Calculate(const vector<int>, int);

int main(){
  int a, b, a_ans, b_ans;
  vector<int> data;

  data = MakePrimeNumber(1000000);

  while(1){
    cin >> a >> b;
    if(a == 0 && b == 0) break;

    a_ans = Calculate(data, a);
    b_ans = Calculate(data, b);

    if(a_ans > b_ans) cout << "a" << endl;
    else cout << "b" << endl;
  }
  return 0;
}

vector<int> MakePrimeNumber(int n){
  int i, j, k;
  vector<int> data;

  data.push_back(2);
  data.push_back(3);
  for(i=5; i<=n; i+=2){
    for(j=1, k=0; data[j]<=sqrt(i); ++j){
      if(i%data[j] == 0){
        k = 1;
        break;
      }
    }
    if(k == 0) data.push_back(i);
  }
  return data;
}

int Calculate(const vector<int> data, int x){
  int i, sum, max;
  i = 0;
  sum = 0;
  max = 0;
  while(i<data.size()){
    if(x % data[i] == 0){
      sum += max;
      max = data[i];
      while(x % data[i] == 0) x /= data[i];
      if(x == 1) break;
    }else{
      ++i;
    }
  }
  return max - sum;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
ll yo(const ll n) 
{ 
    // Modulus operator are expensive on most of the  
    // computers. n & 3 will be equivalent to n % 4.    
  
    switch(n & 3) // n % 4  
    { 
    case 0: return n;     // if n is multiple of 4 
    case 1: return 1;     // If n % 4 gives remainder 1   
    case 2: return n + 1; // If n % 4 gives remainder 2     
    case 3: return 0;     // If n % 4 gives remainder 3   
    } 
} 
void solve()
{
    ll a,b;
    cin>>a>>b;
    if(a!=0)
        a--;
    cout<<(yo(b)^yo(a));
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3652
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;


#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))
#define sq5(x) ((x) * (x) * (x) * (x) * (x))

int main(void) {
	int n;
	scanf("%d", &n);
	ll cnt = 0;

	for (int a = 1; a < n; a++) {
		cnt += (n - 1) / a;
	}

	printf("%lld\n", cnt);
}

Measured memory_bytes: 3836
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (is_prime(a[i])) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int x, y, b, p;
		cin >> x >> y >> b >> p;
		int A = x * b + y * p;
		int B = x * max(b, 5) + y * max(p, 2);
		B = B / 5 * 4;
		cout << min(A, B) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int INF = 1e9;
const int MOD = INF+7;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
using P = pair<int,int>;
//d

signed main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;

    int left = 0,right = 0;
    int ans = 0;
    int cnt = K;
    while(left < S.size() && right < S.size()){

        while(cnt > 0 && left < S.size() && right < S.size()){
            while(S[right] == '0' && right < S.size()) right++;
            if(right == 0) cnt++;
            while(S[right] == '1' && right < S.size()) right++;
            cnt--;
        }

        ans = max(ans,right-left);
        //cout << right << " " << left << endl;
        bool zero = false;
        while(cnt == 0 && left < S.size()){
            if(S[left] == '0') zero = true;
            left++;
            if(S[left] == '1' && zero) cnt++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
def main():
    N  = int(input())
    R = [[] for i in range(N)]
    for i in range(N):
        A = int(input())
        R[i] = [list(map(int, input().split())) for i in range(A)]
    ans = 0
    for i in range(1<<N):
        CNT = 0
        for j in range(N):
            if not (i>>j & 1):
                continue
            CNT += 1
            for x, y in R[j]:
                if y == 1 and (i>>(x-1) & 1):
                    continue
                elif y == 0 and (not (i>>(x-1) & 1)):
                    continue
                else:
                    CNT = 0
                    break
            else:
                continue
            break

        ans = max(ans, CNT)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9212
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    System.out.println(Math.min(a, b) + Math.min(c, d));
  }
}


Measured memory_bytes: 35840