akhauriyash/Code-Regression huggingface dataset:
/*
  Id: ak260901
  Task: a
  Lang: C++
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define foru(i, l, r) for(register int i = l; i <= r; i++)
#define ford(i, r, l) for(register int i = r; i >= l; i--)

int read() {
  int res = 0; char c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)) res = res * 10 + c - '0', c = getchar();
  return res;
}

int n, m;

int main() {
  n = read(); m = read();
  if(n < m) puts("0");
  else puts("10");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b, c; cin >> a >> b >> c;
	if( a == b && b == c && c == a ){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

d1=[]
p1=0
p2=0
p3=0
pi=0

for i in range(n):
    di=abs(x[i]-y[i])
    p1=p1+di
    p2=p2+pow(di,2)
    p3=p3+pow(di,3)
    if di>pi:
        pi=di

p2=math.sqrt(p2)
p3=pow(p3,(1.0/3.0))

print(p1)
print(p2)
print(p3)
print(pi)



Measured memory_bytes: 5696
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 62) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    vector<int>A(N),B(N);
    rep(i,0,N)cin >> A[i] >> B[i];
    ll mini = INF;
    rep(i,0,N)rep(j,0,N){
        //if(i == j)continue;
        rep(k,0,N){
            //if(j == k || i == k)continue;
            rep(l,0,N){
                //if(k == l || j == l || i == l)continue;
                //cout << i << " " << j << " " << k << " " << l << endl;
                int cnt = 0;
                ll x1 = min({A[i],A[j],A[k],A[l]}), x2 = max({A[i],A[j],A[k],A[l]});
                ll y1 = min({B[i],B[j],B[k],B[l]}), y2 = max({B[i],B[j],B[k],B[l]});
                rep(m,0,N){
                    if(A[m] >= x1 && A[m] <= x2 && B[m] >= y1 && B[m] <= y2)cnt++;
                }
                //cout << cnt << endl;
                if(cnt < K)continue;
                mini = min(mini, (x2 - x1) * (y2 - y1));
            }
        }
    }
    cout << mini << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	bool isbreak =false;
	
	while (1)
	{
		string s;
		cin >> s;
		if(s=="-")break;
		int m;
		cin >> m;
		if(isbreak)break;
		int sum = 0;
		for(int i = 0;i<m;i++)
		{
			int h;
			cin >> h;
			sum += h;

		}
		
		for(int i = 0 ;i<s.size();i++)
		{
			cout<<s[(i+sum)%s.size()];
		}
		cout<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3184
A1,A2,A3 = map(int,input().split())

min_cost = abs(A1-A2)
if (min_cost < abs(A2-A3)) :
    min_cost = abs(A2-A3)

if (min_cost < abs(A1-A3)) :
    min_cost = abs(A1-A3)

print(min_cost)

Measured memory_bytes: 2940
N = int(input())
S = input()
Bsum = [0] #境界より左にある黒の数
Wsum = [0] #境界より右にある白の数
for i in range(N):
    Bsum += [Bsum[-1]+(1 if S[i]=="#" else 0) ]
    Wsum += [Wsum[-1]+(1 if S[N-i-1]=="." else 0)]
print(min([Bsum[i]+Wsum[N-i] for i in range(N+1)]))

Measured memory_bytes: 27256
N = int(input())
A1, A2 = [input().split() for _ in range(2)]

ans = 0
sum = 0
for n in range(0, N):
    for i in range(0, n + 1):
        #print('i=', i)
        sum += int(A1[i])
    for j in range(n, N):
        #print('j=', j)
        sum += int(A2[j])
    if ans < sum:
        ans = sum
    sum = 0

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

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

  int n = s.size();
  const int mod = 2019;
  vi d(n+1);
  d.at(n) = 0;
  int ten = 1;
  drep(i,n) {
    int now = (s.at(i) - '0') * ten % mod;
    d.at(i) = (d.at(i+1) + now) % mod;
    ten *= 10;
    ten %= mod;
  }
  ll ans = 0;
  vi cnt(mod,0);
  drep(i,n+1) {
    ans+=cnt.at(d.at(i));
    cnt.at(d.at(i))++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4404
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int H,W,h,w;
int mat[550][550];
long long sum;
int main()
{
	scanf("%d%d%d%d",&H,&W,&h,&w);
	for(int i=h;i<=H;i+=h)
		for(int j=w;j<=W;j+=w)
			mat[i][j]=-4000*h*w+3999;
	for(int i=1;i<=H;++i)
		for(int j=1;j<=W;++j)
			if(!mat[i][j])sum+=4000;
			else sum+=mat[i][j];
	if(sum<=0)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i=1;i<=H;++i)
		for(int j=1;j<=W;++j)
		{
			if(!mat[i][j])printf("4000 ");
			else
				printf("%d ",mat[i][j]);
			if(j==W)puts("");
		}
	return 0;
}


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

#define N 100

int main() {
	static char ss[3][N + 1];
	static int jj[3], kk[3];
	int i;

	for (i = 0; i < 3; i++) {
		scanf("%s", ss[i]);
		kk[i] = strlen(ss[i]);
	}
	i = 0;
	while (jj[i] < kk[i])
		i = ss[i][jj[i]++] - 'a';
	printf("%c\n", i + 'A');
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  long long x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
long long o[5500101];
int l[500101];
int j[500101];

long long x,y,z,mod=1000000007;
//string r;
char r[3];

P u[1];
queue<P> q;
stack<int> s;
//set<int> s;
map<int,int> p;

vector<int> v[3];


bool as(P a,P b)
{
  if(a.x!=b.x)
  return a.x<b.x;
  return a.y>b.y;
}

long long f(int n,int m)
{
  long long x=0;
  for(;n<m;)
  {
    if(n%2) x+=o[n++],x%=mod;
    else if(m%2==0) x+=o[m--],x%=mod;
    else n/=2,m/=2;
  }
  return (x+o[n])%mod;
}

int main()
{
  scanf("%d",&a);
  for(i=1;i<a*2;i*=2);
  for(int t=2*a;t>a;t--)
  {
    for(int h=t+i-1;h;h/=2)
      o[h]++;
  }
  for(int h=a+i-1;h;h/=2)
    o[h]+=a,o[h]%=mod;
  for(int t=a-1;t;t--)
  {
    o[t+i-1]=(long long)(a-1)*(a-1)%mod+o[t+i];
    o[t+i-1]+=f(t+3+i-1,t+a+1+i-1);
    o[t+i-1]%=mod;
    for(int h=(t+i-1)/2;h;h/=2)
      o[h]=(o[h*2]+o[h*2+1])%mod;
  }
  printf("%lld",o[i]);
}
//3
//21




Measured memory_bytes: 35072
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,M;
  cin>>N>>M;
  if(N==M){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
void solve(){
    int n ; cin >> n ;ll ans =0 ;
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0)
            ans+=i ;
    }
    pf(ans);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


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

int main() {
  int N, S=0;
  cin >> N;
  vector<int> V(N);
  for (int i=0; i<N; i++) {
    cin >> V[i];
    S+=V[i];
  }
  
  S/=N;
  int m=0, n=0;
  
  for (int i=0; i<N; i++) {
    m+=(V[i]-S)*(V[i]-S);
  }
  S++;
  for (int i=0; i<N; i++) {
    n+=(V[i]-S)*(V[i]-S);
  }
  cout << min(m, n) << endl;
}

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


#define ll long long 
ll N, M;
ll dp[100001];

ll solve (ll src, vector<ll> g[]) {
    
    if(dp[src]!= -1)
    return dp[src];
    
    
    ll bestChild = 0, leaf = 1;
    
    for(auto child : g[src]) {
        leaf = 0;
        bestChild = max(bestChild, solve(child, g));
    }
    
    
    if(leaf == 1) {
        dp[src] = 0;
    }else{
        dp[src] = 1 + bestChild;
    }
    
    
    //cout<<"SRC : "<<src<<" RETURNS "<<dp[src]<<endl;
    
    return dp[src];
    
}




int main() {
	// your code goes her
    cin>>N>>M;
    
    
    vector<ll> g[N+1];
    
    memset(dp, -1, sizeof(dp));
    
    
    for(ll i = 0; i < M ; i++) {
        ll src , dest;
        cin>>src>>dest;
        
        g[src].push_back(dest);
    }
    
    
    ll ans = 0;
    
    
    for(ll i = 1; i <= N; i++) ans = max(ans, solve(i, g));
    
    cout<<ans<<endl;
    
	return 0;
}


Measured memory_bytes: 8576
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  int N,M,like[60]={},ans=0;
  std::cin >> N >> M;
  for(int i=0; i<N; i++){
    int k; std::cin >> k;
    for(int j=0;j<k; j++){
      int a; std::cin >> a;
      like[a]++;
    }
  }

  for(int i=1; i<=M; i++){
    if(like[i]==N) ans++;
  }
  std::cout << ans << '\n';
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007LL

typedef long long ll;
typedef pair<ll,ll> P;

void solve(){
	ll n;cin >> n;
	vector<P> a;
	vector<P> b;
	ll ans = 0;

	REP(i, n){
		ll k, l, r;cin >> k >> l >> r;
		if(l < r){
			b.PB(MP(n - k - 1, r - l));
		}
		else {
			a.PB(MP(k - 1, l - r));
		}
		ans += min(l, r);
	}

	sort(ALL(a), greater<P>());
	sort(ALL(b), greater<P>());
	//REP(i, a.size())cout << "(" << a[i].FI << "," << a[i].SE << ")";cout << endl;
	//REP(i, b.size())cout << "(" << b[i].FI << "," << b[i].SE << ")";cout << endl;
	//cout << "ans: " << ans << endl;

	priority_queue<ll> pq;
	ll pla = 0;
	REV(i, a.size()){
		while(pla < a.size() && a[pla].FI >= i){
			pq.push(a[pla].SE);
			pla++;
		}
		if(!pq.empty()){
			ans += pq.top();
			pq.pop();
		}
	}
	while(!pq.empty())pq.pop();
	pla = 0;
	REV(i, b.size()){
		while(pla < b.size() && b[pla].FI >= i){
			pq.push(b[pla].SE);
			pla++;
		}
		if(!pq.empty()){
			ans += pq.top();
			pq.pop();
		}
	}
	while(!pq.empty())pq.pop();
	cout << ans << endl;
}

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

	ll t;cin >> t;
	REP(i, t)solve();

	return 0;
}


Measured memory_bytes: 8180
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

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

Measured memory_bytes: 46184
function main()
	lines=readlines()
	N,K=map(x->parse(Int,x),split(shift!(lines)))
	X=Int[]
	Y=Int[]
	for s=lines
		x,y=map(x->parse(Int,x),split(s))
		push!(X,x)
		push!(Y,y)
	end
	ans=5145141919810931893
	for lx=1:N,ly=1:N,rx=1:N,ry=1:N
		cnt=0
		for i=1:N
			if X[lx]<=X[i]<=X[rx]&&Y[ly]<=Y[i]<=Y[ry]
				cnt+=1
			end
		end
		if cnt>=K
			ans=min(ans,(X[rx]-X[lx])*(Y[ry]-Y[ly]))
		end
	end
	println(ans)
end
main()


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

typedef pair<int,int> P;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);(i)++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x<<"="<<x<<endl

#define INF INT_MAX/3

struct state{
  int x,d;
};
bool operator<(const state& a,const state& b){
  return a.d > b.d;
}

int m=100010;
int d[210021];

int main(){

  rep(i,210001)d[i]=INF;

  int n,x;
  vector<P> ps;
  cin>>n>>x;
  x+=m;
  rep(i,n){
    int a,b; 
    cin>>a>>b;
    ps.push_back(P(a,b));
  }

  priority_queue<state> que;
  que.push((state){m,0});
  while(que.size()){
    state crt=que.top(); que.pop();
    if(d[crt.x]!=INF)continue;
    d[crt.x]=crt.d;
    // dbg(crt.x); dbg(crt.d);
    rep(i,n)rep(j,2){
      int nx=crt.x+(j==0?ps[i].first:-ps[i].first);
      // dbg(nx);
      if(nx<0||nx>210000)continue;
      que.push((state){nx,crt.d+ps[i].second});
    }
  }
  if(d[x]==INF)cout<<-1<<endl;
  else cout<<d[x]<<endl;

}



Measured memory_bytes: 36624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

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

    int n = s.length();

    string ans;
    for (int i = 0; i < n - 1; i++) {
        int toa = ('z' - s[i] + 1) % 26;
        if (toa <= k) {
            k -= toa;
            ans += 'a';
        } else {
            ans += s[i];
        }
    }

    int d = (s[n - 1] - 'a' + k) % 26;
    ans += (char) ('a' + d);

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

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

char s[5][20];
char ans[5][20];

int main() {

	int i,j;

	for (i = 0; i < 3; i++) {
		scanf(" %s",s[i]);
		for (j = 0; j < strlen(s[i]); j++) {
			ans[i][j] = (s[i][j] - 'a') + 'A';
		}
	}


	for (i = 0; i < 3; i++) {
		printf("%c", ans[i][0]);
	}
	printf("\n");
	return 0;
}

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

using namespace std;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int num = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = 0; j < N -1-i; j++) {
			if (a[j] > a[j + 1]) {
				int tmp;
				tmp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = tmp;
				num++;
			}
		}
	}
	for (int i = 0; i < N-1; i++) {
		cout << a[i] << " ";
	}
	cout << a[N - 1] << endl;
	cout << num << endl;
}

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

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

    vector<bool> era(1000001, false);
    vector<int> a(n);
    vector<int> check;
    rep(i, n)
    {
        cin >> a[i];
        if (era[a[i]])
            check.emplace_back(a[i]);
        era[a[i]] = true;
    }
    sort(a.begin(), a.end());
    for (int i : check)
        era[i] = false;

    int ans = 0;
    for (int t : a)
    {
        if (era[t])
            ++ans;
        for (int i = t + t; i <= a[n - 1]; i += t)
            era[i] = false;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5204
#include<bits/stdc++.h>
using namespace std;
int n,m;
bool AC[105000];
int WA[105000];

void solve(){
    cin>>n>>m;
    int AC_num=0;
    int WA_num=0;

    for(int i=1;i<=n;i++){
        WA[i]=0;
        AC[i]=false;
    }

    while(m--){
        int a;
        string s;
        cin>>a>>s;

        if(AC[a]){
            continue;
        }
        if(s=="AC"){
            AC[a]=true;
            AC_num++;
            WA_num+=WA[a];
        }
        else if(s=="WA"){
            WA[a]++;
        }

    }
    cout<<AC_num<<" "<<WA_num<<"\n";
    return;
}
int main(){

    solve();
    return 0;
}

Measured memory_bytes: 768
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Golden Coins
 */

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

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll x;
  scanf("%lld", &x);

  printf("%lld\n", x / 500 * 1000 + x % 500 / 5 * 5);
  return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [x,y] <- getIntList
    print $ x + (y `div` 2)

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define MAXN 2550
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x < n and y >= 0 and y < n)
using namespace std;
const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    int n, ans = 0, var = 0;
    char tmp;
    cin >> n;

    for (int i=0; i<n; i++){
        cin >> tmp;
        if (tmp == 'I') var++;
        else var--;
        ans = max(ans, var);
    }

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

