akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;





int main(void) {

    ll n,k;
    cin>>n>>k;
    vi a(n),f(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>f[i];
    Sort(a);
    Rort(f);

    ll UP = pow(10,12); //可能
    ll DO = -1; //不可能

    while(UP-DO!=1){
        //cout<<UP<<" "<<DO<<endl;
        ll X = (UP+DO)/2;
        ll sum=0;
        for(int i=0;i<n;i++){
            sum+=max(a[i]-X/f[i],(ll)0);
        }
        if(sum<=k){
            UP=min(UP,X);
        } else {
            DO = max(DO,X);
        }
    }
    cout<<UP<<endl;

}



Measured memory_bytes: 1792
n = int(input())
result = 0
q = list('753')
while q:
  s = q.pop(0)
  if int(s) > n:
    continue
  if all(s.count(c) > 0 for c in '753'):
    result += 1
  q.extend([s + c for c in '753'])
print(result)


Measured memory_bytes: 7324
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);

    public static void main(String[] arg){
        Main m = new Main();
        m.run();
    }

    String I = "IDENTICAL";
    String C = "CLOSE";
    String D = "DIFFERENT";

    void run(){
        for(;;) {
            String s1 = sc.nextLine();
            if(s1.equals(".")){
                break;
            }
            String s2 = sc.nextLine();
            s1 = s1.replace('"', '#');
            s2 = s2.replace('"', '#');
            s1 =s1.replaceAll("#","#dummy");
            s2 =s2.replaceAll("#","#dummy");


            String ss1[] = s1.split("#");
            String ss2[] = s2.split("#");

            if (ss1.length != ss2.length){
                System.out.println(D);
                continue;
            }

            int count =0 ;
            boolean d = false;
            for(int i = 0 ; i< ss1.length ;i++){
                if(!ss1[i].equals(ss2[i])) {
                    if (i % 2 == 0) {
                        d= true;
                    } else {
                        count++;
                    }
                }
            }

            if(!d && count == 0){
                System.out.println(I);
            }else if(!d && count ==1){
                System.out.println(C);

            }else{
                System.out.println(D);
            }
        }
    }

}



Measured memory_bytes: 31436
let
  n = parse(Int, readline())
  black_board_numbers = map(x -> parse(Int, x), split(readline()))

  left_gcd = zeros(Int, n - 1)
  right_gcd = zeros(Int, n - 1)

  left_gcd[1] = black_board_numbers[1]
  right_gcd[1] = black_board_numbers[n]

  for i = 2:n - 1
    left_gcd[i] = gcd(left_gcd[i - 1], black_board_numbers[i])
    right_gcd[i] = gcd(right_gcd[i - 1], black_board_numbers[n - i + 1])
  end
  
  max_gcd = max(left_gcd[n - 1], right_gcd[n - 1])

  for i = 2:n - 1
    max_gcd = max(max_gcd, gcd(left_gcd[i - 1], right_gcd[n - i]))
  end
  
  println(max_gcd)
end


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

const int V=100000;
const int N=404040;
const int INF=123456789;

set<int> TIMESET[V];
map<pi,int> v_to_id;

struct edge{int to,cost;};
vector<edge> G[N];
int dist[N];

