akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let x: u64 = read!(u64);

    // 6 -> 5 -> 6 -> 5 ... と繰り返していけばよい
    // 6 -> 5 の2回をまとめて1セットと数え、何セットできるかをとりあえず数える
    let d = x / 11;
    let r = x % 11;

    let ans = if 1 <= r && r <= 6 {
        2 * d + 1
    } else if r == 0 {
        2 * d
    } else {
        2 * d + 2
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
#define N 30

char name[N];/*Sの名前*/

int main(void){
  int i=0;
  int len;/*文字列の長さ*/
  scanf("%s",name);
  len=strlen(name);
  if (3<=len && len<=20){
    while(i<3){   
      printf("%c",name[i]);
      i++;
    }
  }
  else{
    printf("string_error");
  }
  return 0;
}


Measured memory_bytes: 1664
n = int(input())
a = list(map(int,input().split()))
l = set(a)
dict = {}
for x in l:
    dict.update({x:0})
for b in a:
    dict[b] += 1
ans = 0
for i in dict:
    if dict[i] < i:
        ans += dict[i]
    else:
        ans += abs(dict[i]-i)
print(ans)

Measured memory_bytes: 23412
#include <bits/stdc++.h>
#define ll 			long long
#define vl 			vector<ll>
#define vi 			vector<int>
#define pi 			pair<int,int>
#define pl 			pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb 			push_back
#define mp 			make_pair
#define F 			first
#define S 			second
#define trace(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 fast_io 	std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

using namespace std;


int main()
{
	fast_io;
	int n,a,b;
	cin>>n>>a>>b;
	int ans=min(n*a,b);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	int a , b ,c;
	cin >> a >> b >> c;
	if(c >= a && c <= b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
	}

Measured memory_bytes: 256
n = int(input())
l = [int(input()) for i in range(n)]
ans = {}
i = 1
while True:
  i = l[i-1]
  if i in ans:
    print(-1)
    exit()
  else:
    ans[i] = 1
    
  if i == 2:
    print(len(ans))
    exit()
      

Measured memory_bytes: 16292
N = int(input())

dic = {}
for n in range(1,N+1):
  dic[n] = int(input())

now = 1
count = 0
flag = False
while True:
  if now==2:
    flag = True
    break
  if now not in dic:
    break
  now = dic.pop(now)
  #del dic[now]
  count += 1

if flag:
  print(count)
else:
  print(-1)

Measured memory_bytes: 55256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll n,k;
vl a(101010), b(101010);

ll rec(ll x){
	ll res = 0;
	if(x == 0){
		rep(i,n){
			if(a[i] == 0) res += b[i];
		}
		return res;
	}
	ll p = 0;
	while(1<<p <= x) p++;
	p--;
	rep(i,n){
		if(a[i] > x) continue;
		else if(a[i]>>p & 1) a[i] -= 1<<p;
		else res += b[i];
	}
	chmax(res, rec(x - (1<<p)));
	return res;
}

int main(){
	cin >> n >> k;
	rep(i,n) cin >> a[i] >> b[i];
	cout << rec(k) << endl;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  string s;
  cin >> s;
  s[5] = ' ';
  s[13] = ' ';
  cout << s << endl;
}


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

// 插入此處

int main() {
	LL h, w; cin >> h >> w;
	if (h == 1 || w == 1) {
		cout << 1 << endl;
	} else {
		cout << h * w / 2 + h * w % 2 << endl;
	}
	return 0;
}



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

using namespace std;

int main() {
int a,b,c;
cin>>a>>b>>c;
int maxx=max(a,max(b,c));
if(3*maxx%2==(a+b+c)%2){
   cout<<(3*maxx-(a+b+c))/2<<endl;
}
else{
   cout<<(3*(maxx+1)-(a+b+c))/2<<endl;
}
   return 0;
}






Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

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

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

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


	int N = getint();

	int A[1000001] = {};
	rep(i, N) A[getint()]++;

	if (A[1]) {
		if (A[1] == 1) co(1);
		else co(0);
		return 0;
	}

	int kotae = 0;
	for (int i = 2; i <= 500000; i++) {
		if (A[i]) {
			kotae += (A[i] == 1);
			for (int j = i + i; j <= 1000000; j += i) {
				A[j] = 0;
			}
		}
	}
	for (int i = 500001; i <= 1000000; i++) kotae += (A[i] == 1);
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 7196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
public class Main {
	private static  BufferedReader  br = null;
	private	static	String			st = "012345678954321";
	private	static	int				sl = st.length();

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	* @param args
	*/
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int cnt = 0;
		while ((cnt = parseCnt()) != -1) {
			while (cnt-- > 0) {
				solve(parsePos());
			}
		}
	}

	private static void solve(int[]	pos) {
		int		pos1 = st.indexOf('0'+pos[0]);
		int		pos2 = st.indexOf('0'+pos[1]);
		String	out = "";

		if (pos[2] == 0) {
			for (int i = pos1; i <= pos2; i++) {
				out += (i == pos1) ? st.charAt(i) : " "+st.charAt(i);
			}
		} else {
			if (pos[3] < 6) {
				for (int i = pos1; i >= pos2; i--) {
					out += (i == pos1) ? st.charAt(i) : " "+st.charAt(i);
				}
			} else {
				int	pos3 = st.indexOf('0'+pos2, pos1);
				pos2 = (pos3 == -1) ? pos2 : pos3;
				for (int i = pos1; ; i = (i+1)%sl) {
					out += (i == pos1) ? st.charAt(i) : " "+st.charAt(i);
					if (i == pos2) break;
				}
			}
		}

		System.out.println(out);
	}

	private static int parseCnt() {
		int     cnt = -1;
		String  str = null;

		if ((str = parseStdin()) != null) {
			cnt = Integer.parseInt(str);
		}

		return cnt;
	}

	private static int[] parsePos() {
		int[]	pos = null;
		String	str = null;
	
		if ((str = parseStdin()) != null) {
			str = str.replaceAll(" ", "");
			pos = new int[4];
			pos[0] = str.charAt(0) - '0';
			pos[1] = str.charAt(1) - '0';
			pos[2] = (pos[0] < pos[1]) ? 0 : 1;
			pos[3] = (pos[0] < pos[1]) ? pos[1] : pos[0];
		}
	
		return pos;
	}

	private static String parseStdin() {
		String	stdin = null;

		try {
			String	tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
				}
			}
		catch (IOException e) {}

		return stdin;
	}
}

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

