akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, x;
  cin >> N >> x;

  vector<int> A(N);
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
  }

  sort(A.begin(), A.end());
  int cnt = 0;
  for ( int i = 0; i < N; i++ ) {
    if ( A[i] <= x ) {
      x -= A[i];
      cnt++;      
    }
  }

  if ( x && cnt == N ) cnt--;

  cout << max(0LL, cnt) << endl;
  
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class dijkstra{
  public:
	struct edge{ int to, cost;};
	int V;
	vector<vector<edge> > G;
	vector<int> d;
	dijkstra(int nv){ // nv:ノード数
		nv += 10;
		d = vector<int>(nv); 
		V = nv;
		G = vector<vector<edge> >(nv);
	}
		
	void run(int s){
		priority_queue<P, vector<P>, greater<P> > que;
		fill(d.begin(), d.end(), INT_MAX); // 型をlong longにした時はLLONG_MAXにすること。
		d[s] = 0;
		que.push(P(0, s));

		while(!que.empty()){
			P p = que.top(); que.pop();
			int v = p.second;
			if(d[v] < p.first) continue;
			for (int i = 0;i < G[v].size();i++){
				edge e = G[v][i];
				if(d[e.to] > d[v] + e.cost){
					d[e.to] = d[v] + e.cost;
					que.push(P(d[e.to],e.to));
				}
			}
		}
	}
};

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

	int n,k; cin >> n >> k;
	int c[5005],r[5005];
	dijkstra D(n);

	for (int i = 0;i < n;i++){
		cin >> c[i] >> r[i];
	}

	vector<int> way[5005];

	for (int i = 0;i < k;i++){
		int a,b; cin >> a >> b;
		a--; b--;
		way[a].push_back(b);
		way[b].push_back(a);
	}

	for (int i = 0;i < n;i++){
		queue<int> que;
		que.push(i);
		int d[5005]; memset(d,-1,sizeof(d));
		d[i] = 0;
		while(que.size()){
			int now = que.front(); que.pop();
			if(d[now] == r[i]) break;
			for (int j = 0;j < way[now].size();j++){
				int to = way[now][j];
				if(d[to] != -1) continue;
				que.push(to);
				d[to] = d[now]+1;
				D.G[i].push_back({to,c[i]});
			}
		}
	}

	D.run(0);
	cout << D.d[n-1] << endl;

	return 0;

}



Measured memory_bytes: 127864
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;

ll T;
ll a, b;

int main()
{
    scanf("%lld", &T);
    while(T--)
    {
        scanf("%lld%lld", &a, &b);
        ll x = sqrt((double)a * b);
        if(a * b < x * x) x--;
        if(a * b == x * x)
        {
            printf("%lld\n", 2 * x - 3 + (a == b));
        }
        else
        {
            printf("%lld\n", 2 * x - (a * b <= x * (x + 1)) - 1);
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		String a = scan.next();
		String b = scan.next();

		 StringBuilder asb = new StringBuilder();

		 // a * b
		 for(int i= 0; i< Integer.parseInt(b); i++) {
			 asb.append(a);
		 }

		 StringBuilder bsb = new StringBuilder();

		 // b * a
		 for(int i= 0; i< Integer.parseInt(a); i++) {
			 bsb.append(b);
		 }

		 //System.out.println(asb.toString());
		 //System.out.println(asb.toString().compareTo(bsb.toString()));

		 if(asb.toString().compareTo(bsb.toString()) <= -1) {
			 System.out.println(asb.toString());
		 }else{
			 System.out.println(bsb.toString());
		 }


	}

}

Measured memory_bytes: 21972
import bisect
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF = 10**20
def main():
    A,B,Q=mi()
    X,Y= [], []
    for i in range(A):
        X.append(ii())
    for i in range(B):
        Y.append(ii())
    
    def search_min_dist(Z,z):
        insert_i = bisect.bisect_left(Z,z)
        res = []
        m = INF
        for di in [-2,-1,0,1,2]:
            i = insert_i + di
           
            if 0<= i < len(Z):
                res.append(Z[i])

        return res


    for q in range(Q):
        x=ii()
        minX = search_min_dist(X,x)
        minY = search_min_dist(Y,x)

        ans = INF
        for mx in minX:
            for my in minY:
                min_dist_x,min_dist_y = mx,my
                if not min_dist_x < min_dist_y:
                    min_dist_x,min_dist_y = min_dist_y,min_dist_x

                _ans = 0
                if min_dist_x <= x <= min_dist_y:
                    _ans = min(min_dist_y-x,x-min_dist_x) + min_dist_y - min_dist_x
                elif x <= min_dist_x <= min_dist_y:
                    _ans = min_dist_y - x
                else:
                    _ans = -min_dist_x + x
                
    
                ans = min(ans,_ans)
        print(ans)

        

if __name__ == "__main__":
    main()

Measured memory_bytes: 88164
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout << k <<"\n";
        return;
    }
    ll ans = a;
    k-=a;
    if(k<=b){
        cout  << ans <<"\n";
        return;
    }
    k-=b;
    ll z= min(k,c);
    ans-=z;
    cout << ans <<"\n";

}