int main()
{
    int n,m,s,g;
    scanf(" %d %d %d %d", &n, &m, &s, &g);
    --s;
    --g;

    TIMESET[s].insert(0);
    v_to_id[pi(s,0)] = 0;

    int idx=1;

    rep(i,m)
    {
        int u,v,t,c;
        scanf(" %d %d %d %d", &u, &v, &t, &c);
        --u;
        --v;

        TIMESET[u].insert(t);
        TIMESET[v].insert(t+c);

        if(v_to_id.find(pi(u,t)) == v_to_id.end()) v_to_id[pi(u,t)] = idx++;
        if(v_to_id.find(pi(v,t+c)) == v_to_id.end()) v_to_id[pi(v,t+c)] = idx++;

        int S=v_to_id[pi(u,t)], T=v_to_id[pi(v,t+c)];
        G[S].pb(edge{T,0});
    }

    rep(i,n)
    {
        int SZ = TIMESET[i].size();

        auto itr = TIMESET[i].begin();
        rep(j,SZ-1)
        {
            auto nx = itr;
            ++nx;

            int d = *nx - *itr;
            int S=v_to_id[pi(i,*itr)], T=v_to_id[pi(i,*nx)];
            G[S].pb(edge{T,d});

            ++itr;
        }
    }

    priority_queue<pi, vector<pi>, greater<pi>> pq;
    pq.push(pi(0,0));
    fill(dist,dist+N,INF);
    dist[0]=0;
    while(!pq.empty())
    {
        pi p=pq.top();
        pq.pop();
        int v=p.se;
        if(dist[v]<p.fi) continue;
        for(edge &e:G[v])
        {
            if(dist[e.to] > dist[v]+e.cost)
            {
                dist[e.to] = dist[v]+e.cost;
                pq.push(pi(dist[e.to],e.to));
            }
        }
    }

    int ans=INF;
    for(const auto &x:TIMESET[g])
    {
        int S = v_to_id[pi(g,x)];
        ans = min(ans,dist[S]);
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  int h, n;
  cin >> h >> n;
  rep(i, n) {
    int a;
    cin >> a;
    h -= a;
  }
  cout << (h > 0 ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: i32,
        s: String,
    }
    println!("{}", {
        let mut ans = 0;
        for i in 0..s.len() - 2 {
            if (&s[i .. i + 3] == "ABC") {
                ans += 1;
            }
        }
        ans
    });
}


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

const int MOD = 1e9 + 7;

int h, w;
int n;

int r[3055], c[3055];

int fact[200055], inv[200055];
int dp[200055];

int mod_pow(int n, int k) {
	if (k == 0) return 1;
	
	int res = mod_pow(n, k >> 1);
	res = (1ll * res * res) % MOD;
	
	if (k & 1) res = (1ll * res * n) % MOD;
	return res;
}
inline int comb(int n, int k) {
	return 1ll * fact[n] * inv[k] % MOD * inv[n - k] % MOD;
}
inline void sub(int &a, int b) {
	a -= b;
	
	if (a < 0) {
		a += MOD;
	}
}
int main() {
	cin >> h >> w >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> r[i] >> c[i];
	}
	
	fact[0] = 1;
	
	for (int i = 1; i <= (int)2e5; i++) {
		fact[i] = (1ll * i * fact[i - 1]) % MOD;
	}
	
	for (int i = 0; i <= (int)2e5; i++) {
		inv[i] = mod_pow(fact[i], MOD - 2);
	}
	
	vector<int> vs;
	
	for (int i = 0; i < n; i++) {
		vs.push_back(i);
	}
	
	sort(vs.begin(), vs.end(), [&] (int v, int u) {
		if (r[v] == r[u]) return c[v] < c[u];
		return r[v] < r[u];
	});
	
	for (auto v : vs) {
		dp[v] = comb(r[v] + c[v] - 2, r[v] - 1);
		
		for (auto u : vs) {
			if (u == v) continue;
			if (!(r[u] <= r[v] && c[u] <= c[v])) continue;
			
			sub(dp[v], 1ll * dp[u] * comb((r[v] - r[u]) + (c[v] - c[u]), (r[v] - r[u])) % MOD);
		}
	}
	
	int res = comb(h + w - 2, h - 1);
	
	for (int i = 0; i < n; i++) {
		sub(res, 1ll * dp[i] * comb((h - r[i]) + (w - c[i]), (h - r[i])) % MOD);
	}
	
	cout << res;
}


Measured memory_bytes: 1920
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 1000000007
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

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

int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    int ok=0;
    rep(i,1,n)
    {
        a[i]=(a[i-1]+(s[i]-'a')+1)%3;
        if (s[i]==s[i-1]) ok=1;
    }
    if (!ok) {puts("1");return 0;}
    rep(i,1,n)
    {
        f[i]=(f[lst[0]]+f[lst[1]]+f[lst[2]])%maxd;
        f[i]=(f[i]-f[lst[a[i]]]+maxd)%maxd;
        if (a[i]) f[i]++;lst[a[i]]=i;
    }
    printf("%lld\n",f[n]);
    return 0;
}

Measured memory_bytes: 5120
N, K = map(int, input().split())


