akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    set<int> s;
    rep(i,n){
        int a; cin>>a;
        if(s.count(a)){
            cout<<"NO"<<endl;
            return 0;
        }
        s.insert(a);
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 12844
k = int(input())
s = input()
 
l = len(s)
mod = 10**9+7 #出力の制限
 
n = l+k
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 

 
ans = 0
for i in range(l,l+k+1):
    ans = (ans+cmb(i-1,l-1)*pow(25,k-(l+k-i),mod)*pow(26,l+k-i,mod)) % mod
 
print(ans)

Measured memory_bytes: 197216
#include <stdio.h>
#include <string.h>
#define STMAX 50
int main(void)
{
  int i, slen, tlen, spos, tpos;
  char str[STMAX+1], ttr[STMAX+1];
  scanf("%s%*c", str);
  scanf("%s%*c", ttr);
  slen = strlen(str);
  tlen = strlen(ttr);
  spos = slen - 1;
  tpos = tlen - 1;
  while (spos >= tpos) {
    if (str[spos] != '?') {
      while (tpos < tlen && str[spos] != ttr[tpos]) tpos++;
    }
    if (!tpos) break;
    spos--;
    tpos--;
  }
  if (spos >= tpos) {
    for (i = spos; i < spos + tlen; i++) str[i] = ttr[i-spos];
    for (i = 0; i < slen; i++) {
      if (str[i] == '?') str[i] = 'a';
    }
    printf("%s\n", str);
  } else printf("UNRESTORABLE\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

Int h[100005];

int main(){
    cin.tie(0);

    int N; cin >> N;
    int K; cin >> K;
    for (int i = 0; i < N; i++){
        cin >> h[i];
    }
    sort(h, h+N);
    Int ans = 10000000000;
    for (int i = 0; i < N-K+1; i++){
        ans = min(ans, h[i+K-1]-h[i]);
    }
    cout << ans << endl;

}



Measured memory_bytes: 1024
import java.util.*;
import java.lang.String;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String str = sc.nextLine();
        String strArr[] = str.split("");
        int numArr[] = new int[4];

        for (int i = 0; i < 4; i++){
            numArr[i] = Integer.valueOf(strArr[i]);
        }

        Boolean isYYMM = false;
        Boolean iSMMYY = false;

        isYYMM = isYYMM(numArr);
        iSMMYY = isMMYY(numArr);

        if (isYYMM && iSMMYY) {
            System.out.println("AMBIGUOUS");
        } else if (isYYMM) {
            System.out.println("YYMM");
        } else if (iSMMYY) {
            System.out.println("MMYY");
        } else {
            System.out.println("NA");
        }
    }

    static Boolean isYYMM(int[] numArr) {
        Boolean isYYMM = true;
        String month = Integer.toString(numArr[2]) + Integer.toString(numArr[3]);

        if (Integer.valueOf(month) > 12) {
            isYYMM = false;
        } else if (Integer.valueOf(month) == 0) {
            isYYMM = false;
        }
        return isYYMM;
    }

    static Boolean isMMYY(int[] numArr) {
        Boolean isMMYY = true;
        String month = Integer.toString(numArr[0]) + Integer.toString(numArr[1]);

        if (Integer.valueOf(month) > 12) {
            isMMYY = false;
        } else if (Integer.valueOf(month) == 0) {
            isMMYY = false;
        }

        return isMMYY;
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

int cnt[100010];
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N];
    int sum=0;
    rep(i,N) cin >> A[i];
    rep(i,N) {
        cnt[A[i]]++;
        sum+=A[i];
    }
    int Q; cin >> Q;
    rep(i,Q) {
        int a,b; cin >> a >> b;
        sum-=cnt[a]*a;
        sum+=cnt[a]*b;
        cnt[b]+=cnt[a];
        cnt[a]=0;
        cout << sum <<"\n";
    }
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long n, std::vector<long long> a){
    i64 wa = 0, tmp = 0;
    rep(i, n){
        wa += a[i];
        if(i % 2 == 0){
            if(wa <= 0){
                tmp += 1 - wa;
                wa = 1;
            }
        }else{
            if(wa >= 0){
                tmp += wa + 1;
                wa = -1;
            }
        }
    }
    i64 ans = tmp;
    wa = 0; tmp = 0;
    rep(i, n){
        wa += a[i];
        if(i % 2 == 1){
            if(wa <= 0){
                tmp += 1 - wa;
                wa = 1;
            }
        }else{
            if(wa >= 0){
                tmp += wa + 1;
                wa = -1;
            }
        }
    }
    cout << min(tmp, ans) << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long n;
    scanf("%lld",&n);
    std::vector<long long> a(n);
    for(int i = 0 ; i < n ; i++){
        scanf("%lld",&a[i]);
    }
    solve(n, std::move(a));
    return 0;
}


Measured memory_bytes: 4056
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}


