akhauriyash/Code-Regression huggingface dataset:
n = int(input())
arr = []
for i in range(n):
    x,y = map(int,input().split())
    arr.append([x,y])
arr = sorted(arr, key = lambda x : (x[1],-x[0]))

ans = True
ti = 0
for i in arr:
    if ti + i[0] > i[1]:
        ans = False
        break
    ti += i[0]
if ans:
    print("Yes")
else:
    print("No")        


Measured memory_bytes: 58572
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    string s;
    string t;
    cin >> s >> t;
    int ans=0;
    rep(i,t.size()){
        rotate(s.rbegin(),s.rbegin()+1,s.rend());
        if(s==t){
            cout << "Yes";
            return 0;
        }
    }
    
    cout << "No";
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using ll=long long;
#define rep(i,j,n) for(ll i=(j);i<(n);i++)
#define per(i,n,j) for(ll i=(n);i>=(j);i--)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

ll l,r;

int main(){
    cin>>l>>r;
    ll ans=INF;
    rep(i,l,min(l+2019,r)){
        rep(j,l+1,min(l+2020,r+1)){
            ll num=(i*j)%2019;
            chmin(ans,num);
        }
    }
    /*if(l%2019==0 ||l%2019>=r%2019 || r-l>=2019) ans=0;
    else{
        ll num;
        num=l%2019*(l+1)%2019;
        if(num<2019) ans=num;
        else ans=num%2019;
    }*/
    cout<<ans<<"\n";
    return 0;
}


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

int main() {
  int K;
  string S;
  cin >> K >> S;

  if ((int)S.size()<=K){
    cout << S << endl;
  } else {
    for (int i = 0; i < K; i++) {
      cout << S[i] ;
    }
    cout << "..." << endl;
  }

  return 0;
}

Measured memory_bytes: 3620
import numpy as np
h,w=map(int,input().split())
a=np.array([[0 if x=='.' else 1 for x in input()] for _ in range(h)])
f=True
while(f):
    f=False
    i=0
    while(i<a.shape[0]):
        if np.sum(a[i])==0:
            f=True
            a=np.delete(a,i,0)
        i+=1
    i=0
    while(i<a.shape[1]):
        if np.sum(a[:,i])==0:
            f=True
            a=np.delete(a,i,1)
        i+=1
a=[list(x) for x in list(a)]
a=[['.' if x==0 else '#' for x in a[i]] for i in range(len(a))]
for i in range(len(a)):
    print(''.join(a[i]))


Measured memory_bytes: 13368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7,INF=1e17;
const int iINF=1e9;
#define enld endl
int main(){
    int n,d,x[20][20];
    cin>>n>>d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            double sum=0;
            for(int k=0;k<d;k++){
                sum+=pow(x[i][k]-x[j][k],2);
            }
            sum=sqrt(sum);
            if(ceil(sum)==floor(sum))ans++;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int dp[50];

int fib(int n) {
  if (n == 0 || n == 1) {
    return dp[n] = 1;
  }
  if (dp[n] != -1) {
    return dp[n];
  }
  return dp[n] = fib(n - 1) + fib(n - 2);
}

int main() {
  int n, i;
  for (i = 0; i < 50; i++) dp[i] = -1;

  scanf("%d", &n);
  printf("%d\n", fib(n));

  return 0;
}



Measured memory_bytes: 2744
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
long a = sc.nextLong();
long b = sc.nextLong();
long x = sc.nextLong();
long ax;
if(a != 0){
ax = ((a -1) / x )+ 1;
}else{
ax = 0;
}
long bx = b / x + 1;
long ans = bx - ax;

System.out.println(ans);


}
}


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int A, B, C;
	cin >>A >>B >>C;
	cout <<A*(B==C)+B*(A==C)+C*(A==B) <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;
typedef vector<ll>  mat;
int sz;
mat mul(mat A,mat B){
   mat C(sz);
   rep(i,sz)rep(j,sz)C[(i+j)%sz]+=A[i]*B[j]%mod;
   rep(i,sz)C[i]%=mod;
   return C;
}

mat pow(mat A,ll k){
   mat B(sz);
   B[0]=1;
   while(k>0){
       if(k&1)B=mul(A,B);
       A=mul(A,A);
       k/=2;
   }
   return B;
}
int main(){
    cin>>sz;
    int m,k;
    cin>>m>>k;
    mat A(sz);
    int p[m];
    rep(i,m){
        cin>>p[i];
        A[p[i]%sz]++;
    }
    A[0]++;
    A=pow(A,k);
    rep(i,sz)cout<<A[i]<<endl;
    return 0;
}


