akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 998244353;
const double pi = acos(-1);
const double eps = 1e-10;

const int N = 300009;

ll fac[N], inv[N], n, a, b, k;
ll comb(lll a){
  return fac[n] * inv[a] % mod * inv[n-a] % mod;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  fac[0] = 1;
  inv[0] = 1;
  FOR(i, 1, N){
    fac[i] = fac[i-1] * i % mod;
    inv[i] = modpow(fac[i], mod-2, mod);
  }
  cin >> n >> a >> b >> k;
  if(a > b) swap(a, b);
  if(n * (a + b) < k){
    cout << 0 << endl;
    return 0;
  }
  lll xx, yy;
  ll x, y, d;
  ll g = (ll)gcd(a, b, xx, yy);
  x = (ll)xx;
  y = (ll)yy;
  ll dx = b/g, dy = a/g;
  if(k%g){
    cout << 0 << endl;
    return 0;
  }
  x *= k/g;
  y *= k/g;
  if(x < 0){
    d = (-x-1) / dx + 1;
    x += d * dx;
    y -= d * dy;
  }
  if(n < x){
    d = (x-n-1) / dx + 1;
    x -= d * dx;
    y += d * dy;
  }
  if(y < 0){
    d = (-y-1) / dy + 1;
    y += d * dy;
    x -= d * dx;
  }
  if(n < y){
    d = (y-n-1) / dy + 1;
    y -= d * dy;
    x += d * dx;
  }
  if(x < 0 || y < 0 || n < x || n < y){
    cout << 0 << endl;
    return 0;
  }
  d = min((n-x)/dx, y/dy);
  x += d * dx;
  y -= d * dy;
  ll ans = 0;
  while(0 <= x && y <= n){
    ans += comb(x) * comb(y) % mod;
    x -= dx;
    y += dy;
  }
  cout << ans%mod << endl;
  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int n = N%10;
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
    cout << "hon" << endl;
  }else if(n == 3){
    cout << "bon" << endl;
  }else{
    cout << "pon" << endl;
  }
}

Measured memory_bytes: 3648
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };
int a[110];
signed main() {
	int n, m;
	cin >> n >> m;
	int sum = 0, ans = 1;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
		if (sum <= m)ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int cnt = 0, N = S.size();
  for (int i=0; i<(N/2); i++) {
    if(S[i] != S[N-i-1]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/

int s(int n) {

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) { return 0; }
	}
	return 1;
}

int main() {

	int ans[2 * 123456 + 1] = {};

	ans[2] = 1;

	for (int i = 3; i <= 2 * 123456; i += 2) {
		ans[i] = s(i);
	}

	for (int i = 1; i <= 2 * 123456; i++) {
		ans[i] += ans[i - 1];
	}

	while (1) {
		int n; cin >> n;
		if (n == 0) { return 0; }

		cout << ans[2 * n] - ans[n] << endl;

	}

	return 0;
}



Measured memory_bytes: 4064
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

// a > b
int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

// a > b
int lcm(int a, int b) {
  int tmp = gcd(a, b);
  return tmp ? (a / tmp * b) : 0;
}

void solve(long long X) {
  ll y = X;
  ll ans = 1;
  while (true) {
    if (y % 360 == 0) {
      break;
    }
    y += X;
    ans++;
  }
  cout << ans << endl;
}

int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <climits>

using namespace std;
typedef vector<int> vi;

int main() {
    string A, B;
    cin >> A >> B;
    int n = A.size(), m = B.size();
    vector<vi> dp(n + 1, vi(m + 1));
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            if (i == 0 || j == 0)dp[i][j] = 0;
            else {
                if (A[i - 1] == B[j - 1])
                    dp[i][j] = 1 + dp[i - 1][j - 1];
                else {
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }
    }

    if (dp[n][m] == 0) {
        printf("");
    } else {

        int len = dp[n][m];
        char *ch = new char[len + 1];
        ch[len] = '\0';
        for (int i = n, j = m; i >= 1 && j >= 1;) {
            if (A[i - 1] == B[j - 1]) {
                ch[--len] = B[j - 1];
                --i;
                --j;
            } else if (dp[i][j - 1] < dp[i - 1][j])
                --i;
            else
                --j;
        }

        printf("%s", ch);
    }
}



Measured memory_bytes: 35584
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int sum = 0, mx = 0;
  for (int i = 0; i < n; ++i) {
    int l;
    cin >> l;
    sum += l;
    mx = max(mx, l);
  }
  puts(sum-mx>mx?"Yes":"No");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char str[3];
    int i,price=700;
    for(i=0;i<3;i++){
        scanf("%c",&str[i]);
    }
    for(i=0;i<3;i++){
        if(str[i] == 'o'){
            price+=100;
        }
    }
    printf("%d\n",price);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  ll count = 0;
  ll tmp = sz(s)-1;
  for (ll i = sz(s) - 1; i >= 0;i--){
    if(s[i]=='B'){
      count += tmp - i;
      tmp--;
    }
  }
  print(count);
}


