akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

def main():
    X,Y = map(int, input().split())
    for i in range(X+1):
        j = X-i
        if 2*i+4*j==Y:
            ans='Yes'
            break
    else:
        ans='No'
    print(ans)
    
if __name__ == "__main__":
    main()


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int64_t gcd(int64_t a, int64_t b);
int64_t lcm(int64_t a, int64_t b);

int main(){
  int64_t n, m;
  cin >> n >> m;

  int guu=0;

  vector<int64_t> a(n);
  vector<int64_t> b(n);
  rep(i,n) {
    cin >> a.at(i);
    b.at(i) = a.at(i)/2;
    if(b.at(i)%2==0) guu++;
  }
  
  int64_t saidai;
  int64_t saisho = b.at(0);

  int64_t ans = 0;
  if(guu!=0&&guu!=n) cout << 0;
  else{
    for(int i=1; i<n; i++){
      saisho = lcm(saisho, b.at(i));
    }
  

  bool frag=true;
  
  rep(i,n){
    if((saisho/b.at(i))%2==0){frag=false; break;}
  }

  if(guu==0){
    if(frag) cout<<((m/saisho)+1)/2;
    else cout<<(m/saisho)/2;
  }
  if(guu==n){
    bool frag2=true;
    rep(i,n){
      if((saisho/b.at(i))%2==0){frag2=false; break;}
    }
    if(frag&&frag2)cout<<((m/saisho)+1)/2;
    else if(frag2) cout<<(m/saisho)/2;
    else cout << 0;
  }

}
}

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

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


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

using namespace std;

#define DEBUG 0
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define VIN(VECTOR,n)\
REP(CNT,n){\
	lli TMP;\
	cin>>TMP;\
	VECTOR.push_back(TMP);\
}

lli isBitOn(lli bitmap,lli num){
	return ((bitmap>>num)&1);
}

lli pOrM(lli flag){
	if(flag==1)return -1;
	else return 1;
}

lli bitPM(lli bitmap,lli num){
	return pOrM(isBitOn(bitmap,num));
}

lli zettai(lli a){
	if(a<=0)return -a;
	else return a;
}

int main(){

	lli n,m;

	vector<lli> x[3];


	lli *flag;

	cin>>n>>m;
	flag = new lli[n];
	REP(i,n){
		lli tmpX,tmpY,tmpZ;
		cin>>tmpX>>tmpY>>tmpZ;
		x[0].push_back(tmpX);
		x[1].push_back(tmpY);
		x[2].push_back(tmpZ);
	}

	lli ansSum=-1000000000000000000;


	REP(i,8){
		if(DEBUG)cout<<endl;
		vector<lli> ans;
		REP(j,n){
			lli tmp=0;
			REP(k,3){
				if(DEBUG)cout<<x[k][j]*bitPM(i,k)<<" ";
				tmp+=x[k][j]*bitPM(i,k);
			}
			if(DEBUG)cout<<endl;
			ans.push_back(tmp);
		}
		sort(ans.begin(),ans.end());

		lli sum=0;
		REP(j,m){
			sum+=ans[j];
		}
		if(ansSum<=zettai(sum))ansSum = zettai(sum);
	}
	cout<<ansSum<<endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

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

    vector<ll> dp(N+1,INF);
    
    dp[0]=0;

    for(int n=1;n<=N;n++){
        for(int pow6=1;pow6<=n;pow6*=6){
            chmin(dp[n],dp[n-pow6]+1);
        }
        for(int pow9=1;pow9<=n;pow9*=9){
            chmin(dp[n],dp[n-pow9]+1);
        }
    }
    cout<<dp[N]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

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

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

    if(s[0] == 'A') {
        string tmp = s.substr(2, s.size()-3);
        int pos = tmp.find('C');
        if(pos != string::npos) {
            string tmp2 = s;
            transform(tmp2.begin(), tmp2.end(), tmp2.begin(), ::tolower);
            s[0] = 'a';
            s[pos+2] = 'c';
            
            if(s == tmp2) { cout << "AC" << endl; return 0; }
        }
    } 
    cout << "WA" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define slowanddetermined ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long
using namespace std;

const int mod=1000000007;

int a[10003],b[10003];
int dp[10003][1003]; // Health & pos
//int dp[1003][1003];

int solve(int health,int pos){

    if(pos<0)return INT_MAX;
    if(health<=0) return 0;

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

    else{
        return dp[health][pos]=min(b[pos]+solve(health-a[pos],pos),solve(health,pos-1));
    }



}

int32_t main()
{
   

    int n,h;
    cin>>h>>n;

    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<=h;i++){
        for(int j=0;j<=n;j++){
            dp[i][j]=-1;
        }
    }

    int ans=solve(h,n-1);

    cout<<ans<<endl;





    return 0;

}


