akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SIZE 5005
#define MX 10000005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll inv[MX],fac[MX],finv[MX];
ll dp[SIZE][SIZE];
ll naive[SIZE][SIZE];
ll dp2[SIZE];
ll rt[SIZE];

void make()
{
	inv[1]=1;
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	for(int i=2;i<MX;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;
	}
	rt[0]=1;
	for(int i=1;i<SIZE;i++) rt[i]=rt[i-1]*2LL%MOD;
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int main()
{
	make();
	int n,A;
	scanf("%d %d",&n,&A);
	for(int i=0;i<=A;i++)
	{
		dp2[i]=1;
		for(int j=2;j<=i;j++)
		{
			dp2[i]-=inv[i];
			if(dp2[i]<0) dp2[i]+=MOD;
		}
	}
	int B=n-A;
	dp[0][0]=1;
	ll ret=0;
	for(int i=0;i<=A;i++)
	{
		ll sum=0;
		for(int j=0;j<=A;j++)
		{
			if(i>0||j>0)
			{
				ll now=sum;
				if(i>0&&j>0)
				{
					now+=dp[i-1][j-1]*inv[A-j+1]%MOD;
					if(now>=MOD) now-=MOD;
				}
				dp[i][j]=now;
				if(j>0)
				{
					sum+=dp[i][j-1]*inv[A-j+1]%MOD;
					if(sum>=MOD) sum-=MOD;
				}
				if(dp[i][j]>0&&i<=B)
				{
					ret+=C(B+j-i-1,j-1)*dp[i][j]%MOD*dp2[A-j]%MOD;
					if(ret>=MOD) ret-=MOD;
				}
			}
		}
	}
	printf("%lld\n",ret*fac[A]%MOD*fac[B]%MOD);
	/*
	ll ret2=0;
	naive[A][B]=fac[A]*fac[B]%MOD;
	for(int i=A;i>=0;i--)
	{
		for(int j=B;j>=0;j--)
		{
			for(int k=1;k<=i;k++)
			{
				for(int l=0;l<=j;l++)
				{
					if(k+l==1) continue;
					ll vl=naive[i][j]*C(k+l-1,k-1)%MOD*inv[i]%MOD;
					naive[i-k][j-l]+=vl;
					if(naive[i-k][j-l]>=MOD) naive[i-k][j-l]-=MOD;
				}
			}
		}
	}
	for(int i=0;i<=A;i++)
	{
		ret2+=naive[i][0]*dp2[i]%MOD;
		if(ret2>=MOD) ret2-=MOD;
	}
	printf("%lld\n",ret2);*/
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    int l = x - k, r = x + k;
    rep(l+1, r) {
        cout << i;
        if (i < r) cout << " ";
    }
    cout << endl;

    return 0;
}


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

using namespace std;

int A[100005];

long long solve(long long sum, int poz, int n, int sgn)
{
    long long rez=0;
    sum+=A[poz];

    if(sum*sgn<=0)
    {
        rez=abs(sum-sgn);
        sum=sgn;
    }

    if(poz!=n)
        rez=rez+solve(sum,poz+1,n,-sgn);

    return rez;
}

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

    int n;
    cin>>n;

    for(int i=1; i<=n; i++)
        cin>>A[i];

    cout<<min(solve(0,1,n,-1),solve(0,1,n,1))<<"\n";
    return 0;
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int d;
  cin>>d;
  if(d==25)cout<<"Christmas"<<endl;
  if(d==24)cout<<"Christmas Eve"<<endl;
  if(d==23)cout<<"Christmas Eve Eve"<<endl;
  if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
  
}

Measured memory_bytes: 256
#https://atcoder.jp/contests/abc151/tasks/abc151_c

n,m=map(int,input().split())
res_ac=[-1 for i in range(n)]
tmp_wa=[0 for i in range(n)]
ac=0
wa=0


for i in range(m):
    sbmt=input().split()
    problem_num=int(sbmt[0])-1
    problem_ans=sbmt[1]
    if (problem_ans=="WA")&(res_ac[problem_num]==-1):#まだACしてない
        tmp_wa[problem_num]+=1
    if (problem_ans=="AC")&(res_ac[problem_num]==-1):
        res_ac[problem_num]=1
        ac+=1
        wa+=tmp_wa[problem_num]

print(ac,wa)


Measured memory_bytes: 52016
#include <stdio.h>
#include <string.h>

