akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
#define MOD 1000000007

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<ll> llStack;
typedef queue<ll> llQueue;
typedef vector<ll> llVector;
typedef list<ll> llList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  ll N, M, X;
  cin >> N >> M >> X;
  ll C[N];
  ll A[N][M];
  for(int i=0;i<N;i++){
    cin >> C[i];
    for(int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  
  ll ans = MAX;
  ll p = 0;
  ll r[M];
  bool f = true;
  for(int i=0;i<(1<<N);i++){
    for(int j=0;j<M;j++){
      r[j] = 0;
    }
    for(int j=0;j<N;j++){
      if(i & (1<<j)){
        p += C[j];
        for(int k=0;k<M;k++){
          r[k] += A[j][k];
        }
      }
    }
    for(int j=0;j<M;j++){
      if(r[j] < X){
        f = false;
        break;
      }
    }
    if(f){
      ans = min(ans, p);
    }
    //cout << p;
    p = 0;
    f = true;
  }
  if(ans == MAX){
    ans = -1;
  }
  
  
  cout << ans << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.Vector;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		char s[] = sc.next().toCharArray();

		char target[] = {'1', '0'};
		int targetIndex = 0;
		Vector<Integer> vec = new Vector<Integer>();
		int count = 0;
		for(int i = 0; i < n; i++){

			if(s[i] != target[targetIndex]){
				targetIndex++;
				targetIndex %= 2;
				vec.add(count);
				count = 0;
			}

			count++;

			if(i == n - 1){
				vec.add(count);
				break;
			}
		}

		for(int i = 0; i < vec.size(); i++){
//			System.out.println(vec.get(i));
		}

		int sum = 0;
		for(int i = 0; i < Math.min(vec.size(), 2*k + 1); i++){
			sum += vec.get(i);
		}
//		System.out.println("sum = "+sum);

		int tmpSum = sum;
		for(int i = 2; i < vec.size(); i += 2){
			tmpSum -= (vec.get(i - 1) + vec.get(i - 2));
//			System.out.println("remove "+(i - 2)+ " and " + (i - 1));
			if(i + 2*k - 1 < vec.size()){
				tmpSum += vec.get(i + 2*k - 1 );
//				System.out.println("add "+(i + 2*k - 1));
			}
			if(i + 2*k  < vec.size()){
				tmpSum += vec.get(i + 2*k  );
//				System.out.println("add "+(i + 2*k));
			}

//			System.out.println("tmpSum "+tmpSum);
			sum = Math.max(sum, tmpSum);
		}

		System.out.println(sum);
	}

}

