akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vll A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    vector<pair<ll, ll>> BA(N);
    rep(i, N) {
        BA[i] = mp(B[i], A[i]);
    }
    sort(all(BA));

    ll t = 0;
    bool ans = true;
    rep(i, N) {
        t += BA[i].second;
        if (t > BA[i].first) ans = false;
    }

    write(ans ? "Yes" : "No");
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

int n, ans;
vector <int> a;
vector <int> b;

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	ans = 0;
	cin >> n;
	for(int i = 0; i < n+1; ++i) {
		int x; cin >> x;
		a.pb(x);
	}
	for(int i = 0; i < n; ++i) {
		int x; cin >> x;
		b.pb(x);
	}
	for(int i = 0; i < n; ++i) {
		ans += min(a[i], b[i]);
		if (b[i] - a[i] > 0) {
			ans += min(a[i+1], b[i]-a[i]);
			a[i+1] -= min(a[i+1], b[i]-a[i]);
		}
	}
	cout << ans;
}


Measured memory_bytes: 5588
#include <iostream>
#include <set>
#include <cstring>
using namespace std;
int n ,x ,y;
int ans [3003],viz[2001];
int modul(int x, int y)
{
    if(x > y )
        return x- y;
    else
        return y- x;
}
int main() {
    cin >> n >> x >> y;
    for( int i =1 ;i <=n; i ++)
        for( int j =i + 1 ;j <=n;j ++)
        {
            int minim = min(modul(j , i), min(modul(x , i) + 1 + modul(j , y), modul(y, i)+1+modul(j, x)));
            ans[minim]++;
        }
    for( int i =1 ;i <n ;i ++)
        cout << ans[i]<<'\n';
    return 0;
}


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

int main() {
	int a,b,o,ab;
	a=0;b=0;o=0;ab=0;
	int n;
	char ty[5]={'e'};
	while(scanf("%d,%s",&n,ty)+1){
		if(ty[1] == 'B'){
			ab++;
		}else if(ty[0] == 'A'){
			a++;
		}else if(ty[0] == 'B'){
			b++;
		}else if(ty[0] == 'O'){
			o++;
		}
	}
	cout << a << endl;
	cout << b << endl;
	cout << ab << endl;
	cout << o << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=1e5+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

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


int main()
{
    IOS;
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll mn=min({a,b,c,d,e});
    ll ans=ceil(double(n)/double(mn))+4;
    cout<<ans<<endl;

    

}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Y = sc.nextInt();
    for(int a = 0; a <= N ; a++ ){
        for(int b = 0; b <= N -a  ; b++ ){
            int c = N - a - b;
            int amt = a * 10000 + b * 5000 +  c * 1000;
            if(amt == Y){
                System.out.println(a + " " + b + " " + c);
               return ;
            }
        }
    }
    System.out.println("-1 -1 -1");
    }    
}

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

int main() {
  
  int n, m;
  cin >> n >> m; 
  int count = 0;
  
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    count += a;
  }
  
  if (n-count < 0)
        cout << -1 << endl;
    else 
        cout << n - count << endl;
  
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvl;
const int mod = 1000000007;
const int N = 3e5;
vi g[N];
int a[N];
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
ll f(ll n, ll d){
	ll ans = n/d;
	if(n%d) ans++;
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,k,j;
	string s;
	cin>>s;
	n = s.size();
	int ans = 0;
	map<char, int>cnt;
	fo(i, n)cnt[s[i]]++;
	int x = min(cnt['g'], n/2);
	cout<<x-cnt['p']<<endl;
	return 0;
} 

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
	if (exp & 1) result = ((ll)result * base) % mod;
	base = ((ll)base * base) % mod;
	exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
for(int v:g[u]){
	if (v == par) continue;
	dfs(v, u);
}
}

Measured memory_bytes: 7680
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s;



int main()
{
cin>>a>>b>>c;
  cout<<min(b/a,c)<<endl;
	
}


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

int main(){
	ll n;
	cin>>n;
	for(ll i=0;i<9 && n>0;i++,n--){
		cout<<i+1<<endl;
	}
	for(ll i=0;i<9 && n>0;i++,n--){
		cout<<(i+1) * 10 + 9<<endl;
	}
	ll cnt=1;
	long long t = 99; 
	long long diff=100;
	while(n>0){
		//for(ll i=cnt;i<((cnt+1)*10) - 9*(cnt/10) && n>0;i++,n--){
		if (cnt<10)
		for(ll i=0;i<(cnt*9 + 10) && n>0;i++,n--){
			t+=diff;
			cout<<t<<endl;
		}
		else
		for(ll i=0;i<(cnt*10 - 10) && n>0;i++,n--){
			t+=diff;
			cout<<t<<endl;
		}
		//cout<<cnt<<"-----\n";
		cnt++;
		diff*=10;
	}
}


