akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n,m;cin>>n>>m;
    vector<pair<int,int>> p(m);
    map<int,int> mp1;
    vector<vector<int>> x(n+10);
    int tmp=1;
    rep(i,m){
        int a,b;cin>>a>>b;
        p[i]={a,b};
        if(mp1[a]==0){
            mp1[a]=tmp;
            x[tmp].push_back(b);
            tmp++;
        }else{
            int y=mp1[a];
            x[y].push_back(b);
        }
    }
    rep(i,tmp){
        auto& c=x[i];
        sort(c.begin(),c.end());
    }
    rep(i,m){
        int a=p[i].first,b=p[i].second;
        string P=to_string(a), Y;
        while(P.size()<6) P="0"+P;
        auto t=mp1[a];
        auto itr= lower_bound(x[t].begin(),x[t].end(),b);
        Y=to_string((int)(itr-x[t].begin())+1);
        while(Y.size()<6) Y="0"+Y;
        cout<<P<<Y<<endl;
    }
}

Measured memory_bytes: 12416
#include<stdio.h>
int main(void)
{
	int data[3],i,j,temp;
	scanf("%d %d %d",&data[0],&data[1],&data[2]);
	for(i=0;i<2;i++) {
		for(j=1;j<3;j++) {
			if(data[i]>data[j]) {
				temp=data[i];
				data[i]=data[j];
				data[j]=temp;
			}
		}
	}
	printf("%d %d %d\n",data[0],data[1],data[2]);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
int main(){
    int n,m,k,a,ans=0; cin >> n >> m;
    int A[31]={0};
    rep(i,n){
        cin >> k; 
        rep(j,k){
            cin >> a;
            A[a]++;
        }
    }
    rep(i,31) if (A[i]==n) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
S = []
C = []
for i in range(M):
    s,c = map(int, input().split())
    S.append(s)
    C.append(c)
for n in range(1000):
    m=n
    if len(str(n))==N:
        count = 0        
        if n==0:
            l=[0]
        else:
            l = []
            while m > 0:
                l.append(m%10)
                m //= 10
            l.reverse()
                
        for i in range(M):     
            if(l[S[i]-1] == C[i]):
                count += 1
            
        if count == M:
            break
else:
    n=-1
    
print(n)                


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct edge{
    int to, cost;
    edge(int to, int cost):to(to), cost(cost){}
};


int n;
vector<edge> G[100010];
int d[100010];
int e[100010];
bool f;


void dijkstra(int s){
    fill(d, d + 100010, INF);//V, INF
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P> > q;
    q.push(P(d[s], s));
    while(!q.empty()){
        P p = q.top(); q.pop();
        int from = p.second;
        int cost = p.first;
        if(d[from] < cost) continue;
        rep(i, 0, G[from].size()){
            edge e = G[from][i];
            int next = e.to;
            int newCost = e.cost + cost;
            if(d[next] > newCost){
                d[next] = newCost;
                q.push(P(newCost, next));
            }
        }
    }
}

void dfs(int now, int pre){
    if(pre != -1){
        if(abs(d[now] - d[pre]) != 1) f = false;
    }
    // cout << now << " " << pre << endl;
    rep(i, 0, G[now].size()){
        int next = G[now][i].to;
        if(next == pre) continue;
        if(next == n) continue;
        if(abs(d[next] - d[now]) != 1) f = false;
        dfs(next, now);
    }

}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 0, n - 1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a]. push_back((edge){b, 1});
        G[b]. push_back((edge){a, 1});
    }
    int k;
    cin >> k;
    rep(i, 0, n) e[i] = INF;
    int v, p;    
    rep(i, 0, k){
        cin >> v >> p;
        v--;
        e[v] = p;
        G[n]. push_back((edge){v, p});
        G[v]. push_back((edge){n, p});
    }
    dijkstra(n);
    f = true;
    rep(i, 0, n){
        if(d[i] == INF) f = false;
        if(e[i] != INF && d[i] != e[i]) f = false;
    }
    dfs(0, -1);
    cout << (f ? "Yes" : "No") << endl;
    if(f){
        rep(i, 0, n){
            cout << d[i] << endl;
        }
    }
}

Measured memory_bytes: 16624
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  string s;
  cin >> s;
  int n = s.size();
  rrep(i, n) {
    if ((n-i)%2) continue;
    bool ok = true;
    rep(j, (n-i)/2) if (s[j] != s[j+(n-i)/2]) ok = false;
    if (ok) {
      cout << n-i << endl;
      return 0;
    }
  }
}

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

