akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main ( )
{
int x,y;
    scanf("%d %d",&x,&y);
if(x>=-1000 && y<=1000 && y>=-1000 && y<=1000)
    {
    if(x<y)
    {
    printf("a < b\n");
    }
    if(x>y)
    {
    printf("a > b\n");
    }
    if(x==y)
    {
    printf("a == b\n");
    }
    }
return 0;
}









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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(false);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

string s0, s1;
int main() { BUFF
  cin >> s0;
  for(auto it : s0) {
    if(it == '0') s1.pb('0');
    else if (it == '1') s1.pb('1');
    else if (!s1.empty()) s1.pop_back();
  }
  cout << s1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}

/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/


signed main(){
	ll n;
	cin >> n;
	ll a[n] = {};
	
	
	vector<ll> vec_ans;
	
	bool is_used[n] = {false};
	
	rep(i,0,n) cin >> a[i];
	
	repr(i,1,n+1){
		ll temp = 1;
		ll cnt = 0;
		while(i*temp <= n){
			if(is_used[i*temp-1]){
				cnt++;
			}
			
			temp++;
		}
		
		cnt %= 2;
		if(cnt != a[i-1]){
			vec_ans.push_back(i);
			is_used[i-1] = true;
		}
	}
	
	cout << vec_ans.size() << endl;
	
	rep(i,0,vec_ans.size()){
		if(i != vec_ans[(ll)vec_ans.size()-1])cout << vec_ans[i] << " ";
		else cout << vec_ans[i] << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3828
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)

	var cnt int
	for i := 0; i < len(s); i++ {
		n, _ := strconv.Atoi(string(s[i]))
		if n == i%2 {
			cnt++
		}
	}

	fmt.Println(min(cnt, len(s)-cnt))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 2556
#include "iostream"
#include "math.h"
using namespace std;

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (a >= b&&a >= c)cout << (a*pow(2, k) + b + c) << endl;
	else if (b > a&&b >= c)cout << (a + b*pow(2, k) + c) << endl;
	else cout << (a + b + c*pow(2, k)) << endl;
	return 0;
}



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

#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--)