int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output

    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
using namespace std;

int main() {
  long yokin;

  cin >> yokin;
  int ans = 0;
  double money = 100;
  while(money < yokin) {
    money = money * 1.01;
    money = floor(money);
    ans++;
  }

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


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,l,r,s;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>l>>r;
        s += (r-l+1);
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
l = []
for i in range(h):
    l.append(input())
x = [-1,0,1,0]
y = [0,-1,0,1]
flg = False
for i in range(h):
    for j in range(w):
        if l[i][j] == "#":
            cnt = 0
            for k in range(4):
                if j+x[k] != -1 and i+y[k] != -1 and j+x[k] != w and i+y[k] != h:
                     if l[i+y[k]][j+x[k]] == "#":
                         cnt += 1
            if cnt == 0:
                flg =True
print("YNeos"[flg::2])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000000;
typedef int64_t ll;
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; }




int main() {
	int N, T, A;
	cin >> N >> T >> A;
	int buf = 1<<30;
	int ans = 0;
	rep(i, N) {
		int tmp,h;
		cin >> h;
		tmp = abs(T*1000 - h *6 - A*1000);
		if (buf>tmp)
		{
			buf = tmp;
			ans = i + 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		int a = S.indexOf('A');
		int z = S.lastIndexOf('Z');
		int ans = z - a + 1;
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 15268
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int n, a;

	cin >> n >> a;

	for (i = 0; i <= 10000; i+=500) {
		for (j = 0; j <= a; j++) {
			if (i + j == n) {
				cout << "Yes" << endl;
				
				getchar();
				getchar();
				return 0;
			}
		}

	}

	cout << "No" << endl;










	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <iomanip>
    #include <string>
    #include <vector>
    #include <deque>
    #include <queue>
    #include <map>
    #include <set>
    #include <algorithm>
    #include <climits>
    #include <cmath>
     
    using namespace std;
    using Pos = std::pair<int, int>;
    //cout<<fixed<<std:cout<<fixed<<setprecision(2)<<Max<<endl;
    constexpr int mod=1e9+7;
     
    int main() {
        long long N,M;
        cin>>N>>M;
     
        long long ans=0;
        if(2*N>=M){
            ans=M/2;
        }else{
            ans+=N;
            M-=2*N;
            ans+=M/4;
        }
        cout<<ans<<endl;
     
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>

using namespace std;

int main() {

    //std::vector<std::tuple<int, int, int>> vec2;
    std::vector<vector<long>> vec;

    int n;
    cin >> n;

    int xyh[n][3];
    int idx = 0;
    for(int i=0; i<n; i++)
        for(int j=0; j<3; j++)
        {
            cin >> xyh[i][j];
            if(j == 2 && xyh[i][j] != 0) idx = i;
        }

    for(long i=0; i<=100; i++)
    {
        for(long j=0; j<=100; j++)
        {
            long hi;
            long absx = abs(xyh[idx][0] - i);
            long absy = abs(xyh[idx][1] - j);
            hi = xyh[idx][2] + absx + absy;
            vec.emplace_back(vector<long>{i, j, hi});
            //cout << i << ", " << j << ", " << h << endl;
        }
    }

    for(long j=0; j<n; j++)
    {
        //cout << "size " << vec.size() << endl;
        for(long i=0; i<vec.size(); i++)
        {
            auto ve = vec[i];
            long absx = abs(xyh[j][0] - ve[0]);
            long absy = abs(xyh[j][1] - ve[1]);
            long hh = max(ve[2] - absx - absy, (long)0);
            if(hh != xyh[j][2])
            {
                vec.erase(vec.begin() + i);
                i--;
            }
        }

    }

    //cout << vec.size() << endl;
    auto ans = vec[0];
    cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;

    return 0;
}


Measured memory_bytes: 896
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

Vi V,odd,res;
int n,m,x;

int main(){
	n=IN(),m=IN();
	For(i,0,m){
		x=IN();
		if (x&1) odd.pb(x);else V.pb(x);
	}
	if (odd.size()>2){
		puts("Impossible");
		return 0;
	}
	if (odd.size()) res.pb(odd.back()),odd.pop_back();
	For(i,0,V.size()) res.pb(V[i]);
	if (odd.size()) res.pb(odd.back()),odd.pop_back();
	if (res.size()==1){
		printf("%d\n",res[0]);
		if (res[0]==1){
			printf("1\n");
			printf("1\n");
		} else{
			printf("2\n");
			printf("%d %d\n",res[0]-1,1);
		}
	} else{
		For(i,0,res.size()) printf("%d ",res[i]);
		puts("");
		res[0]++;
		res.back()--;
		if (res.back()==0) res.pop_back();
		printf("%d\n",res.size());
		For(i,0,res.size()) printf("%d ",res[i]);
		puts("");
	}
}

Measured memory_bytes: 256
n = gets.to_i
a = []
sum = 0.0
k = 1
(n-1).times do |i|
    k*=(i+1)
end
n.times {a.push(gets.split.map(&:to_i))}
n.times do |i|
    (i+1).upto(n-1) do |j|
        x = ((a[i][0]-a[j][0])**2).to_f
        y= ((a[i][1]-a[j][1])**2).to_f
        sum += 2*k*(x+y)**(1/2.0)
    end
end

p sum/k/n

Measured memory_bytes: 1788
#include <stdio.h>

int main(void)
{
    int m500, m100, m50, pay, count = 0;
    scanf("%d", &m500);
    scanf("%d", &m100);
    scanf("%d", &m50);
    scanf("%d", &pay);

    for (int i500 = 0; i500 <= m500; i500++)
    {
        for (int i100 = 0; i100 <= m100; i100++)
        {
            for (int i50 = 0; i50 <= m50; i50++)
            {
                if ((i500*500+i100*100+i50*50) == pay)
                {
                    count++;
                }
            }
        }
    }

    printf("%d", count);

    return 0;
}

Measured memory_bytes: 128
import sys

input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7) 

count_list = []

while True:
    w, h = map(int, input().split())
    if (w, h) == (0, 0):
        break

    grid = [0] * (w + 2)
    for _ in range(h):
        grid += [0]
        grid += list(map(int, input().split()))
        grid += [0]
    grid += [0] * (w + 2)

    move = [-1, +1, -(w + 2) - 1, -(w + 2), -(w + 2) + 1, w + 2 - 1, w + 2, w + 2 + 1]
    visit = set()
    count = 0

    def search(x):
        if x not in visit:
            visit.add(x)
            for dx in move:
                y = x + dx
                if grid[y] == 0:
                    continue
                else:
                    search(y)

    for i in range((w+2) * (h+2)):
        if grid[i] == 0 or i in visit:
            continue
        count += 1
        search(i)
    count_list.append(count)

for i in range(len(count_list)):
    print(count_list[i])


Measured memory_bytes: 7988
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main() {
	int N = 0;
	int L = 0;
	int result = 0;
	int smallest_count = 0;
	int copy_result = 0;
	int new_stream = 0;
	int copy_copy_result = 0;
	scanf("%d", &N);
	scanf("%d", &L);

	for (int i = 0; i < N; i++) {
		result += (L + i);
	}

	copy_copy_result = result;

	if (result < 0) {
		result *= -1;
	}

	for (int i = 0; i < N; i++) {
		new_stream = sqrt((result - (L + i)) * (result - (L + i)));
		new_stream = (result - new_stream) * (result - new_stream);
		if (i == 0) {
			smallest_count = L + i;
			copy_result = sqrt((result - (L + i)) * (result - (L + i)));
			copy_result = (result - copy_result) * (result - copy_result);
			continue;
		}

		if ((result-(sqrt(copy_result))) < (result-sqrt(new_stream))) {
			smallest_count = L + i;
			copy_result = sqrt((result - (L + i)) * (result - (L + i)));
			copy_result = (result - copy_result) * (result - copy_result);
		}
	}
	copy_copy_result -= smallest_count;
	printf("%d", copy_copy_result);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  bool ans;
  // ll n;
  // cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k,x,y;
  // cin >> n >> m >> k;
  // ans = (sqrt(n)+sqrt(m))<sqrt(k);
  // cout << sqrt(n) << ","<<sqrt(m)<<","<<sqrt(k)<<endl;
  // ans = (n+2*sqrt(n*m)+m)<k;
  // x=n*m*4;
  // y=(k-n-m);
  // ans = y*y-x>0;
  // cout<<x<<endl;
  // ans = 4*n*m<(k-n-m)*(k-n-m);
  // cout<<4*n*m<<","<<k-n-m<<","<<(k-n-m)*(k-n-m)<<endl;
  // cout<<ans<<endl;
  ld a, b, c;
  cin>>a>>b>>c;
  if(c-a-b>(ld)sqrt(a*b)*2)
    cout << "Yes\n";
  else
    cout<<"No\n";
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int w,h;
	while(cin>>w>>h){
		if(w==0&&h==0) break;
		int k[w+2][h+2],s[w+2][h+2],nk=0,ns=0;
		for(int i=0;i<=h+1;i++){
			k[0][i]=1;
			k[w+1][i]=1;
			s[0][i]=1;
			s[w+1][i]=1;
		}
		for(int i=1;i<=w;i++){
			k[i][0]=1;
			k[i][h+1]=1;
			s[i][0]=1;
			s[i][h+1]=1;
		}
		string str;
		for(int i=1;i<=h;i++){
			cin>>str;
			for(int j=1;j<=w;j++){
				if(str[j-1]=='.'){
					k[j][i]=0;
					s[j][i]=0;
					nk++;
					ns++;
				}
				else if(str[j-1]=='B'){
					k[j][i]=2;
					s[j][i]=2;
				}
				else if(str[j-1]=='W'){
					k[j][i]=3;
					s[j][i]=3;
				}
			}
		}
		int ct=1;
		while(nk>0){
			for(int i=1;i<=h;i++){
				for(int j=1;j<=w;j++){
					if(k[j][i]==0){
						k[j][i]=6;
						nk--;
						goto e1;
					}
				}
			}
			e1:;
			int ckk=0,cks=0;
			ct=1;
			while(ct>0){
				ct=0;
				for(int i=1;i<=h;i++){
					for(int j=1;j<=w;j++){
						if(k[j][i]==6){
							if(k[j+1][i]==0){
								k[j+1][i]=6;
								nk--;
								ct++;
							}
							if(k[j-1][i]==0){
								k[j-1][i]=6;
								nk--;
								ct++;
							}
							if(k[j][i+1]==0){
								k[j][i+1]=6;
								nk--;
								ct++;
							}
							if(k[j][i-1]==0){
								k[j][i-1]=6;
								nk--;
								ct++;
							}
							if(k[j+1][i]==2) ckk++;
							if(k[j-1][i]==2) ckk++;
							if(k[j][i+1]==2) ckk++;
							if(k[j][i-1]==2) ckk++;
							if(k[j+1][i]==3) cks++;
							if(k[j-1][i]==3) cks++;
							if(k[j][i+1]==3) cks++;
							if(k[j][i-1]==3) cks++;
						}
					}
				}
			}
			if(cks>0||ckk==0){
				for(int i=1;i<=h;i++){
					for(int j=1;j<=w;j++){
						if(k[j][i]==6) k[j][i]=5;
					}
				}
			}
			else{
				for(int i=1;i<=h;i++){
					for(int j=1;j<=w;j++){
						if(k[j][i]==6) k[j][i]=4;
					}
				}
			}
		}
		ct=1;
		while(ns>0){
			for(int i=1;i<=h;i++){
				for(int j=1;j<=w;j++){
					if(s[j][i]==0){
						s[j][i]=6;
						ns--;
						goto e2;
					}
				}
			}
			e2:;
			int csk=0,css=0;
			ct=1;
			while(ct>0){
				ct=0;
				for(int i=1;i<=h;i++){
					for(int j=1;j<=w;j++){
						if(s[j][i]==6){
							if(s[j+1][i]==0){
								s[j+1][i]=6;
								ns--;
								ct++;
							}
							if(s[j-1][i]==0){
								s[j-1][i]=6;
								ns--;
								ct++;
							}
							if(s[j][i+1]==0){
								s[j][i+1]=6;
								ns--;
								ct++;
							}
							if(s[j][i-1]==0){
								s[j][i-1]=6;
								ns--;
								ct++;
							}
							if(s[j+1][i]==2) csk++;
							if(s[j-1][i]==2) csk++;
							if(s[j][i+1]==2) csk++;
							if(s[j][i-1]==2) csk++;
							if(s[j+1][i]==3) css++;
							if(s[j-1][i]==3) css++;
							if(s[j][i+1]==3) css++;
							if(s[j][i-1]==3) css++;
						}
					}
				}
			}
			if(csk>0||css==0){
				for(int i=1;i<=h;i++){
					for(int j=1;j<=w;j++){
						if(s[j][i]==6) s[j][i]=5;
					}
				}
			}
			else{
				for(int i=1;i<=h;i++){
					for(int j=1;j<=w;j++){
						if(s[j][i]==6) s[j][i]=4;
					}
				}
			}
		}
		int kazub=0,kazuw=0;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				if(k[j][i]==4) kazub++;
				if(s[j][i]==4) kazuw++;
			}
		}
		cout<<kazub<<" "<<kazuw<<endl;
	}
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> ans(n + 1, 0);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        if (x * x + y * y + z * z + x * y + y * z + z * x <= n) {
          ans.at(x * x + y * y + z * z + x * y + y * z + z * x)++;
        }
      }
    }
  }
  
  for (int i = 1; i <= n; i++) cout << ans.at(i) << '\n';
}

