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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li w, h;
string alh = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

string board[33][33];

int main() {
    cin >> h >> w;
    rep(i, h) {
        rep(j, w) {
            cin >> board[i][j];
        }
    }

    rep(i, h) {
        rep(j, w) {
            if (board[i][j] == "snuke") {
                cout << alh[j] << i + 1 << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
export class Main {
  static main(input: string): string {
    const a: number[] = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    const tmp: string[] = input.split("\n");
    const k: number = parseInt(tmp.shift().split(" ")[0]);
    return `${a[k - 1]}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	vector<int> v(3);
	for (int i = 0; i < 3; i++) cin >> v.at(i);
	sort(v.begin(), v.end());

	int ans = abs(v.at(0) - v.at(1)) + abs(v.at(1) - v.at(2));

	cout << ans << endl;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;

  int m = max(max(a, b), c);
  cout << a + b + c - m << endl;

  return 0;
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
#define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int a, b, c, d;
int cound_divisors(int n, int d){
	return n/d;
}
int range_count(int l, int r, int d){
	return cound_divisors(r, d) - cound_divisors(l-1, d);
}
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> a >> b >> c >> d;
	int lcm = (c*d)/__gcd(c,d);
	int ans = (b-a+1) - range_count(a, b, c) - range_count(a, b, d) + range_count(a, b, lcm);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
a, b, c = [0] * N, [0] * N, [0] * N
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
dp = [[0] * 3 for _ in range(N)]
# print(dp)
dp[0] = [a[0], b[0], c[0]]
for i in range(N - 1):
    dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + a[i + 1], dp[i][2] + a[i + 1])
    dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + b[i + 1], dp[i][2] + b[i + 1])
    dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + c[i + 1], dp[i][1] + c[i + 1])
print(max(dp[N - 1]))

Measured memory_bytes: 34616
import sys
readline = sys.stdin.readline

from bisect import bisect_left, insort_left

def main():
    n = int(readline())
    s = list(readline().rstrip())
    q = int(readline())
    
    chk_abc = [[] for i in range(26)]
    for i, si in enumerate(s):
        ci = ord(si) - 97
        chk_abc[ci].append(i)
        
    ans = []
    for _ in range(q):
        cmd, i, j = readline().rstrip().split()
        i = int(i) - 1
        
        if cmd == "1":
            if s[i] == j:
                continue
            c1 = ord(s[i]) - 97
            prev = chk_abc[c1]
            c2 = ord(j) - 97
            prev.pop(bisect_left(prev, i))
            s[i] = j
            insort_left(chk_abc[c2], i)
            
        else:
            j = int(j) - 1
            num = 0
            for chk in chk_abc:
                le = len(chk)
                k = bisect_left(chk, i, 0, le)
                if k == le:
                    continue
                if i <= chk[k] <= j:
                    num += 1
            ans.append(num)

    print(*ans, sep="\n")

if __name__ == "__main__":
    main()

Measured memory_bytes: 30624
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=205;
int fl[N][N][N],fu[N][N][N],gl[N][N][N],gu[N][N][N];
char mp[N][N];int L[N][N],U[N][N],n,m;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&m);
	fp(i,1,n){
		scanf("%s",mp[i]+1);
		fp(j,1,m){
			L[i][j]=(mp[i][j]==mp[i][j-1])?L[i][j-1]+1:1;
			U[i][j]=(mp[i][j]==mp[i-1][j])?U[i-1][j]+1:1;
		}
	}
	fp(x,1,n)fp(y,1,m){
		for(R int xx=x,mn=233;mp[x][y]==mp[xx][y];++xx)cmin(mn,L[xx][y]),fl[x][y][xx]=mn;
		for(R int yy=y,mn=233;mp[x][y]==mp[x][yy];++yy)cmin(mn,U[x][yy]),fu[x][y][yy]=mn;
	}
	for(int res=0;233;++res){
		if(fl[1][m][n]==m||fu[n][1][m]==n)return printf("%d\n",res),0;
		memcpy(gl,fl,sizeof(fl)),memcpy(gu,fu,sizeof(fu));
		fp(x,1,n)fp(y,1,m){
			fp(xx,x,n)fl[x][y][xx]+=gl[x][y-gl[x][y][xx]][xx];
			fp(yy,y,m)fu[x][y][yy]+=gu[x-gu[x][y][yy]][y][yy];
		}
		fp(x,1,n)fp(y,1,m){
			for(R int xx=x,X=1;xx<=n;++xx,++X)
				for(R int yy=y-fl[x][y][xx]+1;yy<=y&&fu[xx][yy][y]<X;++yy)
					fu[xx][yy][y]=X;
			for(R int yy=y,Y=1;yy<=m;++yy,++Y)
				for(R int xx=x-fu[x][y][yy]+1;xx<=x&&fl[xx][yy][x]<Y;++xx)
					fl[xx][yy][x]=Y;
		}
	}
	return 0;
}

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

using namespace std;

using ll = long long;

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL



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

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	bool win;
	while (true) {
		c -= b;
		if (c <= 0) {
			win = true;
			break;
		}
		a -= d;
		if (a <= 0) {
			win = false;
			break;
		}
	}
	if (win) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <queue>
#include <stack>
using namespace std;
int m[2890],m1[2890];

int main()
{
    int n,ss,ee,k,i,j,p1,p2,s,e;
    char t1[10],t2[10];
    while(scanf("%d",&n)!=EOF)
    {
        scanf("%s%s",&t1,&t2);
        if(n == 0&&strcmp(t1,"0") == 0&&strcmp(t2,"0") == 0) break;
        s = ((t1[0]-'0')*10 + t1[1]-'0')*60 + (t1[2] - '0')*10 + t1[3]-'0';
        e = ((t2[0]-'0')*10 + t2[1]-'0')*60 + (t2[2] - '0')*10 + t2[3]-'0';
        if(e < s) e += 1440;
        //for(i = s;i <= e;i ++) m[i] = 1;
        memset(m,0,sizeof(m));
        //cout<<s<<" "<<e<<endl;
        for(i = 0;i < n;i ++)
        {
            scanf("%d",&k);
            for(int l = s;l < e;l ++) m1[l] = 1;
            for(j = 0;j < k;j ++)
            {
                scanf("%s%s",&t1,&t2);
                ss = ((t1[0]-'0')*10 + t1[1]-'0')*60 + (t1[2] - '0')*10 + t1[3]-'0';
                ee = ((t2[0]-'0')*10 + t2[1]-'0')*60 + (t2[2] - '0')*10 + t2[3]-'0';
                if(ee < ss) ee += 1440;
                for(int l = ss;l < ee;l ++) m1[l] = 0;
                //cout<<ss<<" "<<ee<<endl;
            }
            for(int l = s;l < e;l ++)
            {
                if(m[l] == 0) m[l] = m1[l];
            }
        }
        int ans = 0,len= 0 ;
        for(i = s;i < e;i ++)
        {
            //cout<<m[i];
            if(m[i] == 1) len ++;
            else
            {
                if(len > ans) ans = len;
                len = 0;
            }
        }
        if(len > ans) ans  = len;
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main() {
	int n,x;
	scanf("%d %d",&n,&x);
	long long int a[200];
	for(int i=1;i<n+1;i++){
		scanf("%lld",&a[i]);
	}
	long long int sum=0;
	for(int i=1;i<n+1;i++){
		sum+=a[i];
		if(sum>x){
			printf("%d",i);
			return 0;
		}
	}
	if(sum<=x){
		printf("%d",n+1);
	}
	return 0;
}

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

string s;
char stgc[4] = {'A', 'T', 'G', 'C'};

int main() {
    cin >> s; 
    int n = s.size();
    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= n-i; j++) {
            string sub = s.substr(i,j);
            int flag = 1;
            for (int k = 0; k < sub.size() && flag; k++) {
                int tempflag = 1;
                for (int l = 0; l < 4 && tempflag; l++) {
                    if (sub[k] == stgc[l]) {
                        tempflag = 0;
                    }
                }
                flag = !tempflag;
            }
            if (flag) res = max(res, j);
        }
    }
    cout << res << endl;
    return 0;
}

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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;


void solve()
{
    int n;
    cin >> n;
    ld a[n+1];
    for(int i=1;i<=n;i++)    cin >> a[i];
    ld dp[n+1][n+1];
    memset(dp,0.0,sizeof(dp));
    dp[0][0] = 1.0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j == 0)
            {
                dp[i][j] = dp[i-1][j]*(1.0-a[i]);
            }
            else
            {
                dp[i][j] = dp[i-1][j]*(1-a[i]) + dp[i-1][j-1]*a[i];
            }
        }
    }
    ld ans = 0.0;
    for(int i=(n+1)/2;i<=n;i++)
    {
        ans += dp[n][i];
    }
    cout << fixed << setprecision(12) << ans;
}


signed main()
{
    IOS;
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; 0 <= i; i--)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A(N); REP(i, N) cin >> A[i]
#define ANS(ans) cout << (ans) << endl
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DEBUGV(V) REP(i, V.size()) cout << V.at(i) << " "; cout << endl 

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

int
main()
{
  CIN(N);
  CINVEC(A, N);

  vector<int> L(N), R(N);
  
  L[0] = 0; 
  L[1] = A[0];
  for (int i = 2; i < N; i++) {
    L[i] = gcd(L[i - 1], A[i - 1]);
  }

  R[N - 1] = 0;
  R[N - 2] = A[N - 1];
  for (int i = N - 3; 0 <= i; i--) {
    R[i] = gcd(A[i + 1], R[i + 1]);
  }

  int ans = 0;
  REP(i, N) {
    ans = max(ans, gcd(R[i], L[i]));
  }

  ANS(ans);

  return 0;
}


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

int main()
{
	int a, b, k = 0;
	cin >> a >> b >> k;
	int ct = 0;
	int ans = 0;
	for (int i = 100; i >= 0; i--)
	{

		if ((a % i == 0) && (b % i == 0))
		{
			ct++;
			if (ct == k)
			{
				ans = i;
				break;
			}

		}
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
<>;($x,$y)=glob,printf"%f\n",sort{$b<=>$a}0,map+(-$~+($~=$_))/$P-.5,(@b=sort{$a<=>$b}map{/ /*atan2$'-$y,$`-$x}grep!/^$x $y$/,@a),"@b"+($P=6.2831853)for@a=<>

Measured memory_bytes: 5248
n=int(input())

dp=[0]*n
dp[0]=list(map(int,input().split()))

for i in range(1,n):
    dp[i]=list(map(int,input().split()))
    dp[i][0]+=max(dp[i-1][1],dp[i-1][2])
    dp[i][1]+=max(dp[i-1][0],dp[i-1][2])
    dp[i][2]+=max(dp[i-1][0],dp[i-1][1])

print(max(dp[n-1]))

Measured memory_bytes: 30160
/*

与えられた整数n以下の素数2つ、その素数の差が2となる組み合わせで、最大の組み合わせを求めよ。

やり方：
	・nを入力。
	・データセット数を記録。
	・numにn[i]を入れ、「numが素数かつnum-2も素数」になるまで、numを1ずつ減らし続ける。
	・それぞれ、numをlarge[i]に、num-2をsmall[i]に入れる。
	・small[i]とlarge[i]を出力して終了。

結果：Run time error.


-------------------------------------------------------------

アドバイスを受け、改良。
どうやら、配列のサイズ（100）が駄目だったらしい。入力が100を超えるかもしれないからだ。
別に、「入力は入力、出力は出力」という風にまとめなくても、「入力→出力→次の入力・・・」でも良いらしい。
配列を使わずに、即出力するようにしたら、Run time errorは脱した。
しかし、今度はTime limit exceeded。どうしたものか。

結果：Time limit exceeded

※「素数かどうか判定する関数、sosuu00」を改良。
「自分以外で割り切れたらcount++,	最終的にcountが0ならreturn 1」とやっていたところを、
「自分以外で割り切れたらreturn 0.	無事にループを抜けたらreturn 1.」とした。
数行の削減に成功。

*/

#include <stdio.h>

int sosuu00(int n);

int main()
{
	int n;
	int small,large;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		while(1){
			if(sosuu00(n)){
				if(sosuu00(n-2)){
					break;
				}
			}
			n--;
		}
		large=n;
		small=n-2;
		printf("%d %d\n",small,large);
	}
	return 0;
}

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

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

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

int main(){
	string S;
	cin >> S;
	int N=S.size();
	LL ans=0;
	rep(bit, 1<<(N-1)){
		for(LL i=0; i<N; i++){
			LL n=S[i]-'0';
			for(LL j=i; j<N-1; j++){
				if(bit&(1<<j)){
					n*=pow(10,j-i);
					break;
				}
				if(j==N-2) n*=pow(10,N-1-i);
			}
			ans+=n;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    string s = to_string(n);
    ll c = 0;
    rep(i,s.size()) c += s[i]-'0';
    Yes(n%c == 0);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

main(){
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    int tmp = s[0][0] - 97;
    s[0].erase(0,1);
    while(1){
        if(s[tmp].empty()){
            printf("%c\n",tmp+65);
            return 0;
        }

        int t = tmp;
        tmp = s[tmp][0] - 97;
        s[t].erase(0,1);
    }

    return 0;
}


Measured memory_bytes: 256
import Control.Monad
main = do
  getLine
  magic <- toTable . concat . map (map (read :: String -> Int) . words) <$> replicateM 10 getLine
  wall <- concat . map (map (read :: String -> Int) . words) . lines <$> getContents
  let index = [[k, i, j] | k <- [0..9], i <- [0..9], j <- [0..9]]
      minMagic = foldl wf magic index
  putStrLn . show . sum . map (solve minMagic) $ wall

toTable :: [Int] -> [(Int, Int, Int)]
toTable = zipWith (\[a, b] x -> (a, b, x)) [[s, t] | s <- [0..9], t <- [0..9]]

readTable :: Int -> Int -> [(Int, Int, Int)] -> Int
readTable x y t = let (_, _, m) = t !! (x * 10 + y) in m

writeTable :: Int -> Int -> Int -> [(Int, Int, Int)] -> [(Int, Int, Int)]
writeTable x y d t = let i = x * 10 + y
                       in take i t ++ [(x, y, d)] ++ drop (i+1) t

wf :: [(Int, Int, Int)] -> [Int] -> [(Int, Int, Int)]
wf t (k:i:j:_) = let d = min (readTable i j t) (readTable i k t + readTable k j t)
                    in writeTable i j d t

solve :: [(Int, Int, Int)] -> Int -> Int
solve t n
  | n == 1 || n == (0-1) = 0
  | otherwise            = readTable n 1 t


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n, L;
	scanf("%d%d", &n, &L);
	ll sumv = 0;
	ld sumtv = 0;
	deque<pair<ll, ld>> deq;
	for (int i = 0; i < n; ++i) {
		int t, v;
		scanf("%d%d", &t, &v);
		sumv += v;
		ll tv = (ll)t * v;
		sumtv += tv;
		deq.push_front({v, tv});
		assert(deq.size() >= 1);
		while (sumv - deq.back().first >= L) {
			sumv -= deq.back().first;
			sumtv -= deq.back().second;
			deq.pop_back();
		}
		if (sumv > L) {
			ll remv = sumv - deq.back().first;
			ld ntv = (L - remv) * deq.back().second / deq.back().first;
			sumtv = sumtv - deq.back().second + ntv;
			deq.pop_back();
			deq.push_back({L - remv, ntv});
			sumv = L;
		}
		printf("%.9Lf\n", sumtv / L);
		while (deq.size() >= 2) {
			auto f = deq.front();
			deq.pop_front();
			auto g = deq.front();
			if (g.second / g.first >= f.second / f.first) {
				deq.pop_front();
				deq.push_front({g.first + f.first, g.second + f.second});
			} else {
				deq.push_front(f);
				break;
			}
		}
	}
}


Measured memory_bytes: 26428
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n = int(input())
a = lmp()
q = int(input())
num = [0]*(10**5+1)
ans = sum(a)
for i in range(n):
    num[a[i]] += 1
for i in range(q):
    b,c = mp()
    ans -= b*num[b]
    ans += c*num[b]
    print(ans)
    num[c] += num[b]
    num[b] = 0



Measured memory_bytes: 84620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    int p[110];for(int i=0;i<n;i++)cin>>p[i];
    int ans=0;
    for(int i=1;i<=100;i++){
        int c=0;
        for(int j=0;j<n;j++){
            if(p[j]>=i){
                c++;
            }
        }
        if(c>=i){
            ans=i;
        }
    }
    cout<<ans<<endl;
}
 


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=305;
ll N,d[MAX][MAX],pos[MAX][MAX],fin;
int main(){
    scanf("%lld",&N);
    for(int i=0;i<N;i++) for(int j=0;j<N;j++) scanf("%lld",&d[i][j]);
    for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) if(i!=j&&j!=k&&k!=i){
        if(d[i][j]>d[i][k]+d[k][j]){
            printf("-1\n");
            return 0;
        }
        if(d[i][j]==d[i][k]+d[k][j]){
            pos[i][j]=1;
        }
    }
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++) if(!pos[i][j]) fin+=d[i][j];
    printf("%lld\n",fin);
}


Measured memory_bytes: 1664
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>int LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>int UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int n,i;cin>>n;
	pair<int,int>a;
	a=mp(mod,0);
	for(i=0;i<n;i++){
		int x;cin>>x;
		mineq(a,mp(x,i+1));
	}
	cout<<a.sec<<endl;
	return 0;
}



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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  string a, b;
  cin >> a >> b;

  int n = atoi((a + b).c_str());
  int m = (int)sqrt(n);
  cout << (m * m == n ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
from bisect import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
k=a[0]
data=[]
count=1
for i in range(1,n):
    if a[i]==k:
        count+=1
    else:
        k=a[i]
        data.append(count)
        count=1
data.append(count)
data.sort()
l=len(data)
lst=[]
for u in data:
    if lst:
        lst.append(u+lst[-1])
    else:
        lst.append(u)
li=[0]*(n+1)
for ans in range(1,n+1):
    i=bisect(data,ans)
    if i==0:
        j=ans*l
    else:
        j=lst[i-1]+ans*(l-i)
    k=j//ans
    li[k]=ans
z=0
for i in range(n):
    if li[n-i]==0:
        li[n-i]=z
    else:
        z=li[n-i]
for i in range(1,n+1):
    print(li[i])

Measured memory_bytes: 119068
m1,d1=map(int,input().split())
m2,d2=map(int,input().split())
if m1<=11:
  if m2==m1+1 and d2==1:
    print(1)
  else: 
    print(0)
elif m1==12:
  if m2==1 and d2==1:
    print(1)
  else: 
    print(0)
else:
  print(0)
  

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Text;

class Program
{
    static void Main()
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();
        var z = S.Zip(T, (first, second) => new char[] { first, second });
        int ans = 0;
        foreach (var v in z) if (v[0] != v[1]) ans++;
        Console.WriteLine(ans);
        return;
    }
}

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

#define pi 3.14159265358979323846
#define ll long long


int main()
{
    int x;
    cin>>x;
    ll val=0;

    for(int i=1;i<=x;i++){
        for(int j=1;j<=x;j++){
            for(int k=1;k<=x;k++){
                int z=__gcd(i,j);
                z=__gcd(z,k);
                val+=z;
            }
        }
    }
    cout<<val<<endl;

}


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

int main() {
  int x1,x2,y1,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  cout << x2+y1-y2 << " " << y2+x2-x1 
    << " " << x1+y1-y2 << " " << y1+x2-x1 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
template <class T>
void read(T &x)
{
	x=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
}
const int N=2e5+10;
const int mod=1e9+7;
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int dp[N],las[N],n;
int main()
{
	read(n);
	dp[0]=1;
	for(int c,i=1;i<=n;i++)
	{
		read(c);
		dp[i]=dp[i-1];
		if(las[c]&&las[c]!=i-1) dp[i]=add(dp[i],dp[las[c]]);
		las[c]=i;
	}
	printf("%d\n",dp[n]);
	return 0;
}


Measured memory_bytes: 1664
# coding: utf-8
import heapq

n, m = map(int, input().split())
s = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(s)

for i in range(m):
  maxi = heapq.heappop(s)
  heapq.heappush(s, -(-maxi // 2))

print(-sum(s))

Measured memory_bytes: 14180
from  collections import defaultdict
N, X, Y = map(int, input().split())
D = defaultdict(int)
for i in range(1,N):
    for j in range(i+1, N+1):
        r = min(j-i, abs(X-i)+abs(X-j)+1, abs(X-i)+abs(Y-j)+1, abs(Y-i)+abs(Y-j)+1)
        D[r] += 1
for i in range(1, N):
    print(D[i])


Measured memory_bytes: 51292
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

if len([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0]) > 0:
    m = min([i for i in [a % 10, b % 10, c % 10, d % 10, e % 10] if i is not 0])
else:
    m = 10

print((a // 10 + (1 if a % 10 != 0 else 0)) * 10 + (b // 10 + (1 if b % 10 != 0 else 0)) * 10 + (c // 10 + (1 if c % 10 != 0 else 0)) * 10 + (d // 10 + (1 if d % 10 != 0 else 0)) * 10 + (e // 10 + (1 if e % 10 != 0 else 0)) * 10 - 10 + m)


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

int main() {
 long long a,b,x;
  cin >> a >> b >> x;
  long long m=b/x;
  long long n=a/x;

  if(a%x!=0){
    cout << m-n << endl;
  }
  else{
    cout <<m-n+1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,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;}

const long long INF = 1LL << 60;


int main(void){
	int x; cin >> x;
	int ans=0;
	while(1){
		if(x>=500){ ans += 1000;x-=500;}
		else break;
	}
	cout << ans + (x/5)*5;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int k; cin>>k;
    string s; cin>>s;
    int n = s.length();
    if (n <= k) {
        cout << s << '\n';
    }
    else {
        s = s.substr(0, k);
        s += "...";
        cout << s << '\n';
    }

    return 0;
}

Measured memory_bytes: 3604
n = int(input())

static_min_x = 10 ** 8
static_max_x = - 10 ** 8
static_min_y = 10 ** 8
static_max_y = - 10 ** 8
rx_max = - 10 ** 8
rx_min = 10 ** 8
lx_max = - 18 ** 8
lx_min = 10 ** 8
uy_max = - 10 ** 8
uy_min = 10 ** 8
dy_max = - 18 ** 8
dy_min = 10 ** 8
for _ in range(n):
    x, y, d = input().split()
    x = int(x)
    y = int(y)
    if d == 'R':
        rx_max = max(rx_max, x)
        rx_min = min(rx_min, x)
        static_max_y = max(static_max_y, y)
        static_min_y = min(static_min_y, y)
    elif d == 'L':
        lx_max = max(lx_max, x)
        lx_min = min(lx_min, x)
        static_max_y = max(static_max_y, y)
        static_min_y = min(static_min_y, y)
    elif d == 'U':
        uy_max = max(uy_max, y)
        uy_min = min(uy_min, y)
        static_max_x = max(static_max_x, x)
        static_min_x = min(static_min_x, x)
    else:
        dy_max = max(dy_max, y)
        dy_min = min(dy_min, y)
        static_max_x = max(static_max_x, x)
        static_min_x = min(static_min_x, x)

def calc_ans(t):
    max_x = max(rx_max + t, lx_max - t, static_max_x)
    min_x = min(rx_min + t, lx_min - t, static_min_x)
    max_y = max(uy_max + t, dy_max - t, static_max_y)
    min_y = min(uy_min + t, dy_min - t, static_min_y)
    return (max_x - min_x) * (max_y - min_y)

ans = calc_ans(0)
ans = min(ans, calc_ans(abs(rx_max - lx_max) / 2.0))
if lx_max > static_max_x:
    ans = min(ans, calc_ans(lx_max - static_max_x))
if static_max_x > rx_max:
    ans = min(ans, calc_ans(static_max_x - rx_max))

ans = min(ans, calc_ans(abs(rx_min - lx_min) / 2.0))
if lx_min > static_min_x:
    ans = min(ans, calc_ans(lx_min - static_min_x))
if static_min_x > rx_min:
    ans = min(ans, calc_ans(static_min_x - rx_min))

ans = min(ans, calc_ans(abs(uy_max - dy_max) / 2.0))
if dy_max > static_max_y:
    ans = min(ans, calc_ans(dy_max - static_max_y))
if static_max_y > uy_max:
    ans = min(ans, calc_ans(static_max_y - uy_max))

ans = min(ans, calc_ans(abs(uy_min - dy_min) / 2.0))
if dy_min > static_min_y:
    ans = min(ans, calc_ans(dy_min - static_min_y))
if static_min_y > uy_min:
    ans = min(ans, calc_ans(static_min_y - uy_min))

print(ans)

Measured memory_bytes: 46680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 510;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

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

int h, w, cnt;
int a[MAX_N][MAX_N];
vector<int> x, y, tx, ty;

int main(){
    cin >> h >> w;
    int i, j;
    REP(i, h) REP(j, w) cin >> a[i][j];

    REP(i, h - 1) REP(j, w){
        if (a[i][j] % 2){
            x.push_back(i + 1);
            y.push_back(j + 1);
            tx.push_back(i + 2);
            ty.push_back(j + 1);
            a[i + 1][j]++;
            cnt++;
        }
    }

    for (j = 0; j < w - 1; j++){
        if (a[h - 1][j] % 2){
            x.push_back(h);
            y.push_back(j + 1);
            tx.push_back(h);
            ty.push_back(j + 2);
            a[h - 1][j + 1]++;
            cnt++;
        }
    }

    cout << cnt << endl;
    for (i = 0; i < (int)x.size(); i++){
        cout << x[i] << " " << y[i] << " " << tx[i] << " " << ty[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 5220
#include<bits/stdc++.h>
#define LL long long
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(x,l,r) for(int x=l,x##_=r;x<=x##_;x++)
#define FR(x,l,r) for(int x=l,x##_=r;x<x##_;x++)
#define DOR(x,r,l) for(int x=r,x##_=l;x>=x##_;x--)
using namespace std;
const int N=300005;
int n,cnt,A[N],B[N],ans[N];
bool fl;
int main() {
	scanf("%d",&n);
	FOR(i,1,n)scanf("%d",&A[i]);
	DOR(i,n,1){
		for(int j=i+i; j<=n; j+=i)A[i]^=A[j];
		if(A[i])cnt++;
	}
	printf("%d\n",cnt);
	FOR(i,1,n)if(A[i])printf("%d ",i);
	return 0;
}


Measured memory_bytes: 1792
import math

a,b = (int(x) for x in input().split())
if (a*100)%8 == 0:
  amin = int(a/0.08)
else:
  amin = math.ceil(a/0.08)
if ((a+1)*100)%8 == 0:
  amax = int((a+1)/0.08)-1
else:
  amax = math.floor((a+1)/0.08)

if (b*100)%10 == 0:
  bmin = int(b/0.1)
else:
  bmin = math.ceil(b/0.1)
if ((b+1)*100)%10 == 0:
  bmax = int((b+1)/0.1)-1
else:
  bmax = math.floor((b+1)/0.1)
  
if amax < bmin or bmax < amin:
  print(-1)
else:
  la = list(range(amin,amax))
  lb = list(range(bmin,bmax))
  print(min(set(la) & set(lb)))

Measured memory_bytes: 3064
#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define lc (x<<1)
#define rc (x<<1|1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define ll long long
#define pi pair<int,int>
using namespace std;
const int N=1e5+10,M=4*N,size=1<<20,mod=998244353;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	x=0; int f=1; char c=gc;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c))x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x<0) putchar('-'),x=-x;
	if(x>9) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {qw(x); putchar(' ');}
template<class o> void pr2(o x) {qw(x); puts("");}

//math
ll gcd(ll x,ll y) {return !x?y:gcd(y%x,x);}
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}

int n,m,fa[N],q[N],l,r;
bool v[N];
struct edge{int y,next;}a[M]; int len,last[N];
void ins(int x,int y) {a[++len]=(edge){y,last[x]};last[x]=len;}


int main() {
	qr(n); qr(m);
	for(int i=1,x,y;i<=m;i++)
		qr(x),qr(y),ins(x,y),ins(y,x);
	q[l=r=1]=1;v[1]=1;
	while(l<=r) {
		int x=q[l++];
		for(int k=last[x],y;k;k=a[k].next) 
			if(!v[y=a[k].y]) {
				q[++r]=y;
				fa[y]=x;
				v[y]=1;
			}
	}
	for(int i=2;i<=n;i++)
		if(!fa[i]) return puts("No"),0;
	puts("Yes");
	for(int i=2;i<=n;i++) pr2(fa[i]);
	return 0;
}



Measured memory_bytes: 7852
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using ll =long long;
using namespace std;
/*int main() {
	ll A, B;
	string a;
	cin >> A;
	
	cin >> a;
	cin >> B;
	if (a == "+") {
	
		cout << A + B;
	
	}
	else {
		cout << A - B;
	}

}*/
int main() {
	int A, B;
	string S;
	int count=0; 
	int i = 0;
	cin >> A >> B;
	cin >> S;
	int x=1;
	while (S[i]) {
		if ((S[i] == '-' && i != A)|| (S[A] != '-' )) {

			x = 0;
		}
		count++;
		i++;
	}
	if (count == B + A + 1 && x==1) {
		cout << "Yes";

	}
	else {
		cout << "No";
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    int N;
    cin >> N;
    vector<i64> A(N);
    for(i64 &x : A) cin >> x;
    vector2d<int> edge(N);
    for(int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    int r = -1; // root
    for(r = 0; r < N; r++) {
        if(edge[r].size() == 1) {
            break;
        }
    }
    bool ans = true;
    ans &= recursive([&](auto f, int prev, int i) -> i64 {
        if(i != r && edge[i].size() == 1) return A[i];
        i64 n;
        if(i == r) n = A[i];
        else n = 2 * A[i];
        for(int j : edge[i]) {
            if(j == prev) continue;
            i64 x = f(f, i, j);
            if(x > A[i]) ans = false;
            n -= x;
        }
        if(n > A[i] || 0 > n) ans = false;
        return n;
    })(r, r) == 0;
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}



Measured memory_bytes: 12544
from collections import deque
while True:
  w, h = list(map(int, input().split()))
  if w==0:
    break
  visited = [[0 for i in range(w)] for i in range(h)]
  visited[0][0] = 1
  ywall = [[] for i in range(h)]
  xwall = [[] for i in range(h-1)]
  for i in range(h*2-1):
    if i%2==0:
      ywall[i//2] = list(map(int, input().split()))
    else:
      xwall[i//2] = list(map(int, input().split()))
  gx, gy = w-1, h-1
  dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]
  que = deque([(0, 0)])
  while len(que):
    x, y = que.popleft()
    for dxt, dyt in zip(dx, dy):
      nx, ny = x+dxt, y+dyt
      if 0<=nx<w and 0<=ny<h:
        if visited[ny][nx]!=0:
          continue
        if (dxt==1 and ywall[y][x]!=1) or (dxt==-1 and ywall[y][x-1]!=1) or (dyt==1 and xwall[y][x]!=1) or (dyt==-1 and xwall[y-1][x]!=1):
          visited[ny][nx] = visited[y][x]+1
          que.append((nx, ny))
  print(visited[gy][gx])


Measured memory_bytes: 6008
#include<iostream>
using namespace std;
int main(){
	int n1,n2,m1,m2,z;
	cin>>n1>>n2>>m1>>m2;
   z=min(n2,m2)-max(n1,m1);
    if(z>0)
       cout<<z;
       else
       cout<<"0";


	return 0;
	
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    for (i, c) in s.iter().enumerate() {
        if i % 2 == 1 {
            continue;
        }
        print!("{}", c);
    }
    println!("");
}


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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<int> a(m);
    ll count=0;
    for(int i=0;i<m;i++){
        cin>>a[i];
        count+=a[i];
    }
    count=n-count;
    if(count<0){
        cout<<"-1"<<endl;
    }else{
        cout<<count<<endl;
    }
}

Measured memory_bytes: 3644
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int N;
	cin >> N;
	ll ans = 1;
	ll last_ans = 1;
	vector<ll> A(N, 0);
	rep(i, N)
	{
		cin >> A[i];
		if (A[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}

	rep(i, N)
	{
		ans *= A[i];
		if (ans > 1000000000000000000LL)
		{
			ans = -1;
			break;
		}
		else if (ans < last_ans)
		{
			ans = -1;
			break;
		}
		last_ans = ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4052
import math

k=int(input())

sum=0
sum1=0
sum2=0
sum3=0
for a in range(1,k+1):
    sum1+=a
sum+=sum1
for a in range(1,k+1):
    for b in range(a+1,k+1):
        ans=a
        ans=math.gcd(ans,b)
        sum2+=ans
sum+=sum2*6
for a in range(1,k+1):
    for b in range(a+1,k+1):
        for c in range(b+1,k+1):
            ans=a
            ans=math.gcd(ans,b)
            ans=math.gcd(ans,c)
            sum3+=ans
sum+=sum3*6

print(sum)

Measured memory_bytes: 9224
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   string s; cin>>s;

   int q; cin>>q;

   bool rev = false;

   queue<char> beg, end;

   for(int i = 0; i < q; i++){
       int t; cin>>t;
       if(t==1){
           rev = rev^true;
       }else{
           int f; cin>>f;
           char ch; cin>>ch;
           if(rev){
               if(f==1)
                    end.push(ch);
                else   beg.push(ch);
           }else{
               if(f==1)
                    beg.push(ch);
                else end.push(ch);

           }
       }
    }

    
    string x, y;
    while(!beg.empty()){
        x = string(1, beg.front()) + x;
        beg.pop();
    }
    s = x + s;

    while(!end.empty()){
        y += string(1, end.front());
        end.pop(); 
    }
    s += y;

    if(rev)
        reverse(all(s));

    cout<<s<<"\n";
    


   














}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 1400
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;
const int64_t INF=10000000000000000;

int main(){
	int64_t a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==0){
		cout<<a-b<<endl;
	}else{
		cout<<b-a<<endl;
	}



}


Measured memory_bytes: 256
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(ll i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };

int main() {
    int H, W, D;
    cin >> H >> W >> D;
    vvi A(H + 1, vi(W + 1));
    vector<pair<int, int>> B(H * W + 1);
    rep(i, H) {
        rep(j, W) {
            int a;
            cin >> a;
            B[a] = mp(i + 1, j + 1);
        }
    }
    int Q;
    cin >> Q;
    vi L(Q);
    vi R(Q);
    rep(i, Q) {
        cin >> L[i];
        cin >> R[i];
    }

    vvi dis(D);
    rep(i, D) {
        int sum = 0;
        int x = i;
        if (i == 0)x = 0;
        dis[i].push_back(0);
        while (x + D <= H * W) {
            int x1 = B[x].first;
            int y1 = B[x].second;
            int x2 = B[x + D].first;
            int y2 = B[x + D].second;
            sum += abs(x1 - x2) + abs(y1 - y2);
            dis[i].push_back(sum);
            x += D;
        }
    }


    rep(i, Q) {
        int a = L[i] / D;
        int b = L[i] % D;
        int c = R[i] / D;
        int ans;
        if (b != 0) {
            ans = dis[b][c] - dis[b][a];
        }
        else {
            ans = dis[b][c] - dis[b][a];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 7168