akhauriyash/Code-Regression huggingface dataset:
import copy

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

list_sorted = list.copy()
list_sorted.sort()

stock = 0
for i in range(n):
    if list[i] != list_sorted[i]:
        stock += 1

if stock == 0 or stock == 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3572
import java.util.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int [] cy = new int[n];
			for(int i = 0; i < n; i++){
				cy[i] = sc.nextInt();
			}
			int m = sc.nextInt();
			int [] sche = new int[101];
			Arrays.fill(sche, 23);
			for(int i = 0; i < m; i++){
				int day = sc.nextInt();
				sche[day] = Math.min(sche[day], sc.nextInt());
			}
			
			int [][] dp = new int[101][n];
			int INF = 1 << 24;
			for(int i = 0; i < 101; i++){
				Arrays.fill(dp[i], INF);
			}
			dp[1][0] = 0;
			for(int i = 1; i < 100; i++){
				for(int j = 0; j < n; j++){
					if(dp[i][j] == INF) continue;
					if(cy[(j + 1) % n] <= sche[i + 1]){
						dp[i + 1][(j + 1) % n] = Math.min(dp[i][j], dp[i + 1][(j + 1) % n]);
					}
					dp[i + 1][0] = Math.min(dp[i + 1][0], dp[i][j] + 1);
				}
			}
			int min = INF;
			for(int i = 0; i < n; i++){
				min = Math.min(min, dp[100][i]);
			}
			System.out.println(min);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

Measured memory_bytes: 25772
import math
import numpy as np

def  XYZTriplets():

    num = int(input())
    
    list_num = []
    
    count = [0]*num
    
    for i in range(1, num+1):
        list_num.append(i)

    for x in range(1, int(math.sqrt(num))):
        for y in range(1, int(math.sqrt(num))):
            for z in range(1, int(math.sqrt(num))):
                
                function = x*x + y*y + z*z + x*y + y*z + z*x
                
                if function <= num and function > 0:
                    count[function-1] = count[function-1] + 1
 
    for i in range(0, num):
        print(count[i])
        

if __name__ == '__main__':
    XYZTriplets()


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

int main() {
  int total;
  int type;
  int cnt = 0;
  int tmpNum;
  int tmpCnt = 0;
  cin >> total >> type;
  vector<int> vec(total,0);
  
  for(int i = 0; i < total; i++){
    cin >> tmpNum;
    // 一致する値にインクリメント
    vec.at(tmpNum - 1) += 1;
  }
  
  // 0を考慮して降順でソート
  sort(vec.begin(), vec.end(), greater<int>());
  
  // 種類数より膨れた数をカウント
  for(int i = type; i < vec.size(); i++){
    cnt+= vec.at(i);
  }
  
  cout << cnt;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        var l = sc.IntArray();
        Array.Sort(l);
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                for (int k = j + 1; k < n; k++)
                {
                    if (l[i] == l[j] || l[j] == l[k]) continue;
                    if (l[i] + l[j] > l[k])
                    {
                        ans++;
                    }
                }
            }
        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 28168
use proconio::{input, marker::Usize1};
use std::cmp;
use std::collections::VecDeque;
use std::iter;

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        abcds: [(Usize1, Usize1, usize, u64); q],
    }

    let mut ass = vec![];
    let mut queue = (0..m).map(|x| vec![x]).collect::<VecDeque<_>>();
    while let Some(r#as) = queue.pop_front() {
        if r#as.len() == n {
            ass.push(r#as);
        } else {
            for a in *r#as.last().unwrap()..m {
                queue.push_back(r#as.iter().copied().chain(iter::once(a)).collect());
            }
        }
    }

    let ans = ass
        .into_iter()
        .map(|r#as| {
            abcds
                .iter()
                .filter(|&&(a, b, c, d)| r#as[b] - r#as[a] == c)
                .map(|&(_, _, _, d)| d)
                .sum::<u64>()
        })
        .max()
        .unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 16056
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int n, m,ans = 0;
	cin >> n >> m;
	vi memo(100);
	repz(i, n) {
		int k,temp;
		cin >> k;
		repz(j, k) {
			cin >> temp;
			memo[temp]++;
		}
	}

	repz(i, 100)if (memo[i] == n)ans++;

	cout << ans << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 504
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const ll MAX_N=1e5;
ll N;
string S;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>S;
	ll ans=1;
	REP(i,N-1){
		if(S[i+1]!=S[i])ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.max(0,a-2*b));
        sc.close();
    }
}

