akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = write!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! eprintln {
    () => { eprintln!(""); };
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = writeln!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! dbg {
    ($v:expr) => {{
        let val = $v;
        eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
        val
    }}
}

macro_rules! mat {
    ($($e:expr),*) => { Vec::from(vec![$($e),*]) };
    ($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
    ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
    ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
    ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
        $a$([$i])*.$f($($t),*)
    };
    ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
        let t = $e;
        ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
    } };
}

pub fn readln() -> String {
    let mut line = String::new();
    ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
    line
}

macro_rules! read {
    ($($t:tt),*; $n:expr) => {{
        let stdin = ::std::io::stdin();
        let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
            let line = line.unwrap();
            let mut it = line.split_whitespace();
            _read!(it; $($t),*)
        }).collect::<Vec<_>>();
        ret
    }};
    ($($t:tt),*) => {{
        let line = readln();
        let mut it = line.split_whitespace();
        _read!(it; $($t),*)
    }};
}

macro_rules! _read {
    ($it:ident; [char]) => {
        _read!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        Vec::from(_read!($it; String).into_bytes())
    };
    ($it:ident; usize1) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_read!($it; $t)),*)
    };
}


pub fn main() {
    let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: i64 = 1_000_000_007;
const INF: i64 = std::i64::MAX/3;

fn solve() {
    let (n,k) = read!(usize,usize);
    let mut p = read!([i64]);
    p.sort();
    let mut ans = 0;
    for i in 0..k {
        ans += p[i];
    }
    println!("{}",ans);
    
}

fn run() {
    solve();
}


Measured memory_bytes: 2252
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

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

    int res = 0;
    for( int a = 0; a <= min( n, k ); ++a ) {
        set< int > st;
        int pos = a;
        int tmp = 0;
        while( pos > 0 ) {
            st.insert( v[pos - 1] );
            tmp += v[pos - 1];
            --pos;

        }

        for( int b = 0; a + b <= min( n, k ); ++b ) {
            if( b != 0 ) {
                st.insert( v[n - b] );
                tmp += v[n - b];

            }
            int t = tmp;
            pos = 0;
            res = max( res, t );
            for( auto it = st.begin(); it != st.end() && pos < k - ( a + b ); ++it, ++pos ) {
                t -= *it;
                res = max( res, t );

            }
        }

    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int32_t main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);    
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    while (b <= a) 
    {
        ++ans;
        b <<= 1;
    }
    while (c <= b)
    {
        ++ans;
        c <<= 1;
    }
    if (ans > k) cout << "No";
    else cout << "Yes";
    return 0;
}

Measured memory_bytes: 3688
#include<iostream>

using namespace std;

int main ()
{
	int x,y;

	while(1)
	{
		cin >> x >> y;
		if(x == 0 && y == 0) break;
				if(x <= y)
				{
					cout << x << " " << y << endl;
				}
				else
				{
					cout << y << " " << x << endl;
				}
	}

	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<int> a(n);
    for (int i = 0; i < n; i++){
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = INF;
    for (int i = 0; i < n - 1; i++){
      ans = min(ans, a[i + 1] - a[i]);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;



int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS



      int n;
      cin >> n;

      for(int i = 1; i <= 50000; i++)
      {
        int x = floor(i*1.08);
        if(x == n)
        {
          cout << i << endl;
          return 0;
        }

      }



      cout << ":(";
      
    return 0; 
}


Measured memory_bytes: 3644
#include <stdio.h>

int F[45];
int fibonacci(int);

int main(){
  int n;
  scanf("%d",&n);
  
  fibonacci(n);
  
  printf("%d\n",F[n]);
  
  return 0;
}

int fibonacci(int n){
  
  if(n == 0 || n == 1) return F[n] = 1;
  if(F[n] != 0) return F[n];
  return F[n] = fibonacci(n-2) + fibonacci(n-1);
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n+1];
  vector<int> b;
  for(int i=1; i<=n; i++) cin >> a[i];
  for(int i=1; i<=n; i++){
    if(i % 2)
      b.push_back(a[i]);
    else
      b.insert(b.begin(), a[i]);
  }
  if(b.size() % 2) reverse(b.begin(), b.end());
  for(auto x : b) cout << x << " ";
  cout << '\n';
  return 0;
}


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

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int a = 0, b = 0;
	for(auto i = 0; i < n; ++i){
		if(i % 2 == 0){
			if(s[i] == '0') ++a;
			else            ++b;
		} else{
			if(s[i] == '1') ++a;
			else            ++b;
		}
	}
	cout << min(a, b) << endl;
	return 0;
}