Measured memory_bytes: 79104
s = input()
N = int(input())
for _ in range(N):
    q = input().split()
    a = int(q[1])
    b = int(q[2])
    if q[0] == "replace":
        s = s[:a] + q[3] + s[b+1:]
    elif q[0] == "reverse":
        s = s[:a] + s[b:a:-1] + s[a] + s[b+1:]
    else:
        print(s[a:b+1])


Measured memory_bytes: 5616
#include <bits/stdc++.h> 
#include <atcoder/all>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
string Yes[2] = {"Yes", "No"};

using Graph = vector<vector<int>>;
Graph G;

/*------------------------------------------------------------------*/
int op(int a, int b){
    return max(a, b);
}
 
int e(){
    return 0;
}

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

    int n, k; cin >> n >> k;
    segtree<int, op, e> seg(300010);
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = 0;
    rep(i, n){
        int left = max(a[i] - k, 0);
        int right = min(a[i] + k, 300000);
        int cur = seg.prod(left, right + 1) + 1;
        ans = max(ans, cur);
        seg.set(a[i], cur);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8540
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
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 REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> &P){
os << P.first;
os << " ";
os << P.second;
os << "\n";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//素因数分解
bool is_prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int a;
    int ans=0;
    REP(i,N){
        cin >> a;
        if(is_prime(a)){
            ans++;
        }
    }



    cout << ans << endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
void rm(vector<deque<char> > &, int, int);

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<deque<char> > origField(w, deque<char>(h)); // [x][-y]
  for(int y = h - 1; y >= 0; --y) for(int x = 0; x < w; ++x) {
    char c;
    cin >> c;
    origField[x][y] = c;
  }
  for(int sx = 0; sx < w - 1; ++sx) for(int sy = 0; sy < h; ++sy) {
    auto field = origField;
    swap(field[sx][sy], field[sx + 1][sy]);
    for(int x = sx; x <= sx + 1; ++x) for(int y = h - 1; y >= 0; --y) if(field[x][y] == '.') rm(field, x, y);
    int removeCnt, lastRemoveCnt;
    removeCnt = lastRemoveCnt = 0;
    do {
      lastRemoveCnt = removeCnt;
      removeCnt = 0;
      vector<vector<int*> > pxfield(w, vector<int*>(h));
      vector<vector<int*> > pyfield(w, vector<int*>(h));
      for(int x = 0; x < w; ++x) for(int y = 0; y < h; ++y) {
        pxfield[x][y] = ((y >= 1 && field[x][y] == field[x][y - 1]) ? pxfield[x][y - 1] : (new int(0)));
        ++(*pxfield[x][y]);
      }
      for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) {
        pyfield[x][y] = ((x >= 1 && field[x][y] == field[x - 1][y]) ? pyfield[x - 1][y] : (new int(0)));
        ++(*pyfield[x][y]);
      }
      for(int x = 0; x < w; ++x) for(int y = h - 1; y >= 0; --y) if(max(*pxfield[x][y], *pyfield[x][y]) >= n) {
        rm(field, x, y);
        ++removeCnt;
      }
      if(removeCnt == w * h) {
        cout << "YES" << endl;
        return 0;
      }
    } while(lastRemoveCnt != removeCnt);
  }
  cout << "NO" << endl;
  return 0;
}
void rm(vector<deque<char> > &field, int x, int y) {
  field[x].erase(field[x].begin() + y);
  field[x].push_back('.');
}

