akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MODS 100005
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define ld long double
#define bigint int64_t
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define mp make_pair
#define pb push_back
#define test ll t;read(t);while(t--)
#define pll pair<ll,ll>
#define vvll vector<vector<ll>>
#define fst first
#define scd second
#define ins insert
#define line "\n"
string yes="YES";
string no="NO";

#define forn(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define for1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define forr(i,n) for(ll (i) = (n)-1 ; (i)>=0 ; --(i))
#define forab(i,a,b,c) for(ll (i) = a ; (i) <= (b) ; (i)+=(c))

template <typename T>
void read(T &x){
    cin >> x;
}
template <typename T , typename T0>
void read(T &x,T0 &y){
    cin >> x >> y;
}

template <typename T , typename T0 , typename T1>
void read(T &x,T0 &y,T1 &z){
    cin >> x >> y >> z;
}

template <typename T , typename T0 , typename T1 , typename T2>
void read(T &x,T0 &y,T1 &z,T2 &w){
    cin >> x >> y >> z >> w;
}

template <typename T , typename T0>
void read(pair< T , T0 > &p){
    cin >> p.fst >>p.scd;
}

template <typename T>
void read(vector< T > &oneD,ll n){
    forn(i,n)
    {
        ll x;
        read(x);
        oneD.push_back(x);
    }
}

template <typename T>
void read(T oneD[] , ll n){
    for(ll i=0;i<n;i++){
        read(oneD[i]);
    }
}

template <typename T>
void write(T &x){

    cout << x << " ";
}

template <typename T>
void wrtline(T &x){

    cout << x << line;
}

template <typename T , typename T0>
void write(T &x,T0 &y){
    cout << x << " " << y << "\n";
}

template <typename T , typename T0 , typename T1>
void write(T &x,T0 &y,T1 &z){
    cout << x << " " << y << " " << z << "\n";
}

template <typename T , typename T0 , typename T1 , typename T2>
void write(T &x,T0 &y,T1 &z,T2 &w){
    cout << x << " " << y << " " << z << " " << w << "\n";
}

template <typename T , typename T0>
void write(pair< T , T0 > &p){
    write(p.fst);
    write(p.scd);
    cout << line;
}

template <typename T>
void write(vector< T > &oneD,ll n){
    for(ll i=0;i<n;i++){
        cout<<oneD[i]<<" ";
    }
    cout << line;
}

template <typename T>
void write(T oneD[] ,int n){
    for(ll i=0;i<n;i++){
        write(oneD[i]);
    }
    cout <<line;
}

template <typename T , typename T0>
void write(map< T , T0 > &mpp){
    for(auto it : mpp){
        write(it.fst);
        cout << ": ";
        write(it.scd);
        cout << "\n";
    }
    cout<<line;
}
void write(vvll rc,ll n,ll m)
{
    forn(i,n)
    {
        forn(j,m)
        {
            cout<<rc[i][j]<<" ";
        }
        cout<<line;
    }
}
void solve()
{
    ll n,k;
    read(n,k);
    vll c;
    read(c,n);
    sort(all(c));
    ll ct=0;
    forn(i,k)
    {
        ct+=c[i];
    }
    wrtline(ct);
}
int main() {
    /*#ifndef ONLINE_JUDGE
         freopen("input.txt", "r", stdin);
         freopen("output.txt", "w", stdout);
     #endif*/
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//*******************************************************//
/*test*/
solve();

return 0;
}


Measured memory_bytes: 3488
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    S = list(_ for _ in input())
    l = S.count('E')
    r = 0
    ans = min(S.count('E'),S.count('W'))
    for i in range(N):
        if i != N-1:
            if S[i] == 'E':
                l = l - 1
        if i != 0:                        
            if prev == 'W':
                r = r + 1
        prev = S[i]
        ans = min(ans,l+r)
        # print(ans,l,r)
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 6544
//
// Created by Myabu on 2020/01/06.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int A, B;

    cin>>A>>B;

    int ans;
    ans = max(A+B, A-B);
    ans = max (ans, A*B);

    cout<<ans<<endl;


    return 0;
}



Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

string maze[2020];
int h, w, q;
int rui[2020][2020], rui2[2020][2020], rui3[2020][2020];

