akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    long Y = sc.nextLong();
    ArrayList<Long> array = new ArrayList<>();
    array.add(X);
    long i = X;
    while (true) {
      i = 2 * i;
      if (i > Y) {
        break;
      }
      array.add(i);
    }
    System.out.println(array.size());
  }
}

Measured memory_bytes: 21844
n, m = map(int, input().split())
a = list(int(input()) for i in range(m))

a.insert(0, -1)
a.append(n + 1)
total = 1

def Fib(x):
    a, b = 1, 1
    if x == 1:
        return a
    elif x == 2:
        return b
    else:
        for i in range(x - 2):
            a, b = b, a + b
        return b

for i in range(1, m + 2):
    interim = a[i] - a[i - 1] - 1
    if interim <= 0:
        total = total * 0
    else:
        total = total * Fib(interim)

ans = total % 1000000007
print(ans)

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

int main() {
string S;
cin >> S;
int i = 0;
if (S == "SUN") i = 7;
else if (S == "MON") i = 6;
else if (S == "TUE") i = 5;
else if (S == "WED") i = 4;
else if (S == "THU") i = 3;
else if (S == "FRI") i = 2;
else if (S == "SAT") i = 1;

cout << i << endl;
return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


def read_input():
    n, m = map(int, input().split())

    d = defaultdict(lambda : True)
    for i in range(m):
        d[int(input())] = False

    return n, m, d




def submit():
    n, m, d = read_input()

    prev = 1
    prev_prev = 0
    for i in range(1, n + 1):
        curr = 0
        if d[i - 1]:
            curr += prev
        if d[i - 2]:
            curr += prev_prev

        curr %= 1000000007

        prev_prev = prev
        prev = curr

    print(curr)


if __name__ == '__main__':
    submit()


Measured memory_bytes: 54744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int cnt[101010];
int main() {
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        cnt[a]++;
        cnt[b]++;
    } 

    for(int i=1;i<=n;i++){
        if(cnt[i]%2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}



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



int main(){
int n,a[100],b[100],c[100],m=0;;
cin>>n;
for(int i=1;i<n;i++){
cin>>a[i];
}
m=a[1]+a[n-1];
for(int i=2;i<n;i++){
m+=min(a[i],a[i-1]);
}
cout<<m;
}


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

using namespace std;

class Solution {
public:
    void init(vector<int>& _A) {
        A = _A;
    }

    int query(int n, int x, int M) {
        int m = A.size();
        long long sum = accumulate(A.begin(), A.end(), 
                        0LL,[&](long long l, int r) { return l + r % M;});

        long long total = sum * ((n - 1) / m);
        int rem = n - 1 - (n - 1) / m * m;
        for (int i = 0; i < rem; ++i) {
            total += A[i] % M;
        }
        total += x;

        int res = n - 1 - (total / M - x / M);
        for (int i = 0; i < m; ++i) {
            if (A[i] % M == 0) {
                int cnt = (n - 1) / m + (rem > i);
                res -= cnt;
            }
        }

        return res;
    }

private:
    vector<int> A;
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int k, q;
    cin >> k >> q;
    vector<int> A(k);
    for (int i = 0; i < k; ++i) {
        cin >> A[i];
    }

    Solution sol;
    sol.init(A);
    while (q-- > 0) {
        int n, x, m;
        cin >> n >> x >> m;

        cout << sol.query(n, x, m) << "\n";
    }

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
long long gcd(long long a,long long b)
{	long long m,n,r;
	m=a;n=b;
	r=m%n;
	while(r)
	{	m=n;n=r;r=m%n;}
	return n;
}
int main() {
	  int N;
	  scanf("%d",&N);
	  long long res=1;
	  for (int i = 0; i < N; i++) 
	  {	long long b;
	    scanf("%lld",&b);
		res=res/gcd(res,b)*b;
	  }
	 printf("%lld\n",res);
	 return 0;
	}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func max(x int, y int) (ret int) {
	if x > y {
		ret = x
		return
	}
	ret = y
	return
}

func min(x int, y int) (ret int) {
	if x < y {
		ret = x
		return
	}
	ret = y
	return
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		sc.Scan()
		x := sc.Text()
		num, _ := strconv.Atoi(x)
		nums = append(nums, num)
	}
	return
}

func main() {
	// return value
	var output int

	// input the number of values
	var n int
	fmt.Scan(&n)

	// fetch values as a slice
	var nums []int
	nums = scanNums(n)

	maxv := nums[1] - nums[0]
	minv := nums[0]
	for i := 1; i < len(nums); i++ {
		maxv = max(maxv, nums[i]-minv)
		minv = min(minv, nums[i])
	}

	output = maxv
	fmt.Println(output)
}



Measured memory_bytes: 9552
#include<bits/stdc++.h>
#define ull unsigned long long int 
#define pb push_back
#define F first
#define S second
#define ll long long 
#define ld long double 

#define int long long int

const int mod = 1e9+7;
const ll inf = 1e18; 
 
int power(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int ncr(int n, int r){ int C[r+1]; memset(C, 0, sizeof(C)); C[0] = 1; for(int i = 1; i <= n; i++) {int t=i;if(r<t)t=r; for (int j = t; j > 0; j--) C[j] = C[j] + C[j-1]; }return C[r];} 
int gcd(int a,int b){if (a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}

int min(int a , int b){return a < b ? a : b;}
int max(int a , int b){return a > b ? a : b;}

using namespace std;

const int MAX = 200005;

int dp[MAX] , tree[4*MAX] = {} , h[MAX] , a[MAX];

int update(int pos , int value , int l , int r , int index){
	if(l == r)
		return tree[index] = max(tree[index] , value);
		
	if(l > pos || r < pos){
		return 0; // minimum
	}
	
	int mid = (l+r)/2;
	int x = update(pos , value , l , mid , 2*index);
	int y = update(pos , value , mid+1 , r , 2*index + 1);
	
	return tree[index] = max(tree[index] , max(x , y));
}

int get(int l , int r , int left , int right , int index){
	if(l > right || r < left){
		return 0;
	}
	
	if(l  >= left && r <= right)
		return tree[index];
		
	int mid = (l+r)/2;
	
	int x = get(l , mid , left , right , 2*index);
	int y = get(mid+1 , r , left , right , 2*index + 1);
	
	return max(x , y);
}


signed main(){

	 ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	
	for(int i = 1 ; i <= n ; i++){
		cin >> h[i];
	}
	
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
	}
	
	int ans = 0;
	for(int flower = 1 ; flower <= n ; flower++){
		int max_beauty = get(1 , n , 1 , h[flower]-1 , 1); // from 1 to h[flower]-1 , in between 1 and n
		dp[h[flower]] = max_beauty + a[flower];
		//cout << max_beauty << endl;
		ans = max(ans , dp[h[flower]]);
		int temp = update(h[flower] , dp[h[flower]] , 1 , n , 1);
	}
	
	cout << ans;
	
}










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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

template <class T>  inline void smax(T &x,T y){ x = max((x), (y)); }
template <class T>  inline void smin(T &x,T y){ x = min((x), (y)); }

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

char s[100005] ;

int main()
{
    int i , j , k , l , m , n ;

    scanf("%s",s) ;

    l = strlen(s) ;

    int ans = (l+1)/2 ;

    i = ans ;
    j = i-1 ;
    if(l%2==1) j-- ;

    while( j>=0 && s[i-1]==s[i] && s[j]==s[j+1] )
    {
        i++ ;
        j-- ;
        ans++ ;
    }

    printf("%d\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int n,a[N],sgt[2][N<<2];
inline void add(int op,int pos,int l, int r, int cnt) {
    if(a[cnt]<a[sgt[op][pos]])sgt[op][pos]=cnt;
    if(l==r)return;
	int mid=(l+r)>>1;
	if(cnt<=mid)add(op,pos<<1,l,mid,cnt);
	else add(op,pos<<1|1,mid+1,r,cnt);
}
inline int ask(int op,int pos,int l, int r, int L, int R) {
    if(l>R||r<L)return 0;
    if(L<=l&&r<=R)return sgt[op][pos];
    int mid=(l+r)>>1;
    int lans=ask(op,pos<<1,l,mid,L,R);
	int rans=ask(op,pos<<1|1,mid+1,r,L,R);
	return a[lans]<a[rans]?lans:rans;
}
struct stru{
    int l,r,v;
    stru(int _l,int _r){
    	l=_l,r=_r,v=(l>r)?0:ask(l&1,1,1,n,l,r); 
	}
	bool operator <(const stru &other) const{
		return a[v]<a[other.v]; 
	}
};
set<stru> s;
int main(){
	scanf("%d",&n);a[0]=n+1;
    for(int i=1;i<=n;i++){
    	scanf("%d",&a[i]);
        add(i&1,1,1,n,i);
    }
    s.insert(stru(1,n));
    for(int i=1;i<=n>>1;i++){
        stru now=*s.begin();
        s.erase(s.begin());
        int l=now.l,r=now.r;
        int lmid=now.v,rmid=ask((lmid&1)^1,1,1,n,lmid,r);
        printf("%d %d ",a[lmid],a[rmid]);
        s.insert(stru(l,lmid-1));
        s.insert(stru(lmid+1,rmid-1));
        s.insert(stru(rmid+1,r));
    }
    return 0;
}

Measured memory_bytes: 11008
#include <iostream>

int main(int argc, char *argv[]) {
  std::string s;
  std::cin >> s;
  if (s.find("YAKI") == 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
from bisect import bisect_left
x, n = [int(i) for i in sys.stdin.readline().split()]
p_s = [int(i) for i in sys.stdin.readline().split()]
candidate = [i for i in range(-1000,1000) if i not in p_s]
ind = bisect_left(candidate, x)
if ind == len(candidate):
    print(candidate[-1])
elif x - candidate[ind-1] <= candidate[ind] - x:
    print(candidate[ind-1])
else:
    print(candidate[ind])

Measured memory_bytes: 64476
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()
int linear_search(vector<int> a, int target){
    int index = -1;
    for (int i = 0; i < a.size(); i++){
        if (a[i] == target){
            index = i+1;
            break;
        }
    }
    return index;
}
void solve(){

}
int main(){
    int n;
    cin >> n;
    vector<int> a,b;

    int x;
    for (int i = 0; i < n; i++){
        cin >> x;
        a.push_back(x);
    }

    int index = 1;
    for (int i = 0; i < n; i++){
        b.push_back(a[index-1]);
        index = a[index-1];
    }

    cout << linear_search(b,2) << endl;
}

Measured memory_bytes: 1528
n,*b=map(int,open(0).read().split())
a=[]
while b:
  j=max(i*(i==v)for i,v in enumerate(b,1))
  if j:
    b=b[:j-1]+b[j:]
    a+=[j]
  else:
    a=[-1]
    break
print(*a[::-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[55],b[55],c[55];
	int n;
	int cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++)	
		cin>>a[i];
	for(int i=1;i<=n;i++)	
		cin>>b[i];
	for(int i=1;i<n;i++)	
		cin>>c[i];	
	for(int i=1;i<=n;i++)
	{
		cnt+=b[a[i]];
		if(a[i]==a[i-1]+1)cnt+=c[a[i-1]];
	}
	cout<<cnt<<endl;
	return 0;
 } 

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

int main() {
    int H,W;
    cin >> H >> W;
    char pixel_org[H][W];

    for(int i=0; i<H; i++)
        for(int j=0; j<W; j++)
            cin >> pixel_org[i][j];
    
    cout << endl;

    for(int i=0; i<H; i++)
    {
        for(int j=0; j<W; j++)
        {
            cout << pixel_org[i][j];
        }
        cout << endl;

        for(int j=0; j<W; j++)
        {
            cout << pixel_org[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
import itertools

n,m,q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(q)]

A = list(range(1,m+1))

ptr = list(itertools.combinations_with_replacement(A, n))

ans = 0

for i in ptr:
    tmp = 0
    for a,b,c,d in abcd:
        if i[b-1] - i[a-1] == c:
            tmp += d
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 21616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=100,z=0,w=0,n=0,m=0,o=0;
std::cin >> x;
while(x>y){
y+=y*0.01;
z++;
}
std::cout <<z<< '\n';
}


Measured memory_bytes: 3640
n = int(input())
s = [x for x in input()]
start = len([1 for i in s[1:] if i=='E'])
dp = [0]*n
ans =start
for i,j in enumerate(s):
	if i ==0:
		now=start
		continue
	if j =='E':
		now-=1
	if s[i-1]=='W':
		now+=1
	ans=min(ans,now)
print(ans)
	

Measured memory_bytes: 10392
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "numeric"
#include "iomanip"
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	double vec1[105], vec2[105];
	for (int i = 1; i <= n; i++) {
		cin >> vec1[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> vec2[i];
	}
	double d[5] = {};
	double sum = 0, powered2_Sum = 0, powered3_Sum = 0;
	double maxAbs = 0;
	for (int i = 1; i <= n; i++) {
		int Abs= abs(vec1[i] - vec2[i]);
		if (maxAbs < Abs)maxAbs = Abs;
		sum += Abs;
		powered2_Sum+= Abs*Abs;
		powered3_Sum += Abs * Abs*Abs;
	}
	d[1] = sum;
	d[2] = sqrt(powered2_Sum);
	d[3] = cbrt(powered3_Sum);
	d[4] = maxAbs;
	for (int i = 1; i <= 4; i++) {
		cout << fixed<< setprecision(6) << d[i] << endl;
	}
}


Measured memory_bytes: 3476
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI3(H, W, N);
  map<ll, int> list;
  FOR(i, N) {
    GI2(a, b);
    a--;
    b--;
    for (int x = b - 2; x <= b; ++x) {
      for (int y = a - 2; y <= a; ++y) {
        if (0 <= x && x < W - 2 && 0 <= y && y < H - 2) {
          list[y * (ll)W + x]++;
        }
      }
    }
  }
  vector<ll> acc(10);
  ll sum = 0;
  for (pair<ll, int> p : list) {
    acc[p.second]++;
    sum++;
  }
  acc[0] = (ll)(H - 2) * (W - 2) - sum;
  FOR(i, 10) print(acc[i]);
  return 0;
}

Measured memory_bytes: 56448
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  string a,b,c;
  int n;
  cin >> n >> a >> b >> c;
  int ans = 0;
  rep(i,n){
    set<char>check;
    check.insert(a[i]);
    check.insert(b[i]);
    check.insert(c[i]);
    ans += check.size() - 1;
  }
  cout << ans << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <complex>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
using namespace std;
#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGATIVESET(d) if ((d) < 0) d = (d % MOD + MOD) % MOD;
#define pii pair<long long ,long long >
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define loop2(i,n) for(ll i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define EPS 1e-7
using namespace std;
// JAI SHREE KRISHNA
//Winning is my right
//I.W.T.D.I.F.M.F


bool check(string s)
{
    
    set<char>s1;
    loop(i, s.length())
    {
        s1.insert(s[i]);
    }
    if(s1.size()>2)
    {
        return false;
    }
    else{
        for(ll j = 0 ;j<s.length()-2;j+=1)
        {
            if(s[j]!=s[j+2])
            {
                return false;
            }
        }
    }
    return true;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
   
    string s;
    cin>>s;
    if(check(s))
    {
        cout<<"Second";
        return 0;
    }
    ll n = s.length();
    if(s[0]==s[n-1])
    {
        ll x = s.length()-2;
        x-=1;
        if(x&1)
        {
            cout<<"First";
        }
        else{
            cout<<"Second";
        }
return 0;
    }
    else{
        ll x = s.length()-2;
        if(x&1)
        {
            cout<<"First"<<endl;
        }
        else{
            cout<<"Second";
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
const int N = 100005, M = 500005;
const int Inf = 0x3f3f3f3f;
int End[M], Last[M], Next[M], Path[N], dis[N];
bool Vis[N];
struct P{
    int x, step;
};
queue<P> Q;

void add_edge(int &cnt, int x, int y) {
    ++cnt;
    End[cnt] = y, Next[cnt] = Last[x], Last[x] = cnt;
}

int main() {
    int cnt = 0, n, m, a, b;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= m; ++i) {
        scanf("%d%d",&a,&b);
        add_edge(cnt,a,b);
        add_edge(cnt,b,a);
    }
    for(int i = 1; i <= n; ++i) Path[i] = -1, dis[i] = Inf;
    P u, v;
    u.x = 1, u.step = 0, Q.push(u);
    while(!Q.empty()) {
        u = Q.front(), Q.pop();

        for(int t = Last[u.x]; t; t = Next[t]) {
            v.x = End[t];
            v.step = u.step + 1;
            if(!Vis[v.x] && v.step < dis[v.x]) {
                Vis[v.x] = true;
                dis[v.x] = v.step;
                Path[v.x] = u.x;
                Q.push(v);
            }
        }
    }

    bool Can = true;
    for(int i = 1; i <= n; ++i)
        if(Path[i] == -1) Can = false;
    
    if(Can) {
        printf("Yes\n");
        for(int i = 2; i <= n; ++i)
            printf("%d\n",Path[i]);
    } else {
        printf("No\n");
    }
return 0;
}

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

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

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

    ll k; cin >> k;
    ll m = k % 50;
    cout << 50 << '\n';
    vector<ll> a(50, k / 50 + 49 - m);
    for (int i = 0; i < m; i++) a[i] += 51;
    for (int i = 0; i < 50; i++) cout << a[i] << " \n"[i == 49];
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int H, W;
char a[110][110];
int cnt[26];
int num[5];

int solve()
{
	int i, j;
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			cnt[a[i][j]-'a'] ++;
		}
	}
	num[4] = H*W;
	if(H%2==1)
		num[4] -= W;
	if(W%2==1)
		num[4] -= H;
	if(H%2==1 && W%2==1)
		num[4] ++;
	num[4] /= 4;
	if(H%2==1)
		num[2] = W;
	if(W%2==1)
		num[2] += H;
	if(H%2==1 && W%2==1)
		num[2] -= 2;
	num[2] /= 2;
	if(H%2==1 && W%2==1)
		num[1] = 1;
	for(i=0; i<26; i++){
		while(cnt[i]>=4 && num[4]>0){
			cnt[i] -= 4;
			num[4] --;
		}
	}
	for(i=0; i<26; i++){
		while(cnt[i]>=2 && num[2]>0){
			cnt[i] -= 2;
			num[2] --;
		}
	}
	for(i=0; i<26; i++){
		while(cnt[i]>=1 && num[1]>0){
			cnt[i] -= 1;
			num[1] --;
		}
	}
	for(i=0; i<26; i++){
		if(cnt[i] > 0)
			return 0;
	}
	return 1;
}

int main()
{
	int i;
	scanf("%d%d", &H, &W);
	for(i=0; i<H; i++)
		scanf("%s", &a[i]);
	if( solve() )
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}


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

	cin >> N;
	cin >> H >> K;
	vector<long long int>by(max(N, H) + 1, 1);
	vector<long long int>rev_by(max(N, H) + 1, 1);
	for (int i = 1; i <= max(N, H); i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev_by[i] = power(by[i], MOD - 2, MOD);
	}
	long long int box = 0;
	for (int i = 1; i <= N; i++) {
		box += by[i];
		box %= MOD;
	}
	vector<long long int>dp(H + 1);
	dp[0] = by[N];
	for (int i = 1; i <= K; i++)dp[i] = by[N];
	for (int i = 1; i <= H; i++) {
		dp[i] = dp[i - 1];
		if (i - K - 1 >= 0)dp[i] -= dp[i - K - 1];
		dp[i] += MOD;
		dp[i] %= MOD;
		if (i == H)break;
		dp[i] *= box;
		dp[i] %= MOD;
		dp[i] += dp[i - 1];
		dp[i] %= MOD;
	}
	cout << dp.back() << endl;
}

Measured memory_bytes: 23808
n, m = map(int, input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


divisors = sorted(make_divisors(m), reverse=True)
for div in divisors:
    if div <= m//n:
        print(div)
        exit()


Measured memory_bytes: 3060
import heapq  # heapqライブラリのimport
N,M=map(int,input().split())
A = list(map(int,input().split()))
for j in range(N):
 A[j]*=-1
heapq.heapify(A)  # リストを優先度付きキューへ
for i in range(M):
 c=heapq.heappop(A)
 c=((-c)//2)
 heapq.heappush(A, -c)
print(-sum(A))


Measured memory_bytes: 72300
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int a,b;string s;
    cin>>a>>b;
    cin>>s;
    bool f=true;
    if(s[a]!='-')   f=false;
    for(int i=0;i<a+b+1;i++){
        if(i==a)    continue;
        if((s[i]-'0')>9||(s[i]-'0')<0)  f=false;
    }
    if(f)   cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 892
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val c = sc.nextInt()

  if (a == b && b == c) {
    println(0)
    return
  }

  val abc = mutableListOf<Int>()
  abc.add(a)
  abc.add(b)
  abc.add(c)

  val sum = abc.sum()
  val max = abc.max()!!
  val tmp = 3 * max

  if (sum % 2 == tmp % 2) {
    println((tmp - sum) / 2)
  } else {
    val max1 = max + 1
    println((max1 * 3 - sum) / 2)
  }

}


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

using namespace std;

int main(int argc, char** argv){
    string tiles;
    cin >> tiles;
    int n = tiles.length();
    int black[n];
    int white[n];
    for(int i = 0; i < n; i++){
        if(i == 0){
            black[i] = tiles[i] == '0' ? 0 : 1;
            white[i] = tiles[i] == '1' ? 0 : 1;
        } else {
            black[i] = white[i-1] + (tiles[i] == '0' ? 0 : 1);
            white[i] = black[i-1] + (tiles[i] == '1' ? 0 : 1);
        }
    }
    cout << min(black[n-1], white[n-1]) << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
const int N = 35;
const int M = 1e4;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0); 
 
int main(){
	double r;
	cin >> r;
	printf("%.16f",2*PI*r);
	return 0;
}


Measured memory_bytes: 3780
object Main extends App {
  val ab = scala.io.StdIn.readLine()
  val abArray = ab.split(" ").map(_.toInt).toVector
  val a = abArray(0)
  val b = abArray(1)
  if (a >= 10 || b >= 10) {
    println(-1)
  } else {
    println(a * b)
  }
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int A,B,C;
    cin>>A>>B>>C;
    if (A+B >= C) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  int i;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
    vec.at(i)--;
  }
  int count=0,x=vec.at(0);
  for(i=1;i<n;i++){
    count++;
    if(x==1){
      cout << count;
      return 0;
    }
    x=vec.at(x);
  }
  cout << -1;
}

Measured memory_bytes: 640
import math
import copy

n = int(input())
A = [None for i in range(n)]
for i in range(n):
    a, b = input().split()
    A[i] = [a, int(b)]
inf = 10**9

def merge(A,left,mid,right):
	#global cnt
	L = A[left:mid] + [[inf,inf]]
	R = A[mid:right] + [[inf,inf]]
	i = 0
	j = 0

	for k in range(left,right):
		#cnt += 1
		if L[i][1] <= R[j][1]:
			A[k] = L[i]
			i += 1
		else:
			A[k] = R[j]
			j += 1

def mergeSort(A,left,right):
	if left + 1 < right:
		mid = (left + right) // 2
		mergeSort(A,left,mid)
		mergeSort(A,mid,right)
		merge(A,left,mid,right)


def partition(A,p,r):
	x = A[r][1]
	i = p
	for j in range(p,r):
		if A[j][1] <= x:
			A[i], A[j] = A[j], A[i]
			i = i+1
	A[i], A[r] = A[r], A[i]

	return i

def quickSort(A,p,r):
	if p < r:
		q = partition(A,p,r)
		quickSort(A,p,q-1)
		quickSort(A,q+1,r)


B = copy.deepcopy(A)
mergeSort(A,0,n)
quickSort(B,0,n-1)

if A == B:
	print("Stable")
else:
	print("Not stable")

ans = [str(x[0]) +" "+str(x[1]) for x in B]
ans = '\n'.join(ans)
print(ans)


Measured memory_bytes: 39312
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;
	auto ans1 = A + B;
	auto ans2 = A - B;
	auto ans3 = A * B;

	writeln(max(ans1, max(ans2, ans3)));
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int tmp;
        int[] nums=new int[n];
        int[] dp=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        for(int i=1;i<n;i++){
            tmp=-1;
            for(int j=0;j<Math.min(k,i);j++){
                if(tmp==-1||tmp>dp[i-j-1]+Math.abs(nums[i]-nums[i-j-1])){
                    tmp=dp[i-j-1]+Math.abs(nums[i]-nums[i-j-1]);
                }
            }
            dp[i]=tmp;
        }
        System.out.println(dp[n-1]);

    }
}

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

using namespace std;

const int N = 100005;

int n, a[N], dp[N][2];

int fun(int i, int f) {
  if (i >= n) return 0;
  int &ret = dp[i][f];
  if (ret != -1) return ret;
  ret = INT_MAX;
  if (i + 1 < n) {
    ret = min(ret, abs(a[i] - a[i + 1]) + fun(i + 1, 0));
  } else {
    return ret = 0;
  }
  if (i + 2 < n) {
    ret = min(ret, abs(a[i] - a[i + 2]) + fun(i + 2, 1));
  }
  return ret;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  memset(dp, -1, sizeof dp);
  printf("%d\n", fun(0, 0));
  return 0;
}


Measured memory_bytes: 6144
#include<cstdio>
#include<cstring>
#include<algorithm>
#define P 998244353
#define N 305

char s[N];
int n,m;

int cnt[N];

int dp[N][N][N<<1],s1[N][N<<1],s2[N][N<<1],ans;

int main(){
	scanf("%s%d",s+1,&m);
	n=strlen(s+1);
	m=std::min(m,n)<<1;
	for(int i=1,tmp=0;i<=n;i++)
		if(s[i]=='0')
			tmp++;
		else
			cnt[tmp+1]++;
	dp[0][0][0]=1;
	for(int j=0;j<=n&&j<=m;j++)
		s1[j+1][j+1]=1;
	s2[1][1]=1; 
	for(int i=1;i<=n+1;i++){
		for(int j=0;j<=n;j++)
			for(int k=0;k<=m;k++){
				dp[i][j][k]=(dp[i][j][k]+s1[j+1][k+1])%P;
				int x=std::min(std::min(n-j,k),cnt[i]);
				if(x)
					dp[i][j][k]=((dp[i][j][k]+s2[j+2][k])%P+P-s2[j+2+x][k-x])%P;
			}
		for(int j=0;j<=n;j++)
			for(int k=0;k<=m;k++)
				s1[j+1][k+1]=(s1[j][k]+dp[i][j][k])%P;
		for(int j=n;j>=0;j--)
			for(int k=0;k<=m;k++)
				s2[j+1][k+1]=(s2[j+2][k]+dp[i][j][k])%P;
	}
	for(int k=0;k<=m;k++)
		ans=(ans+dp[n+1][0][k])%P;
	printf("%d",ans);
}

Measured memory_bytes: 220000
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

long long largestRectangle(const vector<int> &histogram) {
    long long res = 0;
    const int n = (int)histogram.size();
    stack<int> stk;
    vector<int> toLight(n), toRight(n);
    for (int i = 0; i < n; ++i) {
        while (!stk.empty() && histogram[stk.top()] >= histogram[i])
            stk.pop();
        toLight[i] = stk.empty() ? 0 : stk.top() + 1;
        stk.push(i);
    }
    while (!stk.empty())stk.pop();
    for (int i = n - 1; i >= 0; --i) {
        while (!stk.empty() && histogram[stk.top()] >= histogram[i])
            stk.pop();
        toRight[i] = stk.empty() ? n : stk.top();
        stk.push(i);
        long long width = toRight[i] - toLight[i];
        res = max(res, (width + 1)*(histogram[i] + 1));
    }
    return res;
}

/*
0と1からなるグリッドで
1のみからなる長方形の最大の面積を返す
O(HW)
*/
int largestRectangle(vector<vector<int> > a) {
    int h = (int)a.size();
    int w = (int)a[0].size();
    for (int i = 1; i < h; ++i)for (int j = 0; j < w; ++j)
        if (a[i][j])a[i][j] = a[i - 1][j] + 1;
    int res = 0;
    for (int i = 0; i < h; ++i)
        res = max(res, (int)largestRectangle(a[i]));
    return res;
}

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

    int H, W;
    cin >> H >> W;
    int ans = max(H, W);
    vector<string> S(H);
    vector<vi> A(H, vi(W)), B(H - 1, vi(W - 1));
    rep(y, H) {
        cin >> S[y];
        rep(x, W) {
            A[y][x] = S[y][x] == '.' ? 1 : 0;
        }
    }
    rep(y, H - 1)rep(x, W - 1) {
        B[y][x] = 1 ^ A[y][x] ^ A[y + 1][x] ^ A[y][x + 1] ^ A[y + 1][x + 1];
    }

    smax(ans, largestRectangle(B));
    cout << ans << endl;
}

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

int dp[1<<16];

int main()
{   
    int N, M, L;
    
    while(cin >> N, N) {

	int res = 0;
	memset(dp, 0, sizeof(dp));
	
	for(int i=0; i<N; i++) {
	    cin >> M >> L;

	    int sb = 0;
	    for(int j=0; j<M; j++) {
		int s,e;
		cin >> s >> e;
		s -= 6; e -= 6;
		
		for(int k=s; k<e; k++)
		    sb |= (1<<k);
	    }

	    for(int k=0; k<(1<<16); k++) {
		if(sb&k) continue;
		dp[sb|k] = max(dp[sb|k], dp[k] + L);
		res = max(res, dp[sb|k]);
	    }
	}

	cout << res << endl;
	
    }
}

Measured memory_bytes: 0
from collections import deque

n = int(input())
A = list(map(int, input().split()))

d = deque()

for i, a in enumerate(A):
    if i%2 == 0:
        d.append(a)
    else:
        d.appendleft(a)

if n%2==0:
    print(*d)
else:
    d = list(d)
    print(*d[::-1])


Measured memory_bytes: 32508
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int W = scan.nextInt();
        while (H != 0 || W != 0) {
            for (int a = 1; a <= H; a++) {
                for (int b = 1; b <= W; b++) {
                    if (a%2 == 1 && b%2 == 0 || a%2 == 0 && b%2 == 1) {
                        System.out.print(".");
                    } else {
                        System.out.print("#");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
            H = scan.nextInt();
            W = scan.nextInt();
        }

    }
}


Measured memory_bytes: 34600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;cin>>h>>w;
  string s[h];
  int x[4]={-1,1,0,0};
  int y[4]={0,0,1,-1};
  for(int i=0;i<h;i++)cin>>s[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='.')continue;
      int c=0;
      for(int k=0;k<4;k++){
        if(i+y[k]<0||i+y[k]>=h||j+x[k]<0||j+x[k]>=w)continue;
        if(s[i+y[k]][j+x[k]]=='#'){
          c=1;break;
        }
      }
      if(c==0){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}

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

// header area

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

    int t = N%10;
    if(N%10 == 3)  cout << "bon" << endl;
    else if(t == 0 || t==1 || t==6 || t==8)  cout << "pon" << endl;
    else cout << "hon" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int n, k;
struct Edge
{
	int to;
	int next;
}edge[100005 << 1];
int head[100005];
int cnt;
void Addedge(int fr,int to)
{
	edge[++cnt].to = to;
	edge[cnt].next = head[fr];
	head[fr] = cnt;
}
int p[100005];
bool vp[100005];
bool vi[100005];
int l[100005],r[100005];
bool DFS1(int now, int fa)
{
	for(int i = head[now]; i; i = edge[i].next)
	{
		if(edge[i].to != fa)
		{
			if(!DFS1(edge[i].to, now))
			{
				return 0;
			}
			if(vi[edge[i].to])
			{
				int ll = l[edge[i].to] - 1;
				int rr = r[edge[i].to] + 1;
				if(vi[now])
				{
					if(rr < l[now] || ll > r[now] ||((ll & 1) != (l[now] & 1)))
					{
						return 0;
					}
					l[now] = max(l[now], ll);
					r[now] = min(r[now], rr);
				}
				else
				{
					vi[now] = 1;
					l[now] = ll;
					r[now] = rr;
				}
			}
		}
	}
	if(vp[now])
	{
		if(vi[now] && (p[now] < l[now] || p[now] > r[now] || (p[now] & 1) != (l[now] & 1)))
		{
			return 0;
		}
		vi[now] = 1;
		l[now] = r[now] = p[now];
	}
	return 1;
}
void DFS2(int now, int fa)
{
	if(now == 1)
	{
		p[now] = l[now];
	}
	else
	{
		if(p[fa] - 1 >= l[now])
		{
			p[now] = p[fa] - 1;
		}
		else
		{
			p[now] = p[fa] + 1;
		}
	}
	for(int i = head[now]; i; i = edge[i].next)
	{
		if(edge[i].to != fa)
		{
			DFS2(edge[i].to, now);
		}
	}
}
int main()
{
	scanf("%d", &n);
	for(int x, y, i = 1; i < n; i++)
	{
		scanf("%d%d", &x, &y);
		Addedge(x, y);
		Addedge(y, x);
	}
	scanf("%d", &k);
	for(int v, i = 1; i <= k; i++)
	{
		scanf("%d", &v);
		scanf("%d", &p[v]);
		vp[v] = 1;
	}
	if(!DFS1(1, 0))
	{
		printf("No\n");
		return 0;
	}
	DFS2(1, 0);
	printf("Yes\n");
	for(int i = 1; i <= n; i++)
	{
		printf("%d\n", p[i]);
	}return 0;
}


Measured memory_bytes: 8960
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long ll;

int n,k;
ll T[MAX];
int check(ll p)
{
	int i = 0;
	for (int j = 0; j < k; ++j)
	{
		ll s = 0;
		while(s+T[i] <= p)
		{
			s+=T[i];
			i++;
			if(i==n) return i;
		}
	}
	return i;
}
int slove()
{
	ll left = 0;
	ll right = 100000 * 10000;
	while(left+1 < right)
	{
		ll mid = left+(right-left)/2;
		int v = check(mid);
		if(v >= n) right = mid;
		else left = mid;
	}
	return right;
}

int main(int argc, char const *argv[])
{
	cin>>n>>k;
	for (int i = 0; i < n; ++i)
	{
		cin>>T[i];
	}
	ll ans = slove();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std; 

string list = "yuiophjklnm";

int main()
{
	string in;
	int l, count;
	int p; //0,1,2

 while(cin >> in){
	if(in=="#"){return 0;}
	count=0; p=0;
	l = in.length();
	for(int i=0; i<l; i++){
		if( list.find( in.substr(i,1) ) != string::npos){
			if(p==1){count++;}
			p=2;
		}
		else{
			if(p==2){count++;}
			p=1;
		}
	}
	cout << count << endl;
 }
}

Measured memory_bytes: 1192
#include<iostream>

using namespace std;

int MAX = 100;

void trace(int A[], int n)
{
    for (int i = 0; i < n; i++)
    {
        if (i > 0)
            cout << ' ';
        cout << A[i];
    }
    cout << endl;
}


void insertion_sort(int A[], int n)
{
    for(int i = 1; i < n; i++)
    {
        int key = A[i], j = i - 1;
        while (j >= 0 && key < A[j])
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = key;
        trace(A, n);
    }
}

int main()
{
    int A[MAX], n;
    
    cin >> n;
    
    for (int i = 0; i < n; i++)
        cin >> A[i];

    trace(A, n);
    
    insertion_sort(A, n);
    
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>

using namespace std;

int main()
{
    int mAi = 1;
    int mBi;
    int N,A,B;

    cin >> N;

    for(int i=0; i<N; ++i) {
        cin >> A >> B;
        if(mAi<=A) {
            mAi=A;
            mBi=B;
        }
    }
    cout << mAi+mBi << endl;

    return 0;
}


Measured memory_bytes: 256
def f():
    t0, t1 = [int(s) for s in input().split()]
    a = [int(s) for s in input().split()]
    b = [int(s) for s in input().split()]
    sa = t0*a[0] + t1*a[1]
    sb = t0*b[0] + t1*b[1]
    if sa == sb:
        return 'infinity'
    if sa > sb:
        a, b = b,a
        sa, sb = sb, sa
    # sa < sb
    if b[0] > a[0]:
        return 0

    delta = sb - sa

    ans = 1
    d0 = (a[0]-b[0])*t0
    if d0%delta == 0:
        ans += 1
    count = (d0-1)//delta
    ans += 2 * count
    return ans


print(f())

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi h(n+k+5);
    rep(i, n) cin >> h[i];
    vi dp(n+k+5, INF);
    dp[0] = 0;
    rep(i, n) rep1(j, k) {
        dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 4032
n,m=[int(i) for i in input().split()]
es=set()
for _ in range(m):
    u,v=map(int,input().split())
    u,v=u-1,v-1
    es|={(u,v),(v,u)}


p=[[0]]
x=0
while p:  
  p1=p.pop()
  if len(p1)==n:
    x+=1
  else:
    for l0,l1 in es:
      if l0==p1[len(p1)-1] and l1 not in p1:
          p.append(p1+[l1])

print(x)

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

int main(){
    while(1){
        int a = 0;
        string x;
        cin >> x;
        if(x == "0") break;
        for(int i = 0 ; i < x.size() ; i++){
            a += x[i] - '0';
        }
        cout << a << endl;
    }
    return 0;
}



Measured memory_bytes: 3176
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int N;
	double sum = 0;
	cin >> N;
	vector<double> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		sum += (1.0 / a[i]);
	}
	cout << (1.0 / sum) << endl;
	return 0;
}

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

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int a, b, x;
        {int[] c = in.ii(); a = c[0]; b = c[1]; x = c[2];}
        if(a*a*b==x){
            System.out.println(0);
            return;
        }
        double y = 2.0*x/a/a-b;
        double t = y >= 0 ? Math.atan((double)a*a*a/(a*a*b-x)/2):
                            Math.atan(2.0*x/a/b/b);
        out.println(90-t*180/Math.PI);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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


int main() {
    ll A, B, C, D;

    cin >> A >> B >> C >> D;

    string ans = "Yes";

    while(1) {
        C = C-B;

        if(C<=0) {
            ans = "Yes";
            break;
        }

        A = A-D;

        if(A<=0) {
            ans = "No";
            break;
        }
    }


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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n, l[205];

bool comp(int a, int b){
	return a >= b;
}

int main(){
cin >> n;
for(int i = 1; i <= n + n; i++) {
	cin >> l[i];
}
sort(l + 1, l + n + n + 1);
int res = 0;
for(int i = 1; i <= n + n; i += 2) {
	res += l[i];
}
cout << res;
return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
H = list(map(int,input().split()))
ans = [1 for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] > H[b-1]:
        ans[b] = 0
    elif H[a-1] == H[b-1]:
        ans[b] = 0
        ans[a] = 0
    else:
        ans[a] = 0

print(sum(ans)-1)

Measured memory_bytes: 20000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
using namespace std;

int main () {
	int n;
	cin >> n;
	int ar[n];
	int mx = -1;
	for(int i = 0; i < n; i++) {
		int cur;
		cin >> cur;
		ar[i] = cur;
		mx = max(cur, mx);
	}
	int cnt[mx + 1];
	for(int i = 0; i < mx + 1; i++) {
		cnt[i] = 0;
	}
	for(int i = 0; i < n; i++) cnt[ar[i]] += 1;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		int cur = ar[i];
		if(cnt[cur] > 1) continue;
		bool flag = true;
		for(int j = 2; j <= (int)(ceil(sqrt(cur))); j++) {
			if(cur % j == 0) {
				int a = j;
				int b = cur / j;
				if(a == cur) continue;
				if(b == cur) continue;
				if((cnt[a] > 0) || (cnt[b] > 0)) {
					flag = false;
					break;
				}
			}
		}
		if(flag == true) ans += 1;
	}
	if(cnt[1] > 1) {
		cout << "0" << "\n";
	}else if(cnt[1] == 1) {
		cout << "1" << "\n";
	}else {
		cout << ans << "\n";
	}
	return 0;
}  
  

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

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int N;
    vector<int> p,use(301010);
    for(int i=2;i<301010;i++)
        if((i%7==1||i%7==6)&&!use[i]){
            p.push_back(i);
            for(int j=i<<1;j<301010;j+=i)
                use[j]=1;
        }
    while((cin>>N,N-1)){
        cout<<N<<":";
        for(int e:p)
            if(N%e==0){
                cout<<" "<<e;
            }
        cout<<endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 4344