Measured memory_bytes: 57316
def main():
    INF = int(1e9+7)
    N, M, *a = map(int, open(0).read().split())
    a = set(a)
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in a else 0
    for i in range(2, N + 1):
        if i not in a:
            dp[i] = (dp[i - 1] + dp[i - 2]) % INF
    print(dp[-1])
    return


main()


Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N, K;
  cin >> N >> K;
  int count = 0;
  while(N > 0){
    count++;
    N /= K;
  }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)

using namespace std;
int main()
{
    long X;
    cin >> X;
    double y;
    y = pow(X, 1.0 / 5.0);
    int a, b;
    a = (int)y;
    double dif = pow(X - pow(a, 5), 1.0 / 5.0);
    b = -round(dif);
    if (pow(a, 5) - pow(b, 5) == X)
    {
        cout << a << " " << b << endl;
        return 0;
    }
    int i = 0;
    while (true)
    {
        i++;
        a = (int)y + i;
        double dif = pow(pow(a, 5) - X, 1.0 / 5.0);
        b = round(dif);
        if (pow(a, 5) - pow(b, 5) == X)
        {
            break;
        }
        a = (int)y - i;
        dif = pow(X - pow(a, 5), 1.0 / 5.0);
        b = -round(dif);
        if (pow(a, 5) - pow(b, 5) == X)
        {
            break;
        }
        if (i > 10000000)
        {
            return 0;
        }
    }
    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 4100
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)x.size()

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        int k,x;
        cin>>k>>x;
        if(k*500 >=x)puts("Yes");
        else puts("No");




return 0;
}







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

class Main {
    static long gcd(long a, long b) {
        if(b == 0) return a;
        return gcd(b, a % b);
    }

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

        int T = sc.nextInt();
        for(int i = 0; i < T; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            long c = sc.nextLong();
            long d = sc.nextLong();

            if(b > a) {
                System.out.println("No");
                continue;    
            }
            if(b > d) {
                System.out.println("No");
                continue;                   
            }
            if(c >= b) {
                System.out.println("Yes");
                continue;
            }

            long g = gcd(b,d);
            long aa = b - g + a % g;

            if(aa > c) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }


        }
    }
}

Measured memory_bytes: 25544
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
//#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true; 
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
/*
ll ncr(ll n,ll r)
{
	if(n==1 || r==0)
	return 1;
	if(r>n/2)
	r=n-r;
	ll ans=1;
	for(ll i=1;i<=r;i++)
	{
		ans=((ans * n )/i);
		n--;
	}
	return ans;
}
*/
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow(ll a,ll b,ll m)
{
	ll ans=1;
	while(b>0)
	{
		if(b&1)
			ans=(ans*a)%m;
		b=b/2;
		a=(a*a)%m;
	}
	return ans;
}
 
ll modinv(ll k)
{
	return pow(k,MOD-2,MOD);
}

ll ncr(ll n,ll c)
{
    ll t=1;
    c=min(c,n-c);
    for(ll i=1;i<=c;i++)
    {
     	t=(t*(n-i+1))%MOD;
        t=(t*modinv(i))%MOD;
	}
    return t;
}
int main()
{
	fast;
	ll l;
	cin>>l;
	ll k=l/500;
	ll sum=0;
	sum=sum+k*1000;
	ll h=l%500;
	ll g=h/5;
	sum=sum+g*5;
	cout<<sum;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<bitset>
#define int long long
using namespace std;
int n,a,b;
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<<1)+(x<<3)+(ch^48);
		ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
		char a='-',b='1';
		putchar(a);
		putchar(b);
    }
    else
    {
		if(a>=10)
			write(a/10);
		putchar(a%10+'0');
    }
}

