akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll x; cin >> x;
  if(x==3||x==5||x==7) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef set<int> si;
typedef string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
const ll MAX_P=200010;
ll fact[MAX_P];
int N,K;

void make_fact(){
  fact[0]=fact[1]=1;
  for(ll i=2;i<MAX_P;i++){
    fact[i]=(fact[i-1]*i)%MOD;
  }
}
ll Extgcd(ll a,ll b,ll &x,ll &y){
  ll d=a;
  if(b!=0){
    Extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }
  else{
    x=1;y=0;
  }
  return d;
}

ll mod_inv(ll a,ll p){//mod pでのaの逆元を求める
  ll x,y;
  Extgcd(a,p,x,y);
  return (x%p+p)%p;
}
//n!=a*p^e (a,p互いに素,p素数) とした時のeとa mod p を求める
ll mod_fact(ll n,ll p,ll& e){
  e=0;
  if(n==0) return 1;
  
  ll res=mod_fact(n/p,p,e);
  e+=n/p;

  if(n/p%2!=0) return res*(p-fact[n%p])%p;
  return res*fact[n%p]%p;
}

//nCk mod pを求める
ll mod_comb(ll n,ll k,ll p){
  if(n<0||k<0||n-k<0) return 0;
  ll e1,e2,e3;
  ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inv(a2*a3%p,p)%p;
}

int main(){
  make_fact();
  cin>>N>>K;
  rep1(i,K){
    ll res=mod_comb(K-1,i-1,MOD)*mod_comb(N-K+1,i,MOD)%MOD;
    prin(res);
  }
  return 0;
}


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

int main()
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<string> name(0);
    vector<int> time(0);
    for(int i = 0; i < N; i++)
    {
        string S;
        int T;
        cin >> S >> T;
        name.push_back(S);
        time.push_back(T);
    }
    string targetName;
    cin >> targetName;
    int index = 0;
    for(int i = 0; i < N; i++)
    {
        if(name.at(i) == targetName)
        {
            index = i + 1;
            break;
        }
    }
    int answer = 0;
    for(int i = index; i < N; i++)
    {
        answer += time.at(i);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(usize));
    }
    
    let d = get!();
    let g = get!() / 100;
    
    use std::cmp::min;
    
    let mut dp = vec![100000; g + 1];
    dp[0] = 0;
    for i in 0..d {
    	let i = i + 1;
    	let p = get!();
        let c = get!() / 100;
        for j in 0..dp.len() {
        	let j = dp.len() - j - 1;
            let k = min(g, j+i*p+c);
            dp[k] = min(dp[k], dp[j]+p);
            for r in 1..p {
                let k = min(g, j+i*r);
                dp[k] = min(dp[k], dp[j]+r);
            }
        }
    }
    println!("{}", dp[g]);
    
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int cunt[1000001];
int main ()
{
    int tc;
    cin >> tc;
    for(int i=0; i<(tc-1); i++)
    {
        int n;
        cin >> n;
        cunt[n]++;
    }
    for(int i=1; i<=tc; i++)
    {
        cout << cunt[i] << endl;
    }
}