Measured memory_bytes: 3232
/*
×¢Òâ·¶Î§£¡
short·¶Î§£º-32768~32767
unsigned short·¶Î§£º0~65535
int·¶Î§£º-2147483648~2147483647
uint·¶Î§£º0~4294967295
INT·¶Î§£º-9223372036854775808~9223372036854775807
UINT·¶Î§£º0~18446744073709551615
float·¶Î§£º-3.4e38~3.4e38£¬¾«¶È£º6~7Î»
double·¶Î§£º-1.7e308~1.7e308£¬¾«¶È£º15~16Î»
ldouble·¶Î§£º-1.2e4932~1.2e4932£¬¾«¶È£º18~19Î»
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef greater<int> gint;
typedef greater<INT> GINT;
typedef greater<pii> gpii;
typedef greater<PII> GPII;

int n,a[100007],mn[4];

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		a[i]%=4;
		mn[a[i]]++;
	}
	if(mn[1]+mn[3]<=mn[0])OVER("Yes");
	else if(mn[1]+mn[3]+mn[0]==n&&mn[1]+mn[3]<=mn[0]+1)OVER("Yes");
	else OVER("No");
}

Measured memory_bytes: 640
n,m=map(int,input().split())
num=[]
ans=[""]*m
numcount=[1]*n
count=1
for i in range(m):
    p,y=map(int,input().split())
    num.append([p,y,i])
stry= lambda val: val[1]
num.sort(key=stry)
for i in range(m):
    p=str(num[i][0])
    y=str(numcount[int(num[i][0])-1])
    numcount[int(num[i][0])-1]+=1
    ans[num[i][2]]="0"*(6-len(p))+p+"0"*(6-len(y))+y
for i in range(m):
    print(ans[i])


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

int main() {
  int num;
  int mon;
  long long tmp;
  map<long long, long long> m;
  cin >> num;
  
  vector<long long> vec(num);
  for(int i = 0; i < num; i++) cin >> vec.at(i);
  
  cin >> mon;
  
  for(int i = 0; i < mon; i++){
    cin >> tmp;
    m[tmp] += 1;
  }
  
  for(int i =0; i < num; i++){
    auto itr = m.find(vec.at(i));
    if(itr != m.end()){
      m[vec.at(i)] -= 1;
    }
  }
  
  long long Min = -1;
  for(auto itr : m){
    Min = max(Min, itr.second);
  }
  
  if(Min <= 0) cout << "YES";
  else cout << "NO";
}


Measured memory_bytes: 14336
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    int ans = 0;
    per(i, n) {
        a[i] += ans;
        if(a[i] % b[i] == 0) continue;
        ans += (b[i] - a[i] % b[i]);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define M 2000000000
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200100
vector<int>e[N];
int n, m;
bool used[N];
vector<int>a;
vector<int>b;
vector<int>c;
void dfs(int k) {
	used[k] = true;
	a.push_back(k);
	f(i, e[k].size()) {
		if (!used[e[k][i]]) {
			dfs(e[k][i]);
			return;
		}
	}
	return;
}
void dfs2(int k) {
	used[k] = true;
	b.push_back(k);
	f(i, e[k].size()) {
		if (!used[e[k][i]]) {
			dfs2(e[k][i]);
			return;
		}
	}
	return;
}

int main(void) {
	scanf("%d %d", &n, &m);
	int x, y, z;
	int ans = 0;
	f(i, m) {
		scanf("%d %d", &x, &y);
		e[x - 1].push_back(y - 1);
		e[y - 1].push_back(x - 1);
	}
	f(i, n)used[i] = false;
	dfs(0);
	dfs2(0);
	x = a.size();
	for (int i = x - 1; i > 0; i--)c.push_back(a[i]);
	x = b.size();
	f(i, x)c.push_back(b[i]);
	x = c.size();
	printf("%d\n", x);
	f(i, x - 1)printf("%d ", c[i]+1);
	printf("%d\n", c[x - 1]+1);
	return 0;
}

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

int main(){
	int n,x,ans,i,j,k;
	for(;;){
		ans = 0;
		cin>>n>>x;
		if(n == x && n == 0)
			break;
		else{
		for(i = 1;i<=n;i++){
			if(i > 100)
				break;
		for(j = i+1;j<=n;j++){
			if(j > 100)
				break;
		for(k = j+1;k<=n;k++){
			if(k > 100)
				break;
			if(i+j+k==x){
				ans++;
			}
		}
		}
		}
	}

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

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if(n%3!=0){
		for(int i=1;i<=n;i++){
			if(a[i]!=0){
				printf("No\n");
				return 0;
			}
		}
		printf("Yes\n");
	}
	else{
		for(int i=1;i<=n/3;i++){
			if(a[i]!=a[1]){
				printf("No\n");
				return 0;
			}
		}
		for(int i=n/3+1;i<=n/3*2;i++){
			if(a[i]!=a[n/3+1]){
				printf("No\n");
				return 0;
			}
		}
		for(int i=n/3*2+1;i<=n;i++){
			if(a[i]!=a[n/3*2+1]){
				printf("No\n");
				return 0;
			}
		}
		int y=a[1]^a[n/3+1];
		y=y^a[n/3*2+1];
		if(y==0) printf("Yes\n");
		else printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    vector<ll> sum(n+1,0);
    rep(i,n){
        sum[i+1]=sum[i]+a[i];
    }
    ll ans=LINF;
    for(int i=1;i<n;i++){
        ans=min(ans,abs(sum[i]-(sum[n]-sum[i])));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
def main():
    S = input()
    N = len(S)
    for i in range(N):
        for j in range(i, N+1):
            ans = []
            for k in range(N):
                if i <= k and k < j:
                    continue
                ans.append(S[k])
            if "".join(ans) == "keyence":
                print("YES")
                return
    print("NO")


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long I64;

const int NMAX = 100;

int N;
int v[2*NMAX+2][NMAX+2];
int used[NMAX+2];
int ans[NMAX+2][NMAX+2];

int main()
{
    int N;
    int v[10000];
    cin >> N ;
    for( int i = 1;  i <= N;  ++i ) cin >> v[i];
    sort( v+1, v+N+1 );
    int dif = 0;
    for( int i = 1;  i <= N;  ++i ) {
        if( i % 2 == 1 ) dif += v[i];
        else dif -= v[i];
    }
    cout << abs(dif) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 510000;
const int MOD = 1000000007;
typedef pair<int , int> P;
typedef long long ll;

int main () {
  ll N, K, ans;
  cin >> N >> K;
  ll S[N+10];
  ans = 0;
  S[0] = 0;
  for (int i = 1; i <= N; ++i) {
    S[i] = S[i-1] + i;
  }
  for(int i = K; i <= N+1; ++i) {
    if(i == N+1) {
      ans += 1;
      ans %= MOD;
    } else {
      ans += (S[N] - S[N-i]) - S[i-1] + 1;
      ans %= MOD;
    }    
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 5220
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll x,y;
    cin>>x>>y;
    if(y%2==1)
    {
        cout<<"No\n";
        return;
    }
    ll mini=x*2;
    ll maxi=x*4;
    if(y>=mini && y<=maxi)
    {
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15532
using System;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            long n=0;
            int[] x = new int[100000];
            x[0] = int.Parse(Console.ReadLine());
            while (x[n]!=0)
            {
                n++;
                x[n] = int.Parse(Console.ReadLine());
            }
            for (int c = 0; c < n; c++)
            {
                Console.WriteLine("Case " + (c + 1) + ": " + x[c]);
            }
        }
    }
}

Measured memory_bytes: 6504
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define show(a) cout<<""#a""<<" is "<<a<<endl;
#define shw(a,b)cout<<"-->"<<a<<" "<<b<<endl;
#define print(arr,xx)for(int i=0;i<xx;i++)cout<<arr[i]<<" \n"[i>=xx];
#define here cout<<"here\n"; 
int caseno=0;
#define print_case cout<<"Case "<<++caseno<<": ";
#define fout freopen("output.txt","w",stdout);
#define fin freopen("input.txt","r",stdin);
#define pb push_back
#define ll long long
const int primemod=1e9+7;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
const ll maxsize = 100000+9;
#define inf 1<<28
 ll n;
void solve(){
	ll a ,b,c,k;
	cin>>a>>b>>c>>k;
	ll cnt=0;
	cnt+=min(a,k);
	k=max(0,k-a);
	if(k>0){
		k-=b;
	}
	if(k>0){
		cnt-=k;
	}
	cout<<cnt<<endl;
}
 
int main(){
	#ifndef ONLINE_JUDGE
 	fout	
 	fin
 	int kase=1; 	
 	while(kase--){
 	#endif     
 	///-----		
 	fastio
 	int T;
 	T=1;
 
 	while(T--){
 		 // if(solve())cout<<"Yes"<<endl;
 		 // else cout<<"No"<<endl;
 		solve();
 	}
 	///-----
 }
 
 #ifndef ONLINE_JUDGE
 }			
 #endif
 /*
9
1 2 3 4
*/