Measured memory_bytes: 512
n, m = [ int(v) for v in input().split() ]

a = 1900*m
b = 100*(n-m)
a = a+b

total = 0

for i in range(1000):
    total += a * (i+1) * ( (2**m-1)**i / (2**m)**(i+1) )
    
print(round(total))


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<list>

using namespace std;

int main() {
	int n, ans;
	double d, x, y;
	while(cin >> n >> d) {
		ans = 0;
		while(n--) {
			cin >> x >> y;
			if(sqrt(x*x+y*y) <= d)
				ans++;
		}
		cout << ans << endl;
	} 
}

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

int main(){
	int n,x,s=0;


	while(1){
		cin >> n >> x;

		if( n==0 && x==0) break;

		 for(int i=1; i<n-1; i++){
			 for(int j=i+1; j<n; j++){
				 for(int k=j+1; k<=n; k++){
					 if ( i+j+k == x){
						 s++;
					 }
				 }
			 }
		 }
		 cout << s << "\n";
		 s=0;
	}

	return 0;
}

Measured memory_bytes: 1160
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#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(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		int cx = 0, cy = 0;
		int ct = 0;
		bool f = true;
		REP(i,n) {
			int t, x, y;
			cin >> t >> x >> y;
			if((((x+y)-(cx+cy)+1)%2+1)%2 == (t-ct)%2) {
				 if(abs(cx-x)+abs(cy-y) <= (t-ct)) {

				 } else {
					DEBUG(1);
					f = false;
				 }
			} else {
				DEBUG(2);
				DEBUG((t-ct)%2);
				DEBUG((((x+y)-(cx+cy)+1)%2+2)%2);
				f = false;
			}
			cx = x;
			cy = y;
			ct = t;
		}
		if(f) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int x[4], y[4];
    int persX, persY;
    scanf("%d %d %d %d", &x[0], &y[0], &x[1], &y[1]);

    persX = x[1] - x[0];
    persY = y[1] - y[0];

    x[2] = x[1] - persY;
    y[2] = y[1] + persX;

    x[3] = x[0] - persY;
    y[3] = y[0] + persX;

    printf("%d %d %d %d\n", x[2], y[2], x[3], y[3]);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
    char buffer[256];
    int n;
    
    fgets(buffer, 256, stdin);
    sscanf(buffer, "%d", &n);
    
    int i;
    for(i=1;i<=n;i++)
    {
        int x = i;
        if ( x % 3 == 0 )
        { 
            printf(" %d", i);
            continue;
        }
        if ( x % 10 == 3 )
        { 
            printf(" %d", i);
            continue;
        }
        while(x)
        {
            x /= 10;
            if ( x % 10 == 3)
            { 
                printf(" %d", i);
                break;
            }
        }
    }
    putchar('\n');
    return(0);
}



Measured memory_bytes: 2036
# coding: utf-8
# Your code here!
S=input()

e=1
a=0
ab=0
abc=0
M=10**9+7
for i in S:
    if i == "A":
        a=(a+e)%M
    if i == "B":
        ab = (ab+a)%M
    if i == "C":
        abc=(abc+ab)%M
    if i == "?":
        abc=(3*abc+ab)%M
        ab = (3*ab+a)%M
        a=(3*a+e)%M
        e=e*3%M
#    print(e,a,ab,abc)

