akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
const ll MAXX = 1e18;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("INP.txt", "r", stdin);
    //freopen("OUT.txt", "w", stdout);
	ll a, b;
	cin >> a >> b;
	cout << max(a - (b * 2), 0LL) << '\n';
	return 0;
}

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

typedef long long ll;

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

// chmax, chmin
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; }

int N;
vector<int> C,S,F;

int next_time( int s, int i ){
    int quo = ( s + (F[i]-1) ) / F[i];
    int dep;
    if ( quo < ( S[i] / F[i] ) ) dep = S[i];
    else dep = F[i] * quo;
    return dep + C[i];
}

int main() {
    cin >> N;
    C.resize(N-1); S.resize(N-1); F.resize(N-1);
    REP(i,N-1) cin >> C[i] >> S[i] >> F[i];
    
    REP(i,N-1){
        //cout << "station" << i << endl;
        int s = S[i];
        for ( int j = i; j < N-1; ++j){
            s = next_time(s,j);
            //cout << "time" << s << endl;
        }
        cout << s << endl;
    }
    cout << 0 << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

typedef long long ll;

const int N = 6666;

int n, a[N];

int getid(int x) {
	if (x < 400) return 1;
	if (x < 800) return 2;
	if (x < 1200) return 3;
	if (x < 1600) return 4;
	if (x < 2000) return 5;
	if (x < 2400) return 6;
	if (x < 2800) return 7;
	if (x < 3200) return 8;
	return 9;
}

int cnt[233];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) cnt[getid(a[i])]++;
	int min_ans = 0;
	for (int i = 1; i <= 8; i++)
		min_ans += (cnt[i] > 0);
	int max_ans = min_ans;
	if (min_ans == 0 && cnt[9] > 0) min_ans = 1;
	max_ans = max_ans + cnt[9];
	printf("%d %d\n", max(min_ans, 1), max_ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll a;
    cin >> a;
    ll v = a%100;
    ll c = a / 100;
    if (v <= c * 5)cout << "1" << endl;
    else cout << "0" << endl;
}

Measured memory_bytes: 256
let quick_sort a cmp =
  let rec partition p r =
    let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
    in
    let rec exchange i j =
      if j >= r then (swap (i + 1) r; i + 1)
      else if cmp a.(j) a.(r) <= 0 then (swap (i + 1) j; exchange (i + 1) (j + 1))
      else exchange i (j + 1)
    in exchange (p - 1) p
  and doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end in
  doit 0 (Array.length a - 1)

let calc_cost a n =
  let b = Array.copy a in
  quick_sort b compare;
  let min_a = b.(0) in
  let max_a = b.(n - 1) in
  let b_i = Array.make (max_a + 1) 0 in
  Array.iteri (fun i e -> b_i.(e) <- i) b;
  let v = Array.make n false in
  let rec doit i cost =
    if i = n then cost
    else if v.(i) then doit (i + 1) cost
    else begin
      let rec aux j ws =
        v.(j) <- true;
        let w = a.(j) in
        if v.(b_i.(w)) then w :: ws
        else aux b_i.(w) (w :: ws)
      in
      let ws = aux i [] in
      let n_w = List.length ws in
      let sum_w = List.fold_left (+) 0 ws in
      let min_w = List.fold_left min max_a ws in
      doit (i + 1) (cost + (min (sum_w + (n_w - 2) * min_w) (sum_w + min_w + (n_w + 1) * min_a)))
    end in
  doit 0 0

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun e -> e)) in
  Printf.printf "%d\n" (calc_cost a n)

Measured memory_bytes: 2912
import java.util.Scanner;

class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

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

    if (N * A < B){
        System.out.println(N * A);
    }
    else {
      System.out.println(B);
    }
  }
}


Measured memory_bytes: 21460
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        for(int i = 0; i < s.length() - 1; i++){
            if(s.charAt(i) == s.charAt(i + 1)){
            System.out.println("Bad");
            return;
            }
        }
        System.out.println("Good");
        scan.close();
    }
}


Measured memory_bytes: 26972
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 199

void initialize();
char isEmpty();
char isFull();
void push(int);
int pop();

int S[100],top;

int main(){
  char temp[100];
  int i,a,b;

  initialize();
  
  while(scanf("%s",temp) != EOF){
    if(temp[0] >= '0' && temp[0] <= '9'){
      push(atoi(temp));
    }
    else{
      b = pop();
      a = pop();
      if(temp[0] == '+'){
	push(a+b);
      }
      if(temp[0] == '-'){
	push(a-b);
      }
      if(temp[0] == '*'){
	push(a*b);
      }
      if(temp[0] == '/'){
	push(a/b);
      }
    }
  }

  printf("%d\n",S[1]);
  
  return 0;
}

void initialize(){
  top = 0;
}

char isEmpty(){
  return top == 0;
}

char isFull(){
  return top >= MAX - 1;
}