Measured memory_bytes: 3664
using System;
namespace kuku
{
    class kukuclass
    {
        public static void Main()
        {
            for(int i=1;i<10;i++){
                for(int j=1;j<10;j++){
                    Console.WriteLine(i + "x" + j + "=" + i * j);      
                }
            }
        }
    }
}

Measured memory_bytes: 5520
# include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846

const int MAX_N = 100;
vector<int> xy(MAX_N);
 
void solve()
{
        int n; cin >> n;
        ll c = 1;
        while(c < n)
        {
                if(c * 2 > n)
                {
                        cout << c;
                        return;
                }
                c *= 2;
        }
        cout << c;
}
 
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}

Measured memory_bytes: 256
import math
n = int(input())
alphabets = 'abcdefghijklmnopqrstuvwxyz'
def f(X):
    if (int((X-1)/26)):
        return f(int((X-1)/26))+alphabets[(X-1)%26]
    return alphabets[(X-1)%26]
print(f(n))

Measured memory_bytes: 9172
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    public class atcoder
    {
        
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            Dictionary<string, int> D = new Dictionary<string, int>(n);
            string preStr = "";
            for (int i = 0; i < n; i++) {
                string str = Console.ReadLine();
                if (D.ContainsKey(str)) {
                        Console.WriteLine("No");
                        break;
                } else {
                    D[str] = 1;
                }
                if (i > 0) {
                    if (!(preStr[preStr.Length - 1] == str[0]))
                    {
                        Console.WriteLine("No");
                        break;
                    }
                }
                if (i == n - 1) Console.WriteLine("Yes");
                preStr = str;
            }
        }
    }
}
 

Measured memory_bytes: 13152
import java.util.*;
class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
     	
      String s = sc.next();
      if(s.equals("Sunny")){
      	System.out.println("Cloudy");
      } else if(s.equals("Cloudy")){
      	System.out.println("Rainy");
      } else {
      	System.out.println("Sunny");
      }
    }       
}

Measured memory_bytes: 35600
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int d[2100];
typedef long long ll;
signed main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>d[i];
    sort(d,d+n);
    long long ans=0;
    for(ll mid=n-1;mid>=0;mid--)for(ll low=mid-1;low>=0;low--) ans+=(n-1-mid)-distance(lower_bound(d,d+n,d[mid]+d[low]),d+n);


    cout<<ans<<endl;
}

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

int N, K;
vector<int> arr;

int currNum;
//short memo[5005][5005];

bitset<5005 * 5005> memo, isSet;

short dp(int currN, int currSum)
{
	if(isSet.test(currN * 5005 + currSum))
		return memo.test(currN * 5005 + currSum);
		
	if(currN == 0)
	{
		memo.set(currN * 5005 + currSum, (K - currNum <= currSum && currSum < K));
		isSet.set(currN * 5005 + currSum, 1);
		return memo.test(currN * 5005 + currSum);
	}
	
	memo.set(currN * 5005 + currSum, dp(currN - 1, currSum));
	if(currSum + arr[currN] < K)
		memo.set(currN * 5005 + currSum, memo.test(currN * 5005 + currSum) | dp(currN - 1, currSum + arr[currN]));
	
	isSet.set(currN * 5005 + currSum, 1);
	return memo.test(currN * 5005 + currSum);
}