Measured memory_bytes: 3568
n = int(input())
#h, w = map(int,input().split())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
#ls = [input() for i in range(h)]
#n = input()
sum = sum(list(map(int,list(str(n)))))
if n%sum == 0:
  print("Yes")
  quit()
print("No")

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

int main(void) {
  int n;
  std::string s;
  std::cin >> n;
  std::cin >> s;

  std::string s1 = s.substr(0, n >> 1);
  std::string s2 = s.substr(n >> 1);

  std::cout << (s1 == s2 ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = list(map(int,input().split()))

#n,m = 3,2
#a = [380,19,1]

x = sum(a) / (4*m)

b = [i for i in a if i >= x]

if len(b) >= m:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9180
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()
	a := make([]int, N)
	f := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}
	for i := 0; i < N; i++ {
		f[i] = getInt()
	}
	sort.Ints(a)
	sort.Sort(sort.Reverse(sort.IntSlice(f)))

	l := -1
	r := 10000000000000
	for l+1 < r {
		c := (l + r) / 2
		sum := 0
		for i := 0; i < N; i++ {
			sum += max(0, a[i]-c/f[i])
		}
		if sum <= K {
			r = c
		} else {
			l = c
		}
	}
	out(r)
}


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

long long int a,b,c,ans;
string s;