void push(int x){
  if(isFull()){
    printf("エラー(オーバーフロー)");
  }
  else {
    top++;
    S[top] = x;
  }
}

int pop(){
  if(isEmpty()){
    printf("エラー(アンダーフロー)");
    return 0;
  }
  else {
    top--;
    return S[top+1];
  }
}

  



Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,h,w,ans=0;
cin >>n >> h >>w;
int a[n],b[n];
for (int i=0;i<n;i++){
cin >> a[i] >> b[i]; 
}
for(int i=0;i<n;i++){
if (a[i]>=h && b[i]>=w)ans++;
}
cout << ans << endl;
}

Measured memory_bytes: 256
function Main(input){
  var inp = input.split(' ');
  var X = inp[0];
  // 'A'の文字コードは65。'A'を10とするために65-10=55を引く
  var Xc = inp[0].charCodeAt() - 55;

  var Y = inp[1];
  var Yc = inp[1].charCodeAt() - 55;

  if(Xc < Yc){
    console.log('<');
  } else if(Xc > Yc){
    console.log('>');
  } else {
    console.log('=');
  }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	cout << (abs(in() - in()) > 1 ? "Alice" : "Brown") << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vpii = vector<pii>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
int main() {
	int n;
	while (cin >> n,n) {
		vector<vector<int>> buf(n);
		for (auto &a : buf) {
			int m;
			cin >> m;
			while (m--) {
				int b;
				cin >> b;
				a.push_back(b);
			}
			sort(ALL(a));
		}
		vi l;
		int m;
		cin >> m;
		while (m--) {
			int b;
			cin >> b;
			l.push_back(b);
		}
		int cnt = 0;
		int ans;
		rep(i, buf.size()) {
			auto &a = buf[i];
			bool f = 1;
			for (auto b : l) {
				if (!binary_search(ALL(a), b)) {
					f = 0;
					break;
				}
			}
			if (f) {
				cnt++;
				ans = i;
			}
		}
		cout << (cnt == 1 ? ans + 1 : -1) << endl;
	}
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <stdio.h>
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)

using namespace std;

typedef long long unsigned int ll;

int main(void) {
    ll i, n;
    ll count = 0;

    cin >> n;
    vector<ll> v(n);
    FOR(i,0,n) {
        cin >> v[i];
    }
    FOR(i,0,n) {
        if (i % 2 != 0)
            continue;
        if (v[i] % 2 == 0)
            continue;
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3624
import numpy as np
from functools import partial
D = int(input())
C = list(map(int, input().split()))
B = np.array([0] * 26)
S = [list(map(int, input().split())) for _ in range(D)]

def calc_satisfaction(d, t):
    _B = np.array(B)
    _B[t-1] = d
    satiety = sum(C * (d - B))
    return S[d-1][t-1] - satiety

satisfaction = 0
for d in range(1, D+1):
    f = partial(calc_satisfaction, d)
    t, satisfaction_d = max([(t, f(t)) for t in range(1, 27)], key=lambda x: x[1])
    B[t-1] = d
    satisfaction += satisfaction_d
    print(t)

Measured memory_bytes: 27536
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
 
const int MOD = 1e9 + 7;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0}; 
const char dir[] = {'R', 'L', 'D', 'U'};
 
int add(int a, int b){
    a += b;
    if(a >= MOD){
        a -= MOD;
    }
    return a;
}
 
int sub(int a, int b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}
 
int mult(int a, int b){
    return ((ll) a * b) % MOD;
}
 
void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}
 
//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//alt r is search & replace
//alt d is delete a line
 
bool comp(pii a, pii b){
    return a.y < b.y;
}
 
int main(){
    setIO();
    int n, x, t; cin >> n >> x >> t;
    int amt = n / x;
    if(n % x) ++amt;
    cout << amt * t << "\n";
}

Measured memory_bytes: 3608
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_C&lang=jp
  * Structure and Class - Dice III
  */
object Main {

  case class Dice(numbers: IndexedSeq[Int]) {
    def apply(number: Int): Int = {
      numbers(number)
    }

    def rotateTo(direction: Char): Dice = {
      direction match {
        case 'N' => Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))
        case 'S' => Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))
        case 'W' => Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))
        case 'E' => Dice(IndexedSeq(numbers(3), numbers(1), numbers(0), numbers(5), numbers(4), numbers(2)))
      }
    }

    def find(number: Int): Int = {
      // returns -1 if not found
      numbers.indexWhere(_ == number)
    }

    def adjustWith(dice: Dice): Dice = {
      val operationsToTop = Seq("", "", "N", "W", "E", "S", "NN")
      val operationsToFront = Seq("", "S", "", "WSE", "ESW", "SEEN", "N")
      val dice2 = operationsToTop(this.find(dice(0)) + 1).foldLeft(this)(_.rotateTo(_))
      val dice3 = operationsToFront(dice2.find(dice(1)) + 1).foldLeft(dice2)(_.rotateTo(_))
      dice3
    }
  }

  def main(args: Array[String]): Unit = {
    val dice1 = Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    val dice2 = Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    if (dice1 == dice2.adjustWith(dice1))
      println("Yes")
    else
      println("No")
  }
}

