akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s,x0=0,x1=1e9,x2,y0=0,y1=1,y2;
    cin>>s;
    x2=((ll)1e9-s%(ll)1e9)%(ll)1e9;
    y2=(s+x2)/(ll)1e9;
    cout<<x0<<" "<<y0<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <stdio.h>
using namespace std;

int main(){
    int num = 753;
    string S;
    cin >> S;
    int X = (S[0]-'0')*100 + (S[1]-'0')*10 + (S[2]-'0');
    //cout << X <<endl;
    int dif = num - X;
    if(dif < 0)dif *= -1;
    for(int i=1;i<S.size()-2;i++){
        X = (S[i]-'0')*100 + (S[i+1]-'0')*10 + (S[i+2]-'0');
        //cout << X << endl;
        int local = num - X;
        if(local < 0)local *= -1;
        if(local < dif)dif = local;
    }
    cout << dif << endl;
}

Measured memory_bytes: 256
while True:
    a, op, b=input().split()
    a=int(a)
    b=int(b)
    if op=="+":
        answer=a+b
    elif op=="-":
        answer=a-b
    elif op=="*":
        answer=a*b
    elif op=="/":
        answer=a//b
    elif op=="?":
        break
    print(answer)


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

int N, K;

int main() {
  using namespace std;
  cin >> N >> K;

  long long ans = 0;

  if (K == 0) {
    cout << N * (long long)N << endl;
    return 0;
  }

  for (int i = K + 1; i <= N; ++i) {
    // ? % i >= K
    // K, K + i, ... <= N
    ans += N / i * (i - K) + std::max(0, (N % i - (K - 1)));
  }

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


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

int main() {
int N;
cin >> N;
if (N < 10) cout << N << endl;
else if (10 <= N && N<100) cout << 9 << endl;
else if (100 <= N && N< 1000) cout << 9+N-99 << endl;
else if (1000 <= N && N<10000) cout << 909 << endl;
else if (10000 <= N && N< 100000) cout << 909 + N -9999 << endl;
else cout << 90909 << endl;


return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdlib.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	scanf("%lld",&n);
	if(n%2==0)
	{
		printf("%lld",n);
	}
	else
		printf("%lld",2*n);
	return 0;
} 

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

int N, A, B;

int main() {
    cin >> N >> A >> B;
    int train = N * A;
    cout << min({train, B}) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n;
   cin>>n;
   string cn1,cn2;
   cin>>cn1;
   cin>>cn2;
   string k;
   int l=0;
   for(int i=0,j=0;i<n;i++,j++){
        k[l]=cn1[i];
        l++;
        k[l]=cn2[j];
        l++;



   }
   k[l]='\0';
   //cout<<" hello"<<endl;
   for(int i=0;i<l;i++){
    cout<<k[i];
   }





}


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

int n, m;
int s[100005], t[100005];
vector<int> edge[10005], redge[10005];
bool used[10005];
vector<int> ord;
int comp[10005];
set<int> usedin, usedout;
void dfs1(int a){
  if(used[a]) return;
  used[a]=true;
  for(int i=0; i<edge[a].size(); i++)
    dfs1(edge[a][i]);
  ord.push_back(a);
}
void dfs2(int a, int c){
  if(used[a]) return;
  used[a]=true;
  comp[a]=c;
  for(int i=0; i<redge[a].size(); i++)
    dfs2(redge[a][i], c);
}int main(){
  cin >> n >> m;
  for(int i=0; i<m; i++){
    cin >> s[i] >> t[i];
    edge[s[i]].push_back(t[i]);
    redge[t[i]].push_back(s[i]);
  }
  fill(used, used+n, false);
  for(int i=0; i<n; i++) dfs1(i);
  int cnt=0;
  fill(used, used+n, false);
  for(int i=n-1; i>=0; i--) 
    if(!used[ord[i]])
      dfs2(ord[i], cnt++);
  for(int i=0; i<m; i++){
    if(comp[s[i]]!=comp[t[i]]){
      usedout.insert(comp[s[i]]);
      usedin.insert(comp[t[i]]);
    }
  }
  int ans=0;
  if(cnt>1)
    ans=max(cnt-usedout.size(),
         cnt-usedin.size());
  cout << ans << endl;
}

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

int main()
{
	int day;
	cin >> day;

	switch(day%7){
		case 0 :
			cout << "thu" <<endl;
			break;
		case 1 :
			cout << "fri" <<endl;
			break;
		case 2 :
			cout << "sat" <<endl;
			break;
		case 3 :
			cout << "sun" <<endl;
			break;
		case 4 :
			cout << "mon" <<endl;
			break;
		case 5:
			cout << "tue" <<endl;
			break;
		case 6 :
			cout << "wed" <<endl;
			break;
	}

	return 0;
}


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, p1, p2, x=0;

            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            p1 = n * a;
            p2 = b;

            if (p1 < p2)
                x = p1;
            else  
                x = p2;

            Console.WriteLine(x);

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  double N, K;
  double res=0;
  cin >> N >> K;

  // 1 ~ K-1                                                                             
  if(K-1 < N) {
    res = (K-1)/N;
  }
  else {
    res = 1.0;
  }

  double win=0;
  int limit = (int)min(N, K-1);
  FOR(i,1,limit){
    int num=i;
    double p = 1;
    while(num<K){
      num *= 2;
      p /= 2.0;
    }
    win += p/limit;
  }
  res *= win;

  // K ~                                                                                 
  if(K-1<N) res += (N-K+1)/N;

  printf("%1.12f\n", res);
}


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