Measured memory_bytes: 256
N = int(input())
Alist = [0] + list(map(int, input().split()))
costs = [abs(Alist[i] - Alist[i+1]) for i in range(N)]
# print(costs)
base = sum(costs)
for not_go in range(1, N):
    print(base - costs[not_go-1] - costs[not_go] + abs(Alist[not_go-1] - Alist[not_go+1]) + abs(Alist[-1]))
print(base - costs[-1] + abs(Alist[-2]))


Measured memory_bytes: 13920
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int a=scan.nextInt();
        int b=scan.nextInt();
        if(a>b)System.out.println("a > b");
        else if(a<b)System.out.println("a < b");
        else System.out.println("a == b");
    }
}


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

using ll=long long; 

void solve(){
	int lacnt=0,lbcnt=0,gbcnt=0;
	int n;
	cin>>n;
	int a,b;
	cin>>a>>b;
	vector<int>p(n);
	for(int i=0; i<n; i++)cin>>p[i];
	for(int i=0; i<n; i++){
		if(p[i]<=a){
			lacnt+=1;
		}
		else if(p[i]<=b){
			lbcnt+=1;
		}
		else{
			gbcnt+=1;
		}
	}
	cout<<min(lacnt, min(lbcnt, gbcnt))<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    ll n; cin>>n;
    ll ans = 0;
    for (ll i = 1; i <= n; ++i) {
        ans += i;
    }
    cout << ans-n << endl;
    return 0;
}