string A, B;

int main() {
    cin >> A >> B;
    if (A.size() > B.size()) {
        cout << "GREATER" << endl;
        return 0;
    }

    if (A.size() < B.size()) {
        cout << "LESS" << endl;
        return 0;
    }

    string ans = "EQUAL";
    rep(i, A.size()) {
        if (A[i] > B[i]) {
            ans = "GREATER";
            break;
        } else if (A[i] < B[i]) {
            ans = "LESS";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n,p = map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n,1])

    return arr

arr = factorization(p)
ans = 1
for base, times in arr:
    new = base**(times // n)
    ans *= new
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
 
 
 
 
 
 
 







int last[200005];
int main(){
    int a,b,q;
    cin>>a>>b>>q;
    vector<ll> s(a);
    vector<ll> t(b);
    for(int i=0;i<a;i++)cin>>s[i];
    for(int i=0;i<b;i++)cin>>t[i];
    s.push_back(-1e17);
    t.push_back(-1e17);
    s.push_back(1e17);t.push_back(1e17);
    sort(s.begin(),s.end());sort(t.begin(),t.end());
    while(q--){
         ll x;
         cin>>x;
         int idx1=lower_bound(s.begin(),s.end(),x)-s.begin();
         int idx2=lower_bound(t.begin(),t.end(),x)-t.begin();
         ll a=s[idx1]-x;
         ll b=t[idx2]-x;
         ll la=x-s[idx1-1];
         ll lb=x-t[idx2-1];
         ll ans=1e18;
         ans=min(ans,max(a,b));
         ans=min(ans,max(la,lb));
         ans=min(ans,lb+a+min(a,lb));
         ans=min(ans,b+la+min(la,b));
         cout<<ans<<"\n";
         
    }
}






































Measured memory_bytes: 5628
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

/*int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

struct BIT{
    vector<int> dat;
    int sz;
    BIT(int n){
        for(sz=1;sz<n;sz *= 2);
        dat.resize(++sz);
    }
    int q(int n){
        int ret = 0;
        for(int i=n;i>0;i-=i&-i)ret +=dat[i];//和の計算　iから最後の１のbit(i&-i 多分＆はビット積)を減算
        for(int i=n;i<sz;i+=i&-i) dat[i]++;//値の加算　iから最後mの１のbitを加算
        return ret;
    }
};

int main(){
    char b;
    cin >> b;
    if(b=='A'){
        cout<<'T'<<endl;
    }else if(b=='C'){
        cout<<'G'<<endl;
    }else if(b=='G'){
        cout<<'C'<<endl;
    }else{
        cout<<'A'<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll x,y,z;
    x=a*b*abs((c-(c/2))-c/2);
    y=b*c*abs((a-(a/2))-a/2);
    z=c*a*abs((b-(b/2))-b/2);
    cout<<min({x,y,z})<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

string S;
int dp[1000010][2];

void _main() {
    cin >> S;
    S = "0" + S;
    dp[0][0] = 0;
    dp[0][1] = 1LL << 30;
    REP (i, S.size()) {
        int d = S[i] - '0';
        dp[i + 1][0] = min(dp[i][0] + d, dp[i][1] + 10 - d);
        dp[i + 1][1] = min(dp[i][0] + d + 1, dp[i][1] + 9 - d);
    }
    cout << dp[S.size()][0] << endl;
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 16968
class Dice
  @north = 5
  @south = 2
  @east = 3
  @west = 4
  @top = 1
  @bottom = 6

  def initialize(input_t, input_s, input_e, input_w, input_n, input_b)
    @north = input_n
    @south = input_s
    @east = input_e
    @west = input_w
    @top = input_t
    @bottom = input_b
  end

  def set(north, south, east, west, top, bottom)
    100000.times do
      output =  self.move(["N", "S", "E", "W"].sample)
      # p "output = #{output}, dice = [#{north}, #{south}, #{east}, #{west}, #{top}, #{bottom}]"
      if output[0] == north && output[1] == south && output[2] == east && output[3] == west && output[4] == top && output[5] == bottom
        return true
        break
      end
    end
    return false
    #@top = top, @south = front???????????????????????¶??????move??????
    #???????????°?????????false?????§????????´??????true?????????
  end

  def move(order_array)
    length = order_array.length
    for i in 0..(length-1)
      if order_array[i] == "N"
        move_north
      elsif order_array[i] == "S"
        move_south
      elsif order_array[i] == "E"
        move_east
      else
        move_west
      end
    end
    output = [@north, @south, @east, @west, @top, @bottom]
    return output
  end

  def move_north
    tmp = []
    tmp.push(@north)
    tmp.push(@south)
    tmp.push(@top)
    tmp.push(@bottom)
    @bottom = tmp[0]
    @top = tmp[1]
    @north = tmp[2]
    @south = tmp[3]
  end

  def move_south
    tmp = []
    tmp.push(@north)
    tmp.push(@south)
    tmp.push(@top)
    tmp.push(@bottom)
    @top = tmp[0]
    @bottom = tmp[1]
    @south = tmp[2]
    @north = tmp[3]

  end

  def move_east
    tmp = []
    tmp.push(@east)
    tmp.push(@west)
    tmp.push(@top)
    tmp.push(@bottom)
    @bottom = tmp[0]
    @top = tmp[1]
    @east = tmp[2]
    @west = tmp[3]
  end

  def move_west
    tmp = []
    tmp.push(@east)
    tmp.push(@west)
    tmp.push(@top)
    tmp.push(@bottom)
    @top = tmp[0]
    @west = tmp[2]
    @bottom = tmp[1]
    @east = tmp[3]
  end

end

dice_numbers = gets.chomp.split.map(&:to_i)
input_t = dice_numbers[0]
input_s = dice_numbers[1]
input_e = dice_numbers[2]
input_w = dice_numbers[3]
input_n = dice_numbers[4]
input_b = dice_numbers[5]
other_dice_numbers = gets.chomp.split.map(&:to_i)
dice2 = Dice.new(other_dice_numbers[0], other_dice_numbers[1],other_dice_numbers[2],other_dice_numbers[3],other_dice_numbers[4],other_dice_numbers[5])
dice2_result = dice2.set(input_n, input_s, input_e, input_w, input_t, input_b)
if dice2_result == true
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 9024
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t;

int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      string s;
      cin>>s;
      if(s[0]!=s[1]||s[1]!=s[2])cout<<"Yes";
      else cout<<"No";
      
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18;

/*--------------------------------------------------------------------*/

signed main(){
	int n,k;
	cin>>n>>k;
	vi po,ne;
	int zero=0,pos,neg;
	rep(i,n){
		int a;cin>>a;
		if(a>=0) po.pb(a);
		else ne.pb(a);
	}
	pos=po.size();
	neg=ne.size();

	sort(all(po));
	sort(all(ne));
	reverse(all(po));

	int pro;

	if(n==k){
		pro=1;
		rep(i,pos){
			pro*=po[i];
			pro%=MOD;
		}
		rep(i,neg){
			pro*=ne[i];
			pro=(pro+MOD*MOD)%MOD;
		}
		cout<<pro<<endl;
		return 0;
	}

	if(pos==0&&k%2==1){
		pro=1;
		rep(i,k){
			pro*=ne[neg-i-1];
			pro=(pro+MOD*MOD)%MOD;
		}
		cout<<pro<<endl;
		return 0;
	}

	int ip=0,in=0;
	pro=1;
	while(in+ip<k){

		if(k-ip-in>=2&&in+1<neg&&ip+1<pos&&ne[in]*ne[in+1]>=po[ip]*po[ip+1]){
				pro*=ne[in];
				pro=(pro+MOD*MOD)%MOD;
				pro*=ne[in+1];
				pro=(pro+MOD*MOD)%MOD;
				in+=2;
		}else if(k-ip-in>=2&&in+1<neg&&ip+1>=pos){
				pro*=ne[in];
				pro=(pro+MOD*MOD)%MOD;
				pro*=ne[in+1];
				pro=(pro+MOD*MOD)%MOD;
				in+=2;		
		
		}else if(ip<pos){
			pro*=po[ip];
			pro%=MOD;
			ip++;
		}else{
			assert(0);
		}

	}
	cout<<pro<<endl;
	return 0;


}



Measured memory_bytes: 5328
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 200000;
const ll mod = 1e9 + 7;
int n;
ll sz[N], dp[N], cnt[N];
VI e[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

void dfs(int now, int past){
    sz[now] = 1;
    for (int next : e[now]){
        if (next == past) continue;
        dfs(next, now);
        sz[now] += sz[next];
    }
    dp[now] = powll(2, sz[now] - 1) - 1;
    for (int next : e[now]){
        if (next == past) continue;
        ll s = (dp[next] * powll(2, sz[now] - sz[next])) % mod;
        (dp[now] += s) %= mod;
    }
    cnt[now] = dp[now];
    for (int next : e[now]){
        if (next == past) continue;
        ll s = (dp[next] + powll(2, sz[next]) - 1) % mod;
        cnt[now] = (cnt[now] - s + mod) % mod;
    }
}

int main() {
    n = in();
    REP(i,n-1){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    dfs(0, -1);
    // REP(i,n){
    //     cout << i << " " << dp[i] << " " << cnt[i] << endl;
    // }
    ll ans = 0;
    REP(i,n) (ans += cnt[i]) %= mod;
    ans = divll(ans, powll(2, n));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 27008
def check(l):
    c0 = all(l[i] for i in range(0, 9, 3))
    c1 = all(l[i] for i in range(1, 9, 3))
    c2 = all(l[i] for i in range(2, 9, 3))
    r0 = all(l[i] for i in range(3))
    r1 = all(l[i] for i in range(3, 6))
    r2 = all(l[i] for i in range(6, 9))
    x0 = all(l[i] for i in [0, 4, 8])
    x1 = all(l[i] for i in [2, 4, 6])
    return c0 or c1 or c2 or r0 or r1 or r2 or x0 or x1


def solve(string):
    *anb,  = map(int, string.split())
    a, n, b = anb[:9], anb[9], anb[10:]
    return "Yes" if check([_a in b for _a in a]) else "No"


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans*= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main() {
    ll A,B,C;
    cin>>A>>B>>C;
    if(A%2==0||B%2==0||C%2==0){
        cout<<0<<endl;
    }
    else{
        ll D=min(A*B,A*C);
        cout<<min(D,B*C)<<endl;
    }
}





Measured memory_bytes: 3584
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
//#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 100 + 5, LG = 19, MOD = 998244353;
const int SQ =225;
int A, B, C, D;
int dp[3005][3005];
int solve(int X, int Y){
  if(X > C || Y > D)
    return 0;
  if(X == C && Y == D)
    return 1;
  int &ret = dp[X][Y];
  if(~ret)
    return ret;
  ret = 1ll * solve(X + 1, Y) * Y % MOD;
  ret += 1ll * solve(X, Y + 1) * X % MOD;
//  cout << X << ' ' << Y << ' ' << solve(X-1,Y) * Y << ' '<< solve(X,Y-1) * X << ' ' << (X-A+Y-B)  << endl;
  ret -= 1ll * solve(X+1,Y+1) * (X * Y) % MOD;
  if(ret >= MOD)ret -= MOD;
  if(ret < 0)ret += MOD;
  return ret;
}
//set<vector<string>>st;
//vector<string> vs;
//void bt(int x, int y){
//  if(x==C&&y==D){
//    st.insert(vs);
//    return;
//  }
//  if(y < D){
//  ///add column
//    for(int i = 0; i < x; i++){
//      vs[i][y] ^= 1;
//      bt(x, y + 1);
//      vs[i][y] ^= 1;
//    }
//  }
//  if(x < C){
//  ///add row
//    for(int i = 0; i < y; i++){
//      vs[x][i] ^= 1;
//      bt(x+1, y);
//      vs[x][i] ^= 1;
//    }
//  }
//}
//int dp[305][305][305][2];
//vector<int> vp;
//int solve(int idx, int cnt, int lft, bool take){
//  if(idx == vp.size())
//    return (cnt == 0);
//  int &ret = dp[idx][cnt][lft][take];
//  if(~ret)
//    return ret;
//  ///take
//  ret = 0;
//  if(!take){
//    for(int j = 1; j <= vp[idx] && j <= lft; j++){
//        ret += solve(idx + 1, cnt + j, lft - j, 0);
//        if(ret >= MOD)
//          ret -= MOD;
//    }
//  }
//  ret += solve(idx + 1, cnt, lft, 0);
//  if(ret >= MOD)ret -= MOD;
//  if(cnt)
//    ret += solve(idx, cnt - 1, lft, 1);
//  if(ret >= MOD)ret -= MOD;
//
//  return ret;
//}
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
  cin >> A >> B >> C >> D;
  memset(dp,-1,sizeof dp);
  cout << solve(A,B) << endl;


  return 0  ;
}


Measured memory_bytes: 39384
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
	x*=p;
}
char s[100010];
int main()
{
//	freopen("ARC059D.in","r",stdin);
//	freopen("ARC059D.out","w",stdout);
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<len;i++)
		if(s[i]==s[i+1]) { printf("%d %d\n",i,i+1); return 0; }
		else if(i+2<=len&&s[i]==s[i+2]) { printf("%d %d\n",i,i+2); return 0; }
	puts("-1 -1");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string A,B,C;
    cin>>A>>B>>C;
    if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC109
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input;
            input = Console.ReadLine().Split(' ');
            long N = long.Parse(input[0]);
            long X = long.Parse(input[1]);

            long[] dist = new long[N];
            input = Console.ReadLine().Split(' ');
            for (long i = 0; i < N; i++)
            {
                dist[i] = Math.Abs(X - long.Parse(input[i]));
            }

            dist = dist.OrderByDescending(x => x).ToArray();

            long gcd = dist[0];
            //long result = 0;
            for (long i = 0; i < N; i++)
            {
                gcd = CalGcd(gcd, dist[i]);
            }
            Console.WriteLine(gcd);
        }

        static long CalGcd(long x, long y)
        {
            if (y == 0) { return x; }
            return CalGcd(y, x % y);
        }
    }
}