int main() {
	cin >> h >> w >> q;
	for (int i = 1; i <= h; i++)cin >> maze[i], maze[i] = " " + maze[i];
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			rui[i][j] = rui[i - 1][j] + rui[i][j - 1] - rui[i - 1][j - 1] + (maze[i][j] == '1' ? 1 : 0);
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 2; j <= w; j++) {
			rui2[i][j] = rui2[i - 1][j] + rui2[i][j - 1] - rui2[i - 1][j - 1] + ((maze[i][j] == '1'&&maze[i][j - 1] == maze[i][j]) ? 1 : 0);
		}
	}
	for (int j = 1; j <= w; j++) {
		for (int i = 2; i <= h; i++) {
			rui3[i][j] = rui3[i - 1][j] + rui3[i][j - 1] - rui3[i - 1][j - 1] + ((maze[i][j] == '1'&&maze[i - 1][j] == maze[i][j]) ? 1 : 0);
		}
	}
	REP(i, q) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int num = rui[c][d] - rui[c][b - 1] - rui[a - 1][d] + rui[a - 1][b - 1];
		int num2 = rui2[c][d] - rui2[c][b] - rui2[a - 1][d] + rui2[a - 1][b];
		int num3 = rui3[c][d] - rui3[c][b - 1] - rui3[a][d] + rui3[a][b - 1];
		//cout << num << " " << num2 << " " << num3 << endl;
		cout << num - num2 - num3 << endl;
	}
}

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

Measured memory_bytes: 256
import java.util.Scanner;


class Main{
    public static void main(String[] a){
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) {
				break;
			} else {
				int ua = 0;
				int ub = 0;
				for(int i=0; i<n; i++) {
					int va = sc.nextInt();
					int vb = sc.nextInt();
					if (va > vb) {
						ua += va+vb;
					} else if (vb > va) {
						ub += va + vb;
					} else {
						ua += va;
						ub += vb;
					}
				}
				System.out.println(ua + " " + ub);
			}
		}
	}
}

Measured memory_bytes: 56532
import sys
input = sys.stdin.readline

x=int(input())

import math 
L=int(math.sqrt(x))

FACT=dict()

for i in range(2,L+2):
    while x%i==0:
        FACT[i]=FACT.get(i,0)+1
        x=x//i

if x!=1:
    FACT[x]=FACT.get(x,0)+1

ANS=0
for f in FACT.values():
    i=1
    while f:
        if f>=i:
            ANS+=1
            f-=i
            i+=1
        else:
            break
print(ANS)