Measured memory_bytes: 28304
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  int flag = 1, bra = 0, bramax = 0;
  for(int i = B - 1 - 1; i <= min(C, D) - 1 + 1; i++){
    if(S.at(i) == '.'){
      bra++;
    } else {
      bramax = max(bra, bramax);
      bra = 0;
    }
  }
  bramax = max(bra, bramax);
  int change = 0;
  if(A < B && C < D)change = 0;
  else change = 1;
  int flaga = 1, flagb = 1;
  while(A < C){
    if(S.at(A + 1 - 1) == '.')A++;
    else {
      if(A + 2 <= C){
        if(S.at(A + 2 - 1) == '.')A += 2;
        else flaga = 0;
      } else flaga = 0;
    }
    if(flaga == 0 || A == C)break;
  }
  while(B < D){
    if(S.at(B + 1 - 1) == '.')B++;
    else {
      if(B + 2 <= D){
        if(S.at(B + 2 - 1) == '.')B += 2;
        else flagb = 0;
      } else flagb = 0;
    }
    if(flagb == 0 || B == D)break;
  }
  if((change == 0 || (change == 1 && bramax >= 3)) && flaga == 1 && flagb == 1)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
	string s;
	cin>>s;
	s[5]=' ';
	s[13]=' ';
        cout<<s<<endl;
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Dsu {
    int fa[200005];
    Dsu() {for (int i = 0; i <= 200000; ++ i) fa[i] = i;}
    int Fa(int x) {return x == fa[x] ? x : fa[x] = Fa(fa[x]);}
    void Mg(int u, int v) {fa[Fa(u)] = Fa(v);}
};
Dsu dsu1, dsu2;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m1, m2;
    cin >> n >> m1 >> m2;
    for (int i = 0; i < m1; ++ i) {
        int u, v; cin >> u >> v;
        -- u; -- v; dsu1.Mg(u, v);
    }
    for (int i = 0; i < m2; ++ i) {
        int u, v; cin >> u >> v;
        -- u; -- v; dsu2.Mg(u, v);
    }
    vector <pair <int, int> > p(n);
    vector <pair <int, int> > v;
    for (int i = 0; i < n; ++ i) {
        p[i] = make_pair(dsu1.Fa(i), dsu2.Fa(i));
        v.push_back(p[i]);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; ++ i) {
        cout << upper_bound(v.begin(), v.end(), p[i]) - lower_bound(v.begin(), v.end(), p[i]) << (i + 1 == n ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,m,k;cin >> n >> m >> k;
    int a[n],b[m];
    rep(i,n)cin >> a[i];
    rep(i,m)cin >> b[i];
    vector<int> sa(n+1),sb(m+1);
    rep(i,n)sa[i+1] = sa[i] + a[i];
    rep(i,m)sb[i+1] = sb[i] + b[i];
    int bot = 0;
    int top = 440000;
    auto ok = [&](int c){
        //cことる
        int res = 1001001001;
        rep(na,c+1){
            int ret = 0;
            int nb = c - na;
            if(nb < 0|| nb > m||na < 0 || na > n)continue;
            ret += sa[na];
            ret += sb[nb];
            //trace(c,na,nb,ret);
            res = min(res,ret);

        }
        //trace(res,c);
        return res <= k;



    };
    while(top - bot > 1){
        int mid = (top + bot)/2;
        if(ok(mid))bot = mid;
        else top = mid;
    }
    cout << bot << endl;
    return 0;
}


Measured memory_bytes: 9600
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
using namespace std;
int _P=1000000007;
int main(){
	long long a;
	double b;
	int c;
	cin >> a >> b;
	c = 100 * (b+0.001);
	cout << a*c/100 << endl;
	return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;
  int ans = 0;
  rep(i,n) {
    int a;
    std::cin >> a;
    ans += a;
  }

  std::cout << ans - n << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
int dp[5][202][202];
signed main(){
  int n,m,s,t;
  while(cin>>n>>m>>s>>t,n){
    memset(dp,0,sizeof(dp));
    
    s--;t--;
    vector< vector<int> > Ex(n);
    vector< vector<int> > Gb(n),Ge(n);
    vector< vector<int> > Hb(n),He(n);
    vector< vector<int> > On(n),Op(n);
    using T = tuple<int, int, int>;
    queue<T> qu;
    auto push=[&](int t,int x,int y)->void{
                if(dp[t][x][y]) return;
                dp[t][x][y]=1;
                qu.emplace(t,x,y);
              };
    for(int i=0;i<m;i++){
      int x,y;
      char c;
      cin>>x>>y>>c;
      x--;y--;
      if(c=='a') Ex[y].emplace_back(x);
      if(c=='(') Gb[y].emplace_back(x);
      if(c==')') Ge[x].emplace_back(y);
      if(c=='[') Hb[y].emplace_back(x);
      if(c==']') He[x].emplace_back(y);
      if(c=='+') On[x].emplace_back(y);
      if(c=='*') On[x].emplace_back(y);
      if(c=='+') Op[y].emplace_back(x);
      if(c=='*') Op[y].emplace_back(x);

      if(c=='a') push(0,x,y);     
    }
    
    while(!qu.empty()){
      int t,x,y;
      tie(t,x,y)=qu.front();qu.pop();
      // cout<<t<<" "<<x<<" "<<y<<endl;
      if(t==0){
        for(int z:Gb[x]) push(1,z,y);
        for(int z:Hb[x]) push(2,z,y);
        for(int z:On[y]) push(3,x,z);
        for(int z:Op[x]) push(4,z,y);
      }
      if(t==1){
        for(int z:Ge[y]) push(0,x,z);
      }
      if(t==2){
        for(int z:He[y]) push(0,x,z);
      }
      if(t==3){
        for(int z=0;z<n;z++)
          if(dp[0][y][z]) push(0,x,z);        
      }
      if(t==4){
        for(int z=0;z<n;z++)
          if(dp[0][z][x]) push(0,z,y);        
      }
    }
    
    cout<<(dp[0][s][t]?"Yes":"No")<<endl;
  }
  return 0;
}



Measured memory_bytes: 6780
n = int(input())
l = list(map(int, input().split()))
a = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                if l[i] < l[j]+l[k] and l[j] < l[k]+l[i] and l[k] < l[i]+l[j]:
                    a += 1
print(a)

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>

int main(void) {
    int N;
    int *A;
    int s=0;
    unsigned long int sad=0;
    std::cin >> N;
    A = (int *) malloc(sizeof(int) * N);
    for (int i=0;i < N;i++) {
        std::cin >> A[i];
        s += A[i];
        A[i] = A[i] - (i+1);
    }
    std::sort(A, A+N);
    int idx;
    unsigned long int tmp1=0, tmp2=0, tmp3=0;
    int b1, b2, b3;
    idx = (int) (N/2);
    b1 = A[idx];
    b2 = A[idx+1];
    b3 = A[idx-1];
    for(int i=0;i < N;i++) {
        tmp1 += std::abs(A[i] - b1);
        tmp2 += std::abs(A[i] - b2);
        tmp3 += std::abs(A[i] - b3);
    }
    sad = (tmp1 < tmp2) ? tmp1 : tmp2;
    sad = (sad < tmp3) ? sad : tmp3;

    std::cout << sad << std::endl;

    return 0;
}


Measured memory_bytes: 1024
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

const mod = 1000000007

func mpow(a, b int) int {
	if b == 0 {
		return 1
	} else if b%2 == 0 {
		tmp := mpow(a, b/2)
		return tmp * tmp % mod
	}
	return mpow(a, b-1) * a % mod
}

var fracMemo = []int{1, 1}

func mfrac(n int) int {
	if len(fracMemo) > n {
		return fracMemo[n]
	}
	if len(fracMemo) == 0 {
		fracMemo = append(fracMemo, 1)
	}
	for len(fracMemo) <= n {
		size := len(fracMemo)
		fracMemo = append(fracMemo, fracMemo[size-1]*size%mod)
	}
	return fracMemo[n]
}

var ifracMemo = []int{1, 1}

func mifrac(n int) int {
	if len(ifracMemo) > n {
		return ifracMemo[n]
	}
	if len(ifracMemo) == 0 {
		fracMemo = append(ifracMemo, 1)
	}
	for len(ifracMemo) <= n {
		size := len(ifracMemo)
		ifracMemo = append(ifracMemo, ifracMemo[size-1]*mpow(size, mod-2)%mod)
	}
	return ifracMemo[n]
}

func nCr(n, r int) int {
	if n == r {
		return 1
	}
	if n < r || r < 0 {
		return 0
	}
	ret := 1
	ret *= mfrac(n)
	ret %= mod
	ret *= mifrac(r)
	ret %= mod
	ret *= mifrac(n - r)
	ret %= mod
	return (ret)
}

func main() {
	sc.Split(bufio.ScanWords)

	X, Y := getInt(), getInt()

	a := 2*X - Y
	b := 2*Y - X

	ans := 0
	if a%3 != 0 || b%3 != 0 {
		ans = 0
	} else {
		a /= 3
		b /= 3
		ans = nCr(a+b, a)
	}
	out(ans)
}


Measured memory_bytes: 25216
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N, K, Q;
    scan(N, K, Q);
    auto s = new long[](N);
    foreach (i; 0 .. Q)
    {
        long A = lread();
        A--;
        if (i < K + s[A])
            s[A]++;
    }
    foreach (i; 0 .. N)
    {
        bool b = Q < K + s[i];
        writeln(b ? "Yes" : "No");
    }
}


Measured memory_bytes: 4348
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstdio>
using namespace std;

#define M 100001

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
	return (a.first > b.first);
}