Measured memory_bytes: 25824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int num[10][10],n,ans=0;//10*10にしたのは番兵を含めたため
void move_tree(int now,int cnt,int *check_num){
    if(cnt==n-1){
        for(int i=0;num[now][i]!=0;i++){
            if(check_num[num[now][i]]==0)ans++;
        }
    }
    else{
        for(int i=0;num[now][i]!=0;i++){
            if(check_num[num[now][i]]==0){
                check_num[num[now][i]]=1;
                move_tree(num[now][i],cnt+1,check_num);
                check_num[num[now][i]]=0;
            }
        }
    }
}
int main(){
    int m,check[9]={0,1/*1は始点なので行った扱いにする*/,0,0,0,0,0,0,0},a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        int hoge=0;
        while(num[a][hoge]!=0)hoge++;
        num[a][hoge]=b;
        hoge=0;
        while(num[b][hoge]!=0)hoge++;
        num[b][hoge]=a;
    }
    move_tree(1,1,check);
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
 
using namespace std;
const int maxn = 305;

int ans=1<<30,p[maxn],usd[maxn],a[maxn][maxn],n,m,cnt[maxn];
int main()
{
	#ifdef Amberframe
		freopen("agc018b.in","r",stdin);
		freopen("agc018b.out","w",stdout);
	#endif
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
		scanf("%d",&a[i][j]);
	for (int i=1;i<=n;i++) p[i]=1;
	
	for (int i=1;i<=m;i++)
	{
		int o=0;memset(cnt,0,sizeof cnt);
		for (int j=1;j<=n;j++) {
			while (usd[a[j][p[j]]]) ++p[j];
			int t=a[j][p[j]];
			if (++cnt[t]>cnt[o]) o=t;
		}
		ans=min(ans,cnt[o]);usd[o]=1;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n,a[100],c[9]={},ans=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    a[i]=a[i]>=3200?3200:a[i];
    c[a[i]/400]++;
  }
  for(i=0;i<8;i++){
    ans+=c[i]>0;
  }
  if(ans==0){
    ans++;
    c[8]--;
  }
  printf("%d %d",ans,ans+c[8]);
}