Measured memory_bytes: 63256
def ABC106():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)
        # divisors.sort()
        return divisors
    N = I()
    ans = 0
    for i in range((N+1)//2):
        cur = i*2+1
        if len(make_divisors(cur))==8:
            ans += 1
    print(ans)
    return

def exam2():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    ABC106()

"""

"""

Measured memory_bytes: 3824
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    char a[32];
    cin  >> a;
    replace(a,a+32,',',' ');
    cout << a;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int  n,m;
ll k,a[200001],b[200001],sa[200001],sb[200001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m>>k;
	rep(i,n)
	cin>>a[i];
	rep(i,m)
	cin>>b[i];
	forn(i,1,n+1)
	sa[i]=sa[i-1]+a[i-1];
	forn(i,1,m+1)
	sb[i]=sb[i-1]+b[i-1];
	int ans=0;
	rep(i,n+1){
		if(sa[i]>k)
		break;
		int l=0,r=m;
		while(l<r){
			int mid=(l+r+1)/2;
			if(sb[mid]>k-sa[i])
			r=mid-1;
			else
			l=mid;
		}
		ans=max(ans,i+l);
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 9892
A,B,K = map(float,raw_input().split())
ans_A=0
ans_B=0
if A <= K:
  ans_A=0
  if K-A < B:
    ans_B = int(B-(K-A))
    print ans_A,ans_B
  else:
    print 0,0
else:
  ans_A=A-K
  print int(ans_A),int(B)


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

int frog(int n,int a[],int dp[])
{
	//base case
	if(n==1)
		return 0;

	if(dp[n]!=-1)
		return dp[n];
	//recursion case
	if(n>=3)
		dp[n]=std::min(abs(a[n]-a[n-1])+frog(n-1,a,dp),abs(a[n]-a[n-2])+frog(n-2,a,dp));
	else if(n==2)
		dp[n]=abs(a[n]-a[n-1])+frog(n-1,a,dp);

	return dp[n];
}
int main()
{

	int n;cin>>n;

	int a[n+1];
	int dp[n+1];

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

	for (int i = 1; i <=n; ++i)
	{
		cin>>a[i];
	}
	int ans=frog(n,a,dp);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main(void) {
	int n, x;
	int i, j, k,answer;

	while (1)
	{
		scanf("%d %d", &n, &x);
		if (n == 0 && x == 0)break;

		answer = 0;

		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				for (k = j + 1; k <= n; k++) {
					if (i + j + k == x)answer++;
				}
			}

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

	return 0;
}



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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

ll a, b, c, d, sum;

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

int main() {
    cin >> a >> b >> c >> d;
    sum+=b/c-(a-1)/c;
    sum+=b/d-(a-1)/d;
    int e=gcd(c,d);
    sum-=b/(c*d/e)-(a-1)/(c*d/e);
    cout<<b-a+1-sum<<endl;
    return 0;
}


Measured memory_bytes: 3588
a,b = gets.split(" ").map(&:to_i)
c,d = gets.split(" ").map(&:to_i)
e,f = gets.split(" ").map(&:to_i)

ary = a,b,c,d,e,f
ary.sort!

iti = ary.count(1).to_i
ni = ary.count(2).to_i
san = ary.count(3).to_i
yon = ary.count(4).to_i

if (iti >= 3) || (ni >= 3) || (san >= 3) || (yon >= 3)
  puts 'NO'
elsif (iti == 0) || (ni == 0) || (san == 0) || (yon == 0)
  puts 'NO'
else
  puts 'YES'
end

Measured memory_bytes: 1788
// 23
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef DEBUG
// 3
ostream &operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 4
ostream &operator<<(ostream &o, vector<auto> v) {
  rep(i, len(v)) o << setw(7) << right << v[i];
  return o << endc << endl << coutc;
}
// 4
ostream &operator<<(ostream &o, map<auto, auto> m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
void debug(const auto &e, const auto &... r) {
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
}
#else
#define debug(...)
#endif
// 3
void _main(int tc) {
  int n;
  cin >> n;
  li ans = 1;
  bool zero = false, exceeds = false;
  const li limit = 1e18;

  rep(n) {
    li x;
    cin >> x;
    if (x == 0) {
      zero = true;
      break;
    }
    if (ans > 0 && x > limit / ans) {
      exceeds = true;
    }
    ans *= x;
  }
  if (zero)
    cout << 0 << endl;
  else if (exceeds)
    cout << -1 << endl;
  else
    cout << ans << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	pair<int,int> a[n];
	rep(i,n){
		cin>>a[i].first;
		a[i].second=i+1;
	}
	sort(a,a+n);

	rep(i,n) cout<<a[i].second<<" ";
	cout<<"\n";

}

Measured memory_bytes: 1536
//#######################     Starting_with_name_of_ALLAH     ##############################
//#######################     Bismillahir_rahmair_raheem      ##############################
 
//                      coded in 2020
//
//                   Shamim Ahammad Rasel
//                  Begum Rokeya University
//                 shamim.brur.cse@gmail.com
//                    I love your thinking 


#include<bits/stdc++.h>
#include<bitset>
#include<iostream>
#define tc()         int tc;cin>>tc;while(tc--)

using namespace std;


bitset<1000001> prime;


void shomoy();

void seive(){
    // o prime
    // 1 not prime
    prime[1] = 1;
    prime[2] = 0;
    for(int i=3;i*i<1000009;i+=2){
        if(prime[i]==0){
            for(int j=i+i;j<1000009;j+=i){
                prime[j] = 1;
            }
        }
    }
}

long long fact(int n){
    long long mul = 1;
    for(int i=1;i<=n;i++){
        mul *= i;
    }
    return mul;
}



int npr(int n,int r){
    int mul=1;
    int temp =0;
    for(int i=0;i<r;i++){
        mul *= (n-i);
    }
    return mul;
}
int divisor(int n){
	int d = 0;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			d += 2;
		}
	}
	int temp;
	temp = sqrt(n);
	if(temp*temp == n){
		d--;
	}
	return d;
}

int main(){
	ios::sync_with_stdio();
	cin.tie();
    int  i,j,k,x,y,a,b,n,s,p,total=0,index,count,sum,temp,len,t,temp1,count1,count2,mn;
    
    cin>>n;
    total =0;
    for(i=1;i<n;i++){
    	temp = n - i;
    	total += (divisor(temp));
    }
    cout<<total<<endl;
	    

    

   


shomoy();
return 0;
}




void shomoy(){
    #ifndef ONLINE_JUDGE
        cerr<<"---------END OF OUTPUT---------------\n";
        cerr<<"---------Time  :"<<1.0*clock()/CLOCKS_PER_SEC<<"s------------\n";
        
    #endif
 
}


Measured memory_bytes: 3700
/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("avx2")

#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define ii pair<int,int>
#define fst first
#define scd second
#define vi vector<int>
#define vii vector<ii>
#define pb push_back
#define pf push_front
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
#define des(x,s1,s2,end1,end2) cout<<((x)?(s1):(s2))<<fl;if(x){end1;}else{end2;}
#define precision(x) cout.setf(ios::fixed);cout.precision(x);
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///=====================================================================

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

    cout<<a+a*a+a*a*a;

return 0;}







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

using namespace std;

#define cerr if(true)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef long long ll;
typedef pair<ll, ll> ii;

const ll maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 322;

int main(){

	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	cout.tie(0);

	ll n, k;
	cin >> n >> k;

	ll arr[n];

	for(ll i = 0; i < n; i++){
		cin >> arr[i];
		--arr[i];
	}

	//Empieza el ciclo
	vector<bool> vis(n, false);
	ll indx = 0;
	while(!vis[indx]){
		vis[indx] = true;
		indx = arr[indx];
	}

	//Size del ciclo
	vis.assign(n, false);
	ll cont = 0;
	ll sec = indx;
	while(!vis[sec]){
		vis[sec] = true;
		sec = arr[sec];
		++cont;
	}

	//Pasos para llegar al ciclo
	sec = 0;
	ll pasos = 0;
	while(sec != indx){
		sec = arr[sec];
		++pasos;
	}	

	

	if(k < pasos){
		ll i = 0;
		ll aux = 0;
		while(i < k){
			aux = arr[aux];
			++i;
		}
		cout << aux + 1<< endl;
	}else{
		k -= pasos;
		k %= cont;
		while(k){
			indx = arr[indx];
			--k;
		}
		cout << indx + 1 << endl;
	}



	return 0;
}

Measured memory_bytes: 5236
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            long[] nk  = ILongs();
            long n = nk[0];
            long k = nk[1];
            long[][] td = ILongLongs(n);

            Array.Sort(td,Compare);
            //for(int i=0;i<n;i++){
            //    Console.Write(td[i][0]);
            //    Console.Write(" ");
            //    Console.WriteLine(td[i][1]);
            //}

            HashSet<long> sset = new HashSet<long>();
            bool[] kaburi = new bool[n];

            long ans = 0;
            long syurui = 0;

            for(long i=0;i<k;i++){
                ans += td[i][1];
                if(!(kaburi[i] = !sset.Add(td[i][0]))){
                    syurui ++;
                }
            }
            ans += syurui * syurui;
            long ansppoi = ans;

            long imal = k-1;
            long imar = k;
            while(imal>-1&&imar<n){
                if(kaburi[imal]){
                    if(sset.Add(td[imar][0])){
                        ansppoi -= td[imal][1];
                        ansppoi += td[imar][1];
                        ansppoi += 2*syurui + 1;
                        syurui ++;
                        if(ans < ansppoi)ans = ansppoi;
                        imal --;
                        imar ++;
                    }else{
                        imar ++;
                    }
                }else{
                    imal --;
                }
            }
            Console.WriteLine(ans);
        }

        static int Compare(long[] a, long[] b){
            if(a[1]>b[1])return -1;
            if(a[1]<b[1])return 1;
            return 0;
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}


Measured memory_bytes: 28100
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++ i)
#define per(i,a,b) for(int i = (a); i >= (b); -- i)
#define pb push_back
#define VI vector<int>
#define VVI vector<VI>
#define Pii pair<int,int>
#define Pll pair<ll,ll>
#define Pli pair<ll,int>
#define fi first
#define se second
#define Ppi pair<Pii,int>
#define VII vector<Pii>