int main(){

    deque<char> sq;
    string s;
    int q;
    cin >> s >> q;
    rep(i,s.size()) sq.push_back(s[i]);

    int total_t = 0;
    rep(i,q) {
        int t;
        cin >> t;
        // 正位置かどうか
        if (t==1) {
            total_t += 1;
            total_t %= 2;
            continue;
        }

        int f;
        cin >> f;
        f %= 2; // f=0:末尾 f=1:先頭
        char c;
        cin >> c;
        if (total_t == 0) {
            if (f==0){
                sq.push_back(c);
            } else {
                sq.push_front(c);
            }
        }
        if (total_t == 1) {
            if (f==0){
                sq.push_front(c);
            } else {
                sq.push_back(c);
            }
        }
    }
    if (total_t == 1) {
        rep(i, sq.size()) {
            cout << sq.back();
            sq.pop_back();
        }
    } else {
        rep(i, sq.size()) {
            cout << sq.front();
            sq.pop_front();
        }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 896
# coding: utf-8
S = list(input())
n = len(S) - 1
ans = 0
for i in range(2**n):
    tmp = S[:]
    for j in range(n):
        if (i >> j) & 1 == 1:
            tmp[j] += "+"
    ans += eval("".join(tmp))
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int main() {
    char s[8];
    scanf(" %s", s + 1);
    if(s[3] == s[4] && s[5] == s[6]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void count(int H, int W, int row, int col, char map[6][6], int* cnt);

int main() {
  int H,W,K;
  char map[6][6];
  char buf;
  int x,y;
  int cnt;
  int row,col;
  int result;
  scanf("%d %d %d\n", &H, &W, &K);
  for ( y = 0; y < H; y++ ) {
    for ( x = 0; x < W; x++ ) {
      scanf("%c", &map[x][y]);
    }
    scanf("%c", &buf);
  }
  result = 0;
  for ( row = 0; row <= (1<<W)-1; row++ ) {
    for ( col = 0; col <= (1<<H)-1; col++ ) {
      count(H,W,row,col,map,&cnt);
      if ( cnt == K ) {
//         printf("%x, %x\n", col, row);
        result ++;
      }
    }
  }
  printf("%d\n", result);
  return 0;
}

void count(int H, int W, int row, int col, char map[6][6], int* cnt) {
  int x,y;
  *cnt = 0;
  for ( y = 0; y < H; y++ ) {
    if ( ((1<<y)&col) != 0 ) {
      continue;
    }
    for ( x = 0; x < W; x++) {
      if ( ((1<<x)&row) != 0 ) {
        continue;
      }
      // printf("check map[%d][%d]\n", x, y);
      if ( map[x][y] == '#' ) {
        (*cnt)++;
      }
    }
  }
}




Measured memory_bytes: 2156
import java.util.Scanner;

class Main {
    
    int a,b;
    
    public void suzuki(){
        
        Scanner sc = new Scanner(System.in);
        
        a = sc.nextInt();
        b = sc.nextInt();
        
        if(a < b){
            System.out.println("a < b");
        }else if(a > b){
            System.out.println("a > b");
        }else if(a == b){
            System.out.println("a == b");
        }
    }
    public static void main(String[] args){
        
        new Main().suzuki();
    }
}

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

int main(){
  int X;
  vector<int> a(5);
  for(int i=0; i<5; i++){
    cin>>a.at(i);
    if(a.at(i)==0){
      X=i+1;
    }
  }
  cout<<X<<endl;
}
  

Measured memory_bytes: 3624
read N T
min=1001
for ((i=0;i<$N;++i))
do
    read c t
    if ((T < t))
    then
        continue
    fi
    if ((min > c))
    then
        min=$c
    fi
done
if ((min == 1001))
then
    echo 'TLE'
else
    echo $min
fi


Measured memory_bytes: 504
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    int n=s.length()+1;
    vi a(n);
    rep(i,n-1){
        if(s[i]=='<'){
            a[i+1]=a[i]+1;
        }
    }
    rev(i,n-1){
        if(s[i]=='>'){
            a[i]=max(a[i],a[i+1]+1);
        }
    }
    cout<<accumulate(all(a),0ll)<<endl;
}

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

int main() {
  string strlong, strshort, ans = "No";
  cin >> strlong;
  cin >> strshort;

  int i = 0, j = 0;
  while (1) {
    if ( strlong.size() <= i) break;

    j = 0;
    while (1) {
      if ( strlong[ (i + j) % strlong.size()] != strshort[j]) break;
      if ( j == strshort.size() - 1) { ans = "Yes"; break; }
      j++;
    }

    if (ans == "Yes") break;

    i++;
  }

  cout << ans << endl;

  return 0;
}


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

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

using namespace __gnu_pbds;
using namespace std;

#define int long long
#define pb push_back
#define pii pair<int,int>
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define nl '\n'
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
double dp[3000][3000];
double arr[3000];
double solve(int i , int cnt , int n)
{
    if(i>n)
    {
        if(cnt>n/2)return 1;
        else return 0;
    }
    if(dp[i][cnt] != -1.0)return dp[i][cnt];
    double ans = (1-arr[i])*solve(i+1 , cnt , n)+arr[i]*solve(i+1 , cnt+1 , n);
    return dp[i][cnt] = ans;
}
int32_t main()
{
    int n;
    cin>>n;

    for(int i=1; i<=n; i++)cin>>arr[i];
    for(int i=0; i<3000; i++)
    {
        for(int j=0; j<3000; j++)
            dp[i][j]=-1.0;
    }
    cout<<setprecision(10)<<solve(1 , 0 , n)<<endl;
}

Measured memory_bytes: 70912
N,M = map(int,input().split())
A = list(map(int,input().split()))
sum_A = [0]*(N+1)
for i in range(N):
    sum_A[i+1] = sum_A[i] + A[i]

mod_M = {} # 累積和をMで割った余りがkey、そのような数の頻度がv
for sA in sum_A:
    r = sA%M
    if not r in mod_M:
        mod_M[r] = 1
    else:
        mod_M[r] += 1
ans = 0
for v in mod_M.values():
    ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 62576
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
	string a,b,c;
	cin>>a>>b;
	c=a+b;
	int x;
	x=atoi(c.c_str());
	if(int(sqrt(x))==sqrt(x)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
} 

Measured memory_bytes: 256
n,m = map(int,input().split())
foods = {i:0 for i in range(1, m+1)}
for i in range(n):
  tmp_list = list(map(int,input().split()))
  for j in range(len(tmp_list)):
    if j>0:
      a = tmp_list.pop(1)
      foods[a] += 1
  del tmp_list
ans = [v for v in foods.values() if v==n] 
print(len(ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

vector<int> cr;
vector<vector<int>> can;

void gen(int n, int m, int cur = 0, int lst = 1) {
  if (cur == n) {
    can.pb(cr);
    return;
  }
  for (int i = lst; i <= m; i++) {
    cr.pb(i);
    gen(n, m, cur + 1, i);
    cr.pop_back();
  }
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  gen(n, m);
  vector<int> a(q), b(q), c(q), d(q);
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  int ans = 0;
  for (auto it : can) {
    int sum = 0;
    for (int i = 0; i < q; i++) {
      if (it[b[i]] - it[a[i]] == c[i]) {
        sum += d[i];
      }
    }
    ans = max(ans, sum);
  }
  cout << ans << '\n';
}
    

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数
uintmax_t combination(unsigned int n, unsigned int r){    //組み合わせ
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score = 0;
    rep(i,n-1){
        if(s[i]==s[i+1])
            score++;
    }
    int ans = min(score + 2 * k, n - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
	string str, strR;
	cin >> str;
	strR = str;
	int strCnt = str.size();
	int halfSize = strCnt / 2;
	string str1, str2;
	str1 = str.substr(0, halfSize);
	reverse(strR.begin(), strR.end());
	if (strCnt % 2) {
		halfSize++;
	}
	str2 = strR.substr(0, halfSize);

	int ret = 0;
	for (int i = 0; i < str1.size(); ++i) {
		if (str1[i] != str2[i]) {
			ret++;
		}
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
val= list(input())

if val[:int(len(val)/2)] == val[int(len(val)/2):]:
    val.pop()

for i in range(0, len(val)):
    
    if val[:int(len(val)/2)] == val[int(len(val)/2):]:
        break
    else:
        val.pop()
print(int(len(val)))

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

//main関数
int main() {
    //入力
    long N,M;
    cin>>N>>M;
    vector<long> L(M),R(M);
    for(int i=0;i<M;i++){
        cin>>L.at(i)>>R.at(i);
    }
    //計算
    long l=0,r=N;
    for(int i=0;i<M;i++){
        l=max(l,L.at(i));
        r=min(r,R.at(i));
    }
    
    //出力
    cout<<max((long) 0,r-l+1)<<endl;
}

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

int main(){
  int n;
  long long w;
  cin>>n>>w;
  long long wei[n], val[n];
  for(int i=0; i<n; ++i)cin>>wei[i]>>val[i];

  long long dp[n+10][w+10]={0};

  for(int j=0; j<w+1; ++j){
    if(wei[0]<=j)dp[0][j]=val[0];
  }

  for(int i=1; i<n; ++i){
    for(int j=0; j<w+1; j++){
      if(j-wei[i]>=0)dp[i][j]=max(dp[i-1][j], dp[i-1][j-wei[i]]+val[i]);
      else dp[i][j]=dp[i-1][j];
    }
  }

  cout<<dp[n-1][w]<<endl;
  
}


Measured memory_bytes: 86144
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long t=0,i=0,j=0;
  double sum=0,A,B,C,D;
  string ans;

  cin >> A >> B >> C>> D;
  
  if (B>=C)
  {
    ans="Yes";
  }else if(ceil(C/B)<=ceil(A/D))
  {
    ans="Yes";
  }else
  {
    ans="No";
  }
  
  
  cout << ans << endl;
  
  
  
  return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  map<int, int> mp;
  for(int i=0; i<N; ++i){
    int x; cin >> x;
    ++mp[x];
    if(x-1 >= 0)
      ++mp[x-1];
    ++mp[x+1];
  }
  auto it = mp.begin();
  int res = 0;
  while(it != mp.end()){
    res = max(it->second, res);
    ++it;
  }
  cout << res << "\n";
  return 0;  
}



Measured memory_bytes: 4736
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

const int MAX_N = 1e5;
vector<int> G[MAX_N];

void bfs(int start_node_id, vector<int>& color, int col) {
  int u;
  queue<int> q;
  color[start_node_id] = col;
  q.push(start_node_id);
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (color[v] == 0) {
        q.push(v);
        color[v] = col;
      }
    }
    color[u] = col;
  }
}

int main() {
  int n, m, q, s, t;
  cin >> n >> m;
  // vector<int> emp = {};
  // vector<vector<int>> G(n, emp);
  for (int i = 0; i < m; i++) {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  vector<int> color(n);
  int col = 1;
  for (int i = 0; i < n; i++) {
    if (color[i] == 0) {
      bfs(i, color, col);
      col++;
    }
  }

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> s >> t;
    if (color[s] == color[t]) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 8628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
int32_t main()
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> index;
    int c = 0;
    index.push_back(c);
    for (int i = 0; i < s.size() - 1; i++)
    {
        if (s[i] == 'A')
        {
            if (s[i + 1] == 'C')
            {
                index.push_back(++c);
            }
            else
            {
                index.push_back(c);
            }
        }
        else
        {
            index.push_back(c);
        }
    }
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout<< index[--r]-index[--l]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4432
#include<stdio.h>

int main(){
    int a,b,add,sub,mul;
    scanf("%d",&a);
    scanf("%d",&b);

    add=a+b;
    sub=a-b;
    mul=a*b;


    if(add>sub && add>mul) printf("%d",add);

    else if(mul>add && mul>sub) printf("%d",mul);

    else printf("%d",sub);


   
return 0;
}


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

using Graph=vector<vector<int>>;

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

    int n,m;
    cin>>n>>m;

    Graph node(n+1); //using graphを宣言しておくことで、nodeの長さを入力後に決められる。
    rep(i,m){ 
        int a,b;
        cin>>a>>b;
        node[a].push_back(b);
        node[b].push_back(a);
    }
    
    int inf=pow(10,9);
    vector<int> oya(n+1,inf);
    oya[1]=1;
    queue<int> que;
    que.push(1);

    while(!que.empty()){
        int now=que.front();
        que.pop();
        for(int next:node[now]){
            if(oya[next]!=inf) continue;
            oya[next]=now;
            que.push(next);
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++){
        cout<<oya[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 10164
N,T = map(int,input().split())
t   = list(map(int,input().split()))
time = 0 # お湯が出てる累計時間、一回目
for i in range(N-1):
	# print('ボタンを押す時間:',t[i])
	if abs(t[i+1]-t[i]) > T:
		time += T
	else:
		time += abs(t[i+1]-t[i])
	# print('累計:',time)

print(time+T)

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	int w , a , b;
	cin >> w >> a >> b;
	int ans = 0;
	if(b > a)ans = max(0 , b - a - w);
	else ans = max(0 , a - b - w);

	die(ans);

	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18
const long MOD = 998244353;

class Combination{
private:
    long long m_mod;
    long long *fac;
    long long *finv;
    long long max_n;
    long long power(long long a, long long b);
    long long ext_gcd(long long a, long long b, long long &x, long long &y);
public:
    Combination(long n, long mod);//max_n, mod
    ~Combination();
    long long comb(long n, long r);
    void fac_vis();
    void finv_vis();
};
long long Combination::power(long long a, long long b){
    if(b == 0){
        return 1ll;
    }else if(b % 2){
        return power(a, b-1) * a % m_mod;
    }else{
        return power(a, b/2) * power(a, b/2) % m_mod;
    }
}
long long ext_gcd(long long a, long long b, long long &x, long long &y){//ax + by = gcd(a, b), returns gcd. |x| + |y| is minimum and x <= y.
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    long d = ext_gcd(b, a % b, y, x);
    y -= a/b * x;
    return d;
}
long long mod(long long a, long long m){
    return (a % m + m) % m;
}
long long modinv(long long a, long long m){
    long long x, y;
    ext_gcd(a, m, x, y);
    return mod(x, m);
}
Combination::Combination(long n, long mod){
    max_n = n;
    m_mod = mod;
    fac = new long long[n+1];
    finv = new long long[n+1];
    fac[0] = finv[0] = 1;
    if(max_n > 0){
        fac[1] = finv[1] = 1;
    }
    for(long long i = 2; i <= max_n; i++){
        fac[i] = fac[i-1] * i % m_mod;
    }
    finv[n] = modinv(fac[n], m_mod);
    for(long long i = max_n-1; i >= 0; i--){
        finv[i] = finv[i+1] * (i+1) % m_mod;
    }
}
Combination::~Combination(){
    delete[] fac;
    delete[] finv;
}
long long Combination::comb(long n, long r){
    if(n < r || n < 0 || r < 0){
        return 0;
    }
    return fac[n] * finv[r] % m_mod * finv[n-r] % m_mod;
}
void Combination::fac_vis(){
    for(int i = 0; i <= max_n; i++){
        printf("%lld ", fac[i]);
    }
    printf("\n");
}
void Combination::finv_vis(){
    for(int i = 0; i <= max_n; i++){
        printf("%lld ", finv[i]);
    }
    printf("\n");
}


long long power(long a, long b, long MOD){
	if(b == 0){
		return 1l;
	}else if(b % 2 == 1){
		return a * power(a, b-1, MOD) % MOD;
	}else{
		long r = power(a, b/2, MOD);
		return r * r % MOD;
	}
}

int main(){
    long n, m, k;
    scanf("%ld%ld%ld", &n, &m, &k);
    long ans = 0;
    Combination c(n, MOD);
    for(long i = 0; i <= k; i++){
        ans += c.comb(n-1,i) * m % MOD * power(m-1, n-i-1, MOD) % MOD;
        ans %= MOD;
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 6428
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	printf("%d\n",(n-1)*(m-1));
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<iterator>
using namespace std;

int dfs(int vertex,vector <vector <int>> &adj, vector <int> &visited)
{
	int gang = 0;
	for (int i = 0; i < adj[vertex].size(); i++)
	{
		int child = adj[vertex][i];
		if (visited[child] == 0)
		{
			visited[child] = 1;
			gang+=dfs(child, adj, visited);
		}
	}
	return gang + 1;
}

int main() {

	int n, m;
	cin >> n >> m;
	vector <int> visited(n, 0);
	vector < vector <int> > adj(n);
	int first, second;
	for (int i = 0; i < m; i++)
	{
		cin >> first >> second;
		first--;
		second--;
		adj[first].push_back(second);
		adj[second].push_back(first);
	}
	
	int max_gang = 0;
	for (int i = 0; i < n; i++)
	{
		if (visited[i] == 0)
		{
			visited[i] = 1;
			int gang = dfs(i, adj, visited);
			if (gang > max_gang) max_gang = gang;
		}
	}
	cout << max_gang;

	return 0;
}




Measured memory_bytes: 24292
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 3000010;
const int INF = 2147483600;

int K,N,M; 
int S[MAXN+1],T[MAXN+1];
char cS[MAXN+1],cT[MAXN+1];
int sta[MAXN+1],top,P[MAXN+1],tot;
inline int Add(int *A,int p,int v){
	if(v==-1) { A[p]+=v; return -1; }
	else{ A[p]+=v; while(A[p]>=2) A[p]-=2,++p,A[p]++; return p; }
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(),M=read(),K=read();
	scanf("%s",cS+1); scanf("%s",cT+1);
	reverse(cS+1,cS+N+1);
	reverse(cT+1,cT+M+1);
	for(int i=1;i<=N;i++) S[i]=cS[i]-'0';
	for(int i=1;i<=M;i++) T[i]=cT[i]-'0';
	for(int i=N+1;i<=max(N,M)+K;i++) S[i]=0;
	for(int i=M+1;i<=max(N,M)+K;i++) T[i]=0;
	//for(int i=max(N,M)+K;i>=1;i--) cout<<S[i]; cout<<endl;
	//for(int i=max(N,M)+K;i>=1;i--) cout<<T[i]; cout<<endl;
	for(int i=max(N,M)+K;i>=1;i--){
		if(!S[i]&&!T[i]) continue;
		if(S[i]^T[i]){ sta[++top]=i; continue; }
		int lst=i,nw=K; tot=0;
		/*cout<<i<<":\n";
		for(int j=1;j<=top;j++)
			cout<<sta[j]<<" ";
		cout<<endl;
	for(int j=max(N,M)+K;j>=i;j--) cout<<S[j]; cout<<endl;
	for(int j=max(N,M)+K;j>=i;j--) cout<<T[j]; cout<<endl;*/
		while(top&&lst!=-1&&sta[top]-lst<=nw){
			Add(S,lst,-1); Add(T,lst,-1);
			nw-=sta[top]-lst; int mxt=0;
			mxt=max(Add(S,sta[top],1),Add(T,sta[top],1));
			//cout<<"jump:"<<lst<<" "<<sta[top]<<" "<<mxt<<endl;
			for(int j=sta[top];j<=mxt;j++) P[++tot]=j;
			if(S[mxt]&&T[mxt]) lst=mxt;
			else lst=-1;
			while(top&&sta[top]<=mxt) --top;
		} if(lst!=-1){ Add(S,lst,-1); Add(T,lst,-1); Add(S,lst+nw,1); Add(T,lst+nw,1); }
		for(int j=tot;j>=1;j--){
			if(!top&&lst!=-1&&(lst+nw<=P[j])) continue;
			if((top&&P[j]==sta[top])||(j<tot&&P[j]==P[j+1])) continue;
			if(S[P[j]]^T[P[j]]) sta[++top]=P[j];
		}
	} 
	int fs=max(N,M)+K,ft=fs;
	while(!S[fs]) --fs;
	for(int i=fs;i>=1;i--) printf("%d",S[i]); puts("");
	while(!T[ft]) --ft;
	for(int i=ft;i>=1;i--) printf("%d",T[i]); puts("");
	return 0;
}




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

int main()
{

    ll n,m,a[100000+20]= {0},i,j,s=0;
    cin>>n>>m;
    for(i=0; i<m; i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    s=n-s;
    if(s<0)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 4404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadInts();
            var list = new List<int>();
            list.Add(s[0] + s[1]);
            list.Add(s[0] * s[1]);
            list.Add(s[0] - s[1]);
            WriteLine(list.Max());
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
from math import sqrt
import sys
sdin = sys.stdin.readline

q = int(sdin())
ab = []
for i in range(q):
    ab.append(tuple(map(int, sdin().split())))

for a, b in ab:
    if b-a >= 0 and b-a < 2:
        print(2*a - 2)
        
    else:
        if not (sqrt(a*b) - int(sqrt(a*b))):
            c = int(sqrt(a*b) - 1)
        else:
            c  = int(sqrt(a*b))
        
        if c*(c+1) >= a*b:
            print(2*c - 2)
        else:
            print(2*c - 1)
            

Measured memory_bytes: 3188
// Java program For handling Input/Output 
import java.io.*; 
import java.util.*;
import java.math.*;
//import java.awt.*;

public class Main 
{ 
    FastReader sc;
    //actual logic
    void solve() throws IOException{
        int n = sc.ni();
        int m = sc.ni();

        if(n < m)
        {
            for(int i = 0;i < m;i++)
                System.out.print(n);
        }
        else
        {
            for(int i = 0;i < n;i++)
                System.out.print(m);
        }

    }

    //constructor
    Main()
    {
        try{  
            sc = new FastReader();
        }catch(Exception e){
            System.out.println(e);
        }
    }


    //main metohd
    public static void main(String[] args) throws IOException
    { 
     new Main().solve();
 }
    //Utility methods

 static class FastReader{
    BufferedReader br;
    StringTokenizer st;
    FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
        try{
            st = new StringTokenizer(br.readLine());
        }catch(Exception e){
            System.out.println(e);
        }
    }

    FastReader(String s){
        try{
            br = new BufferedReader(new FileReader(s));
            st = new StringTokenizer(br.readLine());
        }catch(Exception e){
            System.out.println(e);
        }
    }

    String ns(){
        if(!st.hasMoreTokens())
        {
            try{
                st = new StringTokenizer(br.readLine());
            }catch(Exception e){
                System.out.println(e);
            }    
        }
        return st.nextToken();

    }

    int ni(){
        return Integer.parseInt(ns());
    }

    long nl(){
        return Long.parseLong(ns());
    }

    double nd(){
        return Double.parseDouble(ns());
    }
}
}


Measured memory_bytes: 21076
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      int h = Integer.parseInt(st.nextToken());
      int w = Integer.parseInt(st.nextToken());
      int k = Integer.parseInt(st.nextToken());
      st = new StringTokenizer(br.readLine());
      int a = Integer.parseInt(st.nextToken())-1;
      int b = Integer.parseInt(st.nextToken())-1;
      int c = Integer.parseInt(st.nextToken())-1;
      int d = Integer.parseInt(st.nextToken())-1;
      String[] map = new String[h];
      int[][] len = new int[h][w];
      for(int i = 0; i < h; i++) {
    	  map[i] = br.readLine();
      	  for(int j = 0; j < w; j++)
      		  len[i][j] = -1;
      }
      Queue<Integer> curr = new LinkedList<Integer>();
      curr.add(c*w+d);
      len[c][d] = 0;
      while(curr.size() > 0) {
    	  int temp = curr.remove();
    	  int x = temp/w;
    	  int y = temp%w;
    	  int val = len[x][y];
    	  x--;
    	  while(x >= Math.max(temp/w - k,0) && map[x].charAt(y) == '.') {
    		  if(len[x][y] == -1) {
    			  len[x][y] = val + 1;
    			  curr.add(x*w+y);
    		  }
    		  else if(len[x][y] <= val)
    			  break;
    		  x--;
    	  }
    	  x = temp/w + 1;
    	  while(x < Math.min(temp/w+k+1,h) && map[x].charAt(y) == '.') {
    		  if(len[x][y] == -1) {
    			  len[x][y] = val + 1;
    			  curr.add(x*w+y);
    		  }
    		  else if(len[x][y] <= val)
    			  break;
    		  x++;
    	  }
    	  x = temp/w;
    	  y--;
    	  while(y >= Math.max(temp%w - k,0) && map[x].charAt(y) == '.') {
    		  if(len[x][y] == -1) {
    			  len[x][y] = val + 1;
    			  curr.add(x*w+y);
    		  }
    		  else if(len[x][y] <= val)
    			  break;
    		  y--;
    	  }
    	  y = temp%w + 1;
    	  while(y < Math.min(temp%w+k+1,w) && map[x].charAt(y) == '.') {
    		  if(len[x][y] == -1) {
    			  len[x][y] = val + 1;
    			  curr.add(x*w+y);
    		  }
    		  else if(len[x][y] <= val)
    			  break;
    		  y++;
    	  }
      }
      out.println(len[a][b]);
      out.close();
   }
}

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

int main(){
  int n,x,a[101],ans=0;
  cin>>n>>x;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<n-1;i++){
    if(a[i]>x){
      break;
    }
    x-=a[i];
    ans++;
  }
  cout<<(x==a[n-1]?ans+1:ans);
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b < c) cout << 2*b + a + 1 << endl;
    else cout << b + c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
map<ll,ll>mp;
map<ll,ll>mpp;
int main()
{
    ll n,k=0,i,j;
    double s=0,t;

    string str;
    cin>>str;

    for(i=0;i<str.size();i++){
        if(str[i]=='7'){
            k=1;
            break;
        }
    }
    if(k){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
using namespace std;
 
struct ice{
	int money;
	double v;
	double ms;
}a[4];
 
bool cmp(ice a, ice b)
{
	return a.ms<b.ms;
}
 
int main()
{
	int q, h, s, d;
	double n;
	cin >> q >> h >> s >> d >> n;
	a[0].v = 0.25, a[0].money = q, a[0].ms = q*1.0/0.25;
	a[1].v = 0.5, a[1].money = h, a[1].ms = h*1.0/0.5;
	a[2].v = 1, a[2].money = s, a[2].ms = s*1.0/1.0;
	a[3].v = 2, a[3].money = d, a[3].ms = d*1.0/2.0;
	sort(a, a+4, cmp);
	long long sum = 0;
	while(n>0)
	{
		for(int i=0; i<4; i++)
		{
			if(a[i].v>n||n-a[i].v<0)
				continue;
			int mid = n/a[i].v;
			while(mid--)
			{
				sum += a[i].money;
				n -= a[i].v;
			}
		}
	}
	cout << sum << 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 all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  string s;
  ll k;
  cin >> s;
  cin >> k;
  ll bound=MOD,num=1;
  rep(i,s.size()){
    if(s[i] - '0' > 1){
      num = s[i] - '0';
      bound = i;
      break; 
    }
  }
  cout << (k-1 < bound ? 1 : num) << endl;
}



Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll D, G;
    cin >> D >> G;

    vector<ll> P(D);
    vector<ll> C(D);

    FOR(i, 0, D){
        cin >> P[i];
        cin >> C[i];
    }

    ll min_solve_num = inf;
    FOR(i, 0, 1<<D){
        ll score = 0;
        ll solve_num = 0;
        FOR(j, 0, D){
            if(i>>j & 1){
                // それ j を完全に解く
                ll unit = 100 * (j+1);
                score += unit * P[j] + C[j];
                solve_num += P[j];
            }
        }


        if(score < G){
            ll rest = G - score;
            // 解いていないものから中途半端に解く
            // 一番高いやつ
            for(int j=D-1; j>=0; j--){
                if((i>>j & 1) == 0){
                    ll unit = 100 * (j+1);
                    ll num;
                    if(rest%unit==0){
                        num = rest / unit;
                    }else{
                        num = rest / unit + 1;
                    }

                    if(num >= P[j]){
                        solve_num = inf;
                    }else{
                        solve_num += num;
                    }
                    break;
                }
            }
        }
        min_solve_num = min(min_solve_num, solve_num);
    }

    p(min_solve_num);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <cstdio>
#include <deque>
#include <algorithm>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <stack>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	int sum = 0;
	int m = 0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		sum += x;
		m = max(m, x);
	}
	cout << sum - m / 2 << '\n';






}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define int long long
#define swap(x,y) (x^=y^=x^=y)

#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

using namespace std;
 
#define mod 1000000007
long long modexpo(long long x, long long p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

struct compare{
    bool operator() (const pair<int,int> a, const pair<int,int> b) const{
        return a.first < b.first;
    }
};

int32_t main(){
    IOS
    int n,k;
    cin >> n >> k;
    int ind = 0;
    int arr[n+1];
    arr[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
        if(arr[i] == 1){
            ind = i;
        }
    }       
    int x = ceil((double)(n-1)/(double)(k-1));
    cout << x << endl;
} 

Measured memory_bytes: 4492
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)
typedef long long ll;

using namespace std;


string sb( int n){
	string res = ((n>4)? " *=": "* =");
	if (n%5>3)  res += "**** ";
	else if (n%5>2)  res += "*** *";
	else if (n%5>1)  res += "** **";
	else if (n%5>0)  res += "* ***";
	else  res += " ****";
    return res;
}

int main(void){

int n;
bool pg=false;
string ss[5], sd[8];
	while(cin >> n){
		if(cin.eof()) break;
		int wk=100000;
		rep(i,5){
			int z = (n%wk )/(wk/10);
			ss[i] = sb(z);
			wk /= 10;
		}
		rep(j,8) sd[j] = "     ";
		rep(i,5) rep(j,8) sd[j][i] = ss[i][j];
		
		if(pg) cout << endl;
		//		rep(i,5)cout << ss[i] << endl;
		rep(i,8)cout << sd[i] << endl;
		pg=true;
	}
	return 0;
	
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n, f;
ll a1, a2, a3, a_xor, a_and;
int main(){
	scanf("%d%lld%lld", &n, &a1, &a2);
	n -= 2;
	rep(i,n){
		scanf("%lld", &a3);
		a_xor ^= a3;
	}
	a_and = a1 + a2 - a_xor;
	if(a_and & 1) f |= 1;
	else a_and >>= 1;
	if((a_and & a_xor) || a_and > a1) f |= 1;
	for(int i=50; i>=0; i--){
		if((a_xor >> i & 1) && a_and + (1ll << i) <= a1) a_and += 1ll << i;
	}
	if(a_and == 0) f |= 1;
	printf("%lld\n", f ? -1 : a1 - a_and);
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int x; cin >> x;
  for(int i = 0; i <= x/100; i++){
    int t = x-i*100;
    if(0 <= t && t <= 5*i){
      cout << 1 << endl;
      return 0;
    }
    if(t < 0)break;
  }
  cout << 0 << endl;

  system("pause");
}

Measured memory_bytes: 504
a,b = map(int,input().split(" "))
if a <= 0 <= b:
    print("Zero")
    exit()
if 0 < a:
    print("Positive")
    exit()
b = min(b,-1)
if (b-a+1)%2 == 0:
    print("Positive")
    exit()
else:
    print("Negative")
    exit()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, a, n) for (int i = a; i < (n); ++i)

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	
	int count = 0;
	bool reach[n] = {false};
	rep(i, 0, n)
	{
		if (reach[i] == true) continue;
		if (a[a[i]-1] == i+1) 
		{
			reach[i] = true;
			reach[a[i] - 1] = true;
			++count;
		}
	}
	cout << count << endl;
	
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		
		while(b <= a) {
			b = b*2;
			k--;
		}
		while(c <= b) {
			c = c*2;
			k--;
		}
		
		if(k<0) System.out.println("No");
		else System.out.println("Yes");
	}
}


Measured memory_bytes: 35568
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int bubble_sort(vector<int>& v, int length) {
    int count = 0;
    bool flag = true;

    while (flag) {
        flag = false;
        for (int j = length - 1; j > 0; --j) {
            if (v[j] < v[j - 1]) {
                swap(v[j], v[j - 1]);
                flag = true;
                ++count;
            }
        }
    }

    return count;
}

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

    vector<int> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];

    int count = bubble_sort(v, n);

    cout << v[0];
    for (int i = 1; i < n; ++i)
        cout << ' ' << v[i];
    cout << '\n';

    cout << count << '\n';
}



Measured memory_bytes: 3084
import sys

n, k = map(int, input().split())

if k > (n-1)*(n-2)//2:
    print(-1)
else:
    for i in range((n-1)*(n-2)//2 + 1):
        if k == (n-1)*(n-2)//2 - i:
            print(n - 1 + i)
            m = i
            break
    for i in range(2, n+1):
        print(1, i)
    for i in range(2, n):
        for j in range(i+1, n+1):
            if m == 0:
                sys.exit()
            print(i, j)
            m -= 1

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

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;

  //両方とも正
  ll ans1 = b * d;
  //xが負
  ll ans2 = a * d;
  //yが負
  ll ans3 = b * c;
  //両方とも負
  ll ans4 = a * c;

  //１番大きいものを採用
  ll ans5 = max(max(max(ans1,ans2),ans3),ans4);
  cout << ans5 << endl;
}


Measured memory_bytes: 3624
// AOJ 0384: Dudeney Number
// 2019.2.20 bal4u
 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int tbl[11] = { 0,0,10000,464,100,39,21,13,10,7,6 };

int sb(int a)
{
	int s = 0;
	while (a) {
		s += a % 10;
		a /= 10;
	}
	return s;
}

int main()
{
	int a, n, m;
	int x, y, lim, ans;

	scanf("%d%d%d", &a, &n, &m);
	lim = tbl[n] - a, ans = 0;
	for (y = 1; y <= lim; y++) {
		x = (int)pow(y + a, n);
		if (x > m) break;
		if (sb(x) == y) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 063 C / Link: http://abc063.contest.atcoder.jp/tasks/abc063_c  ----- */


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

	LL N; 
	cin >> N;
	vector<LL> a(N);
	VL noten;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		if (a[i] % 10)noten.push_back(a[i]);
	}
	SORT(noten);
	LL ans = accumulate(ALL(a),0LL);
	if (ans % 10 == 0) {
		if (SZ(noten))ans -= noten.front();
		else ans = 0;
	}

	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256