Measured memory_bytes: 128
result_all = []
counter = 0
while True:
    N,M,P = map(int, input().split())
    if(N == 0 and M == 0 and P == 0): break
    X = [int(input()) for i in range(N)]
    X_sum = sum(X)
    if(X[M-1] == 0):
        result_all.append(0)
        continue
    result = ((X_sum * 100) - ((X_sum * 100) * (P / 100))) / X[M-1]
    result_all.append(result)

for i in range(len(result_all)):
    print(int(result_all[i]))



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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a != 0 ? gcd (b % a, a) : b; }

int n;
int m;
int a, b;
vi res;

int go (int a, int b, int cur) {
	assert (a != b);
	if ((cur & (cur - 1)) == 0) {
		res.pb (a);
		res.pb (b);
		re 0;
	}
	for (int i = 0; i < n; i++)
		if (((cur >> i) & 1) == 1 && (((a ^ b) >> i) & 1) == 1) {
			int x = -1, y = -1;
			for (int j = 0; j < n; j++)
				if (i != j && ((cur >> j) & 1) == 1) {
					x = a ^ (1 << j);
					y = a ^ (1 << j) ^ (1 << i);
					break;
				}
			assert (x != -1);
			go (a, x, cur ^ (1 << i));
			go (y, b, cur ^ (1 << i));
			break;
		}
	re 0;
}

