akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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












 
int main(){
    ll a, b;
    cin >> a >> b;
    
    vector<bool> sosu(1000005, true);
    sosu[0] = false;
    for(ll i = 2; i <= 1000000; i++){
        if(!sosu[i]) continue;
        for(ll j = i * 2; j <= 1000000; j += i){
            sosu[j] = false;
        }
    }
    
    set<ll> st1, st2;
    for(ll i = 1; i <= sqrt(a); i++){
        if(a % i == 0){
            st1.insert(i);
            st1.insert(a / i);
        }
    }
    for(ll i = 1; i <= sqrt(b); i++){
        if(b % i == 0){
            st2.insert(i);
            st2.insert(b / i);
        }
    }
    
    ll ans = 0;
    set<ll> st3;
    for(auto &x : st1){
        if(x > 1000000){
            if(st2.find(x) != st2.end()){
                bool f = true;
                for(auto &xx : st3){
                    if(xx == 1) continue;
                    if(x % xx == 0){
                        f = false;
                        break;
                    }
                }
                if(f){
                    ans++;
                }
            }
        }
        else if(sosu[x] && st2.find(x) != st2.end()){
            ans++;
            st3.insert(x);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
long long int n,W,i,j,weight[1005],val[1005],mat[105][100005];
 
int main()
{
    cin>>n>>W;
    for(i=0;i<n;i++)
    {
        cin>>weight[i]>>val[i];
    }
    for(i=0;i<=W;i++)
    mat[0][i] = 0;
    for(i=0;i<=n;i++)
    mat[i][0] = 0;
 
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=W;j++)
        {
            if(weight[i-1]<=j)
            {
                mat[i][j] = max(mat[i-1][j],val[i-1]+mat[i-1][j-weight[i-1]]);
            }
            else
            {
                mat[i][j] = mat[i-1][j];
            }
        }
    }
    cout<<mat[n][W]<<endl;
}

Measured memory_bytes: 80128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	map<pair<int,int>,int> mp;
	int n,a[44]={},b[44]={},c[44]={},ma,mb;
	cin>>n>>ma>>mb;
	int ans=mod;
	FOR(i,0,n){
		cin>>a[i]>>b[i]>>c[i];
	}

	int dp[42][422][422];
	FOR(i,0,42)FOR(j,0,422)FOR(k,0,422)dp[i][j][k]=mod;
	dp[0][0][0]=0;
	FOR(ii,0,n)FOR(j,0,402)FOR(k,0,402){
		int i=ii+1;
		dp[i][j+a[ii]][k+b[ii]]=min(dp[i][j+a[ii]][k+b[ii]],dp[i-1][j][k]+c[ii]);
		dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);

	}
	FOR(coeff,1,400/ma){
		int aa=coeff*ma,bb=coeff*mb;
		if(bb>400)break;
		ans=min(ans,dp[n][aa][bb]);
	}
	if(ans==mod)cout<<-1;
	else cout<<ans;
    return 0;
}


Measured memory_bytes: 29568
#include<stdio.h>