int main(){
	int n,i,x[10],temp,j;
	for(i = 0;i < 10;i++){
		scanf("%d",&x[i]);
	}
	n = 10;
    for (i = 0; i < n - 1; i++) {
        for (j = n - 1; j > i; j--) {
            if (x[j - 1] > x[j]) {  
                temp = x[j];        
                x[j] = x[j - 1];
                x[j - 1]= temp;
            }
        }	
    }
    
     for(i = 0; i < 3; i++){
    	printf("%d\n",x[9 - i]);
     }
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > a;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if(x <= m) {
            a.push_back(make_pair(x, y));
        }
    }
    ll ans = 0;
    sort(a.begin(), a.end());
    priority_queue<int> pq;
    ll x = 0;
    for(int i = 1; i <= m; i++) {
        while(x < a.size() and a[x].first <= i) {
            pq.push(a[x].second);
            x++;
        }
        if(pq.size()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1908
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  string s;
  cin >> s;

  FOR(i, 0, s.size()){
    if(i%2==0) cout << s[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 592
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int h1 = sc.nextInt();
    int m1 = sc.nextInt();
    int h2 = sc.nextInt();
    int m2 = sc.nextInt();
    int k = sc.nextInt();
    
    int min1 = (h2 - h1) * 60;
    int min2 = (m2 - m1);
    int min = min1 + min2;
    
    int ans = (min - k);
    
    System.out.println(ans);
  }
}
    

Measured memory_bytes: 35780
#include <stdio.h>
#include <string.h>
  
int main(void){
  char word[1010],temp[10],p[1010];
  int i,j,k,t,a,b,trial;
  
  scanf("%s",word);  scanf("%d",&trial);
  for(i=0;i<trial;i++){
    scanf("%s",temp);
    if(strcmp(temp,"print")==0){
      scanf("%d%d",&a,&b);
      for(j=a;j<=b;j++)  printf("%c",word[j]);
      printf("\n");
    } else if(strcmp(temp,"reverse")==0) {
      scanf("%d%d",&a,&b);
      for(j=a,k=b;j<=k;j++,k--){
        t=word[j];
        word[j]=word[k];
        word[k]=t;
      }
    } else if(strcmp(temp,"replace")==0) {
      scanf("%d%d",&a,&b);  scanf("%s",p);
      for(j=a;j<=b;j++)  word[j]=p[j-a];
    }
  }
  
  return 0;
}

Measured memory_bytes: 576
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    cin >> N;
    if(!cin) return;
    vector<bool> aA(100001);
    ll cross = 0;
    for (int i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        if(aA[a]){
            cross++;
        }
        else aA[a] = true;
    } // end i
    ll d = cross + cross % 2;
    cout << N - d << endl;
    
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    s[1] ^= 'R' ^ 'B';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b,c;cin>>a>>b>>c;
  if(c>=a && c<=b){
    P("Yes");
  }else{
    P("No");
  }
  return 0;
}


Measured memory_bytes: 256
// ITP1_4_A.js
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});
/* 入力は 
3 2
*/
var s = 0;
reader.on('close', () => {
    var a,b;
    [a,b]  = lines[0].trim().split(' ').map(x=>parseInt(x));

    console.log(aux(a,b).join(' '));
});

function aux(a,b)
{
    var c = a/b;

    return([Math.floor(c).toString(),(a%b).toString(),c.toFixed(5)]);
}


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

