akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#define Fast register
char BUF[16384],*S=BUF,*T=BUF;
inline char Getchar(){return(S==T)&&(T=(S=BUF)+fread(BUF,1,16384,stdin),S==T)?EOF:*S++;}
inline int Getint(){
	Fast int s=0;Fast char c;
	while(c=Getchar(),c<48||c>57);
	while(s=s*10+c-48,c=Getchar(),c>47&&c<58);
	return s;
}

int main(){
	Fast int N=Getint()+1,tmpx=0,tmpy=0,Time=0;
	while(--N){
		Fast int t=Getint(),x=Getint(),y=Getint();
		Fast int Delta=x-tmpx+y-tmpy;
		if(Delta>t-Time||(Delta-(t-Time))&1){puts("No");return 0;}
		tmpx=x,tmpy=y,Time=t;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)
#define ror(a,b,c) for(register int a=c;a>=b;--a)
typedef long long ll;

const int N=3e5+5;
const ll MOD=1e9+7;

char s[N]; int n;
ll f[N][3][3],ans;

inline void inc(ll &a,ll b){
	(a+=b)>=MOD?a-=MOD:a;
}

inline void trans(int &a,int &b,int c){
	if(!c){
		++b; if(b>=3) b-=2;
	}
	else{
		if(b) --b;
		else ++a,a=min(a,2);
	}
}

int main(){

	scanf("%s",s+1); n=strlen(s+1);
	f[0][0][0]=1ll;
	lor(k,1,n){
		if(s[k]!='0'){
			lor(i,0,2) lor(j,0,2){
				int a=i,b=j; trans(a,b,1);
				inc(f[k][a][b],f[k-1][i][j]);
			}
		}
		if(s[k]!='1'){
			lor(i,0,2) lor(j,0,2){
				int a=i,b=j; trans(a,b,0);
				inc(f[k][a][b],f[k-1][i][j]);
			}			
		}
	}
	lor(i,0,2) lor(j,0,i) inc(ans,f[n][i][j]);
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 21632
#coding: utf-8

ta = 0
ha = 0
n = int(input())
for i in range(n):
    names = list(map(str, input().split()))
    if names[0] == names[1]:
        ta += 1
        ha += 1
    else:
        sorted_n = sorted(names)
        if names[0] == sorted_n[0]:
            ha += 3
        else:
            ta += 3
print(ta, ha)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1e9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  rep(i, H) cin >> S[i];
  int ans = 0;  
  rep(si, H) rep(sj, W) {
    if (S[si][sj] == '#') continue;
    vector<vector<int>> dist(H, vector<int> (W, INF));
    queue<P> que;
    auto update = [&] (int i, int j, int d) {
      if (dist[i][j] != INF) return;
      dist[i][j] = d;
      que.emplace(i, j);
    };
    update(si, sj, 0);
    while (!que.empty()) {
      int ci = que.front().first;
      int cj = que.front().second; que.pop();
      rep(dir, 4) {
        int ni = ci + dx[dir];
        int nj = cj + dy[dir];
        if (ni<0 || ni >= H || nj < 0 || nj >= W) continue;
        if (S[ni][nj] == '#' || dist[ni][nj] != INF) continue;
        update(ni, nj, dist[ci][cj] + 1);
      }      
    }
    rep(i, H) rep(j, W) {
      if (dist[i][j] == INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int f(int n){
    if(n % 2 == 0)return n/2;
    else return 3 * n + 1;
}
int main(){
    int s;
    cin >> s;
    vector<int> a(1);
    a[0] = s;
    int i = 1;
    while(1){
        int b = f(a[i-1]);
        a.push_back(b);
        //cout << b << ",";
        rep(j,a.size()-1){
            if(a[j] == b){
                cout << i+1 << endl;
                return 0;
            }
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
ll dp[300000][60]={};
ll dp2[300000][60]={};
ll a[300000];
int main() {
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	rep(i,n)cout<<s[i]<<t[i];
	
	return 0;
}


Measured memory_bytes: 3584
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

A,B,C=map(int, input().split())


for i in range(1,100):
    if (A*i)%B == C:
        print("YES")
        sys.exit()

print("NO")

Measured memory_bytes: 77160
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int A, B, C; cin >> A >> B >> C;
	cout << ((A <= C && C <= B) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int N;

signed main(void) {
    cin >> N;
    cout << N*N*N <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    scanf("%d",&n);
    vector<ll> as(n),bs(n),cs(n);
    vector<ll> ss(n),ss2(n);
    int i,j;
    for(i=0;i<n;i++)
        scanf("%lld",&as[i]);
    for(i=0;i<n;i++)
        scanf("%lld",&bs[i]);
    for(i=0;i<n;i++)
        scanf("%lld",&cs[i]);
    sort(as.begin(),as.end());
    sort(bs.begin(),bs.end());
    sort(cs.begin(),cs.end());
    ll s=0;
    for(j=n-1,i=n-1;i>=0;i--)
    {
        s += 1;
        while(j>=0 && cs[i]<=bs[j])
        {
            ss[j] = s-1;
            j--;
        }
    }
    for(;j>=0;j--)
        ss[j] = s;
    s = 0;
    for(j=n-1,i=n-1;i>=0;i--)
    {
        s += ss[i];
        while(j>=0 && bs[i]<=as[j])
        {
            ss2[j] = s-ss[i];
            j--;
        }
    }
    for(;j>=0;j--)
        ss2[j] = s;
    s = 0;
    for(i=0;i<n;i++)
        s += ss2[i];
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
	using namespace std;
	int main(int argc, char const *argv[])
	{
		     //  #ifndef ONLINE_JUDGE
	      //  // for getting input from input.txt
	      //  freopen("input.txt", "r", stdin);
	      //  // for writing output to output.txt
	      //  freopen("output.txt", "w", stdout);
	      // #endif
		string s1,s2;
		cin>>s1>>s2;
		if(s1.at(0) == s2.at(2)){
			if(s1.at(1) == s2.at(1)){
				if(s1.at(2) == s2.at(0)){
					cout<<"YES"<<"\n";
					return 0;
				}
			}
		}
		cout<<"NO"<<"\n";
		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//namespaces
using namespace __gnu_pbds; 
using namespace std;

//MACROS
#define ld long double
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long 
#define For(i,s,e) for (int i=(s); i<(e); i++)
#define Fod(i,s,e) for (int i=(s); i>(e); i--)
#define pii pair<ll,ll>
#define f first
#define s second
#define endl "\n"
#define all(container) container.begin(), container.end()
#define mp make_pair

//debug
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//Templates
template <typename T>
using ordered_set =tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }

//globals
ll const prime1 = 304933;
ll const prime2 = 15486277;
ll const mod = 1e9+7;
ll const inf = 1e18;
ll const size_1d = 1e6 + 7;
ll const size_2d = 1e3 + 7;

//functions
ll power(ll x, ll y, ll mod = 2e18){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;} 
ll gcdext(ll a,ll b,ll *x = 0, ll *y = 0){if(a == 0){*x = 0;*y = 1;return b;}ll x1,y1;ll gcd1 = gcdext(b%a,a,&x1,&y1);*x = y1 - (b/a)*x1;*y = x1;return gcd1;}
int randomize(){return (rand()%10000);} 

// CODE STARTS HERE
int a[size_2d][size_2d];
ll const max_size = (1 << 21);
ll dp[max_size][22];
int main(){
    IOS
    int n;cin >> n;
    dp[(1 << n) - 1][n] = 1;
    For(i,0,n)
    {
        For(j,0,n)
        {
            cin >> a[i][j];
        }
    }
    Fod(i,(1 << n) - 2,-1){
        int level = __builtin_popcount(i);
        For(j,0,n){
            if(a[level][j] && ((1 << j) & i) == 0){
                dp[i][level] += dp[i | (1 << j)][level + 1];
                dp[i][level] %= mod;
            }
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}

Measured memory_bytes: 362752
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int a, b;
void in(){
    cin >> a >> b;
}

void solve(){

    if(a == 6){
        print(b / 2);
        return;
    }

    if(a >= 13){
        print(b);
    }else if(6 <= a && 12 <= a){
        print(b / 2);
    }else{
        print(0);
    }

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
s=list(input())
cnt=[0 for _ in range(len(s))]
k=0
for i in range(len(s)):
    if(s[i]=="A" or s[i]=="G" or s[i]=="C" or s[i]=="T" ):
        cnt[k]+=1
    else:
        k+=1

print(max(cnt))

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int a,b;
    cin>>a>>b;
    if(a>=13)cout<<b<<endl;
    else if(a>=6)cout<<b/2<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n, k, x, y, sum;
	cin >> n;
	cin >> k >> x >> y;
	sum = 0;

	for (int i = 1; i <= n; i++) {
		if (i <= k) {
			sum += x;
		}
		else {
			sum += y;
		}
	}
	cout << sum << endl;


}

Measured memory_bytes: 384
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
connection=[[] for i in range(n)]
for i in range(m):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)

def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while len(next)!=0 and visitct!=n:
    ct+=1
    for i in range(len(next)):
      if visited[next[i]]==-1:
        distance[next[i]]=ct
        visited[next[i]]=1
        visitct+=1
        for j in range(len(connection[next[i]])):
          if visited[connection[next[i]][j]]==-1:
            next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
  return distance

b=bfs(0)
ans=[0]*n
print('Yes')
for i in range(1,n):
  for j in range(len(connection[i])):
    if b[connection[i][j]]==b[i]-1:
      print(connection[i][j]+1)
      break

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

int main(){
  
    int N;
    cin >> N;
    int C[55], V[55];
  
    for(int i=0; i<N; i++){
    cin >> C[i];
    }

    for(int i=0; i<N; i++){
    cin >> V[i];
    }
  
    int count = 0;
    for(int i=0; i<N; i++){ 
      
       if( C[i]-V[i] > 0 ){
       count += (C[i] - V[i]);
       } 
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
int gcd(int a,int b){//最大公約数
int c=a%b;
while(true){
if(c==0) break;
a=b;
b=c;
c=a%b;
}
return b;
}
bool IsPrime(int num){
if (num < 2) return false;
else if (num == 2) return true;
else if (num % 2 == 0) return false;
double sqrtNum = sqrt(num);
for(int i=3;i<=sqrtNum;i+=2){
if(num%i==0){
return false;
}
}
}
int lcm(int a,int b){//最小公倍数
return (a*b)/gcd(a,b);
}	
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b=0,c=0,d=1,e=1,f,i=1;
    cin>>a;
    if(a%2==1) cout<<"0\n";
    else{
	while(true){
	    d*=5;
	    if(d>a) break;
	    c=a/d;
	    b+=((c)/2);
	}
	cout<<b<<"\n";	    
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A_list = list(map(int, input().split()))
 
A_sorted = sorted(A_list)
 
CB_list = []
for _ in range(M):
    B, C = map(int, input().split())
    CB_list.append((C, B))
    
CB_reverse_sorted = sorted(CB_list, reverse=True)
 
bflag = False
pointer = 0

for CB_tuple in CB_reverse_sorted:
    C = CB_tuple[0]
    B = CB_tuple[1]
    
    for i in range(pointer, pointer + B):
        if i >= N or A_sorted[i] > C:
            bflag = True
            break
            
        if A_sorted[i] < C:
            A_sorted[i] = C
            
    pointer += B
    
    if bflag == True:
        break

print(sum(A_sorted))

Measured memory_bytes: 22596
#include <bits/stdc++.h>
#define MAX 100007

#define REP(i, N) for(int (i)=0; (i) < (N); (i)++)
#define PER(i, N) for(int (i)=(N)-1; (i) >= 0; (i)--)

using namespace std;
typedef long long ll;
typedef pair<ll, int> pii;

int k;
int _x[3] = {-1, 0, 1};
void solve(){
    
    queue<ll> q;
    int cnt = 0;
    REP(i, 10){
        if(i == 0) continue;
        cnt++;
        if(cnt == k){
            cout << i << endl;
            return;
        }
        q.push(i);
    }
    while(!q.empty()){
        ll top = q.front();
        q.pop();

        REP(i, 3){
            ll x = top%10 + _x[i];
            if(x >= 0 && x < 10){
                cnt++;
                if(cnt == k){
                    cout << top*10LL + x << endl;
                    return;
                }
                //cout << cnt << " " << top*10 + x << endl;
                q.push(top*10LL + x);
            }
        }
    }
}

int main(){
    cin >> k;
    solve();
    return 0;
}

Measured memory_bytes: 768
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val lrList = Array(n) {
        val (x, l) = readLongList()
        Pair(x - l, x + l)
    }.sortedWith(compareBy { it.second })

    var last = Long.MIN_VALUE
    var ans = 0
    for (lr in lrList) {
        if (last <= lr.first) {
            ans++
            last = lr.second
        }
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 70700
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=200023};

ll a[N],b[N],c[N],d[N];
ll sum[N],p[N];

int main(){
	int x=ci(), y=ci();
	int A=ci(), B=ci(), C=ci();
	rep(i,1,A) a[i]=ci();
	rep(i,1,B) b[i]=ci();
	rep(i,1,C) c[i]=ci();
	sort(a+1,a+A+1,greater<ll>());
	sort(b+1,b+B+1,greater<ll>());
	sort(c+1,c+C+1,greater<ll>());
	rep(i,1,x) d[i]=a[i];
	rep(i,1,y) d[x+i]=b[i];
	sort(d+1,d+x+y+1);
	rep(i,1,x+y) sum[i]=sum[i-1]+d[i];
	rep(i,1,C) p[i]=p[i-1]+c[i];
	ll ans=0;
	rep(i,1,min(x+y,C)) ans=max(ans,p[i]-sum[i]);
	printf("%lld\n",sum[x+y]+ans);
	return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>

using namespace std;

int main() {
    int N;
    cin >> N;
    int V[N], C[N];
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (V[i] > C[i]) {
            ans += V[i] - C[i];
        }        
    }
    cout << ans << endl;
    
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);

  vector<int> DP(N, 1e9);
  DP.at(0) = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j <= i + K; j++) {
      if (j >= N) break;
      DP.at(j) = min(DP.at(j), DP.at(i) + abs(H.at(i) - H.at(j)));
    }
  }

  cout << DP.at(N - 1) << "\n";
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void  main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String strArray[] = str.split(" ");
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		int c = Integer.parseInt(strArray[2]);
		StringBuffer out = new StringBuffer() ;
		out.append("No");
		if(a<b){
			if(b<c){
				out.replace(0,2,"Yes");
			}
		}
		System.out.println(out);
	}
}

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <


// CODE STARTS HERE

void solve(){
	int n, k;
	cin >> n >> k;

	vector<int> arr(n);
	for(auto& i : arr) cin >> i;

	int lb = 1, ub = *max_element(arr.begin(), arr.end());

	while(lb < ub){
		int mid = (lb + ub) / 2;

		int needed = 0;
		for(auto i : arr) needed += (i - 1) / mid;

		if(needed <= k) ub = mid;
		else lb = mid + 1;
	}

	cout << lb << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3988
import java.util.*;
import java.lang.Integer;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
     
      if(A > 12){
        System.out.println(B);
      }
      else if(A > 5){
        System.out.println(B/2);
      }
      else{
        System.out.println(0);
      }
    }
}

Measured memory_bytes: 22996
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)




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

using namespace std;

typedef long long ll;

int main () {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(n, k - q);
  for (int i = 0; i < q; ++i) {
		int t;
		cin >> t;
		++a[t - 1];
	}
	for (auto x : a) {
		x > 0 ? cout << "Yes\n" : cout << "No\n";
	}
}


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

typedef long long ll;

int main(){
  ll N,X,M,c=0,lp,st,lpp;
  cin >> N >> X >> M;
  map<ll,ll> mp;
  mp[X] = c;
  vector<ll> A(M+100),S(M+100);
  A[0] = X;
  S[0] = X;
  while(1){
    c++;
    X = (X*X)%M;
    if(mp.count(X)){
      lp = c - mp.at(X);
      st = mp.at(X);
      lpp = S.at(c-1);
      if(st > 0) lpp -= S.at(st-1);
      break;
    }
    mp[X] = c;
    A[c] = X;
    S[c] = S[c-1] + A[c];
    //cout << A[c] << "--";
  }
  ll ans=0,lpc = (N-st)/lp;
  ans += lpc*lpp;
  //cout << ";;" << lpp << endl;
  if(st > 0) ans += S.at(st-1);
  ll ret = (N-st)%lp;
  if(ret + st > 0) ans += S.at(ret + st-1);
  if(st > 0) ans -= S.at(st-1);
  cout << ans;
  return 0;
}

Measured memory_bytes: 7944
#include <stdlib.h>
#include <stdio.h>
int main() {
char* string1 = "CODEFESTIVAL2016";
char string2[17];
scanf("%s",string2);
int counter = 0;
for(int i = 0 ; i < 16 ; i++) {
if(string1[i]!=string2[i]) counter++;
}
printf("%d\n",counter);
return 0;
}

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

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

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

int main() {
  int N;
  cin >> N;
  vector<long long> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }
  long long aa = 1LL;
  for (int i = 0; i < T.size(); i++) {
    aa = lcm(T.at(i), aa);
  }
  cout << aa << endl;
}

Measured memory_bytes: 256
using System;
using System.Threading.Tasks;
class Program{
  static void Main(string[] args){
    Program p= new Program();
    p.Run();
  }
  void Run(){
    int n = int.Parse(Console.ReadLine());
    string[] vs = Console.ReadLine().Split(' ');
    string[] cs = Console.ReadLine().Split(' ');
    int[] v = new int[n];
     int[] c = new int[n];
    int m =0;
    Parallel.For(0,n,i=>{
        v[i]=int.Parse(vs[i]);
        c[i]=int.Parse(cs[i]);
        if(v[i]>c[i]){
            m+=v[i]-c[i];
        }
    });
    Console.WriteLine(m.ToString());
  }
}

Measured memory_bytes: 13652
import sys
input = sys.stdin.readline

n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    if max(p[i], p[i+1], p[i+2]) != p[i+1] and min(p[i], p[i+1], p[i+2]) != p[i+1]:
        ans += 1
print(ans)

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

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

int main() {
    int a, b;
    cin >> a >> b;
    int64_t lcm = (int64_t) a * b / gcd(max(a, b), min(a, b));
    cout << lcm << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define INF ((int)1e9)
#define EPS (1e-9)
#define MOD (1000000007)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};

vi dx={1,1,1,1,1,2,2,2,3};
vi dy={2,1,0,-1,-2,1,0,-1,0};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int w,h;
	while(cin>>w>>h,w){
		vvi a(h,vi(w,0));
		vi s,t;
		rep(i,h)rep(j,w){
			char c; cin>>c;
			if(isdigit(c)) a[i][j]=c-48;
			if(c=='X') a[i][j]=INF;
			if(c=='S') s.push_back(j);
			if(c=='T') t.push_back(j);
		}
		using data=tuple<int,int,int,int>; //cost,y,x, L1 or R-1
		auto cmp=[](data a,data b){return get<0>(a)>get<0>(b);};

		int ans=INF;
		for(auto start:s) for(auto LR:{1,0}){
			vector<vvi> f(2,vvi(h,vi(w,INF)));
			priority_queue<data,vector<data>,decltype(cmp)> q(cmp);
			q.emplace(0,h-1,start,LR);
			while(!q.empty()){
				int cost,y,x,lr;
				tie(cost,y,x,lr)=q.top(); q.pop();
				if(f[lr][y][x]!=INF) continue;
				if(y==0 and binary_search(all(t),x)){
					ans=min(ans,cost);
					break;
				}
				f[lr][y][x]=cost;
				rep(i,9){
					int nx=x+dx[i]*(lr?1:-1),ny=y+dy[i];
					if(nx<0 or nx>=w or ny<0 or ny>=h or a[ny][nx]==INF or f[lr^1][ny][nx]!=INF) continue;
					q.emplace(cost+a[ny][nx],ny,nx,lr^1);
				}
			}
		}
		if(ans==INF){
			cout<<-1<<endl;
		}else{
			cout<<ans<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std;

int main(void){
    long int n; 
    cin >> n;
    long int min = LONG_MAX;
    for(int i=0; i<5; i++){
        long int a;
        cin >> a;
        if(a < min){
            min = a;
        }
    }
    
    long int ans = n % min == 0l ? n/min + 4l : n/min + 5l;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
def LILI(n): return [LI() for _ in range(n)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main_1(): 
    text = (['Sunny', 'Cloudy'], ['Cloudy', 'Rainy'],['Rainy','Sunny'])
    s = SI()
    for i in text:
        if s == i[0]:
            print(i[1])

def main_2(): 
    s = SI()
    for num, i in enumerate(s):
        if num % 2 == 1: # even
            if not (i in 'LUD'):
                print('No')
                return
        else:
            if not (i in 'RUD'):
                print('No')
                return
    print('Yes')

def main_3():
    N, K, Q = LI()
    A = [0] * (N+1)
    for _ in range(Q):
        n = II()
        A[n] += 1

    for i in range(N):
        if K - Q + A[i+1] <= 0:
            print('No')
        else:
            print('Yes')


from heapq import heappop, heappush

def main():
    N, M = LI()
    A = LI()
    hq = []
    for a in A:
        heappush(hq, -a)  # heap からは最小値が出るのでマイナスを付けておくが、計算時は -1//2 = -1, 1//2 = 0 なので注意。
    for _ in range(M):
        a = -heappop(hq)
        heappush(hq, -(a//2))
    print(-sum(hq))


main()

Measured memory_bytes: 60952
# -*- coding: utf-8 -*-
'''
所要時間は、分位であった。
'''
# ライブラリのインポート
#import re #正規表現
import sys
#import heapq
import bisect
#import collections
#import math

def main():
    n = int(input())
    X = [[] for i in range(n)]
    l = []
    for i, line in enumerate(sys.stdin):
        X[i] = list(line.strip("\n").split())
        for j in range(i,n):
            c = int(X[i][j])
            if c == -1:
                continue
            else:
                r = (c,i,j)
                bisect.insort(l, r)
    
    uf = UnionFind(n)
    k = 0
    ans = 0
    count = 0
    while(count < n):
        try: tmp = l[k]
        except: break
        x = tmp[1]
        y = tmp[2]
        if not uf.same(x,y):
            uf.unite(x, y)
            ans += tmp[0] 
            count += 0
        k += 1
    print(ans)

class UnionFind:
    def __init__(self,n):
        self.p = [i for i in range(n)]
        return
    
    def root(self,x):
        while(1):
            if (self.p[x] == x): break
            y = x
            x = self.p[x]
            self.p[y] = self.p[x]
        return x

    def unite(self ,x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry: return
        else:
            self.p[rx] = ry
            return 
    
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry


    
if __name__ == '__main__':
    main()



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

int S[105][105];

int main(void)
{
	int h, w, n, x;
	pair<int, int> cur = {0, 0};
	scanf("%d%d%d", &h, &w, &n);
	for(int i = 0;i < n;i++)
	{
		scanf("%d", &x);
		while(x--)
		{
			S[cur.first][cur.second] = i;
			cur.second++;
			if(cur.second == w) cur.first++, cur.second = 0;
		}
	}

	for(int i = 0;i < h;i++)
	{
		if(i%2) reverse(S[i], S[i]+w);
		for(int j = 0;j < w;j++) printf("%d ", S[i][j]+1);
		printf("\n");
	}
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader tec = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		for (String line; (line = tec.readLine()) != null;) {
			int n=Integer.parseInt(line.trim());
			int[]arr=new int[n];
			HashMap<Integer, Boolean>bool=new HashMap<>();
			for (int i = 0; i < n; i++){ 
				arr[i]=Integer.parseInt(tec.readLine().trim());
				bool.put(arr[i], (i&1)==1);
			}
			Arrays.sort(arr);
			int cont=0;			
			for (int i = 0; i < arr.length; i++) {
				if((i&1)==0==bool.get(arr[i])){
					cont++;
				}
			}
			out.println(cont>>1);
		}
		out.close();
	}
}

Measured memory_bytes: 48920
// Last Change: 03/22/2019 19:45:07.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

struct Num {
  ll x;
  ll order;
  ll ans;
};

bool CompX(const Num& one, const Num& another) {
  return one.x < another.x;
}
bool CompOrder(const Num& one, const Num& another) {
  return one.order < another.order;
}

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

  vector<Num> X(N);
  for (ll i = 0; i < N; ++i) {
    cin >> X[i].x;
    X[i].order = i;
  }
  sort(X.begin(), X.end(), CompX);

  ll pos = N / 2;
  for (ll i = 0; i < N; ++i) {
    if (i < pos) {
      X[i].ans = X[pos].x;
    } else {
      X[i].ans = X[pos - 1].x;
    }
  }

  sort(X.begin(), X.end(), CompOrder);
  for (ll i = 0; i < N; ++i) {
    cout << X[i].ans << '\n';
  }
  cout << flush;

  //NS::LoopUntilZeroInpput();
}


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

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int X, Y;
	//long long N, M;
	//double d, e;
	//string s, t;
	//vector<int> v;
	//vector<pair<int, int>> pl;

	//while() {}
	//for(int i=0; i<N; i++) {}
	
	cin >> X >> Y;

	int ans = 0;
	switch(X) {
	case 1:
		ans += 300000;
		break;
	case 2:
		ans += 200000;
		break;
	case 3:
		ans += 100000;
		break;
	}
	switch(Y) {
	case 1:
		ans += 300000;
		break;
	case 2:
		ans += 200000;
		break;
	case 3:
		ans += 100000;
		break;
	}
	if(X == Y && X == 1) ans += 400000;

	cout << ans;
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

typedef long long ll;

int main()
{
	int N, D;
	scanf("%d%d", &N, &D);
	ll D2 = (ll)D*D;
	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		int X, Y;
		scanf("%d%d", &X, &Y);
		if ((ll)X*X+(ll)Y*Y <= D2) ++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 3220
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 2e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	FIO
	ll n, w; cin >> n >> w;
	ll wt[n], val[n];
	FOR(i, n) cin >> wt[i] >> val[i];
	ll dp[n + 1][w + 1] = {}; // dp[i][j] represents max sum that we can make using i elements if weight was j
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= w; j++) {
			if (wt[i - 1] <= j) {
				dp[i][j] = max(dp[i - 1][j], val[i - 1] + dp[i - 1][j - wt[i - 1]]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	cout << dp[n][w];
	return 0;
}


Measured memory_bytes: 82412
#include<bits/stdc++.h>
#include<cstring>
//#define Mfc_Tanzim
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define all(v) (v.begin(), v.end())
#define pi acos(-1.0)
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define bug(a) cerr << #a << " : " << a << endl
#define pq dp
using namespace std;
const ll mx = 4444444444;

ll posx[] = {1,-1, 0, 0};
ll posy[] = {0, 0, 1,-1};

int main()
{
    FastRead

#ifdef Mfc_Tanzim
    freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
#endif /// Mfc_Tanzim

    ll t=1, n, k, m, a, b, c, d;
    //cin >> t;

    while(t--){
              cin >> n >> k;
              ll mp[1000] = {}, res = 0;
              while(n--){
                        cin >> a >> b;
                        a*=a;
                        b*=b;
                        a+=b;
                        d = sqrt(a);
                        //cout << a << " " << b << " " << d << endl;
//                        bug(d);
                        res+=(a<=k*k);
                        //bug(res);
              }
              cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,q,top;
ll sta[N],cnt[N];
map<ll,ll> M;
//M[x]表示长为x的序列有多少个 
int main()
{
	scanf("%d%d",&n,&q);
	sta[top=1]=n;
	while (q--){
		ll x;
		scanf("%lld",&x);
		while (sta[top]>=x) top--;
		sta[++top]=x;
	}
	M[-sta[top]]=1;
	for (int i=top-1;i;i--){
		ll T=sta[i];
		for (auto i:M){
			ll v=-i.first,cnt=i.second;
			if (v<=T) break;
			M[-T]+=cnt*(v/T);
			if (-v%T) M[-v%T]+=cnt;
		}
		while (M.begin()->first<-T) M.erase(M.begin());
	}
	for (auto i:M) cnt[-i.first]+=i.second;
	for (int i=n;i;i--) cnt[i]+=cnt[i+1];
	for (int i=1;i<=n;i++) printf("%lld\n",cnt[i]);
	return 0;
}

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

string s;
map<char, int> m;

ll ans = 1;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> s;

    m[s[0]]++;
    for (int i = 1; i < (int)s.size(); ++i) {
        // cout << i << ' ' << m[s[i]] << '\n';
        ans += i - m[s[i]];
        m[s[i]]++;
    }

    cout << ans;
}


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

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

    for(int i = 1;i < n - 1;i++){
        if(a[i] > b[i]){
            a[i] = b[i];
        }
        a[i + 1] = b[i];
    }

    long long int ans = 0;
    for(int i = 0;i < n;i++){
        ans += a[i];
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        d: isize,
        p: [(isize, isize); n],
    }
    let ans = p
        .into_iter()
        .filter(|(x, y)| x.pow(2) + y.pow(2) <= d.pow(2))
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 7780
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
 
int main(void){
  int n;
  cin >> n;
  vector<long long> arr = vector<long long>(n + 1);
  vector<long long> acc = vector<long long>(n + 1);
  for(int i = 1; i <= n; i++) {
    cin >> arr[i];
    acc[i] = acc[i - 1] + arr[i];
  }
  long long result = acc[n];
  
  for(int i = 1, l = 1, r = 2; i < n - 1; i++){
    while(l < i && abs(acc[i] - 2 * acc[l]) > abs(acc[i] - 2 * acc[l + 1])) l++;
    while(r < n && abs(acc[n] + acc[i] - 2 * acc[r]) > abs(acc[n] + acc[i] - 2 * acc[r + 1])) r++;

    vector<long long> blocks;
    blocks.push_back(acc[n] - acc[r]);
    blocks.push_back(acc[r] - acc[i]);
    blocks.push_back(acc[i] - acc[l]);
    blocks.push_back(acc[l]);
    
    sort(blocks.begin(), blocks.end());
    
    if(result > (blocks[3] - blocks[0])) {
      
      result = blocks[3] - blocks[0];
    }
  }
  
  cout << result << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
using namespace std;

int main()
{
	int a,b;
	cin >> a >> b;
	if(b%a == 0)
	{
		cout << a+b;
	}
	else 
	{
		cout << b-a;
	}
 } 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
//#include <ios>
#include <iomanip>
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<long long> a[n + 1];
  long long p[m], y[m];
  for (int i = 0; i < m; i++){
    cin >> p[i] >> y[i];
    a[p[i]].push_back(y[i]);
  }
  for (int i = 1; i <= n; i++)
    sort(a[i].begin(), a[i].end());
  for (int i = 0; i < m; i++){
    int index = lower_bound(a[p[i]].begin(), a[p[i]].end(), y[i]) - a[p[i]].begin() + 1;
    printf("%06lld%06d\n", p[i], index);
  }
  return 0;
}


Measured memory_bytes: 8576
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine();
            var N = S.Length;
            var A = 'A';
            var B = 'B';
            var C = 'C';
            var Q = '?';
            var right = new Dictionary<char, long>() { { A, 0 }, { B, 0 }, { C, 0 }, { Q, 0 } };
            var left = new Dictionary<char, long>() { { A, 0 }, { B, 0 }, { C, 0 }, { Q, 0 } };
            foreach (var s in S.Skip(2))
                ++right[s];
            ++left[S[0]];
            var ans = 0L;
            for (var i = 1; i < N - 1; ++i)
            {
                if (S[i] == B || S[i] == Q)
                {
                    var lAnum = left[A];
                    var rCnum = right[C];
                    var lQnum = left[Q];
                    var rQnum = right[Q];

                    var lQsum = lQnum * modpow(3, lQnum - 1, Mod) % Mod;
                    lQsum = (lQsum + lAnum * modpow(3, lQnum, Mod)) % Mod;

                    var rQsum = rQnum * modpow(3, rQnum - 1, Mod) % Mod;
                    rQsum = (rQsum + rCnum * modpow(3, rQnum, Mod)) % Mod;
                    ans = (ans + lQsum * rQsum % Mod) % Mod;

                }
                --right[S[i + 1]];
                ++left[S[i]];
            }
            WriteLine(ans);
        }

        static long modpow(long a, long n, long mod)
        {
            var res = 1L;
            while (0 < n)
            {
                if (n % 2 != 0) res = res * a % mod;
                a = a * a % mod;
                n >>= 1;
            }
            return res;
        }
    }
}

Measured memory_bytes: 27132
// Alert!!! This program may have some NARGLE.
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define endl '\n'

using namespace std;

const int Mod = 1e9 + 7, Inf = 1e9;

int32_t main ()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	if (s[s.size() - 1] == 's')
		cout << s << "es";
	else
		cout << s << 's';
	return 0;
}

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

int main()
{
	vector<int>a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(),a.end());
	int ans = 0;
	ans += (a[2]*2-a[1]-a[0])/2;
	if(0!=(a[0]+a[1])%2)ans+=2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplicationSample
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int n = int.Parse(str[0]);
                int x = int.Parse(str[1]);

                if (n == 0 && x == 0) break;
                int count = 0;
                for (int i = 1; i <= n; i++)
                {
                    for (int j = i + 1; j <= n; j++)
                    {
                        for (int k = j + 1; k <= n; k++)
                        {
                            if (i + j + k == x)
                            {
                                ++count;
                            }
                        }
                    }
                }
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 5616