akhauriyash/Code-Regression huggingface dataset:
import * as fs from 'fs';

namespace AtCoder.abc163 {

    export class Program {

        constructor(private readonly args: string[]) {
        }

        /**
         * in
         *
         * out
         *
         */
        main(this: Program): void {
            const r :number = parseInt(this.args[0],10);
            console.log((r*2)*Math.PI);
        }
    }
}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg: AtCoder.abc163.Program = new AtCoder.abc163.Program(args);
prg.main();


Measured memory_bytes: 29632
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#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);
 
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 vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n,k;cin>>n>>k;
  int ans=1;
  rep(i,n){
    if(ans<k)ans*=2;
    else ans+=k;
  }
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF = 10**20
def main():
    S=list(input())
    N=len(S)

    A,B=[],[]
    pre = "0"
    for i in range(N):
        if pre == "0":
            new = "1"
        else:
            new = "0"
        A.append(new)
        pre = new
        
    pre = "1"
    for i in range(N):
        if pre == "0":
            new = "1"
        else:
            new = "0"
        B.append(new)
        pre = new

    ans = INF
    for X in [A,B]:
        count = 0
        for i in range(N):
            if S[i] != X[i]:
                count += 1

        ans = min(ans,count)

    print(ans)





if __name__ == "__main__":
    main()

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

int main(){
	ll N;cin >> N;
	ll i=100;
	double rate =0.01;
	for(int j=0;;j++){
		if(i>=N){
			cout << j << endl;
			return 0;
		}
		i = i+(double)i*rate;
	}
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    int H, W;
    cin >> H >> W;
    VS s(H);
    REP(i, H) cin >> s[i];

    int white_cnt = 0;
    REP(i, H) REP(j, W) white_cnt += s[i][j] == '.';
    white_cnt -= 1;

    vector<PII> now;
    now.PB(MP(0, 0));

    int count = 0;
    while(!now.empty()) {
        vector<PII> next;
        REP(i, now.size()){
            int nx = now[i].second;
            int ny = now[i].first;
            if(nx == W-1 && ny == H-1) {
                cout << white_cnt - count << endl;
                return 0;
            }

            if(s[ny][nx] == '#') continue;
            s[ny][nx] = '#';

            REP(i, 4) {
                int mx = nx + DX[i];
                int my = ny + DY[i];

                if(RANGE(mx, my, W, H)) next.PB(MP(my, mx));
            }
        }
        count++;
        now = next;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int count = 0;
    int a,b;
    scanf("%d %d",&a,&b);
    for(int i = 1; i <= a; i++){
        if(i != a){
            for(int j = 1; j <= 31; j++){
                if(i == j){
                    count++;
                }
            }
        }else{
            for(int j = 1; j <= b; j++){
                if(i == j){
                    count++;
                }
            }
        }
    }
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
const int MOD = 1e9 + 7;

int n, k, arr[MAXN];
int bui[MAXN], revb[MAXN], rev[MAXN];
int ans;

bool cmp1(const int &x, const int &y){return x < y;}
bool cmp2(const int &x, const int &y){return x > y;}
int C(int i, int j){
	if(j > i) return 0;
	if(i == j || j == 0) return 1;
	return (1ll * bui[i] * revb[j] % MOD) * revb[i - j] % MOD;
}

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++) scanf("%d", &arr[i]);
	
	bui[0] = 1;
	for(int i = 1; i <= n; i++) bui[i] = 1ll * bui[i - 1] * i % MOD;
	rev[1] = revb[1] = 1;
	for(int i = 2; i <= n; i++) rev[i] = 1ll * (MOD - MOD / i) * rev[MOD % i] % MOD;
	for(int i = 2; i <= n; i++) revb[i] = 1ll * revb[i - 1] * rev[i] % MOD;
	sort(arr + 1, arr + n + 1, cmp1);
	int ans1 = 0, ans2 = 0;
	for(int i = 1; i <= n; i++) ans1 = (ans1 + 1ll * arr[i] * C(i - 1, k - 1) % MOD) % MOD;
	sort(arr + 1, arr + n + 1, cmp2);
	for(int i = 1; i <= n; i++) ans2 = (ans2 + 1ll * arr[i] * C(i - 1, k - 1) % MOD) % MOD;
	printf("%lld\n", (1ll * ans1 - 1ll * ans2 + MOD) % MOD);
	return 0;
}

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

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

const int MAX = 1e3 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N, A[MAX];