class io{
    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }
}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 21844
l=list(map(int,input().split()))
s=input()
for i in s:
    if i=="W":
        l[0],l[2],l[5],l[3]=l[2],l[5],l[3],l[0]
    elif i=="E":
        l[0],l[2],l[5],l[3]=l[3],l[0],l[2],l[5]
    elif i=="N":
        l[0],l[1],l[5],l[4]=l[1],l[5],l[4],l[0]
    else:
        l[0],l[1],l[5],l[4]=l[4],l[0],l[1],l[5]
print(l[0])


Measured memory_bytes: 5600
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - 1 - i]) {
      ans++;
    }
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 256
table = [".,!? ", "abc", "def", "ghi","jkl",
        "mno", "pqrs", "tuv", "wxyz"]

n = int(raw_input())

for _ in range(n):
    msg = raw_input().replace("\r", "")
    ans = ""; j = 0; t = "";

    for i in msg:
        if i == "0":
            ans += t
            j = 0; t = ""
        else:
            t = table[int(i)-1][j]
            j += 1
            j %= len(table[int(i)-1])

    print ans



Measured memory_bytes: 4648
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
char a[1000][1000];
int c[1000][1000];
int main() {
	int h,w;
	while (cin >> h >> w) {
		string u;
		for (int i = 0; i < h; i++) {
			cin >> u;
			for (int j = 0; j < w; j++) {
				a[i][j] = u[j];
				c[i][j] = 0;
			}
		}
		char b[2][2];
		for (int i = 0; i < 2; i++) {
			cin >> u;
			b[i][0] = u[0];
			b[i][1] = u[1];
		}
		int sum = 0;
		for (int i=0; i < h-1; i++) {
			for (int j = 0; j < w-1; j++) {
				if (a[i][j] == b[0][0]&&a[i][j+1]==b[0][1]&&
					a[i+1][j]==b[1][0]&&a[i+1][j+1]==b[1][1]) {
					c[i][j]++;
					sum++;
					c[i][j + 1]++;
					c[i + 1][j]++;
					c[i + 1][j + 1]++;
				}
			}
		}
		int sum2 = sum;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				map<char, int>d;
				d.insert(map<char, int>::value_type('J', 0));
				d.insert(map<char, int>::value_type('O', 0));
				d.insert(map<char, int>::value_type('I', 0));
				if (i + 1 < h&&j + 1 < w) {
					if (a[i][j + 1] == b[0][1] &&
						a[i + 1][j] == b[1][0] && a[i + 1][j + 1] == b[1][1]) {
						d[b[0][0]]++;
					}
				}
				if (i + 1 < h&&j - 1 >= 0) {
					if (a[i][j-1] == b[0][0] &&
						a[i + 1][j-1] == b[1][0] && a[i + 1][j] == b[1][1]) {
						d[b[0][1]]++;
					}
				}
				if (i - 1 >= 0 && j + 1 < w) {
					if (a[i-1][j] == b[0][0] && a[i-1][j + 1] == b[0][1] &&
						a[i][j + 1] == b[1][1]) {
						d[b[1][0]]++;
					}
				}
				if (i - 1 >= 0 && j - 1 >= 0) {
					if (a[i-1][j-1] == b[0][0] && a[i-1][j] == b[0][1] &&
						a[i][j-1] == b[1][0]) {
						d[b[1][1]]++;
					}
				}
				int sum3 = max(d['J'], max(d['O'], d['I']));
				if (sum - c[i][j] + sum3 > sum2) {
					sum2 = sum - c[i][j] + sum3;
				}
			}
		}
		cout << sum2 << endl;
	}
}