Measured memory_bytes: 256
// =================================
//   author: memset0
//   date: 2018.12.10 19:23:51
//   website: https://memset0.cn/
// =================================
#include <bits/stdc++.h>
namespace ringo {
typedef long long ll;

template < class T >
inline void read(T &x) {
  x = 0; register char c = getchar(); register bool f = 0;
  while (!isdigit(c)) f ^= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  if (f) x = -x;
}

template < class T >
inline void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar('0' + x % 10);
}

template < class T >
inline void print(T x, char c) {
  print(x), putchar(c);
}

const int N = 1e5 + 10;
int n, m, u, v, cntn, cnte, flag, cnt[3], vis[N], col[N];
int tot = 2, hed[N], to[N << 1], nxt[N << 1], val[N << 1];
ll ans;

void dfs(int u) {
	vis[u] = 1, ++cntn, ++cnt[col[u]];
  for (int i = hed[u], v, c; i; i = nxt[i]) {
    v = to[i], c = (col[u] + val[i] + 3) % 3;
    ++cnte;
    if (vis[v]) {
      if (col[v] != c) flag = true;
      continue;
    }
    col[v] = c, dfs(v);
  }
}

void main() {
  read(n), read(m);
  for (int i = 1; i <= m; i++) {
    read(u), read(v);
    nxt[tot] = hed[u], to[tot] = v, val[tot] =  1, hed[u] = tot++;
    nxt[tot] = hed[v], to[tot] = u, val[tot] = -1, hed[v] = tot++;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
			cnt[0] = cnt[1] = cnt[2] = cntn = cnte = flag = 0;
      dfs(i);
			// printf("%d %d %d %d %d %d\n", cnt[0], cnt[1], cnt[2], cntn, cnte, flag);
      if (flag) ans += (ll)cntn * cntn;
			else {
        if (cnt[0] && cnt[1] && cnt[2]) {
          ans += (ll)cnt[0] * cnt[1];
          ans += (ll)cnt[0] * cnt[2];
          ans += (ll)cnt[1] * cnt[2];
        } else ans += cnte >> 1;
      } 
    }
		print(ans, '\n');
}

} signed main() { return ringo::main(), 0; }