long long po(long long p, long long n){
    long long res = 1;
    for(int i = 0; i < n; i++){
        res *= p;
    }

    return res;
}

int main(){    

    long long n; cin >> n;
    vector<long long> a(n);

    for(int ii = 0; ii < n; ii++){
        int p; cin >> p;
        string m; cin >> m;
        
        long long num = 0;
        int len = (int)m.size();
        for(int i = 0; i < len; i++){
            int idx = len - 1 - i;
            char c = m[idx];
            long long aa;
            if('A' <= c && c <= 'Z') aa = (long long)(10 + c - 'A');
            else if('a' <= c && c <= 'Z') aa = (long long)(36 + c - 'Z');
            else aa = (long long)(c - '0');
        
            a[ii] += aa * po(p, i);
        }
    }

    /*for(int i = 0; i < n; i++){
        cout << a[i] << endl;
    }*/

    int num = 0;
    for(int i = 0; i < n; i++){
        bool is_pre = false;
        while(a[i] != 0){
            if(a[i] % 2 == 1){
                num++;
                if(is_pre == true){
                    cout << "win" << endl;
                    return 0;
                }
                a[i] /= 2;
                is_pre = true;
            }else{
                is_pre = false;
                a[i] /= 2;
            }
        }
    }

    if(num % 2 == 1) cout << "win" << endl;
    else cout << "lose" << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int keta(long long int n){
	int i=0;
	while(1){
		if(n>0){
			i++;
		}
		n/=10;
		if(n==0){
			break;
		}
	}
	return i;
}

int max(int a,int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}

int main(){

	long long int n;
	scanf("%lld",&n);

	long long int a,b,i;
	
	for(i=1;i<=100000;i++){
		if(i*i>n){
			break;
		}
		
		if(n%i==0){
			a=i;
			b=n/i;
		}
	}
	
	printf("%d\n",max(keta(a),keta(b)));

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
#define P pair<int, int>
using namespace std;

const int M = 1000005;

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

  int zy = x / 100;
  int per = x % 100;
  int cnt = zy;
  for(int i = 5; i >= 0; i--){
    if(per == 0){
      break;
    }
    if(per % i == 0){
      cnt = per / i;
      per %= i;
    }
  }

  if(cnt != 0 && zy >= cnt){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }

}



Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
  int a[5],b[5],i = 0,mod = 10,ans = 0,buf = 0;
  for(i = 0;i < 5;i++) {
    scanf("%d",&a[i]);
    b[i] = a[i] % 10;
    if(b[i] > 0 && b[i] < mod) mod = b[i];
  }

  i = 0;
  for(i = 0;i < 5;i++) {
    buf = a[i] % 10;
    if(buf == 0) ans += ((a[i] / 10) + 0) * 10 ;
    else if(buf > 0) ans += ((a[i] / 10) + 1) * 10 ;
    //printf("%d\n",ans);
  }
  ans = ans - 10 + mod;

  printf("%d\n",ans);
  return 0;
}


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

signed main() {
    int n;
    cin >> n;
    long long int sum = 0;
    for( int i = 1 ; i <= n ; i++ ) {
        for( int j = 1 ; j <= n ; j++ ) {
            for( int k = 1 ; k <= n ; k++ )
                sum += __gcd(__gcd(i,j),k);
        }
    }
    cout << sum << "\n";
}


Measured memory_bytes: 3588
import math

N=int(input())
S=""
while N!=0:
    if N%2==0:
        S+="0"
        N=math.floor(N/2)
    else:
        S+="1"
        N=math.floor(N/2)#切り上げ
    
    N=N*-1#
   

if S=="":
    print(0)
else:
    print(S[::-1])



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

int H,W;
char fld[55][55];

