akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
const int N=2e3+10;
struct dabt{ int next,to; }e[N<<1],pt[N];
int n,m,k,head[N],st,dis[N][N],ans=2e9,minn;
inline void add(int from,int to){e[++k]=(dabt){head[from],to}; head[from]=k;}
inline int read(){
	char ch=getchar(); int x=0, f=1;
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;}
inline int mi(int a,int b){return a<b ? a : b;}
void dfs(int lst,int x,int dep)
{
	for(RG int i=head[x];i;i=e[i].next)
	{
		int v=e[i].to;
		if(v==lst) continue;
		dis[v][st]=dis[st][v]=dep;
		dfs(x,v,dep+1);
	}
}
int main()
{
	//freopen("Shorten Diameter.in","r",stdin);
	n=read(); m=read();
	for(RG int i=1,a,b;i<n;i++)
	{
		a=read(); b=read();
		add(a,b); add(b,a);
		pt[i]=(dabt){a,b};
	}
	for(RG int i=1;i<=n;i++) st=i, dfs(0,i,1);//直接暴力找距离 
	if(m%2==0)//若为偶数就可以直接暴力判断 
	{
		m/=2;
		for(RG int i=1;i<=n;i++)
		{
			minn=0;
			for(RG int j=1;j<=n;j++)
			 if(i!=j && dis[i][j]>m) minn++;
			ans=mi(ans,minn);
		}
	}
	else
	{
		m/=2;
		for(RG int i=1;i<n;i++)//枚举点对 
		{
			int a=pt[i].next, b=pt[i].to; minn=0;
			for(RG int j=1;j<=n;j++)
			 if(dis[a][j]>m && dis[b][j]>m) minn++;//两个点必须都要满足 
			ans=mi(ans,minn);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16128
import sys
input = sys.stdin.readline

N=int(input().rstrip('\n'))
A=[int(x) for x in input().rstrip('\n').split()]
now = 0
for x in range(N):
  if A[x] == now+1:
    now += 1
if now == 0:
  print(-1)
else:
  print(N-now)

Measured memory_bytes: 32332
#include <iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int x;
	cin>>x;
	int coutt=0;
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b;j++)
		{
			for(int k=0;k<=c;k++)
			{
				if(500*i+100*j+50*k==x)
				{
					coutt++;
				}
			}
		}
	}
	cout<<coutt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
struct E{
	int x,y,nxt,flag;
}mm[N<<2];
int h[N],len,p[N],n,ans[N],cur[N];
bool v[N];
inline int rd(){
	int x=0;int f=1;char s=getchar();
	while(!isdigit(s)) f=(s=='-'?-1:f),s=getchar();
	while(isdigit(s)) x=(x<<1)+(x<<3)+s-'0',s=getchar();
	return x*f;
}

inline void add(int x,int y){
	++len;
	mm[len].x=x;mm[len].y=y;mm[len].nxt=h[x];h[x]=len;
	++len;
	mm[len].x=y;mm[len].y=x;mm[len].nxt=h[y];h[y]=len;
	p[x]++;p[y]++;
	return ;
}
void dfs(int u,int f){
	for(int& k=h[u];k;k=mm[k].nxt){
		int y=mm[k].y;
		if(mm[k].flag||f==y) continue; 
		mm[k].flag=mm[k%2==0?k-1:k+1].flag=1;
		if(v[u] && u<=n && y>n) ans[u]=ans[y]=1; 
		if(v[u] && u>n && y<=n) ans[u]=ans[y]=-1;
		dfs(y,u);
	}
}
int main(){
//	freopen("t.in","r",stdin);
	n=rd();memset(h,0,sizeof h);
	for(int i=1;i<=n;i++){
		int u=rd();u=max(0,u);
		add(u,i);
	}
	for(int i=1;i<=n;i++){
		int u=rd();u=u==-1?0:(u+n);
		add(u,i+n);
	}
	for(int i=1;i<=2*n;i++){
		if(p[i]%2) v[i]=1;
		else v[i]=0;
	}
	bool flag=true;
	for(int i=1;i<=n;i++)
		if(v[i]!=v[i+n]) flag=0;
	if(flag) printf("POSSIBLE\n");
	else {
		printf("IMPOSSIBLE\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
		if(v[i]) add(i,i+n);//,printf("#%d %d\n",i,i+n);
	dfs(1,0);
	for(int i=1;i<=n;i++) printf("%d ",ans[i]);printf("\n");
	return 0;
}

Measured memory_bytes: 23424
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;
typedef map<ll, ll> Map;

ll sum[4][110];
int main(void) {
    ll N, W, i, j, k, l;
    ll w1=0, w, v;
    cin >> N >> W;
    vector<ll> vec[4];
    
    for(i=0; i<N; i++) {
        cin >> w >> v;
        if(i==0) w1=w;
        vec[w-w1].push_back(v);
    }
    
    for(i=0; i<4; i++) sort(vec[i].rbegin(), vec[i].rend());
    
    for(i=0; i<4; i++) {
        for(j=0; j<vec[i].size(); j++) {
            sum[i][j+1]=sum[i][j]+vec[i][j];
        }
    }
    
    ll max=0;
    for(i=0; i<vec[0].size()+1; i++) {
        for(j=0; j<vec[1].size()+1; j++) {
            for(k=0; k<vec[2].size()+1; k++) {
                for(l=0; l<vec[3].size()+1; l++) {
                    ll pos=i*w1+j*(w1+1)+k*(w1+2)+l*(w1+3);
                    ll v=sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l];
                    if(pos<=W) max=max(max, v);
                }
            }
        }
    }
    
    prin(max)
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>
#include <iomanip>

using namespace std;


int main(){
	int n;
	int cnt = 1;
	cin >>n;
	
	vector<string> v(n);
	
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	
	sort(v.begin(),v.end());
	
	for(int i=0;i<v.size()-1;i++){
		if(v[i] != v[i+1]) cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 9604
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001000001;

//bitdp メモ化再帰

int n, m;
int s[15];
int d[101];
int dp[1 << 15][101];

int calc(int bit){

    //cout << bit << endl;
    //探索済みなら値return
    if(dp[bit][m] != INF) return dp[bit][m];

    //全部使った時のぬくもり
    int warm = 0;
    for(int i = 0; i < n; i++){
        if(bit & (1 << i)) warm += s[i];
    }

    //bitを1本折るときと、現在のbitを組み合わせる
    for(int i = 0; i < n; i++){
        if(bit & (1 << i)){
            //もしbitが立っていたら
            //bitを折る
            int next_bit = bit & (~(1 << i));
            //dpが最新バージョンに更新
            int dummy = calc(next_bit);

            //これはいい感じですか？
            int temp_sum = 0;
            vector<int> temp_dp(m + 1);
            for(int j = 0; j < m; j++){
                temp_dp[j] = min(dp[next_bit][j], abs(warm - d[j]));
                temp_sum += temp_dp[j];
            }
            temp_dp[m] = temp_sum;

            if(temp_sum < dp[bit][m]){
                //もしいいなら入れ替える
                for(int j = 0; j <= m; j++) dp[bit][j] = temp_dp[j];
            }
        }
    }

    //cout << bit << " " << dp[bit][m] << endl;
    return dp[bit][m];
}

int main(){

    while(1){
        cin >> n >> m;
        if(!n) break;
        for(int i = 0; i < (1 << n); i++){
            for(int j = 0; j <= m; j++){
                dp[i][j] = INF;
            }
        }

        for(int i = 0; i < n; i++) cin >> s[i];
        for(int i = 0; i < m; i++) cin >> d[i];


        //dp初期化
        int sum = 0;
        for(int i = 0; i < m; i++){
            dp[0][i] = d[i];
            sum += d[i];
        }
        dp[0][m] = sum;

        cout << calc((1 << n) - 1) << endl;

        /*for(int i = 0; i < (1 << n); i++){
            for(int j = 0; j <= m; j++){
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }*/


    }
    return 0;
}


Measured memory_bytes: 16020
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
  int X, N;
  cin >> X >> N;
  int ans = -1;
  vector<int> p(N);
  for(int i = 0; i < N; i++) cin >> p[i];
  for(int i = -1; i <= 101; i++) {
    bool ok = true;
    for(int j = 0; j < N; j++) {
      if(p[j] == i) ok = false;
    }
    if(ok and abs(ans - X) > abs(i - X)) ans = i;
  }
  cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;

namespace C___Attack_Survival
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] Numbers = Console.ReadLine().Split(' ');
            var NumberOfPeople = int.Parse(Numbers[0]);
            int[] PointOfPeople = new int[NumberOfPeople];

            var NumberOfPoint = int.Parse(Numbers[1]);
            var NumberOfCorrect = int.Parse(Numbers[2]);

            int[] Ai = new int[NumberOfCorrect];

            for (int i = 0; i < NumberOfCorrect; i++)
            {
                Ai[i] = int.Parse(Console.ReadLine());
            }
            
            for (int i = 0; i < NumberOfCorrect; i++)
            {
                PointOfPeople[Ai[i]-1]++;
            }

            var Point = NumberOfPoint - NumberOfCorrect;
            for (int i = 0; i < PointOfPeople.Length; i++)
            {
                PointOfPeople[i] += Point;
                int temp = PointOfPeople[i];
                if(temp > 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }

            }
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    map<ll,ll> mp;
    rep(i,N){
        if(mp[A[i]]){
            cout<<"NO"<<endl;
            return 0;
        }
        mp[A[i]]++;
    }
    cout<<"YES"<<endl;

    return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int a[3];
    for(int i = 0;i<3;i++) cin>>a[i];
    int g[5];
    g[0] = abs(a[0]-a[1])+abs(a[1]-a[2]);
    g[1] = abs(a[0]-a[2])+abs(a[1]-a[2]);
    g[2] = abs(a[1]-a[0])+abs(a[0]-a[2]);
    g[3] = abs(a[1]-a[2])+abs(a[0]-a[2]);
    g[4] = abs(a[2]-a[1])+abs(a[0]-a[1]);
    g[5] = abs(a[2]-a[0])+abs(a[0]-a[1]);
    sort(g,g+5);
    cout<<g[0];
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s=="SUN") cout << 7;
    if(s=="MON") cout << 6;
    if(s=="TUE") cout << 5;
    if(s=="WED") cout << 4;
    if(s=="THU") cout << 3;
    if(s=="FRI") cout << 2;
    if(s=="SAT") cout << 1;
    cout << endl;
    return 0;
}

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

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

    int n;
    cin >> n; 
    n *= 2;
    vector <int> A(n);
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int res = 0;
    for(int i = A.size() - 2; i >= 0; i -= 2) {
        res += A[i];
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=sorted([int(x) for x in input().split()])
a=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if l[i]<l[j]<l[k] and l[i]+l[j]>l[k]:
        a+=1
print(a)        

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int n,m;

ii a[200000];

bool tained[200000];

bool compare(ii a,ii b)
{
	if(a.se>b.se)
		return true;
	if(a.se==b.se)
	{
		if(a.fi<b.fi)
			return true;
		else return false;
	}
	return false;
}

map<int,vi> mapu;

int output = 0;


signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
    	cin>>a[i].fi>>a[i].se;
    	mapu[a[i].fi].pb(a[i].se);
    }
    multiset<int,greater<int>> Q;
    int valu = 0;
   // cout<<m;
    while(valu<=m)
    {
    	if(mapu.find(valu)!=mapu.end())
    	{
    	  for(int i =0;i<mapu[valu].size();i++)
    	       Q.insert(mapu[valu][i]);
    	}
    	 if(!Q.empty())
    	{
    	  output += *(Q.begin());
    	  Q.erase(Q.begin());
    	}
    	 valu++;
    }
    cout<<output;
	return 0;
}

Measured memory_bytes: 12544
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <string>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int n, k, sum=0;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    rep(i, k){
        sum += p[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define pb push_back
#define lt (st[p][0])
#define rt (st[p][1])
#define x first
#define y second
template<typename T>inline void check_min(T a,T &b){if(a<b)b=a;}
template<typename T>inline void read(T &x)
{
	char c=x=0;
	for(c=getchar();!isdigit(c);c=getchar());
	for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48);
}
namespace nymtql
{
	typedef long long ll;
	typedef std::pair<ll,ll> pii;
	const int N=140000;
	const ll INF=214748364700000ll;
	int st[N][2],w[N];
	int n;
	ll lim;
	void initialize()
	{
		read(n);
		for(int i=2,a;i<=n;i++)
			read(a),read(w[i]),st[a][st[a][0]!=0]=i;
	}

	std::vector<pii> s[N],vl,vr;
	bool cmp(pii a,pii b){return a.x>b.x;}
	bool dfs(int p=1)
	{
		s[p].clear();

		if(!lt){s[p].pb(pii(w[p],w[p]));return 1;}
		if(!dfs(lt) || !dfs(rt))return 0;

		vl.clear(),vr.clear();

		for(auto it:s[lt])vl.pb(it),vl.pb(pii(it.y,it.x));
		for(auto it:s[rt])vr.pb(it),vr.pb(pii(it.y,it.x));
		if(vl.size()>vr.size())std::swap(vl,vr);
		std::sort(vl.begin(),vl.end(),cmp);
		std::sort(vr.begin(),vr.end());

		std::vector<pii>::iterator ind=vr.begin();
		ll tmp=INF;
		for(auto it:vl)
		{
			for(;ind!=vr.end() && ind->x+it.x<=lim;ind++)check_min(ind->y,tmp);
			if(tmp<INF)s[p].pb(pii(it.y,tmp));
		}

		for(std::vector<pii>::iterator it=s[p].begin();it!=s[p].end();it++)
			it->x+=w[p],it->y+=w[p];

		return !s[p].empty();
	}

	ll getans()
	{
		ll u=(ll)N*N,d=0;
		while(u>d)
		{
			lim=(u+d)>>1;

			if(dfs())u=lim;
			else d=lim+1;
		}
		return d;
	}
	void solve()
	{
		initialize();
		printf("%lld\n",getans());
	}
}
int main()
{
	nymtql::solve();
	return 0;
}


Measured memory_bytes: 29288
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)


class DP{
public:
	int cost;
	int x;
	
	DP(){}
	DP(int xx, int cc){
		cost = cc;x=xx;
	}
	
	bool operator< (const DP &opp) const {
		return cost>opp.cost;
	}
};
int d[4] = {-3, -1, 3, 1};

int swap(int t, int x, int y){
	static int d[9] = {1e0,1e1,1e2,1e3,1e4,1e5,1e6,1e7,1e8};
	int ret = t;
	ret -= (t/d[x])%10 * d[x] + (t/d[y])%10 * d[y];
	ret += (t/d[x])%10 * d[y] + (t/d[y])%10 * d[x];
	return ret;
}

main(){
	int ch,cv;
	while(cin >> ch >> cv, ch || cv){
		int from=0, to=0;
		REP(i, 9){
			int x;
			cin >> x;
			from = from*10+x;
		}
		REP(i, 9){
			int x;
			cin >> x;
			to = to*10+x;
		}
		priority_queue<DP> dp;
		DP S;
		dp.push(DP(from, 0));
		
		map<int, int> memo;
		memo[from] = 0;
		while(!dp.empty()){
			S = dp.top();
			dp.pop();
			if(S.x == to) break;
			if(memo.count(S.x) && memo[S.x] < S.cost) continue;
			
			int idx = 0;
			for(int i=S.x;i%10;i/=10) idx ++;
			REP(i, 4){
				int next = (idx + d[i] + 9) % 9;
				DP T=S;
				T.x = swap(T.x, idx, next);
//				printf("%d = swap(%d, %d, %d)\n", T.x, S.x, idx, next);
				T.cost += (i&1) ? ch : cv;
				if(memo.count(T.x) && memo[T.x] <= T.cost) continue;
				memo[T.x] = T.cost;
				dp.push(T);
			}
		}
		cout << S.cost << endl;
	}
	return 0;
}

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

int n[100],i=0;

void push(int a){
  n[i]=a;
  i++;
}

int top(){
  return n[i-1];
}

int pop(){
  i--;
  return n[i];
}
int main(){
  int a,b;
  char c[100];
  while(scanf("%s",c) != EOF){
    if(c[0]=='+'){
      a=top();
      pop();
      b=top();
      pop();
      push(a+b);
    }else if(c[0]=='-'){
      a=top();
      pop();
      b=top();
      pop();
      push(b-a);
    }else if(c[0]=='*'){
      a=top();
      pop();
      b=top();
      pop();
      push(a*b);
    }else{
      push(atoi(c));
    }
  }
  cout<<top()<<endl;
  return 0;
}



Measured memory_bytes: 3232
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


typedef pair<ll, pair<ll, ll>> pt;

int main()
{
    ll h, w;
    cin >> h >> w;
    ll ch, cw;
    cin >> ch >> cw;
    ll dh, dw;
    cin >> dh >> dw;
    vector<string> s(h + 2);
    s[0] = string(w + 2, '#');
    s[h + 1] = string(w + 2, '#');
    rrepp(i, 1, h) {
        string ss;
        cin >> ss;
        s[i] = '#' + ss + '#';
    }
    ll vx[4] = { 1, 0, -1,  0 };
    ll vy[4] = { 0, 1,  0, -1 };
    priority_queue<pt, vector<pt>, greater<pt>> que;
    que.emplace(0, pair<ll, ll>(ch, cw));
    while (!que.empty()) {
        pt p = que.top();
        que.pop();
        ll c = p.first;
        ll x = p.second.first;
        ll y = p.second.second;
        if (x == dh && y == dw) {
            cout << c << endl;
            return 0;
        }
        if (s[x][y] != '.') {
            continue;
        }
        s[x][y] = '-';
        rep(i, 4) {
            ll xx = x + vx[i];
            ll yy = y + vy[i];
            if (s[xx][yy] == '.') {
                que.emplace(c, pair<ll, ll>(xx, yy));
            }
        }
        rrepp(i, -2, 2) {
            rrepp(j, -2, 2) {
                if (abs(i) + abs(j) <= 1) {
                    continue;
                }
                ll xx = x + i;
                ll yy = y + j;
                if (0 < xx && xx <= h && 0 < yy && yy <= w && s[xx][yy] == '.') {
                    que.emplace(c + 1, pair<ll, ll>(xx, yy));
                }
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 5536
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("yes")
    else:print("no")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
c = []
e = ["#" for i in range(w+2)]
c.append(''.join(e))
for i in range(h):
    d = ["#",a[i],"#"]
    c.append(''.join(d))
e = ["#" for i in range(w+2)]
c.append(''.join(e))
for  i in range(h+2):
    print(c[i])

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

int main(){
  int n,m;
  int i,j;
  scanf("%d %d", &n, &m);
  
  int ary[n][m];
  int vec[m];

  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&ary[i][j]);
    }
  }
  for (i = 0; i < m; i++){
    scanf("%d", &vec[i]);
  }

  int sum;
    for (i = 0; i < n; i++){
      sum=0;
      for (j = 0; j < m; j++){
        sum +=  ary[i][j]*vec[j];
      }
      cout<< sum <<endl;
    }

  return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <queue>
#include <math.h>
#include <set>
#define Epsilon 0.000001
using namespace std;

double cal1( double x, double y ) {
    return sqrt( x * x + y * y );
}

double cal2(double a, double b, double c, double d){
	return a*b+c*d;
}


int main(){

	double D, px, py, vx, vy;
	double d;
	while(1){
		scanf("%lf", &D);
		if(D==0||D<Epsilon)
			break;
		scanf("%lf%lf%lf%lf", &px, &py, &vx, &vy);
		double a = cal1(px, py);
		double b = cal1(vx, vy);
		// printf("%lf %lf\n", a, b);
		if(fabs(py*vx-vy*px)<Epsilon){
            double x1=a*vx/b,y1=a*vy/b;
            if(fabs(x1-px)<Epsilon && fabs(y1-py)<Epsilon){
                d=2-a;
            }else{
                d=a;
            }       
        }else{
            d=D+1;
        }
         
        if(d>D||fabs(d-D)<Epsilon)
        	printf("impossible\n");
        else printf("%.8lf\n",d);
 
	}
	return 0;
}

Measured memory_bytes: 2640
N, D = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

D_2 = D*D
ans = 0
for xy in XY:
    x = xy[0]
    y = xy[1]
    dis_2 = x**2 + y**2
    if dis_2 <= D_2:
        ans += 1

print(ans)

Measured memory_bytes: 45320
N, x = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
sorted = as.sort
ans = 0
sum = 0
sorted.each.with_index do |n, i|
  break if sum + n > x
  break if i + 1 == N && sum + n != x
  ans += 1
  sum += n
end
puts ans


Measured memory_bytes: 1916
h, w = map(int, input().split())
a = [input() for i in range(h)]

while "." * w in a:
  a.remove("." * w)
hh = len(a)
  
a = ["".join(h_line) for h_line in zip(*a)]
while "." * hh in a:
  a.remove("." * hh)
    
for line in zip(*a):
  print("".join(line))

Measured memory_bytes: 3060
N = int(input())
a = [[] for _ in range(N)]
for i in range(N):
  A_i = int(input())
  for j in range(A_i):
    a[i].append(list(map(int, input().split())))

max_person = 0
for i in range(2**N):
  judge = True
  bin_num = bin(i)
  times = 0
  end = False
  for j in reversed(bin_num):
    if j == "b":
      break
    if j == "1":
      for k in a[times]:
        if ((i >> k[0]-1) & 1) != k[1]:
          judge = False
    times += 1
  true_person = bin_num.count("1")
  if judge == True:
    max_person = max(max_person, true_person)
print(max_person)

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

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            var a = new int[n, n];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    if (i == j) a[i, j] = 0;
                    else a[i, j] = -1;
            for (int i = 0; i < m; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var w1 = int.Parse(line2[0]);
                var w2 = int.Parse(line2[1]);
                var w3 = int.Parse(line2[2]);
                a[w1, w2] = w3; a[w2, w1] = w3;
            }
            var s = new List<int>();
            var res = getStlist(a, s);
            Console.WriteLine(res);
        }
    }
    public static int getStlist(int[,] a, List<int> s)
    {
        var n = a.GetLength(0);
        var a1 = 0;
        var totalmincost = 0;
        while (true)
        {
            s.Add(a1);
            if (s.Count() == n) return totalmincost;
            var nexta1 = -1; var mincost = 999999;
            foreach (var x in s)
                for (int i = 0; i < n; i++)
                    if (!s.Contains(i) && a[x, i] != -1 && a[x, i] < mincost) { nexta1 = i; mincost = a[x, i]; }
                    else a1 = nexta1;
            totalmincost += mincost;
        }
    }
}