using ll = long long;
using ul = unsigned long long;
using ld = long double;

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

    int c = 0;
    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] != T[i]) c++;
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 3860
#include <stdio.h>
#include <iostream>
#include <climits>
#include <cmath>

using namespace std;

double solve(int d, int e){
	//x + y = d
	//sqrt(x**x + y**y) = e
	int tmpx = 0, tmpy = 0;
	double res = 100000.0;
	for(int ix = 0;ix <= 100;ix++)
		for (int iy = 0;iy <= 100 ; iy++){
			if(ix + iy != d)
				continue;
			double tmp = sqrt(ix*ix + iy*iy) - (double)e;
			tmp = tmp>0?tmp:-tmp;
			if (tmp < res)
				res = tmp;
		}
	return res;
}

int main(){

	int d,e;
	while(cin >> d >> e , d||e){
		printf("%.10lf\n", solve(d, e));
	}

	return 0;
}


Measured memory_bytes: 3124
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int k;
	vector<int> as;

	scanf("%d", &k);
	as.resize(k);
	for(int i = 0; i < k; ++i)
		scanf("%d", &as[i]);

	i64 lo = 2, hi = 2;
	bool failed = false;

	for(int index = k - 1; index >= 0; --index) {

		i64 v = as[index];

		i64 p_lo = (lo / v + !!(lo % v)) * v;
		i64 p_hi = (hi / v) * v;

		if(p_lo > p_hi) {
			failed = true;
			break;
		}

		lo = p_lo;
		hi = p_hi + (v - 1);
	}

	if(failed)
		printf("%d\n", -1);
	else
		printf("%lld %lld\n", lo, hi);

	return 0;
}

/* waffle */


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

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



Measured memory_bytes: 3088
#include <cassert>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <cstdalign>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <exception>
#include <initializer_list>
#include <limits>
#include <new>
#include <stdexcept>
#include <string>
#include <system_error>
#include <typeinfo>

#if __has_include(<string_view>)
#include <string_view>
#endif

#include <algorithm>
#include <array>
#include <cfenv>
#include <cmath>
#include <deque>
#include <forward_list>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#if __has_include(<filesystem>)
#include <filesystem>
#endif

#include <cinttypes>
#include <cstdio>

#include <atomic>
#include <condition_variable>
#include <future>
#include <mutex>
#include <regex>
#include <shared_mutex>
#include <thread>

using namespace std;
using namespace std::literals;
int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] bw = new int[N];
		List<int>[] E = new List<int>[N];
		for(int i=0;i<N;i++){
			E[i] = new List<int>();
		}
		for(int i=0;i<M;i++){
			E[U[i]].Add(V[i]);
		}
		
		int[][] min = new int[3][];
		for(int i=0;i<3;i++){
			min[i] = new int[N];
			for(int j=0;j<N;j++){
				min[i][j] = -3;
			}
		}
		
		var q = new Queue<int>();
		min[0][S] = 0;
		q.Enqueue(0 * N + S);
		while(q.Count > 0){
			var np = q.Dequeue();
			int t = np / N;
			int now = np % N;
			int nt = (t + 1) % 3;
			foreach(var nxt in E[now]){
				if(min[nt][nxt] == -3){
					min[nt][nxt] = min[t][now] + 1;
					q.Enqueue(nt * N + nxt);
				}
			}
		}
		
		Console.WriteLine(min[0][T] / 3);
		
		
	}
	int N,M;
	int[] U,V;
	int S,T;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		U = new int[M];
		V = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			U[i] = d[0] - 1;
			V[i] = d[1] - 1;
		}
		d = ria();
		S = d[0] - 1; T = d[1] - 1;
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 28036
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
 
typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int N = 2e5 + 123;
int n, k, a[N], m, fen[N];
ll p[N];
 
void upd(int x) {
	for (; x <= m; x |= (x + 1)) {
		fen[x]++;
	}
}
 