def convert(X, n):
    X_dumy = X
    out = ''
    while X_dumy > 0:
        out = str(X_dumy % n)+out
        X_dumy = int(X_dumy/n)
    return out


print(len(str(convert(N, K))))

Measured memory_bytes: 38256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int c[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	for(int i=0;i<a;i++){
		if(i==0||c[i-1]<=c[i]-1)c[i]--;
		if(i&&c[i-1]>c[i]){
			printf("No\n");return 0;
		}	
	}printf("Yes\n");
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n; cin >> n;
    string s; cin >> s;
    int cnt = 0;
    int cnt2 = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') cnt++;
        else cnt2++;
    }

    if(cnt > cnt2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

  ll a,b,c;
  std::cin>>a>>b>>c;

  if(a+b+c>=22)std::cout<<"bust\n";
  else std::cout<<"win\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
int ar[mx],br[mx],pos[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
void solve()
{
    int x;
    cin>>x;
    if(x==1)
        cout<<0<<endl;
    else
        cout<<1<<endl;
}
int main()
{
    faster();
    int tc;
    tc=1;
    while(tc--)
        solve();
    return 0;
}



Measured memory_bytes: 3652
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	set<string> hav;
	cin >> N;
	string s;
	rep(i, N){
		cin >> s;
		hav.insert(s);
	}
	cout << hav.size();
}

Measured memory_bytes: 19184
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
     int minv = 100000000;
    for(int i = 1;i <= 100; i++) {
        int sum = 0;
        for(int j = 0;j<n;j++) {
            sum += (i-a[j])*(i-a[j]);
        }
        minv = min(sum,minv);
    }
    cout << minv << endl;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int m = max(a,max(b,c));
  int sa = (m - a) + (m - b) + (m - c),kekka;
  if(sa % 2 == 0){
    kekka = sa / 2;
  }
  else{
    kekka = (sa + 3) / 2;
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
const int bits=200;

int main(){
	int n,q;
	cin>>n;
	int *A=new int[n];
	for(int i=0;i<n;++i)cin>>A[i];
	
    int max=pow(2,n);
    int *B=new int[max];
	for(int i=1;i<max;++i){
       
		 bitset<20> t;
         t =i;
         int sum=0;
         for(int j=0;j<20;++j){
         	if(t[j]==1)sum+=A[j];
         }
         B[i-1]=sum;
   	}
    
	cin>>q;
	int m;
	for(int i=0;i<q;++i){
		cin>>m;
		int j=0;
		for(;j<max;++j){
			if(B[j]==m){
				cout<<"yes"<<endl;
				break;
			}
			
		}
		if(j==max)cout<<"no"<<endl;
	}
	
   
}


Measured memory_bytes: 7356
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#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*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if((abs(b-a)<=d&&abs(c-b)<=d)||abs(a-c)<=d)
        Yes
    else
        No
    
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    vector<int> W;
    int sumn = 0;

    for(int i = 0; i < N; i++){
        int w;
        cin >> w;

        W.push_back(w);
        if(i != 0){
            sumn += w;
        }
    }

    int sumt = W[0];
    int mi = abs(sumt - sumn);

    for(int i = 1; i < N-1; i++){
        sumt += W[i];
        sumn -= W[i];

        mi = min(mi, abs(sumt-sumn));
    }

    cout << mi << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
main(){
  int n, i, tmp, ans;
  double sum;
  while(1){
    if(scanf("%d", &n)==EOF) break;

    sum=0;
    for(i=0;i<n;i++){
      scanf("%d", &tmp);
      sum+=tmp;
    }
    ans=(int)(sum/(double)n);
    printf("%d\n", ans);
  }
    
  return 0;
}

Measured memory_bytes: 0
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}

vector<int> a;
int n;
map<pair<int,int>,int> done;


int f(int l,int r,int left)
{
	if(left==0)
		return 0;
	if(r-l+1<left*2-1 || r<l)
		return -INF;
	if(done.find({l,left})!=done.end())
		return done[{l,left}];
	return done[{l,left}]=max(a[l]+f(l+2,r,left-1), f(l+1,r,left));
}


signed main()
{
	fio
	cin>>n;
	a.resize(n);
	fo(i,n)	
		cin>>a[i];
	cout<<f(0,n-1,n/2)<<'\n';
	printclock;
}

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

typedef long long ll;

int main()
{
	
	ll n,w;
	cin>>n>>w;
	ll v[n+1],wt[n+1];
	for(int i=1;i<=n;i++)
	cin>>wt[i]>>v[i];
	
	ll dp[n+1][w+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i==0 || j==0)
			dp[i][j] = 0;
			else if(wt[i] <= j)
			{
				dp[i][j] = max(v[i] + dp[i-1][j-wt[i]] , dp[i-1][j]);
			}
			else
			dp[i][j] = dp[i-1][j];
		}
	}
	cout<<dp[n][w]<<endl;
	
	
	return 0;
}

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

