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

Measured memory_bytes: 3620
#include<stdio.h>

int main(void) {

	int a, b, w;
	int ans;

	scanf("%d%d%d", &w, &a, &b);

	if (a + w <= b) {
		ans = b - a - w;
	}
	else if (a <= b && b <= a + w) {
		ans = 0;
	}
	else if (b <= a && a <= b + w) {
		ans = 0;
	}
	else {
		ans = a - b - w;
	}

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



	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        string S = Console.ReadLine();

        var list = new List<string>();
        for(var i = 'a'; i <= 'z'; i++)
        {
            list.Add(i.ToString());
        }

        foreach(var x in S)
        {
            list.Remove(x.ToString());
        }

        if (list.Count == 0) Console.WriteLine("None");
        else Console.WriteLine(list[0]);
        Console.ReadLine();
    }

}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


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

int main() {
  int N,M;
  cin>>N>>M;
  vector <int> X(M);
  for (int i(0);i<M;i++) cin>>X[i];
  sort(X.begin(),X.end());
  vector <int> dif(M-1);
  for (int i(0);i<M-1;i++) {
    dif[i]=X[i+1]-X[i];
  }
  sort(dif.begin(),dif.end());
  int diff=X[M-1]-X[0];
  int sum(0);
  if (M-N>0){
    for (int i(M-N);i<M-1;i++){
      sum+=dif[i];
    }
  }else{
    cout << 0 <<endl;
    return 0;
  }
  // cout << diff << " " << sum <<endl;
  cout << diff - sum <<endl;
  return 0;
}


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

int main(){
    int n, a, min = 1000000, max = -1000000;
    long long sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(a < min) min = a;
        if(a > max) max = a;
        sum = sum + a;
    }
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const ll N = 100005, MOD = 1e9 + 7;

ll n, k;

ll a[N];

ll A, B;