Measured memory_bytes: 44088
// atcoder.jp/contests/dp/tasks/dp_h
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define rep(i, s, n) for (ll i = s; i < n; ++i)
#define repm(i, s, n) for (ll i = s; n < i; --i)
#define dump(x) cerr << #x << " = " << (x) << " | ";
const int INF = 2 * 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int solve(int row, int col) {
    // input
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    string g[row + 2][col + 2]{};

    rep(i, 0, col + 2) { g[0][i] = "#"; }

    rep(i, 1, row + 1) {
        cin >> s;
        rep(j, 0, col + 2) {
            if (j == 0 || j == col + 1) {
                g[i][j] = "#";
            } else {
                g[i][j] = s[j - 1];
            }
        }
    }
    rep(i, 0, col + 2) { g[row + 1][i] = "#"; }
    // input

    int dp[row + 2][col + 2]{};

    rep(i, 0, row + 2) {
        rep(j, 0, col + 2) { dp[i][j] = 0; }
    }
    dp[1][1] = 1;

    rep(i, 1, row + 1) {
        rep(j, 1, col + 1) {
            if (g[i][j - 1] == ".") {
                dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
            }
            if (g[i - 1][j] == ".") {
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
            }
        }
    }
    return dp[row][col];
}

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

    int row, col;
    cin >> row >> col;

    int ans = solve(row, col);
    cout << ans << endl;
}


Measured memory_bytes: 38916
//#pragma GCC optimize(2)
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	bool f=0;int x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXN 100
#define INF 0x3f3f3f3f
#define Mod int(1e9+7)
char S[MAXN+5];
int L[MAXN+5],R[MAXN+5];
int main(){
	scanf("%s",S+1);
	int n=strlen(S+1),k=read();
	LL cnt=0;
	if(n==1){
		printf("%d\n",k/2);
		return 0;
	}
	for(int i=1;i<=n;i++)
		if(S[i]!=S[i-1]){
			int j=i;
			while(S[i]==S[j])
				j++;
			j--;
			cnt+=(j-i+1)/2;
			L[j]=j-i+1,R[i]=j-i+1;
		}
	if(k==1){
		printf("%lld\n",cnt);
		return 0;
	}
	if(R[1]==n){
		printf("%lld\n",1ll*n*k/2);
		return 0;
	}
	cnt*=k;
	if(S[1]!=S[n]){
		printf("%lld\n",cnt);
		return 0;
	}
	if(R[1]%2==1&&L[n]%2==1){
		printf("%lld\n",cnt+k-1);
		return 0;
	}
	printf("%lld\n",cnt);
	return 0;
}


Measured memory_bytes: 256
from math import sqrt
  
def primeFactors(n): 
    factor = dict()
    # Print the number of two's that divide n 
    while n % 2 == 0: 
        if 2 not in factor:
            factor[2] = 1
        else:
            factor[2] += 1
        n = n / 2
          
    # n must be odd at this point 
    # so a skip of 2 ( i = i + 2) can be used 
    for i in range(3,int(sqrt(n))+1,2): 
        # while i divides n , print i ad divide n 
        while n % i== 0: 
            if i not in factor:
                factor[i] = 1
            else:
                factor[i] += 1
            n = n / i 
              
    if n > 2: 
        factor[n] = 1

    return factor

x = int(input())
res = 0
pf = primeFactors(x)
for i in pf:
    res += int(0.5*(sqrt(8*pf[i] + 1) - 1))

print(res)

Measured memory_bytes: 9284
#include <iostream>
#define N 100005
using namespace std;
typedef long long ll;

string a;
ll n, M=1e9+7, c[N];

ll f(ll p) {
	if(p==n) return 1;
	if(a[p]=='0') return f(p+1);
	return (2*f(p+1) + c[p+1]) % M;
}

int main() {
	cin >> a;
	n = a.size();
	c[n] = 1;
	for(ll i=n-1; i>=0; i--) c[i] = c[i+1]*3 % M;
	cout << f(0);
	return 0;
}

Measured memory_bytes: 2816
def iip():
    return [int(i) for i in input().split()]

N, K = iip()
R, S, P = iip()
T = input()

point = 0
win = []
wp = {
    "r":P,
    "s":R,
    "p":S
}

for i in range(N):
    if i >= K and win[i-K] == T[i]:
        win.append(False)
    else:
        win.append(T[i])
        point += wp[T[i]]

#print(win)
print(point)

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