int main(){
  int h,w;
  cin >> h >> w;
  char a[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(a[i][j] == '#' && a[i][j+1] != '#' && a[i][j-1] != '#' && a[i+1][j] != '#' && a[i-1][j] != '#'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char buf[1<<20],*p1,*p2;
#define GC (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)
template<class T> inline void read(T &n){
	char ch=GC;T w=1,x=0;
	while(!isdigit(ch)){if(ch=='-') w=-1;ch=GC;}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=GC;}
	n=x*w;
}
const int maxn=100005;
int N,k,q,n,r[maxn],a[maxn],ans[maxn];
struct query{
	int t,a;
}Q[maxn];
int lazy[maxn<<2][2],lazya[maxn<<2],num[maxn<<2];
inline void putdown(int id){
	if(lazy[id][0]){
		lazy[id<<1][0]=lazy[id<<1|1][0]=1;
		lazy[id<<1][1]=lazy[id<<1|1][1]=0;
		lazya[id<<1]=lazya[id<<1|1]=0;
		num[id<<1]=num[id<<1|1]=0;
	}
	if(lazy[id][1]){
		lazy[id<<1][0]=lazy[id<<1|1][0]=0;
		lazy[id<<1][1]=lazy[id<<1|1][1]=1;
		lazya[id<<1]=lazya[id<<1|1]=0;
		num[id<<1]=num[id<<1|1]=N;
	}
	if(lazya[id]){
		lazya[id<<1]+=lazya[id];
		lazya[id<<1|1]+=lazya[id];
		num[id<<1]+=lazya[id];
		num[id<<1|1]+=lazya[id];
	} 
	lazy[id][0]=lazy[id][1]=lazya[id]=0;
}
void build(int l,int r,int id){
	if(l==r){
		num[id]=a[l];
		return;
	} 
	int mid=(l+r)>>1;
	build(l,mid,id<<1),build(mid+1,r,id<<1|1);
}
int query(int l,int r,int id,int x){
	if(l==r) return num[id];
	int mid=(l+r)>>1;
	putdown(id);
	if(x<=mid) return query(l,mid,id<<1,x);
	return query(mid+1,r,id<<1|1,x);
}
void modify(int l,int r,int id,int L,int R,int opt){
	if(L<=l&&r<=R){
		lazy[id][opt]=1;
		lazy[id][opt^1]=0;
		lazya[id]=0;
		num[id]=opt*N;
		return;
	}
	int mid=(l+r)>>1;
	putdown(id);
	if(L<=mid) modify(l,mid,id<<1,L,R,opt);
	if(R>mid) modify(mid+1,r,id<<1|1,L,R,opt);
}
void change(int l,int r,int id,int L,int R,int x){
	if(L<=l&&r<=R){
		lazy[id][0]=lazy[id][1]=0;
		lazya[id]+=x;
		num[id]+=x;
		return;
	}
	int mid=(l+r)>>1;
	putdown(id);
	if(L<=mid) change(l,mid,id<<1,L,R,x);
	if(R>mid) change(mid+1,r,id<<1|1,L,R,x);
}
void solve(int num,int opt){
	if(opt>0){
		int l=1,r=n,res=n+1;
		while(l<=r){
			int mid=(l+r)>>1;
			if(query(1,n,1,mid)+num>=N) res=mid,r=mid-1;
			else l=mid+1;
		}
		if(res>1) change(1,n,1,1,res-1,num); 
		if(res<=n) modify(1,n,1,res,n,1);
	}
	else{
		int l=1,r=n,res=0;
		while(l<=r){
			int mid=(l+r)>>1;
			if(query(1,n,1,mid)-num<=0) res=mid,l=mid+1;
			else r=mid-1; 
		}
		if(res<n) change(1,n,1,res+1,n,-num);
		if(res) modify(1,n,1,1,res,0);
	}
} 
int main(){
	read(N),read(k);
	for(int i=1;i<=k;i++) read(r[i]);
	read(q);
	for(int i=1;i<=q;i++){
		read(Q[i].t),read(Q[i].a);
		a[i]=Q[i].a;
	}
	sort(a+1,a+q+1);
	n=unique(a+1,a+q+1)-(a+1);
	for(int i=1;i<=q;i++)
	Q[i].a=lower_bound(a+1,a+n+1,Q[i].a)-a;
	build(1,n,1);
	int now=-1;
	for(int i=1,j=0;i<=q;i++){
		while(j<k&&r[j+1]<=Q[i].t){
			solve(r[j+1]-r[j],now);
			now=-now;
			j++;
		}
		int tmp=query(1,n,1,Q[i].a);
		tmp+=now*(Q[i].t-r[j]);
		if(tmp<0) puts("0");
		else if(tmp>N) printf("%d\n",N);
		else printf("%d\n",tmp);
	}
	return 0;
}

Measured memory_bytes: 9856
#abc064 b
n,m=map(int,input().split())
student=[]
checkpoint=[]
for i in range(n):
    x=list(map(int,input().split()))
    student.append(x)
for i in range(m):
    x=list(map(int,input().split()))
    checkpoint.append(x)

for p in student:
    distance=1001001001
    i=1
    ans=0
    for c in checkpoint:
        d=abs(p[0]-c[0])+abs(p[1]-c[1])
        if distance>d:
            distance=d
            ans=i
        i+=1
    print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  ll n; cin>>n;
  vector<ll> a(5);
  rep(i,0,5) cin>>a[i];
  sort(all(a));
  ll x=a[0];
  co((n-1+x)/x+4);
  
  return 0;
}

Measured memory_bytes: 256
/*
 * 	Roses are red
 * 		Violets are blue
 * 			I cried
 * 				And so did you
*/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
//typedef double f80;
#define double long double
#define pii pair<int,int>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
#define deb cout<<"Line: "<<__LINE__<<" plz "
typedef long long ll;
const ll inf=1e18;
const ll mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powm(ll a, ll b, ll m);

int facs[1000001];
void solve()
{
	int n,p;
	cin>>n>>p;
	if(n==1)
	{
		cout<<p<<endl;
		return;
	}
	int pp=p;
	for(int i=2; i*i<=p; i++)
	{
		while(p%i==0)
		{
			facs[i]++;
			p/=i;
		}
	}
	if(p<=1e6)
		facs[p]++;
	if(pp==p)
	{
		cout<<1<<endl;
		return;
	}
	int ans=1;
	for(int i=2; i<=1e6; i++)
		if(facs[i]/n)
			ans*=powm(i,facs[i]/n,inf);
	cout<<ans<<endl;
}
signed main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
	auto clk=clock();
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	clk=clock()-clk;
	cout<<endl<<endl<< "Time Elapsed: " << ((double)clk)/CLOCKS_PER_SEC <<endl;
#endif
	return 0;
}
ll powm(ll a,ll b, ll m) {
	ll te=1;
	while(b) {
		if(b&1) te=(te*a)%m;
		a=(a*a)%m;
		b>>=1;
	}
	return te;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    ll n,k,q;
    cin >> n >> k >> q;
    map<int,int> sanka;
    rep(i,q){
        int a;
        cin >> a;
        sanka[a]++;
    } 
    rep1(i,n+1){
        int value = k+sanka[i]-q;
        //cout<<value;
        if(value>0) cout<<"Yes"<<endl;
        else{cout <<"No"<<endl;}
    }

    return 0;
}