void solve(vector<vector<int>> &tree, vector<int> &count, vector<int> &ans, int per, int node, int sum){
	
	ans[node] = sum + count[node];
	
	for(int i = 0; i < tree[node].size(); i++){
		if(tree[node][i] == per) continue;
		solve(tree, count, ans, node, tree[node][i], sum + count[node]);
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	vector<vector<int>> tree;
	vector<int> count, ans;
	int N, Q;
	int a, b, p, x;
	
	cin>>N>>Q;
	
	tree.resize(N+2);
	count.resize(N+2);
	ans.resize(N+2);
	
	for(int i = 1; i < N; i++){
		cin>>a>>b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	
	for(int i = 0; i < Q; i++){
		cin>>p>>x;
		
		count[p] += x;
	}
	
	solve(tree, count, ans, 0, 1, 0);
	
	for(int i = 0; i < N; i++){
		if(i) cout<<" ";
		cout<<ans[i+1];
	}
	cout<<endl;
	return 0;
}

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


void solve(long long N, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> p, std::vector<long long> x){
  map<ll,vector<ll>> m;
  vector<ll> v(N+1, 0);
  for(int i=0; i<N; i++) {
    m[i+1] = vector<ll>();
  }
  for(int i=0; i<N; i++) {
    m[a[i]].push_back(b[i]);
    m[b[i]].push_back(a[i]);
  }
  for(int i=0; i<Q; i++) {
    v[p[i]] += x[i];
  }
  queue<int> q;
  q.push(1);
  vector<ll> ch(N+1, 0);
  while(!q.empty()) {
    int x = q.front();
    q.pop();
    ch[x] = 1;
    for(auto chi : m[x]) {
      if(ch[chi] == 0) {
	v[chi] += v[x];
	q.push(chi);
      }
    }
  }
  for(int i=0; i<N; i++) {
    if(i+1 == N) std::cout << v[i+1] << std::endl;
    else std::cout << v[i+1] << ' ';
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    std::vector<long long> p(Q);
    std::vector<long long> x(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&p[i]);
        scanf("%lld",&x[i]);
    }
    solve(N, Q, std::move(a), std::move(b), std::move(p), std::move(x));
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    int N;
    cin >> N;
    vector<lint> A(N);
    for_(i,0,N) cin >> A[i];

    sort(ALL(A));
    lint ans = 1;
    const lint MAXI = (lint)1e18;

    for_(i,0,N) {
        if (A[i] > 0 and MAXI / A[i] < ans) {
            puts("-1");
            return 0;
        }
        ans *= A[i];
        if (ans > MAXI) {
            puts("-1");
            return 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3988
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b = li()
diff = b-a

sm = sum([i for i in range(1,diff+1)])
print(sm-b)

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

int main(){
	
	int N;
	cin>>N;
	
	vector<long long> X(N),Y(N);
	
	rep(i,N){
		long long x,y;
		cin>>x>>y;
		X[i] = x+y;
		Y[i] = x-y;
	}
	
	rep(i,N){
		if(abs(X[i]%2)!=abs(X[0]%2)){
			cout<<-1<<endl;
			return 0;
		}
	}
	rep(j,N){
		for(long long i=0;i<35;i++){
			X[j] += (1LL<<i);
			Y[j] += (1LL<<i);
		}
	}
	
	int sz = 35;
	if(X[0]%2!=0)sz++;
	cout<<sz<<endl;
	vector<long long> t;
	if(X[0]%2!=0)t.push_back(1);
	for(long long i=0;i<35;i++)t.push_back((1LL)<<i);
	rep(i,t.size()){
		if(i!=0)cout<<' ';
		cout<<t[i];
	}
	cout<<endl;
	rep(i,N){
		string ans = "";
		if(X[i]%2!=0){
			ans += 'R';
			X[i] --;
			Y[i] --;
		}
		X[i]/=2;
		Y[i]/=2;
		
		for(long long j=0;j<35;j++){
			int a = (X[i]>>j)&1;
			int b = (Y[i]>>j)&1;
			if(a&&b)ans += 'R';
			if(!a&&!b)ans += 'L';
			if(a&&!b)ans += 'U';
			if(!a&&b)ans += 'D';
		}
		
		cout<<ans<<endl;
		
	}
	
	
    return 0;
}



Measured memory_bytes: 3624
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long X = sc.nextLong();
        long[] An = new long[N+1];
        long[] Bn = new long[N+1];
        long A = 5;
        long B = 3;
        for(int i = 1;i <= N;i++){
            An[i] = A;
            A = A*2+3;
        }
        for(int i = 1;i <= N;i++){
            Bn[i] = B;
            B = B*2+1;
        }
        System.out.println(f(N, X, An, Bn));
    }
    public static long f(int n, long x, long[] an, long[] bn){
        if(n == 1){
            if(x >= 5)  return 3;
            else    return Math.max(0, x-(long)1);
        }else if(an[n]-(long)1 <= x){
            return bn[n];
        }else if(an[n-1]+(long)2 <= x){
            return bn[n-1]+(long)1+f(n-1, x-(long)2-an[n-1], an, bn);
        }else{
            return f(n-1, x-(long)1, an, bn);
        }
    }
}

Measured memory_bytes: 23764
#include<iostream>


int cube(int x) {
  int ans = 1;
  for (int i=0; i < 3; i++) {
    ans *= x;
  }
  return ans;
}


int main() {
  int x;

  std::cin >> x;
  std::cout << cube(x) << std::endl;

  return 0;
}



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

struct UnionFind {
    int n;
    vector<int> sz,par;
    UnionFind(){}
    UnionFind(int sz):n(sz),sz(sz,1),par(sz,0){ iota(par.begin(),par.end(),0); }
    // xの親を見つける.
    int find(int x){
        return (x==par[x]?x:par[x]=find(par[x]));
    }
    // 同じ集合か
    bool same(int x,int y){
        return find(x)==find(y);
    }
    // xの属する集合とyの属する集合を結合
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y) return;
        if(sz[x]<sz[y]) swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    // xの属する集合サイズ
    int size(int x){
        return sz[find(x)];
    }
};


template<typename T>
struct Edge{
    int from,to;
    T cost;
    int used;
    Edge(int from,int to,T cost):
        from(from),to(to),cost(cost),used(0){}
    bool operator<(const Edge& e) const{
        return cost<e.cost;
    }
};


template <typename T>
T Kruskal(int V, vector<Edge<T>> &E) {
    // E: 辺集合
    UnionFind uf(V);
    sort(E.begin(), E.end());
    T minCost = 0;
    for (auto &e : E) {
        // 辺を採用
        if (!uf.same(e.from, e.to)) {
            minCost += e.cost;
            uf.unite(e.from, e.to);
            e.used = 1;
        }
    }
    return minCost;
}

int main(void) {
    int V, E;
    cin >> V >> E;
    vector<Edge<int>> edge;
    for (int i = 0;i < E;i++) {
        int s, t, w;
        cin >> s >> t >> w;
        edge.emplace_back(s,t,w);
    }
    cout << Kruskal(V, edge) << endl;
}


Measured memory_bytes: 4916
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {

			StringBuffer sb = new StringBuffer(sc.next());
			for (int i = 0; i < sb.length() - 1; i++) {
				char c = sb.charAt(i);
				if(c == 'P') {
					if(sb.charAt(i+1) == '?' ) {
						sb.setCharAt(i+1, 'D');
					}
				}else if (c == '?') {
					if (sb.charAt(i + 1) == '?') {
						sb.setCharAt(i, 'P');
						sb.setCharAt(i + 1, 'D');

					} else if (sb.charAt(i + 1) == 'D') {
						sb.setCharAt(i, 'P');
					} else {
						sb.setCharAt(i, 'D');
					}
				} else {
					sb.setCharAt(i, c);
				}
			}

			if (sb.charAt(sb.length() - 1) == '?') {
				sb.setCharAt(sb.length() - 1, 'D');
			}
			System.out.println(sb.toString());

		} catch (Exception e) {
		}

	}

}