Measured memory_bytes: 4368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define int ll
const ll mod=998244353;
const ll inf=17441744174417;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll gyaku(ll x){
  return pow(x,mod-2);
}
vector<ll> frac,gfrac;
void set_frac(ll n){
  frac.push_back(1);
  gfrac.push_back(1);
  for(ll i=1;i<=n;i++){
    frac.push_back(frac[i-1]*i%mod);
    gfrac.push_back(gyaku(frac[i]));
  }
}
ll nCr(ll n,ll r){
  ll res=frac[n]*gfrac[r]%mod;
  res*=gfrac[n-r];
  return res%mod;
}
struct BIT{
private:
  vector<ll> node;
  ll siz;
public:
  BIT(ll n){
    siz=n;
    node.resize(n+1,0);
  }
  void add(ll pos,ll x){
    while(pos<=siz){
      node[pos]+=x;
      pos+=pos&(-pos);
    }
  }
  ll sum(ll pos){
    ll res=0;
    while(pos>0){
      res+=node[pos];
      pos-=pos&(-pos);
    }
    return res;
  }
};
ll xs[200005]={0},ys[200005]={0};
ll ym_L[200005]={0},ym_R[200005]={0};
signed main(){
  ll n;
  cin>>n;
  set_frac(n+5);
  vector<ll> xcomp,ycomp;
  vector<P> vec;
  xcomp.push_back(-inf);
  ycomp.push_back(-inf);
  for(int i=0;i<n;i++){
    ll x,y;
    cin>>x>>y;
    vec.push_back(P(x,y));
    xcomp.push_back(x);
    ycomp.push_back(y);
  }
  xcomp.push_back(inf);
  ycomp.push_back(inf);
  sort(vec.begin(),vec.end());
  sort(xcomp.begin(),xcomp.end());
  sort(ycomp.begin(),ycomp.end());
  for(int i=0;i<n;i++){
    ll xpos=lower_bound(xcomp.begin(),xcomp.end(),vec[i].first)-xcomp.begin();
    xs[i]=xpos;

    ll ypos=lower_bound(ycomp.begin(),ycomp.end(),vec[i].second)-ycomp.begin();
    ys[i]=ypos;
  }
  BIT bl(n+5);
  for(int i=0;i<n;i++){
    ym_L[i]=bl.sum(ys[i]);
    bl.add(ys[i],1);
  }
  BIT br(n+5);
  for(int i=n-1;i>=0;i--){
    ym_R[i]=br.sum(ys[i]);
    br.add(ys[i],1);
  }
  vector<ll> pow2;
  pow2.push_back(1);
  for(int i=1;i<=n;i++){
    pow2.push_back(pow2[i-1]*2%mod);
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ll kans=pow2[n]-1;
    ll mns=0;

    mns+=pow2[i]-1;
    mns+=pow2[n-1-i]-1;
    mns+=pow2[ys[i]-1]-1;
    mns+=pow2[n-ys[i]]-1;
    mns+=mod;
    mns%=mod;

    kans+=pow2[ym_L[i]]-1;
    kans+=pow2[i-ym_L[i]]-1;
    kans+=pow2[ym_R[i]]-1;
    kans+=pow2[n-i-1-ym_R[i]]-1;

    kans+=mod;
    kans-=mns;
    kans%=mod;
    ans+=kans;
    ans%=mod;

  /*  cout<<pow2[i]<<" "<<pow2[n-1-i]<<" "<<pow2[ys[i]-1]<<" "<<pow2[n-ys[i]]<<" ";
    cout<<pow2[ym_L[i]]<<" "<<pow2[i-ym_L[i]]<<" "<<pow2[ym_R[i]]<<" "<<pow2[n-i-1-ym_R[i]]<<" ";
    cout<<mns<<endl; */
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 23520
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
//constexpr ll MOD = 1e9+7;
constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll n;
	string s;
	cin >> n >> s;

	Vec cnt(3);
	string color = "RGB";

	ll ans = 1;
	rep(i, 3 * n){
		Vec el = cnt;
		sort(all(el));
		rep(j, 3){
			if(s[i] == color[j]){
				if(cnt[j] == el[2]){
					ans *= n - cnt[j];
				}else if(cnt[j] == el[1]){
					ans *= el[2] - el[1];
				}else{
					ans *= el[1] - el[0];
				}
				++cnt[j];
			}
		}
		ans %= MOD;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
typedef pair<ll,ll> pll;
typedef pair<pll,pll> ppll;
typedef vector <ll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define lc(n) 2*n+1
#define rc(n) 2*n+2
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL)); 
const ll M = 105;
string s;
ll n, k;
ll dp[M][M][2];
vi v;

ll slove( ll pos , ll check , ll cnt ){
	if( cnt > k ) return 0;

	if(pos == v.size()){
		if(cnt == k) return 1;
		else return 0;
	}

	if(dp[pos][cnt][check] != -1) return dp[pos][cnt][check];

	ll res=0;
	ll limit;

	if(check == 0)
		limit = v[pos];
	else
		limit = 9;

	for(ll d = 0 ; d <= limit ; d ++ ){
		ll nck = check;
		ll nt = cnt;
		if(check == 0 && d < limit) nck=1;

		if(d > 0) nt++;
		if(nt <= k) res += slove(pos+1 , nck , nt);
	}
	return dp[pos][cnt][check] = res;
}

int main() {
    FAST;
    ll x = 0, y = 0, i, t, ans = 0, j, c = 0, z = 0, m;
    cin >> s >> k;
    n = s.size();
    fill(dp , -1);
    for( i = 0 ; i < n ; i ++ )
		v.pb(s[i]-'0');
	
    cout << slove(0 , 0 , 0);
}

Measured memory_bytes: 384
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	long long int N,sw=-1;
	string a="";
	cin>>N;
	if(N==0){
		cout<<"0"<<endl;
		return 0;
	}
	for(long long int i=2;N!=0;i*=2){
		sw*=-1;

		if(N%i!=0){
			a="1"+a;
			N-=(i/2)*sw;
		}else{
			a="0"+a;
		}
	}

	cout<<a<<endl;
}

Measured memory_bytes: 256
// atcoder/abc163/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, m;
  while (cin >> n >> m) {
    vec<int> a(m);
    cin >> a;
    cout << max(-1, n - accumulate(a.begin(), a.end(), 0)) << endl;
  }

  return 0;
}