Measured memory_bytes: 5376
N, = map(int, input().split())
P = list(map(int, input().split()))
i=r=0
while i<N:
    if P[i] == i+1:
        r += 1
        i += 2
    else:
        i += 1
#    elif P[i+1] == i+2:
#        i += 1
print(r)


Measured memory_bytes: 53292
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#define ll long long
#define mp(a,b) make_pair(a,b)
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
using namespace std;

int main(){
  ll d,n;
  cin >> d >> n;
  if(n==100){
    if(d==0)
      cout << "101" << endl;
    else if(d==1){
      cout << "10100" << endl;
    }
    else{
      cout << "1010000" << endl;
    }
  }
  else {
    ll lowest  = 1;
    for(ll i=0;i<d;i++){
      lowest*=100;
    }
    lowest*=n;
    cout << lowest << endl;
  };
}


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

int main()
{
    int H, W;
    cin >> H >> W;

    bool x = false;

    vector<vector<char>> list(H + 2, vector<char>(W + 2,'.'));

    for (int i = 1; i < H + 1; i++)
    {
        for (int j = 1; j < W + 1; j++)
        {
            cin >> list.at(i).at(j);
        }
    }

    for (int i = 1; i < H + 1; i++)
    {
        for (int j = 1; j < W + 1; j++)
        {
            if(list.at(i).at(j)=='#')
            {
                if (list.at(i - 1).at(j) == '.' && list.at(i + 1).at(j) == '.' && list.at(i).at(j - 1) == '.' && list.at(i).at(j + 1) == '.')
                {
                    x = true;
                    break;
                }

            }
            if (x)
                break;
        }
    }

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

Measured memory_bytes: 256
N = raw_input()
x = ''
if N[0] > N[1]:
    x = N[0]*3
elif N[0] < N[1]:
    x = str((int(N[0]) + 1)) * 3
elif N[0] == N[1]:
    if N[1] > N[2]:
        x = x = N[0]*3
    elif N[1] == N[2]:
        x = N
    else:
        x = str((int(N[0]) + 1)) * 3
print(x)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(void){
    int w,h;
    while(cin >> w >> h){
	if(w==0 && h==0) break;
	vector<vector<int> > tate(h,vector<int>(w-1)),yoko(h-1,vector<int>(w));
	for(int i=0;i<2*h-1;i++){
	    if(i%2==0){
		for(int j=0;j<w-1;j++) cin >> tate[i/2][j];
	    }else{
		for(int j=0;j<w;j++) cin >> yoko[i/2][j];
	    }
	}
	vector<vector<int> > G(2*h-1,vector<int>(2*w-1));
	for(int i=0;i<2*h-1;i++){
	    for(int j=0;j<2*w-1;j++){
		if(i%2==0){
		    if(j%2==0) G[i][j] = 0;
		    else G[i][j] = tate[i/2][j/2];
		}else{
		    if(j%2==1) G[i][j] = 1;
		    else G[i][j] = yoko[i/2][j/2];
		}
	    }
	}
	vector<vector<int> > dist(2*h-1,vector<int>(2*w-1,-1));
	queue<pair<int,int> > que;
	dist[0][0] = 1; que.push(make_pair(0,0)); 
	while(!que.empty()){
	    pair<int,int> v = que.front();que.pop();
	    for(int i=0;i<4;i++){
		int di = v.first + dx[i];
		int dj = v.second+ dy[i];
		if(0 > di || 0 > dj || 2*h-1 <= di || 2*w-1 <= dj ) continue;
		if(G[di][dj]==1) continue;
		if(dist[di][dj]==-1){ 
		    dist[di][dj] = dist[v.first][v.second] + 1;
		    que.push(make_pair(di,dj));
		}
	    }
	}
	if(dist[2*h-2][2*w-2]==-1) cout << 0 << endl;
	else cout << dist[2*h-2][2*w-2]/2 + 1 << endl; 
    }
    return 0;
}



Measured memory_bytes: 3188
/*
      author  : nishi5451
      created : 14.08.2020 13:54:10
*/

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


int main(){
    string s;
    cin >> s;
    int len = s.size();
    len -= 2;
    while(len){
        string l,r;
        l = s.substr(0,len/2);
        r = s.substr(len/2,len/2);
        if(l==r){
            cout << len << endl;
            return 0;
        }
        len -=2;
    }
    return 0;
}

Measured memory_bytes: 3540
import java.util.Scanner;


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

		int i;
		int j;
		int k;

		while(true) {

			int total = 0;
			int cnt = 0;

			int n = sc.nextInt();
			int x = sc.nextInt();

			if((n == 0) && (x == 0)) {
				break;
			}

			for(i = 1; i <= n - 2; i++) {
				for(j = i + 1; j <= n - 1; j++) {
					for(k = j + 1; k <= n; k++) {

						total= i + j + k;

						if(total == x) {
							cnt++;
						}

					}
				}
			}
			System.out.println(cnt);

		}

	}
}