using namespace std;

typedef long long ll;
typedef int (*funI_I) (int);
typedef int (*funI_II) (int, int);

constexpr int N = 4000100;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n, MX = 0;
    cin >> n;
    map<string , int> M;
    rep(i, 1, n) {
        string s;
        cin >> s;
        ++ M[s];
        MX = max(MX, M[s]);
    }
    for(auto A: M) {
        if( A.second == MX ) {
            cout << A.first << "\n";
        }
    }
}


Measured memory_bytes: 23808
#include "bits/stdc++.h"
using namespace std;
const int maxn = 333;
char s[maxn][maxn];
int cnt[maxn + maxn];
int main(){
	int n;
	scanf("%d", &n);
	for(int e = 0; e < n; e++)
		scanf("%s", s[e]);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			// for(int a = 0; a < n; a++){
			// 	// (i, j) -> (i + a, j + b)
			// 	// (j + b, i + a) -> (j + b - a, i + a - b)
			// 	// (j + a, i + ?)
			//
			// }
			for(int d = - n + 1; d < n; d++){
				int ni = (j + d + n)%n, nj = (i - d + n)%n;
				if(s[ni][nj] == s[i][j]) cnt[d + maxn]++;
			}
		}
	}
	int res = 0;
	for(int a = 0; a < n; a++){
		for(int b = 0; b < n; b++){
			if(cnt[b - a + maxn] == n * n) res++;
		}
	}
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
a = Array.new(m) { gets.to_i }
f = [0, 1]
skip = a.shift