const int MAX = 1000000;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    int a,b;
    cin>>a>>b;
    if(a>2*b || b>2*a ||(a+b)%3){
        cout << 0 << endl;
        return 0;
    }
    int c = (a+b)/3;
    int d = a-b;
    int e = (c+d)/2;
    COMinit();
    cout << COM(c,e) << endl;
    return 0;
}


Measured memory_bytes: 23680
#include <iostream>
#include <queue>
#include <vector>
#include <map>

#define COL 12
#define ROW 12
using namespace std;

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

bool input(vector< vector<char> > &m);
void delete_island(vector< vector< char > > &m, int x, int y);


int main(){
  vector< vector< char > > m(COL+2, vector<char>(ROW+2, '0'));
  
  while(input(m)){
    int island = 0;
    for(int y = 0; y < m.size(); y++){
      for(int x = 0; x < m[y].size(); x++){
	if(m[y][x] == '1'){
	  delete_island(m,x,y);
	  island++;
	}
      }
    }
    cout << island << endl;
  }
}


bool input(vector< vector<char> > &m){
  for(int y = 0; y < m.size(); y++){
    for(int x = 0; x < m[y].size(); x++){
      if(y == 0 || x == 0 ||
	 y == m.size()-1 || x == m.size()-1){
	m[y][x] = '0';
      }else{
	if(!(cin >> m[y][x])) return false;
      }
    }
  }
  return true;
}


 void delete_island(vector< vector< char > > &m, int x, int y){
   queue< pair< int, int > > q;
   q.push(make_pair(x,y));

   while(!(q.empty())){
     pair<int, int> cur = q.front();
     q.pop();
     if(m[cur.second][cur.first] == '1'){
       m[cur.second][cur.first] = '0';
       for(int i = 0; i < 4; i++){
	 q.push(make_pair(cur.first+dx[i],cur.second+dy[i]));
       }
     }
   }
}

Measured memory_bytes: 3128
A, B, C, D = map(int, input().split())

takahashi_count = (int)(C/B)
aoki_count = (int)(A/D)

if C % B != 0 :
  takahashi_count += 1
if A % D != 0:
  aoki_count += 1

if takahashi_count <= aoki_count:
  print("Yes")
else:
  print("No") 

Measured memory_bytes: 9208
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
r=gi
puts 3.141592653589793*2*r

Measured memory_bytes: 14336
#include<stdio.h>
#define swap(a,b){a+=b;b=a-b;a-=b;}

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

	for (i = 0; i <= n - 1; i++){
		for (j = n - 1; j >= i + 1; j--){
			if (A[j] < A[j - 1]){
				swap(A[j], A[j - 1]);
				count++;
			}
		}
	}

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

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	constexpr int sz = 8010;
	string s;
	int x, y;
	cin >> s >> x >> y;

	vector<vector<int>> d(2, vector<int>(2*sz, 0));
	d[0][sz] = d[1][sz] = 1;
	int cnt = 0;
	int f = -1;
	s += "T";
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'F') {
			++cnt;
			continue;
		}
		if (f < 0) {
			d[0][sz + cnt] = 1;
			cnt = 0;
			f = 1;
			continue;
		}

		vector<int> t(2*sz, 0);
		for (int i = 0; i < 2*sz; ++i) {
			if (i - cnt >= 0) { t[i - cnt] |= d[f][i]; }
			if (i + cnt < 2*sz) { t[i + cnt] |= d[f][i]; }
		}
		d[f] = t;
		cnt = 0;
		f = 1 - f;
	}
	cout << (d[0][x + sz] & d[1][y + sz] ? "Yes" : "No") << "\n";

	return 0;
}


Measured memory_bytes: 3780
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
//#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
//#define base 1000000000000000000
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c,b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ull ba=233;
const db eps=1e-6;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=300000+10,maxn=10000000+10,inf=0x3f3f3f3f;

struct info{
    char s[10];
    int id,p;
    bool operator <(const info&rhs)const{
        return strcmp(s,rhs.s)<0||(strcmp(s,rhs.s)==0&&p>rhs.p);
    }
}a[N];
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%s%d",a[i].s,&a[i].p);
        a[i].id=i;
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)printf("%d\n",a[i].id);
    return 0;
}
/********************

********************/


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

using namespace std;
const int N = 1e5 + 5;
long long weigh[N], val[N], dp[105][N];