Measured memory_bytes: 3672
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
// #define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 5e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];
int dp[N];
int sub[N];
int n, c;
vector<int> v[N];



void solve()
{
	int n, k, s;
	cin >> n >> k >> s;
	vector<int> ret;
	int t = k;
	while(t--)
	{
		ret.push_back(s);
	}
	if(s != 1e9)
	{
		while(ret.size() != n)
		{
			ret.push_back(1e9);
		}
	}
	else
	{
		while(ret.size() != n)
		{
			ret.push_back(1000000000 - 1);
		}	
	}
	for(int x : ret)
	{
		cout << x << " ";
	}
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

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

using namespace std;

#define MAX 7368800

bool f[MAX];

int main()
{
    int m, n;
    while(cin >> m >> n, m|n)
    {
        fill(f, f+MAX, false);
        int p = m;
        for(int i=0; i<n; i++)
        {
            for(int j=2*p; j<MAX; j+=p)
            {
                f[j] = true;
            }
            do{p++;} while(f[p]);
        }
        cout << p << endl;
    }
}

Measured memory_bytes: 10228
import scala.io.StdIn.readLine

class Dice(var d:List[Int]) {
  val fs = (x:List[Int]) => x match {case List(x1,x2,x3,x4,x5,x6) => List(x5,x1,x3,x4,x6,x2) }
  val fw = (x:List[Int]) => x match {case List(x1,x2,x3,x4,x5,x6) => List(x3,x2,x6,x1,x5,x4) }

  def roll(dir:Char)  =
    dir match {
      case 'S' => fs
      case 'N' => fs compose fs  compose fs
      case 'W' => fw
      case 'E' => fw compose fw compose fw
    }

  def apply(f:(List[Int])=>List[Int]) = this.d = f(this.d)
  def getTopFace() = d(0).toString
}

object Main extends App {
  val faces = readLine.split(" ").map(_.toInt).toList
  val dice = new Dice(faces)
  var rolls:(List[Int])=>List[Int] = x=>x

  dice.apply(readLine.foldLeft(rolls) { (x,y) => dice.roll(y) compose x })
  println(dice.getTopFace)
}

Measured memory_bytes: 44132
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=2e5+5;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int n,m,i,x,y;
map<int,int>mp[nmax];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>m;
    for(i=1;i<=m;i++)
	{
		cin>>x>>y;
		mp[x][y]=mp[y][x]=1;
	}
	for(i=2;i<n;i++)if(mp[1][i] && mp[i][n])rc("POSSIBLE");
	rc("IMPOSSIBLE");
}