signed main()
{
    n=read(),a=read(),b=read();
	if((a-b)%2==0)
	{
		write((b-a)/2);
		return 0;
	}
	int ans1,ans2;
	ans1=(a+b-1)/2;
	ans2=(2*n-a-b+1)/2;
	write(min(ans1,ans2));
    return 0;
}


Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from math import gcd
    input = sys.stdin.readline

    K = int(input())
    ans = 0
    for i in range(1, K+1):
        for j in range(i+1, K+1):
            for k in range(j+1, K+1):
                ans += gcd(gcd(i, j), k) * 6
    for i in range(1, K+1):
        for j in range(i+1, K+1):
            ans += gcd(i, j) * 6
    ans += (K * (K+1)) // 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68260
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
class Union {
public:
  int p[200001],r[200001];
  void init(){rep(i,200001)p[i]=i,r[i]=0;}
  int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
  void unite(int x,int y) {
    x=find(x),y=find(y);
    if(x==y)return;
    if(r[x]<r[y])p[x]=y;
    else{p[y]=x;if(r[x]==r[y])r[x]++;}
  }
  bool same(int x,int y){return find(x)==find(y);}
};
Union u1,u2;
void Main() {
  int n,m,k;
  cin >> n >> m >> k;
  u1.init();u2.init();
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    u1.unite(x-1,y-1);
  }
  rep(i,k) {
    int x,y;
    cin >> x >> y;
    u2.unite(x-1,y-1);
  }
  map<P,int> ma;
  rep(i,n) ma[P(u1.find(i),u2.find(i))]++;
  rep(i,n) {
    if(i) cout << " ";
    cout << ma[P(u1.find(i),u2.find(i))];
  }
  ln;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 15232
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

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

  ll N, Q; std::cin >> N >> Q;
  struct R {
    ll S;
    ll T;
    ll X;
  };
  std::vector<R> list(N);
  for(int i=0; i<N; i++) std::cin >> list[i].S >> list[i].T >> list[i].X;

  std::map<ll, ll> ans;
  std::set<ll> D;
  for(int i=0; i<Q; i++) {
    ll d; std::cin >> d;
    D.insert(d);
    ans[d] = -1;
  }


  std::sort(list.begin(), list.end(), [](R &a, R &b) { return a.X < b.X; } );

  for(int i=0; i<N; i++){
    //std::cout << "Range : [ " << list[i].S-list[i].X << " ~ " << list[i].T-list[i].X << " ) : " << list[i].X << std::endl;
    auto l = D.lower_bound(list[i].S-list[i].X);
    auto r = D.upper_bound(list[i].T-list[i].X-1);
    for(auto itr = l; itr != r; ++itr) {
      //std::cout << *itr << " is stop " << std::endl;
      ans[*itr] = list[i].X;
    }
    D.erase(l,r);
  }

  for(auto itr = ans.begin(); itr != ans.end(); ++itr) std::cout << itr->second << std::endl;

  return 0;
}

Measured memory_bytes: 28416
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(A[K-1])