const int INF = 1e9;

int main()
{
  int n;
  cin >> n;
  
  vector<ll> a(n);
  int cnt = 0;
  rep(i, n)
  {
    cin >> a[i];
    if(a[i] < 0) cnt++;
    a[i] = abs(a[i]);
  }
  
  sort(a.begin(), a.end());
  
  ll sum = 0;
  rep(i, n) sum += a[i];
  
  if(cnt%2 == 0) cout << sum << endl;
  else cout << sum - a[0]*2 << endl;
  
  return 0;
}

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

int main()
{
  int N;
  cin >> N;
  
  vector<int> num(N+1);
  int count = 1;
  while(count <= N){
    for(int x = 1; ; x++){
      int fnx = x*x + 1 + 1 + x + 1 + x;
      if(fnx > count){
        break;
      }
      
      for(int y = 1; ; y++){
        int fny = x*x + y*y + 1 + x*y + y + x;
        if(fny > count){
          break;
        }//if
        
        for(int z = 1; ; z++){
          int fnz = x*x + y*y + z*z + x*y + y*z + z*x;
          if(fnz == count ){
            num.at(count)++;
          }//if
          if(fnz > count){
            break;
          }//if
        }//for
        
      }//for
    
    }//for
    
    count++;
  }//while
  
  for(int i = 1; i <= N; i++){
    cout << num.at(i) << endl;
  }
  
}

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

void dfs(int sum,int now,string t)
{
	
	if(now==4)
	{
		t+='=';
		if(sum==7)
		{
			//cout<<t<<endl;
			for(int i = 0;i<3;i++)
			{
				cout<<s[i]<<t[i+1];
			}
			cout<<s[3]<<'='<<7<<endl;
			exit(0);
		}
		return;
	}
	dfs(sum+(s[now]-'0'),now+1,t+'+');
	if(now)dfs(sum-(s[now]-'0'),now+1,t+'-');
}

int main()
{
	cin >> s;
	dfs(0,0,"");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i, k, n, max=0, max_i, ans=0;
  scanf("%d%d",&k,&n);
  int a[n];
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  //最も長いところを探す
  for(i=0;i<n-1;i++){
    ans+=a[i+1]-a[i];
    if(a[i+1]-a[i]>max){
      max=a[i+1]-a[i];
      max_i=i;
    }
  }
  if(k-a[n-1]+a[0]>max){
    printf("%d",ans);
  }
  else{
    printf("%d",k-(a[max_i+1]-a[max_i]));
  }
}

Measured memory_bytes: 896
MOD = 10**9+7
N,K = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse = True)
ans = 1
if A[-1] >= 0:
    for i in range(K):
        ans *= A[i]
        ans %= MOD
elif A[0] < 0:
    if K % 2 == 0:
        for i in range(K):
            ans *= A[N-1-i]
            ans %= MOD
    else:
        for i in range(K):
            ans *= A[i]
            ans %= MOD
else:
    r,l = N-1,0
    n = 0
    while n < K:
        if K-n == 1:
            ans *= A[l]
            ans %= MOD
            n += 1
        else:
            if A[r]*A[r-1] > A[l]*A[l+1]:
                ans *= (A[r]*A[r-1])
                ans %= MOD
                r -= 2
                n += 2
            else:
                ans *= A[l]
                ans %= MOD
                l += 1
                n += 1
print(ans)


Measured memory_bytes: 33072
import sys
readline = sys.stdin.readline