int main () {
	scanf ("%d%d%d", &n, &a, &b);
	if (__builtin_popcount (a ^ b) % 2 == 0) {
		printf ("NO\n");
		re 0;
	}
	printf ("YES\n");
	go (a, b, (1 << n) - 1);
	set<int> all;
	assert (sz (res) == (1 << n));
	for (int i = 0; i < sz (res); i++) {
		printf ("%d ", res[i]);
		assert (!all.count (res[i]));
		all.insert (res[i]);
		assert (i == 0 || __builtin_popcount (res[i] ^ res[i - 1]) == 1);
	}
	printf ("\n");
	return 0;
}

Measured memory_bytes: 7672
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int n, i;
	cin >> n;
	vector <pair <int, int> > v(n);
	fo(i, 0, n){
		cin >> v[i].f;
		v[i].s = i + 1;
	}
	sort(v.begin(), v.end());
	fo(i, 0, n)
	cout << v[i].s << ' ';
}


Measured memory_bytes: 1664
# coding: utf-8

n = int(input())
a = list(map(int, raw_input().split()))

a.sort()

ans = 1000000007
for x in range(a[0], a[n - 1]):
    keep = 0
    for i in range(n):
        keep += (a[i] - x) * (a[i] - x)
    ans = min(keep, ans)