Measured memory_bytes: 39808
public class LibraryOfDataStructures{
	public static void Main(){
		string[] line = System.Console.ReadLine().Split(' ');
		int n = int.Parse(line[0]);
		int p = int.Parse(line[1]);

		int[] dt = new int[n];

		for (int i = 0; i < n; i++)
		{
			dt[i] = i;
		}

		for (int k = 0; k < p; k++)
		{
			string[] line2 = System.Console.ReadLine().Split(' ');
			int cmd = int.Parse(line2[0]);
			int a = int.Parse(line2[1]);
			int b = int.Parse(line2[2]);

			switch (cmd)
			{
				case 0:
					// unite
					int group = dt[a];
					int group2 = dt[b];
					for (int l = 0; l < n; l++)
					{
						if (dt[l] == group2)
						{
							dt[l] = group;
						}
					}
					break;
				case 1:
					System.Console.WriteLine(dt[a] == dt[b] ? "1" : "0");
					break;
			}
		}
	}
}

Measured memory_bytes: 19908
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();

        double sum = 0.0;
        for (int i = 1; i <= N; i++) {
            if (i >= K) {
                sum += 1.0 / N;
                continue;
            }
            int score = i;
            int ntos = 0;
            double p = 1.0 / N;
            while (score < K) {
                score *= 2;
                ntos++;
                p /= 2;
            }
            sum += p;
        }

        System.out.println(sum);

        return;
    }

}

Measured memory_bytes: 21844
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

const long long PRIME = 1000000007;
const double mpi = 3.14159265358979323846;