1.upto(n) do |i|
  if i == skip
    f << 0
    skip = a.shift
    next
  end
  f << (f[i] + f[i - 1]) % 1_000_000_007
end

puts f[-1]

Measured memory_bytes: 3708
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (A, B, C) = Read3Longs();
            var K = ReadLong();

            if (IsValid(A, B, C, K))
            {
                return "Yes";
            }
            return "No";
        }
        private static bool IsValid(long A, long B, long C, long countMax)
        {
            var nums = new long[] { A, B, C };
            var count = 0;
            while (count <= countMax)
            {
                count++;
                if (nums[0] < nums[1] && nums[1] < nums[2])
                {
                    return true;
                }
                if (nums[0] >= nums[1])
                {
                    nums[1] = nums[1] * 2;
                    continue;
                }
                if (nums[1] >= nums[2])
                {
                    nums[2] = nums[2] * 2;
                    continue;
                }
            }
            return false;
        }
        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28208
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=1e5+3;
vector<int>v[N];
string s,p,t,ans[N];
map<pi,int>mp;
int main()
{
    ft
    int i,j,n,k,m,l,r;
    cin>>n>>m;
    for(i=0; i<m; i++)
    {
        cin>>l>>r;
        v[l].pb(r);
        mp[{l,r}]=i+1;
    }
    for(i=1; i<=n; i++)
    {
        sort(v[i].begin(),v[i].end());
        int sz=v[i].size();
        if(sz>0)
        {
            for(int z=0; z<sz; z++)
            {
                s.clear();
                p.clear();
                l=0;
                r=i;
                while(r!=0)
                {
                    s+=((r%10)+48);
                    r/=10;
                    l++;
                }
                for(k=0; k<(6-l); k++)
                {
                    p+='0';
                }
                reverse(s.begin(),s.end());
                t=p+s;
                l=0;
                r=z+1;
                s.clear();
                p.clear();
                while(r!=0)
                {
                    s+=((r%10)+48);
                    r/=10;
                    l++;
                }
                for(k=0; k<(6-l); k++)
                {
                    p+='0';
                }
                reverse(s.begin(),s.end());
                int cc=mp[{i,v[i][z]}];
                ans[cc]=t+p+s;
            }
        }
    }
    for(i=1;i<=m;i++)
    {
        cout<<ans[i]<<"\n";
    }
    return 0;
}



Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

vector<int> G[N];

int dfs(int v,int p){
  int cur=0;
  int ct[24]; FILL(ct,0);
  REP(i,G[v].size()) if(G[v][i]!=p) {
    int x=dfs(G[v][i],v);
    REP(j,20) if((x>>j)&1){
      if(ct[j]==1) cur=max(j+1,cur);
      ct[j]++;
    }
  }
  while(ct[cur]) cur++;
  int occ=0;
  ct[cur]++;
  REPP(i,cur,20) if(ct[i]) occ|=1<<i;
  return occ;
}
int main(){
  int n; scanf("%d",&n);
  REP(i,n-1) {
    int x,y; scanf("%d%d",&x,&y);
    x--;y--;
    G[x].pb(y); G[y].pb(x);
  }
  int a=dfs(0,-1);
  int x=20;
 // printf("%d\n",a);
  while(((a>>x)&1)==0&&x>=0) x--;
  printf("%d\n",x); 
  return 0;
}

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