int main(void)
{
	int A,B,C,D;
	int x,y;
	
	scanf("%d%d%d%d",&A ,&B, &C, &D);
	
	if(A<B){
		x=A;
	}	else{
		x=B;
	}
	if(C<D){
		y=C;
	}	else{
		y=D;
	}
	printf("%d",x+y);
	
	
	
	
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll d ;
    cin >> d ;
    vector<ll> c(26) ;
    REP(i,26){
        cin >> c[i] ;
    }
    vector<vector<ll>> s(d,vector<ll>(26)) ;
    REP(i,d){
        REP(j,26){
            cin >> s[i][j] ;
        }
    }
    ll ans = 0 ;
    vll las(26,0) ;
    for(ll i=0;i<d;i++){
        ll t ;
        cin >> t ;
        t-- ;
        las[t] = i+1 ;
        ans += s[i][t] ;
        REP(j,26){
            ans -= c[j]*(i+1-las[j]) ;
        }
        cout << ans <<endl;
    }


    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 3708
#include <iostream>
#include <string>

using namespace std;

const int MAXL=13;

string str;
char Num[MAXL];
int L;

bool Kill[MAXL];
int Ccnt=0;
bool Win=true;

int main(){
	ios_base::sync_with_stdio(false);
	
	cin >> str;
	L=str.length();
	for(int i=1;i<=L;++i){
		Num[i]=str[i-1];
	}
	
	if(Num[1]!='A'){
		cout << "WA" << endl;
	}
	else{
		Kill[1]=true;
		for(int i=3;i<L;++i){
			if(Num[i]=='C')	++Ccnt;
		}
		if(Ccnt==1){
			for(int i=3;i<L;++i)	if(Num[i]=='C')	Kill[i]=true;
			for(int i=1;i<=L;++i)	if((!Kill[i]) && Num[i]>='A' && Num[i]<='Z')	Win=false;
			if(Win)	cout << "AC" << endl;
			else	cout << "WA" << endl;
		}
		else	cout << "WA" << endl;
	}
	
	return 0;
}

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

using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define ld long double
 	#define lb lower_bound 
	#define ub upper_bound
	#define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
	#define mii         map<pi,int>
	#define vi vector<int> 
	#define vvi vector<vi>
	#define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
	#define all(c) (c).begin(),(c).end()
	#define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
	
	 const int N =3e5+5;
	 const int lg=20;
	
	 int mod= 1e9+7;
	 int dx[4]={0,0,+1,-1};
	 int dy[4]={+1,-1,0,0};  
	 
	 
	int po(int a, int b) {
		a %= mod;
		int res = 1;
		while (b > 0) {
			if (b & 1)
				res = (res * a) % mod;
			a =(a*a) % mod;
			b >>= 1;
		}
		 return res;	
	   }   
	   
mi mp;	   


void solve() {
	  
	  int n;
	  cin>>n;
	  vi a(n,0),b(n,0);
	  rep(i,0,n) {
		    cin>>a[i]>>b[i];
		  }
		  
		  sort(all(a));
		  sort(all(b));
		  
		  int x=0,y=0;
		  
		  if(n%2==1) {
			    x=a[n/2];
			    y=b[n/2];
			  }
		  else {
			     x=a[n/2-1]+a[n/2];
			     y=b[n/2-1]+b[n/2];
			  }	  
			  
			  cout<<y-x+1<<endl;		    
			  
		  } 
 
int32_t main() {
	cool;
	int t=1;	
	   //~ cin>>t;
	while(t--)
	   solve();		   
	   
	   return 0;	   
}


Measured memory_bytes: 6360
using System;
using System.Linq;

namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            string alpha = Console.ReadLine();
            int beta = int.Parse(Console.ReadLine());

            for (int i = 0; i < beta; i++)
            {
                string[] line = Console.ReadLine().Split();
                string a = line[0];
                int eta = int.Parse(line[1]), due = int.Parse(line[2]);
                int anotheralpha = due - eta + 1;
                string bell = alpha.Substring(0, eta);
                string all = alpha.Substring(eta + anotheralpha);

                if (a == "print")
                {
                    Console.WriteLine(alpha.Substring(eta, anotheralpha));
                }
                else if (a == "reverse")
                {
                    string tmp = string.Join("", alpha.Substring(eta, anotheralpha).Reverse());
                    alpha = alpha.Replace(alpha.Substring(eta, anotheralpha), tmp);
                }
                else
                {
                    string tmp2 = alpha.Substring(eta, anotheralpha);
                    tmp2 = tmp2.Replace(tmp2, line[3]);

                    alpha = bell + tmp2 + all;
                }

            }
        }
    }
}



Measured memory_bytes: 20352
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

t = sinput()
ans = t.replace("?", "D")
print(ans)


Measured memory_bytes: 38004
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x; cin >> x;
  if(x%11==0) cout << x/11*2 << "\n";
  else if(x%11<=6) cout << x/11*2+1 << "\n";
  else cout << x/11*2+2 << "\n";
  return 0;
}


Measured memory_bytes: 3644
from math import ceil
N,H = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]

amax = 0
for i in range(N):
    amax = max(amax,ab[i][0])

B = []
for i in range(N):
    if ab[i][1]>amax:
        B.append(ab[i][1])
B.sort(reverse=True)
ans = 0
for b in B:
    H -= b
    ans += 1
    if H <= 0:
        break

