akhauriyash/Code-Regression huggingface dataset:
while True:
    lst = []
    S = raw_input()
    if S == '.':
        break
    lst.append(S)
    while True:
        S = raw_input()
        if S == '.':
            break
        lst.append(S)
    
    upper = []
    flag = False

    for i in range(len(lst)):
        S = lst[i]
        if '=' in S:
            try:
                exec(S)
            except:
                flag = True
            for elem in upper:
                for key in elem[0]:
                    if key >= elem[1]:
                        flag = True
                        break
            if flag:
                print i + 1
                break
        else:
            P = S.split('[')
            name = P[0]
            num = int(P[1][:-1])
            exec(name + ' = {}')
            upper.append((globals()[name], num))
    
    if not flag:
        print 0


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

int sum[26],n;
char s[100010];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll pls(const ll &x,const ll &y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll &x,const ll &y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

int main()
{
	n=rd();
	scanf("%s",s+1);
	for (int i=1;i<=n;i++) sum[s[i]-'a']++;
	ll ans=1;
	for (int i=0;i<26;i++) ans=ans*(sum[i]+1)%mod;
	printf("%lld\n",mns(ans,1));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b;
    cin >> a >>b;
  cout << a - b + 1;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using int64 = long long;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  std::vector<int64> dp(100 * 1000 + 1, -1);
  dp[0] = 0;
  int s = 0;
  for (int i = 0; i < n; ++i) {
    int w, v;
    scanf("%d%d", &w, &v);
    s += v;
    for (int j = s; j >= v; --j) if (dp[j - v] != -1) {
      if (dp[j] == -1 || dp[j] > dp[j - v] + w) {
        dp[j] = dp[j - v] + w;
      }
    }
  }
  for (int i = 100 * 1000; i >= 0; --i) {
    if (dp[i] <= m && dp[i] != -1) {
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int i, count = 0;
    for (i = a; i <= b;i++){
        if (c % i == 0){
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2112
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
def length(i):
  if ls[i]>=0:
    return ls[K+i-1]
  elif ls[K+i-1]<=0:
    return -ls[i]
  else:
    return min([2*ls[K+i-1]-ls[i],ls[K+i-1]-2*ls[i]])
answer=[]
for i in range(N-K+1):
  answer.append(length(i))
  
print(min(answer))
    

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;


void weather_predicition()
{
  string s;
  cin >> s;

  if (s == "Sunny") cout << "Cloudy\n";
  else if (s == "Cloudy") cout << "Rainy\n";
  else if (s == "Rainy") cout << "Sunny\n";
}


void odds_of_oddness()
{
  int n;
  cin >> n;

  int cnt = 0;
  for (int i = 1; i <= n; ++i)
  {
    if (i % 2 != 0) ++cnt;
  }

  cout << (float)cnt / (float)n << "\n";
}


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

  if (a - 2 * b > 0) cout << a - 2 * b << "\n";
  else cout << 0 << "\n";
}


void cant_wait_for_holiday()
{
  string s;
  cin >> s;

  vector<string> S{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  int cnt = 7;
  for (int i = 0; i < 7; ++i)
  {
    if (s == S[i]) cout << cnt << "\n"; 
    --cnt;
  }

}


void blackjack()
{
  vector<int> a(3);
  for (int i = 0; i < 3; ++i) cin >> a[i];

  if (accumulate(a.begin(), a.end(), 0) >= 22) cout << "bust\n";
  else cout << "win\n";
}


int main()
{
  //weather_predicition();
  //odds_of_oddness();
  //curtain();
  //cant_wait_for_holiday();
  blackjack();
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;



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

	cin >> N >> M;
	for (int i = 1; i <= 100000; i++) {
		if (i * 8 / 100 == N && i * 10 / 100 == M) {
			cout << i << endl;
			return 0;
		}
	}
  cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x,m[110];
	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>m[i];
		x-=m[i];
	}
	sort(m,m+n);
	cout<<n+x/m[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    char s[n + 1], t[n + 1];
    scanf("%s%s",s,t);
    for(int i = 0; i < n; i++)
        printf("%c%c",s[i],t[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int ms = 11, m2 = 300;
int cost[ms][ms], matrix[m2][m2];
int n,m,soma,val;

main(){

	cin >> n >> m;
	for(int i= 0;i<10;i++)
		for(int j =0;j<10;j++)
			cin >> cost[i][j];
			
	for(int k= 0;k<10;k++)
		for(int j = 0;j<10;j++)
			for(int i = 0;i<10;i++)
				cost[j][i] = min(cost[j][i], cost[j][k] + cost[k][i]);
	
	for(int i= 0;i<n;i++){
		for(int j =0;j<m;j++){
			cin >> val;
			if(val != -1)
				soma += cost[val][1];
				
		}
	}

	cout<<soma<<endl;
}


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

struct Node{
	int parent, left, right;
};
Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
	if(u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right, d+1);
}

int setHeight(int u){
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
		h1 = setHeight(T[u].left) + 1;
	if(T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

int main(){
	int x, a;
	cin >> x >> a;
	if(x < a) cout << 0 << endl;
	else cout << 10 << endl;

}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;
  bool ans = false;
  for(int i=0;i+1<SZ(S);++i)
	if(S.substr(i,2) == "AC")
	  ans = true;
  cout << (ans? "Yes": "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>

using namespace std;
typedef long long ll;

int main()
{
	int N, Q;
	string S;
	int Query[20000][3];
	cin >> N;
	cin >> S;
	cin >> Q;
	for(int i = 0; i < Q; i++){
		cin >> Query[i][0] >> Query[i][1];
		string temp;
		if(Query[i][0] == 1){
			cin >> temp;
			Query[i][2] = temp[0];
		}else{
			cin >> Query[i][2];
		}
	}
	
	set<int> AlphabetPlace[26];
	for(int j = 0; j < N; j++){
		AlphabetPlace[S[j]-97].insert(j);
	}
	
	for(int i = 0; i < Q; i++){
		if(Query[i][0] == 1){
			int j = Query[i][1]-1;
			int c = Query[i][2];
			AlphabetPlace[S[j]-97].erase(j);
			AlphabetPlace[c-97].insert(j);
			S[j] = (char)c;
		}else{
			int l = Query[i][1]-1;
			int r = Query[i][2]-1;
			int count = 0;
			for(int j = 0; j<26;j++){
				auto upper = AlphabetPlace[j].upper_bound(l-1);
				if(upper != AlphabetPlace[j].end() && *upper <= r){
					count++;
				}
			}
			cout << count << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 27504
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin>>n;
    int k; cin>>k;
    ll r,p,s; cin>>r>>p>>s;
    swap(p,s);
    string op; cin>>op;
    ll ans = 0;
    map<char,int> move_for;
    move_for['r'] = p;
    move_for['p'] = s;
    move_for['s'] = r;

    for(int i = 0 ; i < n; i++){
        ans+=move_for[op[i]];
        if(i-k>=0 && op[i]==op[i-k]){
            ans-=move_for[op[i]];
            op[i] = '!';
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>
 
typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> llll;
typedef pair<double, double> dd;
 
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;
 
#define sz(a) int((a).size())
#define pb push_back
#define FOR(var, from, to) for (int var = (from); var <= (to); ++var)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define rep1(var, n) for (int var = 1; var <= (n); ++var)
#define repC2(vari, varj, n)               \
  for (int vari = 0; vari < (n)-1; ++vari) \
    for (int varj = vari + 1; varj < (n); ++varj)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define found(s, e) ((s).find(e) != (s).end())
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define mid(x, y) ((x) + ((y) - (x)) / 2)
#define IN(x, a, b) ((a) <= (x) && (x) <= (b))
#define cons make_pair
 
ll gcd(ll a, ll b) {
  while (a) swap(a, b %= a);
  return b;
}
 
const ll MOD = 1000000007LL;
 
ll ADD(ll x, ll y) { return (x + y) % MOD; }
ll SUB(ll x, ll y) { return (x - y + MOD) % MOD; }
ll MUL(ll x, ll y) { return x * y % MOD; }
ll POW(ll x, ll e) {
  ll v = 1;
  for (; e; x = MUL(x, x), e >>= 1)
    if (e & 1) v = MUL(v, x);
  return v;
}
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/
  return MUL(x, POW(y, MOD - 2));
}
ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
 
#include <vector>
using namespace std;
 
vector<int> primes;
vector<int> smallest_prime_factor;
 
int sieve(int nmax) {
  primes.clear();
  smallest_prime_factor.assign(nmax + 1, 0);
 
  // ここではあえて愚直な書き方
  for (int n = 2; n <= nmax; ++n) {
    if (!smallest_prime_factor[n]) {
      primes.push_back(n);
      for (int kn = n; kn <= nmax; kn += n) {
        if (!smallest_prime_factor[kn]) {  // ←このチェックをせずに上書きを続けると largest_prime_factor[]
                                           // が出来上がる
          smallest_prime_factor[kn] = n;
        }
      }
    }
  }
  return primes.size();
}
 
vector<ii> factorize(int M) {
  sieve(32000);
  vector<ii> res;
      // int sq = sqrt(M);
      int x = M;
  for (int p : primes) {
    int cnt = 0;
    while (x % p == 0) { x /= p; ++cnt; }
    if (cnt) res.pb(ii(p, cnt));
  }
  if (x != 1) res.pb(ii(x, 1));
  return res;
}
 
ll solve(int N, int M) {
  vector<ii> fac = factorize(M);
  int F = fac.size();
#ifdef DEBUG
  cerr << M << fac << F << endl;
#endif
  ll ans = 1;
 
  for (ii p : fac) {
    int k = p.second;
    ll c = comb(N-1+k, N-1);
    ans = MUL(ans, c);
  }
  return ans;
}
 
int main() {
  int N, M;
  cin >> N >> M;
  cout << solve(N, M) << endl;
  // fprintf(stderr, "[[ %d %d ]]\n", _s_pow2, _assign_mul);
  return 0;
}

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

using namespace std;

int main(){

	int a;
	int b;
	cin>>a>>b;
	
	cout<< a*b <<" "<< 2*a+2*b <<endl;
	
return 0;
}
//cout<<"Hello World"<<endl;

//和+、差-、籍＊、商/



Measured memory_bytes: 3116
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    ll N; cin >> N; 
    ll ans = 0;
    for (int d = 1; d <= N; ++d) {
        ans += N/d * (d + N/d * d);
    }
    out(ans/2);
    
    return 0;
}









Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    string s,t ; cin>>s>>t ;
    int as=0 ;
    for(int i = 0 ; i < s.size() ; i++)
    {
        if(s[i]!=t[i]) as++ ;
    }
    cout<<as<<endl ;
}


Measured memory_bytes: 3856
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val K = readLine()!!.toInt()

    var min = 1
    repeat(N) { min += if (2 * min < min + K) min else K }

    println(min)
}

Measured memory_bytes: 31648
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>

using namespace :: std;

const ll mod=1e9+7;
const ll inf=1e17+500;
const ll maxn=2e5+500;

map<ll,vector<ll> > ger[maxn];
ll s[maxn];
ll t[maxn];
ll c[maxn];
vector<ll> Rger[maxn];
ll dp[maxn];
bool vis[maxn];

int main(){
    ll n,m;
    cin>>n>>m;
    fill(dp,dp+m,inf);
    for(ll i=0;i<m;i++){
        cin>>s[i]>>t[i]>>c[i];
        ger[s[i]][c[i]].pb(i);
        ger[t[i]][c[i]].pb(i);
        Rger[s[i]].pb(i);
        Rger[t[i]].pb(i);
    }
    stack<ll> stk;
    ll w=1;
    for(auto e:Rger[1]){
        stk.push(e);
    }
    while(stk.size()){
        stack<ll> se;
        while(stk.size()){
            ll e=stk.top();
            stk.pop();
            if(dp[e]==inf){
                if(vis[s[e]]==0){
                    se.push(s[e]);
                    vis[s[e]]=1;
                }
                if(vis[t[e]]==0){
                    se.push(t[e]);
                    vis[t[e]]=1;
                }

                dp[e]=w;
                for(auto r:ger[s[e]][c[e]]){
                    stk.push(r);
                }
                for(auto r:ger[t[e]][c[e]]){
                    stk.push(r);
                }
                ger[t[e]][c[e]].clear();
                ger[s[e]][c[e]].clear();
            }
        }
        w++;
        while(se.size()){
            ll v=se.top();
            for(auto e:Rger[v]){
                stk.push(e);
            }
            se.pop();
        }
    }

    ll ans=inf;
    for(auto e:Rger[n]){
        ans=min(ans,dp[e]);
    }
    if(ans>m){
        cout<<-1;
    }
    else{
        cout<<ans;
    }
}




Measured memory_bytes: 71296
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Contests.ABC163
{
    /// <summary>
    /// 
    /// </summary>
    static class A
    {
        static void Main(string[] args)
        {
            var r = NextInt();

            Console.WriteLine(2 * r * Math.PI);
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 27608
#include<deque>
#include<queue>
#include<map>
#include<string>
#include<iostream>
#include<set>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const llint mod=1000000007;


int main(void){
	llint N,L,T,i,j,a,b,c,d,e,isyu,syukai=0;
	vector<llint> ant;
	vector<llint> muki;
	vector<llint> gont;
	scanf("%lld %lld %lld",&N,&L,&T);
	isyu=(T/(2*L));
	T=(T%(2*L));
	gont.resize(N);
	for(i=0;i<N;i++){
		scanf("%lld %lld",&a,&b);
		ant.pub(a);
		muki.pub(b);
	}

	if(muki[0]==1){
		a=1;syukai=0;j=0;//aはアリ　ｂは答え jは周回
		while(-1){
			if(a>=N){a-=N;j++;}
			if(ant[0]+2*2*L<=ant[a]+j*L){break;}
			if(muki[0]!=muki[a]){syukai+=isyu;}
			a++;
		}
	} 
	else{
		a=N-1;syukai=0;j=-1;//aはアリ　ｂは答え jは周回
		while(-1){
			if(a<0){a+=N;j--;}
			if(ant[0]-2*2*L>ant[a]+j*L){break;}
			if(muki[0]!=muki[a]){syukai-=isyu;}
			a--;
		}
	}

	if(muki[0]==1){
		a=1;b=0;j=0;//aはアリ　ｂは答え jは周回
		while(-1){
			if(a>=N){a-=N;j++;}
			if(ant[0]+2*T<=ant[a]+j*L){break;}
			if(muki[0]!=muki[a]){b++;}
			a++;
		}
	} 
	else{
		a=N-1;b=0;j=-1;//aはアリ　ｂは答え jは周回
		while(-1){
			if(a<0){a+=N;j--;}
			if(ant[0]-2*T>ant[a]+j*L){break;}
			if(muki[0]!=muki[a]){b--;}
			a--;
		}
	}
	b+=syukai;
	//ant[N-b]が本物の0番
	for(i=0;i<N;i++){
		if(muki[i]==1){gont[i]=(2000*L+ant[i]+T)%L;}
		else{gont[i]=(2000*L+ant[i]-T)%L;}
	}
	c=gont[0];
	sort(gont.begin(),gont.end());
	llint hon=lower_bound(gont.begin(),gont.end(),c)-gont.begin();
	d=(hon-b+N*10000)%N;//これが本当の0
	for(i=0;i<N;i++){
		printf("%lld\n",gont[d]);
		d++;
		d%=N;
	}
	return 0;
}


Measured memory_bytes: 3820
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

T[] readToArray(T)() {
    return readln.split.to!(T[]);
}

void readInto(T...)(ref T ts) {
    auto ss = readln.split;
    foreach(ref t; ts) {
        t = ss.front.to!(typeof(t));
        ss.popFront;
    }
}

// 冪乗をmod取りつつ計算
@nogc @safe pure ulong modPow(ulong a, ulong n, ulong m) {
    ulong r = 1;
    while (n > 0) {
        if(n % 2 != 0) r = r * a % m;
        a = a * a % m;
        n /= 2;
    }
    return r;
}

// フェルマーの小定理から乗法逆元を計算
// 定理の要請により法は素数
@nogc @safe pure ulong modInv(ulong a, ulong m) {
    return modPow(a, m-2, m);
}

// mod取りつつ順列を計算
@nogc @safe pure ulong modPerm(ulong n, ulong k, ulong m) {
    if (n < k) return 0;

    ulong r = 1;
    for (ulong i = n-k+1; i <= n; i++) {
        r *= i;
        r %= m;
    }
    return r;
}

// mod取りつつ順列を計算
@nogc @safe pure ulong modFact(ulong n, ulong m) {
    return modPerm(n, n, m);
}

// mod取りつつ組み合わせを計算
// modInvを使っているので法は素数
@nogc @safe pure ulong modComb(ulong n, ulong r, ulong m) {
    return modPerm(n, r, m)*modInv(modFact(r, m), m) % m;
}

immutable ulong MOD = 1000000007;

void main() {
    ulong n, a, b;
    readInto(n, a, b);
    writeln(n*a < b ? n*a : b);
}


Measured memory_bytes: 256
s=input()
t=input()
tl=len(t)
m=0
for i in range(len(s)-tl+1):
    c=0
    for x,y in zip(t,s[i:i+tl]):
        if x==y:
            c+=1
    m=max(m,c)
print(tl-m)


Measured memory_bytes: 9108
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N, K;

int main()
{
    cin >> N >> K;

    cout << N - (K - 1) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<utility>
#define ll long long
/*#define fr first
#define sd second*/

using namespace std;

struct Node
{
    int data;
    struct Node* left;
    struct Node* right;
    Node(int x) {
        data =x;
        left=NULL;
        right=NULL;
    }
};

#define Node struct Node
ll dp[105][100005];
ll calc(int w[],ll v[], int i, int W)
{
    if(i==-1)
        return 0;
    if(dp[i][W]!=-1)
        return dp[i][W];
    if(w[i]>W)
    {
        return dp[i][W]=calc(w,v,i-1,W);
    }
    return dp[i][W]=max(calc(w,v,i-1,W),v[i]+calc(w,v,i-1,W-w[i]));
}

int main()
{
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,W;
        cin>>n>>W;
        int w[n];
        ll v[n];
        for(int i=0;i<n;i++)
        {
            cin>>w[i];
            cin>>v[i];
        }
        memset(dp,-1,sizeof(dp));
        cout<<calc(w,v,n-1,W)<<endl;
    }
}











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

typedef long long ll;
typedef unsigned long long ull;

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

    unordered_set<string> dct;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string comm, arg;
        cin >> comm >> arg;
        if(comm=="insert"){
            dct.insert(arg);
        }else{
            cout << ((dct.count(arg)>0)?"yes":"no") << endl;
        }
    }
    
    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, x, a);
  out(x < a ? 0 : 10);
}


Measured memory_bytes: 3636
N, Y = map(int, input().split())

v = 0
def solve():
    for x in range(N+1):
        if Y // 10000 < x:
            return [-1,-1,-1]
        r = Y - 10000 * x
        for y in range(0, r // 5000 + 1):
            rr = r - 5000 * y
            z = rr // 1000
            if x + y + z == N:
                return [x, y, z]
    return [-1,-1,-1]

print(' '.join(map(str, solve())))


Measured memory_bytes: 3064
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 105
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
inline void ADD(int x, int y) {
	printf("%d %d\n", x, y);
}
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");

	int N;
	scanf("%d", &N);
	int one_count = 0;
	for (int x = N; x > 0; x >>= 1) if (x & 1) one_count++;
	if (one_count == 1) return puts("No"), 0;
	puts("Yes");
	ADD(1, 2);
	ADD(2, 3);
	ADD(3, N + 1);
	ADD(N + 1, N + 2);
	ADD(N + 2, N + 3);
	vector <int> connect(N + 1);
	connect[2] = N + 2;
	connect[3] = 3;
	for (int i = 4; i < N; i += 2) {
		ADD(i, i + 1);
		ADD(i, N + 1);
		ADD(N + i, N + i + 1);
		ADD(N + i + 1, N + 1);
		connect[i] = i;
		connect[i + 1] = N + i + 1;
	}
	if (N & 1 ^ 1) {
		for (int i = 2; i < N; i++) {
			if ((N ^ i ^ 1) < N) {
				ADD(N, connect[i]);
				ADD(N + N, connect[N ^ i ^ 1]);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
using vi = vector<int>;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    int N;
    cin >> N;
    double ans = 0;
    rep(i,N) {
        double x;
        cin >> x;
        ans += 1.0 / x;
    }
    ans = 1.0 / ans;
    printf("%.12f\n", ans);
}

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

int main(void) {
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

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

  int res=numeric_limits<int>::max();
  for (int i = 0; i < n-k+1; i++) {
    res = min(res, h[i+k-1]-h[i]);
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner
object Main extends App {
  val sc = new Scanner(System.in)
  val ts = sc.next.map(_ - '0')
  println(Math.min(
    (0 until ts.size).count{i => ts(i) == i % 2},
    (0 until ts.size).count{i => ts(i) != i % 2}
  ))
}


Measured memory_bytes: 33484
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    while (true) {
        int n, w, h;
        int s, t;

        scan(n);

        if (!n) return;

        scan(w, h);
        auto bd = new int[][](w + 1, h + 1);
        foreach (i ; 0 .. n) {
            int xi, yi;
            scan(xi, yi);
            bd[xi][yi]++;
        }

        scan(s, t);
        solve(n, w, h, s, t, bd);
    }
}

void solve(int n, int w, int h, int s, int t, int[][] bd) {
    int ans;

    foreach (i ; 1 .. w - s + 2) {
        foreach (j ; 1 .. h - t + 2) {
            int cnt;

            foreach (k ; i .. i + s) {
                foreach (l ; j .. j + t) {
                    cnt += bd[k][l];
                }
            }

            ans = max(ans, cnt);
        }
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 3008
N = int(input())
A = list(map(int,input().split()))
zero_count = [0]*70
one_count  = [0]*70

for a in A:
    count_ = [0]*70
    bin_a = list(bin(a)[2:])
    bin_a.reverse()
    
    for b_idx,b in enumerate(bin_a):
        count_[b_idx] = int(b)
        
#     print(count_)
    
    for c_idx,c in enumerate(count_):
        if c == 0: 
            zero_count[c_idx] += 1
            
        elif c == 1: 
            one_count[c_idx] += 1
            
# print(zero_count,one_count)
ans = 0     

for l in range(70):
    ans += zero_count[l]*one_count[l]*(2**l)
    
print(ans%((10**9)+7))

Measured memory_bytes: 124888
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])


Measured memory_bytes: 7748
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int n,k;
	map<int,int>m;
	priority_queue<ll,vector<ll>,greater<ll> >q;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		m[t]++;
	}
	for(map<int,int>::iterator it=m.begin();it!=m.end();it++)
	{
		q.push(it->second);
	}
	ll res=0;
	while(q.size()>k)
	{
		res+=q.top();
		q.pop();
	}
	cout<<res<<endl;
}


Measured memory_bytes: 11768
#include <bits/stdc++.h>
using namespace std;
int n,m,a,b,i;
int main()
{
	cin>>a>>b;
	for(i=0;i<1251;i++){
		n=i*8/100;
		m=i/10;
		if(n==a&&m==b){
			cout<<i<<endl;
			return 0;
		}
	}
	if(i==1251)
		cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 256
n=input()
if n[-1]=="2" or n[-1]=="4" or n[-1]=="5" or n[-1]=="7" or n[-1]=="9":
    print("hon")
elif n[-1]=="0" or n[-1]=="1" or n[-1]=="6" or n[-1]=="8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a;
    cin >> a;
    if(a == "Sunny"){
        cout << "Cloudy"<<endl;
    }
    else if(a == "Cloudy"){
        cout <<"Rainy"<<endl;
    }
    else if(a == "Rainy"){
        cout <<"Sunny"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>     // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll modi = 1000000007;

ll n;
vl degree;
vl possiWhite;
vl possiBlack;
vvl graph;

int main() {
	cin.sync_with_stdio(0);
	cin >> n;

	if(n == 1) {
		cout << 2 << endl;
		return 0;
	}

	degree = vl(n, 0);
	graph = vvl(n);

	possiWhite = vl(n, 1);
	possiBlack = vl(n, 1);

	FOR(i, 0, n - 1) {
		ll a, b; cin >> a >> b;
		a--; b--;

		degree[a]++;
		degree[b]++;
		graph[a].pb(b);
		graph[b].pb(a);

	}

	queue<ll> nextEle;
	FOR(i, 0, n) {
		if(degree[i] == 1) {
			//possiWhite[i] = 1;
			//possiBlack[i] = 1;
			nextEle.push(i);

			degree[i] = 1;
		}
	}

	ll output;
	while(!nextEle.empty()) {
		ll next = nextEle.front();
		nextEle.pop();

		degree[next]--;
		
		//output = (possiWhite[next] + possiBlack[next]) % modi;
		//cout << next + 1 << ": " << output << endl;


		for(ll neighbour : graph[next]) {
			if(degree[neighbour] >= 1) {
				possiWhite[neighbour] *= possiWhite[next] + possiBlack[next];
				possiWhite[neighbour] %= modi;

				possiBlack[neighbour] *= possiWhite[next];
				possiBlack[neighbour] %= modi;			

				degree[neighbour]--;
				if(degree[neighbour] == 1) {
					nextEle.push(neighbour);
				}
			}
		}
	}

	FOR(i, 0, n) {
		if(degree[i] != 0) output = (possiWhite[i] + possiBlack[i]) % modi;
	}


	cout << output << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0, b - (n - a)) << endl;
    return 0;
}

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

using namespace std;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if(a < k)
    cout << 0 << " " << max(0LL, a + b - k) << endl;
  else
    cout << a - k << " " << b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int n;
		n = reader.nextInt();
		int may=0, cont;
		int hi[] = new int [100001];
		for(int i=1;i<=n; i++) {
			hi[i]=reader.nextInt();
		}
		cont=0;
		for(int i=1; i<=n-1; i++) {
			if(hi[i]>=hi[i+1]) {
				++cont;
			}else {
				if(cont>may) {
					may = cont;
				}
				cont=0;
			}
			if(i==n-1) {
				if(cont>may) {
					may = cont;
				}
			}
		}
		System.out.println(may);
		
	}

}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    ll X; cin >> X;

    for(int i = -1000; i <= 1000; i++) {
        for(int j = -1000; j <= 1000; j++) {
            if((ll)i*i*i*i*i - (ll)j*j*j*j*j == X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3636
N, W = map(int, input().split())
vw = (map(int, input().split()) for _ in range(N))
values, weights = zip(*vw)
dp = [[0] * (W + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(W + 1):
        if weights[i] <= j:
            dp[i + 1][j] = max(dp[i][j - weights[i]] + values[i], dp[i][j])
        else:
            dp[i + 1][j] = dp[i][j]

print(dp[N][W])


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

int main(void) {
    long long N,K;
    cin >> N >> K;
    vector<int> A(N+1,0);

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

    vector<int> V(N+1,0);
    vector<int> B(N+1,0);
    int t=1;
    int s=1;
    V[t]=s;
    B[s]=1;
  
    for(int i=1;i<=N;i++) {
        s+=1;
        t=A[t];
        if (V[t]>0) break;
        V[t]=s;
        B[s]=A[t];
    }

    long long Kd = (K-V[t])%(s-V[t]);

    int x;
    if (K>s)
        x=Kd+V[t];
    else
        x=K;

    cout << B[x] << endl;

    return 0;
}


Measured memory_bytes: 5640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(a*b, c*d);
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
/***************************************************
 * Problem Name : B.cpp
 * Problem Link :
 * Contest Name :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2018-10-06
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdlib>
#include<deque>
#include<stack>
#include<map>
#include<set>
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define SET(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define pll pair <ll, ll>
#define debug cout <<"#########\n";
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define Pow2(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define Max3(a, b, c) max(a, max(b, c))
#define Min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
std::string NumberToString ( T Number ) {
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    int n, t;
    cin >> n >> t;
    int ans = 2000;

    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;

        if (t >= y) {
            if (ans > x) {
                ans = x;
            }
        }
    }

    if (ans == 2000) cout << "TLE\n";
    else cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&b!=a)){
            System.out.println("Yes");
         }else{
            System.out.println("No");
         }
   }     	
}


Measured memory_bytes: 35500
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int max_bit = 1<<N;
    vector<vector<int>> A(N,vector<int>(N,0));
    REP(i,N)REP(j,N) cin >> A[i][j];
    vector<int> dp(max_bit,0);
    dp[0] = 1;
    REP(mask,max_bit){
        int i = __builtin_popcount(mask); //立ってるbitの数
        REP(j,N){
            if(mask>>j&1) continue;
            if(A[i][j]){
                dp[mask|1<<j] += dp[mask];
                if(dp[mask|1<<j] >= MOD) dp[mask|1<<j] -= MOD;
            }
        }
    }

    int ans=dp[max_bit-1];



    cout << ans << endl;
}

Measured memory_bytes: 8448
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    LL n,k;
    cin >> n >> k;
    vector<LL> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<LL> b;
    for(int i = 0; i < n; i++){
        LL sum = 0;
        for(int j = i; j < n; j++){
            sum += a[j];
            b.push_back(sum);
        }
    }
    LL x = 1;
    for(int i = 0; i < 50; i++){
        x *= 2;
    }
    vector<vector<LL>> z(51);
    LL m = -1;
    LL ans = 0;
    for(int i = 50; i >= 0; i--){
        if(m < 0){
            for(int j = 0; j < b.size(); j++){
               if(x&b[j]){
                    z[i].push_back(b[j]);
                }
            }
            if(z[i].size() >= k){
                m = i;
                ans += x;
            }
        }else{
            for(int j = 0; j < z[m].size(); j++){
                if(x&z[m][j]){
                    z[i].push_back(z[m][j]);
                }
            }
            if(z[i].size() >= k){
                m = i;
                ans += x;
            }
        }
        x /= 2;
    }

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

Measured memory_bytes: 11116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a=N/1000;
  int b=(N-a*1000)/100;
  int c=(N-a*1000-b*100)/10;
  int d=N%10;
  if ((a==b && b==c) || (b==c)&&(c==d) ) {
    cout << "Yes" <<endl;
  }
  else{
  	cout << "No" <<endl;
  }
}

Measured memory_bytes: 256