Measured memory_bytes: 26628
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    rep(i,0,S.size()){
        if(i % 2 == 0 && S[i] == 'L' || i % 2 == 1 && S[i] == 'R'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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


#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define ll long long
#define all(v) v.begin(), v.end()

#define si set<int>
#define sl set<long long>

#define pair(x,y) pair<x, y>

#define frt(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rew(i,a,b) for(int i=a;i>=b;i--)

#define mod %
#define pow ^

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test if(TEST == 1)

#define left (2*idx)+1
#define right (2*idx)+2

#define INF 1000000000000000000
#define MOD (ll)(1e9 + 7)
#define N 7001

ll powerf(ll a, ll b, ll c)
{
    ll ans = 1;
    
    while(b>0)
    {
        if(b & 1)
        {
            ans = (ans * a) % c;
        }
        b = b >> 1;
        a = (a * a) % c;
    }
    
    return ans;}

int main()
{

    FIO
    int TEST = 0;
    int t = 1;

    // cin >> t;

    while(t--)
    {
        int n, k;
        cin >> n >> k;

        if(k == 1)
        {
            cout << 0 << "\n";
        }        
        else
        {
            cout << n - k << "\n";
        }

    }  
}




Measured memory_bytes: 256
#include "stdio.h"

int main(int argc, char const *argv[]) {
  int A[3];
  int B[3];
  int T[5];
  for (size_t i = 1; i < 5; i++) {T[i]=0;}
  for (size_t i = 0; i < 3; i++) {scanf("%d%d",&A[i],&B[i] );}
  for (size_t i = 0; i < 3; i++) {
    T[A[i]]++;T[B[i]]++;
  }
  int odd=0;
  for (size_t i = 1; i < 5; i++) {if (T[i]%2==1) {odd++;}}
  if (odd==2) {printf("YES");}else{printf("NO");}
  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

vector<bool> prime_table(int n)
{
    vector<bool> prime(n + 1, true);
    if (n >= 0)
        prime[0] = false;
    if (n >= 1)
        prime[1] = false;
    for (int i = 2; i * i <= n; i++)
    {
        if (!prime[i])
            continue;
        for (int j = i + i; j <= n; j += i)
        {
            prime[j] = false;
        }
    }
    return prime;
}

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

    ll N;
    string S;
    cin >> N;

    auto t = prime_table(1000+10); //1000までを判定

    vector<ll> p;

    REPS(i,N){
        if(t.at(i)==1){
            p.push_back(i);
        }
    }

    vector<ll> kosu;

    REP(i,p.size()){
        ll tmp = 0;
        REPS(j, N)
        {
            ll tmp1 = j;
            while(tmp1%p.at(i)==0){
                tmp1 /= p.at(i);
                tmp++;
            }
        }
        kosu.push_back(tmp);
    }
    ll ans = 1;
    REP(i, kosu.size())
    {
        ans *= (kosu.at(i) + 1);
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main()
{
	long long int a,b,c,x,n;
	cin>>a>>b>>c>>n;
	if(a>=n){cout<<n;}
	else if(a+b>=n){cout<<a;}
	else{
		x=n-(a+b);
		cout<<a-x;
	}
}


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

#define INF 40 * 100 + 1

// using ll = long long;

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

    int n, ma, mb;
    cin >> n >> ma >> mb;

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

    int half_n = n / 2;
    int min_cost = INF;
    map<int, int> p_ab;
    for (int i = 1; i < 1 << half_n; ++i) {
        int sum_ab = 0;
        int sum_c = 0;
        for (int j = 0; j < half_n; ++j) {
            if (i >> j & 1) {
                sum_ab += a[j] * mb - b[j] * ma;
                sum_c += c[j];
            }
        }
        if (sum_ab == 0) {
            min_cost = min(min_cost, sum_c);
        } else {
            if (!p_ab[sum_ab] || p_ab[sum_ab] > sum_c) p_ab[sum_ab] = sum_c;
        }
    }

    for (int i = 1; i < 1 << (n - half_n); ++i) {
        int sum_ab = 0;
        int sum_c = 0;
        for (int j = 0; j < n - half_n; ++j) {
            if (i >> j & 1) {
                sum_ab += - a[half_n + j] * mb + b[half_n + j] * ma;
                sum_c += c[half_n + j];
            }
        }
        if (sum_ab == 0) {
            min_cost = min(min_cost, sum_c);
        } else if (sum_c < min_cost) {
            if (p_ab[sum_ab]) {
                min_cost = min(min_cost, p_ab[sum_ab] + sum_c);
            }
        }
    }

    if (min_cost == INF) {
        cout << -1 << '\n';
    } else {
        cout << min_cost << '\n';
    }


    return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int N;
	cin >> N;

	vector<int> cnt(1000000);
	for (int x = 1; x < 200; x++) {
		for (int y = 1; y < 200; y++) {
			for (int z = 1; z < 200; z++) {
				cnt[x * x + y * y + z * z + x * y + y * z + z * x]++;
			}
		}
	}

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

	return 0;
}



Measured memory_bytes: 7136
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)
if len(l) >= 2:
    for i in range(len(l)-1):
        ans = []
        for cx in range(101):
            for cy in range(101):
                if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
                    if i == 0:
                        ans.append([cx, cy])
                    else:
                        if [cx, cy] in ansn:
                            ans.append([cx, cy])
        ansn = ans[:]
        if len(ans) == 1:
            break
    print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))
