akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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

	public static void main(String[] args){

		solve_abc160_a();
	}
  
  	public static void solve_abc160_a(){

		FastScanner sc = new FastScanner(System.in);
		
		String s = sc.next();
		
		boolean b = false;
		
		if((s.charAt(2) == s.charAt(3)) && (s.charAt(4) == s.charAt(5))){
			b = true;
		}
		
		if(b) System.out.println("Yes");
		else System.out.println("No");
		
		
		

	}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define D(a) (double)(a)
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define For(a,n,in) for(int i=a; i<n; i+=in)
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI acos(-1)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................function.....................///
#define siz(s) (int)(s.size())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mod 999999937
const int N=1000005;
vll a(N),b(N);
int n;
int main()
{
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    if(n>=30)
        yes;
    else no;
}


Measured memory_bytes: 18684
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)(1e7))
#define pi (2*acos(0))
#define mp make_pair
#define M ((int)(1e9 + 7))
#define xx first
#define yy second
#define NN ((int)(5e5+2))
#define N ((int)(4e2 + 2))
#define pq priority_queue
///#define Q queue
#define eps 0
#define log 20
#define pb push_back
#define MOD 998244353


using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int lu;

typedef tree < int ,  null_type ,  less < int > ,  rb_tree_tag ,  tree_order_statistics_node_update > o_set;

int dp[3][105], a[105];

int call(bool flag, int n)
{
    if(n==0) return 0;
    if(dp[flag][n]!=-1) return dp[flag][n];
    dp[flag][n] = 0;
    if(flag*a[n+1]==a[n]) return dp[flag][n] = 1+call(0,n-1);
    return dp[flag][n] = min(1+call(0,n-1),call(1,n-1));
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1; i<=n; i++) scanf("%d",&a[i]);
    memset(dp,-1,sizeof dp);
    printf("%d\n",call(1,n));
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{   
    int n, q;
    cin >> n >> q;

    queue<pair<string, int>> Q;
    pair<string, int> p;

    for (int i = 0; i < n; i++) {
        cin >> p.first >> p.second;
        Q.push(p);
    }

    int time = 0;

    while (!Q.empty()) {

        if (Q.front().second <= q) {
            time += Q.front().second;
            cout << Q.front().first << " " << time << endl;
            Q.pop();
        }

        else {
            time += q;
            Q.push(make_pair(Q.front().first, Q.front().second - q));
            Q.pop();
        }
    }
}


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

void solve() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    int c = A1+A2+A3;
    cout << (c <= 21 ? "win" : "bust") << endl;
}

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


Measured memory_bytes: 256
from bisect import bisect
from collections import defaultdict

N, D, A = map(int, input().split())
XH = []