int main(){
    cin>>a;
    b=a%10;
    if(b==2||b==4||b==5||b==7||b==9){
        cout<<"hon"<<endl;
    }else if(b==0||b==1||b==6||b==8){
        cout<<"pon"<<endl;
    }else if(b==3){
        cout<<"bon"<<endl;
    }
    

}


Measured memory_bytes: 3624
def Sieve_of_Eratosthenes(n):
  is_prime = [True] * (n+1)
  is_prime[0] = False
  is_prime[1] = False
  for i in range(2, int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2, n+1, i):
      is_prime[j] = False
  return is_prime
  #return [i for i in range(n+1) if is_prime[i]]

def is_2017like(n):
  return is_prime[n] and is_prime[(n+1)//2]

is_prime = Sieve_of_Eratosthenes(10**5)
check = [is_2017like(n) for n in range(10**5 + 1)]
ans = [0]
for i in range(1, 10**5 + 1):
  if check[i]:
    ans.append(ans[-1] + 1)
  else:
    ans.append(ans[-1])

Q = int(input())
for _ in range(Q):
  l, r = map(int, input().split())
  print(ans[r] - ans[l-1])

Measured memory_bytes: 86340
#include <stdio.h>

int main(){
	
	int N, total = 0;
	char str[110];
	
	scanf("%d", &N);
	scanf("%s", &str);
	
	for (int i = 0; i<N/2; i++){
		if(str[i] == str[i + N/2]){
			total++;
		}
	}if (N%2 != 0){
		printf("No\n");
		return 0;
	}
	
	total == N/2 ? printf("Yes\n") : printf("No\n");
	
	return 0;
}

Measured memory_bytes: 1596
import java.util.Scanner;


public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int D = scan.nextInt();
        boolean Hate[] = new boolean[10];

        for(int i=0; i<D; i++){
            Hate[scan.nextInt()] = true;
        }

        int pay = N;
        while(true){
            int tmp = pay;
            while(tmp>0 && Hate[tmp % 10] == false) {
                tmp = tmp / 10;
            }
                if(tmp == 0){
                    break;
                }else{
                    pay++;
                }
            }
            System.out.println(pay);
        }
    }