Measured memory_bytes: 3688
import sys
import math
import bisect

def solve(n, a, b):
    ans = 0
    ans += n // (a + b) * a
    m = n % (a + b)
    if m <= a:
        ans += m
    else:
        ans += a
    return ans

def main():
    n, a, b = map(int, input().split())
    ans = solve(n, a, b)
    print(ans)

if __name__ == "__main__":
    main()


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

int main()
{
    int N;
    cin >> N;
    
    int ans = 0;
    for (int i=1; i<=N; i+=2)
    {
        int num = 0;
        for (int j=1; j<=N; j++)
        {
            if (i%j==0) num++;
        }
        if (num==8) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int A, B, M, mina = 1e9, minb = 1e9;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    for (int i = 0; i < A; ++i) {
        cin >> a[i];
        mina = min(mina, a[i]);
    }
    for (int i = 0; i < B; ++i) {
        cin >> b[i];
        minb = min(minb, b[i]);
    }

    int ans = mina + minb;
    for (int i = 0; i < M; ++i) {
        int x, y, c;
        cin >> x >> y >> c;
        x--, y--;
        ans = min(ans, a[x] + b[y] - c);
    }

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
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; }
int main()
{
    int N, M;
    cin >> N >> M;
    dsu d = dsu(N);
    for (int i=0; i<M; i++) {
        int a, b;
        cin >> a >> b;
        d.merge(a-1, b-1);
    }
    vector<vector<int>> v = d.groups();
    cout << v.size() - 1 << endl;
    return 0;
}

Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int m;
	int box[100001];
	int i;
	
	cin>>n;
	for(i=1;i<=n;i++)	cin>>box[i];
	sort(box,box+n+1);
	m=n/2;
	
	if(box[m]==box[m+1])	cout<<0<<endl;
	else					cout<<box[m+1]-box[m]<<endl;
	return 0;
}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
long long n, k, a[100005], dp[100005], Min;
int main(){
	cin >> n >> k;
	for (int i=0;i<n;i++)
		cin >> a[i];
	dp[0]=0,dp[1]=abs(a[1]-a[0]);
	for (int i=2;i<n;i++){
		Min=2147483647;
		for (int j=0;j<i;j++){
			if (i>k&&j==0) j=i-k;
			Min=min(Min, dp[j]+abs(a[i]-a[j]));
		}
		dp[i]=Min;
	}
	cout << dp[n-1];
} 

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int x;
    cin >> x;

    int q = x / 100;
    int r = x % 100;

    cout << (r > 5*q ? 0 : 1) << endl;
    return 0;
}


Measured memory_bytes: 256
alphabet = "abcdefghijklmnopqrstuvwxyz"
ans = ""

n = int(input())
s = [str(input()) for i in range(n)]

for j in alphabet:
    count = 50
    for k in s:
        if k.count(j) < count:
            count = k.count(j)
    ans += j*count

print(ans)
        

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

using namespace std;

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

    int n, sum = 0;
    cin >> n;
    int arr[n + 2];
    arr[0] = arr[n + 1] = 0;

    for (int i = 1; i <= n; i++)
        cin >> arr[i], sum += abs(arr[i] - arr[i - 1]);
    sum += abs(0 - arr[n]);

    for (int i = 1; i <= n; i++) {
        int diff = abs(arr[i] - arr[i - 1]) + abs(arr[i + 1] - arr[i]) - abs(arr[i + 1] - arr[i - 1]);
        cout << sum - diff << '\n';
    }

    return 0;
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
#define Seg_Max_N (1<<18) 

using Value = vector<int>;
const vector<int> ini = vector<int>(0);
struct segtree {
	int N;
	vector<Value>dat;

	segtree() {}
	segtree(int n) :dat(2 * Seg_Max_N) {
		N = 1;
		while (N < n) N *= 2;
		for (int i = 0; i < 2 * N - 1; i++) {
			dat[i] = ini;
		}
	}
	segtree(int n, vector<int>&v) :dat(2 * Seg_Max_N) {
		N = 1;
		while (N < n) N *= 2;
		for (int i = 0; i < 2 * N - 1; i++) {
			dat[i] = ini;
		}
		int num = N;
		for (int i = 0; i < N; ++i) {
			if (i < n) {
				dat[i + N - 1] = vector<int>(1, v[i]);
			}
		}
		num /= 2;
		while (num) {
			for (int i = 0; i < num; ++i) {
				int k = i + num-1;

				const Value al(dat[k * 2 + 1]);
				const Value ar(dat[k * 2 + 2]);
				dat[k] = merge(al, ar);
			}
			num /= 2;
		}
		
	}
	vector<int> merge(const Value&l, const Value&r) {
		auto it = l.begin(); auto jt = r.begin();
		Value v;
		while (it != l.end() || jt != r.end()) {
			int inum,jnum;
			if (it == l.end())inum = 1e9;
			else inum = *it;
			if (jt == r.end())jnum = 1e9;
			else jnum = *jt;
			if (inum < jnum) {
				v.emplace_back(inum);
				it++;
			}
			else {
				v.emplace_back(jnum);
				jt++;
			}
		}
		return v;
	}
	