Measured memory_bytes: 2940
#include <iostream>
#include <string.h>
#include <stdio.h>
#define MAXN 1000005
#define MOD 1000000007
#define mod 1000000007
using namespace std;
typedef long long LL;
typedef long long ll;
LL n,m,p,f[MAXN],g[MAXN],st;
ll h[MAXN];
void init()
{
    f[0]=1;
    for(int i=1;i<=MAXN;i++)
    {
        f[i]=f[i-1]*i;
        f[i]%=MOD;
     //   printf("%lld\n",fact[i]);
    }
}
ll powmod(ll x,ll n)
{
    ll s=1;
    while(n)
    {
        if(n&1)
            s=(s*x)%mod;
        n>>=1;
        x=(x*x)%mod;
    }
    return s;
}
ll C(ll n,ll m)
{
    if(n<m)
        return 0;
    ll a=f[n],b=(f[n-m]*f[m])%mod;
    return (a*powmod(b,mod-2))%mod;
}
int main()
{
    p=MOD;
    init();
    scanf("%lld",&n);
    //先求g[i]
    //
    if(n%2)
    {
        st=n/2+1;
    }
    else
    {
        st=n/2;
    }
    //
    for(int i=st;i<=n-1;i++)
    {
     //   printf("%d\n",i);
        g[i]=((C(i-1,n-i-1)*f[i])%MOD*f[n-i-1])%MOD;
       // printf("%lld\n",g[i]);
    }
    for(int i=st;i<=n-1;i++)
    {
        h[i]=(g[i]-g[i-1]+MOD)%MOD;
        h[i]%=MOD;
    }
    long long ans=0;
    for(int i=st;i<=n-1;i++)
    {
        ans+=(h[i]*i)%MOD;
        ans%=MOD;
    }
    printf("%lld\n",ans);
    return 0;
}



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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}



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

using ll = long long;