def main():
    H, W = map(int, readline().rstrip().split())
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    res = [[-1] * W for _ in range(H)]
    ht, wt = 0, 0
    for i, a in enumerate(A):
        while a:
            res[ht][wt] = i+1
            a -= 1
            if (ht % 2 == 0 and wt == W-1) or (ht % 2 == 1 and wt == 0):
                ht += 1 
            elif  ht % 2 == 0:
                wt += 1
            else:
                wt -= 1
                
    for l in res:
        print(*l, sep=' ')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3908
n = int(raw_input())
def gb(s):
	bal,m = 0,0
	for l in s: 
		bal += 1 if l == '(' else -1
		m = min(m, bal)
	return (bal,m)


rs = [gb(raw_input()) for _ in range(n)]
rs.sort(key = lambda x: (0,-x[1], x[0]) if x[0]>=0 else (1,x[1] - x[0], -x[0]))

def f(rs):
	s = 0
	for aa,bb in rs:
		if s + bb < 0: return False
		s += aa
	return s == 0

print 'Yes' if f(rs) else 'No'

Measured memory_bytes: 231160
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


int main() {
	string s;
	cin >> s;
	int sz = s.size();
	int f = 0;
	vector<int>ans(sz);
	vector<int>li(sz);
	int r = 0;
	for (int i = 0; i < sz; i++) {
		if (s[i] == 'R') {
			if (s[i + 1] == 'R') {
				r++;
			}
			else {
				li[i] = r + 1;
				r = 0;
			}
		}
	}
	int l = 0;
	for (int i = sz-1; i >= 0; i--) {
		if (s[i] == 'L') {
			if (s[i - 1] == 'L') {
				l++;
			}
			else {
				li[i] = l + 1;
				l = 0;
			}
		}
	}

	for (int i = 0; i < sz; i++) {
		if (s[i] == 'R') {
			int num1 = (li[i] + 1) / 2;
			int num2 = (s[i+1] == 'L')?li[i + 1] / 2:0;
			int num3 = (i != 0 && s[i-1] == 'L') ? (li[i - 1] / 2) : 0;
			cout << num1 + num2 + num3 << " ";
		}
		else {
			int num1 = (li[i] + 1) / 2;
			int num2 = (s[i - 1] == 'R') ? li[i - 1] / 2 : 0;
			int num3 = (i != sz-1 && s[i + 1] == 'R') ? (li[i + 1] / 2) : 0;
			cout << num1 + num2 + num3 << " ";
		}
	}
	puts("");


	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int S, W;

int main() {
  INCANT;
  cin >> S >> W;
  string ans = W>=S?"unsafe":"safe";
  cout << ans << "\n";
  return 0;
}

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



struct comp{
	bool operator()(const pair<int,int>& a,const pair<int,int>& b){
		return a.second > b.second;
	}
};



int main() {

	int n;
	cin>>n;
	int a[n];
	multiset<int> s;
	for(int i=0;i<n;i++){
	cin>>a[i];s.insert(a[i]);}
	multiset<int>::iterator it,it1,it2;
	map<int,int> m;
	int ans=0;
	for(it=s.begin();it!=s.end();it++)
	{
		if(m.find(*it)!=m.end())
		{
			ans+=m[*it];
			continue;
		}
		int f=0;
		int x=*it;
		for(int i=1;i<=sqrt(*it);i++)
		{
			if(x%i==0)
			{
				
				it1=s.lower_bound(i);
				it2=s.lower_bound(x/i);
				if(it1!=s.end())
				{
					if(*it1==i && it1!=it)
					{
						f=1;
						break;
					}
					else
					{
						it1++;
						if(it1!=s.end()&& *it1==i && it1!=it)
						{
							f=1;
							break;
						}
					}
				}
				if(it2!=s.end())
				{
					if(*it2==x/i && it2!=it)
					{
						f=1;
						break;
					}
					else
					{
						it2++;
						
						if(it2!=s.end() && *it2==x/i&&it2!=it)
						{
							f=1;
							break;
						}
					}
				}
				
			}
			
		}
		//cout<<*it;
		if(f==0){
			m[*it]=1;ans++;}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 23040
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;

int N, M, sx, sy, ex, ey, par[1000000]; char map[1000][1002];
vector<int> grp[1000000]; int dist[1000000];

int find(int x)
{
	int& p = par[x];
	if (p != x) p = find(p);
	return p;
}

int main()
{
	scanf ("%d %d", &N, &M);
	scanf ("%d %d", &sx, &sy); sx--; sy--;
	scanf ("%d %d", &ex, &ey); ex--; ey--;
	for (int i = 0; i < N * M; i++) par[i] = i;
	for (int i = 0; i < N; i++) scanf ("%s", map[i]);
	for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) if (map[i][j] == '.'){
		for (int k = 0; k < 4; k++){
			int x = i + "0121"[k] - '1';
			int y = j + "1012"[k] - '1';
			if (x < 0 || x >= N || y < 0 || y >= M || map[x][y] != '.') continue;
			par[find(i * M + j)] = find(x * M + y);
		}
	}

	for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) if (map[i][j] == '.'){
		for (int x = i - 2; x <= i + 2; x++) for (int y = j - 2; y <= j + 2; y++){
			if (x < 0 || x >= N || y < 0 || y >= M || map[x][y] != '.') continue;
			int p = find(i * M + j);
			int q = find(x * M + y);
			if (p != q) grp[p].push_back(q);
		}
	}

	for (int i = 0; i < N * M; i++) dist[i] = -1;
	queue<int> Q;
	int p = find(sx * M + sy);
	Q.push(p); dist[p] = 0;
	while (!Q.empty()){
		int p = Q.front(); Q.pop();
		for (int& q : grp[p]) if (dist[q] == -1){
			Q.push(q); dist[q] = dist[p] + 1;
		}
	}
	printf ("%d\n", dist[find(ex * M + ey)]);

	return 0;
}

Measured memory_bytes: 46948
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL x,y;

int main()
{
    //freopen("1.txt","r",stdin);
    while (scanf("%lld%lld",&x,&y)!=EOF)
    {
        int cnt=0;
        LL t=x;
        while (t<=y)
        {
            t=t*2;
            cnt++;
        }
        printf("%d\n",cnt);
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)

const long double PI = acos(-1);
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    while(true){
        int n,m; cin >> n >> m;
        if(n == 0 && m == 0) break;
        int sn[101],sm[101],Nsum = 0,Msum = 0;
        for(int i = 0; i < n; i++){
            cin >> sn[i];
            Nsum += sn[i];
        }
        for(int i = 0; i < m; i++){
            cin >> sm[i];
            Msum += sm[i];
        }
        bool flg = false;
        pi p; int sum = MM;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(Nsum + sm[j] - sn[i] == Msum - sm[j] + sn[i] && sm[j]+sn[i] < sum){
                    sum = sn[i]+sm[j];
                    p = make_pair(sn[i],sm[j]);
                    flg = true;
                }
            }
        }
        //cout << "ans=";
        if(flg) cout << p.first << " " << p.second << endl;
        if(!flg) cout << "-1" << endl;
    }
}





Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define oo 200005
using namespace std;
int n, a[oo], b[oo];
long long ans, tmp = 1e18;
int main ()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; ++ i)
    scanf("%d%d", &a[i], &b[i]);
    for(int i = 1; i <= n; ++ i)
    {
        ans += a[i];
        if(a[i] > b[i]) tmp = min(tmp, 1ll * b[i]);
    }
    if(tmp == 1e18) puts("0");
    else printf("%lld", ans - tmp);
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		long[] a = new long[N];
		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}
		sc.close();
		ArrayList<Long> ks = orListUnder(K);
		long ans = 0;
		for(int i=0; i<ks.size(); i++) {
			long tempans = 0;
			long k = ks.get(i);
			for(int j=0; j<N; j++) {
				if((a[j]|k) == k) {
					tempans += b[j];
				}
			}
			ans = Math.max(ans, tempans);
		}
		System.out.println(ans);
		
	}
	
	static long pow(long a, long r) {
		if(r==0) return 1;
		if(r%2==0) {
			long d = pow(a, r/2);
			return d*d;
		} else {
			return pow(a, r-1) * a;
		}
	}
	
	static ArrayList<Long> orListUnder(long K) {
		// K以下のorで考える必要のあるものをすべて列挙する。これらのどれかととorをとり変化がないような非負整数の集合はK以下である。
		// https://beta.atcoder.jp/contests/tenka1-2017-beginner/tasks/tenka1_2017_d　を参照
		ArrayList<Long> ks = new ArrayList<Long>();
		int r = 1;
		{
			long tempk = K;
			while((tempk = tempk/2) != 0) r++;
		}
		ks.add(K);
		for(int i=0; i<=r; i++) {
			long tempk = K;
			if((tempk>>>i)%2==0) continue;
			tempk = tempk & ~(pow(2, i));
			if(i!=0) {
				tempk = tempk | (pow(2, i) -1);
			}
			ks.add(tempk);
		}
		return ks;
	}
}