int get(int x) {
	int res = 0;
	for (; x >= 0; x = (x & (x + 1)) - 1) {
		res += fen[x];
	}
	return res;
}
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> k;
	vll comp;
	comp.pb(0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] -= k;
		p[i] = p[i - 1] + a[i];
		comp.pb(p[i]);
	}
	sort(all(comp));
	comp.erase(unique(all(comp)), comp.end());
	m = comp.size();
	int z = lower_bound(all(comp), 0) - comp.begin() + 1;
	upd(z);
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		p[i] = lower_bound(all(comp), p[i]) - comp.begin() + 1;
		ans += get(p[i]);
		upd(p[i]);
	}
	cout << ans;
}


Measured memory_bytes: 5104
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

T = ST()
print(T.replace('?','D'))


Measured memory_bytes: 10312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] A = new int[3][3];
		boolean[][] S = new boolean[3][3];
		for(int i=0; i<3; i++) {
			for(int j=0; j<3; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		int N = sc.nextInt();
		int[] b = new int[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextInt();
		}
		int s=0;
		int l=0;
		String f="No";
		for(int i=0; i<3; i++) {
			for(int j=0; j<3; j++) {
				S[i][j] = false;
				for(int k=0; k<N; k++) {
					if(b[k]==A[i][j]) {
						S[i][j] = true;
					}
				}
			}
		}

		for(int i=0; i<3; i++) {
			if(S[i][0] && S[i][1] && S[i][2]) {
				f="Yes";
			}
		}
		for(int i=0; i<3; i++) {
			if(S[0][i] && S[1][i] && S[2][i]) {
				f="Yes";
			}
		}

		if(S[0][0] && S[1][1] && S[2][2]) {
			f="Yes";
		}
		if(S[0][2] && S[1][1] && S[2][0]) {
			f="Yes";
		}

		System.out.println(f);
	}

}

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

int main(){
	int N;
	vector<int> A,B,C;
	long long ans;
	cin >> N;
	rep(i,N){int t; cin >> t; A.push_back(t); }
	rep(i,N){int t; cin >> t; B.push_back(t); }
	rep(i,N){int t; cin >> t; C.push_back(t); }

	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());

	ans = 0;
	rep(i,N){
		ans += (lower_bound(A.begin(),A.end(),B[i])-A.begin()) * (N-(upper_bound(C.begin(),C.end(),B[i])-C.begin()));
	}

	cout << ans << endl;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
long long a,b;
char ch;
int main()
{
	cin>>a>>ch>>b;
	if(ch=='-')cout<<a-b;
	if(ch=='+')cout<<a+b;
	if(ch=='*')cout<<a*b;
	if(ch=='/')cout<<a/b;
	return 0;
}

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

int main()
{
	int n;
	long long int m;
	cin>>n>>m;

	vector<long long int> v(n,0);

	map<long long int,long long int> l;
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
		if(i!=0)
		{
			v[i]+=v[i-1];
		}
		l[v[i]%m]++;
	}

	//cout<<res<<endl;
	long long int res=0;
	res+=l[0];
	long long int res1=0;
	for(int i=0;i<n;i++)
	{
		res1+=l[v[i]%m]-1;
	}
	//cout<<res1<<endl;
	cout<<res+res1/2<<endl;

}

Measured memory_bytes: 4992
N = int(input())
import copy

def nex(lis):
    li = copy.copy(lis)
    if len(li) == N:
        print(''.join([chr(97+i) for i in li]))
        return 

    for x in range(max(li)+2):
        li2 = copy.copy(li)
        li2.append(x)
        nex(li2)
        
nex([0])

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

ll dp[51][51][2501];

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

    int n, a; cin >> n >> a;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k <= 2500; k++) {
                dp[i + 1][j][k] += dp[i][j][k];
                if (k + x[i] <= 2500) dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
            }
        }
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++) ans += dp[n][i][a * i];

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


Measured memory_bytes: 49152
#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>;

