akhauriyash/Code-Regression huggingface dataset:
#1:30
n,m = map(int, input().split())

hs = list(map(int, input().split()))
from collections import namedtuple

class Node(object):
    # コンストラクタ
    def __init__(self, isGood, seen, height):
        # 通常メンバ変数
        self.nodes = []
        self.isGood = isGood
        self.seen = seen
        self.height = height


# Node = namedtuple('Node', ('nodes', 'isGood', 'seen', 'height'))

# 相手Node、良い展望台、確定済み
graphs = list([Node(False, False, 0) for i in range(n)])

for i in range(m):
    a, b = map(int, input().split())
    graphs[a-1].nodes.append(b-1)
    graphs[b-1].nodes.append(a-1)

for i,h in enumerate(hs):
    graphs[i].height = h
    graphs[i].seen = False
    graphs[i].isGood = False

for g in graphs:
    if g.seen:
        continue

    for other in g.nodes:
        if graphs[other].height >= g.height:
            g.seen = True
            break
        else:
            # notgood で確定
            graphs[other].seen = True
            continue
    if not g.seen:
        g.isGood = True
        g.seen = True

print(len([g for g in graphs if g.isGood]))

Measured memory_bytes: 46572
import numpy as np

K,N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = []
maxdist = 0
for i in range(N-1):
    B.append(A[i+1]-A[i])
    if B[-1]>maxdist:
        maxdist = B[-1]

if A[0]+K-A[-1]>maxdist:
    maxdist = A[0]+K-A[-1]

print(K - maxdist)
    



Measured memory_bytes: 35196
n,m,l = map(int, input().split())

A = [[0 for i in range(m)] for j in range(n)]
B = [[0 for i in range(l)] for j in range(m)]
C = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    lst_Arg = input().split()
    for j in range(m):
        A[i][j] = int(lst_Arg[j])

for i in range(m):
    lst_Arg = input().split()
    for j in range(l):
        B[i][j] = int(lst_Arg[j])

for i in range(n):
    for j in range(l):
        x = 0
        for k in range(m):
            x = x + A[i][k] * B[k][j]
        C[i][j] = x

for i in C:
    print(*i)


Measured memory_bytes: 7068
#include <cstdio>

int main() 
{
	int a_cookies, b_cookies;
	scanf("%d %d", &a_cookies, &b_cookies);
	
	printf(a_cookies%3 == 0 || b_cookies%3 == 0 || (a_cookies + b_cookies)%3 == 0 ? "Possible\n" : "Impossible\n");
	return 0;
}

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

int main(){
 int M,f,g,p;
  string S;
  cin>>S;
  vector<int>N(26);
  for(int i=0;i<S.size();i++){
    g=S[i]-'a';
    N[g]++;
  }
    for(int j=0;j<26;j++){
      if(N[j]%2==0){
        continue;
      }
      else{
        cout<<"No"<<endl;
        return 0;
      }
    }
    
      cout<<"Yes"<<endl;
   
}

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