Measured memory_bytes: 7040
#include<iostream>
using namespace std;
int main ()
{
    int ab,bc,ca;
    int a,b,c;
    int area;
    cin>>ab>>bc>>ca;
    a=ab*ab;
    b=bc*bc;
    c=ca*ca;
    if(a+b==c )
    {
        area=0.5*ab*bc;
        cout<<area<<endl;
    }
 else  if(a+c==b )
    {
        area=0.5*ab*ca;
        cout<<area<<endl;
    }
    else if (c+b==a)
    {
        area = 0.5*bc*ca;
    cout<<area<<endl;
    }
    return 0;
}


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

using namespace std;

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

    if(abs(a-b) > (int64_t)10e18)
    {
        cout << "Unfair\n";
        return 0;
    }

    cout << ((k % 2 == 0 ? 1 : -1) * (a - b)) << '\n';

    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

void solve(){
    int h,w;
    while(cin >> h >> w){
        if(h==0 and w==0) break;

        vector<vector<char>> c(h,vector<char>(w));
        rep(y,0,h) rep(x,0,w) cin >> c[y][x];

        vector<vector<int>> s(h,vector<int>(w));
        rep(y,0,h) rep(x,0,w){
            if(c[y][x]=='.'){
                s[y][x]=1;
                if(y!=0) s[y][x]+=s[y-1][x];
            }
        }

        int ans=0;
        rep(y,0,h){
            vector<int>& v=s[y];
            stack<pii> stk;
            rep(x,0,w){
                int pos=x;
                while(!stk.empty() and v[x]<stk.top().first){
                    ans=max(ans,(x-stk.top().second)*stk.top().first);
                    pos=stk.top().second;
                    stk.pop();
                }
                if(stk.empty() or v[x]>stk.top().first) stk.push(make_pair(v[x],pos));
            }
            while(!stk.empty()){
                ans=max(ans,(w-stk.top().second)*stk.top().first);
                stk.pop();
            }
        }
        cout << ans << endl;
    }
}

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

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