int main() {
	int n;
	cin >> n;
	vector< pair<int,int> > ev;
	vector< pair<int,int> > ov;// ev[v-1] = <cnt,v>
	for (int i = 0; i < M; ++i) {
		ev.push_back(make_pair(0,i+1));
		ov.push_back(make_pair(0,i+1));
	}
	for (int i = 0; i < n; ++i) {
		int v;
		cin >> v;
		if(i%2==0){
			ev[v-1] = make_pair(ev[v-1].first+1,ev[v-1].second);
		}else{
			ov[v-1] = make_pair(ov[v-1].first+1,ov[v-1].second);
		}
	}
	sort(ev.begin(),ev.end(),sortinrev);
	sort(ov.begin(),ov.end(),sortinrev);
//	printf("%d(%d),%d(%d)\n",
//			ev[0].second,ev[0].first,
//			ev[1].second,ev[1].first);
//	printf("%d(%d),%d(%d)\n",
//			ov[0].second,ov[0].first,
//			ov[1].second,ov[1].first);
//	int ei =0,oi=0;
//	while(true){
//		if(ev[ei].second!=ov[oi].second){
//			cout << (n - ev[ei].first - ov[oi].first) << endl;;
//			break;
//		}
//	}
	if(ev[0].second != ov[0].second){
		cout << (n - ev[0].first - ov[0].first) << endl;;
	}else{
		int ret1 = (n - ev[0].first - ov[1].first);
		int ret2 = (n - ev[1].first - ov[0].first);
		cout << ((ret1>ret2)?ret2:ret1) << endl;
	}
	return 0;
}


Measured memory_bytes: 2036
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    vi a(n),res;
    for (int &i: a) cin>>i;
    for (int i=sz(a)-1;i>=0;i--){
        if (a[i]==i+1){
            res.pb(i+1);
            a.erase(a.begin()+i);
            i=sz(a);
        }
    }
    if (sz(a)) cout << -1 << endl;
    else for (auto it=res.rbegin();it != res.rend();it++) 
      cout << *it << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