Measured memory_bytes: 8072
#include<iostream>
#include<string.h>
#define LEN 100005
#include<iostream>
using namespace std;
typedef struct pp{
	char name[100];
	int t;
} p;
p Q[LEN];
int head,tail,n;
void enqueue(p x){
	Q[tail]=x;
	tail=(tail+1)%LEN;
}
p dequeue(){
	p x=Q[head];
	head=(head+1)%LEN;
	return x;
}
int min(int a,int b){
	return a<b?a:b;
} 
int main()
{
	int elaps=0,c;
	int i,q;
	p u;
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		cin>>Q[i].name>>Q[i].t;
	}
	head=1;tail=n+1;
	while(head!=tail)
	{
		u=dequeue();
		c=min(q,u.t);
		u.t-=c;
		elaps+=c;
		if(u.t>0)
		enqueue(u);
		else
		cout<<u.name<<" "<<elaps<<endl;
	}
	return 0;
}


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

int main(){
    ll n, m;
    ll a, b;

    vector<ll> h;    
    vector<bool> good;

    cin >> n >> m;
    h.assign(n+1,0);
    good.assign(n+1,true);

    for(int i=1;i<=n;i++){
        cin >> h[i];
    }

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

    int cnt=0;
    for(int i=1;i<=n;i++){
        cnt+=good[i];
    }

    cout << cnt << '\n';

    return 0;
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,m;
  cin>>h>>w>>m;
  set<vector<int>> yx;
  vector<vector<int>> sy(h);
  for(int i=0;i<h;i++)
    sy.at(i)={0,i};
  vector<vector<int>> sx(w);
  for(int i=0;i<w;i++)
    sx.at(i)={0,i};
  for(int _=0;_<m;_++){
    int hi,wi;
    cin>>hi>>wi;
    hi--;
    wi--;
    yx.insert({hi,wi});
    sy.at(hi).at(0)++;
    sx.at(wi).at(0)++;
  }
  sort(sy.begin(),sy.end(),greater<vector<int>>());
  sort(sx.begin(),sx.end(),greater<vector<int>>());
  int my=sy.at(0).at(0);
  int mx=sx.at(0).at(0);
  bool f=0;
  for(int i=0;i<h&&sy.at(i).at(0)==my;i++){
    for(int j=0;j<w&&sx.at(j).at(0)==mx;j++){
      if(!yx.count({sy.at(i).at(1),sx.at(j).at(1)})){
        f=1;
        i=h;
        j=w;
      }
    }
  }
  cout<<mx+my-(f?0:1)<<endl;
}

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

using namespace std;
 
const long long inf = 1e18;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

ll n,m,k;
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	n = s.length();
	if (s[n-2] == 'B') {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
	return 0;
}

Measured memory_bytes: 3640
<?php
list($n) = ints();
$max = (int) (sqrt($n) + 1);
$ans = array_fill(1, $n, 0);
for ($x = 1; $x <= $max; ++$x) {
    for ($y = $x; $y <= $max; ++$y) {
        for ($z = $y; $z <= $max; ++$z) {
            $t = $x ** 2 + $y ** 2 + $z ** 2 + $x * $y + $y * $z + $x * $z;
            if ($t <= $n) {
                $c = count(array_unique([$x, $y, $z]));
                if ($c === 3) $ans[$t] += 6;
                elseif ($c === 2) $ans[$t] += 3;
                else ++$ans[$t];
            }
        }
    }
}
echo implode(PHP_EOL, $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

#define MAX_N 200
#define MAX_X 100000
#define MOD 1000000007LL
typedef long long int ll;

int n;
ll x, s[MAX_N], dp[MAX_X + 1], inv[MAX_N + 1];


int main() {
  std::cin >> n >> x;
  for(int i = 0; i < n; ++i) {
    std::cin >> s[i];
  }

  inv[1] = 1;
  for(int i = 2; i <= MAX_N; ++i) {
    inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
  }

  for(int i = 1; i <= x; ++i) {
    int cnt = 0;
    for(int j = 0; j < n; ++j) {
      if(s[j] <= i) {
        ++cnt;
        dp[i] = (dp[i] + dp[i % s[j]]) % MOD;
      }
    }
    if(cnt == 0) {
      dp[i] = i;
    } else {
      dp[i] = inv[cnt] * dp[i] % MOD;
    }
  }

  ll ans = dp[x];
  for(int i = 2; i <= n; ++i) {
    ans = ans * i % MOD;
  }

  std::cout << ans << std::endl;
}


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

int n, W;
int v[110], w[110];
int dp[110][10010];

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

  cin >> n >> W;
  for (int i = 0; i < n; i++) {
    cin >> v[i] >> w[i];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= W; j++) {
      if (j >= w[i]) dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j]);
      else dp[i+1][j] = dp[i][j];
    }
  }

  cout << dp[n][W] << endl;

}