int main()
{
	int n, w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++)
		cin >> weigh[i] >> val[i];
	for (int it = 1; it <= n; it++)
	{
		for (int rem = 1; rem <= w; rem++)
		{
			long long op1, op2=0;
			op1 = dp[it - 1][rem];
			if (rem >= weigh[it])
				op2 = val[it] + dp[it - 1][rem - weigh[it]];
			dp[it][rem] = max(op1, op2);
		}
	}
	cout << dp[n][w] << "\n";

	return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int n,m,l;
  cin >> n >> m >> l;
  vector<vector<long long>> a(n,vector<long long>(m));
  rep(i,n) rep(j,m) cin >> a.at(i).at(j);
  vector<vector<long long>> b(m,vector<long long>(l));
  rep(i,m) rep(j,l) cin >> b.at(i).at(j);
  vector<vector<long long>> c(n,vector<long long>(l));
  rep(i,n){
    rep(j,l){
      rep(k,m){
        c.at(i).at(j) += a.at(i).at(k)*b.at(k).at(j);
      }
    }
  }
  rep(i,n){
    rep(j,l){
      cout << c.at(i).at(j);
      if(j == l-1) break;
      cout << " ";
    }
    cout << endl;
  }
}


Measured memory_bytes: 3240
n,m=map(int,input().split())
ab=sorted([list(map(int,input().split())) for _ in range(n)])
ans=0
i=0
while i<n:
    if m>=ab[i][1]:
        ans+=(ab[i][0])*ab[i][1]
        m-=ab[i][1]
        i+=1
    else:
        ans+=(ab[i][0])*(m)
        break
print(ans)

Measured memory_bytes: 86852
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	class E{

		int key;

		int value;

		E(int k,int v){

			key = k;

			value = v;

		}

	}

	void run(){

		boolean[] solved = new boolean[31];

		HashMap<Integer, Integer> l = new HashMap<Integer, Integer>();

		for(;;){

			String buffer = sc.nextLine();

			Scanner in = new Scanner(buffer.replace(',',' '));

			int n = in.nextInt();

			int s = in.nextInt();

			if((n|s)==0) break;

			solved[s] = true;	

			l.put(n, s);

		}

		int[] rank = new int[31];

		int r=0;

		for(int i=0;i < 31;i++){

			if(solved[30-i]){

				r++;

			}

			rank[30-i]=r;

		}

		for(;sc.hasNextLine();){

			String buffer = sc.nextLine();

			Scanner in = new Scanner(buffer.replace(',',' '));

			if(!in.hasNextInt()) break;

			int n = in.nextInt();

			int value = 0;

			value = l.get(n);

			System.out.println(rank[value]);

		}

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll=long long; //using lll=__int128;
using pii=pair<int,int>;
#define repeat(i,a,b) for(int i=(a),iE=(b);i<iE;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,iE=(a);i>=iE;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define N 10010
#define inf 1e9
#define qwq {cout<<"qwq"<<endl;}
//#define int ll
const int mod=1000000007;

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<int(a!=c)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

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

int main() {
    int n;
    cin >> n;
    vll a(n+1), b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll ans = 0;
    rep(i, n) {
        ll dmg = 0;
        for(int j = i; j <= i + 1; j++) {
            dmg = min(a[j], b[i]);
            a[j] -= dmg; b[i] -= dmg;
            ans += dmg;
            if(b[i] == 0) break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  map<int,int>reps;
  for(int i=0;i<n;i++){
  	int x;
  	cin>>x;
  	reps[x]++;
  }
  ll tot = 0;
  map<int,int>::iterator it;
  for(it=reps.begin();it!=reps.end();it++){
  	int a = it->first,b = it->second; 
  	if(a>b){
  		tot+=b;
  	}else if(a<b){
  		tot+=abs(a-b);
  	}
  }
  cout<<tot<<endl;
}  




Measured memory_bytes: 4736
import math

def fail():
    print(0)
    exit()

def main():
    n = int(input())
    As = list(map(int, input().split(' ')))
    ind_lis = {}
    idx = n - 1
    while idx >= 0:
        ind_lis[idx] = 0
        idx -= 2
    for a in As:
        if a not in ind_lis:
            fail()
        ind_lis[a] += 1
        if a == 0 and ind_lis[a] > 1:
            fail()
        elif ind_lis[a] > 2:
            fail()
    print(2**(n//2)%(10**9 + 7))



if __name__ == '__main__':
    main()

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long num,len;
    string str,fin="";
    cin >> num >> str;
    len=str.length();
    char a;
    if (len>=num){
        for (int i=0; i<num; i++) {
            a=str[i];
            fin+=a;}}
    else {
        fin=str;}
    if (len>num){
        fin+="...";}
    cout<<fin;}

Measured memory_bytes: 3624
n=int(input())
l=list(map(int, input().split()))
l1=l[0::2]
l2=l[1::2]
import collections
c1 = collections.Counter(l1)
#print(c1)
# Counter({'a': 4, 'c': 2, 'b': 1})
c2 =collections.Counter(l2)  
c0 =collections.Counter(l)
if len(c0)==1:
  print(int(n/2))
else:
  if c1.most_common()[0]==c2.most_common()[0]:
    print(min(n-c1.most_common()[0][1]-c2.most_common()[1][1], n-c1.most_common()[1][1]-c2.most_common()[0][1]))
  else:
    print(n-c1.most_common()[0][1]-c2.most_common()[0][1])
    
   

Measured memory_bytes: 30856
#include <bits/stdc++.h>
using namespace std;
int main() {

int N;
cin>>N;

bool hant = false;
for(int a=1; a<=9; a++){
  for(int b=1;b<=9; b++){
    if(N == a*b)hant = true;
  }
}
if(hant){
  cout<<"Yes"<<endl;
}
if(!hant) {
  cout<<"No"<< endl;
}
return 0;
}


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

using namespace std;

int n;
long a[100000];
long b[100000];

vector<pair<long, long>> res;

long calc(vector<long> &pos, vector<long> &neg) {
    if (pos.size() == 1) {
        long cur = pos[0];
        for (int i = 0; i < neg.size(); ++i) {
            res.push_back({cur, neg[i]});
            cur -= neg[i];
        }
        return cur;
    } else if (neg.size() == 1) {
        long cur = neg[0];
        for (int i = 0; i < pos.size() - 1; ++i) {
            res.push_back({cur, pos[i]});
            cur -= pos[i];
        }
        res.push_back({pos.back(), cur});
        return pos.back() - cur;
    } else {
        long cur = pos.back(); pos.pop_back();
        long o = calc(neg, pos);
        res.push_back({cur, o});
        return cur - o;
    }
}

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

    vector<long> pos, neg;
    pos.push_back(a[0]); neg.push_back(a[n-1]);
    for (int i = 1; i < n-1; ++i) {
        if (a[i] > 0) pos.push_back(a[i]);
        else neg.push_back(a[i]);
    }

    cout << calc(pos, neg) << "\n";
    for (int i = 0; i < n-1; ++i) cout << res[i].first << " " << res[i].second << "\n";
}


Measured memory_bytes: 11248
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define ppll pair<ll, pll>
#define pii pair<int, int> 
#define mod 998244353
#define pb push_back
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro%mod);
}
vector<int> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
bool cmp(pll a,pll b){
    return a.se<b.se;
}
ld sum=0;
void display(int a[], vector<pll>arr, int n) 
{ 
    setprecision(10);
    for (int i = 0; i < n-1; i++) { 
         sum+=sqrt(power(arr[a[i+1]].fi-arr[a[i]].fi,2)+power(arr[a[i+1]].se-arr[a[i]].se,2));
    } 
} 
void findPermutations(int a[], vector<pll> arr,int n) 
{  
    sort(a, a + n); 
    do { 
        display(a, arr, n); 
    } while (next_permutation(a, a + n)); 
} 
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a,b;
    cin>>n;
    vector<pll> arr(n);
    int ar[n];
    for(int i=0;i<n;i++){
        ar[i]=i;
    }
    for(int i=0;i<n;i++){
        cin>>a>>b;
        arr[i]={a,b};
    }
    findPermutations(ar, arr, n);
    ll pro=1;
    for(ll i=1;i<=n;i++){
        pro=pro*i;
    }
    ld ans=sum/(pro*1.0);
    cout<<setprecision(10)<<ans;
    return 0;
}


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