int main()
{
	int n;
	scanf("%d",&n);
	int v[n],c[n];
	for (int i=0;i<n;i++)
		scanf("%d ",v+i);
	for (int i=0;i<n;i++)
		scanf("%d",c+i);
	int sum=0;
	for (int i=0;i<n;i++)
		if(v[i]>=c[i])
			sum+=v[i]-c[i];
	cout<<sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <set>

using namespace std;

int main(){

    int N, K;
    cin >> N >> K;
    vector<int> P(N);

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

    int ans = N - K + 1;
    int upLen = 0;
    int upCnt = 0;
    int before = -1; 
    set<int> s;

    for(int i = 0; i < K - 1; i++){
        int temp = P[i];
        if(temp > before){
            upLen++;
        }
        else{
            upLen = 1;
        }
        s.insert(temp);
        before = temp;
    }

    bool isMinErased = false;
    for(int i = K - 1; i < N; i++){
        int temp = P[i];
        if(temp > before){
            upLen++;
            if(upLen >= K){
                upCnt++;
            }
        }
        else{
            upLen = 1;
        }

        s.insert(temp);
        auto maxPointer = s.end();
        maxPointer--;
        int maxNum = *maxPointer;

        if(upLen < K){
            if(isMinErased && maxNum == temp){
                ans--;
            }
        }

        auto minPointer = s.begin();
        int minNum = *minPointer;

        if(minNum == P[i - K + 1]){
            isMinErased = true;
        }
        else{
            isMinErased = false;
        }

        s.erase(P[i - K + 1]);

        before = temp;
    }

    if(upCnt > 0){
        ans -= (upCnt - 1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10368
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define INF 1<<30

int a[100010];
long sum[100010];
int L;

vector<int> res;

bool solve(int l, int r){
  if(l==r) return true;

  if(l+1==r && sum[r+1]-sum[l]>=L){
    res.pb(l);
    return true;
  }

  if(a[l]+a[l+1]<=a[r-1]+a[r] && sum[r+1]-sum[l+1]>=L){
    res.pb(l);
    return solve(l+1, r);
  } else if(a[l]+a[l+1]>=a[r-1]+a[r] && sum[r]-sum[l]>=L){
    res.pb(r-1);
    return solve(l, r-1);
  }
  else return false;
}

int main(){
  int n;
  cin>>n>>L;
  rep(i,n) scanf("%d", &a[i]);
  sum[0] = 0;
  rep(i,n) sum[i+1] =(long)sum[i] + a[i];

  if(solve(0,n-1)){
    cout<<"Possible"<<endl;
    rep(i,n-1) printf("%d\n", res[i]+1);
  } else {
    cout<<"Impossible"<<endl;
  }

  return 0;
}


Measured memory_bytes: 8696
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val map = mutableMapOf<Pair<Char, Char>, Int>()
    for (n in 1 .. N) {
        val s = n.toString()
        map.put(s.first() to s.last(), (map.get(s.first() to s.last()) ?: 0) + 1)
    }
    var ans = 0
    for ((pair, value) in map) {
        ans += value * (map.get(pair.second to pair.first) ?: 0)
    }
    println(ans)
}

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long a = long.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string result = "";
            if (a >= 3200)
            {
                result = s;
            }
            else
            {
                result = "red";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
map<int,int> A;
int main(){
	int t,x;
	for(scanf("%d",&t); t--;){
		scanf("%d",&x);
		A[x]++;
	}
	int res = 0;
	for(auto p : A){
		int X = p.first, Y = p.second;
		if(X <= Y)res += Y - X;else
			res += Y;
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 4736
#include <stdio.h>
#define N 1000

int main(void)
{
	int i , n;
	scanf("%d",&n);
	double a[n];
	
	for(i = 0; i < n; i++)
	{
		scanf("%lf",&a[i]);
	}
	double b[n+1];
	for(i = 0; i <= n; i++)
	{
		scanf("%lf",&b[i]);
	}
	double c[n+1][n+1];
	double d[n+1];
	c[0][0]=b[0];
	d[0]=a[0]+b[0];
	
	for(i = 1; i <= n; i++)
	{
		c[i][i] = b[i];
		c[i-1][i] = a[i-1]+(b[i-1]+b[i])*2;
		d[i] = d[i-1]+a[i]+b[i];
	}
	int j , k;
	double s , t;
	for(i = 1;i < n; i++)
	{
		for(j = 0; j < n-i; j++)
		{
			s = c[j][j] + c[j+1][i+j+1];
			for(k = j; k <i+j; k++)
			{
				t = c[j][k+1]+c[k+2][i+j+1];
				if(s>t) s = t;
			}
			c[j][i+j+1] = s + d[i+j] - d[j-1] + b[i+j+1];
		}
	}
	printf("%lf\n",c[0][n]);
	return 0;
}




Measured memory_bytes: 3740
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#include <climits>
#include <cmath>
#include <cstring>

#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int n;
	cin >> n;
	string str[n];

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

	vector<string> t[3];
	string ans = "";
	for(int i=0 ; i<n ; i++)
	{
		int s = str[i].size();
		if(str[i][0] == 'B' && str[i][s-1] == 'A')
		    t[0].push_back(str[i]);
		else if(str[i][0] == 'B')
			t[2].push_back(str[i]);
		else if(str[i][s-1] == 'A')
			t[1].push_back(str[i]);
		else
			ans += str[i];
	}
    if(t[1].size() > 0)
    {
        ans += t[1].back();
        t[1].pop_back();
    }
    
	while(t[0].size() > 0)
	{
		ans += t[0].back();
		t[0].pop_back();
	}
	
	if(t[2].size() > 0)
    {
        ans += t[2].back();
        t[2].pop_back();
    }
    
	while(t[1].size() > 0)
	{
	    ans += t[1].back();
	    t[1].pop_back();
	    if(t[2].size() > 0)
	    {
	        ans += t[2].back();
	        t[2].pop_back();
	    }
	}
	
	while(t[1].size() > 0)
	{
	    ans += t[1].back();
	    t[1].pop_back();
	}
	
	while(t[2].size() > 0)
	{
	    ans += t[2].back();
	    t[2].pop_back();
	}
	
    //cout << ans;
	int count = 0;
	for(int i=0 ; i<ans.size()-1 ; i++)
	{
		if(ans[i] == 'A' && ans[i+1] == 'B')
			count++;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 1408
using System;
using static System.Console;

class Program
{
    public static void Main()
    {
        var h = new int[1000000+1];

        int n = int.Parse(ReadLine());
        h[n] = 1;

        for (int i = 2; i < 1000000; i++)
        {
            n = (n&1) == 0 ? n/2 : 3*n + 1;
            if (h[n] != 0)
            {
                WriteLine(i);
                break;
            }
            h[n] = 1;
        }
    }
}


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

int main() {
int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  if(N <= K){
    cout << N * X << endl;
  }
  else{
    cout << K * X + (N - K) * Y << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int a[26]={0};
  for(int i=0; i<s.size();i++) {
    int b=s.at(i)-'a';
    a[b]=1;
  }
  for(int i=0; i<26; i++) {
    if(a[i]==0) {
      cout << (char)(i+97) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#define REP(i,n) for (int i=0;i<(n);i++)
int main(){
int N;
int T[114514];
int M;
int P[114514];
int X[114514];
int sum=0;
scanf("%d",&N);
REP(i,N){scanf("%d",&T[i]);sum+=T[i];}
scanf("%d",&M);
REP(i,M){scanf("%d %d",&P[i],&X[i]);}
REP(i,M){printf("%d\n",sum-T[P[i]-1]+X[i]);}

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string w;
  cin >> w;
  bool tf = true;
  for(int i=0; i<w.size(); i++){
    int q = 0;
    for(int j=0; j<w.size(); j++){
      if(w[i] == w[j]) q++;
    }
    if(q%2 != 0) tf = false;
  }
  if(tf) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

for i in range(n):
    
    a,b,c=map(int,input().split())
    d=[a,b,c]
    d=sorted(d)
    
    if d[0]**2+d[1]**2 == d[2]**2 :
       print("YES") 
    else:
        print("NO")


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

template<typename T>
T get_value(std::istream& is);

int getMinNum(int _nOriginal, const std::set<int>& _avoid)
{
	std::string org = std::to_string(_nOriginal);
	for (auto& c : org)
	{
		int nTarget = c - '0';
		if (_avoid.find(nTarget) != _avoid.end())
		{
			return getMinNum(_nOriginal + 1, _avoid);
		}
	}

	return _nOriginal;
}

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

	int N, K;

	std::cin >> N >> K;
	std::vector<size_t> v(K);
	std::set<int> s;

	for (auto& e : v) {
		std::cin >> e;
		s.insert(e);
	}

	int answer = getMinNum(N, s);
	std::cout << answer << std::endl;

	return 0;
};


template<typename T>
inline T get_value(std::istream& is)
{
	T v;
	is >> v;
	return v;
}

Measured memory_bytes: 10240
buildings = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = list(map(int, input().split()))
    buildings[b - 1][f - 1][r - 1] += v

for b in range(len(buildings)):
    if 0 < b:
        print("####################")

    for f in range(len(buildings[b])):
        for r in range(len(buildings[b][f])):
            print(" " + str(buildings[b][f][r]), end="")
        print()



Measured memory_bytes: 5624
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int d, n, x = 1;
  cin >> d >> n;
  while (d--) x *= 100;
  int ret;
  for (ret = x; ; ret += x) {
    if (ret % (x * 100) == 0) continue;
    if (--n == 0) break;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
def main():

    import statistics

    n = int(input())
    a = [0] * n
    b = [0] * n

    for i in range(n):
        a[i], b[i] = map(int, input().split())

    meda = statistics.median(a)
    medb = statistics.median(b)

    if n % 2:
        print(int(medb - meda + 1))
    else:
        print(int((medb - meda) * 2 + 1))


if __name__ == '__main__':
    main()


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

int n, a, b;

int main(){
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0)cout << "Alice" << endl;
	else cout << "Borys" << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $n);
  $input = trim(fgets(STDIN));
  $input = explode(" ", $input);
  $word1 = str_split($input[0]);
  $word2 = str_split($input[1]);
  for($i=0; $i<=$n-1; $i++){
    $array[] = $word1[$i];
    $array[] = $word2[$i];
  }
  $word = implode('', $array);
  echo $word;
?>

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <vector>
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n, k, mn=9e20;
pair<ll, ll> a[55];
int main() {
	int i, j, l;
	cin>>n>>k;
	for(i=0; i<n; i++) cin>>a[i].F>>a[i].S;
	sort(a, a+n);
	for(i=0; i<=n-k; i++) {
		vector<ll> v;
		for(j=0; j<k-1; j++) v.push_back(a[i+j].S);
		for(; i+j<n; j++) {
			v.push_back(a[i+j].S);
			sort(v.begin(), v.end());
			for(l=0; l<=v.size()-k; l++) {
				mn = min(mn, (v[l+k-1]-v[l]) * (a[i+j].F-a[i].F));
			}
		}
	}
	cout<<mn;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;


class Networkflow {
private:
	struct edgedata {
		int to, capacity, weight;
		edgedata* dual_p;
	};
	struct node {
		int id;
		bool done;
		list<edgedata> edge;
	};
	vector<node> nodes;
	int n;
	int source, sink;
	edgedata* dummy;
public:
	int result;
	Networkflow(int size, int s, int t) {
		n = size;
		source = s;
		sink = t;
		nodes.resize(n);
		dummy = new edgedata;
		init();
	}
	void init() {
		Loop(i, n) {
			nodes[i] = { i, false,{} };
		}
	}
	void addedge(int s, int t, int c, int w) {
		nodes[s].edge.push_back({ t, c, w, dummy });
		nodes[t].edge.push_back({ s, 0, w, &(nodes[s].edge.back()) });
		nodes[s].edge.back().dual_p = &(nodes[t].edge.back());
	}
	void maxflow() {
		result = 0;
		vector<pair<int, edgedata*>> stk;
		int a; // the node which is focused on
		int df; // how much flow in one operation
		while (1) {
			a = source;
			Loop(i, n) nodes[i].done = false;
			nodes[source].done = true;
			while (a != sink) {
				int b = -1;
				edgedata* p;
				for (auto itr = nodes[a].edge.begin(); itr != nodes[a].edge.end(); ++itr) {
					if ((*itr).capacity > 0) {
						b = (*itr).to;
						if (nodes[b].done) b = -1;
						else {
							p = &(*itr);
							stk.push_back(make_pair(a, p));
							nodes[b].done = true;
							a = b;
							break;
						}
					}
				}
				if (b == -1) {
					if (stk.empty()) break;
					a = stk.back().first;
					stk.pop_back();
				}
			}
			if (stk.empty()) break;
			df = INT_MAX;
			Loop(i, stk.size()) {
				df = min(df, (*(stk[i].second)).capacity);
			}
			while (stk.size()) {
				(*(stk.back().second)).capacity -= df;
				(*((*(stk.back().second)).dual_p)).capacity += df;
				stk.pop_back();
			}
			result += df;
		}
		return;
	}
};

int main() {
	int v, e;
	cin >> v >> e;
	Networkflow networkflow(v, 0, v - 1);
	Loop(i, e) {
		int s, t, c; cin >> s >> t >> c;
		networkflow.addedge(s, t, c, 1);
	}
	networkflow.maxflow();
	cout << networkflow.result << endl;
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
using namespace std;
pair<int,int> arr[100005];
int main()
{
	int n,ans=0;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d",&arr[i].first);
		arr[i].second=i;
	}
	sort(arr,arr+n);
	for (int i=0;i<n;i++)
	{
		if (arr[i].second%2!=i%2)
		ans++;
	}
	printf("%d",ans/2);
}

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

const double inf = 1e100;

int n, m;
vector<int> G[600];
double ET[600];
double PS[600];
double FS[600];

int main() {
  cin >> n >> m;
  for (int j = 0; j < m; ++j) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back(b);
  }
  
  PS[0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j : G[i]) {
      PS[j] += PS[i] / G[i].size();
    }
  }
  
  for (int i = n - 2; i >= 0; --i) {
    double sum = 0;
    int cnt = 0;
    for (int j : G[i]) {
      sum += ET[j];
      ++cnt;
    }
    ET[i] = sum / cnt + 1;
  }
  
  for (int i = 0; i < n; ++i) {
    if (i != 0) FS[i] += PS[i];
    for (int j : G[i]) {
      FS[j] += FS[i] / G[i].size();
    }
  }
  
  double mn = ET[0];
  const int t = n - 1;
  for (int u = 0; u < n; ++u) {
    for (int v : G[u]) {
      double pe = PS[u] / G[u].size();
      double Est = FS[t] / PS[t];
      double Esu = FS[u] / PS[u];
      double Este = Esu + ET[v] + 1;
      double Gut = (ET[u] * G[u].size() - (ET[v] + 1)) / (G[u].size() - 1);
      double ans = Est + (-Este + Esu + Gut) * pe;
      mn = min(mn, ans);
    }
  }
  cout << fixed << setprecision(16) << mn << endl;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	cin >> n;

	vector<ll> a;
	for(int i=0; i<n; i++){
		ll t;
		cin >> t;
		t--;
		a.pb(t);
	}

	int now = 0;
	int cnt = 0;
	while(true){
		if(cnt > 100000){
			puts("-1");
			break;
		}
		if(now == 1){
			cout << cnt << endl;
			break;
		}
		cnt++;
		now = a[now];
	}


	
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
//#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


		


int main(){
	int n,h,w;
	cin>>n>>h>>w;
	int a,b;
	int ans = 0;
	rep(i,n){
		cin>>a>>b;
		if(h<=a && w<=b){
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> x(n), y(n), h(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i];

    int maxH = 0;
    for(int i = 0; i < n; i++) {
        maxH = max(maxH, h[i]);
    }

    for(int cy = 0; cy <= 100; cy++) {
        for(int cx = 0; cx <= 100; cx++) {
            for(int ch = maxH; ch <= maxH + 200; ch++) {
                bool flag = true;
                for(int i = 0; i < n; i++) {
                    int temp = ch - abs(cx - x[i]) - abs(cy - y[i]);
                    int tempH = max(temp, (int)0);
                    if(h[i] != tempH) flag = false;
                }
                if(flag) {
                    cout << cx << " " << cy << " " << ch << endl;
                    return 0;
                }
            }
        }
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int c=0;
 int n;
 double d;
  cin>>n;
  cin>>d;
  for(int i=0;i<n;i++)
  {
    long long a,b;
    cin>>a;
    cin>>b;
    double td=sqrt((a*a) + (b*b));
    if(td<=d)
    {
    c++;
    }
    
  }
  
  cout<<c;
}
  



Measured memory_bytes: 3800
# Aはリストを表している
# Nは要素数を表している
N = int(input())
A = list(map(int, input().split()))

# バブルソートの処理
flag = 1
i = 0  # 未ソート部分列の先頭インデックス
count = 0
while flag:
    flag = 0

    # pythonで逆順にするのは組み込み関数reversedを使用する。またrange関数とも一緒に使うことができる。
    for j in reversed(range(1, N)):
        if A[j] < A[j-1]:
            A[j], A[j-1] = A[j-1], A[j]
            count += 1
            flag = 1
    i += 1

print(*A)
print(count)
# バブルソートは、挿入ソートと同様に、各計算ステップにおいて、配列は「ソート済みの部分列」と「未ソートの部分列」とに分けられる。
# ソート済み | 未ソート

# バブルソート
# リストにおいて隣り合う二つの要素の値を比較して条件に応じた交換を行う整列アルゴリズムである。
# その条件は値の大小関係である。
# このソートを実行すると値の大きいまたは小さい値が浮かび上がって見えることからバブルソートと呼ばれている。



Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

// verified : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
// 負辺があると動作しない?
// O(E log V)
template<typename T>
vector<T> dijkstra(vector<vector<pair<int, T>>> &g, int s){
     
  int n = g.size();
  // numeric_limits がうまく使えない場合は自分で INF を定義する.
  const auto inf = numeric_limits<T>::max();
  vector<T> dist(n, inf);

  using P = pair<T, int>;
  // 小さい順に取り出せる
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()){
    T cost;
    int node;
    tie(cost, node) = que.top();
    que.pop();
    if(dist[node] < cost) continue;
    for(auto &e : g[node]){
      auto next_cost = cost + e.second;
      int next_node = e.first;
      if(dist[next_node] <= next_cost) continue;
      dist[next_node] = next_cost;
      que.emplace(next_cost, next_node);
    }
  }

  return dist;
}

int main() {
  
  int n, m, s, t; cin >> n >> m >> s >> t;
  s--;
  t--;

  vector<vector<pair<int, lint>>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    lint d; cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    g[a].push_back({b, d});
    g[b].push_back({a, d});

    g[a].push_back({c, d});
    g[c].push_back({a, d});

    g[b].push_back({c, d});
    g[c].push_back({b, d});
  }

  cout << dijkstra(g, s)[t] << endl;
  return 0;
}



Measured memory_bytes: 23640
<?php
fscanf(STDIN, "%d %d", $n, $m);
$a = explode(' ', trim(fgets(STDIN)));
while ($m--) {
	fscanf(STDIN, "%d %d", $b, $c);
	if (isset($t[$c])) {
		$t[$c] += $b;
	} else {
		$t[$c] = $b;
	}
}
rsort($a);
krsort($t);
$x = $i = 0;
foreach ($t as $c => $b) {
	while ($a[$i] >= $c) {
		$x += $a[$i];
		$i++;
		if (!--$n) break 2;
	}
	$y = min($n, $b);
	$x += $c * $y;
	$n -= $y;
	if (!$n) break;
}
while ($n--) {
	$x += $a[$i];
	$i++;
}
echo $x;

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

int main() {
  int N, A;
  
  cin >> N >> A;

  if ( A >= 499 ) {
    cout << "Yes" << endl;
  }
  else if ( N % 500 <= A ) {
  cout << "Yes" << endl;
  } 
  else {
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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


	    String s=gs();
	    StringBuilder sb=new StringBuilder();
	    for(int i=0; i<s.length();i++) {
	    	sb.append("x");
	    }	    
	    
       System.out.print(sb.toString());

//        if (s>=H) {
//    	    System.out.print("Yes");
//        }else{
//    	    System.out.print("No");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35700
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    int count=0;
    for(int i=v.size()-1;i>=0;i--)
    {
        int prev=v[i];
        bool inside=false;
        count++;
        while(i>=0&&v[i]==prev)
        {
            i--;
            inside=true;
        }
        if(inside){
            i++;
        }
    }
    cout<<count;
}

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

typedef long long ll;

ll N, M;
vector<ll> A;
map<ll, ll, greater<ll>> CB;
ll R;

int main() {
  cin >> N >> M;
  A.resize(N);
  for (ll i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  for (ll i = 0; i < M; ++i) {
    ll b, c;
    cin >> b >> c;
    CB[c] += b;
  }
  for (ll i = 0; i < N && !CB.empty(); ++i) {
    auto it = CB.begin();
    if (it->first <= A[i]) break;
    A[i] = it->first;
    --it->second;
    if (it->second == 0) CB.erase(it);
  }
  for (ll a : A) R += a;
  cout << R << endl;
  return 0;
}


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

int main(){
int N, D;
cin >> N >> D;
if (N%(2*D + 1) == 0){
    cout << N/(2*D + 1) << endl;
} else {
    cout << N/(2*D + 1) + 1 << endl;
}

}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 500000
#define INFTY 2000000000

void merge(int[],int,int,int);
void mergeSort(int[],int,int);

int L[(MAX/2)+2],R[(MAX/2)+2];
int cnt;


int main(){

  int i,n,A[MAX];
  cnt = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  mergeSort(A,0,n);

  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i==n-1){
      printf("\n");
      break;
    }
    printf(" ");
  }

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

  return 0;
}


void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  
  n1 = mid - left;
  n2 = right - mid;
  
  for(i=0;i<=n1;i++)L[i] = A[left+i];
  for(i=0;i<=n2;i++)R[i] = A[mid+i];

   L[n1] = INFTY;
   R[n2] = INFTY;

    i = 0;
    j = 0;
    for(k=left;k<right;k++){
      cnt++;
      if(L[i] <= R[j]){
	A[k] = L[i];
	i = i + 1;
      }
      else{
	A[k] = R[j];
	j = j + 1;
      }
    }

}

void mergeSort(int A[],int left,int right){
  int mid;

  if(left+1<right){ mid = (left+right)/2;
  mergeSort(A,left,mid);
  mergeSort(A,mid,right);
  merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4508
MOD = 10**9 + 7
def pow(x,n)
  if n == 0
    1
  elsif n % 2 == 0
    pow(x*x%MOD, n/2) % MOD
  else
    x * pow(x, n-1) % MOD
  end
end
def divisors(n)
  p = []
  2.upto((n**0.5)) do |i|
    break if i > n / i
    while n % i == 0
      p << i
      n /= i
    end
  end
  p << n if n != 1
  p
end

n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
lcm = Hash.new(0)
divisors(a[0]).each do |x|
  lcm[x] += 1
end
(n-1).times do |i|
  h = Hash.new(0)
  divisors(a[i+1]).each do |x|
    h[x] += 1
  end
  h.each_key do |j|
    lcm[j] = h[j] if lcm[j] < h[j]
  end
end
lcmNum = lcm.inject(1){|result,(k,v)| result * pow(k,v) % MOD}
ans = 0
a.each do |x|
  ans += lcmNum * pow(x, MOD-2) % MOD
  ans %= MOD
end
puts ans

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

int main()
{
  int a;
  cin >> a;
  if (a == 1) cout << "Hello World" << endl;
  else {
    int n, n2;
    cin >> n;
    cin >> n2;
    cout << n + n2 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,x;
	vector<int> v;
	cin>>n>>m>>x;
	for(int i=0;i<m;i++){
		int a;
		cin>>a;
		v.push_back(a);
	}
	int left=0,right=0;
	for(int i=0;i<m;i++){
		if(v[i]<x) left++;
		else right++;
	}
	cout<<min(left,right)<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AtCoder_Beginner_Contest_134
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
        }
        static  void Solve()
        {
            var ND = Sarray();
            var N = ND[0];
            var D = ND[1];
            var ans = N / (2 * D + 1);
            if (0 != N % (2 * D + 1)) ++ans;
            WriteLine(ans);
            
        }
    }
}


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

using namespace std;

#define ll long long

signed main(){
    int n; cin >> n;
   string s; cin >> s;
    int k; cin >> k;
    char ng = s[k - 1];
    for (int i = 0; i < n; ++i)
        cout << (s[i] == ng ? ng : '*');
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int w,h;
int fie[2][5][5];
vector<P> G[6*6*6*6*6];
int ok[6];
int curfie[5][5];
int id[10005];

void init(int v,int a,int b,int col){
	memset(curfie,-1,sizeof(curfie));
	for(int i=0;i<w;i++){
		for(int j=ok[i];j<h;j++){
			curfie[j][i]=fie[1][j][i];
		}
	}
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			curfie[i][j]=col;
		}
	}
	int nok[6];
	for(int i=w-1;i>=0;i--){
		nok[i]=h;
		for(int j=h-1;j>=0;j--){
			if(i<w-1 && nok[i+1]==nok[i])break;
			if(curfie[j][i]!=fie[1][j][i])break;
			nok[i]--;
		}
	}
	int nxt=0;
	for(int i=w-1;i>=0;i--){
		nxt*=h+1;
		nxt+=nok[i];
	}
	G[v].push_back(P(nxt,(a+1)*(b+1)));
}


typedef vector<double> vec;
typedef vector<vec> mat;

vec gauss_jordan(const mat &A,const vec& b){
	int N=A.size();
	mat B(N,vec(N+1));
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			B[i][j]=A[i][j];
		}
	}
	for(int i=0;i<N;i++){
		B[i][N]=b[i];
	}
	for(int i=0;i<N;i++){
		int pivot=i;
		for(int j=i;j<N;j++){
			if(fabs(B[j][i])>fabs(B[pivot][i]))pivot=j;
		}
		swap(B[i],B[pivot]);
		if(fabs(B[i][i])<EPS)continue;
		for(int j=i+1;j<=N;j++){
			B[i][j]/=B[i][i];
		}
		for(int j=0;j<N;j++){
			if(i!=j){
				for(int k=i+1;k<=N;k++){
					B[j][k]-=B[j][i]*B[i][k];
				}
			}
		}
	}
	vec x(N);
	for(int i=0;i<N;i++){
		x[i]=B[i][N];
	}
	return x;
}


void solve(){
	for(int i=0;i<6*6*6*6*6;i++){
		G[i].clear();
	}
	int siz=1;
	for(int i=0;i<w;i++){
		siz*=(h+1);
	}
	int siz2=0;
	memset(id,-1,sizeof(id));
	for(int i=0;i<siz;i++){
		int v=i;
		bool flag=false;
		for(int j=0;j<w;j++){
			ok[j]=v%(h+1);
			if(j>0 && ok[j-1]<ok[j])flag=true;
			v/=h+1;
		}
		if(flag)continue;
		id[i]=siz2;
		siz2++;
		for(int a=0;a<h;a++){
			for(int b=0;b<w;b++){
				for(int c=0;c<2;c++){
					init(i,a,b,c);
				}
			}
		}
	}
	mat eff(siz2,vec(siz2,0.0));
	for(int i=0;i<siz;i++){
		if(id[i]==-1)continue;
		int v=id[i];
		if(v==0){
			eff[v][0]=1.0;
		}else{
			for(int k=0;k<G[i].size();k++){
				eff[v][id[G[i][k].first]]+=(double)1.0/G[i].size();
			}
		}
	}
	double ads=0.0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ads+=(i+1.0)*(j+1.0);
		}
	}
	ads/=h*w;
	vec vo(siz2,0.0);
	for(int i=1;i<siz2;i++){
		for(int j=0;j<siz2;j++){
			eff[i][j]=-eff[i][j];
		}
		eff[i][i]+=1.0;
		vo[i]=ads;
	}
	vec res=gauss_jordan(eff,vo);
	int nok[6];
	for(int i=w-1;i>=0;i--){
		nok[i]=h;
		for(int j=h-1;j>=0;j--){
			if(i<w-1 && nok[i+1]==nok[i])break;
			if(fie[1][j][i]!=fie[0][j][i])break;
			nok[i]--;
		}
	}
	int resid=0;
	for(int i=w-1;i>=0;i--){
		resid*=h+1;
		resid+=nok[i];
	}
	printf("%.10f\n",res[id[resid]]);
}

int main(void){
	while(1){
		scanf("%d%d",&h,&w);
		if(h==0 && w==0)break;
		for(int k=0;k<2;k++){
			for(int i=0;i<h;i++){
				string str;
				cin >> str;
				for(int j=0;j<w;j++){
					if(str[j]=='W'){
						fie[k][i][j]=0;
					}else{
						fie[k][i][j]=1;
					}
				}
			}
		}
		solve();
	}
	return 0;
}


Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

bool can=true;
ll n,d[201][201],ans=-1;
string s[201];

bool is_bipartite(){  // ２部グラフか判定
	bool ok=true;
	int color[201]={};
	queue<ll> Q;
	Q.push(0);
	color[0]=1;
	while(!Q.empty()){
		ll p = Q.front();Q.pop();
		rep(i,n){
			if(s[p][i]=='1'){
				if(color[i]==0){
					color[i]=3-color[p];
					Q.push(i);
				}else if(color[i] != 3-color[p]){
					ok=false;
					break;
				}
			}
		}
	}
	// rep(i,n)cerr<<color[i]<<endl;
	return ok;
}

void init(){
	cin>>n;
	rep(i,n)cin>>s[i];
}

int main(void){
	init();
	can = is_bipartite();
	// cerr<<(can?"true":"false")<<endl;
	rep(i,n)rep(j,n)d[i][j]=(s[i][j]=='1'?1:1e9);
	rep(i,n)d[i][i]=0;
	rep(k,n) {
		rep(i,n) {
			rep(j,n) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	rep(i,n)rep(j,n)ans=max(ans,d[i][j]);
	cout<<(can?ans+1:-1)<<endl;
	return 0;
}

Measured memory_bytes: 640
import sys,queue,copy
sys.setrecursionlimit(10**8)
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

K,X =inpl()

i = X - (K-1)
j = X + K

ans =list()
for a in range(i,j):
    ans.append(str(a))

print(" ".join(ans))

Measured memory_bytes: 4080
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	long long n, s, t;

	cin >> n;

	t = n;
	while (t > 0) {
		s += t % 10;
		t = t / 10;
	}

	if (n%s == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<utility>
using namespace std;

int main(){
	int n, m;
	int a[10010];
	int b[10010];
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	cin >> m;
	for(int i=0; i<m; i++){
		cin >> b[i];
	}

	int cnt = 0;
	for(int i=0; i<m; i++){
		int f = 0;
		for(int j=0; j<n; j++){
			if(a[j]==b[i]){
				f=1;
				break;
			}
		}
		if(f==1) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int keta(int x) {
	int ans = 0, n = 1;
	while (n <= x) {
		ans++;
		n *= 10;
	}
	return ans;
}
signed main() {
	int n, m;
	cin >> n >> m;
	if (n == m)puts("Yes");
	else puts("No");
	ggr
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < 100000; i++) {
    int sum = ((i * 100) + i * 8) / 100;
    if (sum == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.HashSet;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {


  private void solve(InputReader in, PrintWriter out) {
    String s = in.next();
    int l = s.length();
    for (int i = 0; i < l - 2; i++) {
      if (s.charAt(i) == s.charAt(i + 1) || s.charAt(i) == s.charAt(i + 2) || s.charAt(i + 1) == s.charAt(i + 2)) {
        out.print((i + 1) + " " + (i + 3));
        return;
      }
    }
    if (s.charAt(0) == s.charAt(1)) {
      out.print(1 + " " + 2);
    } else {
      out.print(-1 + " " + -1);
    }
  }


  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {

    try (InputReader in = new InputReader(System.in);
         PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      //reader = new BufferedReader(new FileReader(stream), 32768);
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {
    }
  }

}


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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  string S, R;
  CIN(S);
  R = S;
  reverse(R.begin(), R.end());

  int count = 0;
  for (int i = 0; i < S.length() / 2; i++) {
    if (S[i] != R[i]) {
      count++;
    }
  }

  COUT(count);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int v = scan.nextInt();
		int e = scan.nextInt();

		//space taken by an adjascency list is O(E + V)
		Map<Integer, List<Integer>> adj_list = new HashMap<Integer, List<Integer>>();

		while ( e-- > 0 ){
			int x = scan.nextInt();
			int y = scan.nextInt();
			if ( !adj_list.containsKey(x) ) adj_list.put(x, new ArrayList<Integer>());
			List<Integer> cur_neigh = adj_list.get(x);
			cur_neigh.add(y);
		}
		//at this point the adjascency list is built
		boolean iscycle = graph_iscycle(adj_list, v);
		if ( iscycle ) System.out.println("1");
		else System.out.println("0");
	}

	public static boolean graph_iscycle(Map<Integer, List<Integer>> adj_list, int v_size){
		//for all nodes not yet visited the color is 0, for in-visiting status color is 1, for complete the color is 2
		int color[] = new int[v_size];		

		for ( int v : adj_list.keySet()){
			if ( color[v] == 0 ){
				boolean res = check_cycle_util(v, color, adj_list);
				if ( res ) return true;
			}
		}
		return false;
	}

	//returns true if the graph contains a cycle
	//this function is called once per node (at that time it is marked visited and hence never called again for that node)
	private static boolean check_cycle_util(int v, int color[], Map<Integer, List<Integer>> adj_list){
		color[v] = 1;

		if ( adj_list.containsKey(v) ){
			//at each call it iterates over a loop of size=out-degree
			for ( int neigh : adj_list.get(v) ){
				//if node is not visited, explore it
				if ( color[neigh] == 0 ){
					boolean res = check_cycle_util(neigh, color, adj_list);
					if ( res ) return true;
				}
				//if visited, check if it forms a back edge, that is .. it is part of the current call stack history
				else if ( color[neigh] == 1 ) return true;
			}			
		}

		//undo a node visit to prevent it being considered for back edges bcoz its off the call stack now
		color[v] = 2;
		return false;
	}
}

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

int main() {
    int N; cin >> N;
    vector<int> a(N), b(N);
    rep(i, N){
        cin >> a[i];
    }
    rep(i, N){
        cin >> b[i];
    }

    ll pool = 0;
    rep(i, N){
        if(a[i] > b[i]){
            pool += (a[i] - b[i])*2;
        }
    }

    rep(i, N){
        if(a[i] < b[i]){
            int x = b[i] - a[i];
            if(x%2 == 1)x--;
            pool -= x;
        }
    }

    if(pool <= 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3664
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}

var bit = xArray(0,60);
var y = 30;
var z = 1 << y;

console.log(main());
function main(){
  var n = o.a();
  var a = o.l(1);
  for(var i = 0; i < n; i++){
    if(a[i] > 9e15){
      big(a[i]);
    }else{
      small(+a[i]);
    }
  }
  var ans = 0, x = 1;
  for(var i = 0; i < 60; i++){
    ans += mul(x,bit[i],n-bit[i]);
    x = x*2%mod;
  }
  return ans%mod;
}

function small(x){
  var j = 0;
  while(x > 4e9){
    if(x&1)bit[j]++;
    x = Math.floor(x * 0.5);
    j++;
  }
  while(x){
    if(x&1)bit[j]++;
    x >>>= 1;
    j++;
  }
}

function big(x){
  var h = +x.slice(0,-5);
  var l = +x.slice(-5);
  var u = h / z | 0;
  var v = h - u * z;
  u *= 1e5;
  l += v * 1e5;
  v = l / z | 0;
  u += v;
  v = l - v * z;
  for(var i = y; u; i++, u >>>= 1){
    if(u&1)bit[i]++;
  }
  small(v);
}

Measured memory_bytes: 65128
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, h, w; scanf("%d%d%d", &n, &h, &w);
	int ans = 0;
	while(n--) {
		int a, b; scanf("%d%d", &a, &b);
		
		ans += (h <= a and w <= b);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256