print(abc)        

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 1000000
using namespace std;
typedef long long int ll;
#define mod 998244353
void sync(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
void floud(vector<vector<ll> > &G,ll n){
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
			}
		}
	}
}
int main(){
	sync();
	ll n,x,y;
	cin>>n>>x>>y;
	x--,y--;
	vector<vector<ll> > G(n,vector<ll>(n,INT_MAX));
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		G[i][j]=G[j][i]=min(abs(j-i),min(abs(x-i)+abs(j-y)+1,abs(y-i)+abs(j-x)+1));
	}
	map<ll,ll> ans;
	for(ll i=0;i<=n-1;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			if(G[i][j]!=INT_MAX)ans[G[i][j]]++;
		}
	}
	for(ll i=1;i<=n-1;i++)cout<<ans[i]<<endl;
}

Measured memory_bytes: 33536
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

void solve(istream& cin, ostream& cout) {
    int r, g, b;
    cin >> r >> g >> b;
    cout << ((g * 10 + b) % 4 == 0 ? "YES" : "NO");
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
import collections
N,K = map(int,input().split())
d = collections.defaultdict(int)
b = map(int,input().split())
for e in b:
  d[e]+=1
ret = 0
a = sorted([v for v in d.values()],reverse=True)
while len(a) > K:
  ret += a.pop()
print(ret)

Measured memory_bytes: 41504
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   deque<char> que;
   for (char c : s) que.push_back(c);
   bool flip = false;
   int q;
   cin >> q;
   rep(qi, 0, q) {
      int ti;
      cin >> ti;
      if (ti == 1) {
         flip = !flip;
      } else {
         int f;
         char c;
         cin >> f >> c;
         if (flip) f = 3 - f;
         if (f == 1) {
            que.push_front(c);
         } else {
            que.push_back(c);
         }
      }
   }
   if (flip) reverse(que.begin(), que.end());
   string ans;
   for (auto c : que) ans += c;
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1412
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);		int n = scan.nextInt();
		long[] data = new long[n];
		long max = 0;
		for(int i = 0 ; i < n ; i++){
			data[i]=scan.nextLong();
		}
		long min = Long.MAX_VALUE;
		max=data[n-1]-data[0];
		for(int i = 0 ; i < n ; i ++){
			if (data[i]>min) {
                continue;
            }
			min=data[i];
			for(int j = n-1 ; j > i ; j --){
				if(max<(data[j]-data[i])){
					max= data[j]-data[i];
				}
				//System.out.println(data[i]-data[j]);
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 99680
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int A[114514];
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }
    int M=-INF,m=INF;
    REP(i,N){
        M=max(M,A[i]);
        m=min(m,A[i]);
    }
    if(M-m>=2){GOODBYE;}
    
    if(M==m){
        if(2*m<=N){
            cout << "Yes" << endl;
            return 0;
        }
        if(m==N-1){
            cout << "Yes" << endl;
            return 0;
        }
        GOODBYE;
    }
    
    //M-m=1
    int mnum=0;
    REP(i,N){
        if(A[i]==m){
            mnum++;
        }
    }
    
    if(mnum<=m && 2*(M-mnum)<=(N-mnum)){
        cout << "Yes" << endl;
        return 0;
    }
    GOODBYE;
    
    
  return 0;
}



Measured memory_bytes: 1024
N, M=map(int, input().split())
s_row = [0 for x in range(M+1)]
for n in range(N):
 arr = list(map(int, input().split()))
 arr.append(sum(arr))
 s_row = [x+y for x,y in zip(s_row, arr)]
 print(" ".join([str(x) for x in arr]))
print(" ".join([str(x) for x in s_row]))

Measured memory_bytes: 7792
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// 0 or 1
bool solve_01(V<int> a) {
    int n = int(a.size());
    //for (int x: a) cerr << x << endl;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if ((i & (n - 1 - i)) == 0) {
            ans ^= a[i];
        }
    }
    return ans;
}

// 02, 1
bool solve_is1(V<int> a) {
    V<int> a2;
    for (int x: a) a2.push_back(x % 2);
    return solve_01(a2);
}