if a[0] == a[n - 1]:
    ans = 0
print(ans)

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

using namespace std;

#define int long long

struct Node
{
	int ptr[2];
}tr[200010];
int cnt,root(0);

int lowbit(int x)
{
	return x&(-x);
}

string s;
void ins(string s)
{
	int now=root;
	int len=s.size();
	for(int i=0;i<len;i++)
	{
		if(!tr[now].ptr[s[i]-'0'])
		{
			tr[now].ptr[s[i]-'0']=++cnt;
		}
		now=tr[now].ptr[s[i]-'0'];
	}
}

int l;
int dfs(int now,int dpth)
{
	if((!now)&&dpth)
	{
		return lowbit(l-dpth+1);
	}
	return dfs(tr[now].ptr[1],dpth+1)^dfs(tr[now].ptr[0],dpth+1);
}

main()
{
	int n;
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		ins(s);
	}
	if(dfs(root,0))
	{
		cout<<"Alice\n";
	}
	else
	{
		cout<<"Bob\n";
	}
}

Measured memory_bytes: 5120
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double dx, dy;
    dx = x2 - x1;
    dy = y2 - y1;
    double buf;
    buf = dx * dx + dy * dy;
    double result;
    result = sqrt(buf);
    //double dout;
    //dout = result * pow(10.0, 4);
    //dout = (double)(int)(dout);
    
    //printf("%.8f", dout * pow(10.0, -4));
    
    printf("%.8f", result);
	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<ll, ll> P;

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