else:
    print(l[0][0], l[0][1], l[0][2])

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

int main()
{   
    //データ定義
    int matrix[100][100] = {{}};
    int vector[1000] = {};
    int n;
    int m;
    int i;
    int j;
    int w_num;
    
    //行、列取得
    cin >> n >> m;
    
    //行列データ取得
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            cin >> matrix[i][j];
        }
    }
    //ベクトルデータ取得
    for(i = 0; i < m; i++){
        cin >> vector[i];
    }
    
    //メイン処理
    for(i = 0; i < n; i++){
        w_num = 0;
        for(j = 0; j < m; j++){
            w_num += matrix[i][j] * vector[j];
        }
        cout << w_num << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

    int N,W; cin >> N >> W;
    int v[N],w[N];
    int dp[W+1];
    rep(i,W+1) dp[i]=0;
    rep(i,N) cin >> v[i] >> w[i];
    rep(i,N){
        gnr(j,w[i],W+1){
            chmax(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout << dp[W] << endl;
}


Measured memory_bytes: 3256
from collections import deque

N, M = map(int, input().split())
adj = {u: [] for u in range(1, N+1)}
for i in range(M):
    X, Y, Z = map(int, input().split())
    adj[X].append(Y)
    adj[Y].append(X)

remain = set(adj.keys())

ncc = 0  # the number of connected components
while len(remain) > 0:
    head = remain.pop()
    remain.add(head)  # push back
    queue = deque()
    queue.append(head)
    while len(queue) > 0:
        u = queue.popleft()
        if u not in remain:
            continue
        remain.remove(u)
        queue.extend(adj[u])
    ncc += 1

print(ncc)


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

using namespace std;

int main(){
  int t1,t2,r1,r2; cin >> t1 >> t2 >> r1 >> r2;
  if(r1==-1||r2==-1){
    if(t1<t2) cout << "Alice";
    else if(t1>t2) cout << "Bob";
    else cout << "Draw";
  }else{
    if(r1>r2) cout << "Alice";
    else if(r1<r2) cout << "Bob";
    else cout << "Draw";
  }
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3076
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint x[58],y[59];
int main()
{
	int n,K;lint out=8E18+10;
	cin>>n>>K;
	rep(i,n) cin>>x[i]>>y[i];
	rep(i,n) rep(j,n) rep(k,n) rep(l,n){
		if(x[i]>=x[j] || y[k]>=y[l]) continue;
		int t=0;
		rep(m,n){
			if(x[m]>=x[i] && x[m]<=x[j] && y[m]>=y[k] && y[m]<=y[l]) t++;
		}
		if(t>=K) out=min(out,(x[j]-x[i])*(y[l]-y[k]));
	}
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a, b, x;

  cin >> a >> b >> x;

  if(a > x)
    cout << "NO" << endl;
  else {
    if(a + b >= x)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}


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

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

int main(){
    ll N,D;
    ll ans = 0;
    cin >> N >> D;
    for(int i=0;i<N;i++){
        ll x,y;
        cin >> x >> y;
        if(D*D >= x*x + y*y) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
def solve():
    S = input()

    p = 1

    even = False
    if len(S) % 2 == 0:
        even = True

    if S[0] == S[-1]:  # ababa 奇数で終わる
        if even:
            return -p
        else:
            return p
    else:              # abab 偶数で終わる
        if even:
            return p
        else:
            return -p


if __name__ == '__main__':
    res = solve()
    if res < 0:
        print("First")
    else:
        print("Second")


Measured memory_bytes: 39152
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
ctr = Counter(A)
sa = sorted(ctr.keys(),reverse=True)

ans = 0
for a in sa:
    p = 2**(len(bin(a))-2)
    rem = p - a
    if a == rem:
        v = ctr[a] // 2
    else:
        v = min(ctr[a], ctr[rem])
    ans += v
    ctr[a] -= v
    ctr[rem] -= v
print(ans)

Measured memory_bytes: 56056
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if (abs(x - a) > abs(x - b)) {
    cout << "B" << endl;
  } else {
    cout << "A" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    long long A, B, K;
    cin >> A >> B >> K;
    
    if (A - K < 0) {
        K = K - A;
        A = 0;
    } else {
        A = A - K;
        K = 0;
    }
    

    if (B - K < 0) {
        B = 0;
        K = K - B;
    }
    else {
        B = B - K;
    }

    cout << A << " " << B << endl;

}

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

int main(){
	int n;
	std::vector<int> aList;
	std::list<int> ansList;

	std::cin>>n;
	aList.resize(n);

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

	for(int i=0; i<n; i++){
		if(i%2==0)
			ansList.push_back(aList[i]);
		else
			ansList.push_front(aList[i]);
	}

	if(n%2!=0){
		while(!ansList.empty()){
			std::cout<<ansList.back()<<" ";
			ansList.pop_back();
		}
		std::cout<<std::endl;

	}else{
		while(!ansList.empty()){
			std::cout<<ansList.front()<<" ";
			ansList.pop_front();
		}
		std::cout<<std::endl;
	}

	return 0;
	
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
 
  vector<string> board(H);
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  rep(i,0,H-1) {
    cin >> board[i];
    rep(j,0,W-1) {
      if (board[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }
 
  rep(i,0,H-1) {
    if (row[i]) {
      rep(j,0,W-1) {
        if (col[j]) {
          cout << board[i][j];
        }
      }
      cout << endl;
    }
  }
 
  return 0;
}


Measured memory_bytes: 256
def is_prime(x):
    if x == 2:
        return 1
    elif x % 2 == 0:
        return 0
    else:
        return pow(2, x - 1, x) == 1

import sys

def solve():
    file_input = sys.stdin
    N = file_input.readline()
    count = 0
    for n in map(int, file_input):
        count += is_prime(n)
    print(count)

solve()



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a,b,c) push_back(make_pair(a,make_pair(b,c)))
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 303;
int N;
int A[MC][MC];
int B[MC][MC];
LL ans;

int main(){
	cin >> N;
	repp(i,0,N){
		repp(j,0,N){
			cin >> A[i][j];
			B[i][j] = A[i][j];
			if(i < j) ans += A[i][j];
		}
	}
	repp(k,0,N) repp(i,0,N) repp(j,0,N) B[i][j] = min(B[i][j] , B[i][k] + B[k][j]);
	repp(i,0,N) repp(j,i+1,N){
		if(A[i][j] != B[i][j]){
			cout << -1 << endl;
			return 0;
		}
		repp(k,0,N){
			if(k == i || k == j) continue;
			if(A[i][j] == A[i][k] + A[k][j]){
				ans -= A[i][j];
				k = N;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

vector<pair<int, long long>> Y[100010];
vector<pair<int, long long>> S[100010];

bool vy[100010];
bool vs[100010];

long long ny[100010],ns[100010];

priority_queue<pair<long long, int>> H;

int main()
{
    int n,m,s,t;
    int a,b,y,sn;
    cin >> n >> m >> s >> t;
    for ( int c=1; c<=m; c++ )
    {
        cin >> a >> b >> y >> sn;
        Y[a].push_back({b,y});
        Y[b].push_back({a,y});
        S[a].push_back({b,sn});
        S[b].push_back({a,sn});
    }

    H.push({0,s});
    while(!H.empty())
    {
        auto pa = H.top();
        H.pop();

        if (vy[pa.second])
            continue;
        vy[pa.second] = true;
        ny[pa.second] = -pa.first;
        for ( auto ed: Y[pa.second])
        {
            H.push({pa.first-ed.second, ed.first});
        }
    }

    H.push({0,t});
    while(!H.empty())
    {
        auto pa = H.top();
        H.pop();

        if (vs[pa.second])
            continue;
        vs[pa.second] = true;
        ns[pa.second] = -pa.first;
        for ( auto ed: S[pa.second])
        {
            H.push({pa.first-ed.second, ed.first});
        }
    }


    long long mx=1e15;
    vector<long long> ans(100010);

    for ( int c=n; c>=1; c-- )
    {
        mx = min (mx, ny[c]+ns[c]);
        ans[c] = 1e15 - mx;
    }

    for ( int c=1; c<=n; c++ )
    {
        cout << ans[c] << endl;
    }

}


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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;


int main()
{
    string s;
    cin >> s;
    int a = 1;
    for (int i = 0; i < int(s.size()); i++) {
        if (i%2) {
            if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) a = 0;
        } else {
            if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) a = 0;
        }
    }
    if (a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
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 ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,k;
  cin >> n >> k;
  vector<P>vec(n);
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    vec[i]=P(a,b);
  }
  sort(vec.begin(),vec.end());
  ll cnt=0;
  rep(i,n){
    cnt+=vec[i].second;
    if(cnt>=k){
      cout << vec[i].first << endl;
      return 0;
    }
  }
     
  return 0;     
}


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

int main(){
    int N,n,ans=0;
    cin >> N;
    n = N;
    while(N>0){
        ans += N%10;
        N /=10;        
    }
    if(n%ans==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3576
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int x;
  cin >> x;
  for (int i = 0; i <= 1000; ++i) {
    if (100 * i <= x && x <= 105 * i) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3652
N = int(input())
w = input()
W = []
W.append(w)
z = w[-1]
for i in range(N-1):
    w = input()
    if z != w[0] or W.count(w)!=0:
        ans = 'No'
        break
    W.append(w)
    z = w[-1]
    ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
	/*char c;
	cin >> c;

	if (c == 'a'| c == 'e' | c == 'i' | c == 'o' | c == 'u'  ) {
		cout << "vowel" << endl;
	}
	else
	{
		cout << "consonant" << endl;
	}*/
	char op;
	int A, B;
	cin >> A >> op >>B ;
	if (op=='+')
	{
		cout << A + B << endl;
	}
	if (op == '-')
	{
		cout << A - B << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
	float a,b,c,d,m,n;
	scanf("%f%f%f%f",&a,&b,&c,&d);
	m=ceil(a/d);//m+1ci A si
	n=ceil(c/b);//n+1ci B si
	if(m-n>=0)
	{
		printf("Yes");
	 }
	 else printf("No"); 
}

Measured memory_bytes: 1740
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N = [int(input()) for _ in range(6)]
print((N[0]-1)//min(N[1:])+5)

Measured memory_bytes: 65820
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pii pair <int,int>
ll mod=1000000007;
int main()
{
	fast;
	string s,t;cin>>s>>t;
	int count=INT_MAX;
	for(int i=0;i<=s.length()-t.length();i++)
	{
		int c=0;
		for(int j=0;j<t.length();j++)
		{
			if(t[j]!=s[j+i])
			{	
				c++;
			}
		}
		count=min(c,count);
	}
	cout<<count;

}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll N,M,V,P;
  cin >> N >> M >> V >> P;
  vl A(N);
  rep(i,N) {
    cin >> A[i];
  }
  sort(rng(A));
  vl sum(N+1,0);
  rep(i,N) {
    sum[i+1] = sum[i] + A[i];
  }
  ll l = A[N-P]-M-1;
  ll r = A[N-P];
  while(l+1<r) {
    ll m = (l+r)/2;
    ll id = lower_bound(rng(A),m) - A.begin();
    ll s = (sum[N-P+1] - sum[id]) - m * (N-P-id+1);
    if(s <= M * (N-V)) {
      r = m;
    } else {
      l = m;
    }
  }
  ll ans = N - (lower_bound(rng(A),r) - A.begin());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
/**

  @@@@@@@  @@@@  @@@@  @@@@  @@@@  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @  @  @  @  @  @  @  @  @
  @  @  @  @@@@  @@@@  @@@@  @  @  @

**/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define str string
#define pi pair
#define tup tuple
#define vec vector
#define temp template
#define tn typename

#define ff first
#define ss second
#define SZ(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rsz resize
#define ins insert
#define fr front
#define bc back
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk make_pair

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ROF(i, a, b) for (ll i = (a); i >= (b); i--)
#define trav(a, x) for (auto &a : x)
#define popcount __builtin_popcountll
#define ctz __builtin_ctzll
#define clz __builtin_clzll
#define gcd __gcd

#define max(a, b) max((ll) a, (ll) b)
#define min(a, b) min((ll) a, (ll) b)

// DEBUG
#define ts to_string
temp<tn A, tn B> str ts(pi<A, B> p);
temp<tn A, tn B, tn C> str ts(tup<A, B, C> p);
str ts(const str& s) { return '"' + s + '"'; }
str ts(const char* s) { return ts((str) s); }
str ts(bool b) { return (b ? "true" : "false"); }
str ts(vec<bool> v) { bool f = true; str res = "{";
FOR(i, 0, static_cast<ll>(v.size()) - 1)
{ if (!f) res += ", "; res += ts(v[i]);
f = false; } res += "}"; return res; }
temp<size_t N> str ts(bitset<N> v) { str res = "";
trav(a, v) { res += (char) ('0' + a); } return res; }
temp<tn A> str ts(A v) { bool f = true; str res = "{";
trav(x, v) { if (!f) res += ", "; res += ts(x);
f = false; } res += "}"; return res; }
temp<tn A, tn B> str ts(pi<A, B> p) {
  return "(" + ts(p.ff) + ", " + ts(p.ss) + ")"; }
temp<tn A, tn B, tn C> str ts(tup<A, B, C> t) {
  return "(" + ts(get<0>(t)) + ", " + ts(get<1>(t)) + ", " + ts(get<2>(t)) + ")"; }
void DBG() { cerr << endl; }
temp<tn H, tn... T> void DBG(H h, T... t) { cerr << " " << ts(h); DBG(t...); }
#ifdef LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", DBG(__VA_ARGS__);
#else
#define dbg(...) 42
#endif

// INPUT AND OUTPUT
temp<tn T> void re(T& x) { cin >> x; };
temp<tn H, tn... T> void re(H& h, T&... t) { re(h); re(t...); }
temp<tn T> void pr(T x) { cout << x; };
temp<tn H, tn... T> void pr(H h, T... t) { pr(h); pr(t...); }
temp<tn T> void pri(T x) { cout << x; cout << endl; }; // used for interactives
temp<tn H, tn... T> void pri(H h, T... t) { pri(h); pri(t...); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x, y;
  re(x, y);
  FOR(i, 0, x) {
  	if (i * 2 + (x - i) * 4 == y) {
  		pr("Yes", '\n');
  		return 0;
		}
	}
	pr("No", '\n');
  return 0;
}




Measured memory_bytes: 3640