short isNecessary(int pos)
{
	currNum = arr[pos];
	arr.erase(arr.begin() + pos);

	isSet.reset();
	
	short ans = dp( (int)(arr.size()) - 1, 0);
	arr.insert(arr.begin() + pos, currNum);
	return ans;
}

int main()
{
	scanf("%d%d", &N, &K);
	
	arr.push_back(0);
	
	long long sum = 0;
	for(long long i = 1; i <= N; i++)
	{
		int ai;
		scanf("%d", &ai);
		arr.push_back(ai);
		
		sum += ai;
	}
	
	if(sum < (long long)(K) )
	{
		printf("%d", N);
		return 0;
	}
	
	sort(arr.begin(), arr.end());
	
	int startPtr = 1, endPtr = N, ans = 0;
	while(startPtr <= endPtr)
	{
		int mid = startPtr + (endPtr - startPtr) / 2;
		int necessary = isNecessary(mid);

		if(necessary)
			endPtr = mid - 1;
			
		else
		{
			startPtr = mid + 1;
			ans = mid;
		}
	}
	
	printf("%d", ans);
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> vis(n, 0);
    vector<int> v(m);
    for (int i = 0; i < m; ++i) {
        cin >> v[i];
        --v[i];
    }
    for (int i = m - 1; i >= 0; --i) {
        if (!vis[v[i]]) {
            cout << (v[i] + 1) << "\n";
            vis[v[i]] = 1;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (!vis[i]) {
            cout << (i + 1) << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    string s;cin>>s;
    map<char,int>mp;
    rep(i,s.size()){
        mp[s[i]]++;
    }
    if((mp['N']>0)&&(mp['S']==0)){co("No");return 0;}
    if((mp['S']>0)&&(mp['N']==0)){co("No");return 0;}
    if((mp['W']>0)&&(mp['E']==0)){co("No");return 0;}
    if((mp['E']>0)&&(mp['W']==0)){co("No");return 0;}
    co("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,a,b;
    cin>>n>>a>>b;
    if ((b-a)%2==1) {
        cout<<min(a-1,n-b)+1+(b-a-1)/2<<endl;
    } else {
        cout<<(b-a)/2<<endl;
    }
}

Measured memory_bytes: 3600
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    string s;
    cin >> s; cout << s[0];
    cin >> s; cout << s[1];
    cin >> s; cout << s[2];
}


Measured memory_bytes: 256
// B - Ringo's Favorite Numbers /
// https://atcoder.jp/contests/abc100/tasks/abc100_b
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define eb emplace_back
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, d, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> d >> n;
  a = pow(100, d);
  if (n == 100)
  {
    cout << a * 101 << endl;
    return 0;
  }
  cout << a * n << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> v(200001, 0);
  rep(i, 0, n) {
    cin >> a[i];
    v[a[i]]++;
  }
  
  sort(v.rbegin(), v.rend());
  ll ans = 0;
  rep(i, 0, k) ans += v[i];
  
  cout << max(0LL, n-ans) << "\n";
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	int X; std::cin >> X;
	for (int i{ 1 }; i <= X; ++i) {
		if (i * 108 / 100 == X) {
			std::cout << i << std::endl;
			return 0;
		}
	}
	std::cout << ":(" << std::endl;
	return 0;
}

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

int main() {
	string s;
  	cin >> s;
  	int mn = 1000;
  	for (int i = 0; i < s.size() - 2; i++) {
    	string t;
      	t += s[i];
      	t += s[i + 1];
      	t += s[i + 2];
      	if (mn > abs(753 - stoi(t))) mn = abs(753 - stoi(t));
    }
  	cout << mn << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define Mem(a) memset(a,0,sizeof(a))
#define mem(a) memset(a,-1,sizeof(a))
#define For(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);++(i))
#define FOR(i,l,r) for(int (i)=(int)(l);(i)<=(int)(r);++(i))
#define rof(i,l,r) for(int (i)=(int)(l);(i)>=(int)(r);--(i))
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef unsigned long long llu;
typedef long long ll;
const int mxn=1e5+3;
const int inf=INT_MAX;
ll a[mxn],n;
int main(){
	scanf("%lld",&n);
	ll sum=0;
	For(i,0,n){
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	ll tot=n*(n+1)/2;
	ll cnt=sum/tot;
	if(cnt*tot!=sum){puts("NO");return 0;}
	a[n]=a[0];ll x=0;
	For(i,0,n){
		ll sum=cnt-a[i+1]+a[i];
		ll t=sum/n;
		if(t*n!=sum||t<0||t>cnt){puts("NO");return 0;}
		x+=t;
	}
	if(x!=cnt){puts("NO");return 0;}
	puts("YES");return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int a,b,n,m,k,p[11];
	while(scanf("%d %d",&n,&m),n||m){
		k=0;
		for(int i=0;i<11;i++)p[i]=0;
		while(n--){
			scanf("%d %d",&a,&b);
			p[b]+=a;
		}
		for(int i=10;i>=0;i--){
			if(m>=p[i]){
				m-=p[i];
				p[i]=0;
			}else{
				p[i]-=m;
				m=0;
				break;
			}
		}
		for(int i=1;i<11;i++)k+=p[i]*i;
		printf("%d\n",k);
	}
	return 0;
}

Measured memory_bytes: 2576
#include <stdio.h>
#include <string.h>
int main(void){
  char s[11],a[11]={'\0'};
  scanf("%s",s);
  int n=strlen(s),i;
  for(i=0;i<n;i++){
    int m=strlen(a);
    if(s[i]=='B') a[m-1]='\0';
    else a[m]=s[i];
  }
  printf("%s",a);
  return 0;
}

Measured memory_bytes: 128
n = int(input())
xs = list(map(int, input().split()))
 
ys = list(sorted(xs))
m1 = ys[n//2 - 1]
m2 = ys[n//2]
 
medians = [m2 if x < m2 else m1 for x in xs]
print('\n'.join(map(str, medians)))

Measured memory_bytes: 30340
fun binarySearchFloor(l : List<Long>, x : Long) : Int{
    val i = l.binarySearch(x)
    return if(i >= 0) i else - i - 2
}

fun main(args: Array<String>){
    val INF = 100000000000L
    val (A, B, Q) = readLine()!!.split(" ").map(String::toInt)
    var sl : MutableList<Long> = mutableListOf()
    for (i in 0..(A-1)) {
        sl.add(readLine()!!.toLong())
    }
    var tl : MutableList<Long> = mutableListOf()
    for(i in 0..(B-1)){
        tl.add(readLine()!!.toLong())
    }
    var xl : MutableList<Long> = mutableListOf()
    for(i in 0 .. (Q-1)){
        xl.add(readLine()!!.toLong())
    }
    for(i in 0..(Q-1)){
        val x = xl[i]
        val si = binarySearchFloor(sl, x)
        val ti = binarySearchFloor(tl, x)
        val sWest = if(si >= 0) sl[si] else - INF
        val sEast = if(si < A - 1) sl[si + 1] else INF
        val tWest = if(ti >= 0) tl[ti] else - INF
        val tEast = if(ti < B - 1) tl[ti + 1] else INF
        val ret0 = listOf(Math.abs(x - sWest), Math.abs(x - tWest)).max()!!
        val ret1 = (Math.abs(x - sWest) * 2) + Math.abs(tEast - x)
        val ret2 = (Math.abs(x - tWest) * 2) + Math.abs(sEast - x)
        val ret3 = Math.abs(x - sWest) + (Math.abs(tEast - x) * 2)
        val ret4 = Math.abs(x - tWest) + (Math.abs(sEast - x) * 2)
        val ret5 = listOf(Math.abs(sEast - x), Math.abs(tEast - x)).max()!!
        println((listOf(ret0, ret1, ret2, ret3, ret4, ret5)).min())
    }
}


Measured memory_bytes: 84520
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,sum=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
    a[i]*=n;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(abs(a[ans]-sum)>abs(a[i]-sum)) ans=i;
  }
  cout<<ans<<endl;
}

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

int main() {
    int n, l_, ans = 0;
    cin >> n;
    vector<int> l;
    for(int i = 0; i < n; ++i) {
        cin >> l_;
        l.push_back(l_);
    }
    sort(l.begin(), l.end());
    for(int a = n-1; a >= 0; --a) {
        for(int b = a-1; b >= 0; --b) {
            vector<int>::iterator itr = upper_bound(l.begin(), l.begin()+b, l[a] - l[b]);
            ans += distance(itr, l.begin()+b);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <map>
//#include <algorithm>
//#include <functional>
using namespace std;

int main(void){

  int n=0;
  int m=0;
  int i=0;
  int j=0;
  int mc=0;
  scanf("%d%d",&n,&m);
  while(n!=0 || m!=0){
    pair<int,int> mem[1000];
    for(i=0;i<m;i++){
      mem[i].second=i;
    }
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	scanf("%d",&mc);
	if(mc==1)mem[j].first+=1;
      }
    }
    //stable_sort(mem,mem+m,greater<pair<int,int> >());
    int h=0;
    int g=0;
    pair<int,int> hm;
    for(h=m-1;h>0;h--){
      for(g=0;g<h;g++){
	if(mem[g].first<mem[g+1].first){
	  hm=mem[g];
	  mem[g]=mem[g+1];
	  mem[g+1]=hm;
	}
      }
     }
    for(i=0;i<m-1;i++){
      printf("%d\x0020",mem[i].second+1);
    }
    printf("%d\n",mem[m-1].second+1);
  scanf("%d%d",&n,&m);
  }
  return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;


int main(void)
{
    int H,W;
    cin >> H >> W;
    vector<string> S(H);
    REP(i, H) cin >> S[i];
    vector<pii> start;
    REP(i, H)REP(j, W){
        if(S[i][j] == '.'){
            start.pb(pii(i,j));
        }
    }
    int n = start.size();

    int ans = 0;
    REP(i, n-1){
        Rep(j, i+1, n){
            auto s = start[i];
            auto g = start[j];

            queue<pii> q;
            q.push(s);
            vector<vector<int>> ok(H, vector<int>(W, -1));
            ok[s.fi][s.se] = 0;


            while (!q.empty())
            {
                auto f = q.front();q.pop();
                int dx[4]={-1,1,0,0}, dy[4]={0,0,-1,1};
                for (size_t k = 0; k < 4; k++)
                {
                    int dh = f.fi + dx[k];
                    int dw = f.se + dy[k];
                    if(0 <= dh && dh < H && 0 <= dw && dw < W){
                        if(ok[dh][dw] == -1 && S[dh][dw] == '.'){
                            ok[dh][dw] = ok[f.fi][f.se] + 1;
                            q.push(pii(dh, dw));
                        }
                    }
                }
                    
            }
            ans = max(ans, ok[g.fi][g.se]);
        }
    }
    pr(ans);
}

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

#define INF (1<<25)

int N, M, X,ans;
int C[15];
int A[15][15];

int main() {
    //cout<<"Here we go\n";
    cin>>N>>M>>X;
    for(int i=0; i<N; i++){
        cin>>C[i];
        for(int j=0; j<M; j++)cin>>A[i][j];
    }
    
    ans = INF;
    for(int i=1; i<(1<<N); i++){
        int cost = 0;
        int Algorithm[15]={0};
        for(int j=0; j<N; j++){
            if((1<<j)&i){
                cost += C[j];
                for(int k=0; k<M; k++)Algorithm[k] += A[j][k];
            }
        }
        bool found=true;
        for(int j=0; j<M; j++){
            if(Algorithm[j]<X){
                found= false;
                break;
            }
        }
        if(found) ans = min(ans, cost);
    }
    
    if(ans == INF) cout<<"-1";
    else cout<<ans;
    
    return 0;
}


Measured memory_bytes: 3196
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();

        int[] v = new int[N];
        int[] w = new int[N];

        for (int i = 0; i < N; i++) {
            v[i] = sc.nextInt();
            w[i] = sc.nextInt();
        }

        int[][] dp = new int[W+1][N+1];

        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= W; j++) {
                if (j >= w[i-1]) {
                    dp[j][i] = Math.max(dp[j - w[i-1]][i-1] + v[i-1], dp[j][i-1]);
                } else {
                    dp[j][i] = dp[j][i-1];
                }
            }
        }

        System.out.println(dp[W][N]);
    }
}


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

char s[10];
int main() {
	while (scanf("%s", s), strcmp(s, "0000")) {
		int cnt = 0;
		if (s[0] == s[1] && s[0] == s[2] && s[0] == s[3]) {
			puts("NA");
			continue;
		}
		while (strcmp(s, "6174")) {
			sort(s, s + 4); int a = atoi(s);
			reverse(s, s + 4); int b = atoi(s);
			sprintf(s, "%04d", b - a);
			cnt++;
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3260
N = int(input())
a = list(map(int, input().split()))
count = 0
hcount = 0
for x in a:
    if x % 4 == 0:
        count += 1
    elif x % 2 == 0:
        hcount += 1

if (count + (hcount // 2)) >= (N // 2):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 20124
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>

using namespace std;
typedef long long ll;
const int maxn = 1e5+7;

struct node{   // 构建结构体，a 天数， b 报酬 
	ll a,b;
	
}t[maxn];
bool cmp(node x, node y){   // 将天数按从小到大排序 
	return x.a < y.a;
}
int main(){
	
	int n, m;
	while(cin >> n >> m){
		for(int i = 0; i < n; i++)
			cin >> t[i].a >> t[i].b;
		sort(t, t + n,cmp);
		ll ans = 0;
		int d = 0;
		priority_queue<ll> que; // 构建优先队列，天数相同且满足 i < m 的条件下 优先选 报酬高的 
		for(int i = 1; i <= m; i++){
			while(t[d].a <= i && d < n){
				que.push(t[d].b);
				d++;
			}
			if(que.empty()) continue;  // 队列空 则 跳过 
			ans += que.top(); // 报酬高优先 
			que.pop();
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)

int r;
bool ok(int a, int b) {
	double c = pow(a, 2.0) + pow(b, 2.0);
	if(c < pow(r * 2, 2.0)) return true;
	else return false;
}
int main() {
	int n, m, k, s;
	while(cin >> n >> m >> k && (n || m || k)) {
		cin >> s;
		rep(i,s) {
			cin >> r;
			if(ok(n, m) || ok(m, k) || ok(k, n)) {
				cout << "OK" << endl;
			} else cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
s = int(input())


def f(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3 * n + 1


num_list = [s]
i = 0
while True:
    num = f(num_list[i])
    if num in num_list:
        print(i + 2)
        exit()
    num_list.append(num)
    i += 1


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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;


int main(){
  while(1) {
    int n; cin >> n;
    if (n==0) break;
    vector<int> l(n);
    double total=0;
    rep(i,n) {
      cin >> l[i];
      total +=l[i];
    }
    double avg = total/n;
    
    double t=0;
    rep(i,n) {
      t += pow(l[i]-avg,2);
    }
    double r = sqrt(t/n);
    printf("%8f\n",r);
  }
}



Measured memory_bytes: 3200
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T

main :: IO ()
main = do
  let
    modulus = 1000000007 :: Int
    modAdd :: Int -> Int -> Int
    modAdd x y = (x + y) `mod` modulus
    modMul :: Int -> Int -> Int
    modMul x y = (x * y) `mod` modulus
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    bs = scanl modAdd 0 as :: [Int]
  print . foldl modAdd 0 $ zipWith modMul bs as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 13692
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
   int n, k;
   cin >> n >> k;
   int A[n];
   for(int& x : A) cin >> x;
   vector<bool> dp(k + 1, false);
   for(int i = 0; i <= k; ++i){
       for(int x : A){
           if(i >= x && !dp[i - x]) dp[i] = true;
       }
   }
   if(dp[k]) cout << "First" << endl;
   else cout << "Second" << endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{   int a,b;
    cin>>a>>b;
    if(a>b)
    cout<<"a > b"<<endl;
    else if(a==b)
    cout<<"a == b"<<endl;
    else if(a<b)
    cout<<"a < b"<<endl;
    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long) 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long sum = accumulate(a, a + n, 0LL);
  for (int i = 1; i < n; i++) a[i] += a[i - 1];
  long long res = INF;
  for (int i = 0; i < n - 1; i++) {
    res = min(res, abs(a[i] - (sum - a[i])));
  }
  cout << res << "\n";
  return 0;
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 10005;

int n, m, a[N];

int main() {
    scanf("%d %d", &n, &m);
    int cnt = 0;
    int total = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        total += a[i];
    }
    
    for (int i = 1; i <= n; i++) {
        if (a[i] * 4LL * m >= total) {
            cnt++;
        }
    }
    
    printf(cnt >= m ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define SZ(x) ((int)((x).size()))

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

template<class TH>
void _dbg(const char* name, TH val){
    clog << name << ": " << val << endl;
}
template<class TH, class... TA>
void _dbg(const char* names, TH curr_val, TA... vals) {
    while(*names != ',') clog << *names++;
    clog << ": " << curr_val << ", ";
    _dbg(names+1, vals...);
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
    #define dbg_arr(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg(...)
    #define dbg_arr(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    int N;
    cin >> N;
    vector<int> X(N+1), Y(N+1);
    for (int i = 1; i <= N; i++) cin >> X[i] >> Y[i];

    vector<int> ord(N+1);
    for (int i = 1; i <= N; i++) ord[i] = i;
    sort(ord.begin()+1, ord.end(), [&](int i, int j) { return X[i] > X[j]; });

    vector<int> ans(N+1);
    int mm = 0;
    int last = 0;
    for (int it = 1; it <= N; it++) {
        int i = ord[it];
        // dbg(i);
        mm = max(mm, Y[i]);
        if (mm == it) {
            for (int j = last+1; j <= it; j++) ans[ord[j]] = it-last;
            last = it;
        }
    }
    for (int i = 1; i <= N; i++) cout << ans[i] << "\n";
}


Measured memory_bytes: 6368
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
//#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 85 , K = N * (N + N);
int n , m;
int a[N][N] , b[N][N] ;
int dp[N][N][2*K + 5];
main(){
	cin >> n >> m;
	rep(i , 1 , n)
		rep(j , 1 , m)
			cin >> a[i][j];
	rep(i , 1 , n)
		rep(j , 1 , m)
			cin >> b[i][j];
   dp[1][1][K + a[1][1] - b[1][1]] = dp[1][1][K - a[1][1] + b[1][1]] = 1;
   rep(i  , 1 , n){
   	  rep(j , 1 , m){
   	  	 if(i == 1 and j == 1)continue ;                                                     
			for(int w = -14000 ; w <= 14000 ; w++)
	   	  	 	if(dp[i][j - 1][w + K] or dp[i - 1][j][w + K])                          
	   	  	 		dp[i][j][w + K + a[i][j] - b[i][j]] = dp[i][j][w + K + b[i][j] - a[i][j]] = 1;
   	  	 
   	  }
   }
   int ans = 1e9;
   rep(i , -14000 , 14000){
   	 if(dp[n][m][i + K])
   	 	ans = min(ans , abs(i));
   }
   cout << ans;
}

Measured memory_bytes: 770304
import string


def make_string(string, flag_matched=False, N=5000):
    if string[-1] == 'z':
        string = string[:-1]
        flag_matched = False
    if flag_matched == False or len(string) == N:
        string = string[:-1] + chr(ord(string[-1] )+1)
    else:
        string += 'a'
    return(string)


S = input()
k = int(input())

N = len(S)
if N <= 50:

    A = []

    for i in range(N):
        for j in range(1, N+1-i):
            A.append(S[i:i+j])

    A = list(set(A))
    A.sort()

    print(A[k-1])

else:

    c = 0
    q = 'a'

    while True:
        if q in S:
            c += 1
            if c == k:
                break
            else:
                q  = make_string(q, True, N)
        else:
            q  = make_string(q, False, N)

    print(q)


Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

struct Edge{
    // 始点, 終点, 重み, 最大量
    long long src, dst, weight, capacity;
    Edge(): src(0), dst(0), weight(0), capacity(0) {}
    Edge(long long s, long long d, long long w): src(s), dst(d), weight(w) {}
    Edge(long long s, long long d, long long w, long long c): src(s), dst(d), weight(w), capacity(c) {}
};

class Graph{
public:
    long long size;
    vector<vector<Edge>> node;
    Graph(long long n): size(n), node(n) {}
    // 無向辺の追加
    void addEdge(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
        node[d].emplace_back(d, s, w);
    }
    // 有向辺の追加
    void addArc(long long s, long long d, long long w = 1){
        node[s].emplace_back(s, d, w);
    }
    // ノードの追加
    void addNode(){
        size++;
        node.emplace_back();
    }
};

// TopologicalSort; トポロジカルソート
// ：有向非巡回グラフ（DAG）の全ての辺が右向きになるように整列する。[O(E+V)]
vector<long long> TopologicalSort(const Graph &g){
    vector<long long> indegree(g.size), sorted;
    for(long long v=0; v<g.size; v++) for(auto &edge: g.node[v]) indegree[edge.dst]++;
    queue<long long> que;
    for(long long i=0; i<g.size; i++) if(indegree[i] == 0) que.push(i);
    while(!que.empty()){
        long long v = que.front();
        que.pop();
        sorted.emplace_back(v);
        for(auto &edge: g.node[v]) if (--indegree[edge.dst] == 0) que.push(edge.dst);
    }
    return *max_element(indegree.begin(), indegree.end()) == 0LL ? sorted : vector<long long>();
}

// DAGにおける最大距離の計算
ll maxDistance(const Graph &g, const vector<long long> &tpls){
    vector<long long> dp(g.size, 0);
    ll maxDist = 0;
    for(auto &v: tpls){
        for(auto &edge: g.node[v]){
            chmax(dp[edge.dst], dp[v]+1);
            chmax(maxDist, dp[edge.dst]);
        }
    }
    return maxDist;
}

int main(){
    Init();
    ll n, m; cin >> n >> m;
    Graph g(n);
    rep(i, m){
        ll x, y; cin >> x >> y; x--; y--;
        g.addArc(x, y, 1);
    }
    auto tpls = TopologicalSort(g);
    cout << maxDistance(g, tpls) << endl;
}

Measured memory_bytes: 9720
// ???????¬¬???????????±????????????????????¬????????????
// IOIOI
#include <iostream>
#include <string>
using namespace std;

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

	int n, m;
	//cin >> n >> m;
	while (cin >> n && n != 0){
		cin >> m;

		string str;
		cin >> str;

		size_t i = 0;
		int cnt = 0;
		int ans = 0;
		while (i < str.size() - 2){
			if (str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I'){
				cnt++;
				if (cnt >= n)
					ans++;
				i += 2;
			}
			else
				cnt = 0, ++i;
			//cout << ans << endl;
		}
		cout << ans << endl;
	}
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end

int cnt[300010]={}; ll f[300010];

int main(){
    int n; scanf("%d",&n);
    rep(i,0,n){
        int x; scanf("%d",&x);
        cnt[x]++;
    }
    rep(i,0,n+1)rep(j,1,cnt[i]+1)f[j]++;
    rep(i,0,n)f[i+1]+=f[i];
    rep(i,1,n+1){
        int lb=0,rb=n+1;
        while(rb-lb>1){
            int mid=(lb+rb)/2;
            if(f[mid]>=1LL*mid*i)lb=mid;
            else rb=mid;
        }
        printf("%d\n",lb);
    }
    return 0;
}

Measured memory_bytes: 4352