Measured memory_bytes: 10032
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    string number;
    cin >> number;
    int n[4];
    for(int i=0;i<4;i++){
        n[i] = (number[i]-'0');
    }

    char op[4];
    for(int i=0;i<(1<<4);i++){
        int cal=0;
        for(int j=0;j<4;j++){
            if((i>>j&1)==1){
                cal += n[j];
                op[j]='+';
            }else{
                cal -= n[j];
                op[j]='-';
            }
        }
        // for(int j=0;j<3;j++){
        //     cout << number[j] << op[j+1];
        // }
        // cout << number[3] << '='<<cal << endl;
        
        if(cal==7){
            for(int j=0;j<3;j++){
                cout << number[j] << op[j+1];
            }
            cout << number[3] << "=7";
            break;
        }
    }
}


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

int main(){
  int64_t a,b,c,d;
  int64_t x,y,z,w;
  cin >> a >> b >> c >> d;
  x = a*c;
  y = b*d;
  z = a*d;
  w = b*c;
  cout << max(x,max(y,max(z,w)));
}


Measured memory_bytes: 3632
import re
S = input()
'''
メタ文字：
^ = 文字列の先頭、
| = OR
+ = 直前のパターンを1回以上繰り返し、
$ = 文字列の末尾
'''
if re.match("^(dream|dreamer|erase|eraser)+$", S):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,m,sum=0,mul=1,flag =0,maxi=LONG_LONG_MIN,mini =LONG_LONG_MAX;
    cin>>n>>m;
    sum=(n-1)*n/2 + m*(m-1)/2;
    cout<<sum<<endl;
}


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

