akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// cout << fixed << setprecision(10);
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

struct UnionFind {
	vector<int> par, rank, cnt;
	UnionFind(int n) : par(n), rank(n, 0), cnt(n, 1){
		for(int i=0; i<n; ++i) par[i] = i;
	}
 
	int find(int x) {
		if (x == par[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 (rank[x] < rank[y]) swap(x, y);
 
		par[y] = x;
		cnt[x] += cnt[y];
		if (rank[x] == rank[y]) rank[x]++;
	}
 
	bool same(int x, int y) {
		return find(x) == find(y);
	}
 
	int size(int x) {
		return cnt[find(x)];
	}
};


int main(){
    long long N,M; cin >> N >> M;
    vector<long long> a(M),b(M);
    vector<long long> ans(M);
    long long num = N*(N-1)/2;

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

    UnionFind uf(N);

    for (int i = M-1; i >= 0; i--){
        ans[i] = num;
        if (!uf.same(a[i],b[i])){
            num -= (long long)uf.size(a[i])*(long long)uf.size(b[i]);
            uf.unite(a[i],b[i]);
        }
    }

    for (int i = 0; i < M; i++){
        cout << ans[i] << endl;
    }
} 


Measured memory_bytes: 4864
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define P 998244353

int k[200000];
int rk[200000];

int getk(int a, int x){
	if(x==1) return a;
	int b = getk(a, x/2);
	b = ((long)b)*b%P;
	if((x&1)==0){
		return b;
	}else{
		return ((long)b)*a%P;
	}
}
 
int comb(int a, int b){
	if(a<b) return 0;
	return ((long)k[a])*rk[b]%P*rk[a-b]%P;
}

void init(int n){
	k[0]=1;
	for(int i=1; i<=n; i++){
		k[i]=k[i-1]*((long)i)%P;
	}	
	rk[n]=getk(k[n], P-2);
	for(int i=n-1; i>=0; i--){
		rk[i]=((long)rk[i+1])*(i+1)%P;
	}
}
uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }

int main(void){
	uint32_t n=nextpint();
	uint32_t m=nextpint();
	uint32_t k=nextpint();
	init(n-1);
	uint64_t ans=0;
	uint64_t sh = m--;
	for(uint32_t i=n-k-1; i>0; i--) sh=sh*m%P;
	for(uint32_t i=k; i>0; i--){
		uint64_t now = sh * comb(n-1, i) % P;
		ans+=now;
		sh=sh*m%P;
	}
	ans+=sh;
	printf("%"PRIu64"\n", ans%P);
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  if((a+b)%2 == 0){
  cout << (a+b)/2 <<endl;
  }
  else{
  cout << (a+b)/2 + 1 << endl;
  }
  // ここにプログラムを追記
}

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

int main() {
    int64_t N;
    cin >> N;
    int64_t all = 0;
    for (int64_t i = 0; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) all += i;
    }
    cout << all << endl;
}

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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	int ans = 0;
	int tmp = 0;

	for (int i = a; i <= b; i++)
	{
		string s1 = to_string(i);
		string s2;

		for (int l = 5 - 1; l >= 0; l--)
		{
			s2 += s1[l];
		}

		if (s1 == s2)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int cnt = 0;
    int b_cnt = 1;
    for( int i = 0; i < s.size(); ++i ) {
        if( s[i] == 'a' && cnt < a + b ) {
            ++cnt;
            cout << "Yes";
        } else if( s[i] == 'b' && cnt < a + b && b_cnt <= b ) {
            ++cnt;
            ++b_cnt;
            cout << "Yes";
        } else {
            cout << "No";
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 848
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int n, m, x;
string s;

int main() {
  cin >> n >> m >> x;
  if (n + m >= x && x >= n) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
node=[[]for _ in range(n)]
for _ in range(n-1):
	a,b=map(int,input().split())
	node[a-1].append(b-1)
	node[b-1].append(a-1)
visited=[False]*n
def dfs(i):
	dis=[-1]*n
	dis[i]=0
	stack=[i]
	while stack:
		p=stack.pop()
		for x in node[p]:
			if dis[x]==-1:
				dis[x]=dis[p]+1
				stack.append(x)
	return dis
d0,dn=dfs(0),dfs(n-1)
cnt=0
for i in range(n):
	if d0[i]>dn[i]:
		cnt+=1
if cnt>=n/2:
	print("Snuke")
else:
	print("Fennec")

Measured memory_bytes: 29864
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;

main(){
    int n=in(),k=in();
    string s;cin>>s;
    char c=s[k-1];
    if(c=='A')c='a';
    if(c=='B')c='b';
    if(c=='C')c='c';
    s[k-1]=c;
    cout<<s;
}



Measured memory_bytes: 256
/**********************
    Vikas Kumar Jha
    vkjha1010
**********************/
#include<bits/stdc++.h>
using namespace std;

#define ll          long long int 
#define ld          long double
#define mod         1000000007
#define fi          first
#define se          second
#define pb          push_back
#define mp          make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vb          vector<bool>
#define mii         map<ll,ll>
#define pqb         priority_queue<ll>
#define pqs         priority_queue<ll, vi, greater<ll> >
#define ps(x,y)     fixed << setprecision(y) << x
#define fast        ios_base::sync_with_stdio(0);   cin.tie(0); cout.tie(0);
#define w(t)        ll t; cin >> t; for(ll zx=1;zx<=t;++zx)  
#define fr(be,en)   for(ll i = be; i < en; i++)
ll pow(ll x,ll y){ if(y==0) return 1; if(y%2==1) return (((pow(x,y/2)*pow(x,y/2)%mod)*x)%mod); else return (pow(x,y/2)*pow(x,y/2))%mod;}
vb prime;   vi spf; 
void sieve(ll n) 
{   prime.resize(n+1,true); prime[0]=prime[1]=false;
    spf.resize(n+1,1);  spf[2]=2;
    for(ll i=4;i<=n;i+=2){ prime[i]=false; spf[i]=2; } 
    for (ll p=3; p*p<=n; p+=2) 
    {   if (prime[p] == true) 
        {   spf[p]=p;
            for (ll i=p*p; i<=n; i += p) 
            {   if(prime[i]==true)
                {   spf[i]=p;
                    prime[i] = false;
                }
            } 
        } 
    } 
} 

int main() {
    
    fast;
    ll n,w;
    cin >> n >> w;
    ll wei[n],val[n];
    fr(0,n)
    {
        cin >> wei[i] >> val[i];
    }
    vector<vi> dp(n+1,vi(w+1));

    fr(0,n+1)
    {
        for(ll j=0;j<=w;++j)
        {
            if(i==0 || j==0) continue;
            ll a=dp[i-1][j];
            ll b=(j-wei[i-1]>=0)?(dp[i-1][j-wei[i-1]]+val[i-1]):0;
            dp[i][j]=max(a,b);
        }
    }
    cout << dp[n][w] ;
    return 0;
}

Measured memory_bytes: 80256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

S = [int(x == "1") for x in ins()]
N = len(S)


def check(k):
    assert k < N
    if 2 * k - 1 <= N:
        return True
    a = S[k - 1]
    return all(S[i] == a for i in range(N - k, k))


def solve():
    if all(x == 0 for x in S):
        return N
    if all(x == 1 for x in S):
        return N

    ok, ng = 1, N
    while ng - ok > 1:
        m = (ok + ng) // 2
        if check(m):
            ok = m
        else:
            ng = m
    return ok


print(solve())


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
template<long long Mod = mod>
constexpr long long MOD(long long in) {
    return in % Mod;
}

int n;
char s[305][305];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            std::cin >> s[i][j];

    int ans = 0;
    for (int k = 0; k < n; ++k) {
        bool check = true;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j)
                if (s[i][(j + k) % n] != s[j][(i + k) % n]) {
                    check = false;
                    break;
                }
            if (!check)
                break;
        }

        if (check)
            ++ans;
    }

    std::cout << ans * n << std::endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll x[200005][35],y[200005][35],a[200005],b[200005],res[200005];
vector<ll> z_function(vector<ll> &v) {
    ll n=v.size();
    vector<ll> z(n),res;
    for(ll i=1,l=0,r=0;i<n;i++){
        if(i<=r)
        z[i]=min(r-i+1,z[i-l]);
        while(i+z[i]<n&&v[z[i]]==v[i+z[i]])
        z[i]++;
        if(i+z[i]-1>r){
            l=i;
            r=i+z[i]-1;
        }
    }
    return z;
}
void func(ll x,ll i,ll arr[][35]){
    ll cnt=0;
    while(x>0){
        arr[i][cnt]=(x&1);
        x/=2;
        cnt++;
    }
    for(ll j=0;j<35/2;j++)
    swap(arr[i][j],arr[i][34-j]);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        res[i]=1;
        func(a[i],i,x);
    }
    for(ll i=0;i<n;i++){
        cin>>b[i];
        func(b[i],i,y);
    }
    for(ll g=0;g<35;g++){
        vector<ll> v;
        for(ll i=0;i<n;i++)
        v.push_back(y[i][g]);
        v.push_back(5);
        for(ll i=0;i<n;i++)
        v.push_back(x[i][g]);
        for(ll i=0;i<n;i++)
        v.push_back(x[i][g]);
        vector<ll> z1=z_function(v);
        for(ll i=0;i<n;i++)
        v[i]^=1;
        vector<ll> z2=z_function(v);
        for(ll i=n+1;i<2*n+1;i++)
        if((res[i-n-1]==1)&&(z1[i]<n)&&(z2[i]<n))
        res[i-n-1]=0;
    }
    for(ll i=0;i<n;i++)
    if(res[i])
    cout<<i<<" "<<(a[i]^b[0])<<endl;
}


Measured memory_bytes: 133036
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int x,y;
int main(){
	while(true){
		int a[110]={0};
		int c = -1;
		int cnt = 0;
		while(cin>>x>>y,x||y){
			a[x]++;
			a[y]++;
			c=1;
		}
		if(c==-1)
			return 0;
		bool flag = true;
		if(a[1]%2==0||a[2]%2==0)
			flag = false;
		for(int i =3;i <=100;i++){
			if(a[i]%2==1&&a[i]){
				flag = false;
			}
		}
		if(flag){
			cout <<"OK"<<endl;
		}else{
			cout <<"NG"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,all=0;
	cin >> n;
	vector<int> v(n+2, 0);
	for (int i = 1; i < n+1; i++) {
		cin >> v[i];
	}
	for (int i = 1; i < n+2; i++) {
		all += abs(v[i] - v[i - 1]);
	}
	for (int i = 1; i < n + 1; i++) {
		cout << all - (abs(v[i] - v[i - 1]) + abs(v[i + 1] - v[i]) - abs(v[i - 1] - v[i + 1]))<<endl;
	}
	//cout << all;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1)/ (y))
#define MOD 1000000007ULL

void print_array(u32 *A, u32 N);
u64 bubbleSort(u32 *A, u32 N);

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

    u32 n;
    u32 *A;

    cin >> n;

    A = new u32[n];

    rep (i, n)
    {
        cin >> A[i];
    }

    u64 ret = bubbleSort(A, n);

    print_array(A, n);
    cout << ret << "\n";

    delete[] A;

    return 0;
}

void print_array(u32 *A, u32 N)
{
    string str;
    rep (i, N)
    {
        str += to_string(A[i]) + ' ';
    }
    str.erase(str.end() - 1);
    str += '\n';
    cout << str;
}

u64 bubbleSort(u32 *A, u32 N)
{
    bool flag = true;
    u64 count = 0;
    while (flag)
    {
        flag = false;
        for (int i = N - 1; i > 0; --i)
        {
            if (A[i] < A[i - 1])
            {
                u32 temp = A[i];
                A[i] = A[i - 1];
                A[i - 1] = temp;
                ++count;
                flag = true;
            }
        }
    }

    return count;
}



Measured memory_bytes: 3240
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  s.append(list(map(int, input().split())))
  
sdictlist = []
sdictlistsorted = []
for i in range(D):
  onedict = {}
  for j in range(26):
    onedict[j] = s[i][j]
  sdictlist.append(onedict)
  onesorteddict = sorted(onedict.items(), key=lambda x:x[1], reverse=True)
  sdictlistsorted.append(onesorteddict)

lenpastmax = 23 #26まで設定できる
#26 -> 145419
#25 -> 18657778
#24 -> 40796238
#23
pastlist = []
for i in range(D):
  j = 0
  while(sdictlistsorted[i][j][0] in pastlist):
    j += 1
  print(sdictlistsorted[i][j][0]+1)
  pastlist.append(sdictlistsorted[i][j][0])
  if(len(pastlist)==lenpastmax):
    pastlist.pop(0)

Measured memory_bytes: 10436
#include <stdio.h>
#include <string.h>
#define LEN 100005

// プロセスを表す構造体
typedef struct pp {
	char name[100];
	int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;	//最小値を返す
}

int main(int argc, char *argv[])
{
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);

	for (i = 1; i <= n; i++) {
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1;
	tail = n + 1;

	// シミュレーション
	while (head != tail) {
		u = dequeue();
		c = min(q, u.t);// qまたは必要な時間 u.tだけ処理を行う
		u.t -= c; // 残りの必要時間を計算
		elaps += c; // 経過時間を加算
		if (u.t > 0) enqueue(u); // 処理が完了していなければキューに追加
		else {
			printf("%s %d\n", u.name, elaps);
		}
	}
	return 0;
}



Measured memory_bytes: 12860
#include<stdio.h>

typedef struct model{
  char suit;
  int num;

}Card;

int BubbleSort(Card [], int);
int SelectionSort(Card [], int);
int Compare(Card [], Card[], int);

int main()
{
  int n;
  int i;
  Card A[40]={};
  Card B[40]={};
  char card[3];
  
  scanf("%d",&n);

  for(i=0;i < n;i++){
    scanf("%s",card);
    A[i].suit = card[0];
    A[i].num = (int)(card[1]-'0');

    B[i] = A[i];
  }

  BubbleSort(A,n);
  for(i=0;i < n;i++){
    if(i) printf(" ");
    printf("%c%d",A[i].suit, A[i].num);
  }
  printf("\n");
  printf("Stable\n");

  SelectionSort(B,n);
  for(i=0;i < n;i++){
    if(i) printf(" ");
    printf("%c%d",B[i].suit, B[i].num);
  }
  printf("\n");
  
  if( Compare(A,B,n) ){
    printf("Stable\n");
  }
  else printf("Not stable\n");

  return 0;
}

int BubbleSort(Card A[],int n)
{
  int i,j;
  Card temp;
  
  for(i=0;i < n;i++){
    for(j=n-1;j > i;j--){
      if(A[j-1].num > A[j].num){
	temp = A[j-1];
	A[j-1] = A[j];
	A[j] = temp;
      }
    }
  }
  return 0; 
}

int SelectionSort(Card A[],int n)
{
  int i,j;
  
  int mini;
  Card temp;
  
  for(i=0;i < n;i++){
    mini = i;
    
    for(j = i+1;j < n;j++){
      if(A[j].num < A[mini].num) mini = j;
    }
    
    temp = A[mini];
    A[mini] = A[i];
    A[i] = temp;
  }
  return 0; 
}

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

int Compare(Card A[], Card B[], int n)
{
  int i;

  for(i=0;i < n;i++){
    if(A[i].suit != B[i].suit){
      return 0;
    }
  }
  return 1;
}



Measured memory_bytes: 2716
#include <stdio.h>
#include <math.h>

int main(){
  int n,d;
  int i;
  int64_t x,y;
  int64_t tmp_x,tmp_y;
  long double tmp_2,tmp;
  int cnt=0;
  scanf("%d %d",&n,&d);

  for(i=0;i<n;i++){
    scanf("%lld %lld",&x,&y);
    tmp_x = x*x;
    tmp_y = y*y;
    tmp = (double)tmp_x + tmp_y;
    tmp_2 = sqrt(tmp);
    /*printf("tmp_x = %lld\n",tmp_x);
    printf("tmp_y = %lld\n",tmp_y);
    printf("tmp=%Lf\n",tmp);
    printf("tmp_2=%Lf\n",tmp_2);*/
    if(tmp_2 <= d){
      cnt++;
    }
  }
  /*printf("tmp_x = %d\n",tmp_x);
  printf("tmp_y = %d\n",tmp_y);
  printf("tmp=%f\n",tmp);
  printf("tmp_2=%f\n",tmp_2);
*/
  printf("%d\n",cnt);

  return 0;
}


Measured memory_bytes: 2152
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,sum=0;
	cin>>n;
	int num[n];
	for(int i=0;i<n;i++)
		cin>>num[i],sum+=num[i];
	sort(num,num+n);
	if(num[n-1]>=sum-num[n-1])
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

bool is5050(char a, char b, char c, char d) {
  if (a == b && c == d && a != c) {
    return true;
  } else if (a == c && b == d && a != b) {
    return true;
  } else if (a == d && b == c && a != b) {
    return true;
  }
  return false;
}

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

  const char a = S[0];
  const char b = S[1];
  const char c = S[2];
  const char d = S[3];
  string ans = "No";
  if (is5050(a, b, c, d)) {
    ans = "Yes";
  }

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


Measured memory_bytes: 256
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1e6 + 10;
int n;
int spf[N], lst[N];

void precompute() {
  for (int i = 0 ; i < N ; i++) {
    spf[i] = i;
  }
  for (int i = 2 ; i * i < N ; i++) {
    if (spf[i] != i) continue;
    for (int j = i * i ; j < N ; j += i) {
      spf[j] = i;
    }
  }
}

int main() {
  fill (lst , lst + N , 1e9);
  precompute();
  in(n);
  int gcd = 0;
  bool pairwise = 1;
  for (int i = 0, x ; i < n ; i++) {
    in(x);
    gcd = __gcd(gcd , x);
    while (x > 1) {
      if (lst[spf[x]] < i) pairwise = 0;
      lst[spf[x]] = i;
      x /= spf[x];
    }
  }
  if (pairwise) {
    puts("pairwise coprime");
  } else if (gcd == 1) {
    puts("setwise coprime");
  } else {
    puts("not coprime");
  }
  return 0;
}

void in(int &x){
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-'){
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 11392
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

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


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

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i];
    }
    ll sum = 0;
    for (ll i = 0; i < n; i++){
        sum += a[i];
        sum %= 1000000007LL;
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++){
        sum -= a[i];
        if (sum < 0){
            sum += 1000000007LL;
        }
        ans += a[i]*sum;
        ans %= 1000000007LL;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;


int main(){
    int a, b;
    cin >> a >> b;

    if ((a - b) % 2 == 0) cout << abs(max(a, b) - abs(a - b) / 2) << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define line "\n"
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define ll long long int
#define lb long double
#define ull unsigned long long int
#define pb push_back
#define vi vector < int >
# define vs vector < string >
# define vb vector < bool >
#define vll vector<ll>
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
#define vpii vector<pair<int,int>>
#define vpsi vector<pair<string,int>>
#define mii map<int ,int>
#define mis map<int,string>
#define all(v) v.begin(),v.end()


# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
using namespace std;

void solve()
{ 
 string a;
  cin>>a;
  int count=0;
  for(int i=0;i<a.size();i++)
  {
    int e=a[i]-48;
    count+=e;}
  if(count%9==0)cout<<"Yes"<<line;
  else cout<<"No"<<line;
}



int main()
{fast

{
solve();
}

}



Measured memory_bytes: 3736
N,K=list(map(int, input().split()))
ans=[0]*31

K1=[]
cnt=0
for i in range(N):
	K1=list(map(int, input().split()))
	for i in range(K1[0]):
		ans[K1[i+1]]=ans[K1[i+1]]+1
	K1.clear()


for i in range(30):

	if ans[i+1]==N :
		cnt=cnt+1

print(cnt)

Measured memory_bytes: 3064
// https://atcoder.jp/contests/arc067/tasks/arc067_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    int sum = 0;
    REP(i, n - 1) {
        int t = v[i + 1] + v[i];
        if (t > x) {
            sum += max(0LL, t - x);
            v[i + 1] = max(0LL, v[i + 1] - (t - x));
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans = 0;
  if(s =="RRR") ans = 3;
  if(s =="RRS") ans = 2;
  if(s == "SRR") ans = 2;
  if(s == "RSR") ans = 1;
  if( s =="RSS") ans = 1;
  if( s == "SSR") ans = 1;
  if ( s == "SRS") ans = 1;
  if( s == "SSS") ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 3596
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
result = 0

while n > 0
  if n - k > 0 || n - k < 0
    n = n - (k - 1)
    result += 1
  elsif n - k == 0
    n = n - k
    result += 1
  end
end

puts result

Measured memory_bytes: 8068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
  ll n,k;
  cin>>n>>k;
  vector<ll>h(n);
  rep(i,n)cin>>h[i];
  sort(h.begin(),h.end());
  //もし、ｋ個同じ数のやつがあれば０
  ll ans=1;
  rep(i,n-1){
    if(h[i]==h[i+1]){
      ans++;
      if(ans==k){
        cout<<0<<endl;
        return 0;
      }
    }
    else ans=1;
  }
  ll anar=INF;
  rep(i,n-k+1){
   if(anar>h[i+k-1]-h[i])anar=h[i+k-1]-h[i];
  }
  cout<<anar<<endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string o,e;
    int i;
    cin>>o;
    cin>>e;
    if (o.size()==e.size())
    {
        for (i=0;i<o.size();i++)
        {
            cout<<o[i];
            cout<<e[i];
        }
    }
    else
    {
        for (i=0;i<o.size()-1;i++)
        {
            cout<<o[i];
            cout<<e[i];
        }
        cout<<o[o.size()-1];
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
bool Squ[16001];
int X[10][10];
void Calc(){
	int N = rei();
	int D = rei();
	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			X[i][j] = rei();
		}
	}
	for(int i=0;i*i<=16000;i++){
		Squ[i*i] = true;
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			int sum = 0;
			for(int k=0;k<D;k++){
				sum += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			}
			if(Squ[sum]){
				ans++;
			}
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

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

const Long N = 302;
const Long mod = 1e9 + 7;

vector< pair<Long,Long> > fin[N];
Long n, m;
Long memo[N][N][N];

Long dp(Long p1, Long p2, Long p3){
	if(memo[p1][p2][p3] != -1){
		return memo[p1][p2][p3];
	}
	
	Long mx = max({p1,p2,p3});
	for(Long i = 0; i < (Long)fin[mx].size(); i++){
		Long cnt = 0;
		if(fin[mx][i].first <= p1) cnt++;
		if(fin[mx][i].first <= p2) cnt++;
		if(fin[mx][i].first <= p3) cnt++;
		if(cnt != fin[mx][i].second){
			memo[p1][p2][p3] = 0;
			return 0;
		}
	}
	
	Long pos = mx+1;
	if(pos == n+1){
		return 1;
	}
	
	Long ans = 0;
	ans += dp(pos,p2,p3);
	ans %= mod;
	ans += dp(p1,pos,p3);
	ans %= mod;
	ans += dp(p1,p2,pos);
	ans %= mod;
	memo[p1][p2][p3] = ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	cout << fixed;
	
	for(Long i = 0; i < N; i++){
		for(Long j = 0; j < N; j++){
			for(Long k = 0; k < N; k++){
				memo[i][j][k] = -1;
			}
		}
	}
	
	Long l, r, c;
	cin >> n >> m;
	
	for(Long i = 0; i < m; i++){
		cin >> l >> r >> c;
		fin[r].push_back({l,c});
	}
	
	cout << dp(0,0,0) << "\n";
	return 0;
}


Measured memory_bytes: 215424
#include<stdio.h>
#define min(a,b) a<b?a:b
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    a-=b;
    b=min(a,c);
    printf("%d\n",c-b);
    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	int a[1000];
	int b[1000];

	int count = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i] >> b[i];

		count += b[i] - a[i] + 1;
	}

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

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

int main()
{
	string s;
	cin >> s;
	int x = 0,y=0, n = s.size();
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'A')
		{
			x = i;
			break;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'Z')
		{
			y = i;
		}
	}
	cout << y - x + 1 << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int>ishi(n);
  char s;
  for(int i=0;i<n;i++){
    cin >> s;
    if(s=='R')
      ishi.at(i)=0;
    else
      ishi.at(i)=1;
  }
  int a=0,b=1,c=0;
  while(a+b<n){
    while(a<n){
      if(ishi.at(a)!=1)
        a++;
      else
        break;
    }
    while(b<=n){
      if(ishi.at(n-b)!=0)
        b++;
      else
        break;
    }
    if(a+b<n){
      swap(ishi.at(a),ishi.at(n-b));
      c++;
    }
  }
  for(int i=1;i<n;i++){
    if(ishi.at(n-i)<ishi.at(n-i-1)){
      ishi.at(n-i-1)=0;
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 4000
K, N = map(int,input().split())
A = list(map(int,input().split()))

mi = 10000000
for i in range(N):
  if i == 0:
    d = A[-1] - A[0]
  else:
    d = K - (A[i] - A[i - 1])
  mi = min(d, mi)
print(mi)

Measured memory_bytes: 26100
/***author @sushil
OM nm Shivay
***/
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sushil ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test() long long t;cin>>t;while(t--)
using namespace std;
int main()
{
 ll i,j,k,l,m,n;
 ll md[6];
 for(i=1;i<6;i++)
 {
     cin>>md[i];
     if(md[i]==0)
     cout<<i;
 }
  
} 


Measured memory_bytes: 3608
import numpy as np
a, b = list(input().split())

num_list = []
for s in a:
    num_list.append(int(s))
for s in b:
    num_list.append(int(s))

num = 0
for n in range(1, len(num_list) + 1):
    num += num_list[n - 1] * (10 ** (len(num_list) - n))

num_sqrt = int(np.sqrt(num))
if num_sqrt ** 2 == num:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 13068
from collections import deque
import sys

H, W = map(int, input().split())
grid = '#' * (W+2)
for _ in range(H):
    grid += '#' + input() + '#'
grid += '#' * (W+2)
move = [1, -1, W+2, -W-2]

def bfs(start):
  lst = [10**9] *((H+2)*(W+2))
  lst[start] = 0
  q = deque([start])
  while q:
    x = q.popleft()
    dx = lst[x]
    for d in move:
      y = x + d
      if grid[y] == '#':
        continue
      dy = dx + 1
      if dy >= lst[y]:
        continue
      lst[y] = dy
      q.append(y)
  return max(x for x in lst if x < 10**9)
  
  
print(max(bfs(i) for i in range((H+2)*(W+2)) if grid[i] != '#'))

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll,ll> P;
typedef std::pair<ll,P> State;

const ll MOD = 100000007;

// 2 3 -> (1, -1, 1)
// 6 27 -> (3, -4, 1)
State extgcd(ll a, ll b){
    if(b == 0){
        return mp(a, mp(1, 0));
    }
    State s = extgcd(b, a%b);
    P p = s.second;
    return mp(s.first, mp(p.second, p.first-(a/b)*p.second));
}

// 3 7 -> 5
// 11 7 -> 2
ll mod_inverse(ll a, ll m){
    State s = extgcd(a, m);
    return (m + s.second.first % m) % m;
}

ll fact[2001];
P mod_fact(ll n, ll p){
    int e = 0, _n = n;
    while(_n > 0){
        e += _n / p;
        _n /= p;
    }

    if(n / p % 2 == 0){return mp(fact[n/p] * fact[n%p] % p, e);}
    return mp(fact[n/p] * (p - fact[n%p]) % p, e);
}

ll mod_combination(ll n, ll k, ll p){
    if(n < 0 || k < 0 || n < k){return 0;}
    P p1 = mod_fact(n, p), p2 = mod_fact(k, p), p3 = mod_fact(n-k, p);
    if(p1.second > p2.second + p3.second){return 0;}
    return p1.first * mod_inverse(p2.first * p3.first % p, p) % p;
}

int main(){
    fact[0] = 1;
    FOR(i, 1, 2001){
        fact[i] = (fact[i-1] * i) % MOD;
    }

    int r, c, a1, a2, b1, b2;
    std::cin >> r >> c >> a1 >> a2 >> b1 >> b2;

    if(a1 > b1){std::swap(a1, b1);}
    if(a2 > b2){std::swap(a2, b2);}

    int dx[2] = {b1-a1, a1+r-b1}, dy[2] = {b2-a2, a2+c-b2};
    
    int shortestPath = INF;
    
    REP(i, 2){
        REP(j, 2){
            shortestPath = std::min(shortestPath, dx[i]+dy[j]);
        }
    }

    ll res = 0;
    REP(i, 2){
        REP(j, 2){
            if(dx[i] + dy[j] == shortestPath){
                res = (res + mod_combination(dx[i]+dy[j], dx[i], MOD)) % MOD;
            }
        }
    }

    std::cout << res << std::endl;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    int l, r, d;
    int ans = 0;
    cin >> l >> r >> d;
    for(int i = l; i <= r; i++){
        if(i % d == 0) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}


const int MAX_N = 1e5+10;
const int MAX_M = 4;
using T = tuple<int, int, int>;
T dp[MAX_N][MAX_M][MAX_M][MAX_M];
char ch[MAX_N][MAX_M][MAX_M][MAX_M];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c;
    cin >> n >> a>> b >> c;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    dp[0][min(a, MAX_M-1)][min(b, MAX_M-1)][min(c, MAX_M-1)] = {a, b, c};
    ch[0][min(a, MAX_M-1)][min(b, MAX_M-1)][min(c, MAX_M-1)] = 'X';
    rep(i, n) rep(a, MAX_M) rep(b, MAX_M) rep(c, MAX_M) if(ch[i][a][b][c] != 0) {
        // cout << " " << i << " " << a << " " << b << " " << c << '\n';
        if(s[i] == "AB") {
            if(a > 0) dp[i+1][a-1][min(MAX_M-1, b+1)][c] = {a, b, c}, ch[i+1][a-1][min(MAX_M-1, b+1)][c] = 'B';
            if(b > 0) dp[i+1][min(MAX_M-1, a+1)][b-1][c] = {a, b, c}, ch[i+1][min(MAX_M-1, a+1)][b-1][c]  = 'A';
        }
        else if(s[i] == "AC") {
            if(a > 0) dp[i+1][a-1][b][min(MAX_M-1, c+1)] = {a, b, c}, ch[i+1][a-1][b][min(MAX_M-1, c+1)] = 'C';
            if(c > 0) dp[i+1][min(MAX_M-1, a+1)][b][c-1] = {a, b, c}, ch[i+1][min(MAX_M-1, a+1)][b][c-1] = 'A';
        }
        else {
            if(b > 0) dp[i+1][a][b-1][min(MAX_M-1, c+1)] = {a, b, c}, ch[i+1][a][b-1][min(MAX_M-1, c+1)] = 'C';
            if(c > 0) dp[i+1][a][min(MAX_M-1, b+1)][c-1] = {a, b, c}, ch[i+1][a][min(MAX_M-1, b+1)][c-1] = 'B';
        }
    }
    vector<char> ans(n);
    rep(a, MAX_M) rep(b, MAX_M) rep(c, MAX_M) {
        if(ch[n][a][b][c] == 0) continue;
        repr(i, n) {
            ans[i] = ch[i+1][a][b][c];
            // cout << a << " " << b << " " << c << '\n';
            tie(a, b, c) = dp[i+1][a][b][c];
        }
        cout << "Yes" << '\n';
        rep(i, n) cout << ans[i] << '\n';
        return 0;

    }
    cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 87920
import math

def solve(n,m,lst):
  min_vote = math.ceil(sum(lst)/4/m) - 1
  return lst[m-1] > min_vote

if __name__ == "__main__":
  _n, _m = map(int, input().split())
  a_list = [int(i) for i in input().split()]
  a_list = sorted(a_list,reverse=True)
  if solve(_n,_m,a_list):
    print('Yes')
  else:
    print('No')


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

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

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Scanner sc = new Scanner (System.in);

		int N = sc.nextInt();
		int bunshi = N/2;

		if (N%2==1) {
			bunshi++;
		}

		BigDecimal b1 = new BigDecimal(String.valueOf(N));
		BigDecimal b2 = new BigDecimal(String.valueOf(bunshi));

		BigDecimal answer =(b2.divide(b1,10,RoundingMode.HALF_UP));

		System.out.println(answer);
	}
}

Measured memory_bytes: 21972
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

struct MyStruct {
	int idx, a, b, pl;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.pl != t.pl)
		return s.pl > t.pl; // 降順
	return s.idx < t.idx;
}



int main() {

	int n;
	cin >> n;
	VI v(n);
	REP(i, n) {
		cin >> v[i];
	}
	SORT(v);

	int ans=v[0];
	while (true) {		
		ans = v[0];
		if (ans == 1 || v.size()==1) {
			ANS(ans);
			return 0;
		}
		
		FOR(i,1, v.size()-1) {
			v[i] = v[i] % ans;
		}
		SORT(v);

		if (v.back()== 0) {
			ANS(ans);
			return 0;
		}

		REP(i, v.size()) {
			if (v[i] != 0) {
				v.erase(v.begin(), v.begin() + i);
				break;
			}
		}
	}

	ANS(ans);



	return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-


def main():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    count = 0

    for a in range(a + 1):
        for b in range(b + 1):
            for c in range(c + 1):
                if 500 * a + 100 * b + 50 * c == x:
                    count += 1

    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>

int main()
{
    long N,A,B;
    std::cin >> N >> A >> B;
    if(N%(A+B)<A){
        std::cout << N/(A+B)*A+(N%(A+B))<< std::endl;
    }else{
        std::cout << N/(A+B)*A+A << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll n;cin>>n;
    cout<<(n+1)/2;
    return 0;  
} 





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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

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


void solve() 
{ 
int h,n;
cin>>h>>n;
ll sum=0;
rep(i,n){
	int x;
	cin>>x;
	sum=sum+x;
}
if(sum>=h)
{
cout<<"Yes";	
return ;
}


cout<<"No";
}
int main(){


		solve();
		cout<<endl;
		


	
					
}
		

	

		

 



Measured memory_bytes: 3628
'''input
0
'''
k = input()
arr = []
zz = k%50
for i in range(50-zz):
	arr.append(49-zz)
for i in range(zz):
	arr.append(50)
zzz = k//50
arr = [arr[i]+zzz for i in range(50)]
print 50
for i in range(50):
	print arr[i],


Measured memory_bytes: 28012
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

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

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    string s;
    while (cin >> s) {
        reverse(all(s));
        int n = s.size();
        const int INF = 1e+9;
        vector<vector<int>> f(n + 1, vector<int>(2, INF));
        f[0][0] = 0;
        for (int i = 0; i < n; ++i) {
            for (int t = 0; t < 2; ++t) {
                int x = s[i] - '0' + t;
                if (x < 10) {
                    chmin(f[i + 1][0], f[i][t] + x);
                }
                chmin(f[i + 1][1], f[i][t] + 10 - x);
            }
        }
        cout << min(f[n][0], f[n][1] + 1) << endl;
    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 55964
#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) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	string S;
	cin >> S;

	if (S[0] == S[1] && S[1] == S[2]) co("Yes");
	else if (S[2] == S[3] && S[1] == S[2]) co("Yes");
	else co("No");
	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
struct TXY {
    int t, x, y;
    TXY() : t(0), x(0), y(0) {}
    TXY(int t, int x, int y) : t(t), x(x), y(y) {}
    friend istream &operator>>(istream &input, TXY &t) {
        input >> t.t >> t.x >> t.y;
        return input;
    }
    friend ostream &operator<<(ostream &output, const TXY &t) {
        output << t.t << ", " << t.x << ", " << t.y;
        return output;
    }
};
TXY operator-(const TXY& t1, const TXY& t2) {
    return TXY(t1.t - t2.t, t1.x - t2.x, t1.y - t2.y);
}
bool solve() {
    int N;
    TXY cur, prev;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> cur;
        TXY d = cur - prev;
        prev = cur;
        int tmp = d.t - d.x - d.y;
        if (tmp < 0 || tmp & 1 || tmp / 2.0 + min(0, d.y) < 0) return false;
    }
    return true;
}
int main() {
    cout << (solve() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
/********************************************************************************/
int n,m,k;
int a,b,c,d;
int a2[100010];
string s;
vs v;
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>s;
		v.pb(s);
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	cout<<v.size();
    return 0;
}

Measured memory_bytes: 11612
#
#
answer = Array.new

times = $stdin.gets.to_i
1.upto( times ){
	line = $stdin.gets
	nums = line.split( /\s/ )
	nums.map!{ |r| r.to_i }
	nums.sort!

	a = nums[ 0 ]  
	b = nums[ 1 ]  
	c = nums[ 2 ]

	if a*a + b*b == c*c
		answer << "YES"
	else
		answer << "NO"
	end
}
answer.each{ |ans|
	puts ans
}


Measured memory_bytes: 6096