int main() {
    long a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long ans = 0;
    if (2 * c <= a + b) {
        ans += 2 * c * min(x, y);
        long z = min(x, y);
        x -= z;
        y -= z;
        if (x > 0) {
            if (a <= 2 * c) {
                ans += a * x;
            } else {
                ans += 2 * c * x;
            }
        } else if (y > 0) {
            if (b <= 2 * c) {
                ans += b * y;
            } else {
                ans += 2 * c * y;
            }
        }
    } else {
        ans += a * x + b * y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    a=-1;b=-1;
    for(i=n-1;i>0;i--){
        if(v[i]==v[i-1]){
            a=v[i];
            v[i]=-1;
            v[i-1]=-1;
            break;
        }
    }
    sort(v.begin(),v.end());
    for(i=n-1;i>0;i--){
        if(v[i]==v[i-1]){
            b=v[i];
            v[i]=-1;
            v[i-1]=-1;
            break;
        }
    }
    if(a<=0||b<=0){
        cout<<0<<'\n';
    }
    else cout<<(a*b)<<'\n';
    return 0;
}


Measured memory_bytes: 1400
#include <array>
#include <cstddef>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>

static const int N = 3;
static const int N2 = N * N;

static std::array<int, 4> dx{0, -1, 0, 1};
static std::array<int, 4> dy{1, 0, -1, 0};
static std::array<char, 4> dchar{'u', 'l', 'd', 'r'};

struct Puzzle
{
    std::array<int, N2> state;
    int space;
    std::string path = "";

    // For map comparison
    bool operator<(const Puzzle &p) const
    {
        for (size_t i = 0; i < state.size(); ++i)
        {
            if (state[i] != p.state[i])
            {
                return state[i] < p.state[i];
            }
        }

        return false;
    }
};

bool isTarget(Puzzle &p)
{
    for (int i = 0; i < p.state.size(); ++i)
    {
        if (p.state.at(i) != (i + 1))
            return false;
    }
    return true;
}

std::string bfs(Puzzle &p)
{
    std::queue<Puzzle> q;
    std::map<Puzzle, bool> visited;

    q.push(p);
    visited[p] = true;

    while (!q.empty())
    {
        auto u = q.front();
        q.pop();

        if (isTarget(u))
        {
            return u.path;
        }

        int u_space_x = u.space % 3;
        int u_space_y = u.space / 3;

        for (size_t i = 0; i < 4; ++i)
        {
            auto nx = u_space_x + dx[i];
            auto ny = u_space_y + dy[i];

            if (0 <= nx && nx < N && 0 <= ny && ny < N)
            {
                auto v = u;
                auto next_space = ny * 3 + nx;

                std::swap(v.state[u.space], v.state[next_space]);
                v.space = next_space;
                v.path += dchar[i];

                if (!visited[v])
                {
                    q.push(v);
                    visited[v] = true;
                }
            }
        }
    }

    return "Unsolvable\n";
}

int main()
{
    Puzzle in;
    for (size_t i = 0; i < N2; ++i)
    {
        std::cin >> in.state[i];
        if (in.state[i] == 0)
        {
            in.state[i] = 9;
            in.space = i;
        }
    }

    auto ans = bfs(in);
    std::cout << ans.length() << std::endl;
}



Measured memory_bytes: 33872
//AOJ 2_1 list (advance)

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

int main()
{  
    cout << fixed << setprecision(12);
    int n,q;
    cin>>n>>q;
    vector<vector<int>> a(n);
    REP(i,q)
    {
        
        int x,y,z;
        cin>>x>>y;
        if(x==0)cin>>z,a.at(y).push_back(z);
        else if(x==1)
        {
         REP(i,a.at(y).size())
         {
             cout<<a.at(y).at(i);
             if(i!=a.at(y).size()-1)cout<<" ";
         }
            cout<<endl;
        }
        else if(x==2)a.at(y).clear();
    }
}



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

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;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;

int main(){
  int n,m;
  cin >> n >> m;
  int c=pow(2,m);
  int ans=c*m*1900+c*(n-m)*100;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

int main() {
	int n, m;
	cin >> n >> m;
	
	vector<vector<int>> map(n);
	vector<int> ans(n);
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		
		map[x].push_back(y);
		map[y].push_back(x);

	}
	cout << "Yes" << endl;

	queue<int> q;
	q.push(0); ans[0] = 1;
	while (!q.empty()) {
		int k = q.front(); q.pop();
		rep(i, map[k].size()) {
			int a = map[k][i];
			if (ans[a] != 0) continue;
			ans[a] = k + 1;
			q.push(a);
		}
	}
	for (int i = 1; i < n; i++) cout << ans[i] << endl;
}



Measured memory_bytes: 10128
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans = w * h / 2;

    cout << ans << " ";
    if (2 * x == w && 2 * y == h) {
        cout << "1" << endl;
    } else {
        cout << "0" << endl;
    }
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		//System.out.println("hi ------------------");
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		for(int i = 0; i < totalVertex; i++)
		{
			ifSettled[i] = false;
		}
		
		for(int i = 0; i < totalVertex; i++)
		{
			for(int j = 0; j < totalVertex; j++)
			{
				int next = in.nextInt();
				if(next >= 0)
				{
					adjMatrix[i][j] = 1;
					adjWeight[i][j] = next;
				}else
				{
					adjMatrix[i][j] = 0;
					adjWeight[i][j] = 0;
				}
			}
		}
		in.close();
	}
	
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int spanning(int s) {
		int size = 0;
		int[] solution = new int[totalVertex];
		for(int i = 0; i < totalVertex; i++)
		{
			solution[i] = Integer.MAX_VALUE;
		}
		
		solution[s] = 0;
		ifSettled[s] = true;
		
		int settle = s;
		boolean check = true;
		LinkedList<Integer> next;
		
		while(check)
		{
			next = getUnsettledNeighbors(settle);
			for(int i: next)
			{
				if(solution[i] > getWeight(settle, i))
				{
					solution[i] = getWeight(settle, i);
				}
			}
			
			settle = getUnsettledNearest(solution);
			ifSettled[settle] = true;
			size = size + solution[settle];
			
			check = false;
			for(int i = 0; i < totalVertex; i++)
			{
				if(ifSettled[i] == false)
				{
					check = true;
				}
			}
		}
		
		return size;
	}
}