// 0,2
bool solve_is2(V<int> a) {
    V<int> a2;
    for (int x: a) a2.push_back(x / 2);
    return solve_01(a2);
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    V<int> a;
    bool exist1 = false;
    for (char& c : s) {
        a.push_back(c - '1');
        if (a.back() == 1) exist1 = true;
    }

    if (solve_is1(a)) {
        cout << 1 << endl;
        return 0;
    }

    if (exist1) {
        cout << 0 << endl;
    } else {
        if (solve_is2(a)) {
            cout << 2 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 17224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  ll a; cin >> a;
  double b; cin >> b;
  ll bb = b * 100 + 0.5;
  ll ans = a*bb;
  ans /= 100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3748
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

string S;
string T;

int Main() {
    cin >> S >> T;
    
    if (S.length()+1 == T.length()) {
        if(S.substr(0, T.length()-1).compare(T.substr(0, T.length()-1)) == 0 ) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        cout << "No" << endl;
    }

    
    return 0;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>

const int Max_a = 17; // 1 <= a <= 16
const int Max_b = 17; // 1 <= b <= 16
bool memo[Max_a][Max_b]; // memo for dp

void format(){
	for(u_int i = 0; i < Max_a; ++i){
        for(u_int j = 0; j < Max_b; ++j){
            if(i == 0 || j == 0){ // not use memo[0][] and memo[][0]
                memo[i][j] = true;
            }
            else{
                memo[i][j] = false;
            }
        }
    }
}

int calcRoad(u_int x, u_int y){
	// initialization
	if(x == 1 && y == 1){
		return 1;
	}
	else if(x == 0 || y == 0){
		return 0;
	}
	else{
		int num;
		if(memo[x - 1][y] && memo[x][y - 1]){ // if it was caliculated
			return 0;
		}
		else if(memo[x - 1][y]){
			num = calcRoad(x, y - 1);
			return num;
		}
		else if(memo[x][y - 1]){
			num = calcRoad(x - 1, y);
			return num;
		}
		else{
			num = calcRoad(x - 1, y) + calcRoad(x, y - 1);
			return num;
		}
	}
}
   
int main(){
    u_int a;    // width
    u_int b;    // height
    while(std::cin >> a >> b){
        if(a == 0 && b == 0){
            break;
        }
       
        // construction
		format();
        u_int n;
        std::cin >> n;
        for(u_int i = 0; i < n; ++i){
            u_int x, y;
            std::cin >> x >> y;
            memo[x][y] = true;
        }
		// solve by dp
        std::cout << calcRoad(a, b) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const string t="keyence";
string s;

int main(){
	cin>>s;
	bool B=0;
	int n=s.size();
	if(n==7){
		if(s==t) B=1;
	}
	else{
		for(int i=0;i<=7;i++) if(s.substr(0,i)+s.substr(n+i-7,7-i)==t) B=1;
	}
	cout<<(B?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int main() { 
    
    int a,b,c,d,e;
    cin>>b>>a;
    map<int,int>mp;
    for(int i=0;i<a;i++) {
        cin>>c;
        mp[c]++;
    }
    int min1=INT_MAX,ans;
    for(int i=-300;i<=300;i++) {
        if(min1>(abs(b-i))&&mp[i]==0) {
            min1=abs(b-i);
            ans=i;
        }
    }
    cout<<ans;
	return 0; 
} 


Measured memory_bytes: 3648
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	char[] list1 = reader.readLine().toCharArray();
	char[] list2 = reader.readLine().toCharArray();
	long res = 0;
	for(int i = 0;i<list1.length;i++){
		if(list1[i]!=list2[i]) res++;
	}
	System.out.println(res);
	}
}


Measured memory_bytes: 37768
#include<iostream>
#include<vector>
using namespace std;

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

	bool ans=true;

	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if((a%2)==0){
			if(a%3 && a%5) ans =false;
		}
	}

	if(ans) cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;

	return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    string S;
    cin >>S;

    cout << ((S[0]=='9'||S[1]=='9') ? "Yes" : "No") <<endl;
    return (0);
}

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

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

#define gcd3(x,y,z)                __gcd(__gcd(x,y),z)
#define INF                     LLONG_MAX
#define inf                     LONG_MAX
#define PI                      (2.0*acos(0.0))
#define Log(b,x)                (log(x)/log(b))
#define Unique(x)               sort(all(x)); x.erase(unique(all(x)), x.end());
#define inttostring(x)          to_string(x)
#define stringtoint(x)          stoll(x)
#define valid(nx,ny,row,col)    nx>=0 && nx<row && ny>=0 && ny<col
#define CLR(x,y)                memset(x,y,sizeof(x));
#define max3(x,y,z)             max(z,max(x,y));
#define min3(x,y,z)             min(z,min(x,y));
#define MP(x, y) make_pair(x, y)
#define SZ(c) (int)c.size()
#define pb(x) push_back(x)
#define all(x)                  (x).begin(), (x).end()
#define sz(c)               int(c.size())
#define clr(x, y)           memset(x, y, sizeof(x))
#define ff first
#define ss                  second
#define sf                  scanf
#define si(x)               scanf("%d", &x)
#define sii(x, y)           scanf("%d %d", &x, &y)
#define siii(x, y, z)       scanf("%d %d %d", &x, &y, &z)
#define sl(x)               scanf("%lld", &x)
#define sll(x, y)           scanf("%lld %lld", &x, &y)
#define slll(x, y, z)       scanf("%lld %lld %lld", &x, &y, &z)
#define pf                  printf
#define pi(x)               printf("%d\n", x)
#define pii(x, y)           printf("%d %d\n", x, y)
#define piii(x, y, z)       printf("%d %d %d\n", x, y, z)
#define pl(x)               printf("%lld\n", x)
#define pll(x, y)           printf("%lld %lld\n", x, y)
#define plll(x, y, z)       printf("%lld %lld %lld\n", x, y, z)
#define Pii pair< int, int >
#define psi pair< string, int >
#define case(n) printf("Case %d: ",n);
#define eps 1e-15
#define mod 100000007
#define MAX 100000010
priority_queue<Pii, vector<Pii>, greater<Pii> > q;


int main()
{
    //READ("input.txt");
   // WRITE("output.txt");

    int a,b,c,x;
    cin>>a>>b>>c;
    x=c/a;
    cout<<x*b<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
ll keta(ll num){ ll k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, x, tmp;
    vector<ll> a;
    cin >> n >> x;

    ll asum = 0;
    rep(i, n){
        cin >> tmp;
        a.push_back(tmp);
        asum += tmp;
    }

    vsort(a);

    ll sum = 0;
    ll res = 0;
    rep(i, n){
        if(sum + a[i] <= x){
            sum += a[i];
            res++;
        }else{
            break;
        }
    }

    if(asum <= x){
        if(x != sum && res > 0) res--;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define MAX_N 10
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) x.begin(),x.end()
#define SORT(x)  sort((x).begin(),(x).end() )
#define RSORT(x) sort((x).rbegin(), (x).rend())
using namespace std;


// dist(i,j) return (dx^2 - dy^2)^0.5;
// fct = n!
// cout<<fixed<<setprecision(n)<< ans <<endl; : 浮動小数点型を出力する時に全て小数部10桁
//cout : 整数部、小数部合わせて6桁
//setprecision(n): 整数部、小数部合わせてn桁
// fixed : 小数部n桁


int x[MAX_N];
int y[MAX_N];

double dist(int i, int j){
    double dx = x[i] -x[j];
    double dy = y[i] - y[j];
    return pow((dx*dx + dy*dy), 0.5);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    for(int i = 1;i<=n;i++){
        cin>>x[i]>>y[i];
    }
    vector<int> prm(n);
    for(int i = 0;i <n; i++) prm[i] = i+1;
    double sum = 0.0;
    
     do{
         for(int i = 0; i<n-1; i++) sum += dist(prm[i], prm[i+1]);
     }while(next_permutation(ALL(prm)));
     
     int fct = 1;
     for(int i = 2; i<=n; i++) fct*=i;

     cout<< fixed << setprecision(10) << sum / fct <<endl;
     return 0;
}

Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
#define rep(i,n) for(int i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
bool f(ll n) {
	bool b = 1;
	for (int i = 2; i <= sqrt(n); ++i)if (n%i == 0)b = 0;
	return b;
}
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll n, v[100000], mx = 0,ans,num=0;
int main() {
	cin >> n;
	rep(i, n)cin >> v[i], mx = max(v[i], mx);
	rep(i, n) {
		if (num< min(v[i], mx - v[i])) {
			num = min(v[i], mx - v[i]);
			ans = v[i];
		}
	}
	cout << mx << " " << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#-*- using:utf-8 -*-
def euclidean(a,b):
    if b == 0:
        return a
    else:
        return  euclidean(b,a%b)

def gcd(a,b):
#    print("gcd %d %d" %(a,b))
    n = 0
    if a == b:
        return a
    elif a > b:
        n = euclidean(a,b)

    elif a < b:
        n = euclidean(b,a)

    else:
        pass

    return n

def blackboard(n,a):
    candidate = 0
    maxnum = 0
    b = list(map(int,a))

    left = [0] * (n+1)
    right = [0] * (n+1)
    for i in range(n):
        left[i+1] = gcd(left[i],b[i])
        right[i+1] = gcd(right[i],b[n - i -1])

    for i in range(n):
        candidate = gcd(left[i],right[n-i-1])
        if candidate > maxnum:
            maxnum = candidate

    return maxnum


if __name__ == '__main__':
    n = raw_input()
    a = raw_input().split()
    m = int(n)
    print("%d" %(blackboard(m,a)))

Measured memory_bytes: 16092
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <long long> vi;
typedef pair <long long, long long> pii;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define int long long
#define inf LLONG_MAX
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;	
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}

template <typename X> ostream& operator << (ostream& x,const vector<X>& v){ for (X a : v) x << a << ' '; return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const vector< pair<X, Y> >& v) {for (pair <X, Y> it : v) x << it.first << ' ' << it.second << endl; return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (pair <T, S> it : v) os << it.first << " => " << it.second << endl; return os; }
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
int modulo = 1e9 + 7;

int fpow(int a, int n) {
	int ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b; cin >> a >> b;
	cout << max(a+b, max(a-b, a*b));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <deque>
#include <algorithm>

using namespace std;

void bubbleSort(int n, deque<int> a) {
    bool flag = true;
    int count = 0;
    while (flag) {
        flag = false;
        for (int j = n - 1; j >= 1; --j) {
            if (a[j] < a[j - 1]) {
                int t = a[j];
                a[j] = a[j - 1];
                a[j - 1] = t;
                flag = true;
                ++count;
            }
        }
    }
    for (int i = 0; i < n-1; ++i) {
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl << count << endl;
}

int main(int argc, char* argv[]) {
    deque<int> a;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    bubbleSort(n, a);

    return 0;
}




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

const int MAX_N = 100;

int main(){
    bool flag = 1;
    int A[MAX_N];
    int n, num = 0;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];

    while(flag){
        flag = 0;
        for (int j = n - 1; j >= 1; j--) {
           if(A[j] < A[j - 1]){
               swap(A[j],A[j - 1]);
               num++;
               flag = 1;
           }
        }
    }
    for (int i = 0; i < n - 1; i++) {
        cout << A[i] << " ";
    }
    cout << A[n - 1] << "\n" << num << "\n";

    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

vector<ii> edges;
vector<ii> adj[111111];
ll s[111111];
ll ans[111111],sub[111111],contr[111111];

void dfs(int u,int p)
{
	sub[u]=1;
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i].fi; int e=adj[u][i].se;
		if(v==p) continue;
		dfs(v,u);
		sub[u]+=sub[v];
	}
}

int n; 

void dfs2(int u,int p)
{
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i].fi; int e=adj[u][i].se;
		if(v==p) continue;
		//cerr<<"VISIT : "<<v<<' '<<e<<'\n';
		contr[e] = sub[v];
		if((n-2*sub[v])!=0)
		{
			ans[e] = (s[u] - s[v])/(sub[v] - (n - sub[v]));
		}
		dfs2(v,u);
	}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	bool sub1=1; bool sub2=1;
	for(int i=0;i<n-1;i++)
	{
		int u,v; cin>>u>>v; u--; v--;
		edges.pb(mp(u,v));
		adj[u].pb(mp(v,i)); adj[v].pb(mp(u,i));
		if(u!=0||v!=i+1)
		{
			sub2=0;
		}
		if(u!=i||v!=i+1)
		{
			sub1=0;
		}
	}
	for(int i=0;i<n;i++) cin>>s[i];
	
	dfs(0,-1);
	dfs2(0,-1);
	
	ll sum=s[0];
	for(int i=0;i<n-1;i++)
	{
		sum-=contr[i]*ans[i];
	}
	for(int i=0;i<n-1;i++)
	{
		if(ans[i]==0)
		{
			ans[i]=sum/contr[i];
		}
	}
	for(int i=0;i<n-1;i++)
	{
		cout<<ans[i]<<'\n';
	}
}	

Measured memory_bytes: 19312
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b] <- getInts
  ; putInts [a*b, 2*(a+b)]
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords. map show

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <string>
#include <math.h>
#include <stdint.h>
#include <bitset>
#include <iomanip>

using namespace std;

long int Sum(const long int n) {
  if (n<=1) {
    return 1;
  } else {
    return 2*Sum((n/2)) + 1; 
  }

}

int main() {
  long int H;
  cin >> H;

  long int sum = Sum(H);

  cout << sum << endl; 
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{int pa, le, ri;};
struct Node T[MAX];
int n, H, D[MAX];

int getDepth(int u);

void print(int u);

int main(){
  int i, j, d, v, c, l;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) T[i].pa = T[i].le = T[i].ri = NIL;

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) T[v].le = c;
      else T[l].ri = c;
      l = c;
      T[c].pa = v;
    }
  }
  
  H = 0;
  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
    if ( D[i] > H ) H = D[i];
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

int getDepth(int u){
  int d = 0;
  for(; T[u].pa != NIL ;d++) u = T[u].pa;
  return d;
}

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].pa);
  printf("depth = %d, ", D[u]);

  if ( T[u].pa == NIL ) printf("root, ");
  else if ( T[u].le == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = T[u].le; c != NIL; i++, c = T[c].ri){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}