int main(){
  string n;
  cin >> n;
  int ans = 0;
  for (char c: n) ans += c-'0';
  if (ans % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3700
S = input()
n = int(input())
for i in range(n):
    line = input()
    line_len = len(line.split())
    #print(line_len)
    if(line_len == 3):
        op,a,b = line.split()
    elif(line_len == 4):
        op,a,b,rep = line.split()
    a = int(a)
    b = int(b)
    if(op == "print"):
        print(S[a:b+1])
    elif(op == "replace"):
        tmp = S[0:a] + rep + S[b+1:]
        S = tmp
        #print(S)
    elif(op == "reverse"):
        tmp = list(S[a:b+1])
        tmp.reverse()
        #print(tmp)
        S = S[0:a] + "".join(tmp) + S[b+1:]
        #print(S)


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

using namespace std;

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

ll N, M, P, Q, R, S, A, B, C, D, E, F, X, Y, Z;
ll red[200005], green[200005], colourless[200005];



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> X >> Y >> A >> B >> C;
	priority_queue<pi> pq;
	for (int i = 1; i <= A; ++i){
		cin >> red[i];
		pq.push(pi(red[i],0));
	}
	for (int i = 1; i <= B; ++i){
		cin >> green[i];
		pq.push(pi(green[i],1));
	}
	for (int i = 1; i <= C; ++i){
		cin >> colourless[i];
		pq.push(pi(colourless[i],2));
	}
	while (!pq.empty()){
		if (P + Q + R == X + Y){
			break;
		}
		pi a = pq.top();
		pq.pop();
		if (a.second == 0 && P == X) continue;
		if (a.second == 1 && Q == Y) continue;
		Z += a.first;
		if (a.second == 0) P++;
		if (a.second == 1) Q++;
		if (a.second == 2) R++;
	}
	cout << Z << '\n';
	return 0;
}

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


int main()
{
    int a,p;
    cin>>a>>p;
    p+=a*3;
    cout<<p/2<<endl;
    return 0;
}

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

int main(){
    int bingo[3][3];//横縦
    bool aingo[3][3];
    bool flag = false;

    
    for(int i=0; i<3; i++){
        for(int k=0; k<3; k++){
            cin >> bingo[i][k];
            aingo[i][k]=false;
        }
    }



    int N ;

    cin >> N;

    int b[N];

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

    for(int i=0; i<3; i++){
        for(int k=0; k<3; k++){
            for(int m=0; m<N; m++){
                if(bingo[i][k]==b[m]){
                    aingo[i][k]=true;
                }
            }
        }
    }

    for(int i=0; i<3; i++){
        if(aingo[i][0]==true&&aingo[i][1]==true&&aingo[i][2]==true){
            flag=true;
        }
        if(aingo[0][i]==true&&aingo[1][i]==true&&aingo[2][i]==true){
            flag=true;
        }
    }
    
    if(aingo[0][0]==true&&aingo[1][1]==true&&aingo[2][2]==true){
            flag=true;
    }
    if(aingo[0][2]==true&&aingo[1][1]==true&&aingo[2][0]==true){
            flag=true;
    }

    if(flag==true){
        cout << "Yes";
    }
    else{
        cout << "No";
    }


    return 0;
}

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

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int c0 = gcd(A,B);

    int i = 0;
    for (int j = c0; 0 < j; --j){        
        if (c0 % j == 0) {
            i++;
        }
        if (i == K) {
            cout << j << endl;
            break;
        }
    }
    return 0;
}

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

bool judge(int x) {
  if (x < pow(10, 1)) return true;
  else if (x < pow(10, 2)) return false;
  else if (x < pow(10, 3)) return true;
  else if (x < pow(10, 4)) return false;
  else if (x < pow(10, 5)) return true;
  else return false;
}