signed main(){
    cin>>H>>W;
    rep(i,H)cin>>fld[i];

    rep(i,H)rep(j,W){
        if(fld[i][j]!='#')continue;
        bool flag=false;
        rep(d,4){
            int ny=i+dy[d];
            int nx=j+dx[d];
            if(ny>=0&&ny<H&&nx>=0&&nx<W&&fld[ny][nx]=='#')flag=true;
        }
        if(!flag){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

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

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 main(void){
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  bool flag = false;
  int ans;
  REP(i, N+1){
    double val = i * 1.08;
    int prive = int(val);
    if (prive == N){
      flag = true;
      ans = i;
    }
  }


 if (flag){
   cout <<  ans << endl;}
  else cout << ":(" << endl; 

  return 0;
}



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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  rep(i, N){
    int a;
    cin >> a;
    while(1 < a && 0 == a % 2){
      a /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static final int MD = 1000000007;
	void main() {
		int n = sc.nextInt();
		int[] aa = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = sc.nextInt();
		aa = Arrays.stream(aa).boxed().sorted().mapToInt($->$).toArray();
		long ans = 0;
		for (int i = 0; i < n; i++)
			ans = (ans + (long) (i + 2) * aa[n - 1 - i]) % MD;
		while (--n > 0)
			ans = ans * 4 % MD;
		println(ans);
	}
}


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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int mod=1000000007;
template<class T,class U>
void add(T& a,U b){
	a=((ll)a+b)%mod;
}

template<>
void add(int& a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

template<class T,class U>
void sub(T& a,U b){
	a=((ll)a-b%mod+mod)%mod;
}

template<>
void sub(int& a,int b){
	a-=b;
	if(a<0)a+=mod;
}

template<class T,class U>
void mult(T& a,U b){
	a=((ll)a*b)%mod;
}

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			mult(s,a);
		mult(a,a);
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

int main(){
	vector<ll> fact({1});
	FOR(i,1,114514)
		fact.PB(fact.back()*i%mod);
	auto comb=[&](int a,int b){
		if(b==0)
			return 1LL;
		else if(b<0||a-b<0)
			return 0LL;
		else
			return fact[a]*modInv(fact[b])%mod*modInv(fact[a-b])%mod;
	};
	int ans=0;
	int n=read(),a=read(),b=read(),c=read();
	if(b%2!=0){
		cout<<0<<endl;
		return 0;
	}
	REP(p,min(a,c)+1){
		for(int k=0;k*3<=c-p;k++){
			int w=comb(b/2-1+(c-p-3*k),(c-p-3*k));
			mult(w,fact[p+k+b/2+a-p]);
			mult(w,modInv(fact[p]));
			mult(w,modInv(fact[k]));
			mult(w,modInv(fact[b/2]));
			mult(w,modInv(fact[a-p]));
			add(ans,w);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1400
import java.util.Scanner
import scala.math._

object Main extends App {

  val sc = new Scanner(System.in)

  val N = sc.nextInt()

  val ans = for (i <- 1 to N) yield help(i)

  println(ans.indexOf(ans.max)+1)

  def help(n: Int): Int = if (n % 2 == 0) 1 + help(n / 2) else 0

}




Measured memory_bytes: 27452
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
  string s;
  bool cFlag = false;
  bool yesFlag = false;
  cin >> s;

  REP(i,s.length()){
    if(s[i] == 'C')
      cFlag = true;
    if(s[i] == 'F' && cFlag)
      yesFlag = true;
  }

  if(yesFlag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int x=0;
  for(int i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%3!=0&&a[i]%5!=0){
        x++;
      }
    }
  }
  if(x==0){
    cout<<"APPROVED"<<endl;
  }
  else{
    cout<<"DENIED"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
vector<vector<int> > A;
typedef pair<short,short> P;

bool bfs(){
  sort(A.begin(),A.end());
  A.erase(unique(A.begin(),A.end()),A.end());
  int n = A.size();
  for(int i=0;i<n;i++)
    for(int j=0,used[10]={};j<A[i].size();j++)if(used[A[i][j]]++) return 1;
  
  queue<P> Q;
  vector<vector<int> >D(1<<10,vector<int>(1<<10,INF));
  D[0][0] = 0;
  Q.push(P(0,0));

  while(!Q.empty()){
    P t = Q.front();Q.pop();
    short I = t.first,J = t.second;
    if(I&&J&&__builtin_popcount(I&J) == D[I][J]) return 1;
    if(D[I][J]==10) continue;    

    for(int i=0;i<n;i++){
      for(int l=0,ni=I;l<(int)A[i].size();l++){
	short num = A[i][l],nj =(J|1<<num);
	if(l&&D[ni][nj]==INF)D[ni][nj] = D[I][J]+1,Q.push(P(ni,nj));
	if(I&(1<<num))break;
	ni |= (1<<num);
	if(D[ni][J]==INF)D[ni][J] = D[I][J] + 1,Q.push(P(ni,J));
      }
    }
  }
  return 0;
}

int main(){
  int n;
  while(cin>>n,n){
    string str;
    cin>>str;
    A.clear();
    for(int i=0;i<str.size();i++){
      A.push_back(vector<int>());
      while(str[i]!='u') A.back().push_back(str[i++]-'0');
    }
    cout<<(bfs()? "UN":"")<<"SAFE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 7488
/*
#####################################################
# I will win.. maybe not immediately but definitely #
#####################################################
*/

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

//Optimizations
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//save time
#define endl '\n'
#define db(x) cout << "> " << #x << ": " << x << endl;
typedef long long ll;

//for sorting
#define all(a) a.begin(),a.end()

//Constants
#define PI   3.141592653593
#define MOD  1000000007LL
#define EPS  0.000000001
#define INF  0X3f3f3f3f

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

//vectors
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int>>
#define vlll vector<pair<ll,ll>>
#define pb 	push_back

//pairs
#define pi pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define F first
#define S second

//fast I/O
#ifndef _WIN32
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
#define gc getchar
#define pc putchar

//If using cin and cout
#define IOS ios::sync_with_stdio(false)
#define TIE cin.tie(NULL);cout.tie(NULL)

//queue
#define di deque<int>
#define dll deque<ll>
#define qi queue<int>
#define PQ priority_queue

//general
#define E empty()

//Declare all variables and methods needed between this comment and the next one(OCD lol)

//Main function
int main(){
    IOS;
    TIE;

    int n,x;
    cin>>n>>x;

    int arr[n];
    REP(i,n)
        cin>>arr[i];
    sort(arr,arr+n);

    int cnt=0,idx=-1;
    REP(i,n)
        if(x>=arr[i]){
            ++cnt;
            idx=i;
            x-=arr[i];
        }
        else
            break;

    if(x && idx==n-1)
        --cnt;
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let x = scan "%d" id

let () =
  let l = ListL.map (0++1000) ~f:(fun x -> (x, x*x*x*x*x)) in
  let a,b = ref 0, ref 0 in
  ListL.iter l ~f:(fun (i, y) ->
      ListL.iter l ~f:(fun (j, z) ->
          if -y + z = x then
            (a := -i; b := -j)
          else if -y - z = x then
            (a := -i; b := j)
          else if y - z = x then
            (a := i; b := j)
          else if y + z = x then
            (a := i; b := -j)));
  Printf.printf "%d %d\n" !a !b


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

bool is_even(vector<int> A){
  for (int a : A){
    if (a % 2 != 0)	return false;
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
  	cin >> A.at(i);
  }
  
  int ope_count = 0;
  while(is_even(A)){
    for (int i = 0; i < N; i++){
      A.at(i) /= 2;
    }
    ope_count++;
  }
  cout << ope_count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    int x; cin >> x;
    int ans;
    if(x < 600) ans = 8;
    else if(x < 800) ans = 7;
    else if(x < 1000) ans = 6;
    else if(x < 1200) ans = 5;
    else if(x < 1400) ans = 4;
    else if(x < 1600) ans = 3;
    else if(x < 1800) ans = 2;
    else ans = 1;
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < 3; ++i)
    {
        if (s[i] == s[i + 1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

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

int main()
{

int k ;
cin>>k;
string s;
cin>>s;

if(s.size()<=k)
    cout<<s<<endl;
else
    cout<<s.substr(0,k)<<"..."<<endl;
    return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;

  map<int,int> s;
  multiset<int> vals;

  rep(i,w) s[i] = i;
  rep(i,w) vals.insert(0);

  rep(i,h) {
    int l, r;
    cin >> l >> r;
    --l;
    auto it = s.lower_bound(l);
    int mr = -1;
    while (it != s.end() && it->first <= r) {
      mr = max(mr, it->second);
      int x = it->first - it->second;
      vals.erase(vals.find(x));
      s.erase(it++);
    }
    if (mr != -1 && r < w) {
      vals.insert(r-mr);
      s[r] = mr;
    }
    int ans = -1;
    if (vals.size() > 0) {
      ans = *vals.begin() + (i+1);
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 22456
fun main(args: Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { num ->num.toInt() };    
    val h = Array(n, {readLine()!!.toInt() })
  
    h.sort();
    var ret = h[h.size-1] - h[0];
  
    for (i in 0..n-k){
  	  val r = h[i + k - 1] - h[i];
      if(r < ret){
        ret = r;
      }
    }
  
    println(ret);
}

Measured memory_bytes: 43952
def main() -> None:
    n, c, k = map(int, input().split())
    t = [int(input()) for _ in range(n)]
    ans = wait_start = wait_people = 0

    for ti in sorted(t):
        if ti - wait_start > k or wait_people == c:
            wait_people = 0
        wait_people += 1

        if wait_people == 1:
            wait_start = ti
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8280
from math import factorial
def comb(n,k):
    if n>=k:
        return int(factorial(n)/(factorial(k)*factorial(n-k)))
    else:
        return 0

def calc(a,k):
        t = len(a)
        t1 = len(a) - 1
        if k<1 or t == 0:
            return 0
        else:
            if a[t1]>0:
                ans = (9**k)*comb(t1,k) + (9**(k-1))*(a[t1]-1)*comb(t1,k-1)
                ans+=calc(a[:(t-1)],k-1)
            else:
                ans = 0
                ans+=calc(a[:(t-1)],k)
            if a[-k]>=1 and k == 1:
               ans+=1
            return ans

n = int(input())
k = int(input())
number = []
while n:
    number.append(n%10)
    n//=10

t = len(number)
t1 = len(number) - 1

if t>=k:
    ans = 0
    ans += calc(number,k)
else:
    ans = 0
print(ans)

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

int main()
{
      long long int a,b;
      scanf("%lld %lld",&a,&b);
      if((a*b)%2==0)
        printf("Even\n");
      if((a*b)%2!=0)
        printf("Odd\n");
      return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if (a * b) % 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include<stdio.h>

int main(void){
  int n;
  int m;
  
  scanf("%d",&n);
  
  m = n%10;
  
  if(m == 3){
    printf("bon");
  }
  else if(m == 0 || m == 1 || m == 6 || m == 8){
    printf("pon");
  }
  else{
    printf("hon");
  }
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    ll H,W;
    cin>>H>>W;
    ll ans;
    if(H*W%3==0) ans=0;
    else{
        ans=min(H,W);
        ll a,b,c,w;
        a=W/3*H;
        w=W-W/3;
        b=H/2*w,c=(H-H/2)*w;
        ans=min(ans,max({a,b,c})-min({a,b,c}));
        
        a=(W/3+1)*H;
        w=W-W/3-1;
        b=H/2*w,c=(H-H/2)*w;
        ans=min(ans,max({a,b,c})-min({a,b,c}));

        ll temp=H,
        H=W,W=temp;

        a=W/3*H;
        w=W-W/3;
        b=H/2*w,c=(H-H/2)*w;
        ans=min(ans,max({a,b,c})-min({a,b,c}));

        a=(W/3+1)*H;
        w=W-W/3-1;
        b=H/2*w,c=(H-H/2)*w;
        ans=min(ans,max({a,b,c})-min({a,b,c}));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define INF 1000000000
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define w(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
using namespace std;
int main(){
	fast();
	ll x,k,d;
	cin>>x>>k>>d;
	x = abs(x);
	if(x>0 && (x/d)>=k){
		x-=(k*d);
		cout<<x<<endl;
		return 0;
	}
	ll y = x/d;
	x-=(y*d);
	k-=y;
	if(k%2==0){
		cout<<abs(x)<<endl;
	}
	else{
		cout<<min(abs(x-d),abs(x+d))<<endl;
	}
	return 0;
}

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

vector<int> z_algorithm(const vector<int>& S){
    int N = S.size(), c = 0;
    vector<int> ret(N, 0);
    for(int i=1; i<N; i++){
        if(i + ret[i-c] < c + ret[c]){
            ret[i] = ret[i-c];
        }else{
            int j = max(0, c + ret[c] - i);
            while(i+j < N && S[j] == S[i+j]) j++;
            ret[i] = j;
            c = i;
        }
    }
    ret[0] = N;
    return ret;
}

vector<int> z_algorithm(const string& S){
    int N = S.size();
    vector<int> s(N);
    for(int i=0; i<N; i++) s[i] = S[i];
    return z_algorithm(s);
}

vector<int> z_algorithm(string& A, string& B){
    string S = A + '!' + B;
    auto z = z_algorithm(S);
    vector<int> ret(B.size());
    for(int i=0; i<B.size(); i++){
        ret[i] = z[i+A.size()+1];
    }
    return ret;
}

int main(){
    string S, T;
    cin >> S >> T;
    string S2 = S;
    while(S2.size() < T.size()) S2.append(S);
    S = S2;
    int N = S.size(), M = T.size();
    S.append(S);
    auto z = z_algorithm(T, S);
    int ans = 0;
    const int MX = 1e6;
    bitset<MX> visited;
    for(int start=0; start<N; start++){
        if(z[start] < M || visited[start]) continue;
        visited[start] = true;
        int num = 1;
        int pos = start;
        while(true){
            pos = (pos + M) % N;
            if(pos == start){
                cout << -1 << endl;
                return 0;
            }else if(!visited[pos] && z[pos] == M){
                num++;
                visited[pos] = true;
            }else{
                break;
            }
        }
        pos = start;
        while(true){
            pos = (pos - M + N) % N;
            if(pos == start){
                cout << -1 << endl;
                return 0;
            }else if(!visited[pos] && z[pos] == M){
                num++;
                visited[pos] = true;
            }else{
                break;
            }
        }
        ans = max(ans, num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 26140
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int t[n+1],x[n+1],y[n+1];
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for(int i = 1;i < n+1;i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i = 1;i < n+1;i++){
        int kyori = x[i] + y[i] - x[i-1] -y[i-1];
        int zikan = t[i] -t[i-1];
        if(kyori > zikan ||(zikan - kyori) % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#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 ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<ll,ll>;
using vi=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void yes(bool c) { if (c)print("Yes"); else print("No"); };

void solve() {
    int H,W; cin >> H >> W;
    vstr strs(H);
    rep(i,H) cin >> strs[i];
    string s = "";
    rep(i,W+2) s = s + '#';
    print(s);
    rep(i,H){
        print("#" + strs[i] + "#");
    }
    print(s);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	string ans,judge;
	for(int i=0;i<s.size();++i){
		ans+='z'+1;
	}
	judge=ans;
	for(int i=0;i+t.size()<=s.size();++i){
		bool yes=true; string temp=s;
		for(int j=0,k=i;j<t.size();++j,++k){
			if(t.at(j)!=s.at(k)&&s.at(k)!='?'){
				yes=false;
			}
			temp.at(k)=t.at(j);
		}
		if(yes){
			replace(temp.begin(),temp.end(),'?','a');
			ans=min(ans,temp);
		}
	}
	cout<<(ans!=judge?ans:"UNRESTORABLE"s)<<"\n"s;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;


void solve(std::vector<long long> A){
    if(A[0]+A[1]+A[2]>21)
        cout<<"bust"<<endl;
    else
        cout << "win"<<endl;
}

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


Measured memory_bytes: 256
#import <iostream>
#import <string>
#import <set>
using namespace std;

int main() {
  string S;
  set<char> o;
  cin >> S;

  for (auto s : S) {
      o.insert(s);
  }

  if (((o.find('N') != o.end() && o.find('S') != o.end()) || (o.find('N') == o.end() && o.find('S') == o.end())) and
    ((o.find('E') != o.end() && o.find('W') != o.end()) || (o.find('E') == o.end() && o.find('W') == o.end()))) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  return 0;
}


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

// #define multitest 1
#ifdef WIN32
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

vector<ll> find_fact(ll n)
{
	vector<ll> ret;
	for (ll i = 1; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			if (n == i * i)
			{
				ret.pb(i);
			}
			else
			{
				ret.pb(i);
				ret.pb(n / i);
			}
		}
	}
	sort(ret.begin(), ret.end());
	return ret;
}

bool is_prime(ll n)
{
	if (n <= 3)
		return true;
	if (n % 2 == 0)
		return false;
	for (ll i = 3; i * i <= n; i += 2)
		if (n % i == 0)
			return false;
	return true;
}

void solve()
{
	ll a, b;
	cin >> a >> b;
	a = __gcd(a, b);
	auto fact = find_fact(a);
	pc(fact);
	int n = fact.size(), res = 0;
	// for (int i = 0; i < (1 << n); ++i)
	// {
	// 	vector<ll> nums;
	// 	for (int j = 0; j < 30; ++j)
	// 		if (i & (1 << j));
	// }
	// db(n);
	for (int i = 0; i < n; ++i)
	{
		if (is_prime(fact[i]))
			res++;
	}
	std::cout << res << '\n';
}

int main()
{
#ifndef WIN32
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
	flush(cout);
#endif
	return 0;
}

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

int main() {
  int n;
  string ans;

  cin >> n;

  for(int i=0;i<3;i++) {
    if(n%10==3) {ans="bon";}
    else if(n%10==0||n%10==1||n%10==6||n%10==8) {ans="pon";}
    else {ans="hon";}
  }

  cout <<ans << endl;

  return 0;
}


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

int main(){
	int N;
	cin >> N;
	int cnt = 0;
	for(int i = 1; i <= N; i++){
		string S = to_string(i);
		if(S.size() % 2 == 1) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int k;cin>>k;
    int a,b;cin>>a>>b;


    REP(i,1000){
        if(k*i >= a && k*i <= b){
            cout<<"OK"<<endl;
            return;
        }
    }

    cout<<"NG"<<endl;

	return;
}

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

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    ll S(0);
    rep(i,N){
        cin >> A[i];
        S += A[i];
    }
    vector<ll> d;//答えの候補
    for(int i=1;i*i<=S;i++){
        if(S%i==0){
            d.push_back(i);
            d.push_back(S/i);
        }
    }
    int M = d.size();//答えの候補の数
    vector<ll> a(N);//Aの各要素をdで割った余りの集合
    ll a_sum,sum_left,sum_right,target_d,d_max(0);
    for(int i=0;i<M;i++){
        target_d = d[i];//target_dが達成可能かどうかを調べる
        a_sum = 0;//Aの各要素をtarget_dで割った余りの集合の総和
        for(int j=0;j<N;j++){
            a[j] = A[j] % target_d;
            a_sum += a[j];
        }
        sort(ALL(a));
        //余りの集合を昇り順にソートする
        sum_left = a_sum;
        sum_right = 0;
        ll swap_num = 1e18;
        for(int j=N-1;j>=0;j--){
            sum_left -= a[j];//配れる回数
            sum_right += target_d - a[j];//必要な回数
            if(abs(sum_left - sum_right) % target_d == 0) swap_num = min(swap_num,max(sum_left,sum_right));
        }
        if(swap_num <= K )d_max = max(d_max,target_d);
    }
    cout << d_max << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    char S[5];
    int i,j=0;
    scanf("%s",S);
    if(S[1]!=S[0])j++;
    if(S[2]!=S[0]&&S[2]!=S[1])j++;
    if(S[3]!=S[0]&&S[3]!=S[1]&&S[3]!=S[2])j++;

//printf("%d",j);

    if(j==1)printf("Yes");
    else printf("No");
    return 0;
}

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

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, x, n) for (int i = x; i < (int)(n); ++i)
#define ALL(n) begin(n), end(n)
#define ll long long
#define INF 1e9
int main() {
    ll n;
    cin >> n;
    string ans;
    vector<char> a(15);
    int count = 0;
    ll rem, quo;
    while (true) {
        if ((n - 1) / 26 == 0) {
            a.at(count) = n + '`';
            count++;
            break;
        } else {
            rem = n % 26;
            quo = n / 26;
            if (rem == 0) {
                quo--;
                rem = 26;
            }
            a.at(count) = (rem) + '`';
            count++;
            n = quo;
        }
    }
    REP(i, count) ans += a.at(i);
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int K,N; cin >> N >> K;

  if(K==1) cout << 0 << endl;
  else cout << N-K << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

ios_base::sync_with_stdio(false), cin.tie(NULL);
int n,x,t;
cin>>n>>x>>t;
int result=0;

if(n<=x)
cout<<t<<endl;
else
{
result=(t*(n/x));
if(n%x)
result+=t;
cout<<result<<endl;
}


return 0;
}


Measured memory_bytes: 3644
N=int(input())
C=[]
S=[]
F=[]
from math import ceil
for _ in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)
ans=[]
for i in range(0,N-1):
    t=S[i]+C[i]
    sta=i+1
    while sta<N-1:
        if t<=S[sta]:
            t=S[sta]+C[sta]
        else:
            k=ceil((t-S[sta])/F[sta])
            t=S[sta]+k*F[sta]+C[sta]
        sta+=1
    ans.append(t)
for a in ans:
    print(a)
print(0)


Measured memory_bytes: 41820
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    string s;
    int a,b;
    while(cin>>s>>a>>b){
        cout<<s<<" "<<a+b<<" "<<a*200+b*300<<endl;
    }
    return 0;
}

Measured memory_bytes: 1196