	// min [a, b)
	int query(const int al,const int ar,int a, int b) { return query(al,ar,a, b, 0, 0, N); }
	int query(const int al,const int ar,int a, int b, int k, int l, int r) {
		if (r <= a or b <= l) return 0;
		if (a <= l and r <= b) {

			auto it = lower_bound(dat[k].begin(), dat[k].end(), al);
			auto jt = upper_bound(dat[k].begin(), dat[k].end(), ar);
			return jt - it;
		}
		const int m = (l + r) / 2;
		const int aal(query(al,ar,a, b, k * 2 + 1, l, m));
		const int aar(query(al,ar,a, b, k * 2 + 2, m, r));
		return aal + aar;
	}
};
int main() {
	int N; cin >> N;
	vector<int>as(N);
	for (int i = 0; i < N; ++i) {
		cin >> as[i];
	}
	segtree seg(N, as);
	int Q; cin >> Q;
	while (Q--) {
		int l, r, t; cin >> l >> r>> t;
		l--; r--;
		int a = as[l], b = as[r];
		int amin = min(a, b) - t;
		int amax = max(a, b) + t;
		int vs(seg.query(amin, amax, l, r + 1));
		cout << r-l+1-vs << endl;
	}
	return 0;
}

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

typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N, K, MOD = 1e9 + 7;
    cin >> N >> K;
    vector<ll> d(K + 1, 1);
    ll ans = mod_pow(K, N, MOD);
    for (int i = 2; i <= K; i++) {
        ll s = 1;
        for (int j = 2; j * j <= i; j++) {
            if (i % j != 0) continue;
            if (j * j == i) s += d[j];
            else s += d[j] + d[i / j];
            s = s % MOD;
        }
        d[i] = (i - s + MOD) % MOD;
        ll x = mod_pow(K / i, N, MOD);
        //ll y = (d[i] + MOD - s + i) % MOD;
        ans = (ans + x * d[i]) % MOD;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  if (N == M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 888
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
n,d = inm()
d = d ** 2
ans = 0
for i in range(n):
        x,y = inm()
        if x ** 2 + y ** 2 <= d:
                ans += 1
print(ans)


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

int main()
{
    long long int len[100];
    int i,j,k,l,n;
    scanf("%d",&n);
    len[0]=2;
    len[1]=1;
    for(i=2;i<=n;i++)
    {
        len[i]=len[i-1]+len[i-2];
    }
    printf("%lld\n",len[n]);
    return 0;
}


Measured memory_bytes: 128
i = j = 0
x = ''
y = ''

while True:
  line = input()
  line = line.split()
  x = int(line[0])
  y = int(line[1])

  if x == 0 and y == 0:
    break

  if x >= y:
    print(y,end=' ')
    print(x)

  else:
    print(x,end=' ')
    print(y) 

Measured memory_bytes: 7660
MOD = 10**9+7
n = int(input())
s = bin(n)[2:]
dp = [[0, 0, 0] for _ in range(len(s) + 1)]
dp[0][0] = 1
for i in range(len(s)):
    if s[i] == '0':
        dp[i + 1][0] = dp[i][0] + dp[i][1]
        dp[i + 1][1] = dp[i][1]
        dp[i + 1][2] = dp[i][1] + dp[i][2] * 3
    else:
        dp[i + 1][0] = dp[i][0]
        dp[i + 1][1] = dp[i][0] + dp[i][1]
        dp[i + 1][2] = dp[i][1] * 2 + dp[i][2] * 3
    for j in range(3):
        dp[i+1][j] %= MOD
print(sum(dp[-1])%MOD)


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define size_of(a) (int)(a).size()

class Alphabet {
public:
	static const int N = 4;
	
	int toInt(char c) {
		if (c == 'A') return 0;
		if (c == 'C') return 1;
		if (c == 'G') return 2;
		if (c == 'T') return 3;
		return -1;
	}
};

class Trie {
private:
	struct Node {
		vector< int > link;
		bool end;
		Node(int n) : link(n, -1),  end(false) {}
	};
	
	Alphabet& alph;
	vector< Node > node;
	
public:
	Trie(Alphabet& alph_) : alph(alph_) {
		node.push_back(Node(alph.N));
	}
	
	void insert(string& str) {
		insert(str, 0, 0);
	}
	
	inline void insert(string& str, int i, int vi) {
		if (i == size_of(str)) {
			node[vi].end = true;
			return;
		}
		
		int ci = alph.toInt(str[i]);
		
		if (node[vi].link[ci] != -1) {
			insert(str, i + 1, node[vi].link[ci]);
		} else {
			node.push_back(Node(alph.N));
			node[vi].link[ci] = size_of(node) - 1;
			insert(str, i + 1, node[vi].link[ci]);
		}
	}
	
	bool find(string& str) {
		return find(str, 0, 0);
	}
	
	inline bool find(string& str, int i, int vi) {
		if (i == size_of(str)) return node[vi].end;
		
		int ci = alph.toInt(str[i]);
		
		if (node[vi].link[ci] == -1) return false;
		return find(str, i + 1, node[vi].link[ci]);
	}
};

int main() {
	Alphabet alph;
	Trie trie(alph);
	
	int n;
	cin >> n;
	
	for_(i,0,n) {
		string op, str;
		cin >> op >> str;
		
		if (op == "insert") {
			trie.insert(str);
		} else {
			if (trie.find(str)) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
}

Measured memory_bytes: 35668
N, K = map(int, input().split())
A = list(map(lambda x:int(x) - 1, input().split()))

already = [False for i in range(N)]
already[0] = True
tel = [0]

while True:
    tmp = A[tel[-1]]
    tel.append(tmp)
    
    if already[tmp]:
        tel.pop()
        break
        
    already[tmp] = True

for i in range(len(tel)):
    if tel[i] == tmp:
        s = i
        break
        
if K - s >= 0:
    ans = (K - s) % (len(tel) - s) 
    print(tel[ans + s] + 1)
else:
    print(tel[K] + 1)


Measured memory_bytes: 32256
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

string s[3];
int i[3];
int main() {
	cin >> s[0] >> s[1] >> s[2];
	int t = 0;
	while (i[t] < s[t].size()) {
		t = s[t][i[t]++] - 'a';
	}
	cout << (char)('A' + t) << endl;
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
cost = [list(map(int, input().split())) for _ in range(10)]
wall = [list(map(int, input().split())) for _ in range(h)]
# djikstra
dis = [0] * 10
s = {1}
u = {0,2,3,4,5,6,7,8,9}
for i in range(10):
    dis[i] = cost[i][1]
for _ in range(10):
    if u == set():
        break
    mindis = 10**9
    for i in u:
        if dis[i] < mindis:
            a = i
            mindis = dis[i]
    u.remove(a)
    s.add(a)
    for i in u:
        dis[i] = min(dis[i], dis[a] + cost[i][a])
count = {}
for i in range(h):
    for j in range(w):
        if wall[i][j] >= 0:
            if wall[i][j] not in count:
                count[wall[i][j]] = 1
            else:
                count[wall[i][j]] += 1
ans = 0
for i, c in count.items():
    ans += dis[i] * c
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <queue>
#include <map>
#define rep(i, n) for (int i = 0;i < (n); i++)


typedef std::map<int, int> container;
typedef std::pair<int, int> value_type;

struct second_order {
  bool operator()(const value_type& x, const value_type& y) const {
    return x.second > y.second;
  }
};

int main() {
    int n;
    std::cin >> n;
    container src;
    rep(i, n) {
        int a;
        std::cin >> a; 
        src[i+1] = a;
    }
    std::priority_queue<value_type, std::vector<value_type>, second_order> que;
    std::pair<std::string, int> p;
    for(const auto& q : src) {
        que.push(q);
    }
 
    while ( !que.empty() ) {
        value_type item = que.top();
        std::cout  << item.first << " ";
        que.pop();
    }
    std::cout << std::endl;
    return 0;
}

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

int main(void){
  ll n,k; cin >> n >> k;
  ll sum1[n+1],sum2[n+1];
  for(int i = 0; i < n+1; i++){
    sum1[i] = 0; sum2[i] = 0;
  }
  sum1[0] = 0; sum2[n] = n;
  for(int i = 1; i < n+1; i++){
    sum1[i] = sum1[i-1] + i;
    sum2[n-i] = sum2[n-i+1] + n-i;
  }
  ll sum = 1;
  for(int i = k; i < n+1; i++){
    sum += sum2[n-i+1] - sum1[i-1]+1;
    sum %= 1000000007;
  }
  cout << sum%1000000007 << endl;
  return 0;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll n;
  cin >> n;
  std::vector<ll> l(n);

  rep(i,n) cin >> l.at(i);

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

  ll count = 0;

  for(ll a = 0; a < n; a++) {
    for(ll b = a + 1; b < n; b++) {
      for(ll c = b + 1; c < n; c++) {
        if(l.at(a) < l.at(b) + l.at(c) && l.at(b) < l.at(c) + l.at(a) && l.at(c) < l.at(a) + l.at(b)) {
          count++;
        }
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>

using namespace std;

void printa(int A[], int len) {
	cout << A[0];
	for (int i = 1; i < len; i++)
		cout << " " << A[i];
	cout << endl;
}

void isort(int A[], int len) {
	printa(A, len);
	for (int i = 1; i < len; i++) {
		int key = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > key) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = key;
		printa(A, len);
	}
}

int main() {
	int n, *a;
	cin >> n;
	a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	isort(a, n);
	delete[] a;
	return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>

int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  if (a > b){
    printf("a > b\n");
  } else if (a < b) {
    printf("a < b\n");
  } else {
    printf("a == b\n");
  }
}

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

int main() {
  int N;
  string S;
  cin>>N>>S;
  char x;
  
  rep(i,S.length()){x=S.at(i);
                   x+=N;
                   if(x>90){x-=26;}
                   x=toupper(x);
                   cout<<x;}
  cout<<endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
namespace IO{
    const int SIZE = (1 << 20) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE],*oS = obuf, *oT = obuf + SIZE - 1;
    char _st[55];
    int _qr = 0;
    inline char gc(){
        return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++) : *iS++);
    }
    inline void qread(){}
    template<class T1, class ...T2>
    inline void qread(T1 &IEE, T2&... ls){
        register T1 __ = 0, ___ = 1;
        register char ch;
        while(!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
        do{
            __ = (__ << 1) + (__ << 3) + (ch ^ 48);
        }while(isdigit(ch = gc()));
        __ *= ___;
        IEE = __;
        qread(ls...);
        return ;
    }
    inline void flush(){
        fwrite(obuf, 1, oS - obuf, stdout);
        oS = obuf;
        return ;
    }
    inline void putc_(char _x){
        *oS++ = _x;
        if(oS == oT) flush();
    }
    inline void qwrite(){}
    template<class T1, class ...T2>
    inline void qwrite(T1 IEE, T2... ls){
        if(!IEE) putc_('0');
        if(IEE < 0) putc_('-'), IEE = -IEE;
        while(IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
        while(_qr) putc_(_st[_qr--]);
        qwrite(ls...);
        return ;
    }
    struct Flusher_{~Flusher_(){flush();}}io_flusher;
}
using namespace IO;
int a, b;
int main(){
    cin >> a >> b;
    for(int i = 0;i <= a;i++){
        if(2 * i + 4 * (a - i) == b){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	s := scanRunes()
	ans := 0
	for i := 0; i < n; i++ {
		a := map[rune]bool{}
		b := map[rune]bool{}
		for j := 0; j < i; j++ {
			a[s[j]] = true
		}
		for j := i; j < n; j++ {
			b[s[j]] = true
		}
		t := 0
		for c := range a {
			if b[c] {
				t++
			}
		}
		ans = max(ans, t)
	}
	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 1848
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	string name;
	cin >> name;
	vector<string> candidate(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> candidate[i];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < candidate[i].size(); ++j)
		{
			if (candidate[i][j] != name[0])
			{
				continue;
			}
			for (int interval = 0; interval < candidate[i].size(); ++interval)
			{
				for (int k = 1; k < name.size(); ++k)
				{
					if (j + (interval + 1) * k >= candidate[i].size()) goto out;
					if (name[k] != candidate[i][j + (interval + 1) * k]) goto out;
				}
				ans++;
				goto next;
			out:
				;
			}
		}
	next:
		;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1232
#include<stdio.h>
#include<algorithm>
using namespace std;
int par[100005],com[100005],x[100005],y[100005];
int n,q;

void init(int u){
  for(int i=0;i<u;i++){
    par[i]=i;
  }
}

int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

void unite (int x, int y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  par[y]=x;
}

bool same(int x,int y){
  return find(x)==find(y);
}

int main(){
  scanf("%d%d",&n,&q);
  for(int i=0;i<q;i++){
    scanf("%d%d%d",&com[i],&x[i],&y[i]);
  }

  init(n);

  for(int i=0;i<q;i++){
    if(com[i]==0){
      unite(x[i],y[i]);
    }else{
      printf("%d\n",same(x[i],y[i]));
    }
  }

  return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

ll dp[101][100000];
ll sum[101][100000];

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> vec;
  vec.push_back(0);
  for (int i = 1; i * i <= n; ++i) {
    vec.push_back(i);
    if (i != n / i) {
      vec.push_back(n / i);
    }
  }
  sort(vec.begin(), vec.end());
  int m = vec.size() - 1;
  for (int i = 1; i <= m; ++i) {
    dp[1][i] = (vec[i] - vec[i - 1] + MOD) % MOD;
    sum[1][i] = (sum[1][i - 1] + dp[1][i]) % MOD;
  }
  for (int i = 2; i <= k; ++i) {
    for (int j = 1; j <= m; ++j) {
      dp[i][j] = sum[i - 1][m - (j - 1)];
      dp[i][j] = (dp[i][j] * (vec[j] - vec[j - 1] + MOD) % MOD) % MOD;
      sum[i][j] = (sum[i][j - 1] + dp[i][j]) % MOD;
    }
  }
  cout << sum[k][m] << endl;
  return 0;
}

Measured memory_bytes: 157308
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	a := readInt()
	b := readInt()
	c := readInt()
	d := readInt()
	var s, e int
	if a < c {
		s = c
	} else {
		s = a
	}

	if b < d {
		e = b
	} else {
		e = d
	}

	if e-s < 0 {
		println(0)
	} else {
		println(e - s)
	}
}


Measured memory_bytes: 640
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
        
n = int(input())
P =[]
s = 0
for i in range(n):P.append([int(i) for i in input().split()])
P.append(P[0])
for i in range(n):s += cross(P[i],P[i+1])
print(abs(s)*0.5)

Measured memory_bytes: 7716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n; cin >> n;
    int l = inf, r = 0;
    rep(i, n) {
        int a; cin >> a;
        chmax(r, a); chmin(l, a);
        
    }
    out(r - l);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
vector<vector<ll>>v(4,vector<ll>(3,0));
ll a[30000000]={};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    for(ll i=0;i<2;++i){
        for(ll j=0;j<3;++j)
            cin>>v[i][j];
    }
    for(ll i=0;i<3;++i){
        for(ll j=v[0][i];j<=n;++j){
            if(v[1][i]>v[0][i])
            a[j]=max(a[j-v[0][i]]-v[0][i]+v[1][i],a[j]);
        }
    }
    n=a[n]+n;
    memset(a,0,sizeof(a));
    for(ll i=0;i<3;++i){
        for(ll j=v[1][i];j<=n;++j){
            if(v[0][i]>v[1][i])
            a[j]=max(a[j-v[1][i]]-v[1][i]+v[0][i],a[j]);
        }
    }
    cout<<a[n]+n<<endl;
}


Measured memory_bytes: 234752
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long ans=0,tmp,l,cnt;
  string s;
  cin >> s;
  if(s.size()==1){
    cout << s << endl;
    return 0;
  }
  ans+=atol(s.c_str());
  int bit[s.size()-1];
  for(int i=1;i<pow(2,s.size()-1);i++){
    tmp=i;
    l=0;
    cnt=1;
    for(int j=s.size()-2;j>=0;j--){
      bit[j]=tmp%2;
      tmp/=2;
    }
    for(int j=0;j<s.size()-1;j++){
      if(bit[j]==1){
        ans+=atol(s.substr(l,cnt).c_str());
        l+=cnt;
        cnt=0;
      }
      cnt++;
    }
    ans+=atol(s.substr(l,cnt).c_str());
  }
  cout << ans << endl;
  return 0;
}  

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0; i < N; i++)A[i] = sc.nextInt();
		Arrays.sort(A);
		System.out.println(A[N - 1] - A[0]);
		}

}

Measured memory_bytes: 21844
fun main(args: Array<String>) {
    val (a, b) = readInputLine().split(" ").map{it.toLong()}
    
    if (a == 0L) {
        println(b)
        return
    }
    
    val aSum = f(a - 1L)
    val bSum = f(b)

    println(bSum xor aSum)
}

fun readInputLine(): String {
    return readLine()!!
}

fun f(x: Long): Long {
    if (x == 0L) {
        return 0L
    }
    
    if (x % 2L == 0L) {
        return x xor (1L * (x / 2L) % 2L)
    }
    
    return 1L * (x / 2L + 1) % 2L
}


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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  int ans = 1;
  char c = S[0];
  rep(i, N) {
    if (S[i] != c) ans++;
    c = S[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
let () = Scanf.scanf "%d\n" @@ fun n ->
  let ps = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun p -> p in
  Printf.printf "%d\n" @@
  List.length @@
  List.filter (fun b -> b) @@
  Array.to_list @@
  Array.init (n - 2) @@ fun i ->
    let ps' = [| ps.(i); ps.(i + 1); ps.(i + 2) |] in
    Array.sort compare ps';
    ps'.(1) = ps.(i + 1)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int k, a, b;
	cin >> k >> a >> b;
	
	rep3(i, a, b){
      if(i%k == 0){
      	  puts("OK");
			return;
      }
    }
	puts("NG");
	return;
}

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


Measured memory_bytes: 3696
/*
 * yaswanth phani kommineni
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n';

void solve(){
	ll n;
	cin >> n;
	string s = "ACL";
	for(ll i=0;i<n;i++) cout << s ;
	cout << endl;
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int z;
	z = 1;
	//cin >> z;
	for(int z1=1;z1<=z;z1++){
		solve();
	}
	return 0;
}



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

int main() {
  int N,a,b,c,d;
  cin >> N;
  
  a=N/1000;
  b=(N%1000)/100;
  c=(N%100)/10;
  d=N%10;
    
    if (a==b && c==d && b==c)
      cout <<"Yes"<<endl;
   else if ((a==b && b==c) || (b==c && c==d))
      cout <<"Yes"<<endl;
  else
    cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INF = 1e9 + 7;
int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    REP(i, n){
        cin >> a[i] >> b[i];
    }
    vector<int> dp(20001, INF);
    dp[0] = 0;
    FOR(i, 0, n){
        IFOR(j, 1, 20000){
            if(j-a[i] >= 0)
                dp[j] = min(dp[j], dp[j-a[i]] + b[i]);
        }
    }
    int ans = INF;
    IFOR(i, h, 20000){
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, P = gets_i_list
a_list = gets_i_list

if a_list.select(&:odd?).empty?
  puts 2**N if P == 0
  puts 0    if P == 1
else
  puts 2**(N - 1)
end



Measured memory_bytes: 4092
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));
		int t=0,h=0;
		int n=Integer.parseInt(br.readLine());			
		for(int i=0;i<n;i++){
			String [] card=br.readLine().split(" ");
			//文字列を大小比較する（compareTo, compareToIgnoreCase）
			if(card[0].compareToIgnoreCase(card[1])==0){
				t++;h++;
			}else if(card[0].compareToIgnoreCase(card[1])<0){
				h +=3;
			}else t+=3;
		}
		System.out.println(t+" "+h);
	}
}

Measured memory_bytes: 20100
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=998244353;
/* RMQ：[0,n-1] について、区間ごとの最小値を管理する構造体
    update(i,x): i 番目の要素を x に更新。O(log(n))
    query(a,b): [a,b) での最小の要素を取得。O(log(n))
*/
template <typename T>
struct RMQ {
    const T INF = 0;
    int n;         // 葉の数
    vector<T> dat; // 完全二分木の配列
    RMQ(int n_) : n(), dat(n_ * 4, INF) { // 葉の数は 2^x の形
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
    void update(int i, T x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  // parent
            dat[i] =(dat[i * 2 + 1]+dat[i * 2 + 2])%mod;
        }
    }
    // the minimum element of [a,b)
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    T query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return INF;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return(vl+vr)%mod;
        }
    }
};
signed main(){
    int n,k,l[10],r[10];
    cin>>n>>k;
    for(int i=0;i<k;i++)
        cin>>l[i]>>r[i];
    RMQ<int>seg(n);
    seg.update(0,1);
    for(int i=1;i<n;i++){
        for(int j=0;j<k;j++)
            seg.update(i,(seg.query(i,i+1)+seg.query(i-r[j],i-l[j]+1))%mod);
    }
    cout<<seg.query(n-1,n)<<endl;
}


Measured memory_bytes: 9516
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define N 400010
using namespace std;
int nxt[N<<2],to[N<<2],head[N],cnt=1;
int in[N];
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
	in[u]++;
	nxt[++cnt]=head[v];
	to[cnt]=u;
	head[v]=cnt;
	in[v]++;
}
int num[N],n;
bool cut[N<<2],in2[N];
void dfs(int u,int pre)
{
	for(int &i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v==pre || cut[i]) continue;
		cut[i]=cut[i^1]=true;
		if(in2[u])
		{
			if(u<=n && v>n) num[u]=num[v]=1;
			if(u>n && v<=n) num[u]=num[v]=-1;
		}
		dfs(v,u);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int u;
		scanf("%d",&u);
		if(u==-1) u=0;
		add(u,i);
	}
	for(int i=1;i<=n;i++)
	{
		int u;
		scanf("%d",&u);
		if(u==-1) u=0;
		else u=u+n;
		add(u,i+n);
	}
	for(int i=1;i<=2*n;i++) in2[i]=in[i]&1;
	for(int i=1;i<=n;i++)
	if(in2[i]!=in2[i+n]){puts("IMPOSSIBLE");return 0;}
	puts("POSSIBLE");
	for(int i=1;i<=n;i++)
	if(in2[i]) add(i,i+n);
	dfs(1,0);
	for(int i=1;i<=n;i++) printf("%d ",num[i]);
	return 0;
}


Measured memory_bytes: 23040
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

string S;

signed main(){
	cin >> S;
	cout << S.substr(0, 3) << endl;
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef pair<double, double> pd;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    vll X(5);
    for(auto &e : X)
        cin >> e;
    for(i = 0; i < 5; i++) {
        if(X[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3584