Measured memory_bytes: 9428
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

typedef long long ll;
ll n, m, s;
priority_queue<ll> pq;
int main()
{
	ll i, t;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		scanf("%lld", &t);
		pq.push(t);
	}
    while (m--) {
		t = pq.top(), pq.pop();
		pq.push(t / 2);
    }
    while (!pq.empty()) s += pq.top(), pq.pop();
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1400
using System;
class aizu{
    public static int Main(){
        int i,j;
        int[] n = new int[10000];
        string[] str = new string[10000];

        for( ; ; ){
            str = Console.ReadLine().Split(' ');
            for(i=0;i<2;i++)
                n[i] = int.Parse(str[i]);
            if(n[0]+n[1]==0) break;
            for(i=0;i<n[0];i++){
                for(j=0;j<n[1];j++)
                    Console.Write("#");
                Console.WriteLine();
            }
            Console.WriteLine();
        }        
        return 0;
    }  
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    string S[3];
    REP(i, 3) {
        cin >> S[i];
    }
    cout << S[0][0] << S[1][1] << S[2][2] << endl;
}

Measured memory_bytes: 256
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

bool ng[310];
int a[310][310];

signed main() {
    int N, M; cin >> N >> M;
    rep(i,0,N) rep(j,0,M) cin >> a[i][j], a[i][j]--;

    int ans = INF;
    rep(x,0,M) {
        vector<int> cnt(M);
        rep(i,0,N) {
            rep(j,0,M) {
                if(!ng[ a[i][j] ]) {
                    cnt[ a[i][j] ]++;
                    break;
                }
            }
        }
        int ma = max_element(cnt.begin(), cnt.end()) - cnt.begin();
        chmin(ans, cnt[ma]);
        ng[ma] = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	
	int r,d,tt;
	cin>>r>>d>>tt;
	for(int i=1;i<=10;i++){
		tt=r*tt-d;
		cout<<tt<<endl;
	}
}

signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}