Measured memory_bytes: 7072
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
#include <utility>
using namespace std;
typedef long long longlong;
typedef long long LL;

int main(void) {
	LL h, w, i, j, k;
	char s = '#';
	cin >> h >> w;
	vector<vector<char>> a(h, vector<char>(w+2));
	for (i = 0; i < h; i++) {
		for (j = 0; j < w+2; j++) {
			a[i][j] = s;
		}
	}
	for (i = 0; i < h; i++) {
		for (j = 1; j < w+1; j++) {
			cin >> a[i][j];
		}
	}
	for (i = 0; i < w + 2; i++) {
		cout << s;
	}
	cout << endl;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w+2; j++) {
			cout << a[i][j];
		}
		cout << endl;
	}
	for (i = 0; i < w + 2; i++) {
		cout << s;
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	double a, b;
	int i, a_i, b_i;
	scanf("%lf%lf", &a, &b);

	for (i = 0; i <= 1001; i++) {
		a_i = i * 0.08;
		b_i = i * 0.10;
		if (a_i == a && b_i == b)
			break;

		if (i == 1001) {
			i = -1;
			break;
		}
	}

	printf("%d", i);
}

Measured memory_bytes: 128
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const K = parseInt(arg[0].split(" ")[0]);
    const X = parseInt(arg[0].split(" ")[1]);
    
    console.log(500 * K >= X ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
int main(){
    long long N; cin>>N;
    long k=0;
    for(long j=1;j<=sqrt(N);j++){
        if(N%j==0){
            k=N/j;
        }
    }
  cout<<k+N/k-2<<endl;
    
}



Measured memory_bytes: 256
N, M = list(map(int, input().split()))
LRD = [list(map(int, input().split())) for _ in range(M)]

roots = [(i,0) for i in range(N+1)] #(root, distance_to_root)

def find_root(a, roots=roots):
  if roots[a][0] == a:
    return (a,0)
  else:
    r, d = find_root(roots[a][0])
    roots[a] = (r, roots[a][1] + d)
  return roots[a]

def unite(l, r, d, roots=roots):
  root_l, d_l = find_root(l)
  root_r, d_r = find_root(r)
  if root_l == root_r:
    if d_l == d + d_r:
      return True
    else:
      return False
  else:
    roots[root_l] = (r, d - d_l)
    return True

for l,r,d in LRD:
  if not unite(l,r,d):
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 63212
# -*- coding: utf-8 -*-
import sys

N = int(input())
A = [int(i) for i in input().split()]

for a in A:
    if a % 2 == 0:
        # 偶数なら
        if a % 3 != 0 and a % 5 != 0:
            print('DENIED')
            sys.exit()

print('APPROVED')

Measured memory_bytes: 3060
n, a, b = map(int, input().split())
if a > b:
    ans = 0
elif n == 1 and a == b:
    ans = 1
elif n == 1:
    ans = 0
elif a == b:
    ans = 1
else:
    maxVal = a * 1 + b * (n-1)
    minVal = a * (n-1) + b * 1
    ans = maxVal - minVal + 1
print(ans)


Measured memory_bytes: 9076
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> x;
	for(int i=0;i!=n;++i){
		int t;
		cin>>t;
		x.push_back(t);
	}
	int ans=0;
	for(int i=1;i<n;++i){
		if(x[i]==x[i-1]){
			++ans;
			x[i]=0;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin >> a >> b;
    if(a < b){
        cout << "a < b" <<endl;
    }else if(a > b){
        cout << "a > b" <<endl;
    }else{
        cout << "a == b"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>

int A[100000],n;

int binarySearch(int key){
  int left = 0,right = n,mid;
  while (left < right){
    mid = (left + right) / 2;
    if (A[mid] == key)return 1;
    else if (key < A[mid]) right = mid;
    else left = mid + 1;
  }
  return 0;
}


int main(){
  int i,j,m,num=0,key;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&m);
  for(j=0;j<m;j++){
    scanf("%d",&key);
    if(binarySearch(key)==1)num++;
  }
  printf("%d\n",num);

  return 0;
}
   



Measured memory_bytes: 2964
package main
import (
  "fmt"
  "os"
)
func main() {
  var n int
  var s,t string
  fmt.Scan(&n)
  fmt.Scan(&s)
  fmt.Scan(&t)
  for i:=0;i<n;i++ {
    if s[i:n] == t[0:n-i] {
      fmt.Println(n+i)
      os.Exit(0)
    }
  }
  fmt.Println(2*n)
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int n, x;
	cin >> n >> x;
	int l[200];

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

	int ans = 1;
	int d = 0;
	for(int i = 0;i < n;i++){
		d += l[i];
		if(d <= x) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

signed main(){
  string s;
  int k;
  cin >> k >> s;

  if(s.length() <= k)cout << s << endl;
  else{
    int l = s.length();
    rep(i, k){
      cout << s[i];
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char s[1000];
    int n, i;
    
    scanf("%s",s);
    n=strlen(s);
    
    for(i=0;i<n;i++){
        s[i]='x';
    }
    s[n]='\0';
    printf("%s\n",s);
    return 0;
}

Measured memory_bytes: 128
import bisect
A, B, Q = map(int, input().split())

s = [-float('inf')] + [int(input()) for i in range(A)] + [float('inf')]
t = [-float('inf')] + [int(input()) for i in range(B)] + [float('inf')]

res = []
for i in range(Q):
    x = int(input())
    b = bisect.bisect_right(s, x)
    a = b - 1
    d = bisect.bisect_right(t, x)
    c = d - 1
    ans = float('inf')
    for S in [s[a], s[b]]:
        for T in [t[c], t[d]]:
            ans = min(ans, abs(S - x) + abs(T - S), abs(T - x) + abs(S - T))
    res.append(ans)

print('\n'.join(map(str, res)))


Measured memory_bytes: 24412
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<ll>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main(){
   ll n,x,y ;
   cin>> n>> x>>y ;
   vector<ll> A(n-1) ;
   rep2(i,1,n-1){
     rep2(j,i+1,n){
       ll a=min(j-i,abs(i-x)+abs(j-y)+1) ;
       A[a-1]++ ;
     }
   }
   rep(i,n-1){
     cout<<A[i] <<endl ;
   }
    return 0;
  }

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(24) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                      \
    for (int i = 0; i < v.size(); i++) \
        P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int MOD = 1e9 + 7;

bool pairCompare(const pair<int, int> &firstElof, const pair<int, int> &secondElof)
{
    return firstElof.second < secondElof.second;
}

void solve()
{
    int n, k;
    cin >> n >> k;
    vi v;
    rep(i, n)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }
    double ans = 0.0;
    vector<double> d;
    d.push_back(0);
    double sum = 0.0;
    rep(i, n)
    {
        sum += double(double(v[i] + 1) / 2.0);
        d.push_back(sum);
    }
    REP(i, k, n + 1)
    {
        ans = max(ans, d[i] - d[i - k]);
    }
    sP(ans);
}

int main()
{
    solve();
    return 0;
}


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

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

	int S = 1; for (int i = 0; i < D; i++) S *= 100;
	if (N <= 99) {
		cout << S * N << endl;
	}
	else {
		cout << S * 101 << endl;
	}
	return 0;
}

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



int main(){
    ll n;
    cin>>n;
    ll arr[n][3];
    for(ll i=0;i<n;i++){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    }
    ll answer[n][3];
    answer[0][0] = arr[0][0];
    answer[0][1] = arr[0][1];
    answer[0][2] = arr[0][2];
    for(ll i=1;i<n;i++){
        for(ll j=0;j<3;j++){
            answer[i][j] = arr[i][j] + max(answer[i-1][(j+1)%3],answer[i-1][(j+2)%3]);
        }
    }
    ll answerr = max(answer[n-1][0],max(answer[n-1][1],answer[n-1][2]));
    cout<<answerr<<endl;
    return 0;
}

Measured memory_bytes: 8296
#include<iostream>
using namespace std;
int main(){
	while(1){
		int a,b;
		char op;
		cin >> a >> op >> b;
		if(op == '?')break;
		switch(op){
		case '+':
			cout << a+b << endl;
			break;
		case '-':
			cout << a-b << endl;
			break;
		case '*':
			cout << a*b << endl;
			break;
		case '/':
			cout << a/b << endl;
			break;
		case '%':
			cout << a%b << endl;
			break;
		}
	}
	return  0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int A[200000];
int main(){
  int i, ind, mx, mx2;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY, Q5VJL1cS;
    if(N==0){
      Q5VJL1cS = 0;
    }
    else{
      Q5VJL1cS = A[0];
      for(KL2GvlyY=1;KL2GvlyY<N;KL2GvlyY++){
        Q5VJL1cS = max_L(Q5VJL1cS, A[KL2GvlyY]);
      }
    }
    mx =Q5VJL1cS;
  }
  {
    int FmcKpFmN, RZTsC2BF=0, WYIGIcGE, cTE1_r3A, xr20shxY;
    for(cTE1_r3A=0;cTE1_r3A<((N)-1)+1;cTE1_r3A++){
      xr20shxY = A[cTE1_r3A];
      if(RZTsC2BF==0 || FmcKpFmN<xr20shxY){
        FmcKpFmN = xr20shxY;
        RZTsC2BF = 1;
        WYIGIcGE = cTE1_r3A;
      }
    }
    ind =WYIGIcGE;
  }
  mx2 = 0;
  for(i=0;i<N;i++){
    if(i!=ind){
      chmax(mx2, A[i]);
    }
  }
  for(i=0;i<N;i++){
    if(i==ind){
      wt_L(mx2);
      wt_L('\n');
    }
    else{
      wt_L(mx);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, A[2d5];
// {
//   int i, mx, ind, mx2;
//   rd(N,A(N));
// 
//   mx = max(A(N));
//   ind = argmax(A(N));
// 
//   mx2 = 0;
//   rep(i,N) if(i!=ind) mx2 >?= A[i];
// 
//   rep(i,N) wt( if[i==ind, mx2, mx] );
// }


Measured memory_bytes: 2432
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    int a,b,s=1;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {  
      	if(i<0)s*=-1;
      	if(i==0){
	  		cout<<"Zero"<<endl;
			return 0;
		}
    }
    if(s>0)cout<<"Positive"<<endl;
    if(s<0)cout<<"Negative"<<endl;
    if(s==0)cout<<"Zero"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <limits>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <iterator>
#include <functional>

using namespace std;

typedef unsigned                    ui;
typedef int                         si;
typedef long                        sl;
typedef long long                   ll;
typedef unsigned long long          ull;

#ifdef LOCALHOST
std::ifstream in("input.txt", std::ifstream::in);
#endif // LOCALHOST

#ifdef LOCALHOST
#define is in
#else
#define is cin
#endif // LOCALHOST

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main(int argc, char *argv[])
{
    std::ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;

    vector<vector<ll>> h(n, vector<ll>(3, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> h[i][j];
        }
    }

    vector<vector<ll>> dp(n, vector<ll>(3, 0));
    dp[0][0] = h[0][0];
    dp[0][1] = h[0][1];
    dp[0][2] = h[0][2];

    for (int i = 1; i < n; ++i) {
        for (int now = 0; now < 3; ++now) {
            for (int last = 0; last < 3; ++last) {
                if (now == last) {
                    continue;
                }

                dp[i][now] = max(dp[i][now], dp[i - 1][last] + h[i][now]);
            }
        }
    }

    ll answer = 0;
    for (int i = 0; i < 3; ++i) {
        answer = max(answer, dp[n - 1][i]);
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 11264
using Yorukatsu016.Questions;
using Yorukatsu016.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu016.Questions
{
    /// <summary>
    /// ABC078 C
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nm = inputStream.ReadIntArray();
            var n = nm[0];
            var m = nm[1];

            var pAcc = 1m;
            for (int i = 0; i < m; i++)
            {
                pAcc *= 0.5m;
            }
            var pRej = 1 - pAcc;

            var eachTime = 100 * (n - m) + 1900 * m;

            yield return (int)(pAcc * eachTime / (pAcc * pAcc));
        }
    }
}


namespace Yorukatsu016
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu016.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu016.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.IntStream;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            Integer N = Integer.valueOf(args.get(0).split(" ")[0]);
            Integer L = Integer.valueOf(args.get(0).split(" ")[1]);
            Integer sum = IntStream.range(0, N).map(n -> n + L).sum();
            int min = Integer.MAX_VALUE;
            boolean minus = true;
            for (int i = 0; i < N; i++) {
                if (min > Math.abs(i + L)) {
                    min = Math.abs(i + L);
                    minus = i + L < 0;
                }
            }
            System.out.println(sum - ((minus) ? -min : min));
        };
    }

}


Measured memory_bytes: 27092
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  cout << ((M1 != M2) ? 1 : 0) << endl;
  return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a > b){
    for(int i = 0; i < a; i++){
      cout << b;
    }
    cout << endl;
  }else{
    for(int i = 0; i < b; i++){
      cout << a;
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>

#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[201];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4;
    //float f,g,h;
    char c;
    string s,s1;
    //priority_queue<int> pq;
    //map<string,int> mp;
    //map<string,int>::iterator iter;
    cin>>a1>>a2>>n;
    if((a2-a1+1)<=2*n)
        for(i=a1;i<=a2;i++)
            cout<<i<<endl;
    else
    {
        for(i=a1;i<a1+n;i++) cout<<i<<endl;
        for(i=a2-n+1;i<=a2;i++) cout<<i<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
import os
from collections import Counter

import math
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353
def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret
def get_primes(max=None, count=None):
    """
    素数列挙
    昇順にソートされています
    https://qiita.com/Ishotihadus/items/73e107271275611f05f2
    :param int max:
    :param int count:
    """
    assert max is not None or count is not None
    if count:
        raise NotImplementedError()
    if max <= 1:
        return []

    primes = [2]
    sieve = [False for _ in range(max + 1)]
    p = 3
    while p <= max:
        primes.append(p)
        sieve[p] = True
        if p <= math.sqrt(max):
            for i in range(p * (p | 1), max + 1, p * 2):
                sieve[i] = True
        while p <= max and sieve[p]:
            p += 2

    return primes

N = int(sys.stdin.buffer.readline())

# primes = get_primes(max=1000001)
# a = math.sqrt(10**12)


fs = Counter(get_factors(N))
ans = 0
for k, c in fs.items():
    m = 1
    while c >= m:
        c -= m
        m += 1
        ans += 1
print(ans)


Measured memory_bytes: 9552
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll K;
	cin >> K;
	ll N = 50;
	vector<ll> ans(N);
	ll x = K/N;
	rep(i,N)ans[i] = i+x;
	for(int i=0;i<K%N;i++){
		ans[i]+=N;
		rep(j,N){
			if(i==j)continue;
			ans[j]--;
		}
	}
	cout << N << endl;
	rep(i,N)cout << ans[i] << " ";
	cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char S[100];
    int i,cnt=0,size;
    scanf("%s",S);
    size = strlen(S);
    for(i=0;2*i<size;i++){
        if(S[i] != S[size-1-i]){
            cnt += 1 ;
        }
    }
    printf("%d\n",cnt);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {

//    for (int m = 1; m < 1000; m++) {
//        int n = m;
    ll n;
    cin >> n;
        vector<char> ans;

        while (n > 0) {
            char c = char('a' + ((n - 1) % 26));
            ans.push_back(c);
            n = (n - 1) / 26;
        }

        reverse(ans.begin(), ans.end());
//        cout << m << ' ';
        for (char c : ans) cout << c;
        cout << endl;

//    }
}

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

void solve()
{
	ll x;
	cin>>x;

	for(ll i = 1;i<3982; i++)
	{
		ll k = pow(i,5);
		for(ll j = -3981; j<3982;j++)
		{
			ll e = pow(j,5);
			if(k-e==x)
			{
				cout<<i<<" "<<j;
				return;
			}
		}

	}
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 4068
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, k;

    cin >> n >> k;

    vector<ll> a(n + 1);

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

    int ans = 1;

    while (k)
    {
        if (k & 1)
        {
            ans = a[ans];
        }

        vector<ll> d(n + 1);

        for (int i = 1; i <= n; i++)
        {
            d[i] = a[a[i]];
        }

        a = d;

        k >>= 1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  for (int i = 0; i < 100; i++) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    
    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}



Measured memory_bytes: 3596
// At Corder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <algorithm>
#include <iostream>
using namespace std;
#include <vector>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using p = pair<int, int>;//<key,value>

int main()
{
	int n;
	cin >> n;
	if (n%10 == 9 || n/10 == 9)
		cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
import java.math.*;
import java.util.*;
  
  

public class Main {

	static int n;
	static int in[]=new int[10];
	static boolean ans;
	public static void main(String[] args) {
          
        
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
        	n=scan.nextInt();
	        for(int i=0;i<n;i++) {
	        	
	        	for(int j=0;j<10;j++)in[j]=scan.nextInt();
	        	ans=false;
	        	dfs(0,0,0);
	        	System.out.println(ans?"YES":"NO");
	        }
        }
        
        
        
        
	}
	private static void dfs(int d,int left,int right) {
		if(ans)return;
		if(d==10) {
			ans=true;
			return ;
		}
		if(in[d]>left)dfs(d+1,in[d],right);
		if(in[d]>right)dfs(d+1,left,in[d]);
			
		

	}
	
	
	
	
}


Measured memory_bytes: 26128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 500000000
#define IOS ios_base::sync_with_stdio(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
const int N=200010;
vector<int>adj[N];
int val[N];
bool vis[N];
void dfs(int node,int carry)
{
    for(int i=0;i<adj[node].size();i++)
    {
        int chi=adj[node][i];
        if(vis[chi]==0)
        {
            vis[chi]=1;
            dfs(chi,carry+val[chi]);
            val[chi]+=carry;
        }
    }
}
int main()
{
    IOS;
    int n,q;cin>>n>>q;
    for(int i=0;i<n-1;i++)
    {
        int a,b;cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    while(q--)
    {
        int p,cst;cin>>p>>cst;
        val[p]+=cst;
    }
    vis[1]=1;
    dfs(1,val[1]);
    cout<<val[1];
    for(int i=2;i<=n;i++)cout<<" "<<val[i];
    cout<<endl;
}








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

const int INF = 1 << 30;

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

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

    int ans = INF;
    for (int i = 0; i < (1 << n); ++i) {
      int p = 0, b = 0;
      for (int j = 0; j < n; ++j) {
	if (i & (1 << j))
	  p += a[j];
	else
	  b += a[j];
      }
      ans = min(ans, abs(p-b));
    }

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 904
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  int count = 0;
  string S;
  cin >> S;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'o') count++;
  }

  if (count + (15 - S.length()) >= 8)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
using ll = long long;

const int INF = (int) 1e9 + 9;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int cur = 0;
    priority_queue<int> q;
    rep(i, 0, n) {
        cin >> cur;
        q.push(cur);
    }
    ll ans = 0;
    while (m--) {
        int x = q.top(); q.pop();
        q.push(x/2);
    }
    while (q.size()) {ans += q.top(); q.pop();}
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 892
class Node:
    def __init__(self, label):
        self.label = label
        self.left = None
        self.right = None

def bst_insert(node, label):
    if node is None:
        return Node(label)
   
    elif label< node.label:
        node.left = bst_insert(node.left, label)
    else:
        node.right = bst_insert(node.right, label)
    return node


def bst_inorder(node):
    global In
    if (node.left is not None):
        bst_inorder(node.left)
    In.append(node.label)
    if (node.right is not None):
        bst_inorder(node.right)
    return

def bst_preorder(node):
    global Pre
    Pre.append(node.label)
    if (node.left is not None):
        bst_preorder(node.left)
    if (node.right is not None):
        bst_preorder(node.right)
    return 

n= int(input())
tree = None
for i in range(n):
    cmmd = list(input().split( ))
    if cmmd[0] == "insert":
        k =int(cmmd[1])
        tree = bst_insert(tree, k)
    else:
        In =[]
        bst_inorder(tree)
        print("",*In)
        Pre =[]
        bst_preorder(tree)
        print("",*Pre)


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	priority_queue<int> ans;
	forn(i, n) {
		int input; scanf("%d", &input);
		ans.push(input); 
	}
	while(m--) {
		int x = ans.top(); ans.pop();
		x /= 2; ans.push(x);
	}
	long long count = 0;
	while(!ans.empty()) {
		count += ans.top(); ans.pop();
	}
	printf("%ld", count);
}










Measured memory_bytes: 892