const ll ln=1000000007;

ll sum(ll l,ll r){
    return (l+r)*(r-l+1)/2;
}

int main(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i<=n+1;i++){
        ll l=sum(0,i-1), r=sum(n-i+1,n);
        ans+=r-l+1;
        if(ans>=ln)ans=ans%ln;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3564
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import deque
    n = int(readline())
    s = [input() for _ in range(n)]
    ans = 0
    que = deque()

    for i in range(n):
        dist = [-1] * n
        dist[i] = 0
        que.append((i, 0))
        while que:
            cur, d = que.popleft()
            adj = s[cur]
            for nx, is_connected in enumerate(adj):
                if is_connected == "1":
                    if dist[nx] == -1:
                        dist[nx] = d + 1
                        que.append((nx, d + 1))
                    else:
                        if dist[nx] % 2 != (d + 1) % 2:
                            return print(-1)
            ans = max(ans, max(dist) + 1)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74956
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
INF = float('inf')
dp = [INF] * (1 << N)
dp[0] = 0
for _ in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for i in c:
        bit += 1 << (i-1)
    for i in range(1 << N):
        dp[i | bit] = min(dp[i | bit], dp[i] + a)
print(dp[-1] if dp[-1] != INF else -1)


Measured memory_bytes: 44380
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	int t = b - a;
	cout << t * t - (t-1) * t / 2 - b << '\n';
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String[] l1 = r.readLine().split(" ");

		long n = Long.parseLong(l1[0]);
		long a = Long.parseLong(l1[1]);
		long b = Long.parseLong(l1[2]);

		long cnt = n / (a + b);
		long res = n % (a + b);
		if (res > a) {
			res = a;
		}

		System.out.println(String.valueOf(a * cnt + res));

		r.close();
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

const ll mod=1000000007;

int main() {
    int W,H,N;
    cin>>W>>H>>N;
    vi w(W,0),h(H,0);
    rep(i,N) {
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1) {
            rep(i,x) w[i]++;
        }
        else if(a==2) {
            for(int i=x; i<W; i++) w[i]++;
        }
        else if(a==3) {
            rep(i,y) h[i]++;
        }
        else {
            for(int i=y; i<H; i++) h[i]++;
        }
    }
    int a=0,b=0;
    rep(i,W) {
        if(w[i]==0) a++;
    }
    rep(i,H) {
        if(h[i]==0) b++;
    }
    cout<<a*b<<endl;
}

Measured memory_bytes: 256
//C#(.NET Core)の方に提出.

using System;
using static System.Math;

public class Program{
  public static void Main(string[] args) {

    //文字を指定する必要があるので,' 'の中には必ず半角スペースを入れておく.
    string[] strInput = Console.ReadLine().Split(' ');

    //Parseで32 ビット符号付き整数に変換.
    int a = int.Parse(strInput[0]);
    int b = int.Parse(strInput[1]);

    //標準出力に書き込み、出力終了記号まで書き込むには
    //Console.WriteLine()
    Console.WriteLine(a * b);
    //returnはあってもなくてもいい.
    return;
  }
}


Measured memory_bytes: 27428
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <list>
#include <numeric>
#include <cstdio>
#include <queue>


using namespace std;

int main() {

    int K, X;
    cin >> K >> X;
    
    K--;

    for (int i = X - K; i <= X+K; i++) {
        cout << i << ' ';
    }
    cout << '\n';

}



Measured memory_bytes: 256
#include "bits/stdc++.h"
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 replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
#define PI 3.1415926536
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int N;
	cin >> N;
	vector<int>a(N), num(100001, 0);
	rep(i, N) {
		cin >> a[i];
		num[a[i]]++;
	}
	int over = 0;
	rep(i, 100001) {
		over += max(0, num[i] - 1);
	}
	int ans = N - (over + (over % 2));

	cout << ans << endl;

	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int> > v(n + 1, vector<int>());
    map<int, int> x;
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        if(a == 1) x[b] = 1;
        if(b == n) v[n].push_back(a);
    }
    bool flag = false;
    for(auto i : v[n]){
        if(x[i] == 1){
            flag = true;
            break;
        }
    }
    if(flag) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}


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