int main(){
    cin >> N;
    rep(i, N) cin >> A[i];

    double ans = 0;
    rep(i, N){
        ans += (double) 1.0 / A[i];
    }

    printf("%.15f\n", (double) 1.0 / ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip> 
#include<sstream>
#include <map>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    long long h;
    while (cin >> h)
    {
        long long ans = 0;
        while (h>1)
        {
          ans++;
          if (h / 2 > 1)
              ans = ans * 2;
            h = h / 2;
        }
        ans = ans * 2 + 1;


            cout << ans << '\n';
    }
}


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

int main(){
    int H, W;
    cin >> H >> W;
    map<int, int64_t> mp;
    multiset<int64_t> values;

    auto add = [&](int i, int64_t v){
        if(mp.count(i)) values.erase(values.find(mp[i]));
        mp[i] = v;
        values.insert(v);
    };
    auto del = [&](int i){
        values.erase(values.find(mp[i]));
        return mp.erase(mp.find(i));
    };

    auto solve = [&](int l, int r)->void{
        if(r != W){
            auto it = mp.upper_bound(r+1);
            if(it != mp.begin()){
                it--;
                add(r+1, it->second + (r+1-it->first));
            }
        }

        auto it1 = mp.lower_bound(l);
        while(it1 != mp.end() && it1->first <= r){
            it1 = del(it1->first);
        }
        if(it1 == mp.begin()) return;
        auto it2 = it1;
        it1--;
        while(it2 != mp.end()){
            int d = it2->first - it1->first;
            if(it1->second + d <= it2->second){
                it2 = del(it2->first);
            }else{
                break;
            }
        }
    };

    for(int i=1; i<=W; i++) add(i, 0);
    int64_t fix = 0;
    while(H--){
        int a, b;
        cin >> a >> b;
        solve(a, b);
        fix++;
        if(values.size()){
            cout << fix + *values.begin() << endl;
        }else{
            cout << -1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 25464
import java.util.*;

public class Main {
	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] order = new int[5];
		order[0] = sc.nextInt();
		order[1] = sc.nextInt();
		order[2] = sc.nextInt();
		order[3] = sc.nextInt();
		order[4] = sc.nextInt();
		sc.close();
		int[] time = new int[5];
		for(int i = 0; i < 5; i++) {
			time[i] = (order[i] / 10) * 10 + (order[i] % 10 != 0 ? 10 : 0);
		}
		int max = 0;
		int ans = 0;
		for(int i = 0; i < 5; i++) {
			max = Math.abs(time[i] - order[i]) > max ? Math.abs(time[i] - order[i]) : max;
			ans += time[i];
		}
		System.out.println(ans - max);
	}
}


Measured memory_bytes: 35476
#include <iostream>
#include <map>
#include <algorithm>
#include <cstring>
using namespace std;

int h, w;
char t[50][50];
bool used[50][50];
map<string,int> cnt;

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

void solve(int sx, int sy){
  for(int i = 0; i < 8; i++){
    int x = sx;
    int y = sy;
    string s = "";

    memset(used, 0, sizeof(used));

    while(!used[y][x]){
      used[y][x] = true;
      s += t[y][x];
      x = (x + dx[i] + w) % w;
      y = (y + dy[i] + h) % h;

      cnt[s]++;
      //string ts = s;
      //reverse(ts.begin(), ts.end());
      //cnt[ts]++;
    };
  }
}

int main(){
  while(cin >> h >> w, h || w){
    cnt.clear();

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

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        solve(j, i);
      }
    }

    string ans = "";

    for(map<string,int>::iterator iter = cnt.begin(); iter != cnt.end(); iter++){
      string s = iter->first;
      int c = iter->second;

      if(2 <= c && 2 <= s.length() && ans.length() < s.length()){
        ans = s;
      }
    }

    if(ans == ""){
      cout << 0 << endl;
    }
    else{
      cout << ans << endl;
    }
  }
}

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

int sid = 1;
struct segtree {
  int l, r, sl, sr, v;
} s[1000005];

int build(int l, int r) {
  int u = sid++;
  int m = l + r >> 1;

  s[u].l = l;
  s[u].r = r;
  s[u].v = 0x7fffffff; // from problem statement

  if (l != r) {
    s[u].sl = build(l, m);
    s[u].sr = build(m + 1, r);
  }
  
  return u;
}

void update(int u, int l, int r, int v) {
  if (l == s[u].l && r == s[u].r) {
    s[u].v = v;
    return;
  }

  if (s[u].v != -1) {
    s[s[u].sl].v = s[u].v;
    s[s[u].sr].v = s[u].v;
    s[u].v = -1;
  }
  
  int m = s[u].l + s[u].r >> 1;
  if (r <= m) {
    update(s[u].sl, l, r, v);
  } else if (l > m) {
    update(s[u].sr, l, r, v);
  } else {
    update(s[u].sl, l, m, v);
    update(s[u].sr, m + 1, r, v);
  }
}

int query(int u, int k) {
  if (s[u].v != -1)
    return s[u].v;

  int m = s[u].l + s[u].r >> 1;
  if (k <= m)
    return query(s[u].sl, k);
  else
    return query(s[u].sr, k);
}

int main() {
  int n, q; cin >> n >> q;
  int T = build(0, n - 1);

  for (int i = 0; i < q; i++) {
    int t; cin >> t;
    if (t == 0) {
      int a, b, c; cin >> a >> b >> c;
      update(T, a, b, c);
    } else {
      int k; cin >> k;
      cout << query(T, k) << endl;
    }
  }
}



Measured memory_bytes: 6988
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    int N;
    map<string, int> vote;
    cin >> N;
    REP(i, N){
        string S;
        cin >> S;
        vote[S]++;
    }
    int mx = 0;
    EACH(i, vote){
        chmax(mx, i.se);
    }
    EACH(i, vote){
        if(i.se == mx){
            cout << i.fi << el;
        }
    }
}



Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 3005;