public class Main{
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		System.out.println(g.spanning(0));
	}
}


Measured memory_bytes: 40776
table = [[60, 2, 600], [80, 5, 800], [100, 10, 1000],
         [120, 15, 1200], [140, 20, 1400], [160, 25, 1600]]

until (n = $<.gets.to_i).zero?
  result = n.times.map {$<.gets.split.map(&:to_i)}.map do |x, y, h, w|
    idx = table.index {|d| x + y + h <= d[0] and w <= d[1]}
    idx ? table[idx].last : 0
  end.sum
  puts result
end


Measured memory_bytes: 7412
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 998244353;
ll fac[410],ifac[410];
int n,a[410],b[410],f[410][410];
void upd(int&a,ll b){a=(a+b)%mod;}
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
int main(){
	read(n);
	ll S=0;
	for(int i=1;i<=n;i++)
		read(a[i]),read(b[i]),S+=a[i];
	fac[0]=1;
	for(int i=1;i<=400;i++) fac[i]=fac[i-1]*i%mod;
	ifac[400]=fp(fac[400],mod-2);
	for(int i=400;i;i--) ifac[i-1]=ifac[i]*i%mod;
	f[0][0]=-1;
	for(int i=1;i<=n;i++){
		for(int j=S;~j;j--)
			for(int k=400;~k;k--)
				if(f[j][k]){
					ll now=1;
					for(int p=0;p<b[i];p++,now=now*a[i]%mod)
						upd(f[j+a[i]][k+p],-1ll*f[j][k]*ifac[p]%mod*now);
				}
	}
	ll ans=0;
	for(int j=0;j<=S;j++)
		for(int k=0;k<=400;k++){
			ll now=1ll*f[j][k]*fac[k]%mod*fp(fp(j,k),mod-2)%mod;
		//	if(now) cerr<<j<<' '<<k<<' '<<now<<'\n';
			ans=(ans+now*S%mod*fp(j,mod-2))%mod;
		}
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 1024
a,b,c = map(int,input().split())

if a == 5 and b == 5 and c == 7:
  print('YES')
elif a == 5 and b == 7 and c == 5:
  print('YES')
elif a == 7 and b == 5 and c == 5:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    
    int H, W, N;
    cin >> H >> W >> N;
    int painted_cnt = 0;

    while(N > 0)
    {
        int paint_size = max(H, W);
        N -= paint_size;
        painted_cnt++;
    }
    cout << painted_cnt << endl;

    return 0;
}