int main() {
	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	rep(i,n){
		cin>>a[i];
	}
	ll kai[n+1];
	rep(i,n){
		kai[i]=-1;
	}

kai[1]=0;
ll now=1;
ll cnt=0;
ll d=0;
while(true){
	cnt++;
now=a[now];
if(cnt==k){
	cout<<now<<endl;
return 0;}
if(kai[now]!=-1){
d=cnt-kai[now];
break;
}
else{
	kai[now]=cnt;
}

}

k=(k-cnt)%d;
for(int i=1;i<=k;i++){
	now=a[now];
}

cout<<now<<endl;
return 0;





}




Measured memory_bytes: 6760
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

    private static FastScanner sc;

    private static class FastScanner {
        private Scanner sc;

        FastScanner() {
            sc = new Scanner(System.in);
        }

        public int ni() {
            return sc.nextInt();
        }

        public String ns() {
            return sc.nextLine();
        }

        public long nl() {
            return sc.nextLong();
        }

        public double nd() {
            return sc.nextDouble();
        }
    }

    private static void print(Object o) {
        System.out.print(o);
    }

    private static void println(Object o) {
        System.out.println(o);
    }
    
    private static void printf(String s, Object... data) {
    	System.out.printf(s, data);	
    }

    public static void main(String[] args) {
        sc = new FastScanner();

        solve();
    }

    private static void solve() {
       int n = sc.ni();

       println(n + n*n + n*n*n);
    }
}