if H > 0:
    ans += ceil(H/amax)

print(ans)

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

string s;
int n;

ll f(int bit) {
    ll sum = 0;
    ll cur = 0;
    for(int i = 0; i < n; i++) {
        cur *= 10;
        cur += s[i] - '0';

        if( bit & 1 << i ) {
            sum += cur;
            cur = 0;
        }
    }
    return sum + cur;
}

int main() {
    cin >> s;
    n = s.size();

    ll sum = 0;
    for(int bit = 0; bit < (1 << n-1); bit++) {
        sum += f(bit);
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int N;
    cin>> N;
    string s;
    cin>> s;
    if(s.length() <= N){
        cout<< s;
    }else{
        cout<< s.substr(0,N);
        cout<<"...";
    }
    
    

    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  int W,H,N,x,y,a,i,leftEdge,rightEdge,lowerEdge,upperEdge;

  scanf("%d %d %d",&W,&H,&N);
  leftEdge=0;rightEdge=W;lowerEdge=0;upperEdge=H;
  for(i=0;i<N;++i){
    scanf("%d %d %d",&x,&y,&a);
    if(a==1){
      if(x>leftEdge) leftEdge=x;
    }
    else if(a==2){
      if(x<rightEdge) rightEdge=x;
    }
    else if(a==3){
      if(y>lowerEdge) lowerEdge=y;
    }
    else if(a==4){
      if(y<upperEdge) upperEdge=y;
    }
  }
  if(leftEdge<rightEdge && lowerEdge<upperEdge){
    printf("%d\n",(upperEdge-lowerEdge)*(rightEdge-leftEdge));
  }
  else printf("0\n");

  return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;

namespace AtCoderBeginnerContest175
{
	class Program
	{
		static void Main(string[] args)
		{
			var inputs = Console.ReadLine().Split().Select(x => long.Parse(x)).ToList();

			var current = inputs[0];
			var n = inputs[1];
			var d = inputs[2];

			// 0をまたぐ移動になるまでの数
			var number = Math.Abs(current) / d;
			if (number >= n)
			{
				// 0に到達しない場合
				if (current >= 0)
				{
					// 正なら単純に引く
					Console.WriteLine(current - n * d);
				}
				else
				{
					Console.WriteLine(Math.Abs(current + n * d));
				}
			}
			else
			{
				if (current >= 0)
				{
					// 0までの移動した場合の位置と残り回数を計算
					current -= number * d;
					n -= number;
					if (n % 2 == 0)
					{
						Console.WriteLine(current);
					}
					else
					{
						Console.WriteLine(Math.Abs(current - d));
					}
				}
				else
				{
					current += number * d;
					n -= number;
					if (n % 2 == 0)
					{
						Console.WriteLine(Math.Abs(current));
					}
					else
					{
						Console.WriteLine(Math.Abs(current + d));
					}
				}
			}
		}
	}
}


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

#define ll long long
#define pb push_back

vector<int>g[100003];
vector<int>v(100003);
queue<int>q;

int main()
{
    int n;
    cin>>n;
    if(n>=30)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}











Measured memory_bytes: 5956
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		switch(s) {
		case "a":
		case "e":
		case "i":
		case "u":
		case "o":
			System.out.println("vowel");
			break;
		default :
			System.out.println("consonant");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int mj[10010] = {};
PII box[505] = {};
ll dp[505][10010];
int main(void){
	int M, N;
	ll res = 0;
	cin >> M >> N;
	REP(i, 505){
		fill(dp[i], dp[i]+10010, INF_LL);
	}
	REP(i, M){
		cin >> mj[i];
	}
	sort(mj, mj+M, greater<int>());
	REP(i, N){
		int c, e;
		cin >> c >> e;
		box[i] = {c, e};
	}
	dp[0][0] = 0;
	FOR(i, 1, N+1){
		REP(j, M+1){
			dp[i][j] = min(dp[i-1][j], dp[i-1][max(0, j-box[i-1].first)]+box[i-1].second);
		}
	}
	ll sum = 0;
	REP(j, M){
		sum += mj[j];
		res = max(res, sum-dp[N][j+1]);
	}
	cout << res << endl;
}

Measured memory_bytes: 42612
def main():
    n,k = (int(x) for x in input().split())
    ans = []
    for i in range(k):
        d = int(input())
        A = [int(x) for x in input().split()]
        ans += A
    ans = set(ans)
    print(n-len(ans))

if __name__ == '__main__':
    main()

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  
  ll ans=0;
  for(ll bit=0; bit<(1<<n-1); bit++){
    ll l=0;
    rep(i,n-1){
      if(bit>>i&1){
        // cout<<s.substr(l,i+1-l)<<endl;
        ans+=stol(s.substr(l,i+1-l));
        l=i+1;
      }
    }
    // cout<<s.substr(l,n-l)<<endl;
    ans+=stol(s.substr(l,n-l));
  }
  cout<<ans<<endl;
}

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

#define rep(i,n) for(int i = 0;i < n; i++)
using namespace std;

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


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;

int a[100005];
int mon[100005];

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		mon[i] = mon[i - 1] + abs(a[i] - a[i - 1]);
	}
	for(int i = 1; i <= n; i++)
	{
		if(i == n)
			printf("%d\n", mon[n - 1] + abs(a[n - 1]));
		else
			printf("%d\n", mon[i - 1] + mon[n] - mon[i + 1] + abs(a[i + 1] - a[i - 1]) + abs(a[n]));
	}
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>

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

int main() {
    int x,y;
    scanf("%d %d",&x,&y);
    int ans = (x > y) ? gcd(x, y) : gcd(y,x);
    printf("%d\n",ans);
    return 0;
}




Measured memory_bytes: 2144
#include <stdio.h>

int main(void)
{
    int i, j, k;

    int n;
    scanf("%d", &n);

    int A[n];
    for (i=0; i<n; i++)
        scanf("%d", &A[i]);

    for (i=0; i<n; i++){
        int v;
        v = A[i];
        j = i - 1;

        while (j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;

        for (k=0; k<n-1; k++)
            printf("%d ", A[k]);
        printf("%d\n", A[n-1]);
    }
    return 0;
}



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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int a, b;
	cin >> a >> b;
	set<int> st = { 1, 2, 3 };
	st.erase(a);
	st.erase(b);
	cout << *st.begin();
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N, K;
ll ans;

int main()
{
  std::cin >> N >> K;

  N %= K;

  std::cout << std::min( N, K-N ) << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n,cnt=0;
    cin >> n;
    for(int i=1;cnt<n;i++){
        bool b=true;
        for(int j=2;j<(10*i+1);j++){
            if((10*i+1)%j==0){
                b=false;
            }
        }
        if(b){
            cout << 10*i+1 << " ";
            cnt++;
        }
    }
    cout << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
class Main {
 
  
 
  public static void main(String[] args) {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    
    int n = in.nextInt();
    int[][] can = new int[n][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        can[i][j] = in.nextInt();
      }
    }

    int INF = (int) 1e9 + 7;

    int[] dp = new int[1 << n];
    dp[0] = 1;
    for (int mask = 0; mask < (1 << n) - 1; mask++) {
      int a = countSetBit(mask); // we are going to check assign a woman to (a+1)th man
      for (int b = 0; b < n; b++) {
        if (can[a][b] == 1 && ((mask & (1<<b)) == 0)) {
          dp[mask | (1 << b)] += dp[mask];
          if (dp[mask | 1 << b] >= INF) {dp[mask | (1 << b)] -= INF;}
        }
      }
    }

    System.out.println(dp[(1<<n) - 1]);
  }

  static int countSetBit(int a) {
    String s = Integer.toBinaryString(a);
    int count = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == '1') {count++;}
    }
    return count;
  }

 
}