Measured memory_bytes: 256
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a>b:
    x=a-v*t
    y=b-w*t
    if x<=y:
        print('YES')
    else:
        print('NO')
else:
    x=a+v*t
    y=b+w*t
    if x>=y:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9136
#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<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define debug(x) cerr << #x << ": " << x << "\n"
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}

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

    int m,f,r;
  while(1){
    cin >> m>>f>>r;
    if(m ==-1 && f == -1 && r ==-1)break;
    else if(m + f >=80)cout<<"A\n";
    else if(m + f >= 65 && m + f < 80)cout<<"B\n";
    else if(m + f < 65  && m + f >= 50 && m !=-1 && f !=-1)cout<<"C\n";
    else if(m + f < 50  && m + f >=30 && m !=-1 && f !=-1){
        if(r >= 50)cout<<"C\n";
        else cout<<"D\n";

    }
    else if(m + f< 30 && m !=-1 && f !=-1)cout<<"F\n";
    else cout<<"F\n";
}
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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; }
#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 rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9+7;

int d;
vector<int> c;
vector<vector<int>> s;

vector<int> argsort(vector<int> v) {
    vector<int> indices(v.size());
    iota(indices.begin(), indices.end(), 0);
    // ソートする。
    sort(indices.begin(), indices.end(), [&v](int i1, int i2) {
        return v[i1] < v[i2];
    });
    return indices;
}

int greedy(int date) {
    vector<int> score(26, 0);
    rep (i, 26) {
        score[i] = s[date][i] + c[i];
    }
    vector<int> indices = argsort(score);
    return indices[25];
}