using namespace std;

int main()
{

    int a;
    cin >> a;
    int b[a];

    for (int i = 0; i < a; i++)
    {
        cin >> b[i];
    }

    int max = 0;
    int count = 0;
    for (int k = 0; k < a-1; k++)
    {
        if (b[k] >= b[k + 1])
        {
            count++;
        }
        else
        {
            if (max < count)
            {
                max = count;
            }
            count = 0;
        }
    }
    if (max < count)
    {
        max = count;
    }
    cout << max << endl;
}

Measured memory_bytes: 640
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// }}}
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;

// O(N^.5)
/// --- divisor {{{ ///
vector< ll > divisor(ll n) {
  vector< ll > res;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      res.emplace_back(i);
      if(i != n / i) res.emplace_back(n / i);
    }
  }
  return res;
}
/// }}}--- ///


int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  auto mm = divisor(m);
  ll ans = 1;
  for(ll d : mm) {
    ll f = m / d;
    if(n <= f) {
      ans = max(ans, d);
    }
  }
  cout << ans << endl;
  return 0;
}


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

ll f(ll b, ll n){
	if(n < b) return n;
	return f(b, n / b) + n % b;
}

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

	ll n, s;
	cin >> n >> s;

	ll ans = 1e18;
	for(ll i = 2; i < 1000000; i++){
		ll res = f(i, n);
		if(res == s){
			ans = min(ans, i);
		}
	}

	for(ll i = 1; i < 1000000; i++){
		ll b = (n - s) / i + 1;
		if(b >= 2 && f(b, n) == s){
			ans = min(ans, b);
		}
	}
	if(s == n) ans = min(ans, s + 1);

	if(ans == 1e18) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N;
  cin >> N;
  vector<string> S(N);
  map<string, int> score;
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (score.count(S.at(i))) {
      score.at(S.at(i))++;
    }
    else {
      score[S.at(i)] = 1;
    }
  }
  int maxcount = 0;
  for (auto p : score) {
    auto count = p.second;
    if (count > maxcount) {
      maxcount = count;
    }
  }
  set<string> result;
  for (auto p : score) {
    auto key = p.first;
    auto count = p.second;
    if (count == maxcount) {
      result.insert(key);
    }
  }
  for (auto value : result) {
    cout << value << endl;
  }
}