Measured memory_bytes: 40884
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
import itertools
def resolve():
    N,X=pin()
    A=lispin()
    A.sort()
    S=list(itertools.accumulate(A))
    #print(S)
    for i in range(N):
        if S[i]>X:
            print(i)
            return
    if S[-1]<X:print(N-1)
    else:print(N)
        
        

#%%submit!    
resolve()

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

using namespace std;
using llong = long long;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  int sum = a+b+c;
  for(int l=max(a,max(b,c));l<1000;l++){
    if( (3*l-sum)/2 >= 0 && (3*l-sum)%2==0){
      cout << (3*l-sum)/2 << endl;
      return 0;
    }
  }


  return 0;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 1e5 + 5;
const int inf = 1e16 + 2;


void solve(int Case) {
    string s , t ;
    cin >> s >> t ;
    int n = s.size() , m = t.size();
    int ans = m ;
    for(int i = 0 ; i < n - m + 1 ; i ++) {
        int cnt = 0;
        for(int j = i ; j < i + m ; j ++) {
            if(s[j] != t[j - i]) cnt  ++;
        }
        ans = min(ans , cnt);
    }
    cout << ans << '\n';
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int Case = 1;
    while(testcase --) {
        solve(Case ++);
    }
    return 0;
}


Measured memory_bytes: 3652
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    int a, b, k; cin>>k>>a>>b;
    for(int i = a; i <= b; i++){
        if(i % k == 0){cout<<"OK\n"; return 0;}
    }

    cout<<"NG\n";


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int gcd(int a, int b) {
    if (a % b == 0) {
        return (b);
    }
    else {
        return (gcd(b, a % b));
    }
}
int main(){
    int x;
    cin >> x;
    int ans = x * 360 / gcd(x, 360);
    cout << ans / x << endl;
	return 0;
}