int main() {
    cin >> d;
    c.resize(26);
    rep (i, c.size()) {
        scanf("%d", &c[i]);
    }
    s.resize(d, vector<int>(26));
    rep (i, d) {
        rep (j, c.size()) {
            cin >> s[i][j];
        }
    }
    rep (i, d) {
        cout << greedy(i) + 1 << endl;
    }
}




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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll> hash(n);
  ll a,b;
  for(i=0;i<m;i++){
    cin>>a>>b;
    hash[a-1]++;
    hash[b-1]++;
  }
  for(i=0;i<n;i++){
    cout<<hash[i]<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
ll freq[100];
void Dufaux()
{
    ll n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        ll a,b;
        cin>>a>>b;
        freq[a]++;
        freq[b]++;
    }
    for(int i=1;i<=n;i++){
        cout<<freq[i]<<endl;
    }
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int k,i=0,l;
string s;
cin>>k>>s;
if(s.size()<=k)
{
	cout<<s<<endl;
}
else
{  l=s.size()-k;
	while(k--)
	{
		cout<<s[i];
		i++;
	}
	

		cout<<"...";

	cout<<endl;
}
return  0;
}





Measured memory_bytes: 3656
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val P = readLine()!!.split(" ").map { it.toDouble() }

    // メモを初期化
    val dp = Array(n + 1) { DoubleArray(n + 1) { 0.0 } }
    dp[1][0] = 1 - P[0]
    dp[1][1] = P[0]

    // メモを更新
    for (i in 2 until n + 1) {
        for (j in 0 until n + 1) {
            if (j - 1 >= 0) {
                dp[i][j] = dp[i - 1][j - 1] * P[i - 1] + dp[i - 1][j] * (1 - P[i - 1])
            } else {
                dp[i][j] = dp[i - 1][j] * (1 - P[i - 1])
            }
        }
    }

    // 答えを求める
    var ans = 0.0
    for (j in 0 until n + 1) {
        if (j >= (n + 1) / 2) {
            ans += dp[n][j]
        }
    }

    println(ans)
}

Measured memory_bytes: 127456
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
int a[110];
int main(void)
{
    sync;
    int t;
    int n,m;
    cin>>n>>m;
    int sum=0;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int cnt=0;
    for(int i=0;i<n;++i)
    {
        if(a[i]*4*m>=sum)
            ++cnt;
    }
    if(cnt>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, k = map(int, input().split())

if k <= a:
    print(k)
elif k <= a + b and k > a:
    print(a)
else:
    print(a + a + b - k)


Measured memory_bytes: 8988
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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;
}

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size() - 1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min + (max - min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n, vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());

}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n, m;
	cin >> n >> m;
	ll times = (ll)pow(2, m);
	ll total = times * (m * 1900 + (n - m) * 100);
	cout << total;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

    int count = 0;
    for (int i = 0; i < n+1; i++)
    {
        if (x >= l[i])
        {
            count++;
            continue;
        }
        break;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mxn 19
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
typedef long long int ll;
using  namespace std;
int main(void){
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	int d,t,s;
	cin>>d>>t>>s;
	if(s*t<d)
	cout<<"No";
	else
	cout<<"Yes";
}


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

using namespace std;

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

    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    int pointer = 0;

    for(int i=0;i<h;i++){
        int ans[w];
        if(i%2==0){
            for(int j=0;j<w;j++){
                ans[j] = pointer+1;
                a[pointer]--;
                if(a[pointer]==0)pointer++;
            }
        }
        else{
            for(int j=w-1;j>=0;j--){
                ans[j] = pointer+1;
                a[pointer]--;
                if(a[pointer]==0)pointer++;
            }
        }
        for(int j=0;j<w-1;j++)cout << ans[j] << " ";
        cout << ans[w-1] << endl;
    }
}


Measured memory_bytes: 384
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

template <typename T>
int gcd(T x, T y){
	return y==0 ? x : gcd(y, x%y);
}


int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<int> a(n);
		REP(i, n) cin >> a[i];
		vector<int> l(n);
		vector<int> r(n);
		l[0] = a[0];
		FOR(i, 1, n) {
			l[i] = gcd(l[i-1], a[i]);
		}
		r[0] = a[n-1];
		FOR(i, 1, n) {
			r[i] = gcd(r[i-1], a[n-i-1]);
		}
		dpite(ALL(l)); dpite(ALL(r));
		int ans = max(l[n-2], r[n-2]);
		FOR(i, 1, n-1) {
			DEBUG(i);
			DEBUG(gcd(l[i-1], r[n-i-1]));
			chmax(ans, gcd(l[i-1], r[n-i-2]));
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main(){
    int k;
    int i,j;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++){
            k = i * j;
            cout << i << "x" << j << "=" << k << endl;   
        }
    }


    return 0;
}


Measured memory_bytes: 2924