for _ in range(N):
  X, H = map(int, input().split())
  XH.append((X, -(-H//A)))

XH.sort()
Xs = [ xh[0] for xh in XH ]
HP = [ xh[1] for xh in XH ]

XR = []
for x in Xs:
  XR.append(bisect(Xs, x+2*D))

cnt = 0
temp = 0
D = defaultdict(int)

for i in range(N):
  temp -= D[i]
  HP[i] -= temp
  if HP[i] > 0:
    temp += HP[i]
    cnt += HP[i]
    D[XR[i]] += HP[i]
    HP[i] -= temp

print(cnt)

Measured memory_bytes: 73624
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort( a,  a + 3 );
    cout << a[0] + a[1]  << endl;
   return 0; 
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 1000; ++i) {
		int na = i * 0.08;
		int nb = i * 0.1;
		if (na == a && nb == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,ans=999999999999999;
int main()
{
	cin>>a>>b;
	while(a--)
	{
		cin>>c>>d;
		if(d<=b)
		ans=min(ans,c);
	}
	if(ans==999999999999999)
	cout<<"TLE"<<endl;
	else
	cout<<ans<<endl;
}

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

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

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

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,a;
	cin>>x>>a;
	cout<<(x>=a?10:0)<<endl;
}


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

int main() {
    int N;
    int sum =0;
    cin >>N;
    vector<int> data(N);
    for(int i=0;i<N;i++){
        cin >>data.at(i);
        sum += data.at(i);
    }
    sort(data.begin(),data.end());
    int ans = sum - data.at(N-1)/2;
    cout << ans <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

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

    string S; cin >> S;
    int N = S.size(); 
    ll dp[100100][4];

    dp[N][3] = 1;
    rep(i, 3) dp[N][i] = 0;

    per(i, N) {
        per(j, 4) {
            if (j == 3) {
                dp[i][j] = dp[i + 1][j] * (S[i] == '?' ? 3 : 1);
            }
            if (j < 3) {
                dp[i][j] = dp[i + 1][j] * (S[i] == '?' ? 3 : 1) + dp[i + 1][j + 1] * (S[i] == '?' || S[i] == "ABC"[j] ? 1 : 0);
            }
            dp[i][j] %= mod;
        }
    }
    
    cout << dp[0][0] << "\n";

    return 0;
}

Measured memory_bytes: 3664
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  ll a, b;
  cin>>a>>b;
  ll m = 0;
  if(a<=0&&b>=0)
  {
    puts("Zero");
    return 0;
  }
  if(a<=0&&b<=0)
  {
    m = -a+b+1;
  }
  if(m%2==0)
  {
    puts("Positive");
  }
  else
  {
    puts("Negative");
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	int n;
	cin >> n;
	vector<int> x(n), y;
	FOR(i, n)cin >> x[i];
	y = x;
	SORT(y);
	int c = n / 2 - 1;
	int a=y[c], b = y[c + 1];
	FOR(i, n) {
		if (x[i] <= a)cout << b << endl;
		else cout << a << endl;
	}

	return 0;
}


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

int main(){ 
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];

  sort(p.begin(), p.end(), greater<int>());
  sort(q.begin(), q.end(), greater<int>());
  sort(r.begin(), r.end(), greater<int>());
  priority_queue<int, vector<int>, greater<int>> pq;
  for (int i = 0; i < x; i++) {
    pq.push(p[i]);
  }
  for (int i = 0; i < y; i++) {
    pq.push(q[i]);
  }

  for (int i = 0; i < c; i++) {
    int tmp = r[i];
    if (tmp > pq.top()) {
      pq.pop();
      pq.push(tmp);
    }
  }
  ll res = 0;
  while (!pq.empty()) res += pq.top(), pq.pop();
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define float long double
typedef vector<int> vi;
#define pb push_back
int dp[100005][3];


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

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

	cout << max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}


Measured memory_bytes: 2560
//encoded utf-8
//tested with jdk 11

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception{
        Reader rd = new Reader(System.in);
        //br.readLine(); return String one line.
        //Integer.parseInt(); String to Integer(Primitive).
        //String[] hoge = str.split(" ", 0);
        int N = rd.nextInt();
        int K = rd.nextInt();
        int counter = 0;
        int[] aNum = new int[N];
        for(int i = 0; i < N; i++){
            aNum[rd.nextInt() - 1] ++;
        }
        Arrays.sort(aNum);
        int ans = 0;
        for(int i = 0; i < N; i ++){
            if(K > 0) K --;
            else ans += aNum[N - i - 1];
        }
        System.out.println(ans);
    }
}

class Reader{
    private BufferedReader br;
    private StringTokenizer st;

    public Reader(InputStream in){
        br = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException{
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException{
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException{
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException{
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 44564
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int Max(int &a,int b){return a=max(a,b);}
int Min(int &a,int b){return a=min(a,b);}
int n,K;
int A[N];
set<int> S;
unordered_set<int>used;
clock_t start = clock();


bool solve(int target){
  clock_t end = clock();
  if((double)(end - start) / CLOCKS_PER_SEC > 1.8){
    cout<<(0? "POSSIBLE":"IMPOSSIBLE")<<endl;
    exit(0);
  } 

  if(used.count(target)) return 0;
  used.insert(target);
  auto it = S.lower_bound(target);
  if(it == S.end() || *it == -1) return 0;
  if(*it == target) return 1;
  
  while(it!=S.end())if(solve(*it++ - target)) return 1;
  return 0;
}

signed main(){

  cin>>n>>K;
  S.insert(-1);
  for(int i=0;i<n;i++)scanf("%d",&A[i]),S.insert(A[i]);
  sort(A,A+n);
  int ans = solve(K);
  cout<<(ans? "POSSIBLE":"IMPOSSIBLE")<<endl;
  return 0;
}


Measured memory_bytes: 5504
#include<stdio.h>
int main(){
	int top[10];
	int a,b,c;
	for(a=0;a<10;a++){
		scanf("%d",&top[a]);
	}
	for(a=0;a<10;a++){
		for(b=0;b<9;b++){
			if(top[b]<top[b+1]){
				c=top[b+1];
				top[b+1]=top[b];
				top[b]=c;
			}
		}
	}
	printf("%d\n%d\n%d\n",top[0],top[1],top[2]);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int n; cin >> n;
    string ans = "";
    for (int i = 0; i < n; i++)
    {
        char si = ' ';
        cin >> si; 
        if (si == 'Y')
        {
            ans = "Four";
            break;
        }
        ans = "Three";
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// #![allow(unused_mut)]
#![allow(dead_code)]
#![allow(unused_macros)]

use proconio::{input};

// The debug version
#[cfg(feature = "debug")]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}
// Non-debug version
#[cfg(not(feature = "debug"))]
macro_rules! debug {
       ($( $args:expr ),*) => {}
}


use num_traits::int::PrimInt;
// #[overflow_checks(off)]
// i32 -> i32, i64 -> i64
fn accum<T: PrimInt>(a: &Vec<T>) -> Vec<T> {
    let n: usize = a.len();
    let mut ac: Vec<T> = Vec::with_capacity(n + 1);
    ac.push(a[0] - a[0]);  // ac.push(0) がしたいんですけど
    for i in 0..n {
        ac.push(ac[i] + a[i]);
    }
    ac
}
/// i32 -> i64
fn accum64(a: &Vec<i32>) -> Vec<i64> {
    let n: usize = a.len();
    let mut ac: Vec<i64> = Vec::with_capacity(n + 1);
    ac.push(0);
    for i in 0..n {
        ac.push(ac[i] + i64::from(a[i]));
    }
    ac
}

fn rle<T: PrimInt>(a: &Vec<T>) -> Vec<(T,u32)> {
    let mut res: Vec<(T,u32)> = Vec::with_capacity(0);

    let mut last : T = T::zero();
    let mut cnt : u32 = 0;

    for c in a.iter() {
        if *c == last {
            cnt += 1;
        } else {
            if cnt > 0 {
                res.push((last, cnt));
            }
            last = *c;
            cnt = 1;
        }
    };
    if cnt > 0 {
        res.push((last, cnt));
    }
    res
}
fn rle_str(a: &str) -> Vec<(char,u32)> {
    let mut res: Vec<(char,u32)> = Vec::with_capacity(0);

    let mut last : char = '\0';
    let mut cnt : u32 = 0;

    for c in a.chars() {
        if c == last {
            cnt += 1;
        } else {
            if cnt > 0 {
                res.push((last, cnt));
            }
            last = c;
            cnt = 1;
        }
    };
    if cnt > 0 {
        res.push((last, cnt));
    }
    res
}

fn yesno(b: bool) -> &'static str {
    if b {
        return "Yes";
    } else {
        return "No";
    }
}

fn solve(n: usize, mut a: Vec<i32>) -> u32 {
    let mut cnt: u32 = 0;

    if n < 3 {
        return 0;
    }

    a.sort();

    for i in 0..(n-2) {
        for j in (i+1)..(n-1) {
            for k in (j+1)..n {
                // eprintln!("{} {} {}", i, j, k);
                // ai <= aj <= ak
                if a[i] == a[j] || a[j] == a[k] || a[k] == a[i] {
                    continue;
                }
                if a[i] + a[j] > a[k] {
                    // println!("{} {} {}", a[i], a[j], a[k]);
                    cnt += 1;
                }
            }
        }
    }
    cnt
}

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }
    debug!("Input: n={}, a={:?}", n, a);

    let ans: u32 = solve(n, a);
    println!("{}", ans);
}


Measured memory_bytes: 2192
import numpy as np

n, k = map(int, input().strip().split())
ps = list(map(int, input().strip().split()))

expects = np.array([(p + 1) / 2 for p in ps])
partial_sum = np.sum(expects[:k])
mx = partial_sum

for i in range(1, n - k + 1):
    partial_sum = partial_sum - expects[i - 1] + expects[i + k - 1]
    mx = max(partial_sum, mx)

print(mx)


Measured memory_bytes: 33636
#include <iostream>
#include <cmath>
using namespace std;
int log5(long long n){
int cnt=0;
while(n>0){n/=5;cnt++;}
return cnt;
}
int main(){
long long n;
cin>>n;
if(n%2==1)
{cout<<0<<endl;return 0;}

int log = log5(n);

long long ans=0;
for(int i=1;i<=log;i++){
ans+=n/(2*(long long)pow(5,i));
}
cout<< ans <<endl;
}


Measured memory_bytes: 384
n = int(input())
ans = 0
for i in range(1, n + 1):
  if i % 2 == 0:
    continue
  else:
    j = 1
    c = 0
    for j in range(1, i + 1):
      if i % j == 0:
        c += 1
    if c == 8:
      ans += 1
print(ans)


Measured memory_bytes: 38768
import java.util.ArrayList;
import java.util.Scanner;

class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		int price,n;
		price = scan.nextInt();
		n = scan.nextInt();
		ArrayList<Integer> ok = new ArrayList<Integer>();

		for(int i = 0; i < 10; i++)ok.add(i);

		int buf;

		for(int i = 0; i < n; i++){
			buf = scan.nextInt();
			ok.remove(buf-i);
		}
		
		int ans = price;
		while(ans <= 10 * price)
			if(check(ans,ok))break;
			else ans++;
		System.out.print(ans);
	}
	static Boolean check(int x, ArrayList<Integer> A){
		Boolean flag = false;
		while(x>0){
			for(int i = 0; i < A.size(); i++){
				if(x % 10 == A.get(i))flag = true;
			}
			if(!flag)return(flag);
			flag = false;
			x /= 10;
		}
		return(true);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    ll N, x;
    cin >> N >> x;
    ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    ll ans = 0;
    for(int i = 0; i < N; i++)
        if(a[i] > x) {
            ans += a[i] - x;
            a[i] = x;
        }
    for(int i = 1; i < N; i++) {
        ll tmp = a[i - 1] + a[i];
        if(tmp > x) {
            ans += tmp - x;
            a[i] -= tmp - x;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/e.in", "r", stdin);
//  freopen("../IO/e.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

int mp[1 << 11][1 << 11];
void solve(std::istream &in, std::ostream &out) {
  int n, m;
  in >> n >> m;
  bool swapped = false;
  mp[1][1] = 1;
  for (int len = 1; len < max(n, m); ++len) {
    int L = 1 << len;
    mp[L][L] = 1;
    for (int i = 1; i < L; ++i) {
      for (int j = 1; j < L; ++j) {
        mp[i + L][j + L] = mp[i + L][j] = mp[i][j + L] = mp[i][j];
      }
    }
  }
  for (int i = 1; i < 1 << n; ++i) {
    for (int j = 1; j < 1 << m; ++j) {
      out << char('0' + mp[i][j]);
    }
    out << '\n';
  }
}



Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a>b)
    return gcd(b,a);
  if(a==0)
    return b;
  return gcd(b%a,a);
}
int main(){
  int k;
  cin>>k;
  int s=0;
  for(int a=1;a<=k;a++)
    for(int b=1;b<=k;b++)
      for(int c=1;c<=k;c++)
        s+=gcd(gcd(a,b),c);
  cout<<s<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <bitset>
#include <string>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <list>
#include <deque>
using namespace std;
#define INF 10000000
#define LLINF 100000000000000
typedef pair<int, int> P;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define VSORT(v) sort(v.begin(), v.end());
#define fi first
#define se second
#define out(x) cout << x << endl;
int dx[] = {1, 0, -1, 0}, dy[] = { 0,1,0,-1 };
ll MOD = 1000000007;
struct edge {
	ll from, to, cost;
};

int n;
int l[55] = {0};

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> l[i];
		l[i] += l[i-1];
	}
	int res = INF;
	rep(i, 50000){
		int minl = i;
		int dp[55] = {0};
		rep(k, 55) dp[k] = INF;
		dp[0] = 0;
		for(int j = 1; j <= n; j++){
			for(int k = 0; k < j; k++){
				int now = l[j] - l[k];
				if(now < minl) continue;
				dp[j] = min(dp[j], max(dp[k], now));
			}
		}
		if(dp[n] == l[n]) continue;
		if(dp[n] < minl) continue;
		res = min(res, dp[n] - minl);
	}
	cout << res << endl;
 	return 0;
}



Measured memory_bytes: 3136
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val list = mutableListOf<String>()
    list.add(readLine()!!)
    for (i in 2..N) {
        val next = readLine()!!
        if (list.contains(next) || list.last().last() != next.first()) {
            println("No")
            return
        }
        list.add(next)
    }
    println("Yes")
}

Measured memory_bytes: 33936
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int N=105;
int n;
void qwq(){
	printf("%d\n",n-1+(n-3)*(n-1)/2);
	fp(i,1,n-1)printf("%d %d\n",i,n);
	fp(i,1,n-1)fp(j,i+1,n-1)if(i+j!=n)printf("%d %d\n",i,j); 
}
void QAQ(){
	printf("%d\n",n*(n-2)/2);
	fp(i,1,n)fp(j,i+1,n)if(i+j!=n+1)printf("%d %d\n",i,j);
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read();
	if(n&1)qwq();else QAQ();
	return 0; 
}

Measured memory_bytes: 2304
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#define POSITIVE ((int)(1000))
#define NEGATIVE ((int)((-POSITIVE) * (h * w - 1) - 1))

using namespace std;

typedef long long i64;

int H, W, h, w;


int main()
{

	cin >> H >> W >> h >> w ;

	if(H % h == 0 && W % w == 0)
	{
		cout << "No" << endl ;
		return 0;
	}
	cout << "Yes" << endl ;
	for(int i = 1; i <= H; i++)
	{
		for(int j = 1; j <= W; j++)
		{
			if(i % h > 0 || j % w > 0)
				cout << POSITIVE ;
			else
				cout << NEGATIVE ;
			cout << " " ;
		}
		cout << endl ;
	}


	return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        S[i] = s;
    }

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

    long long res = 0, cnt = 1;
    string pre = S[0];
    for (int i = 1; i < N; i++) {
        if (S[i] == pre) {
            cnt++;
        } else {
            res += cnt * (cnt - 1) / 2;
            cnt = 1;
        }
        pre = S[i];
    }
    res += cnt * (cnt - 1) / 2;
    cout << res << endl;
    return 0;
}

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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
      
uf = UnionFind(n)
for i in range(m):
  a,b = map(int,input().split())  
  uf.union(a-1,b-1)
  
ans = 0  
for i in range(n):
  ans = max(ans,-uf.parents[uf.find(i)])
  
print(ans)  

Measured memory_bytes: 75476
import scala.collection.mutable
import java.io.{BufferedReader, InputStreamReader}

object Main extends App {

  val in = new BufferedReader(new InputStreamReader(System.in))
  val Array(a, b, c, d, e, f) = in.readLine.split(" ").map(_.toInt)
  // 入れる水の量 100a 100b
  // 入れる砂糖の量 c d
  // 100gあたりとける量 e
  // ビーカーに入る量 f
  // 濃度 0% の砂糖水 : water > 0 , sugar >= 0
  val water = {
    val set = mutable.HashSet[Int]()
    for {
      i <- 0 to f/(a*100)
      j <- 0 to f/(b*100)
      w = 100 * a * i + 100 * b * j
      if 0 < w && w <= f
    } set += w
    set.toList
  }
  val sugar = {
    val set = mutable.HashSet[Int]()
    for {
      i <- 0 to (f-100)/c
      j <- 0 to (f-100)/d
      w = c * i + d * j
      if w <= f
    } set += w
    set.toList
  }

  // println(water.length + " " + sugar.length)

  val ans = {
    var max = (-1d, 0, 0)
    for {
      w <- water
      wd = w.toDouble/100d
      s <- sugar
      weight = w + s
      concent = s.toDouble / wd
      if weight <= f && concent <= e
    } {
      if(concent > max._1) {
        // println(weight + " " + concent)
        max = (concent, weight, s)
      }
    }
    max
  }
  
  println(ans._2 + " " + ans._3)
}

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

#define PI 3.14159265359
#define EPS 1e-16
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = (a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (a); i <= (long long)(n); i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

struct Edge { 
    int from;
    int to;
    ll cost;

    Edge(int from_, int to_, int cost_) : 
        from(from_), to(to_), cost(cost_) { }
};

void shortest_path(int s, vector<Edge> &edges, v_ll &dist, v_bool &negative, ll &ans) 
{ 
    irep(i, dist.size()) { dist[i] = LINF; }
    irep(i, negative.size()) { negative[i] = false; }
    dist[s] = 0;

    irep(v, dist.size()) {
        irep(i, edges.size()) { 
            Edge e = edges[i];
            if(dist[e.from] != LINF && 
               dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
            }
        }
    }

    ans = dist[dist.size()-1];

    irep(v, dist.size()) {
            
        irep(i, edges.size()) { 
            Edge e = edges[i];
            if(dist[e.from] != LINF && 
               dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                negative[e.to] = true; 
                if(negative[e.from]) {
                    negative[e.to] = true; 
                }
            }
        }
    }
}

bool find_negative_loop(vector<Edge> &edges, v_ll &dist) { /*find negative loop*/

    irep(i, dist.size()) { dist[i] = LINF; }

    for(int i = 0; i < dist.size(); i++) {
        for(int j = 0; j < edges.size(); j++) {
            Edge edge = edges[j];
            if(dist[edge.to] > dist[edge.from] + edge.cost) {
                dist[edge.to] = dist[edge.from] + edge.cost;
                if(i == dist.size()-1) return true;
            }
        }
    }
    return false;
}

int main(void)
{
    int n, m;
    cin >> n >> m;
    
    vector<Edge> edges;
    v_ll dist(n);
    v_bool negative(n);

    irep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        Edge e(a-1, b-1, -c);
        edges.push_back(e);
    }

    ll ans = 0;
    shortest_path(0, edges, dist, negative, ans);

    if(negative[n-1]) {
        cout << "inf" << endl;
    } else {
        cout << -dist[n-1] << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

int main() {
  int N, L;
  cin >> N >> L;
  int min_abs_taste = INT_MAX;
  int min_taste;
  for (int i = 1; i <= N; i++) {
    if (abs(L+i-1) < min_abs_taste) {
      min_taste = L+i-1;
      min_abs_taste = abs(min_taste);
    }
  }
  cout << N*(L-1) + (N*(N+1))/2 - min_taste << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int d,x;
cin>>d>>x;
int a[n];
  for(int i = 0; i<n; i++){
    cin>>a[i];
  }
  int count = 0;
  for(int j = 0; j<n; j++){
      if(a[j]==1){
          count = count -1;
      }
      if(a[j]!=1&&d%a[j]==0){
          count = count - 1;
      }
      count = count + ((d/a[j])+1);
  }
  
  cout<<count+x<<endl;
  return 0;
}

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

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

	vector<int> aji(N);
	vector<pair<int, int> > absaji(N);

	int minabs = 10000, min = 0, sum = 0;
	for(int i = 0; i < N; ++i){
		aji[i] = L + i;
		if(minabs > abs(aji[i])){ minabs = abs(aji[i]); min = aji[i]; }
		sum += aji[i];
	}

	sum -= min;
	cout << sum << endl;

	return 0;
}


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

int main() {
    ll N;
    cin >> N;
    string A,B,C;
    cin >> A >>B >>C;
    ll ans =0;
    for(int i=0;i<N;i++){
        set<char> s;
        s.insert(A[i]);
        s.insert(B[i]);
        s.insert(C[i]);
        ans += (s.size()-1);
    }
    cout << ans << endl;
    return 0;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct N002 {
   long n;
   T e;
   std::function<T(T, T)> compose;
   std::vector<T> xs;
   N002(long n_, T e_, std::function<T(T, T)> f) : n(1LL << (64 - __builtin_clzll(n_))), e(e_), compose(f) {
      xs.resize(2 * n, e);
      for(long i = n - 1; i >= 1; --i) {
         long s = 2 * i, t = 2 * i + 1;
         xs[i] = compose(xs[s], xs[t]);
      }
   }
};
template<typename T>
void update(N002<T>& u, long i, T e) {
   long k = i + u.n;
   u.xs[k] = e;
   while( k != 1 ) {
      k /= 2;
      long s = 2 * k, t = 2 * k + 1;
      u.xs[k] = u.compose(u.xs[s], u.xs[t]);
   }
}
template<typename T>
T rangeCompose2(N002<T>& u, long a, long b, long x, long z, long i) {
   long y = (x + z) / 2;
   if( a <= x and z <= b ) return u.xs[i];
   if( b <= x or z <= a ) return u.e;
   T p = rangeCompose2(u, a, b, x, y, i * 2);
   T q = rangeCompose2(u, a, b, y, z, i * 2 + 1);
   if( i >= u.n ) return u.e;
   return u.compose(p, q);
}
template<typename T>
T rangeCompose(N002<T>& u, long a, long b) {
   return rangeCompose2(u, a, b, 0, u.n, 1);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, q;
      scan(n, q);
      N002<long> u(n, (1LL << 31) - 1,
                   [](long x, long y){ return std::min(x, y); });
      for(long i = 0; i < q; ++i) {
         long c, x, y;
         scan(c, x, y);
         if( c == 0 )
            update(u, x, y);
         else
            printf("%ld\n", rangeCompose(u, x, y + 1));
      }
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}

Measured memory_bytes: 4916
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n,l;
    scanf("%d %d",&n,&l);
    vector<string>v;
    v.resize(n);
    for(string &s:v){
        cin>>s;
    }
    sort(all(v));
    lp(i,n)
        cout<<v[i];
    return 0;
}

Measured memory_bytes: 3692
import java.util.*;
import java.io.*;

class Main {

    static final int X = 0;
    static final int Y = 1;
    
    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	final int T = stdin.nextInt();
	for ( int t = 0; t < T; t++ ) {
	    double[][] co = new double[4][2];
	    
	    for ( int i = 0; i < 4; i++ ) {
		for ( int j = 0; j < 2; j++ ) {
		    co[i][j] = stdin.nextDouble();
		}
	    }
	    
	    final double dx1 = co[1][X] - co[0][X];
	    final double dy1 = co[1][Y] - co[0][Y];
	    final double dx2 = co[3][X] - co[2][X];
	    final double dy2 = co[3][Y] - co[2][Y];

	    if ( solve( dx1, dy1, dx2, dy2 ) ) {
		System.out.println( "YES" );
	    } else {
		System.out.println( "NO" );
	    }
	}
    }
    static boolean solve ( double dx1, double dy1, double dx2, double dy2 ) {
	return dy1 * dx2 == dx1 * dy2;
    }    
}

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


int main(){ // 1_indexed
  int n;
  long k;
  cin >> n >> k;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
  int town[n+1];
  int flag[n+1];
  rep(i,n+1)flag[i]=0;
  town[0]=1;
  int now=1;
  int end;
  int flag1=0;
  for(int i=1;i<n+1;i++){
    town[i]=a[now-1];
    if(flag[now]!=0){
      end=i;
      flag1=1;
      break;
    }
    flag[now]=1;
    now=a[now-1];
  }
  if(flag1){
    int head;
    for(int i=1;i<n+1;i++){
      if(town[i]==town[end]){
        head=i;
        break;
      }
    }
    if(k<=end)cout << town[k] << endl;
    else{
      int anss = (k-head)%(end-head)+head;
      cout << town[anss] << endl;
    }
  }else{
    cout << town[k%n] << endl;
  }
  return 0;
}

Measured memory_bytes: 5928
n = int(input())
s = input()
ans = s.count('R')*s.count('B')*s.count('G')
for i in range(n-2):
    for j in range(i+1,n-1):
        k = j + (j - i)
        if k>=n:break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1
        
print(ans)
        

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define N 65
using namespace std;

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48&&c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}

int n,a[N],b[N],f[N][N],ma,mi,h[N][N];
long long ans;
int main()
{
	n=read();
	for(int i=1; i<=n; ++i)a[i]=read();
	for(int i=1; i<=n; ++i)b[i]=read();
	
	memset(f,0x1f,sizeof(f));
    f[0][0]=0;
	for(int i=1; i<=50; ++i)
	{
	    for(int j=0; j<i; ++j){
		    for(int k=1; k<=50; ++k)f[i][j]=min(f[i][j],max(f[i%k][j],k));
	    }
	    f[i][i]=0;
    }
	for(int i=1; i<=n; ++i){
		if(a[i]!=b[i]&&b[i]>=(a[i]+1)/2){
			puts("-1");
			return 0;
		}
		ma=max(ma,f[a[i]][b[i]]);
	}
	
	for(int i=1; i<=n; ++i)h[i][a[i]]=1;
	for(int t=ma; t>=1; --t){
		for(int i=1; i<=n; ++i){
			mi=t;
			for(int j=0; j<=50; ++j)if(h[i][j]){
				mi=min(mi,f[j][b[i]]);
			}
			if(mi==t){
				for(int j=1; j<=n; ++j)
				for(int k=0; k<=50; ++k)if(h[j][k])h[j][k%t]=1;
				ans+=1ll<<t;
				break;
			}
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
ll n, x;
vector<ll>adj[N];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 2;i <= n;++i)
        cin >> x, adj[x].push_back(i);
    for(int i = 1;i <= n;++i)
        cout << adj[i].size() << '\n';
    return 0;
}


Measured memory_bytes: 14540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  string ans="NO";
  for(int i=0;i<b;i++){
    if((a*i-c)%b==0){ans="YES";}
  }
  cout<<ans;
}

Measured memory_bytes: 256
n, t = gets.chomp.split(' ').map(&:to_i)
list = n.times.map { gets.chomp.split(' ').map(&:to_i) }

can_route = list.select { |cost, time| time <= t }

if can_route.empty?
  puts 'TLE'
  exit
end

puts can_route.min_by {|cost, time| cost }[0]


Measured memory_bytes: 1788
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, m = map(int, input().split())
    print(min(abs(n%m),abs(n%m-m)))
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 27176
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b;
  cin >> a >> b;
    if(a+b > 9)
    cout << "error"<<endl;
    else
    cout << a+b<<endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
fun main(args: Array<String>)
{
    val (x, a) = readNInts()
    println(if (x < a) 0 else 10)
}

// Read an integer
// Usage: val a = readInt()
fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
fun readString() = readLine()!!


Measured memory_bytes: 37892
N, M = map(int, input().split())
C = [0] * N
for i in range(M):
    ai, bi = map(int, input().split())
    C[ai - 1] += 1
    C[bi - 1] += 1

print('YES' if len(list(filter(lambda i: i % 2 == 1, C))) == 0 else 'NO')


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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    ll s = a[0];
    int t=-1;
    for(int i = 1; i < n; ++i) {
        if(s*2 < a[i]) t = i;
        s+=a[i];
    }
    if(t==-1) cout << n << endl;
    else cout << n-t << endl;
    return 0;
}

Measured memory_bytes: 4044