akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
    int N, X;
    cin >> N >> X;
    int L[N];
    for (int i = 0; i < N; i++) {
      cin >> L[i];
    }
    int ans = 1;
    int D = 0;
    for (int i = 0; i < N; i++){
      D += L[i];
      if(D <= X){
        ans++;
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
//xとyの要素を入れ替え
void swap(long long *x, long long *y)
{
	long long temp=*x;
	*x=*y;
	*y=temp;
}
//ユークリッドの互除法(mとnの最大公約数を求める)
long long GCD(long long m, long long n)
{
	long long temp;

	if(m<n) swap(&m, &n);

	while(n!=0){
		temp=m%n; m=n; n=temp;
	}
	return m;
}
int main(void)
{
	int n;

	cin>>n;

	vll a(n);

	rep(i, n) cin>>a[i];

	sort(all(a));

	ll l=a[0];
	repr(i, 1, n){
		l=GCD(l, a[i]);
	}
	cout<<l<<endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[60];
    rep(i, N) cin >> A[i];
    int cnt = 0;
    rep(i, N) {
        if (A[i] == i + 1) cnt++;
    }
    if (cnt >= N - 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
char a;
/******* define variable end *******/
int solve() {
	cin >> a;
	if(isupper(a)){
		cout << "A" << endl;
	}else{
		cout << "a" << endl;
	}
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int ans = 0;
    for (int i = 1; i <= 5; ++i) {
        int u;
        cin >> u;
        if (u == 0) {
            ans = i;
        }
    }
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;


int main(){
	ll r,D,x[12];
	cin>>r>>D>>x[0];
	rep(i,0,10){
		print(r*x[i]-D);
		x[i+1]=r*x[i]-D;;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> fourprime;
bool prime[10000005];
void Prime();
main(){
  int n;
  Prime();
  //cout<<fourprime.size()<<endl;
  while(1){
    cin>>n;
    if(!n)break;
    vector<int>::iterator ans;
    ans=upper_bound(fourprime.begin(),fourprime.end(),n);
    cout<<*(ans-1)<<endl;
  }
}
void Prime(){
  for(int i=2;i<=10000000;i++){
    prime[i]=false;
  }
  prime[0]=prime[1]=true;
  for(int i=2;i*i<=10000000;i++){
    if(!prime[i]){
      for(int j=i*2;j<=10000000;j+=i){
	prime[j]=true;
      }
    }
  }
  for(int i=13;i<=10000000;i+=2){
    if(!prime[i]&&!prime[i-2]&&!prime[i-6]&&!prime[i-8]){
      fourprime.push_back(i);
    }
  }
}
  

Measured memory_bytes: 10992
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 100010
typedef long long ll;
typedef pair<int, int> P;

struct edge {
    int to, cost;
};

vector<edge> G[MAXN];
int N;
int dist[MAXN];

void dijkstra(int s) {
    for (int i = 0; i <= N; i++) {
        dist[i] = INF;
    }
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(make_pair(0, s));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                que.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

int main(void) {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        int p;
        cin >> p;
        if (p == 0) {
            edge e; e.cost = 1;
            for (int j = 1; j <= 6; j++) {
                e.to = min(N, i+j);
                G[i].push_back(e);
            }
        } else {
            edge e; 
            e.cost = 0; e.to = i + p;
            G[i].push_back(e);
        }
    }
    dijkstra(1);
    cout << dist[N] << endl;
    return 0;
}

Measured memory_bytes: 8652
N = gets.to_i
A = gets.split.map(&:to_i)
ans = 0

0.upto(N-1) do |i|
	minj = i
	
	i.upto(N-1) do |j|
		if A[j] < A[minj]
			minj = j
		end
	end

	A[i], A[minj] = A[minj], A[i]
	ans += 1 if i != minj
end

puts A.join(" ")
puts ans


Measured memory_bytes: 6876
import sys
from io import StringIO
import unittest
from collections import Counter

def resolve():
    # s = input()
    n = int(input())
    # a, b = map(int, input().split())
    # l = [list(map(int, input().split())) for _ in range(n)]
    s = Counter([input() for _ in range(n)])

    ans = ['AC', 'WA', 'TLE', 'RE']

    for ac in ans:
        print(ac + ' x ' + str(s[ac]))




class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """6
AC
TLE
AC
AC
WA
TLE"""
        output = """AC x 3
WA x 1
TLE x 2
RE x 0"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
AC
AC
AC
AC
AC
AC
AC
AC
AC
AC"""
        output = """AC x 10
WA x 0
TLE x 0
RE x 0"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

void solve() {
	string s; cin >> s;

	int ans = 0;
	char pre = s[0];
	for(int i=1; i<s.size(); i++){
		if (pre == s[i]) {
			if (s[i] == '1') s[i] = '0';
			else s[i] = '1';
			ans++;
		}
		pre = s[i];
	}

	int ans2 = 0;
	pre = s[s.size()-1];
	for (int i = s.size() - 2; i >= 0; i--) {
		if (pre == s[i]) {
			if (s[i] == '1') s[i] = '0';
			else s[i] = '1';
			ans2++;
		}
		pre = s[i];
	}

	cout << max(ans, ans2) << endl;
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
int main()
{
	int n,k;
	vector<int> balls;
	int i,j;
	int t;
	scanf("%d %d",&n,&k);
	balls.resize(n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&t);
		balls[t-1]++;
	}
	t=0;
	sort(balls.begin(),balls.end());
	for(i=0;i<n-k;i++)
	{
		t+=balls[i];
	}
	printf("%d",t);
} 

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

#define dbg(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T>& a) {
  for (int i = 0; i < (int)a.size(); ++i)
    os << a[i] << " \n"[i == (int)a.size() - 1];
  return os;
}

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string t = s;
  sort(t.begin(), t.end());

  ll ans = 0;
  rep(i, 0, n) {
    if (s[i] != t[i]) ++ans;
  }
  cout << ans / 2;
  return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b, ans =0;
	cin >>a >>b;
	
	ans = a+b;
	ans = max(ans, 2*a-1);
	ans = max(ans, 2*b-1);
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ll n, k, *x;
    cin >> n >> k;
    x = new ll[n];
    for (ll i = 0; i < n; i++)
        cin >> x[i];

    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ans += 2*min(k-x[i], x[i]);
    }

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

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a, b, i;
  char op;
  for(i=0; i<1000; i++){
  scanf("%d %c %d", &a, &op, &b);
        if(op == '+') {
            printf("%d\n", a + b);
        }
        if(op == '-') {
            printf("%d\n", a - b);
        }
        if(op == '*') {
            printf("%d\n", a * b);
        }
        if(op == '/') {
            printf("%d\n", a / b);
        }
        if(op == '?') break;
        
  } 
  return 0;
}





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

int main()
{
	
	int count = 0;
	string s;
	cin >> s;
	int n = s.size();
	
	for(int i = 0;i<n;i++) {
	if(s[i] == '1') count++;
	}
	cout<<count<<endl;
	return 0;	
	
	
	
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var s = input[0];
  var ans ="No";
  if(s.match(/000/g)
  ||s.match(/111/g)
  ||s.match(/222/g)
  ||s.match(/333/g)
  ||s.match(/444/g)
  ||s.match(/555/g)
  ||s.match(/666/g)
  ||s.match(/777/g)
  ||s.match(/888/g)
  ||s.match(/999/g)){
    ans="Yes";
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), dp(n);
    rep (i, n) cin >> a[i];
    rep (i, n) dp[i] = -1;
    int len = 0;
    rep (i, n) {
        int ok = -1, ng = len;
        while (ng - ok > 1) {
            int med = (ng + ok) / 2;
            if (dp[med] >= a[i]) ok = med;
            else ng = med;
        }
        eprintf("%d ", ok);
        dp[ok + 1] = a[i];
        if (ok + 1 == len) len++;
    }
    eprintf("\n");
    rep (i, len) eprintf("%d ", dp[i]); eprintf("\n");
    cout << len << "\n";
    return 0;
}

Measured memory_bytes: 1024
def generate_square(rest, output=[10000]):                   
  for i in range(rest, 0, -1):                               
    if output[-1] >= i:                                      
        yield from generate_square(rest - i, output + [i])   
  if rest == 0:                                              
    yield output                                             
                                                             
                                                             
while 1:                                                     
  x = int(input().strip())                                   
  if x == 0:                                                 
    break                                                    
  generator = generate_square(x)                             
  for x in generator:                                        
    print(" ".join(map(str, x[1:])))                         
                                                             
                                                             

Measured memory_bytes: 7764
#include<stdio.h>

int main(void){

int i,j,w[100],k[100],tmpw,tmpk,sumw=0,sumk=0;

for(i=0;i<10;i++){
scanf("%d",&w[i]);
}
for(i=0;i<10;i++){
scanf("%d",&k[i]);
}

for(i=0;i<=10;i++){
for(j=9;j>i;j--){
if(w[j]>w[j-1]){
tmpw=w[j-1];
w[j-1]=w[j];
w[j]=tmpw;
}
}
}
for(i=0;i<=10;i++){
for(j=9;j>i;j--){
if(k[j]>k[j-1]){
tmpk=k[j-1];
k[j-1]=k[j];
k[j]=tmpk;
}
}
}

for(i=0;i<3;i++){
sumw += w[i];
}
for(i=0;i<3;i++){
sumk += k[i];
}

printf("%d %d\n",sumw,sumk);

return 0;
}



Measured memory_bytes: 2052
x=int(input())
if x>=400 and x<=599:
    print(8)
if x>=600 and x<=799:
    print(7)
if x>=800 and x<=999:
    print(6)
if x>=1000 and x<=1199:
    print(5)
if x>=1200 and x<=1399:
    print(4)
if x>=1400 and x<=1599:
    print(3)
if x>=1600 and x<=1799:
    print(2)
if x>=1800 and x<=1999:
    print(1)

    

Measured memory_bytes: 61620
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      k: usize,
      mut s: chars,
    }
    let mut t = s.clone();
    t.reverse();
    s.append(&mut t);

    let mut list = vec![];
    for i in 0..n+1 {
        let temp = &s[i..i+n];
        list.push(temp.clone());
    }
    list.sort();
    let s2 = list[0];
    let mut head_num = 1;
    let mut rest_index = 1;
    {
        let mut cur = 1;
        while !(cur == n || s2[0] != s2[cur]) {
            cur += 1;
            head_num += 1;
            rest_index += 1;
        }
    }

    let mut ops_cnt = 1;
    while ops_cnt < k {
        ops_cnt += 1;
        head_num *= 2;
        if head_num >= n {
            break;
        }
    }


    let mut ans = vec![];
    for _ in 0..min(head_num, n) {
        ans.push(s2[0]);
    }
    let rem = n - min(head_num, n);
    for _ in 0..rem {
        ans.push( s2[rest_index] );
        rest_index += 1;
    }
    let ans: String = ans.iter().cloned().collect();
    puts!("{}\n", ans);
}


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

int main()
{
  int n, k;
  std::string s;
  std::cin >> n;
  std::cin >> s;
  std::cin >> k;
  char target = s.at(k-1);
  for (auto& c : s) {
    if (c != target) {
      c = '*';
    }
  }
  std::cout << s << '\n';
  return 0;
}


Measured memory_bytes: 256
class Node{
  constructor(id, parent, children) {
    this.id = id;
    this.parent = parent;
    this.children = children;
  }

  get type() {
    if (this.parent === null) return 'root';
    if (this.children.length === 0) return 'leaf';
    return 'internal node';
  }

  get depth() {
    const getDepth = (node, i) => {
      return node.parent === null ? i : getDepth(node.parent, i + 1);
    };
    return getDepth(this, 0);
  }

  toString() {
    return `node ${this.id}: parent = ${this.parent !== null ? this.parent.id : -1}, depth = ${this.depth}, ${this.type}, [${this.children.map(n => n.id).join(', ')}]`;
  }
};

class Tree {
  static get Node() {
    return Node;
  }

  constructor(n) {
    this.nodes = [];
    let Node = Tree.Node;
    for (let i = 0; i < n; i++) this.nodes[i] = new Node(i, null, []);
  }

  add(id, childrenIds) {
    let node = this.find(id);
    childrenIds.forEach((cid) => {
      let c = this.find(cid);
      c.parent = node;
      c.id = cid;
      node.children.push(c);
    })
  }

  find(id) { return this.nodes[id]; }

  print() { console.log(this.nodes.sort((a, b) => a.id - b.id).map(n => n.toString()).join('\n')); }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  let tree = new Tree(n);
  let id, k, childrenIds;
  lines.map(l => l.split(' ')).forEach(function(line) {
    id = Number(line.shift());
    k = Number(line.shift());
    childrenIds = line.map(Number);
    tree.add(id, childrenIds);
  });
  tree.print();
})();



Measured memory_bytes: 157988
#include<iostream>
#include<string>
#include <cmath>
using namespace std;
int main() {
    char s[3]; int cnt=0;
    cin >> s;
    for(int i=0; i<3; ++i){
        if(s[i]=='1') cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans;
    ans = a*c;
    if(a*d > ans) ans = a*d;
    if(b*c > ans) ans = b*c;
    if(b*d > ans) ans = b*d;
    cout << ans << endl;
    }

Measured memory_bytes: 3564
package main

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

type Alds15a struct {
	a []int
	n int
	m []int
	q int
}

func main() {
	a := NewAlds15a()
	a.main()
}

func NewAlds15a() *Alds15a {
	a := &Alds15a{}
	return a
}

func (a *Alds15a) main() {
	scanner := bufio.NewScanner(os.Stdin)
	a.handle(scanner, fmt.Println)
}

func (a *Alds15a) handle(scanner *bufio.Scanner, f func(a ...interface{}) (n int, err error)) {

	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	a.n, _ = strconv.Atoi(scanner.Text())

	a.a = make([]int, a.n)
	for i := 0; i < a.n; i++ {
		scanner.Scan()
		a.a[i], _ = strconv.Atoi(scanner.Text())
	}

	scanner.Scan()
	a.q, _ = strconv.Atoi(scanner.Text())

	a.m = make([]int, a.q)
	for i := 0; i < a.q; i++ {
		scanner.Scan()
		a.m[i], _ = strconv.Atoi(scanner.Text())
	}

	for _, v := range a.m {
		if a.solve(0, v) {
			f("yes")
		} else {
			f("no")
		}
	}
}

func (a *Alds15a) solve(i, m int) bool {
	if m == 0 {
		return true
	}

	if a.n <= i {
		return false
	}
	return a.solve(i+1, m) || a.solve(i+1, m-a.a[i])
}



Measured memory_bytes: 1124
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 4005;
const double eps = 1e-9;
const long long P = 998244353;
int n, k;
long long jie[N], jv[N], inv[N], tot[N];
long long C(long long x, long long y){
	//printf("%lld %lld %lld\n", x, y, jie[x] * jv[x - y] % P * jv[y] % P);
	return jie[x] * jv[x - y] % P * jv[y] % P;
}

int main() {
	scanf("%d%d", &k, &n);
	jie[0] = inv[0] = jv[0] = jie[1] = inv[1] = jv[1] = 1;
	for(int i = 2; i <= n + k; ++i){
		jie[i] = jie[i - 1] * i % P; 
		inv[i] = (P - P / i) * inv[P % i] % P; 
		jv[i] = jv[i - 1] * inv[i] % P;
	  //  printf("%lld %lld\n", jie[i], inv[i]);
	}
	for(int i = 1; i <= k; ++i) ++tot[i + 1], --tot[i + k + 1];
	for(int i = 1; i <= k + k; ++i) tot[i] += tot[i - 1]; //存在另一个数y满足x + y = i的x有多少个 
	for(int i = 2; i <= k + k; ++i){
		long long cnt = ((tot[i] + 1) >> 1), ans = 0;
		//printf("cnt = %lld\n", cnt);
		for(int j = 0, d = 1; j <= cnt && j + j <= n; ++j, d = P - d){
			ans = (ans + 1ll * d * C(cnt, j) % P * C(n - (j << 1) + k - 1, k - 1) % P) % P;
		    //printf("ans = %lld\n", ans);
		}
		printf("%lld\n", ans);
	}
    return 0;    
}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    if (N % 1000 != 0)
        cout << 1000 - N % 1000;
    else
        cout << 0;
}

Measured memory_bytes: 3596
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        v: [i32; if n == 1 { 0 } else { 2 }],
    }
    if n == 1 {
        println!("Hello World");
    } else {
        println!("{}", v[0] + v[1]);
    }
}


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

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

    int n;
    cin >> n;

    vector<int> x(n), for_med(n);
    rep(i, n) {
        cin >> x[i];
        for_med[i] = x[i];
    }
    
    sort(for_med.begin(), for_med.end());
    int left = for_med[n/2 - 1];
    int right = for_med[n/2];

    rep(i, n){
        if(x[i] <= left) cout << right << endl;
        else if(x[i] >= right) cout << left << endl;
        else raise;
    }
}

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

int main() {
    int N, K;
    int x;
    int i;
    int sum = 0;
    cin >> N >> K;
    for(i = 0;i < N;i++) {
        cin >> x;
        if(2 * x < K) {
            sum += 2 * x;
        }else {
            sum += 2 * (K - x);
        }
    }
    cout << sum << endl;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if ((a * 100 + b * 10 + c) % 4) {
    cout << "NO" << '\n';
  }
  else cout << "YES" << '\n';
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	Vi a(n);
	cin >> a;
	map<int, int> dis;
	rep(i, n) { 
		dis[a[i] + 1]++;
		dis[a[i] ]++;
		dis[a[i] - 1]++;
	}
	repi(itr, dis) { chmax(ans, itr->S); }
	cout<<ans<<endl;
}

Measured memory_bytes: 8008
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	stack<int> s;
	string str;

	getline(cin, str);

	vector<string> element;
	string temp;
	for (char c : str)
	{
		if (c == '+')
		{
			int a, b;
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(a + b);
		}
		else if (c == '-')
		{
			int a, b;
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(b - a);
		}
		else if (c == '*')
		{
			int a, b;
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(a * b);
		}
		else if (c == ' ')
		{
			if (temp.size() != 0)
			{
				stringstream ss;
				int n;
				ss << temp;
				ss >> n;
				s.push(n);
				temp.clear();
			}
		}
		else
		{
			temp += c;
		}
	}

	cout << s.top() << endl;
	return 0;
}

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

#define forn(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int y=n%10;
	if(y==3)cout<<"bon"<<endl;
	else if((y==0) || (y==1) || (y==6) || (y==8))cout<<"pon"<<endl;
	else cout<<"hon"<<endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll s;
	cin >> s;
	ll i = 1;
	set<ll> se;
	while(1){
		if(se.count(s)){
			cout << i << endl;
			return 0;
		}
		se.insert(s);
		if(s%2){
			s = 3*s+1;
		}else{
			s = s/2;
		}
		i++;
	}
}

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

int n,a,b,curtime;
pair<int,int> te;
priority_queue<pair<int,int> > pq;

int main(){
    scanf ("%d",&n);
    for (int i = 0; n > i; i++){
        scanf ("\n%d %d",&te.second, &te.first);
        te.first *= -1;
        pq.push(te);
    }
    curtime = 0;
    while (!pq.empty()){
        te = pq.top();
        pq.pop();
        if ((-1*te.first) - te.second < curtime) {
            printf ("No\n");
            return 0;
        }else{
            curtime += te.second;
        }
    }
    printf ("Yes\n");
    return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL x[100001];
int main(){
	cin>>N;
	REP(i,N){
	    cin>>x[i];
	}
	LL ans=1;
	LL kuuhaku=x[1]-2;
	LL res=2;
	if(x[0]==1&&x[1]==1){
	   ans*=res;
	   kuuhaku++;
	   res--;
	}
	for(int i=2;i<N;i++){
	    kuuhaku=x[i-1]-res;
	    if(kuuhaku>=res-1){
	       res++;
	    }else{
	       ans=(ans*res)%1000000007;
	    }
	}
	while(res>0){
	    ans=(ans*res)%1000000007;
	    res--;
	}
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 1024
A,B = map(int,input().split())
C = []
D = []
def prime_factor(n):
  E = []
  for i in range(2, int(n ** 0.5) + 1):
    while n % i == 0:
      E.append(i)
      n = n // i
  if n != 1:
    E.append(n)
  return E
C = prime_factor(A)
D = prime_factor(B)
f = set(C) & set(D)
print(len(f)+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
int n, c, ps[N], va[N], cb[N], ucb[N], ans;
signed main() {
	scanf("%lld%lld", &n, &c);
	for (int i = 1; i <= n; ++i) scanf("%lld%lld", ps + i, va + i), va[i] += va[i - 1];
	for (int i = 1; i <= n; ++i) {
		cb[i] = max(cb[i - 1], va[i] - ps[i]);
		ans = max(ans, cb[i]);
	}
	for (int i = n; i; --i) {
		ucb[i] = max(ucb[i + 1], (va[n] - va[i - 1]) - (c - ps[i]));
		ans = max(ans, ucb[i]);
	}
	for (int i = 1; i <= n; ++i) {
		ans = max(ans, va[i] - ps[i] * 2 + ucb[i + 1]);
		ans = max(ans, (va[n] - va[i]) - (c - ps[i + 1]) * 2 + cb[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

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

signed main ()
{
    fastio
    ll An , Bm , x , y ;
    cin >> An >> Bm >> x >> y ;
    vi AA (An) , BB (Bm);
    loop(An) {
        cin >> AA[i] ;
    }
    loop(Bm) {
        cin >> BB[i] ;
    }
    sort(AA . begin(), AA .end()) ;
    sort(BB . begin(), BB .end()) ;
    ll z = BB . front() ;
    cout << (z > x && z <= y && z > AA . back() ? "No War" : "War") << endl ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

//int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);


void merge(long long a1[],long long len_a1,long long a2[],long long len_a2,long long a[]){
    long long i = 0,j = 0;
    while(i<len_a1 || j<len_a2){
        if(j>=len_a2 || (i<len_a1 && a1[i]<a2[j])){
            a[i+j] = a1[i];
            i++;
        }else{
            a[i+j] = a2[j];
            j++;
        }
    }
}
void mergeSort(long long a[],long long len_a){
    if(len_a > 1){
        long long m = len_a/2;
        long long n = len_a - m;
        long long a1[m];
        long long a2[n];
        for(long long i = 0;i < m;i++) a1[i] = a[i];
        for(long long i = 0;i < n;i++) a2[i] = a[m+i];
        mergeSort(a1,m);
        mergeSort(a2,n);
        merge(a1,m,a2,n,a);
    }
}
 
//////////////////////////////////////////

int A,B;

int main(){
    scanf("%d%d",&A,&B);
    
    int count = 0;

    if(A > B){
        count += A;
        A--;
    }else{
        count += B;
        B--;
    }
    if(A > B){
        count += A;
        A--;
    }else{
        count += B;
        B--;
    }

    printf("%d\n",count);    
    return 0;
}



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


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

int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int>> a(n, vector<int>(m)), b(m, vector<int>(l));
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> b[i][j];
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            long long c = 0;
            for (int k = 0; k < m; k++) {
                c += a[i][k] * b[k][j];
            }
            printf("%lld", c);
            if (j != l-1) putchar(' ');
        }
        putchar('\n');
    }
}



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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main() {
    int n;
    cin >> n;
    map<ll,int> mp;
    REP(i,n){
        ll t;
        cin >> t;
        mp[t]++;
    }
    ll h=0,w=0;
    for(const auto& e:mp){
        ll a = e.first;
        int b = e.second;
        if(b>=2)h = w,w = a;
        if(b>=4)h = w = a;
    }
    COUT(h*w);
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  rep(i, N) cin >> m[i];

  int ans = N;
  rep(i, N) { X -= m[i]; }

  sort(all(m));
  ans += X / m[0];

  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N = input()
    A = list(map(int, input().split()))
    count = 0
    flag = False
    while True:
        for x in A:
            if x % 2 != 0:
                flag = True

        if flag:
            print(count)
            break

        A = [x / 2 for x in A]
        count += 1

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include <math.h>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	bool fact = false;
	rep2(i, 1, 10) {
		rep2(j, 1, 10) {
			if (i*j == n) {
				fact = true;
				break;
			}
		}
	}
	if (fact)cout << "Yes" << endl;
	else cout << "No" << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <string>
#include<iomanip>
#include<limits>
using namespace std;
int main(void){
   int N;
   cin>>N;
   int P[N];
   double a=1;
   for(int i=0;i<N;i++){
       cin>>P[i];
       a*=P[i];
   }
   bool Q[N];
   for(int i=0;i<N;i++){
       Q[i]=true;
   }
   double sum=0;
   double c=1;
   for(int i=0;i<N;i++){
       Q[i]=false;
       for(int j=0;j<N;j++){
           if(Q[j]){
               c*=P[j];
           }
       }
       sum+=c;
       c=1;
       Q[i]=true;
   }
   cout<<setprecision(12)<<double(a/sum)<<endl;
}


Measured memory_bytes: 256
def resolve():
	n, x = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(n):
		if i != 0:
			if (a[i] + a[i-1]) > x:
				diff = a[i] + a[i-1] - x
				ans += diff
				a[i] = a[i] - diff
		if a[0] > x:
			ans += a[0] - x
			a[0] = x
	print(ans)
resolve()

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> vec(n, 0);
	//vector<long long> presum(n, 0);
	long long vsum, lhlf, dis, tmp;
	//dis = LLONG_MAX;
	dis = 1e17;
	vsum = 0;
	for(int i=0; i<n; i++) {
		cin >> vec[i];
		vsum += vec[i];
	}
	lhlf = 0;
	for(int i=0; i<n-1; i++) {
		lhlf += vec[i];
		tmp = abs(vsum - (lhlf << 1));
		if(dis > tmp)
			dis = tmp;
                if(dis == 0)
                        break;
	}
	cout << dis << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline


def main(n, b):
    total = b[0] + b[-1]

    for i in range(n-2):
        total += min(b[i], b[i+1])

    return total


if __name__ == "__main__":
    n = int(input())
    b = list(map(int, input().split()))
    print(main(n, b))


Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int room[4][3][10] = {0};

	int n, b, f, r, v, i, j, k;

	scanf("%d\n", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		room[b - 1][f - 1][r - 1] += v;
	}
	for (b = 0; b < 4; b++) {
		for (f = 0; f < 3; f++) {
			for (r = 0; r < 10; r++) {
				printf(" %d", room[b][f][r]);
			}
			printf("\n");
		}
		if (b < 3) printf("####################\n");
	}
}



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

vector<vector<int>> graph(100001);

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }

    vector<int> done(n + 1);
    deque<int> dq;
    dq.push_back(1);
    while (true) {
        bool ok = true;
        int v = dq.back();
        done.at(v) = true;
        for (int i = 0; i < (int)graph.at(v).size(); i++) {
            if (!done.at(graph.at(v).at(i))) {
                dq.push_back(graph.at(v).at(i));
                ok = false;
                break;
            }
        }
        if (ok) break;
    }
    while (true) {
        bool ok = true;
        int v = dq.front();
        done.at(v) = true;
        for (int i = 0; i < (int)graph.at(v).size(); i++) {
            if (!done.at(graph.at(v).at(i))) {
                dq.push_front(graph.at(v).at(i));
                ok = false;
                break;
            }
        }
        if (ok) break;
    }

    cout << dq.size() << endl;
    for (auto v: dq) {
        cout << v << " ";
    }
    cout << endl;
}

Measured memory_bytes: 7040
from fractions import gcd
from sys import exit

N, M = map(int, input().split())
A = [int(x) for x in input().split()]

p = -1
while True:
    tmp_2 = [x % 2 for x in A]
    if tmp_2 == [0] * N:
        A = [x // 2 for x in A]
    elif tmp_2 == [1] * N:
        break
    else:
        print(0)
        exit()
    p += 1

lcm = A[0]
for i in range(1, N):
    lcm = lcm * A[i] // gcd(lcm, A[i])
    if A[i] % 2 == 0 or lcm > M:
        print(0)
        exit()

print((M // (lcm*2**p) + 1) // 2)


Measured memory_bytes: 16280
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

A,B,K=map(int,input().split())
gcdAB=gcd(A, B)
cnt=0
for i in range(gcdAB):
    n=gcdAB-i
    if gcdAB%n==0:
        cnt=cnt+1
    if cnt==K:
        print(n)
        exit()

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

string isHitachi(string str) {
	int hitachiPos = 0;
	for (int i = 0; i < (int) str.length(); i += 2) {
		if ((hitachiPos = str.find("hi", i)) != i) {
			return "No";
		}
	}
	return "Yes";
}

int main() {
	string str;

	cin >> str;

	cout << isHitachi(str) << endl;

	return 0;
}


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

using namespace std;

void solve()
{
	int N, H, W, ans = 0;
	cin >> N >> H >> W;
	while (N--)
	{
		int h, w;
		cin >> h >> w;
		ans += H <= h && W <= w;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int N;
	long long tmp = 0, ans = 0;
	scanf("%d", &N);
	long long *A = (long long *)malloc(sizeof(long long)*N);
	long long *B = (long long *)malloc(sizeof(long long)*N);
	for (int i = 0; i < N; i++)
	{
		scanf("%lld%lld", &A[i], &B[i]);
	}
	//for (int i = 0; i < N; i++)
	//{
	//	printf("%lld %lld\n", A[i], B[i]);

	//}
	for (int i = N - 1; i >= 0; i--)
	{
		tmp += (B[i] - (A[i] + tmp) % B[i]) % B[i];
	}
	ans = tmp;
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
    int n;
    cin >> n;
    Yes((n % 10 == 9) || (n / 10) == 9);
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

lint pow(lint a, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (1 <= i&&i < 10 || 100 <= i && i < 1000 || 10000 <= i && i < 100000) ans++;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256