Measured memory_bytes: 74108
n,m = gets.split.map(&:to_i)
a = Array.new(n) { gets.split.map(&:to_i) }
b = Array.new(m) { gets.to_i }

result = 0

n.times do |i|
  m.times do |j|
    result += a[i][j] * b[j]
  end
  puts result
  result = 0
end

Measured memory_bytes: 6128
import Control.Applicative ((<$>), (<*>))
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr, foldl')
import Data.Char (isSpace)
import Data.Vector (Vector, (!))
import qualified Data.Vector as V

main :: IO ()
main = do
  solve <$> readLn <*> f <*> (B.getLine >> f) >>= print
  where f = readiv B.readInt <$> B.getLine

solve :: Int -> Vector Int -> Vector Int -> Int
solve n ss ts = V.foldl' f 0 ts
  where f ct x | bsearch (flip compare x . (ss !)) 0 n = ct + 1
               | otherwise = ct
  

bsearch :: (Int -> Ordering) -> Int -> Int -> Bool
bsearch f l r | l >= r = False
              | otherwise = case f m of
                             GT -> bsearch f l m
                             LT -> bsearch f (m+1) r
                             EQ -> True
  where
    m = (l + r) `div` 2

readiv :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> Vector a
readiv f = V.unfoldr g
  where
    g s = do
      (n, s') <- f s
      return (n, B.dropWhile isSpace s')



Measured memory_bytes: 11392
def main():
    import sys
    readline = sys.stdin.buffer.readline

    n, x, y = map(int, readline().split())

    l = [0] * (n-1)
    for i in range(1, n):
        for j in range(i+1, n+1):
            s = min(j-i, abs(x-i)+abs(j-y)+1)
            l[s-1] += 1
    for i in l:
        print(i)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9404
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;

int main()
{
	int N;
	vector<string> v;
	unordered_map<string, int> map;

	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		string s;
		cin >> s;
		++map[s];
		if (map[s] == 1)
		{
			v.push_back(s);
		}
	}

	int max_count = 0;
	vector<string> max_s;
	for (auto e : v)
	{
		if (map[e] > max_count)
		{
			max_count = map[e];
			max_s.resize(0);
		}
		
		if (map[e] == max_count)
		{
			max_s.push_back(e);
		}
	}

	sort(max_s.begin(), max_s.end());
	for (auto e : max_s)
	{
		cout << e << endl;
	}
	
	return 0;
}

Measured memory_bytes: 27320
s = list(input())
sa = list(reversed(s))
a = s[0:(len(s)-1)//2]
b = s[(len(s)+3)//2-1:len(s)]
c = list(reversed(a))
d = list(reversed(b))
if s == sa and a==c and b == d:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx = INT_MAX;
ll mn = INT_MIN;
ll INF = 1e18+10;
ll MOD = 1e9+7;
const ll maxs = 3e5+5;
const ll lg = 22; 
ll fast(ll base , ll expo){ ll res = 1; while(expo>=1){ if(expo%2) res *= base; base *= base; expo /= 2; } return res; }

void code_idhr_h(){
    ll L,R,d; cin>>L>>R>>d;
    cout<<R/d - (L-1)/d;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>

using namespace std;

int main() {
  int h = 0, w = 0;
  cin >> h >> w;
  string sharp = "";
  for (int i=0; i<w+2; i++) sharp.push_back('#');
  cout << sharp << endl;
  string buf = "";
  for (int i=0; i<h; i++) {
    cout << "#";
    cin >> buf;
    cout << buf;
    cout << "#" << endl;
  }
  cout << sharp << endl;
  return 0;
}


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

long n, m, a[100010], s[100010];

bool C(long x) {
	long cnt = 0;
	for (int i = 0; i < n; ++i) {
		cnt += a + n - lower_bound(a, a + n, x - a[i]);
	}
	return cnt >= m;
}


int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; ++i) s[i + 1] = s[i] + a[i];

	long l = 0, r = 10000000010;
	while (r - l > 1) {
		long mid = (l + r) >> 1;
		if (C(mid)) l = mid;
		else r = mid;
	}

	long ans = 0;
	for (int i = 0; i < n; ++i) {
		long idx = upper_bound(a, a + n, l - a[i]) - a;
		ans += s[n] - s[idx] + (n - idx) * a[i];
		m -= n - idx;
	}
	ans += l * m;
	cout << ans << endl;
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string s; cin>>s;
  ll mo=0;
  rep(i,s.size()){
    mo=(mo+(s[i]-'0'))%9;
  }
  if(mo==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

char s[100005];
int n;
int ans = 1;
int cnt[26];
const int MOD = int(1e9) + 7;

int main() {
    scanf("%d%s", &n, s);
    forn(i, n) {
        cnt[s[i] - 'a']++;
    }
    forn(i, 26) {
        ans = (LL)ans * (cnt[i] + 1) % MOD;
    }
    ans -= 1;
    if (ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef vector <ll> vr;
typedef pair <ll, ll> pr;
typedef vector <ll> :: iterator ir;

#define pub push_back
#define pob pop_back
#define mp make_pair
#define pc __builtin_popcount
#define lb lower_bound

ll dig(ll n) {
	string s = to_string(n);
	return s.size();
}

ll totSum(ll arr[], ll n) {
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		sum += arr[i];
	}
	return sum;
}


int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);







// write your code here

	string s, t;
	cin >> s >> t;
	ll ans = INT_MAX;
	for (ll i = 0; i < s.length() - t.length() + 1 ; i++) {
		ll tmp = i;
		ll count = 0;
		for (ll j = 0; j < t.length(); j++) {
			if (s[tmp] != t[j])count++;
			tmp++;
		}
		ans = min(count, ans);
	}
	cout << ans;

// this is the end of your code

}


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

char a[53][53], b[53][53];

int main(){

        int n, m;
        scanf("%d%d", &n, &m);
        for(int i=0; i<n; ++i){
            scanf("%s", a[i]);
        }

        for(int i=0; i<m; ++i){
            scanf("%s", b[i]);
        }

        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                bool found=true;
                for(int k=i, k2=0; k<m+i; ++k, ++k2){
                    for(int l=j, l2=0; l<m+j; ++l, ++l2){
                        if(a[k][l]!=b[k2][l2])
                            found=false;
                    }
                }
                if(found==true){
                    puts("Yes");
                    return 0;
                }
            }
        }

        puts("No");



    return 0;
}


Measured memory_bytes: 256
// ABC128-C
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

vector<int> setu(11);
vector<vector<int>> denkyu(11);
vector<int> zan(11);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n,m; //n個のスイッチ,m個の電球,m個の電球全てが付くスイッチの付け方
    cin>>n>>m;
    rep(i,m){
        int k;
        cin>>k;
        setu[i]=k;
        rep(j,k){
            int s;
            cin>>s;
            denkyu[i].push_back(s-1);
        }
    }
    rep(i,m) cin>>zan[i];
    int ans=0;
    int l=pow(2,n);
    rep(i,l){
        vector<bool> on(n,false);
        int on_l=0;
        rep(j,n){
            if((i>>j)&1) on[j]=true;
        }
        //cout<<on<<endl;
        rep(j,m){
            int cur=0; //j番目の電球に接続してるスイッチでonの数
            rep(k,setu[j]){
                if(on[denkyu[j][k]]) cur+=1;
            }
            if(cur%2==zan[j]) on_l+=1;
        }
        if(on_l==m) ans+=1;
    }
    //cout<<denkyu<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
    long long int n,m,l,a[105][105],b[105][105],c[105][105]={0};
    int i,j,k;
    scanf("%lld %lld %lld",&n,&m,&l);
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            scanf("%lld",&a[i][j]);
        }
    }
    for(i=1;i<=m;i++){
        for(j=1;j<=l;j++){
            scanf("%lld",&b[i][j]);
        }
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=l;j++){
            for(k=1;k<=m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            printf("%lld",c[i][j]);
            if(j<l)printf(" ");
        }
        printf("\n");
    }
  
  
  
    return 0;
}


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

