akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 1000050
char s[N],t[N];
int n,su[5],fg,v,ct,s1[N],s2[N],ed[N],is;
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;i++)if(s[i]!=s[i-1])t[++v]=s[i],su[s[i]-'A'+1]++;
	if(su[1]<su[2]&&su[1]<su[3])fg=1;
	else if(su[2]<su[3])
	{
		fg=2;
		for(int i=1;i<=v;i++)if(t[i]=='A')t[i]='B';else if(t[i]=='B')t[i]='A';
		su[1]^=su[2]^=su[1]^=su[2];
	}
	else
	{
		fg=3;
		for(int i=1;i<=v;i++)if(t[i]=='A')t[i]='C';else if(t[i]=='C')t[i]='A';
		su[1]^=su[3]^=su[1]^=su[3];
	}
	is=(t[v]=='A');
	ct=1;
	for(int i=1;i<=v;i++)
	if(t[i]=='A')ct++;
	else if(t[i]=='B')s1[ct]++,ed[ct]=1;
	else s2[ct]++,ed[ct]=2;
	int v1=su[2]-su[1],v2=su[3]-su[1];
	for(int i=1;i<=ct;i++)
	{
		if(v1>0&&v2>0)
		{
			int st=min(v1,v2),st2=min(s1[i],s2[i]);
			if(s1[i]==s2[i]&&(1<i&&i<v))st2--;
			st2--;
			if(st2<0)st2=0;
			st=min(st,st2);
			v1-=st,v2-=st,s1[i]-=st,s2[i]-=st;
		}
	}
	for(int i=1;i<=ct;i++)
	{
		if(v1>0&&v2>0)
		{
			int st=min(v1,v2),st2=min(s1[i],s2[i]);
			if(s1[i]==s2[i]&&(1<i&&i<v))st2--;
			if(st2<0)st2=0;
			st=min(st,st2);
			v1-=st,v2-=st,s1[i]-=st,s2[i]-=st;
		}
		if(v1>v2){int tp=min(s1[i]+s2[i]-(1<i&&i<v),s1[i]-s2[i]+1);if(v1<tp)tp=v1;if(s1[i]<tp)tp=s1[i];if(tp<0)tp=0;s1[i]-=tp,v1-=tp;}
		else if(v1<v2){int tp=min(s1[i]+s2[i]-(1<i&&i<v),s2[i]-s1[i]+1);if(v2<tp)tp=v2;if(s2[i]<tp)tp=s2[i];if(tp<0)tp=0;v2-=tp,s2[i]-=tp;}
	}
	for(int i=1;i<=ct;i++)
	if(v1>v2){int tp=min(s1[i]+s2[i]-(1<i&&i<v),s1[i]-s2[i]+1);if(v1<tp)tp=v1;if(s1[i]<tp)tp=s1[i];if(tp<0)tp=0;s1[i]-=tp,v1-=tp;}
	else {int tp=min(s1[i]+s2[i]-(1<i&&i<v),s2[i]-s1[i]+1);if(v2<tp)tp=v2;if(s2[i]<tp)tp=s2[i];if(tp<0)tp=0;v2-=tp,s2[i]-=tp;}
	if(v1)
	{
		if(s1[1]==1&&s2[1]==0)v1--,s1[1]--;
		if(s1[ct]==1&&s2[ct]==0&&v1)s1[ct]--,v1--,is=1;
		int tp=v1,tp2=v1;
		for(int i=1;i<=ct;i++)if(s1[i]==1&&s2[i]==0&&tp)s1[i]=0,tp--;
		for(int i=1;i<=ct;i++){int fg=min(tp2,min(s1[i],s2[i]-1));if(fg<0)fg=0;s1[i]-=fg,s2[i]-=fg,tp2-=fg;}
	}
	if(v2)
	{
		if(s2[1]==1&&s1[1]==0)v2--,s2[1]--;
		if(s2[ct]==1&&s1[ct]==0&&v2)s2[ct]--,v2--,is=1;
		int tp=v2,tp2=v2;
		for(int i=1;i<=ct;i++)if(s1[i]==0&&s2[i]==1&&tp)s2[i]=0,tp--;
		for(int i=1;i<=ct;i++){
		int fg=min(tp2,min(s1[i]-1,s2[i]));if(fg<0)fg=0;
		s1[i]-=fg,s2[i]-=fg,tp2-=fg;}
	}
	for(int i=1;i<=ct;i++)
	{
		if(s1[i]+s2[i]&&i>1)printf("%c",'A'+fg-1);
		if(s1[i]>s2[i])
		{
			for(int j=1;j<=s2[i];j++)
			printf("%c",fg==2?'A':'B'),
			printf("%c",fg==3?'A':'C');
			printf("%c",fg==2?'A':'B');
		}
		else if(s1[i]<s2[i])
		{
			for(int j=1;j<=s1[i];j++)
			printf("%c",fg==3?'A':'C'),
			printf("%c",fg==2?'A':'B');
			printf("%c",fg==3?'A':'C');
		}
		else if(ed[i]==2)
		for(int j=1;j<=s2[i];j++)
		printf("%c",fg==2?'A':'B'),
		printf("%c",fg==3?'A':'C');
		else 
		for(int j=1;j<=s2[i];j++)
		printf("%c",fg==3?'A':'C'),
		printf("%c",fg==2?'A':'B');
	}
	if(is)printf("%c",'A'+fg-1);
}//乱搞大法好