void solve() {
  int n;
  cin >> n;
  int count;
  for (int i = 1; i <= n; ++i) if (judge(i)) count++;
  cout << count << endl;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long int
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
 
using namespace std; 
 
 
int main() 
{
    int n;
    cin>>n;

    int cnt=1;
    int ans = 0;
    for(int i=0;i<n;i++) {
        int a;
        cin>>a;

        if(a!=cnt) {
            ans++;
        }
        else if(a==cnt) {
            cnt++;
        }
    }

    if(cnt==1) cout<<-1<<endl;
    else 
        cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
#include <map>
using namespace std;

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

typedef long long lint;
typedef pair<int,int> P;


int main() {
    int N,D;
    cin >> N >> D;

    	int X[20][20];
    REP(i,N){
    	REP(j,D) cin >> X[i][j];
    }

    int ans=0;

    REP(i,N){
    	FOR(j,i+1,N){
    		double tmp=0;
    		REP(k,D){
    			tmp+=pow(X[i][k]-X[j][k],2);
    		}
    		tmp=sqrt(tmp);

    		if(ceil(tmp)==floor(tmp)){
    			ans++;
    		}
    	}
    }

    cout << ans << endl;



}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# 10 -> n
def ten2n(a,n):
  x=a//n
  y=a%n
  if x:
    return ten2n(x,n)+str(y)
  return str(y)

def main():
  n=S()

  l=list(n)

  l2=[]
  for i in range(pow(2,len(n)-1)):
    l2.append(list(ten2n(i,2).zfill(len(n)-1)))

  sm=0
  for x in l2:
    s=''
    for i in range(len(x)):
      if x[i]=='0':
        s+=l[i]
      else:
        s+=l[i]+'+'
    if len(l)>1:
      s+=l[-1]
    sm+=eval(s)

  return sm


print(main())


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

int main() {
    string s; cin >> s;
    int q; cin >> q;
    string t;
    for (int i = 0; i < q; i++) {
        int type; cin >> type;
        if (type == 1) {
            swap(s, t);
        } else {
            int f; char c;
            cin >> f >> c;
            if (f == 1) {
                t += c;
            } else {
                s += c;
            }
        }
    }
    reverse(t.begin(), t.end());
    t += s;
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 1128
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int x = n % 500;
		if (x <= a) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21716
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{

			int[] count = new int[26];
			int a = (int)'a';
			while (true)
			{
				string s = Console.ReadLine();
				if (s == null) break;
				string ss = s.ToLower();
				char[] c = new char[s.Length];
				for (int i = 0; i < s.Length; i++)
				{
					c[i] = (char)ss[i];
				}
				foreach (char ch in c)
				{
					for (int i = 0; i < 26; i++)
					{
						if (ch == (char)(a + i))
							count[i] += 1;
					}
				}
			}
			for (int i = 0; i < 26; i++)
			{
				Console.WriteLine("{0} : {1}", (char)(a + i), count[i]);
			}
		}
	}
}

Measured memory_bytes: 9016
#!/usr/bin/python
#http://www.checkio.org/mission/spaceship-landing-strip/ verifier.
#sadly TLE for aizu0116

import sys
if sys.version_info[0]>=3: raw_input=input

def checkio(data):
	y=len(data)
	x=len(data[0])
	m=[[0]*x for i in range(y)]
	for j in range(y):
		r=0
		for i in range(x):
			#if data[j][i]=='.': r+=1
			if data[j][i]==1: r+=1
			else: r=0
			m[j][i]=r
	r=0
	for i in range(x):
		for j in range(y):
			M=9999999
			for k in range(j,y):
				M=min(M,m[k][i])
				r=max(r,M*(k-j+1))
	return r

'''
if __name__=='__main__':
	try:
		while True:
			y,x=[int(e) for e in raw_input().split()]
			if y==0: break
			data=[raw_input().rstrip() for i in range(y)]
			print(checkio(data))
	except EOFError:
		pass
'''
if __name__=='__main__':
	n=int(raw_input())
	try:
		for _i in range(n):
			data=[[int(e) for e in raw_input().split()] for i in range(5)]
			print(checkio(data))
			raw_input()
	except EOFError:
		pass

Measured memory_bytes: 4284
package main

import (
	"fmt"
)

func main() {
	var c byte
	fmt.Scanf("%c", &c)
	fmt.Printf("%c\n", c+1)
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	
	//ABC 115 d 

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		long x = Long.parseLong(sc.next());
		

		long ans = rec(n,x);
		System.out.println(ans);

	}
	
	static long rec(int n , long x) {
		
		if(n == 0) {
			return 1;
		}
	
		long ren = (1L << n+1) - 3;		//レベルn-1の層の枚数
		long num = (1L << n) - 1 ;	 	//レベルn-1にあるPの数
		
		if(x == 1) {
			return 0;
		}
		
		if(x <= ren +1) {
			return rec(n-1,x-1); 
		}
		else if (x == ren +2) {
			return num + 1;
		}
		else if (x < 2 * ren + 3) {
			return num + 1 + rec(n-1,x-ren-2);
		}
		else {
			return 2 * num +1;
		}
	}
	
	// B|(n-1Level)|P|(n-1Level)|B
	//  	①		②		③

}


Measured memory_bytes: 22996
import sys
n = [input() for i in range(9)]
path = [[0 for i in range(5)] for j in range(5)]

for i, v in enumerate([a[1] for a in enumerate(n) if a[0] % 2 == 0]):
    for j in range(4):
        if v[j] == '1':
            path[i][j] += 1
            path[i][j+1] += 2


for i, v in enumerate([a[1] for a in enumerate(n) if a[0] % 2 != 0]):
    for j in range(5):
        if v[j] == '1':
            path[i][j] += 4
            path[i+1][j] += 8

dur = {'R':(1, 0, 1),
       'L':(2, 0, -1),
       'U':(8, -1, 0),
       'D':(4, 1, 0)}

dur_next = {'R':('U','R','D','L'),
            'L':('D','L','U','R'),
            'U':('L','U','R','D'),
            'D':('R','D','L','U')}
def walk():
    global cx, cy
    cx = dur[d][2] + cx
    cy = dur[d][1] + cy

def next_D():
    global cx,cy,d,dur
    for nd in dur_next[d]:
        if path[cy][cx] & dur[nd][0]:
            d = nd
            break

cx = cy = 0
d = 'R'
log = []

while 1:
    log.append(d)
    walk()
    if cx == cy == 0:
        break

    next_D()

print(''.join(log))

Measured memory_bytes: 7556
#include <cstdio>
#include <vector>
static const int MAXN = 1e5 + 4;

int n;
std::vector<int> e[MAXN];

int par[MAXN], dep[MAXN], sts[MAXN];