int main() {
    int n;
    while(cin >> n, n) {

    vector <pair <int, int>> pos(n);
    map <pair <int, int>, bool> posToExist;
    rep (i, n) cin >> pos[i].first >> pos[i].second, posToExist[pos[i]] = true;

    double ans = 0;
    for (auto & L : pos) for (auto & R : pos) {
        if (L == R) continue;
        if (L.first >= R.first) continue;
        int A = R.first - L.first, B = R.second - L.second;
        if (posToExist.count(make_pair(L.first + B, L.second - A))
            && posToExist.count(make_pair(R.first + B, R.second - A))) {
            ans = max(ans, pow(R.first - L.first, 2) + pow(abs(R.second - L.second), 2));
        }

    }
    cout << (int)ans << endl;

    }
    return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int y,m,d;
  while(cin>>y>>m>>d){
    if(y<1868||(y==1868&&m<9)||(y==1868&&m==9&&d<8)){
      cout<<"pre-meiji"<<endl;
    }else if(y<1912||(y==1912&&m<7)||(y==1912&&m==7&&d<30)){
      cout<<"meiji "<<y-1868+1<<" "<<m<<" "<<d<<endl;
    }else if(y<1926||(y==1926&&m<12)||(y==1926&&m==12&&d<25)){
      cout<<"taisho "<<y-1912+1<<" "<<m<<" "<<d<<endl;
    }else if(y<1989||(y==1989&&m<1)||(y==1989&&m==1&&d<8)){
      cout<<"showa "<<y-1926+1<<" "<<m<<" "<<d<<endl;
    }else{
      cout<<"heisei "<<y-1989+1<<" "<<m<<" "<<d<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3088
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int a,b;

  scanf("%d%d",&a,&b);

  if(a <= 0 && 0 <= b){
    puts("Zero");
    return 0;
  }

  if(0 < a || (min(0,b+1)-a)%2 == 0){
    puts("Positive");
    return 0;
  }else{
    puts("Negative");
    return 0;
  }
  
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll N, M;
vvll Graph;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(N,M);
  Graph.resize(N);
  REP(i,M){
    ll A, B;
    IN(A,B);
    A--; B--;
    Graph[A].pb(B);
    Graph[B].pb(A);
  }

  vll ans(N, -1);
  queue<ll> que;
  que.push(0);
  ans[0] = 0;

  while(que.size()){
    ll pos = que.front(); que.pop();
    REP(i,Graph[pos].size()){
      ll next = Graph[pos][i];
      if(ans[next]>=0) continue;
      ans[next] = pos;
      que.push(next);
    }
  }

  REP(i,N){
    if(ans[i]<0){
      OUT("No");
      return 0;
    }
  }

  printf("Yes\n");
  REP(i,N-1){
    printf("%lld\n", ans[i+1]+1);
  }

  return 0;
}


Measured memory_bytes: 12932
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int t0=0;
    int x0=0;
    int y0=0;
    for(int i=0;i<n;i++){
      int t=sc.nextInt();
      int x=sc.nextInt();
      int y=sc.nextInt();
//      System.out.println(t+"-"+t0+" "+x+"-"+x0+" "+y+"-"+y0);
      if(t-t0<mh(x0,y0,x,y)||(mh(x0,y0,x,y)+t-t0)%2==1){
        System.out.println("No");
        return;
      }
      t0=t;
      x0=x;
      y0=y;
    }
    System.out.println("Yes");
  }
  static int mh(int x1,int y1,int x2,int y2){
    return Math.abs(x1-x2)+Math.abs(y1-y2);
  }
}