Measured memory_bytes: 256
// 1 atelast 1 0 and 1 9 
// Total - no 0 - no 9 - no 9 and no zero
#include<bits/stdc++.h>
using namespace std;
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();
const int mod = 1e9+7;
inline int mul(int &a, int b) {
	a =  (int) ((long long) a * b % mod);
	return a;
}
 
inline int power(int a, long long b) {
	int res = 1;
	while (b > 0) {
		if (b & 1) {
		  res = mul(res, a);
		}
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int main () { _read(); 

      int n;
      cin >> n;
      int a = power(10,n);
      ( a += power(8,n)) %= mod;
      int b = power(9,n);
      (b *= 2 ) %= mod;
      cout << (a-b+mod) % mod << '\n';
      return 0;
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


Measured memory_bytes: 3648
def mod_comb(n, r, m):
  nn = n+1
  r = min(r, n-r)
  numer = 1
  denom = 1
  for i in range(1, r+1):
    numer = (numer * (nn - i)) % m
    denom = (denom * i) % m
  output = numer * pow(denom, m-2, m) % m
  return output

x, y = map(int, input().split())
if not (x <= 2*y and y <= 2*x):
  result = 0
else:
  c_up = (2*y-x)/3
  c_do = (2*x-y)/3
  if c_up.is_integer() and c_do.is_integer():
    c_up = int(c_up)
    c_do = int(c_do)
    result = mod_comb((c_up+c_do), c_up, 7+10**9)
  else:
    result = 0
print(result)


Measured memory_bytes: 3188
# 各桁の和を計算する関数
def findSumOfDigits(n):
  sum = 0
  while n > 0:
    q, mod = divmod(n, 10)
    sum += mod
    n = q
  return sum

N = int(input())
sum = findSumOfDigits(N)

ans = 'Yes' if N % sum == 0 else 'No'
print(ans)

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define pb push_back
#define fst first
#define snd second

typedef long long ll;

const int N = 2e4;
const int M = 1e9 + 7;

string s;

int n, d;

ll dp[N][200][2];


ll calc(int i, int j, int k) {
    if(i == n && j == 0) return 1;
    if(i == n) return 0;
    ll &r = dp[i][j][k];
    if(r != -1) return r;
    ll times = 0;
    if(k) fore(dig, 0, s[i] - '0' + 1) {
        times += calc(i + 1, (j + dig) % d, (dig == (s[i] - '0')));
        times %= M;
    } else fore(dig, 0, 10) {
        times += calc(i + 1, (j + dig) % d, 0);
        times %= M;
    }
    return r = times % M;
}

int main() {
    s.resize(N);
    cin >> s;
    n = s.size();
    cin >> d;
    memset(dp, -1, sizeof dp);
    cout << (calc(0, 0, 1) + M - 1) % M << endl;
}

Measured memory_bytes: 63488
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> v(N);
    for(int i = 0; i < N; i++){
        int A, B;
        cin >> A >> B;
        v[i] = make_pair(A, B);
    }
    sort(v.begin(), v.end());
    int DP[T + 1];
    for(int i = 0; i <= T; i++) DP[i] = -1;
    DP[0] = 0;
    
    for(int n = 0; n < N; n++){
        for(int from = T - 1; from >= 0; from--){
            if(DP[from] == -1) continue;
            DP[min(T, from + v[n].first)] = max(DP[min(T, from + v[n].first)], DP[from] + v[n].second);
        }
    }
    
    int ans = 0;
    for(int i = 0; i <= T; i++) ans = max(ans, DP[i]);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int ans=0;
  rep(i,n) if(s[i]!=t[i]) ans++;
  out(ans);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3728
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <cstdio>
#include <math.h>
#include <vector>
#include <bitset>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
#define PI 3.14159265
#define INF	9999999999
#define pb push_back
#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
#define FR(i,s_limit,f_limit) for(long long int i=s_limit;i<f_limit;i++)
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
typedef long long int ll; 
typedef vector<ll> vi;
typedef vector<vi> vii;


int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a;
	cin>>a;
	ll p=a.length();
	cout<<a[0]<<p-2<<a[p-1]<<endl;
	return 0;
}

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

using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	vector<int> p(n), dp(n + 1);
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}
	for(int i = 0; i < n; i++){
		int t = p[i];
		dp[t] = dp[t - 1] + 1;
	}
	ans = n - *max_element(dp.begin(), dp.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define SP << " " <<
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000003
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll modpow(ll a, ll n=MOD-2, ll mod=MOD){ // a^n % MOD の計算
    ll res = 1;
    while (n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a  % mod;
        n >>= 1;
    }
    return res;
}
//--MAIN-----------------------------------
void Main() {
    ll Q; cin>>Q;
    ll prod[1010101];
    prod[0]=1;
    prod[1]=1;
    reps(i,2,MOD+1){
        prod[i]=prod[i-1]*i%MOD;
    }
    while(Q--){
        ll x,d,n; cin>>x>>d>>n;
        if(d==0){
            ll ans=modpow(x,n);
            cout<< ans <<"\n";
            continue;
        }
        ll shoko=x*modpow(d)%MOD;
        if(n-1>=MOD-shoko or shoko==0){ cout<< 0 <<"\n"; continue;}
        ll ans=prod[shoko+n-1]*modpow(prod[shoko-1])%MOD;
        ans=ans*modpow(d,n)%MOD;
        cout<< ans <<"\n";
    }
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

#define ll long long
#define ull unsigned long long

int main()
{
    ll x;
    std::cin >> x;
    ll ans = 0;
    ans += (x / 500) * 1000;
    x = x - (x / 500) * 500;
    ans += (x / 5) * 5;
    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;

int main(){
	
	int i,n,m,k=0;
	float ans=0;
	cin>>n>>m;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
		ans+=a[i];
	}
	ans=ans/(4*m);
	for(i=0;i<n;i++){
		if(a[i]>=ans){
			k++;
		}
	}
//	cout<<k;
	if(k>=m){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
	
	
	return 0;
}

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

using namespace std;

#define YES return puts("Heisei"),0
#define NO return puts("TBD"),0

int main()
{
	int a,b,c;
	scanf("%d/%d/%d",&a,&b,&c);
	if(a>2019) NO;
	else if(a<2019) YES;
	else{
		if(b>4)NO;
		else if(b<4) YES;
		else {
			if(c<=30) YES;
			if(c>30) NO;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>

#define SIZE_MIN ((int) 1)
#define SIZE_MAX ((int) 100)
#define ELEMENT_MIN ((int) 0)
#define ELEMENT_MAX ((int) 1000)

typedef enum
{
	kSuccess = 0,
	kError = -1
}Result;

Result checkNumRange( int num, int min, int max );
void showArray( int *arr, int size );
void execInsertuinSort( int *array, int size );

int main( void )
{
	int i, size, array[SIZE_MAX];

	scanf( "%d", &size );
	if( checkNumRange( size, SIZE_MIN, SIZE_MAX ) == kError )
	{
		return kError;
	}

	for( i = 0; i < size; i++ )
	{
		scanf( "%d", &array[i] );
		if( checkNumRange( array[i], ELEMENT_MIN, ELEMENT_MAX ) == kError )
		{
			return kError;
		}
	}

	showArray( array, size );
	execInsertuinSort( &array[0], size );

	return kSuccess;
}

Result checkNumRange( int num, int min, int max )
{
	return ((num >= min) && (num <= max)) ? kSuccess : kError;
}

void showArray( int *array, int size )
{
	int i;

	for( i = 0; i < size - 1; i++ )
	{
		printf( "%d ", array[i] );
	}
	printf( "%d\n", array[size - 1] );
}

void execInsertuinSort( int *array, int size )
{
	int i, j, work;

	for( i = 1; i < size; i++ )
	{
		work = array[i];
		j = i - 1;

		while( (j >= 0) && (array[j] > work) )
		{
			array[j + 1] = array[j];
			j--;
		}
		array[j + 1] = work;

		showArray(array, size);
	}
}



Measured memory_bytes: 2044
#include<stdio.h>
int main(void){
  char str[15];
  int count =0,i;
  scanf("%s",str);
  for (i = 0; str[i] != '\0'; i++){
    if (str[i] == 'x'){
      count++;
    }
  }
  if(count <= 7){
    printf("YES");
  }
  else{
    printf("NO");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )

ll N;
struct e {ll i, val;};
e A[200000];

int main() {
    cin >> N;
    for (ll i = 0; i < N; i++) {
        A[i].i = i;
        cin >> A[i].val;
    }
    sort(A, A+N, [](auto a, auto b) {return a.val < b.val;});
    ll min = A[N / 2-1].val;
    ll max = A[N / 2].val;
    for (ll i = 0; i < N; i++) {
        A[i].val = i + 1;
    }
    sort(A, A+N, [](auto a, auto b) {return a.i < b.i;});
    for (ll i = 1; i <= N; i++) {
        if (A[i-1].val < N/2 + 1) {
            cout << max << endl;
        }
        else {
            cout << min << endl;
        }
    }
}

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

int main(){
	int n, m, A[100][100], b[100],c[100];

	cin >> n >> m;
	for ( int i = 0; i < n; i++ )
		for ( int j = 0; j < m; j++) cin >> A[i][j];
	for ( int i = 0 ; i < m; i++) cin >> b[i];

	for ( int i = 0; i < n; i++){
		c[i] = 0;
		for (int j = 0; j < m; j++){
			c[i] += A[i][j]*b[j];
		}
	} 

	for ( int i = 0; i < n; i++) cout << c[i] << endl;

	return 0;
}

Measured memory_bytes: 3116
package main

import (
	"fmt"
	"math"
	"sort"
)

var N, L int

func main() {
	fmt.Scan(&N, &L)
	A := make(SortBy, N)

	for i := 0; i < N; i++ {
		A[i] = i + L
	}

	sort.Sort(A)

	var ans int
	for i := 1; i < N; i++ {
		ans += A[i]
	}

	fmt.Println(ans)
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy []int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return abs(a[i]) < abs(a[j])
}


Measured memory_bytes: 512
/*
	EDPC[b] Frog2
*/

#include <bits/stdc++.h>
using namespace std;

#define N_MAX 100010

int main() {
	
	int N, K;
	int h[N_MAX];
	
	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> h[i];
	
	int dp[N_MAX];
	dp[0] = 0;
	vector<int> step;
	for(int i=0; i<N-1; i++){
		for(int j=0; j<min(K, i+1); j++){
			step.push_back(dp[i-j] + abs(h[i+1] - h[i-j]));
			//printf("dp[%d] (j: %d) = %d\n", i+1, j, step[j]);
		}
		dp[i+1] = *min_element(step.begin(), step.end());
		step.clear();
	}
	
	cout << dp[N-1] << endl;
	
	return 0;
}

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

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

	int ans=0;
	for(int i=0;i<n;i++){
		string s;	cin>>s;
		if(s=="E869120")ans++;
	}
	cout<<ans<<endl;

	return 0;
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    for(int i = 0; i < 3; ++i) {
        string s;
        cin >> s;
        s[0] -= 'a' - 'A';
        cout << char(s[0]);

    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long MOD = 1e9 + 7;
long long repow(long long x, long long y){
    if(y == 0) return 1;
    if( y % 2 == 0){
        long long t = repow(x, y / 2);
        return t * t % MOD;
    }
    else return x* repow(x, y - 1) % MOD;
}
int main(){
    long long X, Y;
    cin >> X >> Y;
    long long x = min(X, Y);
    long long y = max(X, Y);
    long long t = x / 2;
    int flag = 0;
    long long a, b;
    for(int i = 0; i <= t; i++){
        long long s = x - i*2;
        if(s*2 + i == y){
            a = s;
            b = i;
            flag = 1;
            break;
        }
    }
    if(flag == 0){
        cout << 0 << endl;
        return 0;
    }
    long long bo = 1, si = 1;
    for(long long i = 1; i <= a + b; i++){
        bo = bo* i % MOD;
    }
    for(long long i = 1; i <= a; i++){
        si = si*repow(i, MOD -2)%MOD;
    }
    for(long long i = 1; i <= b; i++){
        si = si*repow(i, MOD - 2)%MOD;
    }
    cout << bo*si%MOD << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  REP(i,h)REP(j,w)cin >> a[i][j];

  vector<bool> r(h,false);
  vector<bool> c(w,false);

  REP(i,h)REP(j,w){
    if(a[i][j]=='#'){
      r[i]=true; c[j]=true;
    }
  }

  REP(i,h){
    if(!r[i])continue;
    REP(j,w){
      if(!c[j])continue;
      cout << a[i][j];
    }
    cout << endl;
  }
}



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

using namespace std;

int findSol(int hieght[],int n){
    vector<int> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=0;i<n-1;i++){
        int j = i+1;
        int k = i+2;
        if(j<n){
            dp[j] = min(dp[j],dp[i]+abs(hieght[i]-hieght[j]));
        }
        if(k<n){
            dp[k] = min(dp[k],dp[i]+abs(hieght[i]-hieght[k]));
        }
    }
    return dp[n-1];
}

int main(){
    int n;
    cin>>n;
    int hieght[n];
    for(int i=0;i<n;i++){
        cin>>hieght[i];
    }
    cout<<findSol(hieght,n)<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll A,B,C;
	cin>>A>>B>>C;
	if(A==B&&B==C){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

}

Measured memory_bytes: 256
N, K = map(int, input().split())
xs = list(map(int, input().split()))
rs = []
for i in range(0, N+1-K):
  r = abs(xs[i])+abs(xs[i+K-1]-xs[i])
  rs.append(r)
for i in range(K-1, N):
  r = abs(xs[i])+abs(xs[i-K+1]-xs[i])
  rs.append(r)
r = min(rs)
print(r)


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

using namespace std;
#define FOR(i,n) for(int i = 0; i < n; i++)
#define sz(c) ((int)c.size())

using ll = long long;

int main() {
	int n; scanf("%d", &n);
	vector<int> v(n);
	FOR(i, n) {
		scanf("%d", &v[i]);
	}

	vector<int> s2;
	FOR(i, n / 2) {
		s2.push_back(v[i] - v[sz(v) - 1 - i]);
	}
	vector<int> s3;
	s3.push_back(s2[0]);
	FOR(i, n / 2 - 1) s3.push_back(s2[i + 1] - s2[i]);
	s3.push_back(-s2.back());
	int not_eq_0 = 0;
	for (auto& x : s3) if (x != 0) not_eq_0++;

	const int n2 = n / 2;
	int q; scanf("%d", &q);
	FOR(_, q) {
		int l, r, x; scanf("%d%d%d", &l, &r, &x);
		auto add = [&](int l, int r, int x) {
			if (s3[l] != 0) not_eq_0--;
			if (s3[r] != 0) not_eq_0--;
			s3[l] += x;
			s3[r] -= x;
			if (s3[l] != 0) not_eq_0++;
			if (s3[r] != 0) not_eq_0++;

		};
		l--, r--;
		if (l < n2) {
			int cl = l;
			int cr = min(r, n2 - 1) + 1;
			add(cl, cr, x);
		}
		if (n2 <= r) {
			int cl = n - r - 1;
			int cr = min(n - l, n2);
			add(cl, cr, -x);
		}

		int y = (not_eq_0 == 0);
		printf("%d\n",y);
	}

	return 0;
}

Measured memory_bytes: 7448
using System;

namespace Dice
{
    class Program
    {
        private static bool Eql(string[] x, string[] y)
        {
            var g = true;
            for (int o = 0; o < x.Length; o++)
              if (x[o] != y[o]) g = false;
            return g;
        }

        private static bool Check(string[] x, string[] y)
        {
            if (Eql(x, y)) return true;
            for (int p = 0; p < 2; p++)
            {
                for(int q = 0; q < 4; q++)
                {
                    var a = x[0]; var b = x[1]; var c = x[2];
                    var d = x[3]; var e = x[4]; var f = x[5];
                    x = p == 0 ? new string[] { e, a, c, d, f, b } :
                                 new string[] { d, b, a, f, e, c };
                    if (Eql(x, y)) return true;
                    var h = x;
                    for(int r = 0; r < 4; r++)
                    {
                        var i = h[0]; var j = h[1]; var k = h[2];
                        var l = h[3]; var m = h[4]; var n = h[5];
                        h = new string[] { i, k, m, j, l, n };
                        if (Eql(h, y)) return true;
                    }
                }
            }
            return false;
        }

        static void Main()
        {
            int s = int.Parse(Console.ReadLine());
            var t = new string[s][];
            for(int u = 0; u < s; u++)
                t[u] = Console.ReadLine().Split(' ');
            for (int v = 0; v < s; v++)
                for (int w = v + 1; w < s; w++)
                    if (Check(t[v], t[w]))
                    {
                        Console.WriteLine("No");
                        return;
                    }
            Console.WriteLine("Yes");
        }
    }
}

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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	while (k > 0)
	{
		k--;
		if (b <= a) {
			b *= 2;
			continue;
		}
		else if (c <= b) {
			c *= 2;
			continue;
		}
	}
	if (a < b && b < c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int n,avg;
vector<int> v;

int main()
{
 cin>>n>>avg;
 v.resize(n);
 for(int &i:v) cin>>i;
 vector<vector<long long int>> dp(n+1,vector<long long int>(2501));
 dp[0][0]=1;
 for(int i=0;i<n;i++)
 {
   for(int j=i;j>=0;j--)
   {
     for(int k=0;k<=2500;k++)
     {
       if(dp[j][k]!=0)
         dp[j+1][k+v[i]] += dp[j][k];
     }
   }
 }
 long long ans = 0;
 for(int i=1;i<=n;i++)
 {
   ans += dp[i][avg*i];
 }
cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N,M; cin>>N>>M;
  vector<int>A(M);
  vector<char>B(M);
  vector<int>AC(N+1);
  vector<int>WA(N+1);
  rep(i,M){
    string C;
    cin>>A[i]>>C;
    B[i]=C.at(0);
    if(AC[A[i]]==1)continue;
    if(B[i]=='A'){
      AC[A[i]]++;
    }
    else{
      WA[A[i]]++;
    }
  }
  int ac=0;
  int wa=0;
  rep(i,N+1){
    if(AC[i]){
    	ac+=AC[i];
    	wa+=WA[i];
    }
  }
  cout<<ac<<" "<<wa<<endl;
}


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

int main(){
    int i,j;
  int num;
scanf("%d",&num);

  /* 文字列 */
  int score[101];
  int sort[101];
  char moji[101][20], tmp[20];
  int test;
 
  /* 3つの文字列を入力 */
  for (i=1;i<num+1;i++) {
      sort[i]=i;
    scanf("%s %d", moji[i],&score[i]);
  }

 
  for(i=2;i<num+1;i++){
    for(j=2;j<num+1;j++){
      if(strcmp(moji[j-1], moji[j])>0){


            strcpy(tmp, moji[j-1]);
            strcpy(moji[j-1], moji[j]);
            strcpy(moji[j], tmp);
            test=score[j-1];
            score[j-1]=score[j];
            score[j]=test;
            test=sort[j-1];
            sort[j-1]=sort[j];
            sort[j]=test;
          


      }
                else if(strcmp(moji[j-1], moji[j])==0){
          if(score[j-1]<score[j]){
            strcpy(tmp, moji[j-1]);
            strcpy(moji[j-1], moji[j]);
            strcpy(moji[j], tmp);
            test=score[j-1];
            score[j-1]=score[j];
            score[j]=test;
            test=sort[j-1];
            sort[j-1]=sort[j];
            sort[j]=test;

          }              
          }
    }
  }
 
  for (i=1;i<num+1;i++){
      printf("%d\n", sort[i]);
  }

    
 
  return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
#ifdef _WIN32
#include <windows.h>
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, string NAME)
{
#ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, 10);
    cerr << NAME << " = " << VARIABLE;
    SetConsoleTextAttribute(hConsole, 7);
    cerr << '\n';
#endif
}
#else
#define print(x) 0
#endif
struct pair_hash
{
    template<typename T1, typename T2>
    size_t operator () (const pair<T1, T2> &p) const
    {
        auto h1 = hash<T1> {}(p.first);
        auto h2 = hash<T2> {}(p.second);
        return h1 ^ h2;
    }
};
typedef long long ll;
typedef unsigned long long ull;
const ll INFLL = 2 * (ll)1e18 + 100;
const int INFINT = 2 * (int)1e9 + 100;
//ifstream fin(".in");
//ofstream fout(".out");
void die()
{
    cout << "-1\n";
    exit(0);
}
const int NMAX = 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;

int n, k;
struct mlc
{
    int a, b;
};

mlc v[NMAX];
ll sol;
ll solve(bitset<31> bit)
{
  ll ret = 0;
  for1(i, n)
  {
      bitset<31> a = bitset<31>(v[i].a);
      for0(ind, 31) if(a[ind] != bit[ind] && a[ind]) goto SKIP;
      ret += v[i].b;
      SKIP: ;
  }
  return ret;
}


int main()
{
    FASTIO;
    cin >> n >> k;
    for1(i, n)
        cin >> v[i].a >> v[i].b;
    bitset<31> K = bitset<31>(k);
    sol = solve(K);
    int pos = 30;
    for(; pos >= 0 && K[pos] == 0; pos--);

    while(pos >= 0)
    {
        if(K[pos] == 0)
        {
            pos--;
            continue;
        }
        bitset<31> cur;
        for(int i = 30; i > pos; i--) cur[i] = K[i];
        cur[pos] = 0;
        for(int i = pos - 1; i >= 0; i--) cur[i] = 1;
        sol = max(sol, solve(cur));
        pos--;
    }
    cout << sol;


    return 0;
}


Measured memory_bytes: 1024
H, W, K = gets.chomp.split(' ').map(&:to_i)
ary = []
H.times { ary.push(gets.chomp.split('')) }

# nBlack = 0
# ary.each { |row| nBlack += row.count("#") }

ans = 0

0.upto(H) do |h|
    ary.combination(h).each do |sAry|
        remainingAry = ary - sAry
        0.upto(W) do |w|
            [*0..(W - 1)].combination(w).each do |w2|
                nBlack = 0
                if w2 == nil then
                    remainingAry.each { |row| nBlack += row.count("#") }
                else
                    w2.each do |i|
                        sAry.each do |ssAry|
                            nBlack += 1 if ssAry[i] == "#"
                        end
                    end
                end
                ans += 1 if nBlack == K
            end
        end
    end
end

puts ans

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

signed main()
{
	int n = in();
	vector<int>imos(100003, 0);
	REP(i, n) {
		int foo = in() + 1;
		++imos[foo - 1];
		--imos[foo + 2];
	}
	REP(i, 100002) {
		imos[i + 1] += imos[i];
	}
	int ans = 0;
	REPC(i, imos) {
		ans = max(ans, i);
	}
	cout << ans << endl;
}

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

#define pb push_back
#define all(a) (a).begin(), (a).end()

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

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    char c; cin >> c;
    cout << char(c + 1);
}

Measured memory_bytes: 256
S = input()

e,o = [],[]
for i in range(len(S)):
    if i%2 == 0: e.append(S[i])
    else: o.append(S[i])

win,lose = 0,0
for s in e:
    if s == 'p': lose+=1
for s in o:
    if s == 'g': win+=1

print(win-lose)


Measured memory_bytes: 4084
from scipy.misc import*;from collections import*;n,m=map(int,input().split());f=Counter();p=h=1
while p*p<=m:
 p+=1
 while m%p==0:f.update([p]);m//=p
if m-1:f.update([m])
for v in f.values():h=h*sum(int(comb(n,i+1,exact=True)*comb(v-1,i,exact=True))for i in range(min(n,v)))%(10**9+7)
print(h)

Measured memory_bytes: 13292
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap |> sort
	f1 = 0
	f2 = -1
	for i in n-1:-1:1
		if f1==0
			if a[i]==a[i+1]
				f1=a[i]
			end
		elseif f2<=0
			if f2==-1
				f2 = 0
			else
				if a[i]==a[i+1]
					f2 = a[i]
				end
			end
		end
	end
	if f1>0&&f2>0
		println(f1*f2)
	else
		println(0)
	end
end

main()

Measured memory_bytes: 174680
#include <stdio.h>
int main()
{
  char n;
  scanf("%s", &n);
  if(n=='A'){
	printf("T\n");
  	}else if(n=='T'){
      printf("A\n");
    }else if(n=='C'){
      printf("G\n");
    }else{
      printf("C\n");
    }
    return 0;
  }


Measured memory_bytes: 128
N = int(input())
X = []
U = []
for i in range(N):
    x_,u_ = input().split(" ")
    X.append(float(x_))
    U.append(u_)

Y = 0

for i in range(N):
    if U[i] == "JPY":
        Y += X[i]
    else:
        Y += X[i] * 380000.0
        
print(Y)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

#define D_MAX 1000000000
#define N_MAX 100000
#define M_MAX 10000

int d;
int n;
int m;

int ad[N_MAX+1];
int ak[M_MAX+1];
int temp[N_MAX+1]; 

void MergeSort(int array[],int left,int right){
  int awork[N_MAX+1];
  int mid;
  int i;
  int j;
  int x;
  int y;
  
  if( left >= right ){
    return;
  }
  
  mid = (left + right) / 2;
  MergeSort( array, left, mid);
  MergeSort( array, mid+1, right);
  
  for( i=left; i<=mid; i++){
    awork[i] = array[i];
  }
  
  j = right;
  for( i=mid+1; i<=right; i++){
    awork[i] = array[j];
    j--;
  }
  
  x = left;
  y = right;
  
  for( i=left; i<=right; i++){
    if(awork[x] <= awork[y]){
      array[i] = awork[x];
      x++;
    }else{
      array[i] = awork[y];
      y--;
    }
  }
}

int calcDist(int k){
  int i;
  int diff;
  int preDiff = 0;
  int minDist = d;
  int tmpDist;
  int halfDist = d >> 1;
  
  for( i=0; i<=n; i++){
    diff = ad[i] - k;
    if( minDist > abs(diff) ){
      minDist = abs(diff);
    }
    preDiff = diff;
  }
  return minDist;
}

void input(void){
  int i;
  scanf("%d",&d);
  if( d != 0){
    scanf("%d",&n);
    scanf("%d",&m);
    ad[0] = 0;
    for( i=1; i<=n-1; i++){
      scanf("%d",&ad[i]);
    }
    ad[n] = d;
    for( i=1; i<=m; i++){
      scanf("%d",&ak[i]);
    }
  }
}

int main(void){
  int i;
  int sumDist = 0;
  while( 1 ){
    input();
    if( d == 0 ){
      break;
    }
    MergeSort( ad, 0, n);
    for( i=1; i<=m; i++){
      sumDist += calcDist(ak[i]);
    }
    printf("%d\n",sumDist);
    sumDist = 0;
  }
}




Measured memory_bytes: 8756
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    char c; cin >> c;
    cout << (char)('A'+32*(c>'Z')) << endl;
}


Measured memory_bytes: 3576
<?php
$n=trim(fgets(STDIN));
$X=explode(' ',trim(fgets(STDIN)),$n);
$Y=explode(' ',trim(fgets(STDIN)),$n);

$A=0.0;
$B=0.0;
$C=0.0;
$D=0.0;
for($i=0;$i<$n;$i++){
  $a=($X[$i]<$Y[$i])?$Y[$i]-$X[$i]:$X[$i]-$Y[$i];
  $b=$a*$a;
  $A+=$a;
  $B+=$b;
  $C+=$b*$a;
  if($D<$a){$D=$a;}
}
echo $A
,PHP_EOL
,pow($B,1/2)
,PHP_EOL
,pow($C,1/3)
,PHP_EOL
,$D;
?>

Measured memory_bytes: 15604
n=int(input())
a=list(map(int,input().split()))
x=0
for i in a[2:]:x^=i
m=(a[0]+a[1]-x)//2
if a[0]+a[1]!=x+m*2or m>a[0]or(x&m)!=0:exit(print(-1))
l=1<<(max(x.bit_length(),m.bit_length())+1)
while l>0:
 if((x&l)!=0)and((m|l)<=a[0]):m|=l
 l>>=1
print(a[0]-m if m!=0else-1)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    for(int i = 0 ; i < n ; i++)
    	cin >> a[i];
    for(int i = 0 ; i < n ; i+=2)
    	sum += a[i];
    for(int i = 1 ; i < n ; i += 2)
    	sum -= a[i];
    int ans[n];
    ans[0] = sum;
    for(int i = 1 ; i < n ; i++){
    	ans[i] = 2 * a[i - 1] - ans[i - 1];
    }
    for(int i = 0 ; i  < n ; i++)
    	cout << ans[i] << " ";
    cout << endl;
} 

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int path[4][4]= {0};
    for(int i = 0; i < 3; i++){
        int a,b;
        cin >> a >> b;
        path[a - 1][b - 1] = path[b - 1][a - 1] = 1;
    }
        for(int i = 0; i < 4; i++){
            int cnt = 0;
            for(int j = 0; j < 4; j++){
                if(path[i][j] == 1)
                    cnt++;
            }
            if(cnt == 3 || cnt == 0){
                cout << "NO" << endl;
                return 0;
            }
        }
        cout << "YES" << endl;
    }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
const ll mod = 1e9+7;

ll dp[2010];
int main(){
  int s;
  cin >> s;
  dp[0] = 1;
  for (int i = 0; i <= s;i++){
    if (i-4 >= 0 ) dp[i] += dp[i-1];
    if (i-3 >= 0) dp[i] += dp[i-3];
    dp[i] %= mod;
  }
  cout << dp[s] << endl;

  return 0;
}

Measured memory_bytes: 3552
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

inline int gcd(int a, int b) {
  return b == 0 ? a : gcd(b, a % b);
}

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

  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    d[i] = abs(X - x);
  }
  int ans = d[0];
  for (int i = 1; i < d.size(); i++) {
    int a = min(ans, d[i]);
    int b = max(ans, d[i]);
    ans = gcd(a, b);
  }
  cout << ans << endl;

  return 0;
}


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

int N, M, s[505], v[505], dp[10005];

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

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

    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < N; i++) {
        for (int j = M; j >= s[i]; j--) {
            dp[j] = max(dp[j], dp[j-s[i]]+v[i]);
        }
    }

    int ans = 0;
    for (int i = 0; i <= M; ++i) ans = max(ans, dp[i]);
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main{

	public static void main(String[] args){

		Scanner sc =new Scanner(System.in);
		double number =sc.nextDouble();
		double[] translimit =new double[5];
		for(int i=0;i<5;i++){
			translimit[i]=sc.nextDouble();
		}

		int bottleneck = 0;
		for(int i=1;i<5;i++){
			if(translimit[bottleneck]>translimit[i]){
				bottleneck =i;
			}
		}

		long ans =(long)Math.ceil(number/translimit[bottleneck])+4;
		System.out.println(ans);
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  
  int count = 0;
  int tmp = 1;

  for(int i=0;i<N;i++){
    if(a[tmp-1]==2){
      cout << count+1 << endl;
      break;
    }
    
    tmp = a[tmp-1];
    count ++;
    
    if(i==N-1){
      cout << -1 << endl;
    }

  }

  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()
 
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
double EPS = 1e-50;
 
signed main() {
  double n;
  cin >> n;
 
  Rrep(i, 1, 3501) Rrep(j, i, 3501) {
    if ( n <= 1.0 / (double)i + 1.0 / (double)j ) continue;
    int l = 1, r = 3501;
    int cnt = 15;
    while ( cnt-- ) {
      int mod = (l + r) / 2;
      if ( 4.0 < n / (double)i + n / (double)j + n / (double)mod ) l = mod;
      else r = mod;
    }
 
    if ( fabs(4.0 - (n / (double)i + n / (double)j + n / (double)l)) < EPS ) {
      cout << i << " " << j << " " << l << endl;
      return 0;
    }
    if ( fabs(4.0 - (n / (double)i + n / (double)j + n / (double)r)) < EPS ) {
      cout << i << " " << j << " " << r << endl;
      return 0;
    }
    
  }
  return 0;
}


Measured memory_bytes: 384
from statistics import median

R, G, B, N = [int(x) for x in input().split()]

count = 0
for r in range(N+1):
    for g in range(N+1):
        if (N - R*r - G*g) < 0:
            break
        if (N - R*r - G*g) % B == 0:
            count += 1

print(count)


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

int main(){
  int A, B, num=0;
  
  cin >> A >> B;
  
  for (int N=A;N<=B;N++){
    if ( ((N/10000)==(N%10))&&((N/1000%10)==(N/10%10)) )
   	  num++;
  }
  
  cout << num << endl;
}

Measured memory_bytes: 3684
r,c=map(int,input().split())
C=[]
for _ in range(r):
  ns = list(map(int, input().split()))
  ns.append(sum(ns))
  C.append(ns)
#print(C)
R = list(zip(*C))
#print(R)
C.append([sum(x) for x in R])
for r in C:
  print(*r)


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

int main() {
	int n,m;
    cin >> n >> m;
    int count = 0;
    for(int i=n-1;i>0;i--){
      count = count+i;
    }
    for(int i=m-1;i>0;i--){
      count = count+i;
    }
    cout << count << endl;
}

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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;

    println((a + b) * c / 2);
}


Measured memory_bytes: 3604
n = int(input())
ans = [0 for i in range(10001)]

for i in range(1,105):
    for j in range(1,105):
        for m in range(1,105):
            v = i**2+j**2+m**2+i*j+j*m+m*i
            #print(v)
            if v<10001:
                ans[v]+=1
#print(count)

for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 9312