int main()
{
    int N, A;
    string B;
    cin >> N;
    A = N % 10;
    if (A == 2 || A == 4 || A == 5 || A == 7 || A == 9)
    {
        B = "hon";
    }
    else if (A == 0 || A == 1 || A == 6 || A == 8)
    {
        B = "pon";
    }
    else
    {
        B = "bon";
    }
    cout << B << endl;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        ans += (a[i]-1);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    int ac, bc, cc;
    ac = 0;
    bc = 0;
    cc = 0;
    char man = a[0];
    while (true)
    {
        if (ac == a.length()+1)
        {
            cout << "A" << endl;
            break;
        }
        if (bc == b.length()+1)
        {
            cout << "B" << endl;
            break;
        }
        if (cc == c.length()+1)
        {
            cout << "C" << endl;
            break;
        }
        switch (man)
        {
        case 'a':
            man = a[ac++];
            break;
        case 'b':
            man = b[bc++];
            break;
        case 'c':
            man = c[cc++];
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int ll
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int n,k;
vi a,f;
bool check(ll mid){
	// multiset<int> m;
	// rep(i,n){
	// 	m.insert(a[i]);
	// }
	int c = 0;
	rep(i,n){
		if(f[i]*a[i] > mid){
			ll temp = mid/f[i];
			c += abs(temp-a[i]);
		}
	}
	// rep(i,n){
	// 	// i?uto it = m.upper_bound(mid/temp);
	// 	if(it == m.begin()){
	// 		if(*it > mid/temp){
	// 			// cout<<i<<"\n";
	// 			c += (*it - mid/temp);
	// 			m.erase(it);
	// 		}
	// 		else{
	// 			m.erase(it);
	// 		}
	// 	}
	// 	else{
	// 		it--;
	// 		m.erase(it);	
	// 	}
	// }
	if(c <= k){
		return true;
	}
	return false;
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	rep(i,n){
		int x;
		cin>>x;
		a.pb(x);
	}
	sort(all(a));
	ll l = 0;
	rep(i,n){
		int x;
		cin>>x;
		f.pb(x);
		// l = max(l,f[i]);
	}
	sort(all(f),greater<int>());
	ll r = 1e12 + 2;
	ll ans = r;
	// cout<<check(1)<<"\n";
	while(l <= r){
		ll mid = (l+r)/2;
		if(check(mid)){
			ans = mid;
			r = mid-1;
		}
		else{
			l = mid+1;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8016
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    string s,t;
    cin >> s;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i]) ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC156C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = RInt;
            var X = RInts;

            int ans = int.MaxValue;
            for (int i = -100; i <= 100; i++)
            {
                int cand = 0;
                for (int j = 0; j < N; j++)
                {
                    cand += (X[j] - i) * (X[j] - i);
                }
                ans = Math.Min(ans, cand);
            }

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	string X, Y;
	cin >> X >> Y;
	if (X < Y)say("<");
	else if (X > Y)say(">");
	else say("=");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;


int main(){
   int a,b;
   cin>>a>>b;
   int ans=max(max(a+b,a-b),a*b);
   cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define drp(i,st,ed) for (int i=st;i>=ed;--i)

const int N=405;
const int M=100005;

std:: bitset <N> a[N];

int x[M],y[M],ans[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

int main(void) {
	int n=read(),m=read();
	rep(i,1,m) x[i]=read(),y[i]=read();
	rep(i,1,n) {
		a[i][i]=1;
		drp(j,m,1) {
			if (a[i][x[j]]&&a[i][y[j]]) {
				ans[i]=1; break;
			}
			if (a[i][x[j]]) a[i][y[j]]=1;
			else if (a[i][y[j]]) a[i][x[j]]=1;
		}
	}
	int prt=0;
	rep(i,1,n) if (!ans[i]) {
		rep(j,i+1,n) if (!ans[j]) {
			if (!(a[i]&a[j]).count()) prt++;
		}
	}
	printf("%d\n", prt);
	return 0;
}

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

using namespace std;

const int N = 2e5 + 7;
const int M = 4e3 + 7;
const int S = 8e3 + 7;
const int mod = 1e9 + 7;
inline int Pow(int x,int k,int re = 1){
	for(; k; k >>= 1,x = 1LL * x * x % mod)
		if(k & 1)re = 1LL * re * x % mod;
	return re;
}
struct Pair{
	int x,y;
}p[N];
int n;
int f[M][M];
inline void add(int& a,int b){
	a += b;if(a >= mod) a -= mod;
}
int fac[S],inv[S];
inline int Com(int n,int m){
	if(n < m)return 0;
	return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main(){
#ifdef WTY
	freopen("in","r",stdin);
#endif
	fac[0] = 1;
	for(int i = 1; i < S; i++)fac[i] = 1LL * fac[i - 1] * i % mod;
	inv[S - 1] = Pow(fac[S - 1],mod - 2);
	for(int i = S - 1; i; i--)inv[i - 1] = 1LL * inv[i] * i % mod;
	cin >> n;
	for(int i = 1; i <= n; i++)
		scanf("%d%d",&p[i].x,&p[i].y),f[2001 - p[i].x][2001 - p[i].y]++;
	for(int i = 1; i < 4003; i++)
		for(int j = 1; j < 4003; j++)if(f[i][j]){
			add(f[i + 1][j],f[i][j]);
			add(f[i][j + 1],f[i][j]);
		}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		add(ans,f[p[i].x + 2001][p[i].y + 2001]);
		add(ans,mod - Com(p[i].x + p[i].y << 1,p[i].x << 1));
	}
	cout << 1LL * ans * (mod + 1 >> 1) % mod  << endl;
	return 0;
}


Measured memory_bytes: 64640
#include<iostream>
using namespace std;
int main(){
    int a1,a2,a3;
    int r,g,b,n;
    int ans=0;
    cin>>r>>g>>b>>n;
    for(int x=0;x<=3000;x++){
        for(int y=0;y<=3000;y++){
            if(x*r + y*g > n){
                
            }else if(x*r + y*g == n){
                ans++;
            }else if( ( n - (x*r + y*g) )%b==0 ){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

void solve()
{
	double v;
	while(cin >> v)
	{
		int N = 2;
		while(true)
		{
			double velocity = 1.4 * sqrt(10.0 * (5 * N - 5));
			if(velocity >= v)
			{
				cout << N << endl;
				break;
			}
			++N;
		}
	}
}

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

Measured memory_bytes: 1224
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

int n;
vector<bool> ok(1000001, true);
vector<int> a;
void f() {
    rep(i, n) {
        int x = a[i];
        if (i != 0 && x == a[i-1]) {
            ok[x] = false;
            continue;
        }
        if (!ok[x]) continue;
        for (long long j = 2*x; j <= 1000000; j += x) {
            if (ok[j]) ok[j] = false;
        }
    }
}

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

    cin >> n;
    a.resize(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    f();
    int ans = 0;
    rep(i, n) {
        if (ok[a[i]]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4260
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin>>n;
  vector<int>v(n);
   int sum=INT_MAX,sum1=0,minsum=INT_MAX;
  for(int i=0;i<n;i++){
      int k;
    cin>>k;
    if(i==0)v[i]=k;
    else v[i]+=k+v[i-1];
    
  }
  for(int i=0;i<n;i++){
    sum=min(sum,min(sum,abs(v[n-1]-2*v[i])));
  }
 
  cout<<sum<<endl;
}

Measured memory_bytes: 256
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n, m;
vector<pll> a;

int main()
{
	int i, j, k, l;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		int x;
		scanf("%d", &x);
		a.emplace_back(x, 0);
	}
	for(i=0;i<m;i++)
	{
		int x;
		scanf("%d", &x);
		a.emplace_back(x, 1);
	}
	sort(all(a));
	ll ans=0;
	int cntx=0, cnty=0;
	for(auto e : a)
	{
		if(e.second == 0)
		{
			ans+=(ll)e.first*(m+1-cnty);
			cntx++;
		}
		else
		{
			ans+=(ll)e.first*(n+1-cntx);
			cnty++;
		}
	}
	cout<<ans<<endl;
	return 0;
}
//*/

Measured memory_bytes: 4464
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long k = sc.NextLong();
        long[] a = sc.LongArray();

        long[] townStep = new long[n + 1];
        for (long i = 0; i < townStep.Length; i++)
        {
            townStep[i] = -1;
        }

        long loopStart = 0;
        long loopSpan = 0;
        long currentTown = 1;
        long currentStep = 0;
        while (true)
        {
            if (townStep[currentTown] == -1)
            {
                townStep[currentTown] = currentStep;
            }
            else
            {
                loopStart = townStep[currentTown];
                loopSpan = currentStep - townStep[currentTown];
                break;
            }
            currentTown = a[currentTown - 1];
            currentStep++;
        }

        if (loopSpan != 0 && k > loopStart)
        {
            k = loopStart + ((k - loopStart) % loopSpan);
        }

        long answer = 0;

        for (long i = 1; i <= n; i++)
        {
            if (townStep[i] == k)
            {
                answer = i;
                break;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 45336
n=int(input())
A=list(map(int,input().split()))
def gcd(a,b):
    if b>a:
        return(gcd(b,a))
    elif b==0:
        return(a)
    else:
        return(gcd(b,a%b))
ans=A[0]
for i in range(n-1):
    ans=gcd(ans,A[i+1])
print(ans)


Measured memory_bytes: 15020
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MOD=998244353;
const int N=2000005;

int jc[N],inv[N];
LL C(int n,int m) {
	return (LL)jc[n]*inv[m]%MOD*inv[n-m]%MOD;
}
LL Pow(LL x,int p) {
	if(p==0) return 1;
	if(!(p&1)) return Pow(x*x%MOD,p/2);
	return x*Pow(x*x%MOD,p/2)%MOD;
}
void Init() {
	jc[0]=inv[0]=1;
	for(LL i=1;i<N;i++)
		jc[i]=i*jc[i-1]%MOD;
	inv[N-1]=Pow(jc[N-1],MOD-2);
	for(LL i=N-2;i>=1;i--)
		inv[i]=(i+1)*inv[i+1]%MOD;
}
int n,m,lim;
int ans;
int main() {
	Init();
	scanf("%d %d",&n,&m);
	int lim=min(n,m);
	for(int i=0;i<=lim;i++)
		ans=(ans+(i&1?-1:1)*C(n,i)*C(m,i)%MOD*jc[i]%MOD*Pow(m+1,n-i)%MOD*Pow(n+1,m-i)%MOD+MOD)%MOD;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 15744
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		int i,h;
		int ans = 0;

		for(i = 0; i < n; i++) {
			h = scan.nextInt();
			if(h >= k)
				ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 46216
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

	int one = 0, flag = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != '1'){
			flag = i;
			break;
		}
		one++;
	}

	if(k<=one) cout << 1 << endl;
	else cout << s[flag] << endl;

	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);

int main() {
	LL h, w;
	int n;
	LL ans[10] = {};
	map<pair<LL, LL>, int>val;

	cin >> h >> w >> n;
	ans[0] = (h - 2)*(w - 2);

	for (int i = 0; i < n; i++) {
		LL x, y;
		cin >> y >> x;
		y--, x--;
		for (int dx = -1; dx <= 1; dx++) {
			for (int dy = -1; dy <= 1; dy++) {
				LL nx = x + dx, ny = y + dy;
				if (0 < nx&&nx < w-1 && 0 < ny&&ny < h-1) {
					if (val.find(pair<LL, LL>(nx, ny)) == val.end()) {
						val[pair<LL, LL>(nx, ny)] = 1;
						ans[0]--;
						ans[1]++;
					}
					else {
						int num = val[pair<LL, LL>(nx, ny)] + 1;
						val[pair<LL, LL>(nx, ny)]++;
						ans[num - 1]--;
						ans[num]++;
					}
				}
			}
		}
	}
	for (int i = 0; i < 10; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 56448
import sys
def input():
    return sys.stdin.readline().rstrip('\n')
    

def calc(N):
    abc = 'abcdefghijklmnopqrstuvwxyz'
    s = ''
    while N > 0:
        i = (N - 1) % 26
        N = (N - 1) // 26
        s = abc[i] + s
    return s

N = int(input())
print(calc(N))

Measured memory_bytes: 61720
#include <iostream>
 
  
 
using namespace std;
 
  
 
int main()
{
   int x; 
   int y;
   int a;
   int b;
   cin >> x >> y;
   a= x * y;
   b= 2*x+2*y;
    
   cout << a << " " << b << endl; 
    
   return 0;
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend();
#define sz  size()
#define forr(i,a,b) for(int i=a ;i <= b ; i++ )
#define inp ios_base::sync_with_stdio(false);cin.tie(NULL);
#define PQ_INC vector<int>, greater<int> ;
using namespace std ;

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

const int N = 2e5+9 ,  mod = 1e7+9  , OO = 0x3f3f3f3f ;
int dX[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dY[] = {0, 0, 1, -1, 1, -1, 1, -1};
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int n , m , c , x[200] , y[200] , ans ;
int main(){
  cin >> n >> m >> c ;
  for (int i = 0 ; i < m ; i++ )cin >> y[i] ;

  while(n--) {
    int sum = c ;
    for (int i = 0 ; i < m ; i++ ){
      cin >> x[i] ;
      x[i] *= y[i] ;
      sum += x[i] ;
    }
    if (sum > 0 ) ans++ ;
  }
  cout << ans ; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  int N,K;cin>>N>>K;
  vector< pair<LL,vector<LL>> >T(N+1,{0,{}});
  for(int i=0;i<N;i++){
    int t;LL d;cin>>t>>d;
    if(T[t].first==0){
      T[t].first=d;
    }else{
      T[t].second.push_back(d);
      if(T[t].first<d)
        swap(T[t].first,T[t].second.back());
    }
  }
  sort(T.begin(),T.end(),greater<>());
  LL ans=0;
  LL now=0,nowsum=0;
  priority_queue<LL, vector<LL>, greater<LL>>que;
  for(int i=0;i<K && T[i].first>0;i++){
    now+=T[i].first+LL((i+1)*(i+1)-i*i);
    for(LL t:T[i].second){
      nowsum+=t;
      que.push(t);
    }
    while(i+1+que.size()>K){
      nowsum-=que.top();que.pop();
    }
    if(i+1+que.size()==K){
      ans=max(ans,now+nowsum);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4864