void dfs(int u, int p = -1, int d = 0)
{
    par[u] = p;
    dep[u] = d;
    sts[u] = 1;
    for (int v : e[u]) if (v != p) {
        dfs(v, u, d + 1);
        sts[u] += sts[v];
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 0, u, v; i < n - 1; ++i) {
        scanf("%d%d", &u, &v); --u, --v;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    dfs(0);
    int moves = (dep[n - 1] + 1) / 2;
    int v = n - 1;
    for (int i = 0; i < moves - 1; ++i) v = par[v];
    puts(n - sts[v] > sts[v] ? "Fennec" : "Snuke");

    return 0;
}


Measured memory_bytes: 14720
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    string s;cin>>s;
    if(s[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }
    int ans=0;
    rep(i,2,s.size()-1){
        if(s[i]=='C')ans=1;
    }
    if(ans==0){
        cout<<"WA"<<endl;
        return 0;
    }
    int c=0;
    rep(i,1,s.size()){
        if(s[i]-'a'<0)c++;
    }if(c!=1){
        cout<<"WA"<<endl;
        return 0;
    }
    cout<<"AC"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n, l;
	cin >> n >> l;
	ll ans = 0;
	int m = INF;
	bool flag = 0;
	REP(i, n){
		ans += i + l;
		if (i+l < 0 and m > abs(i+l)){
			m = abs(i+l);
			flag = 1;
		}
		else {
			m = min(m, i+l);
			flag = 0;
		}
	}
	if (flag) cout << ans + m << endl;
	else cout << ans - m << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
    /**
     * https://atcoder.jp/contests/dp/tasks/dp_f
     * Longest Common Subsequence.
    */
    static ArrayList<Character> answer = new ArrayList<>();
    enum Path{
        I_MINUS_1, // upper cell
        J_MINUS_1, // left-side cell
        I_MINUS_1_J_MINUS_1 // upper left
    }

    private static void solver(String s, String t){
        int n = s.length();
        int m = t.length();
        int[][] dp = new int[n + 1][m + 1];
        Path[][] parent = new Path[n + 1][m + 1];

        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                if(s.charAt(i - 1) == t.charAt(j - 1)){
                    dp[i][j] = dp[i - 1][j - 1] + 1;   // +1 to the length
                    parent[i][j] = Path.I_MINUS_1_J_MINUS_1; // set parent
                } else{ 
                    int l1 = dp[i - 1][j]; // get upper row cell's length
                    int l2 = dp[i][j - 1]; // get left col cell's length
                    dp[i][j] = l1 > l2 ? l1 : l2; // get max length 
                    parent[i][j] = l1 > l2 ? Path.I_MINUS_1 : Path.J_MINUS_1;
                }
            }
        }
        getPath(dp, parent, n, m, s, t);
    }

    private static void getPath(int[][] dp, Path[][] parent, int n, int m, String s, String t){
        
        while(n > 0 && m > 0){
            
            if(s.charAt(n - 1) == t.charAt(m - 1))
                answer.add(s.charAt(n - 1));
            
            if(parent[n][m] == Path.I_MINUS_1_J_MINUS_1){
                n--; m--;
            } else if(parent[n][m] == Path.I_MINUS_1){
                n--;
            } else{
                m--;
            }
        }
        for(int i = answer.size() - 1; i>=0; --i){
            System.out.print(answer.get(i));
        }
    }        

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = in.next();
        String t = in.next();

        if(s == "" || t == ""){
            System.out.println("");
            return;
        }

        solver(s, t);
    }
}

Measured memory_bytes: 128460
n,w = map(int, input().split())
item = [list(map(int,input().split())) for i in range(n)]
dp = [0 for i in range(w+1)]
for i in range(w+1):
    for v in item:
        if i + v[1] <= w:
            dp[i+v[1]] = max(dp[i]+v[0],dp[i+v[1]])
print(dp[w])


Measured memory_bytes: 5928
#include<stdio.h>
#define MOD 1000000007LL

long long int pow( long long int b, long long int i ){
  long long int r = 1;
  while( i ){
    if( i%2 ){
      r *= b;
      r %= MOD;
    }
    b *= b;
    b %= MOD;
    i >>= 1;
  }
  return r;
}

int main(){
  int S;
  scanf("%d", &S);
  long long int dp[2002] = {};
  dp[0] = 1;
  for( int i = 0; i < S; i++ ){
    for( int j = i+3; j <= S; j++ ){
      dp[j] += dp[i];
      dp[j] %= MOD;
    } 
  }
  printf("%lld\n", dp[S]);
}

Measured memory_bytes: 2168
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

fn double_median(v: &mut Vec<i64>) -> i64 {
  v.sort();
  let n = v.len();
  if n % 2 == 0 {
    v[n / 2 - 1] + v[n / 2]
  } else {
    v[n / 2]
  }
}