Measured memory_bytes: 256
# 葉頂点のインデックスを取得する
def search_leaf(edge_list):
    for i in range(N):
        if len([j for j in edge_list[i] if j]) == 1:
            return i
    # 葉頂点がない場合
    return N

N, M = map(int,input().split())
E = [[False for i in range(N)] for j in range(N)]

for i in range(M):
    a, b = map(int,input().split())
    E[a-1][b-1] = True
    E[b-1][a-1] = True

answer = 0

for i in range(N):
    V = search_leaf(E)
    if V == N: break
    
    # 橋を壊す
    main_land = E[V].index(True)
    E[V][main_land] = E[main_land][V] = False

    answer += 1

print(answer)

Measured memory_bytes: 3064
n,k=map(int,input().split());a=[k+i for i in range(n)]
sumA=sum(a);min_num=float('inf');result=0
for i in a:
  if min_num > abs(sumA-(sumA-i)):
    min_num=abs(sumA-(sumA-i))
    result=sumA-i
print(result)

Measured memory_bytes: 9132
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import Data.List (foldl', unfoldr)
import Data.Maybe (fromJust)


type Stack     = [Int]
type Neighbors = [Int]


main :: IO ()
main = do
    n    <- readLn :: IO Int
    adjL <- V.replicateM n $ map ((subtract 1 ) . fst . fromJust . B.readInt) . drop 2 . B.words <$> B.getLine
    let d = VU.replicate n 0 :: VU.Vector Int
        f = d
        (d', f', _) = foldl' (\s i -> dfs [i] adjL s) (d, f, 1) [0..(n-1)]
    forM_ [0..(n-1)] $ \i ->
        putStrLn $ unwords (show (i + 1) : show (d' VU.! i) : show (f' VU.! i) : [])


dfs :: Stack -> V.Vector Neighbors -> (VU.Vector Int, VU.Vector Int, Int) -> (VU.Vector Int, VU.Vector Int, Int)
dfs [] _ (d, f, t) =
    (d, f, t)

dfs stack adjL (d, f, t) =
    let
        s  = head stack
        ss = tail stack
    in
        if d VU.! s == 0 then do
            dfs stack adjL (d VU.// [(s, t)], f, (t + 1))
        else
            case next (adjL V.! s) d of
                Nothing ->
                    if (f VU.! s) == 0 then
                        dfs ss adjL (d, f VU.// [(s, t)], (t + 1))
                    else
                        dfs ss adjL (d, f, t)
                Just x ->
                    dfs (x : stack) adjL (d, f, t)


next :: Neighbors -> VU.Vector Int -> Maybe Int
next []     d = Nothing
next (n:ns) d =
    case d VU.! n of
        0 -> Just n
        _ -> next ns d



Measured memory_bytes: 4932