constexpr int MN = 100005;
unsigned long long s = 0;
ll n, a[MN];
ll max_p[MN];

int main() {
  cin >> n;
  for (int i = 0; i <= n; ++i) {
    cin >> a[i];
    s += a[i];
  }
  if (a[0] > 0) {
    if (n == 0 && a[0] < 2) {
      cout << a[0] << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  max_p[0] = 1;
  for (int i = 1; i < n; ++i) {
    max_p[i] = min((ll)s + 1, max_p[i - 1] * 2 - a[i]);
  }
  max_p[n] = 0;

  for (int i = n - 1; i >= 0; --i) {
    if (max_p[i] < 1 || max_p[i] * 2 < max_p[i + 1] + a[i + 1]) {
      cout << -1 << endl;
      return 0;
    }
    max_p[i] = min(max_p[i], max_p[i + 1] + a[i + 1]);
    s += max_p[i];
  }
  cout << s << endl;
}

Measured memory_bytes: 5176
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int A,B,C,K;
    bool ans = false;
    cin >> A >> B >> C >> K;

    for(int i = 0;i <= K;i++){
        if(A >= B){
            B *= 2;
        }else if(B >= C){
            C *= 2;
        }else{
            ans = true;
        }
    }

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3128
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

N = int(input())
# L = [int(x) for x in input().split()]
# N, M = map(int, input().split())
# S = input()

ball = [[int(x) for x in input().split()] for _ in range(N)]
dist = {}

for i, a in enumerate(ball):
    x0 = a[0]
    y0 = a[1]

    for j, b in enumerate(ball):
        x1 = b[0]
        y1 = b[1]

        xy = (x1-x0, y1-y0)

        if xy == (0, 0):
            continue

        if not xy in dist:
            dist[xy] = 1
        else:
            dist[xy] += 1

try:
    num = max(dist.values())
except:
    num = 0

print(N - num)


Measured memory_bytes: 39408
#include<iostream>
 
using namespace std;
 
int main() {
	int a, b, c, x, y,money=0;
 
	cin >> a >> b >> c >> x >> y;
 
	if (x > y) {
		if (a+b > c*2) {
			money += y * c * 2;
			x -= y;
		}
		else {
			money += y * b;
		}
		if (a > c*2) 
			money += x * c * 2;
		else
			money += x * a;
	}
	else {
		if (a+b > c*2) {
			money += x * c * 2;
			y -= x;
		}
		else {
			money += x * a;
		}
		if (b > c*2)
			money += y * c * 2;
		else
			money += y * b;
	}
 
	cout << money;
 
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,i,j;
  scanf("%d %d",&n,&m);
  if((n-1)*(n-2)/2<m){
    printf("-1\n");
    return 0;
  }
  m=n*(n-1)/2-m;
  printf("%d\n",m);
  for(i=1;i<=n;i++){
    for(j=i+1;j<=n;j++){
      printf("%d %d\n",i,j);
      if(--m==0)return 0;
    }
  }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

template<typename T>
struct UnionFind {
    i64 sz;

    vector<T> parent;
    vector<i64> rank;

    UnionFind(i64 n) : sz(n) {
        parent.assign(n, 0);
        REP(i, n) {
            parent[i] = i;
        }
        rank.assign(n, 1);
    }

    T find(T t) {
        if (parent[t] == t) return t;
        return parent[t] = find(parent[t]);
    }

    bool unite(T t1, T t2) {
        t1 = find(t1);
        t2 = find(t2);
        if (t1 == t2) return false;

        if (rank[t1] < rank[t2]) swap(t1, t2);
        parent[t2] = t1;
        rank[t1] += rank[t2];
        return true;
    }

    i64 get_rank(T t) {
        return rank[find(t)];
    }

    bool same(T t1, T t2) {
        return find(t1) == find(t2);
    }
};

int main() {
    i64 N, M; cin >> N >> M;
    vector<i64> A(M);
    vector<i64> B(M);
    REP(i, M) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }

    vector<i64> inconv(M);
    UnionFind<i64> uf(N);
    inconv[M - 1] = (N * (N - 1)) / 2;
    RREP(i, M) {
        if (i == 0) continue;
        i64 decl = uf.get_rank(A[i]) * uf.get_rank(B[i]);
        inconv[i - 1] = inconv[i];
        if (uf.unite(A[i], B[i])) inconv[i - 1] -= decl;
    }
    REP(i, M) {
        cout << inconv[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5248
n, m = gets.chomp.split.map(&:to_i)
sc = []

m.times do |i|
  sc << gets.chomp.split.map(&:to_i)
end

# p sc
#
d = n

if d == 1
  l = 9
elsif d == 2
  l = 99
elsif d == 3
  l = 999
end

0.upto(999) do |i|

  if d == 1
    next if i > 10
  elsif d == 2
    next if i < 10
    next if i > 99
  elsif d == 3
    next if i < 100
  end





  char = i.to_s

  flag = true




  sc.each do |s, c|

    # if i == 702
    #   # p char[0]
    #   p s
    #   p char[s-1]
    #   p c
    # end
    flag = false if char[s-1] != c.to_s
  end

  if flag == true
    puts i
    exit
  end
end

puts -1

Measured memory_bytes: 1788
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
 freopen("input","r",stdin);
 freopen("output","w",stdout);
*/

ll B = 1E18;

ll DP[100010];
ll H[100010];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    for (int i = 0;i < N;i++) cin >> H[i];
    for (int i = 0;i < N;i++) DP[i] = B;
    DP[0] = 0;
    for (int i = 0;i < N;i++) {
        for (int j = 1;j <= K;j++) {
            if (i + j < N) DP[i + j] = min(DP[i + j], DP[i] + abs(H[i] - H[i + j]));
        }
    }
    cout << DP[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
questions = []
maxNum = 0
for i in range(N):
    tmp = int(input())
    questions.append(tmp)
questions.sort()
notTenLine = [i for i in questions if i % 10 != 0]
if sum(questions) % 10 != 0:
    print(sum(questions))
elif len(notTenLine) == 0:
    print(0)
else:
    print(sum(questions)-min(notTenLine))

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

R = INT()
print(2*3.1415926535*R)


Measured memory_bytes: 10044
#include <cstdio>
#include <iostream>
using namespace std;
int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	int n;
	cin >> n;

	int cnt1=0,cnt2=0,cnt4=0;
	for(int i=0 ; i<n ; ++i) {
		int a;
		cin >> a;
		if (a%4 == 0){
			cnt4++;
		}else if (a%2==0){
			cnt2++;
		}else{
			cnt1++;
		}
	}

	if (0 < cnt2){
		cnt1++;
	}
	const char *ans = "No";
	if (cnt1-1 <= cnt4){ans = "Yes";}
	printf("%s\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n; cin>>n;
	cout<<"ABC";
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int data[2];
	int i, j;
	
	while(1){
		scanf("%d %d", &data[0], &data[1]);
		if(data[0] == 0 && data[1] == 0){
			return 0;
		}
		
		for(i=0 ; i < data[0] ; i++){
			for(j=0 ; j < data[1] ; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}

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

int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  int MAX=0,MAXi;
  
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    
    if(a.at(i)>MAX){
      MAX=a.at(i);
      MAXi=i;
    }
    
  }
  
  for(int i=0;i<N;i++){
    if(i==MAXi){
      int MAX2=0;
      for(int j=0;j<N;j++){
        if(j!=i)
          MAX2=max(MAX2,a.at(j));
      }
      cout<<MAX2<<endl;
    }
    else{
      cout<<MAX<<endl;
    }
  }
}



Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    long long K, N;
    cin >> K >> N;
    vector<long long> A(N);
    
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    A.push_back(K + A[0]);
    
    long long sa = 0;
    for(int i = 0; i < N; i++){
        sa = max(sa, A[i+1] - A[i]);
    }
    
    cout << K - sa << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll turn = 0;
  while (1) {
    if (a <= 0) {
      cout << "No" << endl;
      break;
    } else if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    turn++;
    if (turn % 2 == 1) {
      c -= b;
    } else {
      a -= d;
    }
  }
  return 0;
}

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

int main(){
  int D,N;
  cin >> D >> N;
  if(D==0){
    if(N==100){
      cout << "101" << endl;
    }else{
      cout << N << endl;
    }
  }else if(D==1){
    if(N==100){
      cout << "10100" << endl;
    }else{
      cout << N*100 << endl;
    }  
  }else{
    if(N==100){
      cout << "1010000" << endl;
    }else{
      cout << N*10000 << endl;
    }
  }
}

Measured memory_bytes: 256
/*#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define ll long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;*/

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

#define LL long long
#define ll long long

const LL MOD=1e9+7;
const int maxn=1e5+10;

//const int INF=0x7ffffff;
//const int magic=348;
//const int zero=200;

int n;
//LL p,p1;
LL id1,id2;
LL a[100048];
int v[100048];
int cnt[100048];

LL fac[100048],finv[100048],inv[100048];

void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<maxn;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}

int main ()
{
	//LL i;
	//cin>>n;
	/*memset(cnt,0,sizeof(cnt));
	for (i=1;i<=n+1;i++)
	{
		cin>>a[i];
		cnt[a[i]]++;
	}
	p=p1=0;
	for (i=1;i<=n+1;i++)
		if (cnt[a[i]]==2)
			if (p1==0) p1=i; else p=i;*/
	/*	memset(a, 0, sizeof(a));
    memset(v, 0, sizeof(v));
    for(ll i = 1; i <= n + 1; ++i){
        cin >> a[i];
        v[a[i]]++;
    }
    for(ll i = 1; i <= n + 1; ++i){
        if(v[a[i]] == 2 && !id1){
            id1 = i;
        }
        else if(v[a[i]] == 2) {
            id2 = i;
        }
    }
	LL ans;
	make();
	LL L=max(id1-1,0LL),R=max(n+1-id2,0LL);
	for (ll i=0;i<=n;i++)
	{
		ans=C(n+1,(i+1)*1LL);
		ans-=C(L+R,i*1LL);
		if (ans<0) ans+=MOD;
		cout<<ans<<endl;
	}
	return 0;*/
	ll n;
    make();
    ll id1 = 0, id2 = 0;
    cin >> n;
    memset(a, 0, sizeof(a));
    memset(v, 0, sizeof(v));
    for(ll i = 1; i <= n + 1; ++i){
        cin >> a[i];
        v[a[i]]++;
    }
    for(ll i = 1; i <= n + 1; ++i){
        if(v[a[i]] == 2 && !id1){
            id1 = i;
        }
        else if(v[a[i]] == 2) {
            id2 = i;
        }
    }
    ll L = max(id1 - 1LL, 0LL), /*M = id2 - id1 - 1LL*/ R = max(n + 1LL - id2, 0LL);
    ll res = 0;
    for(ll i = 1; i <= n + 1; ++i){
        res = C(n + 1, i * 1LL);
        res -= C(L + R, (i - 1) * 1LL);
        if(res < 0)res += MOD;
        cout << res << '\n';
    }
    return 0;
}

Measured memory_bytes: 4736
from itertools import accumulate

n, k = map(int, input().split())
p = list(map(int, input().split()))

new_p = []
temp = []
for i in p:
    new_p.append(((i * (i + 1)) / 2) / i)
q = [0] + new_p
q = list(accumulate(q))

for i in range(len(q) - k):
    temp.append(q[i + k] - q[i])
print(max(temp))

Measured memory_bytes: 30276
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> prime;
void init(){
	for(int i=2;i<999999;i++){
		bool isprime=true;
		for(vector<int>::iterator p(prime.begin());p!=prime.end();p++){
			if((*p)*(*p)>i)break;
			if(i%*p==0){
				isprime=false;
				break;
			}
		}
		if(isprime){
			prime.push_back(i);
		}
	}
}
int main(){
	int n;
	init();
	while(cin>>n){
		cout<<upper_bound(prime.begin(),prime.end(),n)-prime.begin()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1588
object Main {


  def main(args: Array[String]): Unit = {

    val Array(n,m) = io.StdIn.readLine().split(" ").map(_.toInt)

    val hights = io.StdIn.readLine().split(" ").map(_.toInt)

    val roads = for(i <- 0 until m) yield {
      io.StdIn.readLine().split(" ").map(_.toInt)
    }

    val highest = new Array[Int](n)

    for(r <- roads) {
      highest(r(0)-1) = highest(r(0)-1) max hights(r(1) -1)
      highest(r(1)-1) = highest(r(1)-1) max hights(r(0) -1)
    }

    val a = (hights zip highest).count(t => t._1 > t._2)
    println(a)

  }


}

Measured memory_bytes: 70612
INF = 10**8
N = int(input())
S = [input() for _ in range(N)]
k = [INF] * 26

for s in S:
    for i in range(26):
        k[i] = min(k[i], s.count(chr(ord('a') + i)))

ret = ""
for i in range(26):
    ret += chr(ord('a') + i) * k[i]
print(ret)

Measured memory_bytes: 3064
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
S = [input() for h in range(H)]
q = deque([(0, 0)])
# s : 0, 0
# g : H - 1, W - 1
visited = [[False] * W for i in range(H)]
dw = [0, 1, 0, -1]
dh = [1, 0, -1, 0]
dist = [[INF] * W for i in range(H)]
dist[0][0] = 1

dic = defaultdict(int)

for h in range(H):
    for w in range(W):
        dic[S[h][w]] += 1

if S[0][0] == "#":
    print("-1")
    exit()
while q:
    h, w = q.popleft()
    # if S[h][w] == "#":
    for i in range(4):
        nw = w + dw[i]
        nh = h + dh[i]
        if 0 <= nw < W and 0 <= nh < H:
            if S[nh][nw] != "#" and visited[nh][nw] == False:
                # dist[nh][nw] = min(dist[h][w] + 1, dist[nh][nw])
                dist[nh][nw] = dist[h][w] + 1
                visited[nh][nw] = True
                q.append((nh, nw))
# print(visited)
# print(*dist, sep="\n")
if dist[H-1][W-1] == INF:
    print(-1)
else:
    print(dic["."] - dist[H-1][W-1])
            

    





Measured memory_bytes: 10520
from collections import Counter

n = int(input())
d = list(map(int,input().split()))

if d[0] != 0:
    print(0)
    exit()

mod = 998244353

set_d = set(d)
list_d = list(set_d)
list_d.sort()
dict_d = Counter(d)

if dict_d[0] == 1:
    pass
else:
    print(0)
    exit()

ans = 1
cnt = 1
temp = -1
check = 1

for i in list_d:

    if i != temp + 1:
        print(0)
        exit()
        
    temp = i
    cnt = dict_d[i]
    ans = (ans * (check**cnt))%mod
    check = cnt
    
print(ans)


Measured memory_bytes: 26336
import java.util.*;

public class Main {
  public static void main(String[] args ) {
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int T = sc.nextInt();
    int A = sc.nextInt();
    
    double min = Double.MAX_VALUE;
    int ret = -1;
      
    for(int i = 0; i< N ; i++){
      double temp = Math.abs(A-(T-sc.nextInt()*0.006));
      if(min>temp){
        min = temp;
        ret = i+1;
      }
    }
    System.out.println(ret);
  }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        string s; cin>>s;
        string t="AKIHABARA";
        if(s.size()>t.size())
        {
                cout<<"NO"<<endl;
                return 0;
        }
        int id=0;

        if(s[id]=='A')id++;

        if(s[id]=='K')id++;
        else return cout<<"NO"<<endl,0;

        if(s[id]=='I')id++;
        else return cout<<"NO"<<endl,0;

        if(s[id]=='H')id++;
        else return cout<<"NO"<<endl,0;

        if(s[id]=='A')id++;

        if(s[id]=='B')id++;
        else return cout<<"NO"<<endl,0;

        if(s[id]=='A')id++;

        if(s[id]=='R')id++;
        else return cout<<"NO"<<endl,0;

        if(s[id]=='A')id++;

        cout<<"YES"<<endl;
}

Measured memory_bytes: 256
s=list(input())


c=[]
for i in range(3):
  cnt=0
  if s[i]=='R':
    
    
    while i<3:
      if s[i]=='R':
        cnt+=1
        i+=1
        
      else:
        break
        
  c.append(cnt)
    
print(max(c))

Measured memory_bytes: 9056