Measured memory_bytes: 84828
// AOJ 1093: KND Runs for Sweets
// 2017.11.16 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define KAI 50
int x[101], y[101], v[101]; int n;
int max;

double fx(double a, double b)
{
	int i;
	double d, max;
	
	max = 0;
	for (i = 0; i < n; i++) {
		d = hypot(a-x[i], b-y[i]) / v[i];
		if (d > max) max = d;
	}
	return max;
}

double srchy(double x)
{
	int i;
	double l, r, a, b;

	l = 0, r = max;
	i = KAI; while (i--) {
		a = (2*l + r) / 3;
		b = (l + 2*r) / 3;
		if (fx(x, a) < fx(x, b) ) r = b;
		else                      l = a;
	}
	return fx(x, (l+r)/2);
}

double srch3()
{
	int i;
	double l, r, a, b;
	
	l = 0, r = max;
	i = KAI; while (i--) {
		a = (2*l + r) / 3;
		b = (l + 2*r) / 3;
		if (srchy(a) < srchy(b)) r = b;
		else                     l = a;
	}
	return srchy((l+r) / 2) ;
}

int main()
{
	int i;

	while (scanf("%d", &n) && n > 0) {
		max = 0;
		for (i = 0; i < n; i++)	{
			scanf("%d%d%d", x+i, y+i, v+i);
			if (x[i] > max) max = x[i];
			if (y[i] > max) max = y[i];
		}
		printf("%.8f\n", srch3());
	}
	return 0;
}

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