using namespace std;


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  if(a[n - 1] - a[0] > 1) {
    cout << "No" << endl;
    return 0;
  }
  map<int, int> s;
  for(int i = 0; i < n; i++) s[a[i]]++;
  if(a[0] != a[n - 1] && s[a[0]] + 1 <= a[n - 1] && a[n - 1] <= s[a[0]] + s[a[n - 1]] / 2) {
    cout << "Yes" << endl;
    return 0;
  }
  if(a[0] == a[n - 1]) {
    if(1 <= a[n - 1] && a[n - 1] <= s[a[0]] / 2) {
      cout << "Yes" << endl;
      return 0;
    }
    if(n - 1 == a[0]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 768
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BTwoColorsCardGame {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n, m;
	    in >> n;
	    map<string, int> s, t;
	    string instr;
	    for(int i=0; i<n; i++){
	        in >> instr;
	        s[instr]++;
	    }
	    in >> m;
	    for(int i=0; i<m; i++){
	        in >> instr;
	        t[instr]++;
	    }

	    int res = 0;
	    for(auto const& e : s){
	        int num = e.second;
	        if(t[e.first]) num -= t[e.first];
	        chmax(res, num);
	    }

	    out << res << endl;
	}
};


int main() {
	BTwoColorsCardGame solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r; };



Node T[MAX];
int n, D[MAX];

void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = "<<T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL)cout << "root, ";
	else if (T[u].l == NIL)cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";

	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i)cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

int rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL)rec(T[u].r, p);
	if (T[u].l != NIL)rec(T[u].l, p + 1);
	return 0;
}

int main() {
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++)T[i].p = T[i].l = T[i].r = NIL;

	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++) {
			cin >> c;
			if (j == 0)T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; i++) {
		if (T[i].p == NIL)r = i;
	}
	rec(r, 0);
	for (i = 0; i < n; i++)print(i);

	return 0;
}


Measured memory_bytes: 7732
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	double a,b,c; cin >> a >> b >> c;
	printf("%.8f\n",a*b*sin(M_PI*c/180)/2 );
	printf("%.8f\n",a+b+sqrt(a*a+b*b-2*a*b*cos(M_PI*c/180)) );
	printf("%.8f\n",b*sin(M_PI*c/180) );
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

struct StronglyConnectedComponents {
  int V;
  std::vector<std::vector<int>> G, rG;
  std::vector<int> vs, cmp;
  std::vector<bool> used;

  StronglyConnectedComponents(int V) : V(V) {
    used.assign(V, false);
    G.resize(V), rG.resize(V);
    cmp.resize(V);
  }

  void add_edge(int from, int to) {
    G[from].push_back(to);
    rG[to].push_back(from);
  }

  void dfs(int v) {
    used[v] = true;
    for (int c : G[v])
      if (not used[c]) dfs(c);
    vs.push_back(v);
  }

  void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for (int c : rG[v])
      if (not used[c]) rdfs(c, k);
  }

  int run() {
    fill(used.begin(), used.end(), false);
    vs.clear();
    for (int v = 0; v < V; v++)
      if (!used[v]) dfs(v);
    fill(used.begin(), used.end(), false);
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--)
      if (!used[vs[i]]) rdfs(vs[i], k++);
    return k;
  }
};


int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  map<pair<int, int>, int> mp;
  int cnt = 0;
  REP(i, N) REP(j, N) {
    if (i < j) {
      mp[make_pair(i, j)] = mp[make_pair(j, i)] = cnt;
      //cout << '(' << i << ',' << j << ")=" << cnt << endl;
      cnt++;
    }
  }

  StronglyConnectedComponents scc(cnt);
  REP(i, N) {
    vector<int> A(N-1); REP(j, N-1) cin >> A[j], A[j]--;
    REP(j, N-2) {
      int from = mp[make_pair(i, A[j])], to = mp[make_pair(i, A[j+1])];
      //cout << from << "->" << to << endl;
      scc.add_edge(from, to);
    }
  }

  if (scc.run() != cnt) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> order(cnt);
  REP(i, cnt) order[scc.cmp[i]] = i;

  vector<int> dp(cnt, 1);

  for (int v : order) {
    for (int c : scc.G[v]) {
      dp[c] = max(dp[c], dp[v] + 1);
    }
  }

  cout << *max_element(ALL(dp)) << endl;
  return 0;
}


Measured memory_bytes: 125424
#include<iostream>