Measured memory_bytes: 3300
#include <stdio.h>

int main(){
    int s[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 
    2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 
    1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int i;
    scanf("%d", &i);
    printf("%d\n", s[i-1]);
    return 0;
}

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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0) ;

ll fact[200005] ;

void calFact()
{
    fact[0] = fact[1] = 1 ;
    for (ll i = 2; i <= 200000; i++) {
        fact[i] = ( fact[i - 1] * i ) % MOD ;
    }
}

ll big_mod(ll base, ll power, ll mod)
{
  if(power == 0)  return 1;
  else if(power % 2 == 1) {
    ll p1 = base % mod;
    ll p2 = (big_mod(base, power-1, mod) ) % mod;
    return (p1 * p2) % mod;
  }
  else if(power % 2 == 0) {
    ll p1 = (big_mod(base, power/2, mod) ) % mod;
    return (p1 * p1) % mod;
  }
}


int main()
{
    calFact() ;
    ll n, a, b, ans, x, valX, val ;
    cin >> n >> a >> b ;
    ans = big_mod(2, n, MOD) ;
    ans-- ;
    ans += MOD;
    ans %= MOD;
    // Subtracting nCa from Ans //
    x = n - a + 1 ;
    valX = x++ ;
    for (int i = x; i <= n; i++) {
        valX = ( (valX % MOD) * (i % MOD) ) % MOD ;
    }
    val = valX * big_mod(fact[a], MOD - 2, MOD);
    val %= MOD;
    ans -= val ;
    ans += MOD;
    ans %= MOD;

    // Subtracting nCb from Ans //
    x = n - b + 1 ;
    valX = x++ ;
    for (int i = x; i <= n; i++) {
        valX = ( (valX % MOD) * (i % MOD) ) % MOD ;
    }
    val = valX * big_mod(fact[b], MOD - 2, MOD);
    val %= MOD;
    ans -= val ;
    ans += MOD;
    ans %= MOD;
    cout << ans << endl ;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;

typedef long long ll;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
int string_to_int(string x) {
	int n;
	stringstream s(x);
	s >> n;
	return n;
}

int64_t power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
int64_t POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

vector<int64_t> INVERSE(int64_t nn, int64_t mo) {
	vector<int64_t> inv(nn + 1);
	vector<int64_t> mul(nn + 1);
	inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= nn; ++i) {
		inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo; 
	}
	mul[0] = 1;
	for (int i = 1; i <= nn; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mo;
	}
	return mul;
}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