Measured memory_bytes: 87592
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];

	int ans = 0;
	map<int, int>mp;
	REP(i, N) {
		int a = A[i];
		ans += mp[i - a];
		mp[a + i]++;
	}
	cout << ans << endl;



	return 0;
}



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

int main() {
  int n;
  cin>>n;
  int ans=0;
  rep(i,n)rep(j,n)rep(k,n){
    
    ans +=gcd(gcd(i,j),k);}
   
  cout<<ans<<endl;
  
    
   
}




 




Measured memory_bytes: 3636
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let a = read::<usize>();
    let b = read::<usize>();
    let c = read::<usize>();
    let x = read::<usize>();

    let mut ans = 0;
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            for k in 0..c + 1 {
                if i * 500 + j * 100 + k * 50 == x {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



const int MAX = 1000100;
bool IsPrime[MAX];
vector<int> Era(int n = MAX) {
    vector<int> res;
	IsPrime[0] = false; IsPrime[1] = false; 
	for (int i = 2; i < n; ++i) IsPrime[i] = true;
	for (int i = 2; i < n; ++i) {
		if (IsPrime[i]) {
            res.push_back(i);
			for (int j = i*2; j < n; j += i) IsPrime[j] = false;
		}
	}
    return res;
}


int N, P;

int main() {
    vint prime = Era();
    while (cin >> N >> P) {
        if (N == -1) break;
        
        vint alt;
        int it = upper_bound(ALL(prime), N) - prime.begin();
        for (int i = it; i < it+100; ++i) {
            for (int j = i; j < it+100; ++j) {
                alt.PB( prime[i] + prime[j] );
            }
        }
        sort(ALL(alt));
        
        
        cout << alt[P-1] << endl;
    }
    
    return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);

class Graph {
  protected:
    int vertex;

    Graph(int v) {
      vertex = v;
    }
};

struct Edge {
  int to;
  int cost;
};

class AdjacentListGraph : public Graph {
  protected:
    std::vector<std::vector<Edge> > list;
  public:
    AdjacentListGraph(int v): Graph(v) {
      list.resize(vertex);
    }

    virtual void push(int from, int to, int cost) = 0;
};

class SingleSourceGraph : public AdjacentListGraph {
  protected:
    int start;
    std::vector<long long> dist;
    std::vector<int> prev;

  public:
    long long inf = LLONG_MAX / 3;

    SingleSourceGraph(int v, int s);

    bool bellman_ford();

    std::vector<long long> get_dist();
    std::vector<int> get_path(int d);
};

SingleSourceGraph::SingleSourceGraph(int v, int s): AdjacentListGraph(v) {
  start = s;
  dist.resize(vertex);
  prev.resize(vertex);
  for (int i = 0; i < vertex; ++i) {
    dist[i] = inf;
    prev[i] = -1;
  }
  dist[start] = 0;
}

bool SingleSourceGraph::bellman_ford() {
  bool update = true;
  int cnt = 0;
  while (update) {
    cnt++;
    update = false;
    for (int i = 0; i < vertex; ++i) {
      for (int j = 0; j < (int)list[i].size(); ++j) {
        Edge e = list[i][j];
        if (dist[i] + e.cost < dist[e.to] && dist[i] != inf) {
          if (cnt >= vertex) return true;
          dist[e.to] = dist[i] + e.cost;
          prev[e.to] = i;
          update = true;
        }
      }
    }
  }
  return false;
}

std::vector<long long> SingleSourceGraph::get_dist() {
  return dist;
}

std::vector<int> SingleSourceGraph::get_path(int d) {
  std::vector<int> path;
  int v = d;
  while (v != start) {
    path.push_back(v);
    v = prev[v];
  }
  path.push_back(v);
  std::reverse(path.begin(), path.end());
  return path;
}

class SingleSourceDirectedGraph : public SingleSourceGraph {
  using SingleSourceGraph::SingleSourceGraph;

  public:
  void push(int from, int to, int cost) {
    Edge e;
    e.to = to;
    e.cost = cost;
    list[from].push_back(e);
  }
};

class SingleSourceUndirectedGraph : public SingleSourceGraph {
  using SingleSourceGraph::SingleSourceGraph;

  public:
  void push(int from, int to, int cost) {
    Edge e;
    e.to = to;
    e.cost = cost;
    list[from].push_back(e);

    e.to = from;
    list[to].push_back(e);
  }
};

int main(){
  
  int v;
  int e;
  int s;

  scanf("%d %d %d", &v, &e, &s);

  SingleSourceDirectedGraph g = SingleSourceDirectedGraph(v, s);

  int from, to, cost;

  for (int i = 0; i < e; i++) {
    scanf("%d %d %d", &from, &to, &cost);
    g.push(from, to, cost);
  }

  bool is_negative = g.bellman_ford();
  std::vector<long long> dist = g.get_dist();

  if (is_negative) printf("NEGATIVE CYCLE\n");
  else {
    for (long long d: dist) {
      if (d == g.inf) printf("INF\n");
      else printf("%lld\n", d);
    }
  }
}



Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define plint pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    string s;
    cin >> s;
    if(s[0]=='7' || s[1]=='7' || s[2]=='7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
n = int(input())
str_list = ["".join(sorted(input())) for i in range(n)]
ans = 0
str_dic = {}

for i in range(n):
    if str_list[i] in str_dic:
        str_dic[str_list[i]] += 1
    else:
        str_dic[str_list[i]] = 0

for v in str_dic.values():
    ans += v*(v+1)/2

print(int(ans))

Measured memory_bytes: 66776
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(ll i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	cin>>n;
	priority_queue<ll,vector<ll>,greater<ll> >q;
	forn(i,1,9)q.push(i); 
	rep(i,n-1)
	{
		ll p=q.top();
		q.pop();
		if(p%10ll!=0ll)q.push(p*10ll+p%10ll-1ll);
		q.push(p*10ll+p%10ll);
		if(p%10ll!=9ll)q.push(p*10ll+p%10ll+1ll);
	}
	cout<<q.top()<<endl;
	return 0;
}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
int n;
int c[550],s[550],f[550];

int main(){
	std::cin >> n;
	for(int i = 0; i < n-1; i++) std::cin >> c[i] >> s[i] >> f[i];
	
	for(int i = 0; i < n; i++){
		int t = 0;
		for (int j = i; j < n-1; j++){
			if(t < s[j]) t = s[j];
			else if (t % f[j] == 0); 
			else t = t + f[j] - t % f[j];
			t += c[j];
		} 
		
		std::cout << t << std::endl;
	}
}
 

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main (String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;
 
		try {
			int c = 0;
			int sumcost = 0;
			double sumn = 0;
			while ((buf = br.readLine())!=null) {
				c++;
				StringTokenizer st = new StringTokenizer(buf,",");
				int cost = Integer.parseInt(st.nextToken());
				int n = Integer.parseInt(st.nextToken());
				sumcost += cost*n;
				sumn += (double)n;
			}
			System.out.println(sumcost);
			System.out.println(Math.round(sumn/(double)c));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

using namespace std;

int a[200005];

int main() {
	//int x;
	//cin>>x;
	//x -= 400;
	//x /= 200;
	
	//cout<< 8 - x<<endl;
	
	//int a, b, c, k;
	//cin>>a>>b>>c>>k;
	
	//while(b <= a) {
		//b = 2*b;
		//k--;
	//}
	//while(c <= b) {
		//c *= 2;
		//k--;
	//}
	//if(k >= 0)
		//cout<<"Yes"<<endl;
	//else
		//cout<<"No"<<endl;
	
	
	int n, k;
	cin>>n>>k;
	for (int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	
	for(int i=k; i<n; i++) {
		if(a[i] > a[i-k])
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	
	return 0;
	
	
}


Measured memory_bytes: 4428