int main(){
  int N, M, a, b, S = 0;
  cin >> N >> M;
  vector<int> C(N);
  
  for (int i = 0; i < M; i++){
    cin >> a >> b;
    if (a == 1){
      C.at(b-1) += 1;
    }
    else if (b == N){
      C.at(a-1) += 1;
    }
  }
  
  for (int i = 0; i < N; i++){
    S = max(S, C.at(i));
  }
  
  if (S == 2){
    cout << "POSSIBLE" << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
X = int(input())
E = []
C = {}
for i in range(M):
    u, v, w = map(int, input().split())
    E.append((w, u-1, v-1))
    C[w] = C.get(w, 0) + 1
E.sort()

*p, = range(N)
def root(x):
    if x == p[x]:
        return x
    y = p[x] = root(p[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px == py:
        return 0
    if px < py:
        p[py] = px
    else:
        p[px] = py
    return 1

MOD = 10**9 + 7

G0 = [[] for i in range(N)]
K = 0
last = None
U = [0]*M
cost = 0
for i in range(M):
    w, u, v = E[i]
    if unite(u, v):
        cost += w
        U[i] = 1
        if last != w:
            K += C[w]
        G0[u].append((v, w))
        G0[v].append((u, w))
        last = w
def dfs0(u, p, t, cost):
    if u == t:
        return 0
    for v, w in G0[u]:
        if v == p:
            continue
        r = dfs0(v, u, t, cost)
        if r is not None:
            return r | (w == cost)
    return None
def dfs1(u, p, t):
    if u == t:
        return 0
    for v, w in G0[u]:
        if v == p:
            continue
        r = dfs1(v, u, t)
        if r is not None:
            return max(r, w)
    return None

if X - cost < 0:
    print(0)
    exit(0)

K = 0
for i in range(M):
    if U[i]:
        K += 1
        continue
    w, u, v = E[i]
    if dfs0(u, -1, v, w):
        K += 1
        U[i] = 1
if cost == X:
    ans = ((pow(2, K, MOD) - 2)*pow(2, M-K, MOD)) % MOD
    print(ans)
    exit(0)

L = 0
G = 0
for i in range(M):
    w, u, v = E[i]
    if last + (X - cost) < w:
        break
    G += 1
    if U[i]:
        continue
    r = dfs1(u, -1, v) + (X - cost)
    if r == w:
        L += 1
    elif r < w:
        G -= 1

#print(K, L, M, M-K-L, G)
ans = (2*(pow(2, L, MOD)-1)*pow(2, M-G, MOD)) % MOD
print(ans)

Measured memory_bytes: 127448
use std::cmp::min;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, a, b) = scan!(i32, i32, i32);
    println!("{}", min(b, a * n));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int long long
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
    int n;
    string x;
    cin >> n >> x;
    int cnt = 0;
    rep (i, 0, n) if (x[i] == '1') cnt++;
    int px = 0, mx = 0; // cnt+1,cnt-1のときのx(mod(cnt))
    int psum[n + 1], msum[n + 1];
    psum[n] = 1, msum[n] = 1;
    per (i, 0, n) {
        psum[i] = psum[i + 1] * 2 % (cnt + 1);
        if (cnt != 1) msum[i] = msum[i + 1] * 2 % (cnt - 1);
        if (x[i] == '0') {
            continue;
        } else {
            px = (px + psum[i + 1]) % (cnt + 1);
            if (cnt != 1) mx = (mx + msum[i + 1]) % (cnt - 1);
        }
    }
    int ans[n];
    per (i, 0, n) {
        int nx;
        int sum = 1;
        if (x[i] == '0') {
            nx = (px + psum[i + 1]) % (cnt + 1);
            if (nx < 0) nx += (cnt + 1);
        } else {
            if (cnt != 1) {
                nx = (mx - msum[i + 1]) % (cnt - 1);
                if (nx < 0) nx += (cnt - 1);
            } else {
                nx = 0;
                sum = 0;
            }
        }
        // cout << i << " " << nx << "\n";
        while (nx != 0) {
            nx = nx % __builtin_popcount (nx);
            sum++;
        }
        ans[i] = sum;
    }
    rep (i, 0, n) cout << ans[i] << "\n";
}


Measured memory_bytes: 8420