int main () {
	int x; cin >> x;
	for (int i = 0; i <= 100000; ++i) {
		if (100*i <= x and x <= 105*i) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
WHN = list(map(int,input().split()))
W=WHN[0]
H=WHN[1]
N=WHN[2]

x = []
y = []
a = []
for i in range(N):
    x1,y1,a1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
    a.append(a1)

l_1 = [i for i , z in enumerate(a) if z==1]
l_1_max=[]

n1=0
n2=W
n4=H
n3=0

for i in l_1:
    l_1_max.append(x[i])
    n1=max(l_1_max)

l_2 = [i for i , z in enumerate(a) if z==2]
l_2_min=[]

for i in l_2:
    l_2_min.append(x[i])
    n2=min(l_2_min)

l_3 = [i for i , z in enumerate(a) if z==3]
l_3_max=[]

for i in l_3:
    l_3_max.append(y[i])
    n3=max(l_3_max)

l_4 = [i for i , z in enumerate(a) if z==4]
l_4_min=[]

for i in l_4:
    l_4_min.append(y[i])
    n4=min(l_4_min)

if n1<n2 and n3<n4:
    S=(n2-n1)*(n4-n3)
    print(S)
else:
    print(0)

    


Measured memory_bytes: 3064
#include <iostream>
#include <string>

int main()
{
	int i,n, l[1000000], r[1000000];
	std::cin >> n;
	for (i = 0;i < n;i++) {
		std::cin >> l[i];
		std::cin >> r[i];
	}
	int nSum = 0;
	for (i = 0;i < n;i++) {
		nSum += r[i] - l[i] + 1;
	}
	std::cout << nSum << std::endl;
    return 0;
}



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

int main() {
  char a, b;
  int ball[3] = {1,0,0};
  while(scanf(" %c,%c", &a, &b) != EOF) {
    swap(ball[a-'A'], ball[b-'A']);
  }
  for(int i = 0; i < 3; ++i) {
    if(ball[i]) printf("%c\n", i+'A');
  }
  return 0;
}

Measured memory_bytes: 1136
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define inf 200000000000
const int maxnodes=1005;
#define ll long long
#define N 2501
#define EPS 0.01
#define ld long double



int32_t main()
{
    IOS;
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    set<pair<int,int>> s;

    for(int i = 0;i < n;i++)
        cin >> a[i];
    for(int i = 0;i < n;i++)
    {
        cin >> b[i];
        s.insert({b[i],i});
    }
    int ans = 0;
    int cnt = 20;
    while(!s.empty())
    {
        int i = s.rbegin()->second;
        s.erase(--s.end());
        int sub = b[(i+1+n)%n] + b[(i-1+n)%n];
        if((b[i] - a[i]) % sub == 0)
        {
            ans += (b[i] - a[i]) / sub;
            b[i] = a[i];
            continue;
        }
        else
        {
            ans += b[i] / sub;
            b[i] %= sub;
            if(b[i] < a[i])
            {
                cout << -1;
                return 0;
            }
            if(b[i] > max(b[(i+1+n)%n],b[(i-1+n)%n]))
            {
                cout << -1;
                return 0;
            }
            s.insert({b[i],i});
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 15872
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
ans=""

ans="U"*y + "R"*x
ans+="D"*y + "L"*x

ans+="L"+"U"*(y+1)+"R"*(x+1)+"D"
ans+="R"+"D"*(y+1)+"L"*(x+1)+"U"
print(ans)


Measured memory_bytes: 3060
N,D = map(int,input().split())

# 2次元配列
x = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    x.append(array)
    
ans = 0

for i in range(N):
  for j in range(i+1,N):
    distance = 0
    for y,z in zip(x[i],x[j]):
      distance += (y-z)**2
    d = distance**0.5
    if d.is_integer():
      ans += 1

print(ans)

Measured memory_bytes: 38256
#include<iostream>
#include<utility>
#include<string>
#include<vector>

using namespace std;
#define cerr cerr << "[DBG] "
#define DBG(x) cerr << #x << ": " << x << endl
// http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.html
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { s << v[i]; if (i < v.size() - 1) s << "\t"; } return s; }

typedef long long ll;

// UNDONE
int main(){
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int count_a = 0;
	int count_b = 0;
	for(int i=0; i<n; i++){
		char c = s[i];
		if(c == 'c'){
			cout << "No" << endl;
		}
		else if(count_a + count_b >= a + b){
			cout << "No" << endl;
		}
		else{
			if(c == 'a'){
				cout << "Yes" << endl;
				count_a++;
			}
			else if(c == 'b'){
				if(count_b < b){
					cout << "Yes" << endl;
					count_b++;
				}
				else{
					cout << "No" << endl;
				}
			}
		}
	}


	return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll N=1e5+7;
ll a[N];
int main()
{
    ll n,x;
    cin>>n>>x;
    ll sum=0;
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    if(a[0]>x)
    {
        sum+=a[0]-x;
        a[0]=x;
    }
//    cout<<sum<<endl;
    for(int i=1;i<n;i++)
    {
        if(a[i-1]+a[i]>x)
        {
            sum+=a[i]-(x-a[i-1]);
            a[i]=x-a[i-1];
        }
    }
    printf("%lld\n",sum);
}

Measured memory_bytes: 1024
N = int(input())
S = [int(input()) for _ in range(N)]
S2 = [x for x in S if x%10 != 0]
S2.sort()
if len(S2) == 0:
    print(0)
elif sum(S) % 10 != 0:
    print(sum(S))
else:
    print(sum(S) - S2[0])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll H,W;
    cin >> H >> W;
    ll cnt = 0;
    vector<vector<char>> field(H,vector<char>(W));
    rep(i,H){
        rep(j,W){
            cin >> field[i][j];
            if(field[i][j] == '#')cnt++;
        }
    }
    if(cnt == H + W - 1)cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define OUT(x) cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

static const int INF = 0x3f3f3f3f;

signed main() { 
        string s;
        cin >> s;
        int ans = INF;
        rep(i, 26) {
                int res = 0;
                int cnt = 0;
                bool f = false;
                rep(j, s.size()) {
                        cnt ++;
                        if (s[j] == 'a' + i) {
                                f = true;
                                amax(res, cnt - 1);
                                cnt = 0;
                        }
                }
                if (f) amax(res, cnt);
                if (f) amin(ans, res);
        }
        cout << ans << endl;
        return 0;
}               



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

int main()
{
  char a[200001];
  int B = 0;
  long int count = 0;
  scanf("%s", a);

  for (int i = 0; i < strlen(a); i++)
  {
    if (a[i] == 'B')
      B += 1;
    else
    {
      count += B;
    }
  }
  printf("%ld\n", count);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

struct op { int y; int x; int yy; int xx; };

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  //一筆書きすればよい => 思いつかないよ！
  //奇数同士のマスのマッチングをするというのは思いついた
  
  int H, W;
  cin >> H >> W;
  vvi a(H, vi(W));
  rep(i, H) {
    rep(j, W) {
      cin >> a[i][j];
    }
  }
  
  //ラストでかつ奇数個目の奇数マスは無視
  //一筆書き
  int li = -1; int lj = -1;
  int ct = 0;
  for(int i = 0; i < H; i++) {
    for(int j_=0; j_<W; j_++) {
      int j = i % 2 == 0 ? j_ : W - j_ - 1;
      
      if(a[i][j] % 2 != 0) {
        li = i; lj = j;
        ct ++;
      }
    }
  }
  
  if(ct % 2 == 0) {
    li = -1; lj = -1;
  }
  
  
  int pri = -1;
  int prj = -1;
  vector<op> ops;
  
  for(int i = 0; i < H; i++) {
    for(int j_=0; j_<W; j_++) {
      int j = i % 2 == 0 ? j_ : W - j_ - 1;
      if(pri != -1) {
        ops.push_back({pri, prj, i, j});
        
        pri = i; prj = j;
        if(a[i][j] % 2 != 0) {
          //動かすのを終了
          pri = -1;
        }
      } else {
        if(a[i][j] % 2 != 0) {
          pri = i;
          prj = j;
        }
      }
    }
  }
  
  fin(ops.size());
  rep(i, ops.size()) {
    cout << (ops[i].y+1) << " " << (ops[i].x+1) << " " << (ops[i].yy+1) << " " << (ops[i].xx+1) << endl;
  }
  
  
  
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< long double, long double > pdd;
typedef pair< long long, long long > pll;

#define vec vector
#define ALL(x) begin(x), end(x)

const int inf = 1e9;
const ll inf64 = 1e18;

const int LOG = 63;

vec< int > ps[LOG];

int main() {

    ios_base::sync_with_stdio(0);

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    int n, k;

    cin >> n >> k;

    vec< ll > a(n + 1);
    vec< ll >  ar;

    ar.reserve(n * (n + 1) / 2 + 5);

    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        a[i] += a[i - 1];
        for(int j = i;j >= 1;j--) {
            ar.push_back(a[i] - a[j - 1]);
        }
    }

    sort(ALL(ar));
    int sz = (int)ar.size();

    for(int i = 0;i < sz;i++) {
        for(int j = 0;j < LOG;j++) {
            if((1ll << j) & ar[i]) {
                ps[j].push_back(i);
            }
        }
    }

    ll res = 0;

    set< int > q;

    for(int i = 0;i < sz;i++) q.insert(i);

    for(int i = LOG - 1;i >= 0;i--) {
        set< int > tmp;
        for(int x : ps[i]) {
            if(q.count(x)) tmp.insert(x);
        }
        if((int)tmp.size() >= k) {
            q = tmp;
            res += (1ll << i);
            continue;
        }
    }

    cout << res << "\n";

    return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll a,b,k;
  cin >> a >> b >> k;


  vll s;
  for(ll i = a; i <= min(a+k-1, b); i++)
    s.push_back(i);
  for(ll i = b; i >= max(b-k+1, a); i--)
    s.push_back(i);

  sort(s.begin(), s.end());
  auto result = unique(s.begin(), s.end());
  s.erase(result, s.end());

  REP(i, s.size())
    cout << s[i] << endl;

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		boolean[] f = new boolean[1000000];
		
		Arrays.fill(f, true);
		for(int i=2;i<1000000;i++){
			if(f[i]){
				for(int j=i*2;j<1000000;j+=i){
					f[j]=false;
				}
			}
		}
		
		while(scan.hasNext()){
			int n = scan.nextInt();
			int ans = 0;
			for(int i = 2; i <= n; i++){
				ans+= f[i] ? 1 : 0;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 28172
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 300010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int nt[MAXN], n, f[MAXN], q;
vector<int> primes;

void sieveBase(int n) {
    FOR(i,2,n) {
        if (nt[i] == 0) {
            nt[i] = i;
            primes.emplace_back(i);
            for (ll j = (ll) i * i; j <= n; j += i) nt[j] = i;
        }
    }
}

bool isPrime(int u) {
    return nt[u] == u;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    // cin >> n;
    // sieveBase(55555);
    // cout << SZ(primes);
    sieveBase(100000);
    FOR(i,1,100000)
        if (i % 2 && isPrime(i) && isPrime((i+1)/2)) f[i]++;
    FOR(i,1,100000) f[i] += f[i-1];
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << f[r] - f[l-1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1536
import sys
from collections import deque
sys.setrecursionlimit(1000000)

def comb(n, r, fact, revfact, mod):
    return (fact[n] * (revfact[n-r] * revfact[r]) % mod) % mod

def dfs(i, parent, DP, sNum, E, fact, revfact, mod):
    Ans = 1
    sonNode = 1
    S = []
    for e in E[i]:
        if e != parent:
            mult, sn = dfs(e, i, DP, sNum, E, fact, revfact, mod)
            S.append(sn)
            Ans *= mult
            Ans %= mod
            sonNode += sn
    stotal = sonNode - 1
    for s in S:
        Ans *= comb(stotal, s, fact, revfact, mod)
        Ans %= mod
        stotal -= s
    DP[i] = Ans
    sNum[i] = sonNode - 1
    return Ans, sonNode

def solve():
    input = sys.stdin.readline
    N = int(input())
    E = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        E[a-1].append(b-1)
        E[b-1].append(a-1)
    mod = 7 + 10 ** 9
    fact = [1] * (N + 1)
    for i in range(N): fact[i+1] = ((i + 1) * fact[i]) % mod
    revfact = [1] * (N + 1)
    revfact[N] = pow(fact[N], mod - 2, mod)
    for i in reversed(range(N)): revfact[i] = ((i + 1) * revfact[i + 1]) % mod

    DP = [1] * N
    sNum = [0] * N
    usNum = [0] * N
    dfs(0, 0, DP, sNum, E, fact, revfact, mod)
    q = deque()
    for e in E[0]: q.append((e, 0))
    while q:
        nn, parn = q.popleft()
        upperMult = DP[parn] * pow(comb(N-1, sNum[nn] + 1, fact, revfact, mod), mod - 2, mod)
        usNum[nn] = upperNum = sNum[parn] - sNum[nn] + usNum[parn]
        DP[nn] = (upperMult * comb(N-1, upperNum, fact, revfact, mod)) % mod
        for e in E[nn]:
            if e != parn: q.append((e, nn))
        
    print("\n".join(map(str, DP)))
      
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 92568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;

int n, a[N], c0, c1;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    ll s = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= i + 1;
        s += abs(a[i]);
        if(a[i] > 0) c0++;
        if(a[i] < 0) c1++;
        // cout << a[i] << endl;
    }
    if(c0 > n - c0 || c1 > n - c1) {
        if(c1 > n - c1) for(int i = 0; i < n; i++) {
            a[i] *= -1;
        }
        sort(a, a + n);
        ll c = 0;
        for(int i = 0; i < n; i++) {
            a[i] -= c;
            if(a[i] > 0 && n - 2 * i > 0) {
                s -= (ll)a[i] * (n - 2 * i);
                // cout << a[i] * ( n - 2 * i ) << endl;
                c += a[i];
                while(i + 1 < n && a[i + 1]  == c) i++;
            }
            // cout << "c: "  << c << endl;
        }
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 1024
K = int(input())
x = [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]
print(x[K-1])


Measured memory_bytes: 2940
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    ll a, v, b, w, t;
    scanf("%lld%lld%lld%lld%lld", &a, &v, &b, &w, &t);

    if (abs(b - a) <= (v - w)*t) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

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

  int cnt = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int k = S - i - j;
      if (0 <= k && k <= K) cnt++;
    }
  }

  // 解答
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
a_s = list(map(int, input().split()))
bs = list(map(int, input().split()))
cs = list(map(int, input().split()))

res = 0
for i in range(n):
	a = a_s[i] - 1
	res += bs[a]
	if i > 0 and a_s[i] - a_s[i - 1] == 1:
		res += cs[a - 1]

print(res)

Measured memory_bytes: 3064