char s[maxn], t[maxn];

int dp[maxn][maxn];

int go[maxn][maxn];

int n, m;

int solve(int a, int b)
{
	if(a == n || b == m) return 0;
	if(dp[a][b] != -1) return dp[a][b];
	int x = solve(a+1, b);
	int y = solve(a, b+1);
	int z = s[a] == t[b]?1+solve(a+1, b+1):-1e9;
	int best = max(max(x, y), z);
	if(best == x) go[a][b] = 1;
	else if(best == y) go[a][b] = 2;
	else go[a][b] = 3;
	return dp[a][b] = best;
}

int main()
{
	memset(dp, -1, sizeof dp);
	scanf("%s", s); scanf("%s", t);
	n = strlen(s), m = strlen(t);
	solve(0, 0);
	int a = 0, b = 0;
	while(a< n && b< m)
	{
		int x = go[a][b];
		if(x == 1) a++;
		else if(x == 2) b++;
		else
		{
			printf("%c", s[a]);
			a++; b++;
		}
	}
	printf("\n"); return 0;
}

Measured memory_bytes: 71168
#include <stdio.h>
#define MAX 50

int main(void)
{
  int n, r, p, c;
  int i, j, k, l, m, temp;
  int card[MAX];
  int blue[MAX];
  int yellow[MAX];
  int firstcard;

  while(1)
    {
      scanf("%d %d",&n,&r);
      if(n==0)
	break;

      j = n;
      for(i=0;i<=n-1;i++)
	{
	  card[i] = j - i;
	}

      /*CHECK BEGIN!!!
      for(i=0;i<=n-1;i++)
	{
	  printf("card[%d] %d\n",i,card[i]);
	}
      CECHK END!!!*/
      
      for(l=0;l<r;l++)
	{
	  scanf("%d %d",&p,&c);

	  if(p!=1)
	    {
	      for(j=0;j<p-1;j++)
		{
		  blue[j] = card[j];
		}
	    }
	  if(c==1)
	    {
	      yellow[0] = card[p-1];
	    }
	  else
	    {
	      for(k=0;k<c;k++)
		{
		  yellow[k] = card[p+k-1];
		}
	    }
	  /*CHECK BEGIN!!
	  if(p!=1)
	    {
	      for(j=0;j<p-1;j++)
		{
		  printf("blue[%d] = %d\n",j,blue[j]);
		}
	    }
	  if(c==1)
	    {
	      printf("yellow[%d] = %d\n",0,yellow[0]);
	    }
	  else
	    {
	      for(k=0;k<c;k++)
		{
		  printf("yellow[%d] = %d\n",k,yellow[k]);
		}
	    }
	  CHECK END!!*/

	  /*????????¨????????\*/
	  if(c==1)
	    {
	      card[0] = yellow[0];
	    }
	  else
	    {
	      for(i=0;i<c;i++)
		{
		  card[i] = yellow[i];
		}
	    }
	  /*????????¨????????\*/
	  if(p==1)
	    {
	    }
	  else
	    {
	      for(j=0;j<p-1;j++)
		{
		  card[c+j] = blue[j];
		}
	    }

	  /*CHECK BEGIN!!!
	  for(i=0;i<=n-1;i++)
	    {
	      printf("card[%d] %d\n",i,card[i]);
	    }
	  CECHK END!!!*/
	}
      printf("%d\n",card[0]);
    }
  return 0;
}

Measured memory_bytes: 600
# edges[src][dst] = cost
def warshall(n, edges)
    dist = Array.new(n+1){Array.new(n+1, Float::INFINITY)}
    edges.length.times do |src|
        edges[src].each do |dst, cost|
            dist[src][dst] = cost
        end
    end
    (n+1).times do |i|
        dist[i][i] = 0
    end

    (n+1).times do |i|
        (n+1).times do |j|
            (n+1).times do |k|
                d2 = dist[i][k] + dist[k][j]
                dist[i][j] = d2 if dist[i][j] > d2
            end
        end
    end
    return dist
end



N = gets.to_i
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

def check(as, bs, set)
    n = as.max
    edges = Array.new(n + 1){Hash.new}
    (0..n).each do |src|
        set.each do |div|
            next if src < div
            edges[src][src % div] = 1
        end
    end
    result = warshall(n, edges)
    return as.length.times.all?{|i| result[as[i]][bs[i]] != Float::INFINITY}
end

use = []

as.max.downto(1) do |i|
    set = (1...i).to_a + use
    unless check(as, bs, set)
        use.push(i)
    end
end

if check(as, bs, use)
    puts use.map{|i| 2**i}.inject(0, :+)
else
    puts -1
end

Measured memory_bytes: 4220
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

getInt = readInt <$> BS.getLine

main = do
  n <- getInt
  let n' = n `mod` 1000
  if n' == 0 then print 0 else print $ 1000 - n'


Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<cstring>

using namespace std;

#ifdef LDEBUG
#define debug(x) cout << #x << ":" << x << endl
#else
#define debug(...)
#endif

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