Measured memory_bytes: 14080
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(int i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(int i=(s), i##_len=(n); i<i##_len; ++i)


using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<int, int> a, pair<int, int> b) {
    return a.second > b.second;
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll A, B;
    cin >> A >> B;
    cout << (B-1+A-2)/(A-1) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
	long i,m,n,mi;
	cin >> n >> m;
	long ans=n,h[n],good[n],a,b;
	for (i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		if (h[a-1]==h[b-1]){
			if (good[a-1]!=1){
			 good[a-1]=1;
			 ans--;
		 }
		 if (good[b-1]!=1){
			good[b-1]=1;
			ans--;
		}
			continue;
		}
		if (h[a-1]>h[b-1]) mi=b;
			else mi=a;
		if (good[mi-1]!=1){
		 good[mi-1]=1;
		 ans--;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4696
#include <stdio.h>
int main()
{
	int i;
	int tmp=0;
	char str[11];
	int count=0;
	int arr[11]={0,0,0,0,0,0,0,0,0,0,0};
	
	scanf("%s",&str);
	for(i=0;i<11;i++)
	{
		if(str[i]=='A'||str[i]=='C'||str[i]=='G'||str[i]=='T')
		{
			count++;
		}
		
		else
		{
			arr[tmp]=count;
			count=0;
			tmp++;
		}
	}
	
	count=arr[0];
	for(tmp=1;tmp<10;tmp++)
	{
		if(count<arr[tmp])
		{
			count=arr[tmp];
		}
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Shift only
 */

#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 */

const int MAX_N = 200;
const int INF = 1 << 30;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int minc = INF;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);

    int c = 0;
    while (! (ai & 1)) c++, ai >>= 1;
    if (minc > c) minc = c;
  }

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


Measured memory_bytes: 256
import sys
import bisect
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = list(map(int, [i for i in S()]))

ID = [[] for _ in range(10)]
for i in range(N):
  ID[s[i]].append(i)

cnt = 0
for a in range(10):
  n1 = bisect.bisect_left(ID[a], 0)
  if n1 == len(ID[a]):
    continue
  for b in range(10):
    n2 = bisect.bisect_left(ID[b], ID[a][n1]+1)
    if n2 == len(ID[b]):
      continue
    for c in range(10):
      n3 = bisect.bisect_left(ID[c], ID[b][n2]+1)
      if n3 == len(ID[c]):
        continue
      cnt += 1
      #print(a,b,c)
print(cnt)

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

using namespace std;

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

	int res = 1e9;
	int cnt = 0;
	int n;
	string s;

	cin >> n;
	cin >> s;

	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')
		{
			cnt++;
		}
	}

	if(cnt==0)
	{
		cout << 0 << '\n';
		return 0;
	}
	
	int cnt2 = 0;

	for(int i=0;i<n;i++)
	{
		if(cnt==0)
		{
			break;
		}
		if(s[i]=='W')
		{
			cnt2++;
		}
		cnt--;
		res = min(res,cnt+cnt2);
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 3768
import Control.Applicative
import Control.Monad
import Data.List
import Text.Printf

readInts :: IO [Int]
readInts = map read . words <$> getLine

main :: IO ()
main = do
  [a, b] <- readInts
  let (d, r, f) = solve a b
  printf "%d %d %f\n" d r f

solve :: Int -> Int -> (Int, Int, Double)
solve a b = (d, r, f)
 where
  (d, r) = a `quotRem` b
  f = fromIntegral a / fromIntegral b



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

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#nclude<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pii pair<int,ll>
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 1000000007
#define pai acos(-1)
#define mx 1000000000
#define N 2005

bool ck(ll n){
    vector<ll>vc;
    while(n){
        vc.pb(n%10);
        n/=10;
    }
    for(int i=0;i<vc.size()-1;i++){
        if(abs(vc[i+1]-vc[i])>=2) return 0;
    }
    return 1;
}


int main ()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
//    freopen("in.txt","r",stdin);
//   freopen("out.txt","w",stdout);
    set<ll>st;
    int k;
    ll x,aa,bb,cc;
    cin>>k;
    for(ll i=1;i<=9;i++) st.insert(i);
    auto it=st.begin();
    while(st.size()<100000){
        x=*it%10;
        aa=(*it)*10+x;
        bb=(*it)*10+(x+1);
        cc=(*it)*10+(x-1);
        if(ck(aa)) st.insert(aa);
        if(ck(bb)) st.insert(bb);
        if(ck(cc)&&cc>=1) st.insert(cc);
        it++;
    }
    int cnt=0;
     for(auto xx:st){
        cnt++;
        if(cnt==k){
            cout<<xx<<endl;
        }
     }


    return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000+3)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll kaijo[1000010];
ll kaijosize=1000010;

void init() {
	kaijo[0] = 1;
	for (ll i = 1;i < kaijosize;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x,ll power) {
	ll res = 1;
	ll k = power;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

int main(void){
    init();
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        ll x,d,n;
        cin>>x>>d>>n;
        if(x==0){
            cout<<0<<endl;
            continue;
        }
        if(d==0){
            cout<<inv(x,n)<<endl;
            continue;
        }
        ll d1=inv(d,n);
        ll f=x*inv(d,N-2)%N;
        if(f+n-1>=N)cout<<0<<endl;
        else{
            cout<<(((d1*kaijo[f+n-1])%N)*inv(kaijo[f-1],N-2))%N<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8832
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  const lines_array = lines[0].split(" ").map(x => Number(x))
  var ary = []
  const first = String(lines_array[0]).repeat(lines_array[1])
  const second = String(lines_array[1]).repeat(lines_array[0])
  ary.push(first)
  ary.push(second)
  ary.sort()
  console.log(ary.shift())
});

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, w; };
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
ll e10 = 1e10 + 10;
double EPS = 1e-10;
 
int main() {
	int N; cin >> N;
	vector<vector<int> > G(N);
	rep(i, N - 1) {
		int a, b; scanf("%d%d", &a, &b);
		a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	vector<int> d(N, -1);
	priority_queue<i_i, vector<i_i>, greater<i_i> > pq;
	int K; cin >> K;
	while (K--) {
		int v, p; scanf("%d%d", &v, &p);
		v--;
		d[v] = p;
		pq.push(i_i(p, v));
	}
	while (!pq.empty()) {
		i_i p = pq.top(); pq.pop();
		int u = p.second;
		for (int v,i=0;i<G[u].size();i++){
			v=G[u][i];
			if (d[v] == -1) {
				d[v] = d[u] + 1;
				pq.push(i_i(d[v], v));
			}
		}
	}
	rep(u, N)
		for (int i=0;i<G[u].size();i++){
			int v=G[u][i];
			if (abs(d[u] - d[v]) != 1) {
				cout << "No" << endl;
				return 0;
			}
		}
	cout << "Yes" << endl;
	rep(u, N) printf("%d\n", d[u]);
}

Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,d;
    cin>>n;
    std::deque<int> deq;
    for (int i=0;i<n;i++) {
        cin>>d;
        deq.emplace_back(d);
    }
    sort(deq.begin(),deq.end());
    cout<<deq[n/2]-deq[n/2-1]<<endl;
}

Measured memory_bytes: 640
/***************************************************************
	File name: E.cpp
	Author: ljfcnyali
	Create time: 2019年09月01日 星期日 20时16分00秒
***************************************************************/
#include<bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i ) 
#define mem(a) memset ( (a), 0, sizeof ( a ) ) 
#define str(a) strlen ( a ) 
typedef long long LL;

const int maxn = 1010;

queue<int> Q[maxn];
int n;
bool vis[maxn];

int main()
{
    scanf("%d", &n);
    REP(i, 1, n)
        REP(j, 1, n - 1)
        {
            int x; scanf("%d", &x);
            Q[i].push(x);
        }
    int i = 1;
    while ( i ) 
    {
        bool flag = true;
        REP(i, 1, n) if ( !Q[i].empty() ) { flag = false; break ; }
        if ( flag == true ) { printf("%d\n", i - 1); return 0; }
        mem(vis);
        REP(i, 1, n)
        {
            if ( Q[i].empty() || Q[Q[i].front()].empty() ) continue ;
            if ( vis[i] || vis[Q[i].front()] ) continue ;
            if ( Q[Q[i].front()].front() == i ) 
            {
                vis[Q[i].front()] = vis[i] = true; 
                Q[Q[i].front()].pop();
                Q[i].pop();
                flag = true;
            }
        }
        if ( !flag ) { printf("-1\n"); return 0; }
        ++ i;
    }
    return 0;
}

Measured memory_bytes: 6784
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

E = [0, 0]
for k, v in Counter(A).items():
    if v >= 2:
        E.append(k)
    if v >= 4:
        E.append(k)
E.sort()
print(E[-1] * E[-2])

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

int main() {
	int a,b;
	cin>>a>>b;
	int count=1;
	int ans=0;
	while(count<b){
		ans++;
		count += a;
		count--;
		if(count>=b) {
			break;
		}
		
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;
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 (a>b) { a=b; return 1; } return 0; }
template<class T>ostream&operator<<(ostream &o,const vector<T>&t){o<<'[';FOR(i,t){if(i!=t.begin())o<<',';o<<*i;}return o<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)output(a[i],i!=n-1?',':10);}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}

int main() {
  int T,D;
  while(input(T,D)) {
    int tA,tB,dA,dB;
    input(tA,tB,dA,dB);
    double ans = INF;
    for (int i=0; dA*(i-1)<=D; ++i) {
      for (int j=0; dB*(j-1)<=D; ++j) {
        int sm = dA*i + dB*j;
        if (1<= sm && sm <= D) {
          double vA = dA*i;
          double vB = dB*j;
          chmin(ans, abs(T-(tA*vA + tB*vB)/(vA+vB)));
        }
      }
    }
    printf("%.10f\n", ans);
  }
}

Measured memory_bytes: 1144
import java.math.*;
import java.util.*;

public class Main {
	static char maze[][] = new char[55][55];
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			int n = cin.nextInt();
			int m = cin.nextInt();
			int flag = 1;
			for(int i=0;i<=51;++i){
				for(int j=0;j<=51;++j){
					maze[i][j] = '.';
				}
			}
			for(int i=1;i<=n;++i){
				String s = cin.next();
				for(int j=1;j<=m;++j){
					maze[i][j] = s.charAt(j-1);
				}
			}
			for(int i=1;i<=n;++i){
				for(int j=1;j<=m;++j){
					if(maze[i][j]=='#'){
						if(check(i,j)==false){
							flag=0;
						}
					}
				}
			}
			if(flag==1) System.out.println("Yes");
			else System.out.println("No");
		}
	}
	public static boolean check(int x,int y){
		//System.out.println(maze[x+1][y]);
		if(maze[x-1][y]=='#'||maze[x+1][y]=='#'||maze[x][y-1]=='#'||maze[x][y+1]=='#')
			return true;
		return false;
	}
}

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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>

typedef long long ll;

int main() {
  vi A(3, 0);
  int ans = 1000000;
  for (int i = 0; i < 3; i++) cin >> A[i];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (i != j && j != k && i != k) {
          ans = min(ans, abs(A[j] - A[i]) + abs(A[k] - A[j]));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 1e5+10;
const int BIT = 32;

ll N, K, A[MAX], B[MAX];

ll solve() {
    ll ans = 0;
    REP (i, N) if ((K | A[i]) == K) ans += B[i];
    REP (b, BIT) if ((K>>b)&1) {
        ll res = 0;
        ll accept = K & (~(1<<b)) | ((1<<b) - 1);
        REP (i, N) if ((accept | A[i]) == accept) res += B[i];
        CHMAX(ans, res);
    }
    return ans;
}

int main() {
    cin >> N >> K;
    REP (i, N) cin >> A[i] >> B[i];
    cout << solve() << endl;
}

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

int main(){
  int h,w;
  char a;
  cin>>h>>w;
  fr(i,w+2) cout<<'#';
  cout<<endl;
  fr(i,h){
    cout<<'#';
    fr(i,w){
      cin>>a;
      cout<<a;
    }
    cout<<'#'<<endl;
  }
  fr(i,w+2) cout<<'#';
  cout<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String n = sc.next();
    int ans = 0;

    for (int i = 0; i < n.length(); i++) {
      if (n.charAt(i) == '2') {
        ans++;
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 35708
import static java.lang.Math.*;
import java.util.Scanner;

public class Main {
        
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int N = scanner.nextInt();
            int [] t = new int[N+1];
            int [] x = new int[N+1];
            int [] y = new int[N+1];
            t[0] = 0;
            x[0] = 0;
            y[0] = 0;
            for (int i=1; i<=N; i++){
                t[i] = scanner.nextInt();
                x[i] = scanner.nextInt();
                y[i] = scanner.nextInt();
            }
            Boolean judge = true;
            int i = 1;
            while ((i <= N) && judge) {
                //System.out.println(t[i]+" "+x[i]+" "+y[i]);
                //System.out.println(abs(x[i]-x[i-1])+" "+abs(y[i]-y[i-1])+" "+(t[i]-t[i-1]-2));
                int dist = abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
                int step = abs(t[i]-t[i-1]);
                if (step < dist) judge=false;
                else if (step == dist) judge=true;
                else if (((step - dist)%2) == 0) judge=true;
                else judge = false;
                i++;
            }
            if (judge) System.out.println("Yes");
            else System.out.println("No");
        }   
}

Measured memory_bytes: 91104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, n) for(long long (i) = (a); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define GET(v) cin >> (v)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main()
{
    int a, b;
    GET2(a, b);
    
    SHOW(a + (b / 2));
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;

    if(s == u) a -= 1;
    else b -= 1;

    cout << a << " " << b << endl;
    return 0;
}


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

using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void chmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  rep(i, 0, 5){
    int x; cin >> x;
    if(x == 0)
      cout << i +1 << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    cin >> n;
    vector<LL> num_list(10100, 0);
    for(LL x=1; x<=100; x++){
        for(LL y=1; y<=100; y++){
            for(LL z=1; z<=100; z++){
                LL kiyu=x*x+y*y+z*z+x*y+y*z+z*x;
                if(kiyu<10100){
                    num_list[kiyu]++;
                }
            }
        }
    }

    for(LL i=1; i<=n; i++){
        cout << num_list[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;

class in {
  int n;
public:
  in() {}
  in(int n_) : n(n_){};
  template <class T> operator T() { T ret; cin >> ret; return ret; }
  template <class T> operator vector<T>() { vector<T> ret(n); for (int i = 0; i < n; i++) cin >> ret[i]; return ret; }
};

template <std::uint_fast64_t Mod> class modint {
  using u64 = std::uint_fast64_t;
  u64 a;
  friend ostream& operator<<(ostream& os, const modint& m);
public:
  constexpr modint(const u64 x = 0) noexcept : a(x % Mod) {}
  constexpr u64 val() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
  constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
  constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
  constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
  constexpr bool operator==(const modint rhs) const noexcept { return modint(*this).val() == rhs.val(); }
  modint &operator+=(const modint rhs) noexcept { a += rhs.a; if (a >= Mod) a -= Mod; return *this; }
  modint &operator-=(const modint rhs) noexcept { if (a < rhs.a) a += Mod; a -= rhs.a; return *this; }
  modint &operator*=(const modint rhs) noexcept { a = a * rhs.a % Mod; return *this; }
  modint &operator/=(modint rhs) noexcept { u64 exp = Mod - 2; while (exp) { if (exp % 2) *this *= rhs; rhs *= rhs; exp /= 2; } return *this; }
};
const ll mod=(ll)1e9+7;
using mint = modint<mod>;
ostream& operator<<(ostream& os, const mint& m){ return os << m.a; }
//}}}

int x[15][15];
int y[15][15];

int main(){
  int N = in();
  vector<int> A(N);
  rep(i, N){
    A[i] = in();
    rep(j, A[i]){
      x[i][j] = in();
      x[i][j]--;
      y[i][j] = in();
    }
  }

  int ans = 0;
  rep(n, 1 << N){
    int cnt = 0;
    vector<int> a(N);
    rep(i, N){
      if((n >> i) & 1){
        cnt++;
        a[i] = 1;
      }else{
        a[i] = 0;
      }
    }
    rep(i, N){
      if(a[i]){
        rep(j, A[i]){
          int X = x[i][j];
          int Y = y[i][j];
          if(a[X] != Y) goto F;
        }
      }
    }
    ans = max(ans, cnt);
F:;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

long long gcd(long long  a, long long b) {
    if (a % b == 0) {
        return b;
    }
    else {
        return gcd(b, a % b);
    }
}

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main()
{
    long long a, b;
    cin >> a>> b;
    long long  ans = lcm(a, b);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll cnt[39];

int main(){
  string s;
  cin>>s;
  ll n=s.size();
  for(int i=0;i<n;i++){
    cnt[s[i]-'a']++;
  }
  ll sum=0;
  for(int i=0;i<27;i++){
    sum+=cnt[i]*(cnt[i]-1)/2;
  }
  cout<<n*(n-1)/2-sum+1<<endl;
  return(0);
}


Measured memory_bytes: 768
package main

import(
    "fmt"
    "sort"
    "strings"
    "strconv"
)



func main() {
    var s string
    fmt.Scan(&s)
    a,_ := strconv.Atoi(s[5:7])
    ans := "TBD"
    if a<=4{
        ans = "Heisei"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#define _GIBCXX_DEBUG
#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()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  string ans = "No";
  for (int i = 1; i < 10; ++i) {
    if (N % i == 0 && N / i < 10) {
      ans = "Yes";
    }
  }

  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 256
N , M, C = map(int,input().split())
b = list(map(int,input().split()))
A = []
for i in range(N):
    a = list(map(int,input().split()))
    A.append(a)
count = 0
for h in range(N):    
    result = 0
    for j in range(M):
        result += b[j] * A[h][j]
    if result + C > 0:
        count += 1
print(count)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int Inf = (int)1e9;
		int Tot = 410;
		
		int[][] dp = new int[Tot][];
		for(int i=0;i<Tot;i++){
			dp[i] = new int[Tot];
			for(int j=0;j<Tot;j++){
				dp[i][j] = Inf;
			}
		}
		
		dp[0][0] = 0;
		for(int i=0;i<N;i++){
			for(int j=Tot-1;j>=0;j--){
				for(int k=Tot-1;k>=0;k--){
					if(dp[j][k] == Inf) continue;
					int na = j+A[i];
					int nb = k+B[i];
					int nc = dp[j][k] + C[i];
					if(InRange(na,0,Tot) && InRange(nb,0,Tot)){
						dp[na][nb] = Math.Min(dp[na][nb],nc);
					}
				}
			}
		}
		
		int min = Inf;
		for(int i=1;i<Tot;i++){
			for(int j=1;j<Tot;j++){
				if(dp[i][j] == Inf) continue;
				if(i * Mb != j * Ma) continue;
				min = Math.Min(min,dp[i][j]);
			}
		}
		Console.WriteLine(min == Inf ? -1 : min);
	}
	
	bool InRange(int t,int l,int r){ return l <= t && t < r;}
	
	int gcd(int a, int b){ return a == 0 ? b : gcd(b%a, a);}
	
	int N,Ma,Mb;
	int[] A,B,C;
	public Sol(){
		var d = ria();
		N = d[0]; Ma = d[1]; Mb = d[2];
		A = new int[N];
		B = new int[N];
		C = new int[N];
		for(int i=0;i<N;i++){
			d = ria();
			A[i] = d[0]; B[i] = d[1]; C[i] = d[2];
		}
		
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

const int N = 2e5 + 10;

int n, m;
int f[N], g[N], a[N], res[N];
vector<int> adj[N];

void dfs(int u, int par, int len) {
    f[u] = lower_bound(g + 1, g + 1 + len, a[u]) - g;
    len = max(len, f[u]); res[u] = len;
    int tx = g[f[u]]; g[f[u]] = a[u];
    for (int v: adj[u]) if (v != par)
        dfs(v, u, len);
    g[f[u]] = tx;
}

int main() {
    if (fopen("A.inp", "r"))
    freopen("A.inp", "r", stdin),
    freopen("A.out", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i < n; i++) {
        int x, y; cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1, 0, 0);
    for (int i = 1; i <= n; i++)
        cout << res[i] << endl;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    long long n7 = 0;
    while(7*n7 <= N){
        if((N-7*n7)%4 == 0){
            cout << YES << endl;
            return;
        }
        n7++;
    }
    cout << NO << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long d = sc.nextLong();
		int r = 0;
		while(n-->0) {
			long x = sc.nextLong(), y = sc.nextLong();
			if (x*x+y*y <= d*d) {
				r++;
			}
		}
		System.out.println(r);

	}
}


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

int main() {
    string S, T;
    cin >> S;
    cin >> T;

    if (S == T.substr(0, T.size() - 1) ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3616
prime = [1 for i in range(int(1e5 + 10))]

def sieve(n):
    prime[0] = prime[1] = 0
    for i in range(2, n):
        for j in range(i + i, n, i):
            prime[j] = 0

q = int(input())
sieve(int(1e5))
cnt = []
for i in range(int(1e5)):
    if(i == 0):
        cnt.append(0)
    else:
        cnt.append(cnt[-1] + (prime[i] and prime[(i + 1) // 2]))
for i in range(q):
    l, r = map(int, input().split())
    print(cnt[r] - cnt[l - 1])


Measured memory_bytes: 52128
#include "bits/stdc++.h"

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

using namespace std;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;
const long long MOD = 1000000000 + 7;
const double PI = acos(-1);

class city {
public:
    int num; // 名前
    int year; // 学生番号
    city(int num, int year) { // コンストラクタ
        this->num = num;
        this->year = year;
    };
};

bool operator< (const city& city1, const city& city2) {
    return city1.year > city2.year;
};

int main() {
	int N, M; cin >> N >> M;
    vector<priority_queue<city>> G;
    rep(i, N) {
        priority_queue<city> pq;
        G.push_back(pq);
    }
    rep(i, M) {
        int p; long long y;
        cin >> p >> y;
        G[p - 1].push(city(i + 1, y));
    }
    map<int, string> mp;
    rep(i, N) {
        int count = 0;
        while (!G[i].empty()) {
            ++count;
            int num = G[i].top().num;
            int y = G[i].top().year;
            G[i].pop();
            ostringstream sout;
            sout << std::setfill('0') << std::setw(6) << i + 1;
            string s1 = sout.str();
            sout << std::setfill('0') << std::setw(6) << count;
            string s2 = sout.str();
            mp[num] = s2;
        }
    }
    rep(i, M) {
        cout << mp[i + 1] << endl;
    }
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int N;

  cin >> N;
  
  FOR(ans,1,50000) {
    if((int)((double)ans * 1.08) == N) {
      cout << ans << endl;
      return 0;
    }
  }

  cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


ll n;
int main(){
	int flag=0;
	scanf("%lld",&n);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		flag|=t%2;
	}
	puts(flag?"first":"second");
}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  lvector A(n+1,1);
  for(ll i=2;i<=n;++i)for(ll j=i;j<=n;j+=i) A[j]++;
  for(ll i=1;i<=n;++i) ans+=i*A[i];
  print(ans);
  return 0;
}

Measured memory_bytes: 81348
#include <bits/stdc++.h>
#define pb push_back
#define int long long int
#define f(i,a,b) for (int i= a; i <b; ++i)
using namespace std;

int dp[3005][3005];

int solve(int s,int e,int a[])
{
    if(s>e)
        return 0;
    if(dp[s][e]!=-1)
        return dp[s][e];
    int x=a[s]+min(solve(s+2,e,a),solve(s+1,e-1,a));
    int y=a[e]+min(solve(s+1,e-1,a),solve(s,e-2,a));
    return dp[s][e]=max(x,y);
}

signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof dp);
    int n;
    cin>>n;
    int a[n],s=0;
    for(int i=0;i<n;i++)
       {
         cin>>a[i];
         s+=a[i];
       }
    int x=solve(0,n-1,a);
    int y=s-x;
    cout<<x-y;
}



Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int n, m;
bool ok(int i, int j) {
    return i >= 0 && i < n && j >= 0 && j < m;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    vector<int> sq;
    for (int i = 1; i <= 50000; i++) {
        sq.pb(i * i);
    }
    int n;
    cin >> n;
    auto x = upper_bound(all(sq), n) - 1;
    cout << *x << endl;

    return 0;
}

Measured memory_bytes: 640
array = [int(input()) for i in range(5)]
k = int(input())


def find(array, k):
    for i in range(5):
        for j in range(5):
            if(i != j):
                if(array[i]-array[j] > k):
                    return False
    return True


result = "Yay!" if find(array, k) == True else ":("
print(result)


Measured memory_bytes: 2940
while 1:
    n = input()
    if n == 0: break
    l = [input(),1]
    for i in range(n-1):
        x = input()
        if i % 2 == 1:
            if l[-2] == x: l[-1] += 1
            else: l += [x]; l += [1]
        else:
            if l[-2] == x: l[-1] += 1
            else:
                if len(l) > 2:
                    l[-3] += l[-1] + 1
                    l = l[:-2]
                else:
                    l[-2] = x
                    l[-1] += 1
    print sum([l[2*i+1] for i in range(len(l)/2) if l[2*i] == 0])

Measured memory_bytes: 9480
//HEADER FILES//
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>

//#########################################################################//
//MACROS
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define stringinput(s) \
    string s;          \
    cin >> s;
#define lc cout << "\n";
#define testcase \
    int t;       \
    cin >> t;    \
    while (t--)
#define umap unordered_map
#define testcasei \
    inti t;       \
    cin >> t;     \
    while (t--)
#define notestcase \
    inti t = 1;    \
    while (t--)
#define input(n) \
    int n;       \
    cin >> n;
#define inputi(n) \
    inti n;       \
    cin >> n;
#define inputl(n) \
    li n;         \
    cin >> n;
#define display(a, n)         \
    {                         \
        int zzzz = n;         \
        for (auto x : a)      \
        {                     \
            cout << x << " "; \
            if (!(--zzzz))    \
                break;        \
        }                     \
        lc                    \
    }
#define pb push_back
#define pause \
    int zzz;  \
    cin >> zzz;
#define arrayinput(a) \
    for (auto &x : a) \
        cin >> x;
#define floop(i, n) for (__typeof(n) i = 0; i < n; ++i)
#define foop(i, start, end) for (__typeof(end) i = start; i < end; ++i)
#define display2d(a, m, n)          \
    for (int i = 0; i < m; ++i)     \
    {                               \
        for (int j = 0; j < n; ++j) \
            cout << a[i][j] << " "; \
        lc                          \
    }                               \
    lc

#define here(n)                  \
    cout << "here(" << n << ")"; \
    lc
#define debugHere(n)                   \
    cout << #n << " is (" << n << ")"; \
    lc
#define MOD 1000000007
#define bb begin()
#define ee end()
//#########################################################################//
using namespace std;
typedef unsigned long long int inti;
typedef long long int intl;
struct trio
{
    intl a, b, c;
};
struct duo
{
    inti l, r;
};
//######################################//
//          SOLUTION STARTS              //
//               HERE                    //
//###################################### //
int main()
{
    fastio
        notestcase
    {
        string s;
        cin>>s;
    string s1;
    cin>>s1;
    intl ans=0;
    set<char> ss;
    for(int i=0; i<s.size();++i){
        if(s[i]!=s1[i])
++ans;    }


    cout<<ans;
    }
}

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

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

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    int c1 = min({c[0][0], c[0][1], c[0][2]});
    vector<int> l(3);
    l[0] = c[0][0] - c1;
    l[1] = c[0][1] - c1;
    l[2] = c[0][2] - c1;
    int c2 = min({c[1][0], c[1][1], c[1][2]});
    bool ok = true;
    rep(i, 3) {
        if (c[1][i] - c2 != l[i]) {
            ok = false;
            break;
        } 
    }
    int c3 = min({c[2][0], c[2][1], c[2][2]});
    rep(i, 3) {
        if (c[2][i] - c3 != l[i]) {
            ok = false;
            break;
        }
    } 
    if (ok) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var tarou = 0;
        var hanako = 0;
        for (int i = 0; i < n; i++)
        {
            var input = Console.ReadLine().Split();
            if (input[0] == input[1])
            {
                tarou++;
                hanako++;
                continue;
            }
            var m = Math.Min(input[0].Length, input[1].Length);
            for (int j = 0; j < m; j++)
            {
                if (input[0][j] < input[1][j])
                {
                    hanako += 3;
                    break;
                }
                else if (input[0][j] > input[1][j])
                {
                    tarou += 3;
                    break;
                }
                if (j == m - 1)
                {
                    if (input[0].Length < input[1].Length)
                    {
                        hanako += 3;
                    }
                    else
                    {
                        tarou += 3;
                    }
                }
            }
        }
        Console.WriteLine("{0} {1}", tarou, hanako);
    }
}


Measured memory_bytes: 15944
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    vector<int> a(3);

    rep(i,3){
        cin >> a[i];
    }

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

    if (a[0]!=5){
        cout << "NO" << endl;
        exit(0);
    }
    if (a[1]!=5){
        cout << "NO" << endl;
        exit(0);
    }
    if (a[2]!=7){
        cout << "NO" << endl;
        exit(0);
    }

    cout << "YES";
    return 0;
}

Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int a, k ,b , c;
	cin >> a >> b >> c >> k;
	cout << min(k, a)-max(0, k-a-b);

	return 0;
}


Measured memory_bytes: 3648