akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int   ull;
typedef long long int            ll;
int main()
{
    int n,a[300000],b[300000]={0},i;
    cin>>n;
    for(i=1;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<n;i++)
    {
        b[a[i]]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<b[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5584
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

#define MAX_N 200005

int N;
vv<Pii> v;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> N;
  v.resize(MAX_N);
  rep(i, 0, N) {
    int a, b;
    cin >> b >> a;
    v.pb(mp(a, b));
  }
  sort(ALL(v));

  int time = 0;
  for (auto va : v) {
    time += va.S;
    if (time > va.F) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}




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

using namespace std;
 
int main(){
  
  int h,w;
  
  cin >> h >> w;

  vector<vector<int>> a;
  
  for(int i=0; i<h; ++i){
    vector<int> tmp;
	
    for(int j=0; j<w; ++j){
      int itmp;
	  
      cin >> itmp;
      tmp.push_back(itmp);
	  
    }
    a.push_back(tmp);
  }
  
  int ans = 10000000;
  
  for(int ir=0; ir<h; ++ir){
    for(int jr=0; jr<w; ++jr){
	  
      int tmp = 0;
	  
      for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
		  
          if(abs(ir-i) <= abs(jr-j))
            tmp += abs(ir-i) * a[i][j];
          else
            tmp += abs(jr-j) * a[i][j];
        }
      }
      if(tmp < ans)
		ans = tmp;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3160
#include <stdio.h>

typedef struct{
	char name[10];
	int t;
} process;
int n,q;
int i=0,j=0;
int timer=0;
int head=-1;
int tail=0;
int flag=0;
process x[100000];
void enqueue(process k){
if(tail==n){
tail=0;	
}
x[tail]=k;
tail++;
}

process dequeue(){

 head++;
 if(head==n){
 	head=0;
 }

return x[head];
}

int main(void){
	scanf("%d%d",&n, &q);
  for(i=0;i<n;i++){
  	scanf("%s%d",x[i].name,&x[i].t);
  	}
  while(flag!=n){
  	process k;
  	k= dequeue();
  	if(k.t<=q){
  		flag++;
  		timer+=k.t;
  		printf("%s %d\n",k.name , timer);
  	}else {
  		timer+=q;
  		k.t-=q;
  		enqueue(k);
  	}

  }
  
}

Measured memory_bytes: 2472
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    X = I()

    if X >= 30:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10004
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using ll = long long;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

void solve(){
    int d,t,s;
    cin >> d >> t >> s;
    cout << (t*s>=d ? "Yes\n" : "No\n");
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}

Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#define INT long long int
#define MOD 1000000007
#define oo 978654321
#define OO 9999999987654321ll
using namespace std;
int n, s[101], dt[101][10010];
int dp(int x, int y)
{
    if( x == n ) return y%10?y:0;
    if( ~dt[x][y] ) return dt[x][y];
    int &ret = dt[x][y];
    return dt[x][y] = max( dp(x+1, y), dp(x+1, y+s[x]) );
}
int main()
{
    ios::sync_with_stdio(false);
    memset(dt, -1, sizeof(dt));
    cin>>n;
    for(int i = 0 ; i < n ; i++ )
        cin>>s[i];
    cout<<dp(0, 0)<<endl;
}


Measured memory_bytes: 4224
N = int(input())
a = list(map(int, input().split()))

num2 = 0
num4 = 0
odd = 0
for i in a:
    if i % 4 == 0:
        num4 += 1
        continue
    elif i % 2 == 0:
        num2 += 1
        continue
    else:
        odd += 1
        continue
if odd<=num4 or (N%2==1 and num4==N//2):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 20076
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

bool less_my(P lhs, P rhs) {
  if ((double)lhs.second/(double)lhs.first != (double)rhs.second/(double)rhs.first)
    return (double)lhs.second/(double)lhs.first < (double)rhs.second/(double)rhs.first;
  else // 5で割った余りが等しいなら普通に大小比較する
    return lhs.first < rhs.first;
}

vll a,b;
ll h, n;
/*
ll dp(ll p, ll dam){
	if(dam >= h){
		return 0;
	}
	ll ret = 1000000000;
	rep(i, n){
		chmin(ret, dp(p+1))
	}
}*/

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
	ll h, n;cin>>h>>n;
	a = vll(n), b = vll(n);
	vector<P> p(n);
	double memo = 100000.0;
	ll mi = 0;
	rep(i, n){
		cin>>a[i]>>b[i];
		if((double)b[i]/(double)a[i]<memo){
			memo = (double)b[i]/(double)a[i];
			mi = i;
		}
		p[i].first = a[i];
		p[i].second = b[i];
	}
	sort(all(p), less_my);
	rep(i, n){
		debug("aaa   %d %d   %f\n",p[i].first, p[i].second, p[i].first/(double)p[i].second);
	}
	ll fh = h;
	ll ans = 0;
	//ans += ((ll)(h/a[mi]))*b[mi];
	//h -= ((ll)(h/a[mi]))*a[mi];
	ll now = 0;
	ll sig = 0;
	ll nmin = 100000000000;
	while(h>0&&now<n){
		ans += ((ll)(h/p[now].first))*p[now].second;
		sig += ((ll)(h/p[now].first))*p[now].second;
		h -= ((ll)(h/p[now].first))*p[now].first;
		if(h==0){
			chmin(nmin, sig);
			break;
		}
		chmin(nmin, sig+p[now].second);
		now++;
	}
	//cout << nmin << endl;


	
	vll t(fh+15000, 1000000000);
	t[0] = 0;
	for(int i = 1;i < fh+15000;i++){
		rep(j, n){
			if(i-a[j] < 0){
				chmin(t[i], b[j]);
			}else{
				chmin(t[i], t[i-a[j]]+b[j]);
			}
		}
	}ll anss = 1000000000;
	for(int i = fh;i < fh+15000;i++){
		chmin(anss, t[i]);
		debug("%d %d\n", i, t[i]);
	}

	cout << anss << endl;

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
string S;
 
bool C(string s){
    int a=0;
    reps(i,1,12){
        int q=i+1;
        if(i>=7)q-=6;
        a+=(s[i]-'0')*q;
    }
    if(a%11<=1)a=0;
    else a=11-a%11;
    return s[0]-'0'==a;
}
 
signed main(){
    cin>>S;
    reverse(all(S));
 
    int idx=find(all(S),'?')-S.begin();
    int ans,cnt=0;
    rep(i,10){
        string s=S;
        s[idx]='0'+i;
        if(C(s)){
            cnt++;
            ans=i;
        }
    }
 
    if(cnt==1)cout<<ans<<endl;
    else cout<<"MULTIPLE"<<endl;
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int H, W, max_size=0;
    cin >> H >> W;
    vector< vector<int> > matrix(H), size(H+1);
    size[0].resize(W+1);
    for(int i=0;i<H;i++){
        matrix[i].resize(W);
        size[i+1].resize(W+1);
        for(int j=0;j<W;j++){
            cin >> matrix[i][j];
            if(i == 0 || j == 0) size.at(i+1).at(j+1) = 1 - matrix[i][j];
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(matrix[i][j] == 0)
                size[i+1][j+1] = min(size[i][j+1], min(size[i+1][j], size[i][j])) + 1;
            else
            {
                size[i+1][j+1] = 0;
            }       
            max_size = max_size < size[i+1][j+1] ? size[i+1][j+1] : max_size;
        }
    }

    cout << max_size*max_size << endl;
}



Measured memory_bytes: 18072
#include <iostream>
#include <string>

using namespace std;

int main() {
    int count = 0;
    string w, t;
    cin >> w;
    for(int i = 0; i < w.length(); i++) {
        if('A' <= w[i] && w[i] <= 'Z') {
            w[i] = w[i] + 'a' - 'A';
        }
    }
    
    while(1) {
        cin >> t;
        if(t == "END_OF_TEXT") break;
        if(w.length() != t.length()) continue;
        for(int i = 0; i < t.length(); i++) {
            if('A' <= t[i] && t[i] <= 'Z') {
                t[i] = t[i] + 'a' - 'A';
            }
        }
        string::size_type pos = t.find(w);
        while(pos != string::npos) {
            count++;
            pos = t.find(w, pos + w.length());
        }
    }

    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) b.rbegin(),v.rend()
typedef long long ll;
//isPrime
//modpow modinv
int getDigit(int num){
  int digit = 0;
  while(num!=0){
    num/=10;
    digit++;
  }
  return digit;
}
int main() {
  int n;
  cin >> n;
  int count=0;
  for(int i=1; i<=n; i++){
    if(getDigit(i)%2==1){
      count++;
    }
  }
  cout << count << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int r, d, x;
    cin >> r >> d >> x;
    int now = r*x-d;
    //2001年
    cout << now << endl;
    //2002年から2010年
    for(int i=0; i<9; i++){
        now = r*now - d;
        cout << now << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<int,int> c;
  rep(i,n) c[a[i]]++;
  sort(all(a));
  int maxValue = a[n-1];
  vector<bool> b(maxValue+1,1);
  rep(i,n){
    ll now = a[i];
    if(b[now] == 0) continue;
    for(int j=now*2;j<=maxValue;j+=now){
      b[j] = 0;
    }
  }
  int ans = 0;
  rep(i,n){
    int now = a[i];
    if(c[now]>1) continue;
    ans += b[now];
  }
  cout << ans << endl;
}


Measured memory_bytes: 13320
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
  int n,m;
  cin>>n>>m;
  int tot = 0;
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    tot += a;
  }
  //cout<<m<<" "<<tot<<endl;
  cout<<((n-tot<0)? -1 : n-tot)<<endl;
  //    cout << fixed << setprecision(10);
}


Measured memory_bytes: 3628
n,m,x = map(int, input().split())

c = []
for i in range(n):
  c.append(list(map(int, input().split())))
  
max = 999999999999
ans = max  
  
for i in range(2 ** n):
  list=[0]*(m+1)
  
  for j in range(n):
    if ((i >> j) & 1):
      for k in range(m+1):
        list[k] += c[j][k]
#  print(list)          
  if min(list[1:]) >= x:
#    print('koe',list)
    ans = min(ans, list[0])

if ans == max:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 68408
n = int(input())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort(key= lambda x:x[1])
time = 0
for i in range(n):
    if a[i][1] < time + a[i][0]:
        print("No")
        exit()
    else:
        time += a[i][0]
print("Yes")

Measured memory_bytes: 53720
/*
 * atcoder/abc136_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template <class T, class T2>
void group(T &xs, vector<pair<T2, int> > &result) {
  int i=0, j;
  while (i<xs.size()) {
    j=i;
    while (j < xs.size() and xs[j] == xs[i]) j++;
    result.push_back({ xs[i], j-i });
    if (j==i) i++;
    i=j;
  }
}

string S;
int N;
vector<int> B;
void solve() {
  cin >> S;
  B.resize(N);
  vector<pair<char, int> > A;
  group(S, A);
  N = A.size();
  for (int a_i = 0; a_i<N-1; a_i += 2) {
    int R = A[a_i].second;
    int L = A[a_i+1].second;
    int numR = (R+1)/2 + L/2;
    int numL = L + R - numR;
    // cout << "L=" << L << endl;
    for (int i=0; i<R-1; i++) cout << "0 ";
    cout << numR << " " << numL << " ";
    for (int i=0; i<L-1; i++) cout << "0 ";
  }
  cout << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1528
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
//#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
//  util
#include <string>
//#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//int modadd(int a, int b) { return ((a += b) < mod) ? a : (a - mod); }
//int modmult(int a, int b) { return (int)((a * b) % mod) }

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

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

    int A, B, C;

    cin >> A >> B >> C;
    cout << max(C - (A - B), 0);
}


Measured memory_bytes: 256
/////////////////////////////////////////
////////// ^\/^ *_* :) :-D '~' \\\\\\\\\\
/////////////////////////////////////////
#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n;
vector <int> g[100010];
int color[100010];

int main()
{
	cin>>n;
	rep(i,n-1)
	{
		int x,y;
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	queue <int> q;
	memset(color,-1,sizeof(color));
	q.push(1);
	color[1]=1;
	q.push(n);
	color[n]=0;
	while(!q.empty())
	{
		int t=q.front();
		q.pop();
		rep(i,g[t].size())
		{
			if(color[g[t][i]]==-1)
			{
				color[g[t][i]]=color[t];
				q.push(g[t][i]);
			}
		}
	}
	int fen=0,snu=0;
	repn(i,n) if(color[i]==1) fen++;else snu++;
	if(fen>snu) puts("Fennec");
	else puts("Snuke");
	rt0;
}

Measured memory_bytes: 6272
from collections import defaultdict
def inpl(): return [int(i) for i in input().split()]

path = defaultdict(lambda: [])
N = int(input())
for _ in range(N-1):
    a, b = inpl()
    path[a].append(b)
    path[b].append(a)

inf = float('inf')
ctr = 1
now = {1}
distF = [inf for _ in range(N+1)]
distF[1] = 0
while True:
    for na in now.copy():
        na = now.pop()
        for nb in path[na]:
            if distF[nb] > distF[na] + 1:  
                distF[nb] = distF[na] + 1
                now.add(nb)
                ctr += 1
    if ctr >=  N:
        break
ctr = 1
now = {N}
distS = [inf for _ in range(N+1)]
distS[N] = 0
while True:
    for na in now.copy():
        na = now.pop()
        for nb in path[na]:
            if distS[nb] > distS[na] + 1:  
                distS[nb] = distS[na] + 1
                now.add(nb)
                ctr += 1
    if ctr >=  N:
        break
D = distF[N]
for i in range(1,N+1):
    if distF[i] == D//2 and distF[i]+distS[i] == D:
        St = i
    if distF[i] == D//2 + 1 and distF[i]+distS[i] == D:
        En = i
path[St].remove(En)
path[En].remove(St)

ctr = 1
now = {1}
distF = [inf for _ in range(N+1)]
distF[1] = 0
ctr1 = 0
while ctr1 != ctr:
    ctr1 = ctr
    for na in now.copy():
        na = now.pop()
        for nb in path[na]:
            if distF[nb] > distF[na] + 1:  
                distF[nb] = distF[na] + 1
                now.add(nb)
                ctr += 1
if 2*ctr > N:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 35544
a,b,c,d = map(int,input().split())

takahashi = a
aoki = c

for i in range(1,1000):
    if i%2 == 0:
        takahashi -= d
    else:
        aoki -= b

    if takahashi <= 0:
        print('No')
        break
    elif aoki <= 0:
        print('Yes')
        break

Measured memory_bytes: 9184
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long LL;

int main(int argc, char *argv[])
{
	long long N, x, prev = 0, ans = 0;
	cin >> N >> x;
	for (int i = 0; i != N; ++i) {
		long long a;
		cin >> a;
		int op = max(0LL, a + prev - x);
		prev = a - op;
		ans += op;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
K=int(input())


if K%2==0 or K%5==0:
    print(-1)
    sys.exit()
    
mod=7%K
if mod==0:
    print(1)
    sys.exit()
    
i=1
while True:
    mod=(10*mod+7)%K
    i+=1
    mod=mod%K

    if mod==0:
        print(i)
        break

Measured memory_bytes: 9200
h,w = map(int,input().split())
grid = ["#"*(w+1)]
for _ in range(h):
    x = input()
    x = "#" + x
    grid.append(x)
p = 10**9 + 7
dp = [[0]*(w+1) for _ in range(h+1)]
dp[1][1] =1
for i in range(h):
    for j in range(w):
        if grid[i][j+1] == ".":
            dp[i+1][j+1] += dp[i][j+1]
            dp[i+1][j+1] %= p
        if grid[i+1][j] == ".":
            dp[i+1][j+1] += dp[i+1][j]
            dp[i+1][j+1] %= p
print(dp[h][w])

Measured memory_bytes: 43608
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc=new Scanner(System.in)){
			int w=sc.nextInt();
			int h=sc.nextInt();
			int[] game=new int[w];
			for(int i=0;i<game.length;i++){
				game[i]=i+1;
			}
			for(int j=0;j<h;j++){
			String line=sc.next();
			String[] ab=line.split(",");
			int a=Integer.parseInt(ab[0])-1;
			int b=Integer.parseInt(ab[1])-1;
			int tran=0;
			tran=game[a];
			game[a]=game[b];
			game[b]=tran;
			}
			for(int i1=0;i1<game.length;i1++){
				System.out.println(game[i1]);
			}
		}
		
	}

}


Measured memory_bytes: 26128
L ,R = map(int,input().split())

ans =[]
if R - L <= 2019:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans.append(i*j%2019)

else:
    for i in range(R-L-1010,R-L+1010):
        for j in range(i,R-L+1010):
            ans.append(i*j%2019)

print(min(ans))


Measured memory_bytes: 75568
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
const long long INF = 1LL << 60;
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> h(N+1);
	REP(i, N) {
		cin >> h[i+1];
	}

	vector<ll> c(N+1);
	REP(i, N) {
		c[i+1] = INF;
	}
	c[1] = 0;
	

	for(int i=1; i<=N; i++) {
		for (int j = 1; j <= K; j++) {
			if (i + j > N) {
				break;
			}
			c[i + j] = min(c[i + j], c[i] + abs(h[i] - h[i + j]));
		}
	}

	cout << c[N] << endl;

	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var time = new long[5];
            (long idx, long v) lo = (-1, 10);
            for (var i = 0; i < 5; ++i)
            {
                time[i] = Sarray()[0];
                var t = time[i] % 10;
                if (t != 0 && t < lo.v)
                    lo = (i, t);
            }
            var cnt = 0L;
            for (var i = 0; i < 5; ++i)
            {
                if (i != lo.idx)
                    cnt += (time[i] + 9) / 10 * 10;
                else
                    cnt += time[i];
            }
            WriteLine(cnt);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

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

using ll=long long;



void solve(){
    int n,k;
    cin>>n>>k;
    n=(n+1)/2;
    if(n>=k){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int W, H, Dist[35][35];
bool Tate[35][35], Yoko[35][35];

int Solve(){
  fill((bool*)Tate, (bool*)(Tate + H + 1), true);
  fill((bool*)Yoko, (bool*)(Yoko + H + 1), true);
  fill((int*)Dist, (int*)(Dist + H), 0);

  for (int i = 0; i < 2 * H - 1; i++){
    if (i % 2 == 0){
      for (int j = 1; j < W; j++) cin >> Tate[i/2][j];
    }else{
      for (int j = 0; j < W; j++) cin >> Yoko[i/2 + 1][j];
    }
  }
  
  queue <Pii> que; que.push(make_pair(0, 0));
  Dist[0][0] = 1;
  while (!que.empty()){
    Pii Q = que.front(); que.pop();
    int i = Q.first, j = Q.second;

    if (i - 1 >= 0 && Yoko[i][j] == 0 && Dist[i - 1][j] == 0){
      Dist[i - 1][j] = Dist[i][j] + 1;
      que.push(make_pair(i - 1, j));
    }
    if (i + 1 < H && Yoko[i + 1][j] == 0 && Dist[i + 1][j] == 0){
      Dist[i + 1][j] = Dist[i][j] + 1;
      que.push(make_pair(i + 1, j));
    }
    if (j - 1 >= 0 && Tate[i][j] == 0 && Dist[i][j - 1] == 0){
      Dist[i][j - 1] = Dist[i][j] + 1;
      que.push(make_pair(i, j - 1));
    }
    if (j + 1 < W && Tate[i][j + 1] == 0 && Dist[i][j + 1] == 0){
      Dist[i][j + 1] = Dist[i][j] + 1;
      que.push(make_pair(i, j + 1));
    }
  }
  cout << Dist[H - 1][W - 1] << endl;

  return 0;
}

int main(){
  while (cin >> W >> H){
    if (W == 0 && H == 0) return 0;
    Solve();
  }
  return 0;
}



Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
map<int,int> data;
pair<int,int> meh[2000005];
bool cmp(pair<int,int> a,pair<int,int> b){
	//if(a.second != b.second) 
	return a.second<b.second;
	//return a.first < b.first;
}
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++){
		int u;
		scanf("%d",&u);
		data[u]++;
	}
	int hit=0;
	for(map<int,int>::iterator it=data.begin();it!=data.end();it++){
		meh[hit]= make_pair(it->first,it->second);
		hit++;
	}
	sort(meh,meh+hit,cmp);
	for(int i=hit-1;i>=0;i--){
		if(k==0)break;
		n-=meh[i].second;
		k--;
	}
	cout<<n<<endl;
	return 0;
}

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

int main(){

    string s;
    cin >> s;

    bool f=false;

    rep(i,2){
        if(s[i]!=s[i+1]){
            f=true;
        }
    }

    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()

k = p[-X:] + q[-Y:] + r

k.sort()

ans_list = k[-(X + Y):]

print(sum(ans_list))

Measured memory_bytes: 23328
def segment_sieve(a, b):
    ass = []
    is_prime_small = [True] * (int(b**0.5)+1)
    is_prime = [True] * (b-a)
    for i in range(2, int(b**0.5)):
        if is_prime_small[i]:
            j = 2*i
            while j**2 < b:
                is_prime_small[j] = False
                j += i
            j = max(2*i, ((a+i-1)//i)*i)
            while j < b:
                is_prime[j-a] = False
                j += i
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(a + i)
            return ass
    if ass[0] == 1:
        del ass[0]
    return ass



x = int(input())
print(segment_sieve(x, 100004)[0])

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

using namespace std;

int main(){
    string s;
    cin >> s;
    int len = s.size();
    int x = 0, y = 0;
    for(int i = 0; i < len; i++){
        if(i%2 == 0){
            if(s[i] == '0') x++;
            else y++;
        }else{
            if(s[i] == '1') x++;
            else y++;
        }
        
    }

    cout << min(x, y) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define    ll long long
#define    pb          push_back
#define    m_p(a,b)    make_pair(a,b)
#define    inp(x)      scanf("%d",&x)
#define    lnp(x)      scanf("%lld",&x)
#define    ff          first
#define    ss          second
#define    srt(v)      sort(v.begin(),v.end())
#define    mxn         111111

ll dp[mxn][5];
ll arr[mxn][5];
ll n;
ll solve(ll i,ll pos)
{
    if(i > n) return 0;
    ll ret = 0;
    if(dp[i][pos] != -1) return dp[i][pos];

    for(ll j = 1;j <= 3;j++){
      if(j != pos){
        ret = max(ret,arr[i][j] + solve(i+1,j));
      }
    }
    dp[i][pos] = ret;
    return ret;
}

int main()
{
    lnp(n);
    for(ll i = 1;i <= n;i++){
        for(ll j = 1;j <= 3;j++){
            lnp(arr[i][j]);
        }
    }
    memset(dp,-1,sizeof dp);
    ll ans = solve(1,0);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
int main() {
   int n; string s;
   cin>>n;
   cin>>s;
   map<int,char> mp;
   int i=1;
   for(char c='A'; c<='Z'; c++)
   {mp[c]=i;
    i++;
   }
   for(int i=0;i<s.length();i++){
    if(mp[ s[i] ] +n >26)
        s[i]=char('A'+(mp[ s[i] ] +n-27));
    else
        s[i] = char('A'+ (mp[ s[i] ] + n-1));

   }
   cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php
  
fscanf(STDIN, "%d", $n);
$cards = [];
for ($i = 0; $i < $n; $i++) {
  $card = trim(fgets(STDIN));
  $cards[$card] = "OnHand";
}
$suits = ["S", "H", "C", "D"];
for ($k = 0; $k < 4; $k++) {
  for ($i = 1; $i <= 13; $i++) {
    $card = $suits[$k]." ".$i;
    if (!isset($cards[$card])) {
      echo $card."\n";
    }
  }
}


Measured memory_bytes: 9260
/*                          The four Truths of Life

                                    CKMKB
                                    PKMKB

                                    CKMKC
                                    PKMKC
*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;
		cin >> n;
		ll arr[n + 1];
		memset(arr, 0, sizeof(arr));
		for (i = 1; i <= 100; i++)
		{
			for (j = 1; j <= 100; j++)
			{
				for (k = 1; k <= 100; k++)
				{
					temp = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i);
					if (temp <= n)
						arr[temp]++;
					else
						break;
				}
			}
		}

		for (i = 1; i <= n; i++)
		{
			cout << arr[i] << "\n";
		}




		//ln
	}
	return 0;
}


Measured memory_bytes: 3696
package main 
import "fmt"

func main(){
	var S, T string;
	var ans int;

	fmt.Scan(&S, &T);

	for i := 0 ; i < len(S) ; i++ {
		if S[i] == T[i] {
			ans++;
		}
	}
	if ans == len(S) {
		fmt.Println("Yes");
	}else {
		fmt.Println("No");
	}
}

Measured memory_bytes: 1752
#include<iostream>
using namespace std;
int main(){
  int m1,d1,m2,d2;
  cin>>m1>>d1;
  cin>>m2>>d2;
  
  if(m1==m2-1){
   cout<<1<<endl;
  }
  else{
    cout<<0<<endl;
  }
  
 return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl
ll n,k;
ll mod(ll a) {
  return (a % (2*k) + (2*k)) % (2*k);
}

ll M,N;
ll bit[2010][2010];

void bit_add(ll a, ll b, ll w) {
  for (int x = a; x <= M; x += x & -x){
    for (int y = b; y <= N; y += y & -y) {
      bit[x][y] += w;
    }
  }
} 
ll bit_sum(ll a, ll b) {
  ll ret = 0;
  for (ll x = a; x > 0; x -= x & -x) {
    for (ll y = b; y > 0; y -= y & -y) {
      ret += bit[x][y];
    } 
  }
  return ret; 
}

ll M2,N2;
ll bit2[2010][2010];

void bit2_add(ll a, ll b, ll w) {
  for (int x = a; x <= M2; x += x & -x){
    for (int y = b; y <= N; y += y & -y) {
      bit2[x][y] += w;
    }
  }
} 
ll bit2_sum(ll a, ll b) {
  ll ret = 0;
  for (ll x = a; x > 0; x -= x & -x) {
    for (ll y = b; y > 0; y -= y & -y) {
      ret += bit2[x][y];
    } 
  }
  return ret; 
}

int main(){
  cin>>n>>k;
  ll x,y;char c;
  M=M2=N=N2=2*k;

  rep(i,n){
    cin>>x>>y>>c;
    if(c=='B'){
      bit_add(mod(x)+1,mod(y)+1,1);
    }else{
      bit2_add(mod(x)+1,mod(y)+1,1);
    }
  }
  ll ans=0,temp;
  FOR(a,0,k+1){
    FOR(b,0,k+1){
      temp=0;
      temp+=bit_sum(a,b);
      temp+=bit_sum(a,2*k)-bit_sum(a,b+k);
      temp+=bit_sum(2*k,b)-bit_sum(a+k,b);
      temp+=bit_sum(a+k,b+k)-bit_sum(a+k,b)-bit_sum(a,b+k)+bit_sum(a,b);
      temp+=bit_sum(2*k,2*k)-bit_sum(a+k,2*k)-bit_sum(2*k,b+k)+bit_sum(a+k,b+k);
      temp+=bit2_sum(a+k,b)-bit2_sum(a,b);
      temp+=bit2_sum(a,b+k)-bit2_sum(a,b);
      temp+=bit2_sum(a+k,2*k)-bit2_sum(a,2*k)-bit2_sum(a+k,b+k)+bit2_sum(a,b+k);
      temp+=bit2_sum(2*k,b+k)-bit2_sum(2*k,b)-bit2_sum(a+k,b+k)+bit2_sum(a+k,b);
      ans=max(ans,temp);
      temp=0;
      temp+=bit2_sum(a,b);
      temp+=bit2_sum(a,2*k)-bit2_sum(a,b+k);
      temp+=bit2_sum(2*k,b)-bit2_sum(a+k,b);
      temp+=bit2_sum(a+k,b+k)-bit2_sum(a+k,b)-bit2_sum(a,b+k)+bit2_sum(a,b);
      temp+=bit2_sum(2*k,2*k)-bit2_sum(a+k,2*k)-bit2_sum(2*k,b+k)+bit2_sum(a+k,b+k);
      temp+=bit_sum(a+k,b)-bit_sum(a,b);
      temp+=bit_sum(a,b+k)-bit_sum(a,b);
      temp+=bit_sum(a+k,2*k)-bit_sum(a,2*k)-bit_sum(a+k,b+k)+bit_sum(a,b+k);
      temp+=bit_sum(2*k,b+k)-bit_sum(2*k,b)-bit_sum(a+k,b+k)+bit_sum(a+k,b);
      ans=max(ans,temp);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 63232
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long max = sc.nextInt();
		long val = sc.nextInt();
		long ans = (long) Math.pow(Math.floor((double) max / val), 3);
		if(val % 2 == 0) {
			ans += (long) Math.pow(Math.floor((double) (max + val * 0.5) / val), 3);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int maxn=1e5+5;
int a[maxn];
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    int sum=0;
    for(int i=1;i<=m;i++){
      sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3640
def mkPrimeTbl(n):
    lst = [True] * (n + 1) #lst[0]-lst[n]
    for i in range(2, int(n ** 0.5) + 1):
        if lst[i]:
            j = i
            while True:
                j += i
                if (j <= n):
                    lst[j] = False
                else:
                    break
    ret = []
    for i in range(2, n + 1):
        if lst[i]:
            ret += [i]

    return ret

if __name__ == '__main__':
    n = int(input())
    ptbl = mkPrimeTbl(55555)

    arr = []
    for x in ptbl:
        if (x % 10 == 1):
            arr += [x]
        if (len(arr) == n):
            break

    print(' '.join(map(str, arr)))

Measured memory_bytes: 3572
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int K = scanner.nextInt();

        if (A >= K) {
            System.out.println(K);
        } else {
            if (B >= K - A) {
                System.out.println(A);
            } else {
                System.out.println(A - (K - A - B));
            }
        }
    }
}




Measured memory_bytes: 27068
#a, b, c, d = (int(i) for i in input().split())  

#a = [int(i) for i in input().split()] 

N, M = (int(i) for i in input().split())  
L_list = []
R_list = []
for i in range(M):
    L, R = (int(i) for i in input().split())
    L_list.append(L)
    R_list.append(R)
#print(L_list)
#print(R_list)
L_max = max(L_list)
R_min = min(R_list)
for i in range(M):
    pass

if R_min-L_max+1 < 0:
    print("0")
else:
    
    print(R_min-L_max+1)
# if A <= 5:
#     print(0)
# elif 5 < A and A <= 12:
#     print(int(B/2))
# else:
#     print(B)


Measured memory_bytes: 11008
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const int OFF = 13000;

signed main(){
    int H, W;
    scanf("%lld%lld", &H, &W);
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));

    for (int i = 0; i < H; ++i) for(int j = 0; j < W; ++j) {
            scanf("%lld", &A[i][j]);
        }
    for (int i = 0; i < H; ++i) for(int j = 0; j < W; ++j) {
        scanf("%lld", &B[i][j]);
    }

    vector<vector<vector<bool>>> dp(H, vector<vector<bool>>(W, vector<bool>(OFF)));

    for (int i = 0; i < H; ++i) for(int j = 0; j < W; ++j) {
        int v = abs(A[i][j] - B[i][j]);

        if (i == 0 && j == 0) {
            dp[i][j][v] = true;
            continue;
        }

        for (int k = 0; k < OFF; ++k) {
            bool a = k + v < OFF;
            int b = abs(k - v);

            if (i > 0) {
                if (a) {
                    dp[i][j][k + v] = dp[i][j][k + v] || dp[i - 1][j][k];
                }
                dp[i][j][b] = dp[i][j][b] || dp[i - 1][j][k];
            }
            if (j > 0) {
                if (a) {
                    dp[i][j][k + v] = dp[i][j][k + v] || dp[i][j - 1][k];
                }
                dp[i][j][b] = dp[i][j][b] || dp[i][j - 1][k];
            }
        }
    }

    for (int k = 0; k < OFF; ++k) {
        if (dp[H - 1][W - 1][k]) {
            cout << k << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 11008
class Deck:

    def __init__(self, card_num):
        self.deck_list = self.make_deck(card_num)

    def make_deck(self, card_num):
        deck_list = [None] * card_num
        order = 0
        for i in reversed(range(1, card_num + 1)):
           deck_list[order] = i
           order += 1
        return deck_list

    def shuffled(self, cut_pos1, cut_pos2):
        above_card = self.deck_list[0:cut_pos1]
        below_card = self.deck_list[cut_pos1:cut_pos2]
        remain_card = self.deck_list[cut_pos2:]
        self.deck_list = below_card + above_card + remain_card


def get_two_int():
    two_int = input().split()
    for i in range(2):
        two_int[i] = int(two_int[i])
    return two_int


if __name__ == "__main__":
    while True:
        card_num, shuffle_num = get_two_int()
        if card_num == shuffle_num == 0:
            break
        deck = Deck(card_num)
        for i in range(shuffle_num):
            c, p = get_two_int()
            cut_pos1 = c - 1
            cut_pos2 = c - 1 + p
            deck.shuffled(cut_pos1, cut_pos2)
        print(deck.deck_list[0])



Measured memory_bytes: 5620
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    cout << (n < 10 ? k + 100 * (10 - n) : k) << '\n';
    return 0;
}

Measured memory_bytes: 764
#include <iostream>  
#include <cstdio>  
#include <cstring> 
#include <cstdlib>
using namespace std;
string s;
int x,m,i;
struct node
{
int data;
struct node * lchild;
struct node * rchild;
};
typedef struct node;
typedef node * tree;
tree root;
void findn(tree bt,int n)
{
    if(bt)
    {
     if(n<bt->data) findn(bt->lchild,n);
     else if(n>bt->data) findn(bt->rchild,n);
  else cout<<"yes"<<endl;
    }
  else cout<<"no"<<endl;
} 
void insert(tree &bt,int n)
{
   if(bt)
    {
       if(n<bt->data)insert(bt->lchild,n);
       else if (n>bt->data)insert(bt->rchild,n);  
    }
    else
    {
        bt=new node;
        bt->data=n;
        bt->lchild=bt->rchild=NULL;
    }  
}

void printh(tree bt)
{
     if(bt)
     {
        cout<<" "<<bt->data;     
        printh(bt->lchild);
        printh(bt->rchild);
         
     }
}
void printz(tree bt)
{
     if(bt)
     {
        printz(bt->lchild);
        cout<<" "<<bt->data;
        printz(bt->rchild);   
     }
}
int main() 
{  
    root=NULL;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
  
     cin>>s;
    
    if(s=="insert")
     {
        cin>>x;
        insert(root,x);            
     }
    if(s=="find")
    {
      cin>>x;
      findn(root,x);           
    }
      if(s=="print")
      {
         printz(root);
         cout<<endl;
         printh(root);
         cout<<endl;            
      }       
    }
    
   //system("pause");  
    return 0;  
}  

Measured memory_bytes: 15608
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/1000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a, sum;
signed main() {
	cin >> n;
	int ma = -INF, ap, mi = INF, ip;
	rep(i, n) {
		cin >> a;
		if (ma < a) {
			ma = a;
			ap = i;
		}
		if (mi > a) {
			mi = a;
			ip = i;
		}
	}
	cout << 2 * n - 1 << endl;
	if (abs(ma) > abs(mi)) {
		rep(i, n)cout << ap + 1 << " " << i + 1 << endl;
		REP(i, n - 1) {
			cout << i << " " << i + 1 << endl;
		}
	}
	else {
		rep(i, n)cout << ip + 1 << " " << i + 1 << endl;
		for (int i = n - 2; i >= 0; i--) {
			cout << i + 2 << " " << i + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan=new Scanner(System.in);
		int S=scan.nextInt();
		int W=scan.nextInt();
		if(W>=S)
		{
			System.out.println("unsafe");
		}
		else
		{
			System.out.println("safe");
		}

	}

}


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

int main(void){
    int n;
    cin >> n;
    char *s;
    s = new char[n+1];
    cin >> s;
    int ans=0;
    char h=0;
    for(int i=0;i<n;i++){
        if(h!=s[i]){
            h=s[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
a=input()
b=input()
c=input()

a=[int(x) for x in a.split(" ")]
b=[int(x) for x in b.split(" ")]
c=[int(x) for x in c.split(" ")]

b.sort(reverse=True)
c.sort()

for x in range(a[2]+1,a[3]+1):
    if b[0] < x and c[0] >= x:
        print("No War")
        break
else:
    print("War")

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
s = sum(A)
for i, b in enumerate(B):
    if A[i] <= b:
        A[i+1] = max(0, A[i+1] - (b-A[i]))
        A[i] = 0
    else:
        A[i] = A[i] - b
print(s-sum(A))


Measured memory_bytes: 24232