Measured memory_bytes: 34816
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	int x, y;
	cin >> x >> y;
	int a, b;
	a = 2 * x - y / 2.0;
	b = y / 2 - x;
	if (a >= 0 && b >= 0 && y%2==0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

int main() {

	vector<int> v;
	int i;
	int a;

	for (i = 0; i < 3; i++) {
		cin >> a;
		v.push_back(a);
	}

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

	for (i = 0; i < 3; i++) {
		if (i != 2) cout << v[i] << " ";
		if (i == 2) cout << v[i];
	}
	cout << endl;

	//system("pause");
	return 0;
	
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, m, x, in;
	cin >> n >> m >> x;
	vector<bool> a(n + 1, false); 
	rep(i, m) {
		cin >> in;
		a[in] = true;
	}
	int ansa = 0, ansb = 0;
	rep(i, x) {
		if (a[i])ansa++;
	}
	range(i, x + 1, n + 1) {
		if (a[i])ansb++;
	}
	cout << min(ansa, ansb) << endl;

}

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

int main(){
  vector <int> a(5);
  int k;
  for (int i = 0; i < 5; i++){
    cin >> a.at(i);
  }
  cin >> k;
  int flag = 0;
  for (int i = 0; i < 5; i++){
    for (int j = i+1; j < 5; j ++){
      if (a.at(j) - a.at(i) > k){
        flag = 1;
        break;
      }
    }
  }
  if (flag == 0){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll p[11];
int main() {
    cin>>n;
    REP(i, 0, n) cin>>p[i];

    sort(p, p+n);
    ll sum=0;
    REP(i, 0, n-1){
        sum+=p[i];
    }
    sum+=p[n-1]/2;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
favlist = []
notfav = []
for i in range(n):
    favlist.append(list(map(int, input().split())))

for i in range(1,len(favlist[0])):
    notfav.append(favlist[0][i])

for i in range(n):
    favlist[i][0] = 0

if n != 1:
    for i in range(n):
        for j in range(len(notfav)):
            if not notfav[j] in favlist[i]:
                notfav[j] = 0
    cnt = 0
    for i in range(len(notfav)):
        if notfav[i] != 0:
            cnt += 1
    print(cnt)
else:
    print(len(favlist[0]) - 1)

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
int X,Y,Z;
ll sumY[114514],sumZ[114514];
int main(){
	cin>>X>>Y>>Z;
	ll ans=0;
	vector<pair<ll,pair<ll, ll> > > data;
	rep(i,X+Y+Z){
		ll a,b,c;
		cin>>a>>b>>c;
		ans+=a;
		data.pb(mp(b-c,mp(b-a,c-a)));
	}
	sort(all(data));
	reverse(all(data));
	priority_queue<ll, vector<ll>, greater<ll> > Q,R;
	ll nowsum=0;
	rep(i,data.size()){
		Q.push(data[i].second.first);
		nowsum+=data[i].second.first;
		if(Q.size()>Y){
			ll x=Q.top();
			Q.pop();
			//cout<<x<<endl;
			nowsum-=x;
		}
		sumY[i+1]=nowsum;
	}
	nowsum=0;
	int M=data.size();
	for(int i=M-1;i>=0;i--){
		R.push(data[i].second.second);
		nowsum+=data[i].second.second;
		if(R.size()>Z){
			ll x=R.top();
			R.pop();
			nowsum-=x;
		}
		sumZ[M-i]=nowsum;
	}
	ll ma;
	for(int i=Y;i<=X+Y;i++){
		if(i==Y)ma=sumY[i]+sumZ[X+Y+Z-i];
		ma=max(ma,sumY[i]+sumZ[X+Y+Z-i]);
		
	}
	
	cout<<ans+ma<<endl;
}


Measured memory_bytes: 6512
#include <iostream>

using namespace std;

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

int main()
{
    int a = 0;
    int b = 0;
    
    cin >> a >> b;
    if (a < b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }
    
    cout << gcd(a, b) << endl;
    
    return 0;
}



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

using namespace std;

const int MAX_N = 55;

long long dp[2][MAX_N*MAX_N][MAX_N],ans;

int main()
{
	int n,a,x;
	cin >> n >> a;
	dp[0][0][0]=dp[1][0][0]=1;
	for (int i=1; i<=n; i++)
	{
		cin >> x;
		copy(&dp[1][0][1],&dp[1][n*a][n]+1,&dp[0][0][1]);
		transform(&dp[0][x][1],&dp[0][n*50][n]+1,&dp[1][0][0],&dp[0][x][1],plus<>());
		swap(dp[0],dp[1]);
	}
	for (int k=1; k<=n; k++)
		ans+=dp[1][a*k][k];
	cout << ans;
	return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define INF (int)1e9+4
#define INFL (ll)1e18+4
#define md (int)1e9+7
#define mx 10000000  //use fixed<<setprecion
#define mk make_pair
#define pi pair<int,int>
#define ss second
#define ff first
#define pb emplace_back
#define onell(x) __builtin_popcountll(x)
#define one(x) __builtin_popcount(x)
#define maxi(a) *max_element(a.begin(),a.end());
#define mini(a) *min_element(a.begin(),a.end());
#define all(s) s.begin(),s.end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, a) for (auto& x: a)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sz(x) ((long long)x.size())
#define mez(s) memset(s,0,sizeof s)
#define mex(s) memset(s,-1,sizeof s)
#define metr(s) memset(s,true, sizeof s)
typedef vector<int> vi;
typedef vector<ll>vl;
typedef map<int,int> mp;
typedef queue<int> que;
typedef vector<pi> vp;
void solve(){
int n=0,x=0,y=0,z=0,m=0,k=INF;ll ans=0;
string st,gh;
cin>>gh>>st;n=sz(gh),m=sz(st);
fr(i,0,n-m){x=0;
   rep(j,i,i+m){
   	  if(gh[j]!=st[j-i])
   	  x++;
   }k=min(k,x);
}
cout<<k;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  //cin>>t;
  while(t--){
  	solve();
  }
  return 0;
}


Measured memory_bytes: 3640
#include <cmath>
#include <cstdlib>
#include <cstdio>

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  long n;
  long last;
  long count;

  while( std::cin >> n ) {
    count = 0;
    for(int i = 0; i <= 9; ++i) {
      for(int j = 0; j <= 9; ++j) {
	for(int k = 0; k <= 9; ++k) {
	  last = n - (i + j + k);
	  if( 0 <= last and last <= 9 ) {
	    ++count;
	  }
	}
      }
    }
    
    std::cout << count << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
ll a[200005];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    erep(i, 1, n) {
        cin >> a[i];
        a[i] -= i;
    }
    sort(a+1, a+n+1);
    int mid = 0;
    if (n%2) mid = a[n/2+1];
    else mid = (a[n/2] + a[n/2+1])/2;
    ll ans = 0LL;
    erep(i, 1, n) {
        ans += abs(a[i] - mid);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int z = sc.nextInt();
			int w = sc.nextInt();

			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			int x = Math.abs(a[n - 1] - w);
			int y = x;
			if (1 < n) {
				y = Math.abs(a[n - 2] - a[n - 1]);
			}

			if (x < y) {
				System.out.println(y);
			} else {
				System.out.println(x);
			}
		}
	}
}


Measured memory_bytes: 24276
fun main(args: Array<String>) {
    val str = readLine()!!.toString()
    println(questionB(str))
}

fun questionB(str: String): String {
    if (str.length !in 1..100) return "No"

    val odd = setOf('R', 'U', 'D')
    val even = setOf('L', 'U', 'D')

    str.mapIndexed { index, c ->
        if (index % 2 == 0) c in odd else c in even
    }.all { it }.let {
        if (it) return "Yes"
        return "No"
    }
}

Measured memory_bytes: 35780
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int ans = 0;
    rep(i, 4){
        if(s[i]=='+') ans++;
        else ans--;
    }
    cout << ans;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define  ff first
#define  ss second
#define sz(a) (ll)a.size()
#define lli long long int
#define pb push_back
#define pf push_front
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
#define M 1000000007
#define pi 3.1415926535

int main(){

fast;

ll n;
cin>>n;

ll a[n];
ll val=0;

for(int i=0;i<n;i++){
	cin>>a[i];
	val=val^a[i];
	

}

for(int i=0;i<n;i++){
	cout<<(val^a[i])<<" ";
}
cout<<"\n";



return 0;
}


Measured memory_bytes: 5184
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1)<<"\n";
  
  return 0;
}

Measured memory_bytes: 3604
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(map(str, input().split()))
def pl(a): print(" ".join(list(map(str, a))))


N = ri()
a = rls()
bubble = a[:]

flag = True
while(flag):
    flag = False
    for i in range(1, N):
        if(bubble[-i][1] < bubble[-i-1][1]):
            hold = bubble[-i]
            bubble[-i] = bubble[-i-1]
            bubble[-i-1] = hold
            flag = True
pl(bubble)
print("Stable")  # ?????????Stable

selection = a[:]
for i in range(N):
    minj = i
    for j in range(i, N):
        if(selection[j][1] < selection[minj][1]):
            minj = j
    hold = selection[i]
    selection[i] = selection[minj]
    selection[minj] = hold

pl(selection)
print("Stable" if bubble == selection else "Not stable")

Measured memory_bytes: 7792
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を素因数分解する。
# 3. 2.の結果に含まれる素因数の種類の数＋１が答え

from fractions import gcd
from math import floor

def main():
  a, b = map(int, input().split())
  print(num_facto(gcd(a,b)) + 1)  
  
def num_facto(n):
  ans = 0
  max_n = floor(n ** 0.5) + 1
  is_prime = [True for x in range(max_n + 1)]
  
  for cursor in two_and_odds(max_n):
    if n == 1: break
    if is_prime[cursor]:
      if n % cursor == 0:
        ans += 1
        while n % cursor == 0:
          n = n // cursor
      for i in range(cursor, max_n, cursor):
        is_prime[i] = False
  if n != 1:
    ans += 1
  return ans

def two_and_odds(max_n):
  yield 2
  for i in range(3, max_n, 2):
    yield i
    
if __name__ == "__main__":
  main()


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b;
    cin >> a >> b;

    string s;
    cin >> s;

    if(s.size()!=a+b+1) {
        cout << "No" << endl;
        return 0;
    }

    for(int in=0;in<s.size();in++) {
        if(in==a) {
            if(s.at(in)!='-') { 
                cout << "No" << endl;
                return 0;
            }
        }
        else {
            if(s.at(in)>='0'&&s.at(in)<='9') { 
                ;
            }
            else {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n,a[200010],vis[200010]={},k;

int main(){
	cin>>n>>k;
	ll i,cnt=0;
	for(i=1;i<=n;++i)
		cin>>a[i];
	i=1;

	while(vis[i]==0&&k!=0){
		++cnt;
		vis[i]=cnt;
		i=a[i];
		--k;
	}
	if(k==0){
		cout<<i;
		return 0;
	}
	//cout<<i<<" "<<cnt-vis[i]+1<<" "<<k<<endl;
	
	k%=(cnt-vis[i]+1);
	//cout<<k<<endl;
	while(k!=0){
		i=a[i];
		--k;
	}
	cout<<i;
	
	
	
	
	return 0;
}

Measured memory_bytes: 6756
#include<stdio.h>
#include<stdbool.h>
#define lint long long
#define INF 9223372036854775807
int main(void){
    lint n,count=INF,b,c;
    scanf("%lld",&n);
    int a[n];
    for(lint i=0;i<n;i++)scanf("%d",&a[i]);
    for(lint j=0;;j++){
        bool f=1;
        for(lint i=0;i<n;i++){
            if(a[i]%2==1)f=0;
            a[i]/=2;
        }
        if(!f){
            printf("%lld\n",j);
            return 0;
        }
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll s;
  cin >> s;
  ll e8 = (ll)10e8;
  ll X1 = 0,Y1 = 0,Y2 = 1,X2 = e8;
  ll X3 = e8 - s % e8;
  ll Y3 = (s+X3)/e8;
  if(X3 == e8) {
    X3 = 0;
    Y3 = (s+X3)/e8;
  }
  cout << X1 << " " << Y1 << " " << X2 << " " << Y2 << " " << X3 << " " << Y3 << endl;
  return 0;
}

Measured memory_bytes: 764
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

int main()
{
	long long int n, sum = 0;

	cin >> n;

	vector<long long int> d(n);

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

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += d[i] * d[j];
		}
	}

	cout << sum << endl;
	

	return 0;

}

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

int main() {
    string s;
    string a,b,c;
    cin>>a>>b>>c;
    s=a+b+c;

    if(stoi(s)%4==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
   
    
    return 0;
    }
    

Measured memory_bytes: 3604
n = int(input())
A = []
i = 0 
while i < n:
    A.append(int(input())-1)
    i += 1
used_list = [0]
count = 0
t = 0
while count < n:
    t1 = A[t] 
    count += 1
    if t1 == 1:
        break
#    if t1 in used_list:
#        count = -1
#        break
    used_list.append(t1)
    t = t1
if t1 != 1:
    count = -1
print(count)

Measured memory_bytes: 7856
#include<stdio.h>

int main(){
  int i,j,k;
  int N,A,B;
  scanf("%d %d %d",&N,&A,&B);
  
  if(A*N > B){
    printf("%d\n",B);
  }
  else
    printf("%d\n",A*N);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
bool w[N];
int sz[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') ch=getchar(),o=-1;
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,m,ans=0;
    cin>>n>>m;w[1]=1;
    for(int i=1;i<=n;i++) sz[i]=1;
    for(int i=1;i<=m;i++) {
	int x=gi(),y=gi();
	--sz[x],++sz[y],w[y]|=w[x];
	if(!sz[x]) w[x]=0;
    }
    for(int i=1;i<=n;i++) ans+=w[i];
    cout<<ans;
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int N;
	int B[100001];
	long long ans = 0;
	cin>>N;
	std::vector<int> A(N, INT_MAX);
	for(int i=0; i<N-1; i++) cin>>B[i];
	for(int i=0; i<N-1; i++){
		A[i] = std::min(A[i], B[i]);
		A[i+1] = std::min(A[i+1], B[i]);
	}
	for(int i=0; i<N; i++){
		ans+= A[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

if a[0] > 0:
  A = 0
  t = a[0]
else:
  A = -a[0] + 1
  t = 1
for i in range(1, n):
  if i % 2 == 1:
    if t + a[i] >= 0:
      A += t + a[i] + 1
      t = -1
    else:
      t = t + a[i]
  else:
    if t + a[i] <= 0:
      A += -(t + a[i]) + 1
      t = 1
    else:
      t = t + a[i]

if a[0] < 0:
  B = 0
  t = a[0]
else:
  B = a[0] + 1
  t = -1
for i in range(1, n):
  if i % 2 == 0:
    if t + a[i] >= 0:
      B += t + a[i] + 1
      t = -1
    else:
      t = t + a[i]
  else:
    if t + a[i] <= 0:
      B += -(t + a[i]) + 1
      t = 1
    else:
      t = t + a[i]

print(min(A, B))

Measured memory_bytes: 14468
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);


int main (){
  ll n,x;
  cin>>n>>x;
  while(n!=0||x!=0){
    ll ans=0;
    for(ll i=1;i<=n;i++){
      for(ll j=i+1;j<=n;j++){
        for(ll k=j+1;k<=n;k++){
          if(i+j+k==x)ans++;
        }
      }
    }
    cout<<ans<<endl;
    cin>>n>>x;
  }
}



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

int a()
{
    int a;
    std::cin >> a;
    
    double ans = 2.0 * a * 3.141592;
    
    std::cout << ans << std::endl;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    a();
    return 0;
}

Measured memory_bytes: 3788
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (n, m) = InputLine.to_ia
  a = InputLine.to_ia

  s = a.reduce(:+)

  c = 0
  n.times do |i|
    c += 1 if (a[i] * (4 * m)) >= s
  end
  puts (c >= m ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

bool a[105];

int main()
{
    int n,x,y;
    scanf("%d %d",&x,&n);
    while(n--){
        scanf("%d",&y);
        a[y]=true;
    }
    int p=x,q=x,ans;
    while(true){
        if(!a[p]){
            ans=p;
            break;
        }
        if(!a[q]){
            ans=q;
            break;
        }
        p--,q++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3828
import java.util.Scanner;

//20180508
//11

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		int card = scanner.nextInt();
		int count = 0;
		boolean[][] check = new boolean[4][13+1];
		String[] types = new String[]{"S", "H", "C", "D"};

 		while (count != card) {
			String input_type = scanner.next();
			int input_number = scanner.nextInt();
			for(int t = 0;t < 4;t++) {
				for(int n = 1;n <= 13;n++) {
					if(n == input_number && types[t].equals(input_type)) {
						check[t][n] = true;
					}
				}
			}
			count++;
		}
    	scanner.close();

		for(int t = 0;t < 4;t++) {
			for(int n = 1;n <= 13;n++) {
				if(!check[t][n]) {
					System.out.printf("%s %d\n", types[t], n);
				}
			}
		}
    }
}


Measured memory_bytes: 26404
#include<bits/stdc++.h>
#define rr register
#define int long long
#define f_for(i,a,b) for(rr int i=a;i<=b;i++)
using namespace std;
const int maxx=1e4;
int n,m;
string a,b;
signed main(){
    cin>>a;
    b=a;
    bool t=true;
    int len=a.length()-1;
    for(rr int i=0; i<=len; i++)
        switch(a[i]){
            case 'q': a[i]='p';break;
            case 'p': a[i]='q';break;
            case 'b': a[i]='d';break;
            case 'd': a[i]='b';break;
        }
    for(rr int i=0;i<=len;i++)
        if(a[i]!=b[len-i])
            t=false;
    if(t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
        return 0;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func main() {
	s := nextInt()
	dic := map[int]bool{}

	for i := 1; ; i++ {
		if _, ok := dic[s]; ok {
			fmt.Println(i)
			break
		}
		dic[s] = true

		if s%2 == 0 {
			s /= 2
		} else {
			s = 3*s + 1
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a;
	int cnt4=0, cnt2=0;
	for(int i=0; i<n; i++){
		cin >> a;
		if(a%4==0){
			cnt4++;
		}
		if(a%2==0){
			cnt2++;
		}
	}
	if(cnt4>=n/2){
		cout << "Yes" << endl;
	}else if(cnt2==n){
		cout << "Yes" << endl;
	}else{
		if(n-2*cnt4 == cnt2-cnt4){
			cout << "Yes" << endl;
		}else{
		cout << "No" << endl;
		}
	}
	return 0;
}

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


typedef long long ll;
    typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
ll n;
ll m;
ll ans;
string str;
ll w[2], b[2];

int main(){
    cin>>str;
    int prt=1;
    for(auto &c : str){
        if(c=='0'){
            b[prt]++;
        }else{
            w[prt]++;
        }      
        prt=1-prt;
    }
    cout<<min(b[0]+w[1],b[1]+w[0])<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
	string cent,word,low;
	getline(cin,cent);
	for(int i=0; i<cent.size(); i++){
		if(cent[i] == ' ' || cent[i] == ',' || cent[i] == '.'){
			if(word.size()>2 && word.size()<7){
				if(low == ""){low+=word;}
				else{low+=' ';low+=word;}
			}
			word = "";
		}
		else{word+=cent[i];}
	}
	cout <<low<<endl;
	return 0;
}

Measured memory_bytes: 0
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s = S()
    t = S()
    ans = 0
    for i in range(3):
        if s[i] == t[i]:
            ans += 1
    print(ans)
    return


# B
def B():
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    A()
    return


# Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38384
n,k = map(int,input().split())
a = list(map(int,input().split()))

c = [0]*50

for i in a:
    for j in range(50):
        if (i >> j) & 1:
            c[j] += 1

s = bin(k)
x = s[2:]


dp = [[0]*2 for i in range(len(x))]
if k != 0:
    dp[0][1] = pow(2,len(x)-1)*(n-c[len(x)-1])
    dp[0][0] = pow(2,len(x)-1)*(c[len(x)-1])
for i in range(1,len(x)):
    dp[i][0] = dp[i-1][0]+pow(2,len(x)-1-i)*max(n-c[len(x)-1-i],c[len(x)-1-i])
    if x[i] == "0":
        dp[i][1] = dp[i-1][1]+pow(2,len(x)-1-i)*c[len(x)-1-i]
    else:
        dp[i][1] = dp[i-1][1]+pow(2,len(x)-1-i)*(n-c[len(x)-1-i])
        dp[i][0] = max(dp[i][0],dp[i-1][1]+pow(2,len(x)-1-i)*(c[len(x)-1-i]))
ans = max(dp[-1])
for i in range(len(x),50):
    if c[i]>0:
        ans += pow(2,i)*c[i]
print(ans)

Measured memory_bytes: 14620