Measured memory_bytes: 35664
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        
        long x = scan.nextLong();
        long y = scan.nextLong();

        long i = x;
        long cnt = 1;
        while(i*2 <= y){
            i *= 2;
            cnt++;
        }
        System.out.println(cnt);
        scan.close();
        
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string w;
    cin >> w;
    map<char, int> mp;
    rep(i, 0, w.size())
        mp[w[i]]++;
    for (auto x:mp)
    {
        if (x.second % 2 != 0)
            return cout << "No", 0;
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
//
// Created by Naman Bhalla on 2019-08-18.
//

#include <bits/stdc++.h>

using namespace std;

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

    string s, t;
    cin >> s >> t;

    vector< vector< int > > ind(26);

    long long int n = s.size();

    for(int i = 0; i < n; ++i){
        ind[s[i] - 'a'].push_back(i);
    }

    int m = t.size();
    long long int nums = 0;

    long long int li = -1;

    for(int i = 0; i < m; ++i){
        int l = 0;
        int r = ind[t[i] - 'a'].size() - 1;
        if(r == -1){
            cout << -1 << "\n";
            return 0;
        }
        if(li >= ind[t[i] - 'a'][r]){
            li = -1;
            ++nums;
        }
        int ans = -1;
        int mid;

        while(l <= r){
            mid = l + (r - l)/ 2;
            if(ind[t[i] - 'a'][mid] > li){
                ans = ind[t[i] - 'a'][mid];
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }

        li = ans;
    }

    cout << nums * n + li + 1ll<< "\n";


    return 0;
}

Measured memory_bytes: 1228
#include <iostream>
using namespace std;
int ic[100002],icL[100002];
int maxer=0;
	int N,L;
void pick(int i){
		if(icL[i-1]<icL[i] && icL[i+1] <icL[i]){
			ic[i]=max(ic[i-1],ic[i+1])+L-icL[i];
			maxer=max(ic[i],maxer);
			icL[i]=0;
			pick(i+1);
			pick(i-1);
		}

}
int main() {

	cin >> N >> L;
	icL[0]=0;
	icL[N+1]=0;
	for ( int i=1;i<=N;i++)
		cin >> icL[i];
	for(int i=1;i<=N;i++){
		pick(i);
	}
	cout << maxer << endl;
	return 0;
}

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


int main() {
   int n, m, penalty = 0, correct = 0;
   string k;
   cin >> n >> m;
   vector<int> checks(n, 0);


   for (int i = 0, p; i < m; i++){
   		cin >> p >> k;

   		if (k == "WA" && checks[p-1] >= 0){
   			checks[p-1]++;
   		}

   		else if(k == "AC" && checks[p-1] >= 0){
   			penalty += checks[p-1];
   			correct++;
   			checks[p-1] = -1;
   		}
   }

   cout << correct << " " << penalty;

}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

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

int n,s;
ll x[100005],a[100005];

int main(){
	n=readint(); s=readint();
	for(int i=1;i<=n;i++) x[i]=readint(),a[i]=readint();
	ll l=1,r=n,ans=0;
	while(1){
		if(s<x[l]) return printf("%lld\n",ans+x[r]-s),0;
		if(s>x[r]) return printf("%lld\n",ans+s-x[l]),0;
		ans+=x[r]-x[l];
		if(a[l]>=a[r]) while(a[l]>=a[r]&&s>x[l]&&s<x[r]) a[l]+=a[r],r--;
		else while(a[l]<a[r]&&s>x[l]&&s<x[r]) a[r]+=a[l],l++;
	}
	return 0;
}

Measured memory_bytes: 1792
R,G,B,N = map(int, input().split())
ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        if N-r*R-g*G >= 0 and (N-r*R-g*G) % B == 0:
            ans += 1

print(ans)



Measured memory_bytes: 40940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b,c,ans;
    cin >> a >> b >> c;
    if(a == b && b == c){
        ans = 1;
    }else if(a != b && b != c && c != a){
        ans = 3;
    }else{
        ans = 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long long a[5000];
	long long ask[5000];
	int max;
	int i;
	int j;
	int k;
	int sign;
	long long saidaiti;
	long long now;
	while(1) {
		scanf("%d",&max);
		if(max==0)break;
		for(i=0;i<max;i++)scanf("%llu",&a[i]);
		for(i=0,j=-1,sign=0;i<max;i++) {
			if(a[i]*sign<=0 && a[i]!=0) {
				sign=(a[i]>0)?1:-1;
				j++;
				ask[j]=0;
			}
			ask[j]+=a[i];
		}
		for(i=0;i<=j;i++) {
			if(ask[i]>=0)break;
		}
		if(i>j) {
			saidaiti=a[0];
			for(i=1;i<max;i++) {
				if(a[i]>saidaiti)saidaiti=a[i];
			}
		} else {
			max=j+1;
			saidaiti=ask[0];
			for(i=1;i<=max;i++) {
				for(j=0;j<=max-i;j++) {
					now=0;
					for(k=j;k<j+i;k++)now+=ask[k];
					if(now>saidaiti)saidaiti=now;
				}
			}
		}
		printf("%d\n",saidaiti);
	}
	return 0;
}

Measured memory_bytes: 460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> vec;
    rep (i, 0, n) {
        int a;
        cin >> a;
        vec.push_back (a);
    }
    sort (vec.begin(), vec.end(), greater<int>());
    pint bc[m];
    rep (i, 0, m) { cin >> bc[i].second >> bc[i].first; }
    sort (bc, bc + m, greater<pint>());
    int cnt = 0;
    int i = 0, j = 0;
    int ans = 0;
    while (cnt < n) {
        if (i < n && j < m) {

            if (vec[i] > bc[j].first) {
                ans += vec[i];
                i++;
                cnt++;
            } else {
                if (n - cnt > bc[j].second) {
                    ans += bc[j].second * bc[j].first;
                    cnt += bc[j].second;
                    j++;
                } else {
                    ans += bc[j].first * (n - cnt);
                    j++;
                    cnt = n;
                }
            }
        } else if (i < n) {
            ans += vec[i];
            i++;
            cnt++;
        } else {
            if (n - cnt > bc[j].second) {
                ans += bc[j].second * bc[j].first;
                cnt += bc[j].second;
                j++;
            } else {
                ans += bc[j].first * (n - cnt);
                j++;
                cnt = n;
            }
        }
        // cout << i << " " << j << " " << cnt << "\n";
    }
    cout << ans << "\n";
}


Measured memory_bytes: 5644
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    string s;
    int n;
    cin>>n>>s;
    int a = 0;
    for(int i = 0; i < min(sz(s), n); i++)cout<<s[i];
    if(sz(s)>n)cout<<"...";
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3648