#[fastout]
fn main() {
  input! {
    n: usize,
    mut ab: [(i64, i64); n],
  }
  let lb = double_median(&mut ab.iter().map(|&(a, _)| a).collect());
  let ub = double_median(&mut ab.iter().map(|&(_, b)| b).collect());

  println!("{}", ub - lb + 1);
}


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

using namespace std;

int main(){

  int pasta1,pasta2,pasta3,juice1,juice2;
  int ans_p;
  int ans_j;
  
  cin>>pasta1;
  cin>>pasta2;
  cin>>pasta3;
  cin>>juice1;
  cin>>juice2;

  if(pasta1<pasta2 && pasta1<pasta3)
	ans_p = pasta1;
  else if(pasta2<pasta1 && pasta2<pasta3)
	ans_p = pasta2;
  else
	ans_p = pasta3;

  if(juice1 < juice2)
	ans_j = juice1;
  else
	ans_j = juice2;

  cout<<ans_p + ans_j - 50 <<endl;

  return 0;
  
}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

bool adj[105][105];

int main()
{
	memset (adj, false, sizeof (adj ) );

	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	rep (i, n ){
		int v, k;
		cin >> v >> k;
		rep (j, k ){
			int u; cin >> u;
			adj[v][u] = true;
		} // end rep
	} // end rep
	
	for (int i = 1; i <= n; i++ )
		for (int j = 1; j <= n; j++ )
			cout << (adj[i][j] ? 1 : 0) << (j != n ? ' ' : '\n' );
	
	
	return 0;
}

Measured memory_bytes: 1216
// template version 1.10
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
//}}}

// dump macro {{{
#if defined(PCM) || defined(LOCAL)
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
// }}}