int main(){
	int X,Y,Z,K;
	cin >> X >> Y >> Z >> K;
	vector<long long> A(X),B(Y),C(Z);
	for(auto &i:A)cin >> i;
	for(auto &i:B)cin >> i;
	for(auto &i:C)cin >> i;
	sort(A.begin(),A.end(),greater<long long>());
	sort(B.begin(),B.end(),greater<long long>());
	sort(C.begin(),C.end(),greater<long long>());
	
	vector<long long> AB;
	for(int i=0;i<min(K,X);i++)for(int j=0;j<min(K,Y);j++){
		AB.push_back(A[i]+B[j]);
	}
	
	sort(AB.begin(),AB.end(),greater<long long>());
	int XY=AB.size();
	
	vector<long long> ABC;
	for(int i=0;i<min(K,XY);i++)for(int j=0;j<min(K,Z);j++){
		ABC.push_back(AB[i]+C[j]);
	}
	
	sort(ABC.begin(),ABC.end(),greater<long long>());
	for(int i=0;i<K;i++)cout << ABC[i] << endl;
	
	return 0;
}

Measured memory_bytes: 42984
#include <stdio.h>
#define N 200

int kansu(int,int);
  
int a[N],b;

int kansu(int i,int y)
{
  int kusuo;
  if(y==0)
    return 1;
   if(i>=b)
    return 0;
  kusuo=kansu(i+1,y) || kansu(i+1,y-a[i]);
  return kusuo;
}


int main()
{
  int i,c,d,e;
  
  scanf("%d",&b);
  for(i=0;i<b;i++)
    {
      scanf("%d",&a[i]);
    }
  
  scanf("%d",&c);
  for(i=0;i<c;i++)
    {
      scanf("%d",&d);
      if(kansu(0,d))
	printf("yes\n");
      else printf("no\n");
    }
  return 0;
}




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

using namespace std;
using ll = long long;

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int t=0;
    while(a>0&&c>0) {
        if(t==0){
            c-=b;
            t=1;
        }
        else{
            a-=d;
            t=0;
        }
    }
    if(a<=0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n, k;
int minCost(int ind, vector<int> &h, vector<int> &dp) {
    if (ind == n-1) {
        return 0;
    }
    if (dp[ind] != -1) {
        return dp[ind];
    }
    int cost = INT_MAX;
    for (int i = 1;i<=k; i++) {
        if (ind+i <= n-1) {
            int costI = abs(h[ind]-h[ind+i]) + minCost(ind+i, h, dp);
            cost = min(cost, costI);
        }
    }
    return dp[ind] = cost;
}

int main() {
    cin>>n;
    cin>>k;
    vector<int> h(n);
    vector<int> dp(n, -1);
    for (int i=0;i<n;i++) cin>>h[i];
    cout<<minCost(0, h, dp);
}


Measured memory_bytes: 11900
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<u32>();

    let mut ans = 0;
    let mut i = 2;
    if n <= 3 {
        println!("1");
    } else {
        while i * i <= n {
            let mut x = i;
            while x * i <= n {
                x *= i;
            }
            ans = std::cmp::max(ans, x);

            i+=1;
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#define MAX 100
#define INFTY 100000000
#define WHITE 0
#define BLACK 2
#define GRAY 1

int n, M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX],color[MAX];
    
    for(int i=0; i<n; i++){
        d[i]=INFTY;
        color[i]=WHITE;
    }
    
    d[0]=0;
    color[0]=GRAY;
    while (1) {
        minv=INFTY;
        int u=-1;
        for(int i=0; i<n; i++){
            if(minv>d[i] && color[i] != BLACK){
                u=i;
                minv=d[i];
            }
        }
        
        if(u==-1) break;
        color[u]=BLACK;
        for(int v=0; v<n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v] > d[u] + M[u][v]){
                    d[v]= d[u]+M[u][v];
                    color[v]=GRAY;
                }
            }
        }
    }
    
  
    for(int i=0; i<n; i++){
        printf("%d %d\n",i, d[i] == INFTY ? -1 : d[i] );
    }

}