int main()
{
    int n[100],x[100],i,j,k,c,a,count[100];

    for (i = 0; i < 100; i++)count[i] = 0;
    
    for (a = 0; a < 100; a++) {
        std::cin >> n[a] >> x[a];
        if ((n[a] == 0) && (x[a] == 0))break;
    }
    for (c = 0; c < a; c++) {
        for (i = 1; i <= n[c]; i++) {
            for (j = 1; j <= n[c]; j++) {
                for (k = 1; k <= n[c]; k++) {
                    if ((i < j) && (j < k)) {
                        if (i + j + k == x[c]) {
                            count[c]++;
                        }
                    }

                }
            }
        }
    }
    for (c = 0; c < a; c++) {
        std::cout << count[c] << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3048
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	std::sort(p,p+a);
	int ret=0;
	int cont=0;
	for(int i=0;i<a;i++){
		if(i==0||p[i]!=p[i-1]){
			ret+=cont%2;
			cont=1;
		}else cont++;
	}
	ret+=cont%2;
	printf("%d\n",ret);
}

Measured memory_bytes: 512
// テ・ツ淞コテヲツ慊ャテ」ツδ?」ツδウテ」ツδ療」ツδャテ」ツδシテ」ツδ?

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    string pat = "23456789TJQKA";
    while(1) {
        char c; cin >> c;
        if(c == '#') break;

        string vs[5][15];
        rep(i,0,4) rep(j,0,13) cin >> vs[i][j];
        int EW = 0, NS = 0, flr = 0;
        rep(turn,0,13) {
            int ma = -1, ma_suit = -1, idx = -1;
            char prev_suit = 127;
            rep(i,0,4) {
                int k = (i + flr) % 4;
                char suit = vs[k][turn][1];
                int val   = pat.find(vs[k][turn][0]);
                if(prev_suit == 127) prev_suit = suit;

                if(suit == c) {
                    if(ma_suit < val) {
                        ma_suit = val;
                        idx = k;
                    }
                }
                else if(suit == prev_suit) {
                    if(ma < val && ma_suit == -1) {
                        ma = val;
                        idx = k;
                    }
                }
            }
            // printf("turn %lld: winner = %lld\n", turn+1, idx);
            if(idx % 2) EW++;
            else NS++;
            flr = idx;
        }
        if(EW < NS) printf("NS %lld\n", NS - 6);
        else printf("EW %lld\n", EW - 6);
    }
    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define input(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define int long long
using namespace std;
signed main(){
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
    cin >> n;
    int a[n][3];
    for(int i=0;i<n;i++){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    int dp[n][3];
    memset(dp,0,sizeof(dp));
    dp[n-1][0]=a[n-1][0];
    dp[n-1][1]=a[n-1][1];
    dp[n-1][2]=a[n-1][2];
    for(int i=n-2;i>=0;i--){
            dp[i][0]=max(dp[i+1][1],dp[i+1][2])+a[i][0];
            dp[i][1]=max(dp[i+1][0],dp[i+1][2])+a[i][1];
            dp[i][2]=max(dp[i+1][0],dp[i+1][1])+a[i][2];
            //cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl;
    }
    cout << max(max(dp[0][0],dp[0][1]),dp[0][2]);
}

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

using namespace std;

int main(){
    int n;
    while(cin >> n){
        vector<vector<int>> cnt(2, vector<int>(100001, 0));
        for(int i=0;i<n;i++){
            int v; cin >> v;
            cnt[i%2][v]++;
        }
        vector<vector<pair<int,int>>> vp(2, vector<pair<int,int>>(1, make_pair(n/2, 0)));
        for(int i=0;i<2;i++){
            for(int j=1;j<=100000;j++){
                if(cnt[i][j]) vp[i].emplace_back(n/2-cnt[i][j], j);
            }
        }
        for(auto& v : vp) sort(v.begin(), v.end());
        if(vp[0][0].second != vp[1][0].second){
            cout << vp[0][0].first + vp[1][0].first << endl;
        } else {
            cout << min(vp[0][0].first + vp[1][1].first, vp[0][1].first + vp[1][0].first) << endl;
        }
    }
}

Measured memory_bytes: 2296
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

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

ll deg(int i){
  ll ret = 1;
  while(i != 0){
    if(i/10 == 0){
      break;
    }
    i/=10;
  }
  
  return i;
}
bool judge(string s){
  bool ret = false;
  string t = s;
  reverse(t.begin(), t.end());
  if(s == t){
    ret = true;
  }
  return ret;
}

//map<ll,ll> m;
void solve(){
  int n,m;
  cin >> n >> m;
  int a[n];
  ll s = 0;
  for(int i = 0;i < n;i++) {
    cin >> a[i];
    s += a[i];
  }
  int ans = 0;
  int r = s%(4*m) ? 1:0;
  for(int i = 0;i < n;i++){
    if(a[i] >= s/4/m+r) ans++;
  }
  if(ans >= m)cout << "Yes" << endl;
  else cout << "No" << endl;

}


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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a,b,c[5]={0};
  for(int i=0; i<3; i++) {
    cin >> a;
    c[a]++;
    cin >> b;
    c[b]++;
  }
  if(c[1]<3&&c[2]<3&&c[3]<3&&c[4]<3) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int ans=0;
	
	while(1)
	{
		 if(a%2!=0 || b%2!=0 || c%2!=0)
		{
			break;
		}
		if(a==b && b==c && a==c)
		{
		ans=-1;
		break;
		}
		
		int a1 = b+c;
		int b1 = a+c;
		int c1 = a+b;
		
			ans++;		
			
			a=a1/2;
			b=b1/2;
			c=c1/2;			
	}
	cout<<ans;	
}


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

int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    if (b > a + w || b + w < a)
    {
        if (a > b)
        {
            cout << a - b - w << endl;
        }
        else
        {
            cout << b - a - w << endl;
        }
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 3596
import math

K = int(input())

ans = 0
arr = []

for b in range(1, K+1):
    for c in range(1, K+1):
        arr.append(math.gcd(b, c))

for a in range(1, K+1):
    for n in arr:
        ans += math.gcd(a, n)

print(ans)


Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int MOD=1000000007;
ULL pw(ULL a, ULL n){ ULL b=1; while(n){ if(n&1){ b=(b*a)%MOD; } a=(a*a)%MOD; n>>=1; } return b; }

int main(){ 
int i, N, A; cin >> N; map<int, int> freq;
for(i=0; i<N; i++){ cin >> A; freq[A]++; }  
if(N%2&&freq[0]!=1){ cout << 0 << "\n"; return 0; }
for(i=1+N%2; i<=N; i+=2){ if(freq[i]!=2){ cout << 0 << "\n"; return 0; } }
cout << pw(2, N/2) << "\n";
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<stdlib.h>
const int maxn = 1e5;
int main(void)
{
	int num[40] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	scanf("%d", &k);
	printf("%d\n", num[k - 1]);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[200009],ans[200009];
main(){
    vector<pair<int,int> > v;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >>a[i];
        v.push_back({a[i],i});
    }
    sort(v.begin(),v.end());
    for(int i =0 ; i < n/2; i++)
        ans[v[i].second]=v[n/2].first;
    for(int i =n/2 ; i < n; i++)
        ans[v[i].second]=v[n/2-1].first;
    for (int i= 0 ;i < n; i++)
        cout<<ans[i]<<endl;

}


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

using namespace std;

int main(){
 long n,t;
   cin >> n >> t;
 
  vector<long> b(n);
  
  long a;
  cin >>a;
  long num=a;
  b[0]=0;
  
  for(int i=1;i<n;i++){
    cin >> a;
    b[i]=a-num;
    num=min(num,a);
  }

  sort(b.begin(),b.end());
  
  cout <<upper_bound(b.begin(),b.end(),b[n-1])-lower_bound(b.begin(),b.end(),b[n-1]) << endl;
     

}

Measured memory_bytes: 1024
#include<vector>
#include<iostream>
#include<fstream>
#include<string>
#include<cassert>
#include<algorithm>
#include<random>
#include<map>
#include<set>

using namespace std;

//int mod = 998244353;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<vector<int>>vvi;
typedef vector<vector<ll>>vvl;
typedef vector< pair<ll, ll>>vpll;
typedef vector< pair<ld, ld>>vpld;
typedef pair<ld, ld>pld;
#define mp make_pair
#define pb push_back

const int mod = 998244353;
int sum(int a, int b)
{
	int c = a + b;
	if (c >= mod)
	{
		c -= mod;
	}
	return c;
}
int dif(int a, int b)
{
	int c = a - b;
	if (c < 0)
	{
		c += mod;
	}
	return c;
}
int mlt(int a, int b)
{
	ll c = a * 1LL * b;
	return c % mod;
}
int ibit(int n, int i)
{
	return ((n >> i) & 1);
}
ll left(ll a, ll b)
{
	ll c = b - a;
	return a + (c - 1) / 2;
}
ll right(ll a, ll b, ll n)
{
	return left(n - b + 1, n - a + 1);
}
void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	ll a, b, n;
	cin >> n >> a >> b;
	if (b % 2 == a % 2)
	{
		cout << (b - a) / 2 << endl;
	}
	else
	{
		cout << min(left(a, b), right(a, b, n))<<endl;
	}
}
int main()
{
	solve();
	int n;
	cin >> n;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0558
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;

int row, col, n;

struct point {
	int x, y;
};

char map[1010][1010];
int d[1010][1010];
int direct[4][2] = { {0,1},{0,-1},{1,0},{-1,0} };

int BFS(int &startX, int &startY, char target) {
	memset(d,0,sizeof(d));

	queue<point> q;
	point p;
	p.x = startX;
	p.y = startY;
	d[startX][startY] = 0;
	q.push(p);
	while (!q.empty()) {
		int nowX = q.front().x,nowY = q.front().y;
		q.pop();

		if (map[nowX][nowY] == target) {
			startX = nowX;
			startY = nowY;
			return d[nowX][nowY];
		}

		int nextX, nextY;
		for (int i = 0; i < 4; i++) {
			nextX = nowX + direct[i][0];
			nextY = nowY + direct[i][1];

			if (nextX >= 0 && nextY >= 0 && nextX < row && nextY < col && 
					map[nextX][nextY] != 'X' && d[nextX][nextY] == 0) {
				d[nextX][nextY] = d[nowX][nowY] + 1;
				p.x = nextX;
				p.y = nextY;
				q.push(p);
			}
		}
	}
	return -1;
}

int main() {
	int startX, startY, sum = 0;

	scanf("%d%d%d", &row, &col, &n);
	for (int i = 0; i < row; i++) {
		scanf("%s", map[i]);
		for (int j = 0; j < col; j++) {
			if (map[i][j] == 'S') {
				startX = i;
				startY = j;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		int dis = BFS(startX, startY, i + '1');
		sum += dis;
	}
	printf("%d\n", sum);
}


Measured memory_bytes: 7764
n=int(input())
a=list(map(int,input().split()))
cnt=0
m=[]
for i in range(n):
  cnt+=(-1)**i*a[i]
m.append(cnt)
for i in range(1,n):
  m.append((a[i-1]-m[i-1]//2)*2)
for i in range(n):
  print(m[i],end=' ')

Measured memory_bytes: 14092
MOD = (10**9) + 7


class modint():
    def __init__(self, value):
        self.value = value % MOD

    def __int__(self):
        return int(self.value)

    def __float__(self):
        return float(self.value)

    def __str__(self):
        return str(self.value)

    def __repr__(self):
        return str(self.value)

    def __add__(self, other):
        return (modint(self.value + other.value) if isinstance(other, modint)
                else modint(self.value + other))

    def __sub__(self, other):
        return (modint(self.value - other.value) if isinstance(other, modint)
                else modint(self.value - other))

    def __mul__(self, other):
        return (modint(self.value * other.value) if isinstance(other, modint)
                else modint(self.value * other))

    def __truediv__(self, other):
        return (modint(self.value * pow(other.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(self.value * pow(other, MOD - 2, MOD)))

    def __pow__(self, other):
        return (modint(pow(self.value, other.value, MOD))
                if isinstance(other, modint)
                else modint(pow(self.value, other, MOD)))

    def __eq__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __ne__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __radd__(self, other):
        return (modint(other.value + self.value) if isinstance(other, modint)
                else modint(other + self.value))

    def __rsub__(self, other):
        return (modint(other.value - self.value) if isinstance(other, modint)
                else modint(other - self.value))

    def __rmul__(self, other):
        return (modint(other.value * self.value) if isinstance(other, modint)
                else modint(other * self.value))

    def __rtruediv__(self, other):
        return (modint(other.value * pow(self.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(other * pow(self.value, MOD - 2, MOD)))

    def __rpow__(self, other):
        return (modint(pow(other.value, self.value, MOD))
                if isinstance(other, modint)
                else modint(pow(other, self.value, MOD)))

    def modinv(self):
        """
        self.valueのmod MOD上での乗法逆元を返す
        >>> MOD
        13
        >>> x = modint(4)
        >>> x.modinv
        <bound method modint.modinv of 4>
        >>> x.modinv()
        10
        """
        return modint(pow(self.value, MOD - 2, MOD))


def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    A = ["{:0>60b}".format(int(i)) for i in input().split()]
    ans = modint(0)
    for i in range(60):
        num_one = 0
        for a in A:
            if a[-(i+1)] == "1":
                num_one += 1
        ans += ((N-num_one)*num_one)*(2**i)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 137916
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;
int d[105000];
int main() {
    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        d[a-1] += 1;
        d[a] += 1;
        d[a+1] += 1;
    }

    int ans = 0;
    rep(i, 100050) {
        ans = max(ans, d[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
N, K = gets.split.map(&:to_i)
X = []
Y = []

N.times
  .map{ gets.split.map(&:to_i) }
  .sort_by(&:last)
  .reverse
  .each_with_index.with_object(Hash.new(0)) do |((k, v), i), used|
    if used[k] > 0 && i < K
      X.push(v)
    elsif used[k] == 0
      Y.push(v)
      used[k] += 1
      break if used.size == K
    end
  end

sumX = Array.new(X.size + 1, 0)
sumY = Array.new(Y.size + 1, 0)

X.each_with_index do |v,i|
  sumX[i + 1] = sumX[i] + v
end
Y.each_with_index do |v,i|
  sumY[i + 1] = sumY[i] + v
end

points = (1 .. K).map do |k|
    K - k < sumX.size && k < sumY.size ? sumY[k] + sumX[K - k] + k ** 2 : nil
  end

puts points.compact.max


Measured memory_bytes: 17472