int solve(){
  int n,k;cin>>n>>k;

  double res=0;
  rep(i, 1, n+1){
    int x = i;
    double p = 1;
    while(x<k){
      x *= 2;
      p *= 2;
    }
    // dump(i, p);
    res += (double)1/p;
  }
  // cout << res/n << endl;
  printf("%.11f", res/n);
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int main()
{
	string n;
	int moto;
	int sum = 0;
	cin >> n;
	moto = atoi(n.c_str());
	for (int i = 0; i < n.size(); ++i)
	{
		sum += n[i] - '0';
	}
	cout << ((moto % sum == 0)?"Yes":"No") << endl;
	return 0;
}

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

int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = 0;
  if (m >= n * 2) {
    ans += n;
    m -= n * 2;
    ans += m / 4;
  } else {
    ans = m / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';
const input = fs.readFileSync("/dev/stdin", "utf8").split(/\n/);

// A - 高橋君とホテルイージー

const N = +input[0];
const K = +input[1];
const X = +input[2];
const Y = +input[3];
let result = 0;

for (let i = 0; i < N; i++) {
    if (i + 1 <= K) {
        result += X;
    } else {
        result += Y;
    }
}

console.log(result);

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 101010
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
unordered_map<ll,ll>par;
unordered_map<ll,bool>vis;
vector<ll>gr[maxp];
void solve(){
	ll n,i,m;
	in2(n,m);
	nfl(i,m){
		ll x,y;
		in2(x,y);
		gr[x].pb(y);
		gr[y].pb(x);
	}
	queue<ll>qq;
	qq.push(1);
	par[1]=-1;
	while(qq.size()){
		auto tp=qq.front();
		qq.pop();
		for(auto it:gr[tp]){
			if(vis[it]==0){
				qq.push(it);
				vis[it]=1;
				par[it]=tp;
			}
		}
	}
	sfl(i,1,n+1){
		if(!vis[i]){
			cout<<"No\n";
			return;
		}
	}
	cout<<"Yes\n";
	sfl(i,2,n+1){
		cout<<par[i]<<'\n';
	}
}	
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	#endif
	clock_t t1=clock();
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
	clock_t t2=clock();
	cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}	

Measured memory_bytes: 20168
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#define F first
#define S second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<28
#define all(n) n.begin(),n.end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
 
bool cmp_n(const P &pp,const P &qq){
  if(pp.S != qq.S)return pp.S < qq.S;
  return pp.F < qq.F;
}
 
int main(){
  int N,M;
  while(true){
    cin >> N >> M;
    if(N+M == 0)break;
    vector<P> vec;
    vec.clear();
    ll total = 0;
    rep(i,N)
      {
    int a,b;
    cin >> a >> b;
    total += a;
    vec.push_back(P(a,b));
      }
    sort(vec.begin(),vec.end(),cmp_n);
    if(0 >= total-M){
      cout << 0 << endl;
      continue;
    }
 
    
 
     
     
    ll sam = 0;
    ll dif = total - M;
 
    int index = 0;
    while(true){
      if(dif <= 0)break;
      sam += vec[index].S;
      //cout << "sum! " << vec[index].S << endl;
      dif--,vec[index].F--;
      if(vec[index].F == 0)index++;
    }
    
    cout << sam << endl;
  }
  return 0;
}

Measured memory_bytes: 1328
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;cin>>n>>k;
    string s;cin>>s;
    int now=0;
    int cnt=0;
    rep(i,0,n-1){
        if(s[i]!=s[i+1])now++;
        else cnt++;
    }
    int y=0;
    rrep(i,now,1){
        y++;
        if(i<=2)cnt++;
        else cnt+=2;
        if(y==k)break;
    }
    cout<<min(n-1,cnt)<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(x-r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3132
import numpy as np
n,k=map(int,input().split())
*a,=map(int, input().split())
a+=[0]
a=np.array(a)

ac=np.ndarray.cumsum(np.maximum(a,0))
acr=np.ndarray.cumsum(np.maximum(a[::-1],0))
amid=np.sum(a[:k])
ans=max(amid,0)+acr[n-k]
for i in range(n-k):
    #print(ans)
    amid+=a[i+k]
    amid-=a[i]
    ans=max(ans,ac[i]+max(amid,0)+acr[n-k-i-1])
    #print(ans,ac[i],amid,acr[n-k-i-1])
print(ans)





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

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    for(int i=0; i<n; i++){
        cin >> b.at(i);
    }
    for(int i=0; i<n; i++){
        cin >> c.at(i);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    vector<int> b_cnt(n);
    for(int i=0; i<n; i++){
        int check=b.at(i);
        int l=-1;
        int r=n;
        while(r>l+1){
            int mid=(l+r)/2;
            if(c.at(mid)>check) r=mid;
            else l=mid;
        }
        b_cnt.at(i)=n-r;
    }
    vector<ll> b_sum(n);
    b_sum.at(n-1)=b_cnt.at(n-1);
    for(int i=n-2; i>=0; i--){
        b_sum.at(i)=(ll)b_cnt.at(i) + (ll)b_sum.at(i+1);
    }
    ll ans=0;
    for(int i=0; i<n; i++){
        int check=a.at(i);
        int l=-1;
        int r=n;
        while(r>l+1){
            int mid=(l+r)/2;
            if(b.at(mid)>check) r=mid;
            else l=mid;
        }
        if(r==n) continue;
        ans += b_sum.at(r);
    }
    cout << ans << endl;
}

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

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	bool a = false;
	for (int i = 0; i <= n && !a; i++) {
		for (int j = 0; j <= m && !a; j++) {
			a = i * (m - j) + (n - i) * j == k;
		}
	}
	cout << (a ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  
  int N,M,C;
  
  scanf("%d %d %d",&N,&M,&C);
  
  int a[N][M];
  int b[M];
  int i,j;
  
  for(j= 0; j < M; j++){
    scanf("%d", &b[j]);
  }
  
  for(i = 0; i < N; i++){
    for(j = 0; j < M; j++){
      scanf("%d", &a[i][j]);
    }
  }
  
  int k[N];
  
  for(i = 0; i < N; i++){
    k[i] = 0;
  }
  
  for(i = 0; i < N; i++){
    for(j = 0; j < M; j++){
      k[i] += a[i][j]*b[j];
    }
  }
  
  int flag = 0;
  
  for(i = 0; i < N; i++){
    if(k[i] > -1*C){
      flag += 1;
    }
  }
  
  printf("%d\n",flag);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main() {
    vector<int> a(3);
    for(int i=0; i<3; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    int ans = 0;
    while(a.at(0) < a.at(2)-1){
        a.at(0) += 2;
        ans += 1;
    }
    while(a.at(1) < a.at(2)-1){
        a.at(1) += 2;
        ans += 1;
    }
    sort(a.begin(),a.end());
    if(a.at(0) == a.at(2)){
        ans += 0;
    }
    else if(a.at(0) == a.at(1)){
        ans += 1;
    }
    else{
        ans += 2;
    }
    cout << ans << endl;   
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>


#define fs first
#define sc second

using namespace std;

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


int main(){
    int n;
    vector<ll> a;
    cin >> n;
    for(int i = 0; i < n; i++){
        ll aa;
        cin >> aa;
        a.push_back(aa);
    }

    sort(a.begin(), a.end());

    auto itr1 = lower_bound(a.begin(), a.end(), (a[n-1]+2)/2);
    auto itr2 = upper_bound(a.begin(), a.end(), a[n-1]/2);

    if(itr1 == a.begin()){
        cout << a[n-1] << " " << *itr2 << endl;
    }
    else if(itr2 == a.end()-1){
        cout << a[n-1] << " " << *(itr1-1) << endl;
    }
    else{
        itr1--;
        if(a[n-1] - *itr1*2 < *itr2*2 - a[n-1]){
            cout << a[n-1] << " " << *itr1 << endl;
        }
        else{
            cout << a[n-1] << " " << *itr2 << endl;
        }
    }


    return 0;

}


Measured memory_bytes: 1908