int main(){
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j]=INFTY;
        }
    }
    int k,c,u,v;
    for(int i=0; i<n; i++){
            scanf("%d %d",&u,&k);
        for(int j=0; j<k; j++){
            scanf("%d %d",&v,&c);
            M[u][v]=c;
        }
    }
    dijkstra();
    return 0;
            
    
    }


Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    string S,T;
    cin >> S;
    cin >> T;
    if( S == T.substr(0,S.size()) ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
   return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

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

        while(0 < a && 0 < c){
            c -= b;
            if(c <= 0) {
                System.out.println("Yes");
                break;
            }
            a -= d;
            if(a <= 0) {
                System.out.println("No");
                break;
            }
        }
    }
}

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

ll pref[405]={};

ll dp[405][405]={};

ll sum(ll a[], ll left, ll right){
//	ll ans=0;
//	for(ll i=left; i<=right; i++)
//		ans+=a[i];
//	return ans;
	// store pref at 1 base index
	return pref[right+1]-pref[left];
}

ll solve(ll a[], int left, int right){
	if(left >= right) return 0;
	
	if(dp[left][right] != -1)
		return dp[left][right];
	
	ll ans = 1e18+1;
	
	for(int k=left; k<=right-1; k++){
		ans=min(ans, solve(a, left, k) + solve(a, k+1, right) + sum(a, left, right) );
	}
	
	return dp[left][right] = ans;	
}

void solve(){
	int n;
	cin >> n;
	
	ll a[n]={};
	
	for(int i=0; i<n; i++)	
		cin >> a[i];
	
	memset(pref, 0, sizeof pref);
	
	pref[0]=0;
	for(int i=1; i<=n; i++){
		pref[i]=pref[i-1]+a[i-1];
	}
	
	// MCM
	memset(dp, -1, sizeof dp);
	ll ans = solve(a, 0, n-1);
	
	cout << ans << "\n";	
}

int main(){
	solve();
}


Measured memory_bytes: 4908
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

const int MOD = 1000000007;
int N;
char S[MAX_N + 1];
ll dp[MAX_N + 1][13];

void solve()
{
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    int c;
    if (S[i] == '?')
      c = -1;
    else
      c = S[i] - '0';

    for (int j = 0; j < 10; j++) {
      if (c != -1 && c != j) continue;
      for (int k = 0; k < 13; k++) {
        dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
      }
    }
    for (int j = 0; j < 13; j++) dp[i + 1][j] %= MOD;
  }
  ull res = dp[N][5];
  printf("%llu\n", res);
}

int main(void)
{
  cin >> S;
  N = strlen(S);
  solve();
  return 0;
}


Measured memory_bytes: 10496
def subst(S, T)-> int:
  lenT = len(T)
  result = lenT
  for i in range(lenT, len(S) + 1):
    tempS = S[i-lenT:i]
    tempResult = 0
    for j in range(lenT):
      if T[j] != tempS[j]:
        tempResult += 1
    if tempResult < result:
      result = tempResult
    
  return result

if __name__ == "__main__":
  S = input()
  T = input()
  print(subst(S, T))

Measured memory_bytes: 9024
#include <iostream>
using namespace std;
int main() {
    int a, b, x, y, r;
    cin >> a >> b >> x >> y >> r;
    cout << (r - 1 < x && r - 1 < y && x - 1 < a - r && y - 1 < b - r ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}



int main()
{
	multiset<int> s;
	int N;
	int size = 0;
	cin >> N;
	int j;
	for(int i = 0;i < N; ++i)
	{
		cin >> j;
		if(size)
		{
			auto itr = s.insert(j);
			auto beg = s.begin();
			if(itr == beg || j == *beg)
			{
				size ++;
			}
			else
			{
				itr = s.lower_bound(j);
				--itr;
				s.erase(itr);
			}
		}
		else
		{
			s.insert(j);
			size = 1;
		}
	}
	cout << size << endl;
	return 0;
}




















Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define F first
#define S second
using namespace std;
typedef long long ll;
const ll mod =1e9 + 7;



int main(){
	int n;
	string s;
	cin>>n>>s;
	if(s.size()%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	rep(i,s.size()/2){
		if(s[i]!=s[i+s.size()/2]){
		cout<<"No"<<endl;
		return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256