Measured memory_bytes: 3632
# https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b

import sys
# sys.setrecursionlimit(100000)
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    s = input()
    d = defaultdict(int)
    for c in s:
        d[c] += 1
    if abs(d["a"] - d["b"]) < 2 and abs(d["b"] - d["c"]) < 2 and abs(d["c"] - d["a"]) < 2:
        print("YES")
    else:
        print("NO")
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 73608
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <map>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
ll a,b,c,d;
map<ll,ll> memo;
ll dfs(ll n){
  if(n==0) return 0;
  else if(n==1) return d;
  else if(memo.count(n)) return memo[n];
  
  ll res=(ll)1e18;
  ll f2 = (ll)floorl((ld)n/2.0)*2;
  ll c2 = (ll)ceill((ld)n/2.0)*2;
  ll f3 = (ll)floorl((ld)n/3.0)*3;
  ll c3 = (ll)ceill((ld)n/3.0)*3;
  ll f5 = (ll)floorl((ld)n/5.0)*5;
  ll c5 = (ll)ceill((ld)n/5.0)*5;
  
  if(n<res/d) res = n*d;
  res = min(res, llabs(n-f2)*d + a + dfs(f2/2));
  res = min(res, llabs(n-c2)*d + a + dfs(c2/2));
  
  res = min(res, llabs(n-f3)*d + b + dfs(f3/3));
  res = min(res, llabs(n-c3)*d + b + dfs(c3/3));
  
  res = min(res, llabs(n-f5)*d + c + dfs(f5/5));
  res = min(res, llabs(n-c5)*d + c + dfs(c5/5));
  
  memo[n] = res;
  return res;
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,t;
  string s;
  
  cin >> t;
  rep(i,t){
    memo.clear();
    cin >> n >> a >> b >> c >> d;
    result = dfs(n);
    cout << result << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4428
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define For(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
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); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, m; cin >> n >> m;
    vector<int> s(m), c(m);
    rep(i, m) cin >> s[i] >> c[i];

    rep(i, 1000){
        string x = to_string(i);
        if(x.size() == n){
            bool valid = true;
            rep(j, m)
                if(x[s[j] - 1] != ('0' + c[j]))
                    valid = false;

            if(valid){
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;

return 0;
}

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

int main()
{
  int N;
  int A;
  
  long long count = 0;
  
  cin >> N;
  
  for(A = 1 ; A <= N; A++)
  {
    count += (N-1) / A;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>

int main(void)
{
   int n, target, count;
   int data[100];
   int lo, hi, ce;
   int i;

   while(scanf("%d", &n)){
      if(n==0) break;

      for(i=0; i<n; i++){
         scanf("%d", &data[i]);
      }
      scanf("%d", &target);

      count=0;
      hi=n-1;
      lo=0;
      while(hi>=lo){
         count++;
         ce=(lo+hi)/2;
         if(data[ce]==target) break;
         if(data[ce]<target) lo=ce+1;
         else hi=ce-1;
      }
      printf("%d\n", count);
   }
   return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] p = new int[n];
        for(int i = 0; i < n; i++) {
            p[i] = scan.nextInt();
        }

        int cnt = 0;
        for(int i = 1; i < n -1; i++) {
            int a = p[i - 1];
            int b = p[i];
            int c = p[i + 1];

            int max = Math.max(Math.max(a, b), Math.max(a, c));
            int min = Math.min(Math.min(a, b), Math.min(a, c));
            if (max != b && min != b) {
                cnt++;
            }

        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		BigDecimal num1 = new BigDecimal(sc.next());
		BigDecimal num2 = new BigDecimal(sc.next());
		BigDecimal mul = num1.multiply(num2);
		BigDecimal result = mul.setScale(0, RoundingMode.DOWN);

		long out = result.longValue();


		System.out.println(out);
		sc.close();

	}

}

Measured memory_bytes: 27224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979
#define EPS 1e-8
#define mod 1000000007
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define endl "\n"
	 
const ll INF=(ll)2e18;	
const int N=1e5+5;
 

 
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinverse(ll a,ll m)
{
	return binpow(a,m-2,m);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(0);
	
	ll n,m,k;
	cin>>n>>m>>k;
	
	vector<ll> a(n+1),b(m+1);
	
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]+=a[i-1];
	}
	ll j=0;
	for(ll i=1;i<=m;i++)
	{
		cin>>b[i];
		b[i]+=b[i-1];
		if(b[i]<=k)
		{
			j=i;
		}
	}
	ll ans=j;
	for(ll i=1;i<=n;i++)
	{
		while(j>0)
		{
			if((a[i]+b[j])<=k)
			{
				break;
			}
			else
				j--;
		}
		if(a[i]+b[j]<=k)
			ans=max(ans,i+j);
	}
	cout<<ans<<endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  // or pb_ds;

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#ifndef DEBUG
// #define endl "\n"
#endif
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

#define all(x) x.begin(), x.end()

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

template <typename T, typename B = null_type>
using oset =
    tree<T, B, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order / order_of_key

const ld eps = 1e-12;

/*-----------------END TEMPLATE-----------------*/

ll fastexp(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % PRIME;

    a = (a * a) % PRIME;
    b >>= 1;
  }
  return res;
}

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

  int ans[k + 1];
  ll sum = 0;
  for (int i = k; i >= 1; i--) {
    int divisors = k / i;
    ll quantosComI = fastexp(divisors, n);
    for (int j = i + i; j <= k; j += i) {
      quantosComI = (quantosComI - ans[j] + PRIME) % PRIME;
    }
    ans[i] = quantosComI;
    sum += ((ll)i * ans[i]) % PRIME;
    sum %= PRIME;
  }
  cout << sum << endl;
}

int(((((((((((((((main)))))))))))))))() {
  FASTIO;
  int n;
  // cin >> n;
  n = 1;
  int i = 1;
  while (n--) {
    solve();
  }
}

/*


00100
00

*/

Measured memory_bytes: 4016
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    if sum([a[i][j] * b[j] for j in range(m)]) + c > 0:
        ans += 1
print(ans)


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

int main() {
  int a, b, c, x, ans = 0;
  cin >> a >> b >> c >> x;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (500*i + 100*j + 50*k == x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1 << 30;
// const ll INF = 1LL << 62;
// --------------------------------------------------------


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N, M; cin >> N >> M;
    VI K(M);
    VVI S(M);
    REP(i, M) {
        cin >> K[i];
        S[i] = VI(K[i]); REP(j,K[i]) cin >> S[i][j];
    }
    VI P(M); REP(i,M) cin >> P[i];

    int ans = 0;
    FOR(bit, 0, 1 << N) {
        bool all_light = true;
        REP(i, M) {
            int cnt = 0;
            for (auto s : S[i]) {
                if (bit & (1 << (s - 1))) cnt++;
            }
            if (cnt % 2 != P[i]) all_light = false;
        }
        if (all_light) ans++;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3620
import sys
from copy import copy
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')

INF = 10**9 + 7


def main():
    H, W = in_nn()
    s = [list(in_s()) for _ in range(H)]

    dp = [INF] * W
    if s[0][0] == '#':
        dp[0] = 1
    else:
        dp[0] = 0

    for x in range(W - 1):
        if s[0][x] == '.' and s[0][x + 1] == '#':
            dp[x + 1] = dp[x] + 1
        else:
            dp[x + 1] = dp[x]

    for y in range(1, H):
        next_dp = [INF] * W
        for x in range(W):
            if s[y - 1][x] == '.' and s[y][x] == '#':
                next_dp[x] = min(next_dp[x], dp[x] + 1)
            else:
                next_dp[x] = min(next_dp[x], dp[x])
        for x in range(1, W):
            if s[y][x - 1] == '.' and s[y][x] == '#':
                next_dp[x] = min(next_dp[x], next_dp[x - 1] + 1)
            else:
                next_dp[x] = min(next_dp[x], next_dp[x - 1])

        dp = next_dp

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9444
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int h, n;
    cin >> h >> n;
    ll acc = 0;
    ll val = 0;
    while(n--) {
        cin >> val;
        acc += val;
    }
    if (acc >= h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define f(i,x,n) for(ll int i=x;i<n;i++) 
#define re(j,x,n) for(ll int j=x;j>=n;j--)
#define f1(k,x,n) for(ll int k=x;k<=n;k++)
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define MAX 1000001
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n;
    cin>>n;
    ll int d[n];
    f(i,0,n)
      cin>>d[i];
    ll int sum=0;
    f(i,0,n)
    {
      f(j,i+1,n)
       sum+=d[i]*d[j];
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 10000010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll S;

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}


void solve() {
	cin >> S;

	auto f = [](int i) {
		if(i < 10) return 1;
		else if(i < 100) return 2;
		else if(i < 1000) return 3;
		else if(i < 10000) return 4;
		else if(i < 100000) return 5;
		else if(i < 1000000) return 6;
		else if(i < 10000000) return 7;
		else return 8;
	};

	ll ans = 0;
	ll at = 1;
	ll sum = 0;
	for(ll i = 1; i < 10000000; i++) {
		while(sum < S) {
			sum += f(at); at++;
		}
		if(sum == S) ans++;
		sum -= f(i);
	}

	for(ll n = 1; n * n <= S; n++) {
		if(S % n) continue;
		ll m = S / n;
		if(n == m && n >= 8) ADD(ans, 9 * mod_pow(10, n - 1) % mod - S / n + 1 + mod);
		else {
			if(n >= 8) ADD(ans, 9 * mod_pow(10, n - 1) % mod - S / n + 1 + mod);
			if(m >= 8) ADD(ans, 9 * mod_pow(10, m - 1) % mod - S / m + 1 + mod);
		}
	}

	ll n;
	for(n = 8; n * (n + 1) <= S; n++) {
		ll t = S % n == 0 ? n : S % n;
		if((S - 1) / (n + 1) - t >= 0) {
			ADD(ans, ((S - 1) / (n + 1) - t) / n + 1);
		}
	}
	for(; n <= S; n++) {
		ll t = S % n == 0 ? n : S % n;
		if(S - 1 - t * (n + 1) >= 0) ADD(ans, 1);
	}
	cout << ans << "\n";
}


int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

void dfs(vector<string>& s, int x, int y, vector<int>& xs, vector<int>& ys){
    int h = s.size(), w = s[0].size();
    xs.push_back(x);
    ys.push_back(y);
    char d = s[x][y];
    s[x][y] = '.';
    for(int i = 0;i < 4;i++){
        int tx = x + dx[i], ty = y + dy[i];
        if(0 <= tx && tx < h && 0 <= ty && ty < w && s[tx][ty] == d){
            dfs(s, tx, ty, xs, ys);
        }
    }
}

pair<int, int> getg(const graph& G, const graph& posx, const graph& posy, int v){
    pair<int, int> res(0, 0);
    for(int i = 0;i < 4;i++){
        res.first += posy[v][i] * 2 + 1;
        res.second += 2;
    }
    for(auto to : G[v]){
        auto p = getg(G, posx, posy, to);
        res.first += p.first;
        res.second += p.second;
    }
    return res;
}

bool judge(const graph& G, const graph& posx, const graph& posy, const graph& a, int v){
    for(auto to : G[v]){
        if(judge(G, posx, posy, a, to)) return true;
    }
    int h = a.size();
    int xl = 100, xr = 0;
    for(int i = 0;i < 4;i++){
        if(posx[v][i] + 1 == h || (a[posx[v][i] + 1][posy[v][i]] != -1 && a[posx[v][i] + 1][posy[v][i]] != a[posx[v][i]][posy[v][i]])){
            xl = min(xl, posy[v][i]);
            xr = max(xr, posy[v][i] + 1);
        }
    }
    auto p = getg(G, posx, posy, v);
    return !(xl * p.second < p.first && p.first < xr * p.second);
}

int main()
{
    int w, h;
    while(cin >> w >> h, w | h){
        vector<string> s(h);
        vector<vector<int>> posx, posy;
        for(int i = 0;i < h;i++){
            cin >> s[i];
        }
        auto tmp = s;
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                if(tmp[i][j] != '.'){
                    posx.push_back(vector<int>());
                    posy.push_back(vector<int>());
                    dfs(tmp, i, j, posx.back(), posy.back());
                }
            }
        }
        vector<vector<int>> v(h, vector<int>(w, -1));
        int n = posx.size();
        for(int i = 0;i < n;i++){
            for(int j = 0;j < 4;j++){
                v[posx[i][j]][posy[i][j]] = i;
            }
        }
        graph G(n);
        int rt = 0;
        for(int i = 0;i < n;i++){
            for(int j = 0;j < 4;j++){
                if(posx[i][j] + 1 == h){
                    rt = i;
                    break;
                }
                if(s[posx[i][j] + 1][posy[i][j]] != '.' && s[posx[i][j] + 1][posy[i][j]] != s[posx[i][j]][posy[i][j]]){
                    G[v[posx[i][j] + 1][posy[i][j]]].push_back(i);
                    break;
                }
            }
        }
        puts(judge(G, posx, posy, v, rt) ? "UNSTABLE" : "STABLE");
    }
    return 0;
}



Measured memory_bytes: 2968
def prime_list_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
def prime_list_eratosthenes_from(n_from, n_to):
    from bisect import bisect_left
    data = prime_list_eratosthenes(n_to)
    i = bisect_left(data, n_from)
    return data[i:]
x = int(input())
d = prime_list_eratosthenes_from(x, 1000000)
print(d[0])


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main() {
    int N;
    ll W;
    cin >> N >> W;
    
    vector<ll> weight(N);
    vector<ll> value(N);
    rep(i,N) cin >> weight[i] >> value[i];

    vector<vector<ll> > dp(N+1, vector<ll>(1e6, INF_LL));

    // 初期条件
    dp[0][0] = 0;

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < dp[i].size(); ++sum_v) {

            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < dp[N].size(); ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 797440
#include<stdio.h>

int main(void)
{
  int x,d[101],l=0,n;
  scanf("%d %d",&n,&x);
  for(int i=1;i<=n;i++){
    scanf("%d",&d[i]);
  }

  int i=1;
  while(i<=n){
    l+=d[i];
    if(l>x) break;
    i++;
  }

  printf("%d",i);
}

Measured memory_bytes: 128
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 110;
ll n, W;

ll w[N] , v[N];
ll dp[N][100005];

ll go(ll i , ll value)
{
	if(value <= 0)
		return 0;
	if(i > n)
		return 999999999999999;

	ll &ans = dp[i][value];
	if(ans != -1)
		return ans;

	ans = min( go(i+1 , value) , w[i] + go(i+1 , value - v[i]));
	return ans;
}

signed main()
{
	fast;
	memset(dp , -1 , sizeof dp);
////////////////////////////////////////////////////////////////////////////////////////////
	cin >> n >> W;
	ll max_value = 0;
	rep(i,1,n+1)
		cin >> w[i] >> v[i] , max_value +=v[i];
	ll ans = -1; 

	for(ll i = max_value ; i>=0 ; --i)
	{
		if(go(1 , i) <= W)
		{
			ans = i;
			break;
		}
	}
	cout<<ans<<endl;




////////////////////////////////////////////////////////////////////////////////////////////

	
	return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define an size()

using namespace std;

const ll maxn=1e5+600;

ll a[3*maxn];
ll l[3*maxn];
ll r[3*maxn];
multiset<ll> st;
multiset<ll> ::iterator it;
int main()
{
    ll n;
    cin>>n;
    for(ll i=0; i<3*n; i++)
    {
        cin>>a[i];
    }
    ll z=0;
    for(ll i=0; i<n; i++)
    {
        z+=a[i];
        st.insert(a[i]);
    }
    l[n-1]=z;
    for(ll i=n;i<3*n;i++)
    {
          it=st.begin();
          if((*it)<a[i])
          {
                z+=a[i];
                z-=(*it);
                st.erase(it);
                st.insert(a[i]);
          }
          l[i]=z;
    }
    st.clear();
    z=0;
    for(ll i=3*n-1;i>=2*n;i--)
    {
          z+=a[i];
          st.insert(a[i]);
    }
    r[2*n]=z;
    for(ll i=2*n-1;i>=0;i--)
    {
         it=st.end();
         it--;
         if((*it)>a[i])
         {
               z+=a[i];
              z -=(*it);
               st.erase(it);
               st.insert(a[i]);
         }
         r[i]=z;
    }
    ll ans=-1e17;
    for(ll i=n-1;i<2*n;i++)
    {
          ans=max(ans,l[i]-r[i+1]);
        //  cout<<i<<';'<<l[i]<<' '<<r[i+1]<<endl;
    }
    cout<<ans;


}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int n, m;
    bool ng[100009]{};
    cin >> n >> m;
    int h[100009];
    rep(i, n) cin >> h[i];
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(h[a] <= h[b]) ng[a] = true;
        if(h[b] <= h[a]) ng[b] = true;
    }
    cout << n - count(ALL(ng), true) << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  string ans = "APPROVED";

  for ( int i = 0; i < n; i++ ) {
    int a;
    cin >> a;
    if ( a%2 == 0 && a%3 != 0 && a%5 != 0 ) {
      ans = "DENIED";
    }
  }

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


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

long long gcd(long long x, long long y) { return (y) ? gcd(y, x % y): x; }

const long long MOD=1000000007;

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

    vector<long long> pw(200010);

    pw[0]=1;
	for (int i=1; i<200010; ++i) pw[i] = (pw[i-1]*2)%MOD;

    map<pair<long long, long long>, pair<int, int> > x;

    long long zz = 0;
    for (int i=0; i<N; ++i) {
        long long a,b;
        cin >> a >> b;
        if (a==0 && b==0) {
            zz++;
            continue;
        }
        if (make_pair(a,b) < make_pair(0LL,0LL)) {
            a=-a;
            b=-b;
        }
        long long g = gcd(abs(a),abs(b));
        a/=g;
        b/=g;
        if (b>0) {
            x[make_pair(a,b)].first++;
        }
        else {
            x[make_pair(-b,a)].second++;
        }
    }

	long long ans = 1;
	for (auto& p : x){
		ans = ans*(pw[p.second.first]+pw[p.second.second]-1)%MOD;
	}

    cout << (ans+zz+MOD-1)%MOD << endl;

    return 0;
}


Measured memory_bytes: 17248
a=int(input())
b=int(input())
c=int(input())
d=int(input())
ans=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if(d==i*500+j*100+k*50):
        ans+=1
print(ans)

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

using namespace std;

int d[55];

int main()
{
    int n;
    scanf("%d", &n);
    int Ans = 0;
    for (int i = 1 ; i <= n ; ++ i)
     scanf("%d", &d[i]);
    for (int i = 1 ; i <= n ; ++ i)
     for (int j = i + 1 ; j <= n ; ++ j)
      Ans += d[i] * d[j];
    printf("%d\n", Ans);
    return 0;
}

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

constexpr int nax = 1e5;

int q;
string s[2];
int pref[2][nax + 1];

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

    for (int i = 0; i < 2; ++i)
    {
        cin >> s[i];
        for (int j = 1; j <= s[i].size(); ++j)
            pref[i][j] = pref[i][j - 1] + 1 + (s[i][j - 1] == 'B');
    }

    int q; cin >> q;
    while (q--)
    {
        int l, r, l2, r2;
        cin >> l >> r >> l2 >> r2;
        cout << ((pref[0][r] - pref[0][l - 1] - (pref[1][r2] - pref[1][l2 - 1])) % 3? "NO":"YES") << '\n';
    }
}

Measured memory_bytes: 1744