ll ans;

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    A = k * (k - 1) / 2;
    B = k * (k + 1) / 2;
    A %= MOD;
    B %= MOD;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++){
        if (a[i] < a[j])
            ans += A;
        else if (a[i] > a[j])
            ans += B;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	string S;
	cin >> S;
	for (int i = 0; i < (int)S.size(); i++)cout << "x";
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);


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

ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}

ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}

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

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n,m;
        cin>>n>>m;
        static ll a[10005][1<<12];
        REP(i,0,1<<12)
        {
            REP(j,0,10005)
            {
                a[j][i]=M;
            }
        }
        a[0][0]=0;
        REP(i,0,m)
        {
            ll v,b;
            cin>>v>>b;
            ll t=0;
            REP(j,0,b)
            {
                ll tt;
                cin>>tt;
                t|=(((ll)1)<<(tt-1));
            }
            REP(j,0,1<<n)
            {
                a[i+1][j]=min(a[i+1][j],a[i][j]);
                a[i+1][t|j]=min(a[i+1][t|j],v+a[i][j]);
            }
        }
        if(a[m][(1<<n)-1]==M) cout<<-1;
        else cout<<a[m][(1<<n)-1];
    }

    return 0;
}


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

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

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

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin>>N;
	LL ans = 0;
	for (LL i = 1; i*i <= N; i++) {
		ans = i * i;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
/*
Railway Connection(https://onlinejudge.u-aizu.ac.jp/problems/1182)
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int INF = 1<<29;


void solve(void){
	int N, M, C, S, G;

	while (cin >> N >> M >> C >> S >> G) {
		if (!N) break;
		S--, G--;

		//dis[c][x][y] := cを使ってxからyに行く時の最短経路
		vector <mat> dis(C, mat (N, vec (N, INF)));

		rep(M, i)
		{
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--, y--, c--;
			dis[c][x][y] = dis[c][y][x] = min(dis[c][x][y], d);
		}

		rep(C, c)
		{
			//各Cの距離についてWF
			rep(N, k) rep(N, i) rep(N, j)
			{
				dis[c][i][j] = min(dis[c][i][j], dis[c][i][k] + dis[c][k][j]);
			}
		}

		vec ps(C);
		rep(C, i) cin >> ps[i];

		//cost[x][y] := xからyに行く時の最低コスト
		mat cost(N, vec(N, INF));

		rep(C, c)
		{
			vec qs(ps[c]+1, 0), rs(ps[c]);
			//qs[0] = 0, qs[ps[i]] = INF
			qs[ps[c]] = INF;
			rep(ps[c]-1, j) cin >> qs[j+1];
			rep(ps[c], j) cin >> rs[j];

			rep(N, x) rep(N, y)
			{

				//Cを使った時のxからyへの運賃を計算

				int d = dis[c][x][y];
				if (d == INF)
				{
					continue;
				}

				int fare = 0;
				rep(ps[c]+1, p)
				{
					if (d > qs[p])
					{
						fare += min(qs[p+1]-qs[p], d-qs[p]) * rs[p];
					}
				}

				//今の鉄道会社を使ったほうが安ければx->yの運賃を更新
				cost[x][y] = min(cost[x][y], fare);

			}

		}

		//コストについてWF
		rep(N, k) rep(N, i) rep(N, j)
		{
			cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
		}

		if (cost[S][G] == INF)
		{
			cout << -1 << endl;
		}
		else
		{
			cout << cost[S][G]  << endl;
		}

	}

}

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



Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;

  cin >> a >> b;
 
  if ( (a*b) % 2 == 0 ) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define inc(i) (++ (i))
#define dec(i) (-- (i))
#define Rep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define Dep(i, a, b) for(register int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))

using namespace std;

int a, b, c, tem, sum = 0; 

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

inline void write(int x){
  	static int sta[35];int top=0;
  	do{sta[top++]=x%10,x/=10;}while (x);
  	while(top)putchar(sta[--top]+48);
}

signed main()
{
    a = read(); b = read(); c = read();
    if(a > b * c) printf("No");
    else printf("Yes");

    return 0;
}

Measured memory_bytes: 3600
#include<iostream>

using namespace std;

int main(){

    ios::sync_with_stdio(false);

    char s[100000];
    int cont1=0,cont2=0;

    cin>>s;

    for(int i=0;s[i]!='\0';i++){
        if(i%2==0){
            if(s[i]=='1'){
                cont2++;
            }
            else{
                cont1++;
            }
        }
        else{
            if(s[i]=='1'){
                cont1++;
            }
            else{
                cont2++;
            }
        }
    }

    if(cont1<cont2)cout<<cont1<<endl;
    else cout<<cont2<<endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> coord;
ll A[1000000];
coord BC[1000000];
bool comp(const ll& left, const ll& right) {
    return left < right;
}
bool comp2(const coord& left, const coord& right){
    return left.second > right.second;
}
int main(){
    ll n,m;
    cin >> n >> m;
    for(ll i=0; i<n; i++) cin >> A[i];
    for(ll i=0; i<m; i++) cin >> BC[i].first >> BC[i].second;
    
    std::sort(A, A+n, comp);
    std::sort(BC, BC+m, comp2);
  
    ll start =0;
    for(ll i=0; i<m; i++){
        ll cnt=0;
        for( ll j=start; j<n; j++){
            if( A[j] > BC[i].second ) {
                break;
            }else{
                A[j] = BC[i].second;
                cnt++;
            }
            if( cnt==BC[i].first ) break;
        }
        start+= cnt;
    }
    //for( int i=0; i<n; i++) cout << A[i] << " " ;
    //cout << endl;
    ll res=0;
    for(ll i=0; i<n; i++){
        res += A[i];
    }
    cout << res << endl;
    return 0;
}


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

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

Measured memory_bytes: 256
def main():
    n = int(input())
    verdicts = ['AC','WA','TLE','RE']
    count = [0]*4
    for i in range(n):
        s = input()
        count[verdicts.index(s)] += 1

    for i in range(4):
        print(verdicts[i],'x',count[i])

        

main()


Measured memory_bytes: 69888
#define NAME "a"

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cctype>
#include <cassert>
#include <memory>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <iterator>

#define pb push_back
#define mp make_pair
#define frs first
#define snd second

using namespace std;

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 7;
const ll INFLONG = (ll) 1e18 + 7;
const double EPS = 1e-9;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<string> vs;

typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;

template <typename T>
T sqr(T a) {
    return a * a;
}

void solve() {
    int n, k;
    scanf("%d %d", &n, &k);
    vi a(n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    sort(a.begin(), a.end());
    int ans = 0;

    for (int i = 0; i < k; i++) {
        ans += a[i];
    }

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

int main() {
    srand(time(0));

//    freopen(NAME".in", "r", stdin);
  //  freopen(NAME".out", "w", stdout);

    int T = 1;

    while (T--) {
        solve();
    }

//    printf("%.3lf\n", (double) clock() / CLOCKS_PER_SEC);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i = 0; i < N; i++)
    cin >> d.at(i);
  int cnt = 0;
  vector<int> sort(N);
  for (int i = 0; i < N; i++){
    int max = 0;
    int max_j = -1;
    for (int j = 0; j < N; j++){
      if (max < d.at(j)){
        max_j = j;
        max = d.at(j);
      }
    }
    sort.at(i) = max;
    d.at(max_j) = 0;
    if (i != 0){
      if (sort.at(i) != sort.at(i-1))
        cnt++;
    }else
      cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a, b, c, d, e, f, g;
int main() {
	cin >> a >> b >> c >> d >> e >> f;
	g = a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500;
	if (g >= 1000) { cout << '1' << endl; }
	else { cout << '0' << endl; }
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N, x;
    cin >> N >> x;
    vi a;
    a.resize(N);
    REP(i, N)
    cin >> a[i];

    sort(ALL(a));

    ll ans = 0;
    REP(i, N)
    {
        x = x - a[i];
        if (x >= 0)
            ans++;
        else
            break;
    }
    if (x != 0 and x > 0)
        ans--;
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
sanka = [K for _ in range(N)]

for ai in A:
    sanka[ai-1] += 1

for i in range(N):
    if sanka[i] - Q > 0:
        print("Yes")
    else:
        print("No")


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

int main() {
  string s;
  cin >> s;
  
  string ans = "";
  
  for(int i = 0; i < s.size(); i ++){
    s.at(i) = 'x';
    ans += s.at(i);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;


int main(){
  int n;
  cin >> n;
  bool flag = false;
  for(int i = 1; i < 10; i++){
    if(n > 81) break;
    if(n % i == 0 && n / i < 10) flag = true;
  }
  if(flag) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n, m;
    n = in();
    m = in();
    int c = m;
    rep(i, n){
        int add, sub;
        add = in();
        sub = in();
        c += add;
        c -= sub;
        if (c < 0){
            return !puts("0");
        }
        m = max(m, c);
    }
    printf("%d\n", m);
    return (0);
}

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

int main() {
    int n;
    cin >> n;
    int p[n], a[n] = {}, b[n] = {};
    for (int i = 0; cin >> p[i]; i++) {
    }
    for (int i = n - 1; i >= 0; i--) {
        a[p[i] - 1] += i + 1;
        b[p[i] - 1] += i + 1;
    }
    for (int i = 1; i < n; i++) {
        a[i] += a[i - 1];
        b[n - i - 1] += b[n - i];
    }
    for (int i = 0; i < n; i++) {
        a[i] += i + 1;
        b[n - 1 - i] += i + 1;
    }
    for (auto i : a) {
        cout << i << ' ';
    }
    cout << '\n';
    for (auto i : b) {
        cout << i << ' ';
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define M 100005
#define mod 1000000007
#define ll long long
int n,k,A[M],H[M];
struct node {
	int nxt,to;
}E[2*M];
int tot;
void link(int a,int b){
	E[++tot].nxt=H[a];
	E[tot].to=b;
	H[a]=tot;
}
ll IN[M];
ll dfs(int x,int f,int d){
	ll ret1=k-d;
	int cnt=-1;
	for(int i=H[x];~i;i=E[i].nxt){
		int v=E[i].to;
		if(v==f)continue;
		cnt++;
		if(x!=1)ret1=ret1*dfs(v,x,2+cnt)%mod;
		else ret1=ret1*dfs(v,x,1+cnt)%mod;
	}
	return ret1;
}
int main() {
	scanf("%d %d",&n,&k);
	memset(H,-1,sizeof(H));
	IN[1]=1;
	for(int i=2;i<=n;i++)
		IN[i]=IN[i-1]*i%mod;
	for(int i=1;i<n;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		link(a,b);
		link(b,a);
	}
	printf("%lld\n",dfs(1,0,0));
	return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi a(3),b(3);
	vi ap(4);
	rep(i,3)cin>>a[i]>>b[i];
	rep(i,3){
		ap[a[i]-1]++;
		ap[b[i]-1]++;
	}
	sort(all(ap));
	YN(ap[0]==1&&ap[1]==1&&ap[2]==2&&ap[3]==2);
}

Measured memory_bytes: 256
import math
N = int(input())

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


B = sorted([a - i for i, a in enumerate(A, start=1)])

ans = []

if N % 2 == 1:
    b = B[N // 2]
    ans.append(sum([abs(x - b) for x in B]))
else:
    b_left = (B[N // 2 - 1] + B[N // 2]) // 2
    b_right = math.ceil((B[N // 2 - 1] + B[N // 2]) / 2)
    ans.append(sum([abs(x - b_left) for x in B]))
    ans.append(sum([abs(x - b_right) for x in B]))

print(min(ans))


Measured memory_bytes: 33304
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

p = a[0]
t = 0
for i in range(n):
    j = a[i]
    if a[i] == p + 1:
        t = t + b[j-1] + c[j-2]
    else:
        t += b[j-1]
    p = a[i]

print(t)

Measured memory_bytes: 9136
state = input()
length = len(state)

adder = 0
ans_1=""
ans_2=""

#make right answer
for a in range(length):
  adder = (adder + 1)%2 
  ans_1 = ans_1 +str(adder)
  #ans_2 = ans_2 +str((adder+1)%2)

#Pattern match
counter = 0
for b in range(length):
  if state[b] == ans_1[b]:
    counter += 1

if counter >= length/2:
  counter = length - counter

#print(ans_1)
print(counter)

Measured memory_bytes: 3188
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_set>
using namespace std;


int main() {
	int N, K, d,x;
	cin >> N >> K;
	unordered_set<int> s;
	while (K--)
	{
		cin >> d;
		for (int i = 0; i < d; ++i)
		{
			cin >> x;
			s.insert(x);
		}
	}
	cout << (N - s.size()) << endl;
	return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> lw(n), re(n);
    for (int i=1; i<n; i++) {
        lw[i] = lw[i-1];
        if (s[i-1] == 'W') lw[i]++;
    }
    for (int i=n-2; i>=0; i--) {
        re[i] = re[i+1];
        if (s[i+1] == 'E') re[i]++;
    }
    int ans = n;
    for (int i=0; i<n; i++) {
        ans = min(ans, lw[i] + re[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
void solve() {
	while (true) {
		int n, a, b, c, x;
		cin >> n >> a >> b >> c >> x;
		if (n == 0) return;
		vector<int> inputs;
		REP(i, n) {
			int d;
			cin >> d;
			inputs.push_back(d);
		}
		reverse(ALL(inputs));
		int ok = -1;
		for (int q = 0; q <= 10000; ++q) {
			if (inputs.back() == x) {
				inputs.pop_back();
				if (inputs.size() == 0) {
					ok = q;
					break;
				}
			}
			x = a * x + b;
			x %= c;
		}
		cout << ok << endl;
	}
}
#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<stdint.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long int
using namespace std;

int32_t main(){
	int m,d,c=0;
	cin>>m>>d;
	for(int i=22;i<=d;i++){
		if(i%10<2)continue;
		if((i%10)*(i/10)<=m){
			c++;
		}
	}
	cout<<c;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
	string s;
	int a;
	cin>>a>>s;
	if(a>=3200){
		cout<<s;
	}else{
		cout<<"red";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll N,n,h,w;
int main(){
    cin >> N;
    for(h=1;h<=3500;h++){
        for(n=1;n<=3500;n++){
            ll a = 4*h*n-N*n-N*h;
            ll b = N*h*n;
            if(a>0){
                if(!(b%a)){
                    printf("%lld %lld %lld\n",h,n,b/a);
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
n=int(input())

if n<=104:
    print(0)
elif n>=105 and n<=134:
    print(1)
elif n>=135 and n<=164:
    print(2)
elif n>=165 and n<=188:
    print(3)
elif n>=189 and n<=194:
    print(4)
elif n>=195:
    print(5)

Measured memory_bytes: 3060
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=lambda x:int(math.floor(x)),lambda x:int(math.ceil(x))
from functools import reduce;gcd=lambda*x:reduce(math.gcd,x);lcm=lambda*x:reduce(lambda x,y:(x*y)//gcd(x,y),x,1)
from collections import deque
Yes=lambda b:print("Yes"if b else"No");YES=lambda b:print("YES"if b else"NO")
is_even=lambda x:True if x%2==0 else False

def is_palindrome(s):
  n=len(s);b=True
  for i in range(int(0.5*n)):
    if s[i]!=s[n-i-1]:b=False
  return b

def main():
  a,b,c=ints()
  Yes(a==b!=c or b==c!=a or c==a!=b)
  
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
A, B, C = map(int, input().split())
minV, midV, maxV = min(A,B,C), A + B + C - min(A,B,C) - max(A,B,C),max(A,B,C)
cnt = 0
work1 = (maxV - minV) // 2
minV = minV + 2 * work1
work2 = (maxV - midV) // 2
midV = midV + 2 * work2
cnt += work1 + work2

if minV == midV == maxV:
    print(cnt)
elif midV == minV:
    print(cnt + 1)
else:
    print(cnt + 2)


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

using namespace std;

vector<int> arr;

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    for(int i = 1; i <= n; ++i){
        int j;
        cin >> j;
        arr.push_back(j - i);
    }

    sort(arr.begin(), arr.end());

    int median = arr[n >> 1];

    long long tot = 0;
    for(int i : arr)
        tot += abs(median - i);

    cout << tot;

    return 0;
}


Measured memory_bytes: 1400
package main

import "fmt"

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

	sumOdd := 0
	sumEven := 0
	for i, v := range s {
		if i%2 == 0 {
			if v != '0' {
				sumOdd++
			} else {
				sumEven++
			}
		} else {
			if v != '1' {
				sumOdd++
			} else {
				sumEven++
			}
		}
	}
	if sumOdd < sumEven {
		fmt.Println(sumOdd)
	} else {
		fmt.Println(sumEven)
	}
}


Measured memory_bytes: 1280
#include <stdio.h>
int main()
{
	int A,B,i;
	scanf("%d\n%d",&A,&B);
	if(A==3 && B==1 || A==1 && B==3)
	{
		printf("2");
	}
	if(A==1 && B==2 || A==2 && B==1)
	{
		printf("3");
	}
	if(A==3 && B==2 || A==2 && B==3)
	{
		printf("1");
	}
	return 0;
	
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int ret=0;
  string s; cin>>s;
  for(int i=1;i<s.size();++i)
    if(s[i]!=s[i-1])
      ret++;
  cout<<ret<<"\n";
  return 0;
}

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

using Lint=long long;

template<class T> class Matrix
{
 public:
    vector<vector<T>> A;
    Matrix(int n):A(n,vector<T>(n)){}
    Matrix(int n,int m):A(n,vector<T>(m)){}

    vector<T>& operator[](int i){ return A[i]; }
    int height(){ return A.size(); }
    int width(){ return A[0].size(); }
    static Matrix I(int n){
        Matrix mat(n);
        for(int i=0;i<n;i++) mat[i][i]=1;
        return mat;
    }

    Matrix& operator+=(Matrix& B){
        int H=height(), W=width();
        for(int i=0;i<H;i++) for(int j=0;j<W;j++)
            A[i][j]+=B[i][j];
        return *this;
    }
    Matrix& operator-=(Matrix& B){
        int H=height(), W=width();
        for(int i=0;i<H;i++) for(int j=0;j<W;j++)
            A[i][j]-=B[i][j];
        return *this;
    }
    Matrix& operator*=(Matrix& B){
        int H=height(), W=B.width(), K=width();
        vector<vector<T>> C(H,vector<T>(W));
        for(int i=0;i<H;i++) for(int j=0;j<W;j++)
            for(int k=0;k<K;k++) C[i][j]+=A[i][k]*B[k][j];
        A.swap(C);
        return *this;
    }
    Matrix operator+(Matrix& B){ return Matrix(*this)+=B; }
    Matrix operator-(Matrix& B){ return Matrix(*this)-=B; }
    Matrix operator*(Matrix& B){ return Matrix(*this)*=B; }
    Matrix pow(Lint K){
        Matrix res=Matrix::I(height());
        Matrix B=*this;
        while(K>0){
            if(K&1) res*=B; B*=B; K>>=1;
        }
        return res;
    }
};

int main()
{
   Lint N; cin>>N;
   int a,b; cin>>a>>b;
   Matrix<Lint> X(2,2),Y(2,2);
   X[0][0]=1; X[0][1]=-1;
   X[1][0]=0; X[1][1]=1;
   Y[0][0]=1; Y[0][1]=0;
   Y[1][0]=1; Y[1][1]=1;

   Matrix<Lint> Z=Y*X;
   Z=Z.pow(N/2);
   if(N%2==1) Z=X*Z;
   Matrix<Lint> ans(2,1);
   ans[0][0]=a;
   ans[1][0]=b;
   ans=Z*ans;
   cout<<ans[0][0]<<' '<<ans[1][0]<<endl;
   return 0;
}




Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
int f(VL &a,int n){
    if(n==2) return 1;
    else{
        return a[n-1]+a[n-2];
    }
};

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    VL a(90);
    a[1]=2;//a[0]は0
    a[2]=1;
    int n;
    cin >> n;
   // cout << f(a,n) << endl;
   FOR(i,3,n+2){
       a[i]=a[i-1]+a[i-2];
   }
   cout << a[n+1] << endl;


}

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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println((c/a)*b);


    }
}


Measured memory_bytes: 35616
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

int main() {
  int N, ans{};
  cin >> N;
  map<int,int> m;
  while(cin >> N) ++m[N];
  for (auto &p:m) ans += p.second - (p.first <= p.second) * p.first;
  cout << ans << endl;
}


Measured memory_bytes: 7944
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int a, b;
    cin >> a >> b;
    int ans  = max(2 * a - 1, 2 * b - 1);
    int ans2 = max(a + b, ans);
    cout << ans2 << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    rep(i, s.size())if(s[i]=='2')ans++;
    cout  << ans << endl;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for(int i = 0; i < N; i++) map.put(i+1, in.nextInt());
		
		int button = 1;
		int count = 0;
		for(int i = 0; i < N; i++){
			button = map.get(button);
			count++;
			if(button == 2){
				System.out.println(count);
				return;
			}
		}
		
		System.out.println(-1);
	}
}


Measured memory_bytes: 66972
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=(1LL<<62);
const double inf=pow(10,10);
double pi=3.141592653589793;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const ll MOD = 1000000007;
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
	init();
	string s;cin>>s;
	if(s[0]==s[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}


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

int main() {
    int n;
    cin >> n;
    map<int, int> mp;

    vector<int> as;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a]++;
        as.push_back(a);
    }
    if (mp.size() > 2) {
        cout << "No" << endl;
        return 0;
    }
    if (mp.size() == 1) {
        // 全員違う色
        if (as.front() == n - 1) {
            cout << "Yes" << endl;
            return 0;
        }

        // 自分のほかに同じ色の帽子の猫がいる
        cout << (n < as.front() * 2 ? "No" : "Yes") << endl;
        return 0;
    }

    int a = -1, b, A, B;
    for (auto& p : mp) {
        if (a == -1) {
            a = p.first;
        } else {
            b = p.first;
        }
    }

    A = min(a, b);
    B = max(a, b);

    if (A + 1 != B) {
        cout << "No" << endl;
        return 0;
    }

    cout << (mp[A] <= A && (B - mp[A]) * 2 <= mp[B] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
long long n;
string s,t;
char c;
int main()
{
	cin>>n;
	do
	{
		c=(n-1)%26+'a';
		s+=c;
		n=(n-1)/26;
	}
	while(n>0);
	for(int i=s.size()-1;i>=0;i--)t+=s[i];
	cout<<t;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

vector<ll> inv, fact, invfact;
void mod_build(int n = 101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0] = inv[0] = invfact[0] = 1;
    inv[1] = 1;
    REP(i, n){
        fact[i+1] = fact[i] * (i+1) % MOD;
        if(i > 0) inv[i+1] = MOD - inv[MOD % (i+1)] * (MOD / (i+1)) % MOD;
        invfact[i+1] = invfact[i] * inv[i+1] % MOD;
    }
}
ll perm(int n, int k){
    if(n < 0 || k < 0 || k > n) return 0;
    return fact[n] * invfact[n-k] % MOD;
}
ll comb(int n, int k){
    if(n<0 || k<0 || k>n) return 0;
    return (fact[n] * invfact[n-k] % MOD) * invfact[k] % MOD;
}

int main(void)
{
    int N;
    cin >> N;
    map<int, ll> s;
    REP(i, N){
        string si;
        cin >> si;
        switch (si[0])
        {
        case 'M':
            s[0]++;
            break;
        case 'A':
            s[1]++;
            break;
        case 'R':
            s[2]++;
            break;
        case 'C':
            s[3]++;
            break;
        case 'H':
            s[4]++;
            break;
        }
    }
    ll ans = 0;
    int n = s.size();
    if(n<3){
        pr(0);
        return 0;
    }
    vector<ll> v(n);
    int it = 0;
    for(auto&& si : s) v[it++] = si.se;
    REP(i, 1<<n){
        if(__builtin_popcount(i)==3){
            ll t = 1;
            REP(j, n){
                if(i & (1<<j)) (t *= v[j]);
            }
            (ans += t);
        }
    }

    pr(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> arr(n);
    std::vector<int> non_dec;
    for (int i = 0; i < n; ++i)
    {
        std::cin >> arr[i];
        if (arr[i] % 10 != 0)
        {
            non_dec.push_back(arr[i]);
        }
    }

    if (non_dec.empty())
    {
        std::cout << 0 << std::endl;
        return 0;
    }

    const int sum = std::accumulate(arr.begin(), arr.end(), 0);
    if (sum % 10 != 0)
    {
        std::cout << sum << std::endl;
        return 0;
    }

    std::sort(non_dec.begin(), non_dec.end());
    std::cout << sum - non_dec.front() << std::endl;
    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    vp in(n);
    rep(i,n)cin >> a[i], in[i] = pii(a[i],i);
    sort(all(in));
    reverse(all(in));
    int ans = 0;
    set<int> st;
    st.insert(n);
    st.insert(-1);
    rep(i,n){
        int ind = in[i].second;
        int num = in[i].first;
        /*
        cout << "set:";
        for(auto x: st)cout << " " << x;
        cout << endl;
        */
        if(i){
            auto left = st.upper_bound(ind);
            auto right = left--;
            int r = *right;
            int l = *left;
            //cout << ind << " " << num << " " << l << " " << r << endl;
            //left
            if(l != -1){
                int l2 = *(--left);
                left++;
                //cout << "!" << l2 << " " << r << endl;
                ans += (l - l2) * (r - ind) * num;

            }
            //right
            if(r != n){
                int r2 = *(++right);
                right--;
                //cout << "!" << l << " " << r2 << endl;
                ans += (ind - l) * (r2 - r) * num;

            }
        }
        //cout <<"!!!!" <<  ans << endl;
        st.insert(ind);
    }
    cout << ans << endl;
}


Measured memory_bytes: 7296
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<unordered_set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<stack>
#include <cstring>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i) < (n); (i)++)
#define rrep(f,i,n) for(int (i)=0;(i) < (f); (i)++)
#define FIND(v, k) find((v).begin(), (v).end(), k)
#define MAX 101
#define MAX_V 15
#define mset(a,x) memset(a,x,sizeof(a))
int main() {
	int n;
	cin >> n;
	int c = 0;
	int i = 1;
	while (c < n) {
		c+=i;;
		i++;
	}
	cout << i -1 << endl;
	return 0;
}


Measured memory_bytes: 256