typedef unsigned long long u64;
typedef long long i64;

string s;

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

        cin >> s;

        int p = 0;
        int q = 0;
        REP(i,s.size()) {
                char k = (i%2 ==0) ? '1' : '0';
                char j = (i%2 ==0) ? '0' : '1';
                if (s[i] != k) {
                        p++;
                }
                if (s[i] != j) {
                        q++;
                }
        }

        cout << min(p,q) << endl;



        return 0;
}


Measured memory_bytes: 512
# すぬけ君は、AtCoder s Contest という名前のコンテストを開こうとしています。 
# ここで、s は長さ 1 以上の文字列であり、1 文字目は英大文字、2 文字目以降は英小文字です。
# すぬけ君は、このコンテストの略称を AxC に決めました。 ここで、x は s の先頭の英大文字です。
# コンテストの名前が与えられるので、コンテストの略称を出力してください。

input = gets.chomp.split
puts "A#{input[1][0].upcase}C"

Measured memory_bytes: 1788
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int a, b;
    cin >> a >> b;

    cout << (ll)lcm((ll)a, (ll)b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

bool evaluate(int64_t x, int64_t b)
{
	int64_t v = x + b * b * b * b * b;
	int64_t a = 0;
	while (true) {
		int64_t w = a * a * a * a * a;
		if (v == w) {
			cout << a << " " << b << endl;
			return true;
		}
		if (v == -w) {
			cout << -a << " " << b << endl;
			return true;
		}
		if (abs(v) < abs(w)) {
			break;
		}
		a++;
	}
	return false;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t x = 0; cin >> x;

	int64_t b = 0;
	while (true) {
		bool end = evaluate(x, b);
		if (end) break;
		end = evaluate(x, -b);
		if (end) break;
		b++;
	}

	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(){
	char str[15];
	int min = 754, no, p = 0, f = 0;
	scanf("%s", str);
	while(1){
		no = 0;
		for(int i = 0; i < 3; i++){
			if(str[p + i] == '\0'){
				f = 1;
				break;
			}
			no = no * 10 + str[p + i] - '0';
		}
		if(f)break;
		if(no < 753)
			if(753 - no < min)min = 753 - no;
		if(753 <= no)
			if(no - 753 < min)min = no - 753;
		p++;
	}
	printf("%d\n", min);
	return 0;
}


Measured memory_bytes: 128
R,G,B,N=map(int,input().split())
count=0
wa=0
for i in range(int(N/R)+1):
    for j in range(int((N-i*R)/G)+1):
        b=(N-i*R-j*G)/B
        if b>=0 and float.is_integer(b)==True:
            count=count+1
     
print(count)

Measured memory_bytes: 40556
//#define _GLIBCXX_DEBUG

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

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  vector<int>ans(n,0);
  vector<int>vec;
  int sum;
  for(int i=n-1;i>=0;i--){
    sum=0;
    for(int j=2;(i+1)*j<=n;j++){
      sum+=ans[(i+1)*j-1];
    }
    sum+=a[i];
    ans[i]=sum%2;
    //cout<<ans[i]<<endl;
  }
  
  int count=0;
  vector<int>b;
  for(int i=0;i<n;i++){
    if(ans[i]==1){
      b.push_back(i+1);
      count++;
    }
  }
  if(count==0){
    cout<<0<<endl;
    return 0;
  }
  cout<<count<<endl;
  int k=b.size();
  if(k==1){
    cout<<b[0]<<endl;
    return 0;
  }
  for(int i=0;i<k-1;i++){
    cout<<b[i]<<" ";
  }
  cout<<b[k-1]<<endl;
}
    
      

Measured memory_bytes: 3064
def call(n):
	i = 1
	while True:
		through_flag = False
		x = i
		if x % 3 == 0:
			print(" {}".format(i), end="")
			through_flag = True
		if not through_flag:
			while True:
				if x % 10 == 3:
					print(" {}".format(i), end="")
					through_flag = True
				if not through_flag:
					x //= 10
					if x == 0: break
				if through_flag: break
		i += 1
		if i > n: break
	print("")



call(int(input()))

Measured memory_bytes: 7904
def main():
    a, b, c, d, e, f = map(int, input().split())
    x, y = set(), set()
    for i in range(f // (100 * a) + 1):
        for j in range((f - 100 * a * i) // (100 * b) + 1):
            x.add(100 * a * i + 100 * b * j)
    for i in range(f // c + 1):
        for j in range((f - c * i) // d + 1):
            y.add(c * i + d * j)
    m = (-1, -1, -1)
    for xi in x:
        for yi in y:
            if xi == 0:
                continue
            if xi + yi > f:
                continue
            if 100 * yi > xi * e:
                continue
            s = yi / (xi + yi)
            if s > m[0]:
                m = (s, xi + yi, yi)
    print(m[1], m[2])


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int i=1;
		while(true){
        	String x=br.readLine();
        	if(x.equals("0")) break;
        	sb.append("Case "+i+": "+x+"\n");
        	if(i%200==0){
        		System.out.print(sb.toString());
        		sb.setLength(0);
        	}
    		i++;
        }
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 25100
def create_fact_mod(num_max, mod)
    $fmod = Array.new(num_max + 1)
    $fmod[0] = 1
    $fmod[1] = 1
    (2..num_max).each do |i|
        $fmod[i] = ($fmod[i - 1] * i) % mod
    end
end

def create_seq_inv_mod(num_max, mod)
    $simod = Array.new(num_max + 1)
    $simod[0] = 1
    $simod[1] = 1
    (2..num_max).each do |i|
        $simod[i] = (mod - mod / i) * $simod[mod % i] % mod
    end
end

def create_fact_inv_mod(num_max, mod)
    $fimod = Array.new(num_max + 1)
    $fimod[0] = 1
    $fimod[1] = 1
    (2..num_max).each do |i|
        $fimod[i] = ($fimod[i - 1] * $simod[i]) % mod
    end
end

def create_mod_tables(n, mod)
    create_fact_mod(n, mod)
    create_seq_inv_mod(n, mod)
    create_fact_inv_mod(n, mod)
end

def comb_mod(n, k, mod)
    return $fmod[n] * $fimod[n - k] * $fimod[k] % mod
end


N = gets.to_i
#N = 10**6
MOD = 10**9 + 7

create_mod_tables(N, MOD)

sum = 0
now = 0
prev = 0

((N+1)/2...N).each do |i|
    now = $fmod[i - 1] * $fmod[i] * $fimod[2 * i - N] % MOD
    sum += (now - prev) * i
    sum %= MOD
    prev = now
end
p sum

Measured memory_bytes: 25212
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
	getline(cin,a);
	//getchar();
	getline(cin,b);
	for(int i=0;i<min(a.size(),b.size());i++)
	cout<<a[i]<<b[i];
	if(a.size()>b.size())
	{
		for(int i=b.size();i<a.size();i++)
		cout<<a[i];
	}
	else if(b.size()>a.size())
	{
		for(int i=a.size();i<b.size();i++)
		cout<<b[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int N;
    scanf("%d",&N);
    int a[N], b[N], c[N];
    for(int i=0;i<N;i++){
        scanf("%d", &a[i]);
    }
    for(int i=0;i<N;i++){
        scanf("%d", &b[i]);
    }
    for(int i=0;i<N-1;i++){
        scanf("%d", &c[i]);
    }
    int bf = -2;
    int sc = 0;
    for(int i=0;i<N;i++){
        int now = a[i]-1;
        if(now == bf+1){
            sc += c[bf];
        }
        sc += b[now];
        bf = now;
    }
    printf("%d\n", sc);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int w[] = new int[n];
    int ans = 10000;
    int t = 0;
    for (int i=0; i<n; i++){
      w[i] = Integer.parseInt(sc.next());
      t += w[i];
    }
    
    int w1 = 0;
    int w2;
    int ab = 0;
    
    for(int i=0; i<n; i++){
      w1 += w[i];
      w2 = t - w1;
      ab = Math.abs(w1 - w2);
      if(ans>ab) {
        ans = ab;
      }
    }
    
    System.out.println(ans);
  }
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	string s;
	ll k;
	cin >> s >> k;

	if(k == 1) cout << s[0] << endl;
	else {
		bool flag = false;
		int idx = 0;
		rep(i, 0, s.size()) {
			if(s[i] != '1') {
				flag = true;
				idx = i;
				break;
			}
		}
		if(flag) {
			if(k <= idx) cout << '1' << endl;
			else cout << s[idx] << endl;
		} else cout << s[1] << endl;

	}

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int N , M ;
int P [100000] , Y [100000];
vector < int > yd [100001];
int main ()
{
scanf ("%d %d" ,&N,&M);
for(int i=0;i<M;i++){scanf ("%d %d",& P [ i ] ,& Y [ i ]) , yd [ P [ i ]]. push_back ( Y [ i ]);}
for(int i=0;i<N;i++){sort ( yd [ i +1]. begin () , yd [ i +1]. end ());}
for(int i=0;i<M;i++){printf ("%012lld\n" , ll ( P [ i ])*1000000+ int ( lower_bound ( yd [ P [ i ]].
begin () , yd [ P [ i ]]. end () , Y [ i ]) - yd [ P [ i ]]. begin ())+1);}
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

    bool is_union(int a, int b) {
        return root(a) == root(b);
    }

};


int main() {
    int n, k, l;

    cin >> n >> k >> l;

    UnionFind road(n), train(n);
    rep(_, k) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        road.connect(a, b);
    }

    rep(_, l) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        train.connect(a, b);
    }

    vector<int> rr(n), tr(n);
    rep(i, n) rr[i] = road.root(i);
    rep(i, n) tr[i] = train.root(i);

    map<P, int> m;
    rep(i, n) m[P(rr[i], tr[i])]++;

    rep(i,n) cout << m[P(rr[i], tr[i])] << endl;


}


Measured memory_bytes: 15104
let rec solve p i k =
  if k <= i then p
  else solve (0.5 *. p) (2 * i) k

let () = Scanf.scanf "%d %d" @@ fun n k ->
  Printf.printf "%.15f\n" @@
  Array.fold_left ( +. ) 0. @@
  Array.init n @@ fun i -> solve (1. /. float_of_int n) (i + 1) k

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int A, B;
    cin >> A >> B;
    if ((A - B) % 2) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << A + (B - A) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from datetime import datetime

def gengo(y,m,d):
    date=datetime(y,m,d)
    if date<datetime(1868,9,8):
        return "pre-meiji"
    elif date<=datetime(1912,7,29):
        return "meiji {0} {1} {2}".format(y-1867,m,d)
    elif date<=datetime(1926,12,24):
        return "taisho {0} {1} {2}".format(y-1911,m,d)
    elif date<=datetime(1989,1,7):
        return "showa {0} {1} {2}".format(y-1925,m,d)
    else:
        return "heisei {0} {1} {2}".format(y-1988,m,d)

while True:
    try:
        y,m,d=[int(i) for i in input().split(" ")]
        print(gengo(y,m,d))
    except EOFError:
        break



Measured memory_bytes: 6044
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define ll long long
inline int roundup(int a, int b) { return (((a + (b -1)) / b)); }
using namespace std;

signed main(void) {
    int n, ac, wa, tle, re;
    ac = wa = tle = re = 0;
    string s;

    scanf("%d", &n);
    for(int i=0; i<n;++i) {
        cin >> s;
        if(s == "AC") {
            ac++;
        } else if(s == "WA") {
            wa++;
        } else if(s == "TLE") {
            tle++;
        } else if(s == "RE") {
            re++;
        }
    }
    cout << "AC x " <<  ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re << '\n';
    return 0;
}

Measured memory_bytes: 3700
n=int(input())
a=list(map(int,input().split()))
c2=0
c4=0
for i in range(n):
  if a[i]%4==0: c4+=1
  elif a[i]%2==0: c2+=1
if c4>=n//2: print("Yes")
elif (n//2-c4)*2<=c2: print("Yes")
else: print("No")


Measured memory_bytes: 15888
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_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(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, m, mn = INF, cnt;
    int a[111111], dif[111111], sum[111111];
    cin>>n>>m;
    rep(i, n) {
        cin>>a[i];
        if(i) dif[i] = a[i] - a[i - 1];
    }
    sum[0] = 0;
    rep(i, 1, n) {
        sum[i] = sum[i - 1] + dif[i];
    }
    rep(i, n - m + 1) {
        cnt = min(abs(a[i]), abs(a[i + m - 1]));
        cnt += sum[i + m - 1] - sum[i];
        chmin(mn, cnt);
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  int a,b,v,w;
  double t;
  cin >> a >> v >> b >> w >> t;
  double k = abs(b-a), s = v-w;
  if(s>0&&k/s<=t){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3720
import Control.Applicative

apply_maybe :: (a -> b) -> Maybe a -> Maybe b
apply_maybe _ Nothing = Nothing
apply_maybe f (Just a) = Just $ f a

sge' :: Int -> [Int] -> Maybe Int
sge' acc [_] = Just acc
sge' acc (a:(r@(b:_))) | b <= a     = sge' (acc + b) r
sge' acc (a:(r@(b:_))) | b == a + 1 = sge' (acc + 1) r
sge' _ _                            = Nothing

sge :: [Int] -> Int
sge l@(0:_) = case sge' 0 l of
    Nothing -> -1
    Just r  -> r
sge _ = -1

main :: IO ()
main = do
    n <- readLn
    a <- mapM (\_->readLn) [1..n]
    putStrLn $ show $ sge a


Measured memory_bytes: 120828
import kotlin.comparisons.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    (1..n).map {
        val (s, p) = readLine()!!.split(' ')
        Triple(it, s, p.toInt() * -1)
    }.sortedWith(compareBy({ it.second }, { it.third })).forEach { println(it.first) }
}


Measured memory_bytes: 36396
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, cnt[5];
string str;

int main(){
	cin >> n;
	memset(cnt, 0, sizeof(cnt));
	for(ll i = 1; i <= n; i++){
		cin >> str;
		if(str[0] == 'M'){cnt[0]++;}
		if(str[0] == 'A'){cnt[1]++;}
		if(str[0] == 'R'){cnt[2]++;}
		if(str[0] == 'C'){cnt[3]++;}
		if(str[0] == 'H'){cnt[4]++;}
	}
	
	ll ans = 0;
	for(ll i = 0; i < 5; i++){
		for(ll j = i+1; j < 5; j++){
			for(ll k = j+1; k < 5; k++){
				ans += cnt[i]*cnt[j]*cnt[k];
			}	
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int, int> pii;
int main(){
long long int n,k,i,q,winner;
cin>>n>>k>>q;
int points[n];
for(i=0;i<n;i++){
  points[i]=0;
}
for(i=0;i<q;i++){
  cin>>winner;
  points[winner-1]++;
}//os pontos do jogador i são k-q+points[i]
for(i=0;i<n;i++){
  if(k-q+points[i]<=0){
    cout << "No"<<endl;
  }else{
    cout << "Yes"<<endl;
  }
}


}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if (A * C <= B) {
		System.out.println(C);
		}else if (A * C > B) {
			System.out.println(B / A);
			}else {
				System.out.println(0);
			}
		}
}

Measured memory_bytes: 23636
m, d = map(int, raw_input().split())
c = 0
for d1 in range(2, 10):
    for d10 in range(2, d/10+1):
        if d1+10*d10 <= d and d1*d10 <= m:
            #print(d1+10*d10)
            #print(d1*d10)
            c +=1
print(c)

Measured memory_bytes: 2568
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]
C = [[0 for _ in range(l)] for _ in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for i in range(n):
    print(' '.join(map(str, C[i])))



Measured memory_bytes: 6892
//D - Insertion:)=-1,(=+1で累積和　一番左の+の数だけ右に),一番右の-の絶対値の数だけ左に(をつければよい
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
 */
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int[] c=new int[n+1];
        String s=sc.next();
        String r="";
        String l="";
        int neg=101;
        for (int i = 0; i < n; i++) {
            char a=s.charAt(i);
            if(a=='(')c[i+1]=c[i]+1;
            else c[i+1]=c[i]-1;
            neg=min(c[i+1],neg);
        }
        for (int i = 0; i < -neg; i++) {
            l+="(";
        }
        s=l+s;
        int temp=0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i)=='(')temp++;
            else temp--;
        }
        for (int i = 0; i < temp; i++) {
            r+=")";
        }
        out.println(s+r);
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int five = 0,
            seven = 0;
        for(int i = 0; i < 3; i++){
            switch(sc.nextInt()){
                case 5:
                    five++;
                    break;
                case 7:
                    seven++;
            }
        }
        if(five != 2 || seven != 1){
             System.out.println("NO");
        } else{
            System.out.println("YES");
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define MOD (1e9+7)

#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)

#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;

using namespace std;

int turnOn(int n, int i) {return n | (1<<i); }
bool status(int n, int i){return (bool)n & (1<<i);}

int n, m;
vector <int> graph[100005];
bool check[100005];
int result[100005];

void bfs(int src)
{
    queue<int> q;
    q.push(src);
    check[src] = true;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(auto v : graph[u]){
            if(check[v]== false){
                q.push(v);
                check[v] = true;
                result[v] = u;
            }
        }
    }
}

void solve()
{
    cin >> n >> m;
    for(int i = 1; i <= m ; i++){
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    memset(check, false, sizeof(check));
    bfs(1);
    //sort(result.begin(), result.end());
    cout << "Yes\n";
    for(int i = 2; i <= n; i++) cout << result[i] << "\n";
    // for(int i = 1; i <= n; i++){
    //     for(int j = 0; j < graph[i].size(); j++){
    //         cout << graph[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    
}

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

    // int t;cin >> t;
    // int i = 1;
    // while(t--){
    //     //cout << "Case " << i++ << ": ";
    //     solve();
    //     cout << "\n";
    // }
    solve();
    return 0; 
}

Measured memory_bytes: 10620
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, k;
  scanf("%d %d", &n, &k);

  int c = ((n - 1)*(n - 2))/2;

  if(k > c) printf("-1\n");
  else{
    printf("%d\n", n - 1 + ((n - 1)*(n - 2))/2 - k);
    for(int i = 2; i <= n; i++){
      printf("1 %d\n", i);
    }
    int cnt = 0; int x; int y = 2;
    while(cnt < ((n - 1)*(n - 2))/2 - k){
      x = y + 1;
      while(x <= n){
	printf("%d %d\n", y, x);
	x++;
	cnt++;
	if(cnt == ((n - 1)*(n - 2))/2 - k) break;
      }
      y++;
      if(cnt == ((n - 1)*(n - 2))/2 - k) break;
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<utility>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<pair<int,int>>ba(n);
    rep(i,n)cin>>ba[i].second>>ba[i].first;
    sort(rng(ba));
    ll t = 0;
    rep(i,n){
        if((ba[i].first-t)<ba[i].second){
            cout<<"No"<<endl;
            return 0;
        }
        t += ba[i].second;
    }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 4836
#include <stdio.h>
int main(){
  int i,relative;
  char t[3];
  double sum=0;
  scanf("%d",&relative);
  double money;
  for(i=0;i<relative;i++){
    scanf("%lf",&money);
    scanf("%s",t);
    if(t[0]=='J')
      sum+=money;
    else
      sum+=money*380000;
  }
  printf("%lf\n",sum);
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;


int main() {
    int A, B;
    cin >> A >> B;
    if(A >= B + 1){
        cout << 2 * A - 1 << endl;
    }else if(B >= A + 1){
        cout << 2 * B - 1 << endl;
    }else{
        cout << A + B << endl;
    }
}

Measured memory_bytes: 256
/* 
   AOJ 1144
   Curling 2.0

*/

#include<stdio.h>
#define MAXW 20
#define MAXH 20
#define MAX_DEPTH 10

int w, h;
int ans = 11;
int map[MAXH][MAXW];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


void print_map(void)
{
  int i, j;
  for(i = 0; i < h; i++)
    {
      for(j = 0; j < w; j++)
	{
	  printf("%d ", map[i][j]);
	}
      printf("\n");
    }
}

int in(int x, int y)
{
  return 0 <= x && x < w && 0 <= y && y < h;
}


void search(int x, int y, int cnt)
{
  /* printf("x = %d, y = %d, cnt = %d\n", x, y, cnt); */
  int i, nx, ny;
  if(cnt > MAX_DEPTH)return;

  for(i = 0; i < 4; i++)
    {
      nx = x + dx[i];
      ny = y + dy[i];

      /* printf("nx = %d, ny = %d\n", nx, ny); */
      
      if(!in(nx, ny) || map[ny][nx] == 1)
	continue;

      while(in(nx, ny) && map[ny][nx] == 0 || map[ny][nx] == 2)
	nx += dx[i], ny += dy[i];

      if(!in(nx, ny))
	continue;
	
      if(map[ny][nx] == 3)
	{
	  if(cnt + 1 < ans)
	    ans = cnt + 1;
	  return;
	}


      if(map[ny][nx] == 1)
	{
	  map[ny][nx] = 0;
	  search(nx - dx[i], ny - dy[i], cnt + 1);
	  map[ny][nx] = 1;
	}
    }
}

int main(void)
{
  int i, j, sx, sy;

  while(scanf("%d %d", &w, &h), (w && h))
    {
      for(i = 0; i < h; i++)
	for(j = 0; j < w; j++)
	  {
	    scanf("%d", &map[i][j]);
	    if(map[i][j] == 2)
	      sx = j, sy = i;
	  }
      search(sx, sy, 0);
      printf("%d\n", (ans == 11) ? -1 : ans);
      ans = 11;
    }

  return 0; 
}
/* 

8 8
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 2 1 3 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1

 */

Measured memory_bytes: 600
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
	int n, m;
	while (cin >> n, n) {
		char a, b;
		string str;
		map<char, char> to;
		for (int i = 0; i < n; ++i) {
			cin >> a >> b;
			to[a] = b;
		}
		cin >> m;
		for (int i = 0; i < m; ++i) {
			cin >> a;
			if (to[a]) a = to[a];
			str += a;
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef int in;
typedef vector<in> VI;
typedef vector<VI> VVI;
in n;
vector<set<in> > bleg,rdeg;
set<pair<in,in> > totegbl,totegrd;
queue<pair<in,in> > gdeg;
void adbl(in a, in b){
  assert(a!=b);
  if(a>b)
    swap(a,b);
  bleg[a].insert(b);
  bleg[b].insert(a);
  totegbl.insert(MP(a,b));
  if(totegrd.count(MP(a,b))){
    gdeg.push(MP(a,b));
  }
}
void adrd(in a, in b){
  assert(a!=b);
  if(a>b)
    swap(a,b);
  rdeg[a].insert(b);
  rdeg[b].insert(a);
  totegrd.insert(MP(a,b));
  if(totegbl.count(MP(a,b))){
    gdeg.push(MP(a,b));
  }
}
void erasebl(in a, in b){
  assert(a!=b);
  if(a>b)
    swap(a,b);
  bleg[a].erase(b);
  bleg[b].erase(a);
  totegbl.erase(MP(a,b));
}
void eraserd(in a, in b){
  assert(a!=b);
  if(a>b)
    swap(a,b);
  rdeg[a].erase(b);
  rdeg[b].erase(a);
  totegrd.erase(MP(a,b));
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>n;
  bleg.resize(n);
  rdeg.resize(n);
  in ta,tb;
  forn(z,n-1){
    cin>>ta>>tb;
    adbl(ta-1,tb-1);
  }
  forn(z,n-1){
    cin>>ta>>tb;
    adrd(ta-1,tb-1);
  }
  in gfd=0;
  pair<in,in> eg;
  in a,b;
  VI te;
  while(!gdeg.empty()){
    eg=gdeg.front();
    gdeg.pop();
    if(!totegrd.count(eg) || !totegbl.count(eg))
      continue;
    ++gfd;
    tie(a,b)=eg;
    if(sz(bleg[a])+sz(rdeg[a])<sz(bleg[b])+sz(rdeg[b]))
      swap(a,b);
    erasebl(a,b);
    eraserd(a,b);
    te.clear();
    fors(i,bleg[b]){
      te.PB(*i);
    }
    forv(i,te){
      erasebl(b,te[i]);
      adbl(a,te[i]);
    }
    te.clear();
    fors(i,rdeg[b]){
      te.PB(*i);
    }
    forv(i,te){
      eraserd(b,te[i]);
      adrd(a,te[i]);
    }
  }
  if(gfd==n-1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 40192
#include<bits/stdc++.h>
using namespace std;
int main(){
  double b,d,a,c;
  cin>>a>>c;
  b=(a+c)/2;
  d=b;
  d=(int)d;
  //cout<<d<<" "<<b<<"\n";
  if(d==b) cout<<d<<"\n";
  else cout<<d+1<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  if (n % 2 != 0) {
    cout << 0 << endl;
    return 0;
  }

  ll f = 10;
  while (f <= n) {
    ans += n / f;
    f *= 5;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256