int main() {
	int n;
	cin  >> n;
	vector<int64_t> v(n);
	int64_t ans = 1000;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		if (i) {
			if (v[i] > v[i - 1]) {
				int64_t x = ans / v[i - 1];
				ans = ans % v[i - 1];
				ans += x * v[i];
			}
		}
	}
	//for (int i = 1; i < n; ++i) {
		//if (v[i] > v[i - 1]) {
			//int64_t x = ans / v[i - 1];
			//ans = ans % v[i - 1];
			//ans += x * v[i];
		//}
	//}
	cout << ans;
}













Measured memory_bytes: 3644
s=input()
n=len(s)
if n%2:
  ms,us=s[:(n-1)//2],s[:(n-1)//2:-1]
else:
  ms,us=s[:n//2],s[:n//2-1:-1]
ans=0
for a,d in zip(list(ms),list(us)):
  if a!=d:ans+=1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
int P[25];

int main(){

	scanf("%d",&N);

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

		scanf("%d",&P[i]);
	}

	int ans = 0;
	for(int i = 1; i < N-1; i++){
		if(P[i] > P[i-1] && P[i] < P[i+1]){

			ans++;

		}else if(P[i] < P[i-1] && P[i] > P[i+1]){

			ans++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long co[200020] = { 0 };
int main() {
	int n;
	int a[200020];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long ans = 0;
	for (int j = 0; j < n; j++) {
		if (j - a[j] > 0) {
			ans += co[j - a[j]];
		}
		if (j + a[j] < 200020) {
			co[j + a[j]]++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int a, b, t;
  cin >> a >> b >> t;
  int ans  = t / a;
  cout << ans * b << endl;
	
  return 0;
}


Measured memory_bytes: 256
def countingSort(A):
    VMAX = 10**4 # A[i] の取りうる範囲
    C = [0] * VMAX
    result = [None] * (len(A))

    # C に A の各要素の出現回数を記録
    for i in range(len(A)):
        C[A[i]] += 1

    # C に A の各要素以下の出現回数を記録 (累積)
    for i in range(1, VMAX):
        C[i] += C[i-1]

    for i in range(len(A)-1, -1, -1): # A の添字を後ろからたどる
        result[C[A[i]]-1] = A [i]
        C[A[i]] -= 1

    return result

n = int(input())
A = [i for i in map(int, input().split())]
result = countingSort(A)
result = [i for i in map(str, result)]
print(' '.join(result))


Measured memory_bytes: 241356
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define out(i) cout<<(i)<<endl
signed main(){
  int n,m;
  cin>>n>>m;
  int dif=abs(n-m);
  int nres=1,mres=1;
  for(int i=1;i<=n;++i){nres*=i;nres%=1000000007;}
  for(int i=1;i<=m;++i){mres*=i;mres%=1000000007;}
  if(dif==0)out(nres*mres*2%1000000007);
  else if(dif==1)out(nres*mres%1000000007);
  else cout<<0<<endl;

  return 0;
}



Measured memory_bytes: 256