akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.size();++i){
        if(s[i]!=t[i]) ++ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3900
#include <iostream>
using namespace std;
int main(){
	string input,copy_1,copy_2;
	cin >> input;
	int length=input.size();
	int nowLength;
	
	for(int i=1;i<length;i++){
		input.erase(length-i);
		nowLength = input.size();
		if(nowLength%2!=0)continue;
		copy_1=input;
		copy_2=input;
		
		copy_1.erase(nowLength/2);
		copy_2=input.substr(nowLength/2);

		
//		cout << "copy_1:" << copy_1 << " copy_2:" << copy_2 << " nowLength:" << nowLength << endl;
		if(copy_1==copy_2)break;
	}
	cout << input.size() << endl;
	
	return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n ; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < min(k, n); i++) {
        a.pop_back();
    }
    ll ans = 0;
    for (int elem : a) {
        ans += elem;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  char base[101];
  scanf("%s",base);
  if (base[0] == 'A'){
    printf("T");
  }else if(base[0] =='T'){
    printf("A");
  }else if(base[0] =='G'){
    printf("C");
  }else{
    printf("G");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
int a,b,c,d;
int main(void){
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d))printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 764
N, K, Q = map(int, input().split())
ans = ['No'] * N
s_array = [K] * N
c_array = [0] * N

for i in range(Q):
    A = int(input())
    c_array[A-1] += 1

sum_array = sum(c_array)

for i in range(N):
    calc = s_array[i] + c_array[i] - sum_array
    if calc > 0:
        ans[i] = 'Yes'

print(*ans, sep='\n')

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll n,cnt=0;;
 string s;
 cin>>n;
 cin>>s;
 for(int i=0;i<s.size();i++)
 {
     if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        cnt++;
 }
 cout<<cnt<<endl;

return 0;
}



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

bool isHaiku(vector<string>::iterator t){
  
  int count;
  string s;

  count = 0;
  while(count < 5){
    s = *t;
    count+=s.size();
    t++;
  }
  if(count>5)return false;



  count = 0;
  while(count < 7){
    s = *t;
    count+=s.size();
    t++;
  }
  if(count>7)return false;



  count = 0;
  while(count < 5){
    s = *t;
    count+=s.size();
    t++;
  }
  if(count>5)return false;



  count = 0;
  while(count < 7){
    s = *t;
    count+=s.size();
    t++;
  }
  if(count>7)return false;



  count = 0;
  while(count < 7){
    s = *t;
    count+=s.size();
    t++;
  }
  if(count>7)return false;



  return true;

}

int main(){

  vector<string> s(0);
  int n;

  while( cin >> n , n){
    s.resize(n);
    for(int i=0; i<n;i++)cin>>s[i];
   
    // for(int i=0; i<n;i++)cout<<s[i]<<' ';

    int indx=0;
    while(isHaiku(s.begin()+indx)==false ){ indx++; }

    cout << indx+1 << endl;

  }


  return 0;
}

Measured memory_bytes: 1212
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,x,t=map(int,input().split())
ans=t*math.ceil(n/x)
print(ans)

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

int main() {

	string a;

	cin >> a;

	if (a[0] == a[1] &&a[1]==a[2] || a[1] == a[2] &&a[2]==a[3]) {
		puts("Yes");
	}

	else {
		puts("No");
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e5 + 100;

int main() {
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	map<string, int>mp;
	map<string, int>::iterator it;
	string s;
	int Max = 0;
	for (int i = 1; i <= n; i++)
		cin >> s, mp[s]++, Max = max(mp[s], Max);
	for (it = mp.begin(); it != mp.end(); it++) {
		if (it->second == Max)
			cout << it->first << endl;
	}
}

Measured memory_bytes: 23936
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 10000000;

int kk[N + 1];

int main() {
	int n; cin >> n;
	for (int a = 1; a <= n; a++)
		for (int b = a; b <= n; b += a)
			kk[b]++;
	long long ans = 0;
	for (int a = 1; a <= n; a++)
		ans += (long long) a * kk[a];
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 42700
use std::io::prelude::*;
use std::str::FromStr;

fn main() {
    let stdin = std::io::stdin();
    let mut handle = stdin.lock();
    let mut string = String::new();
    handle.read_to_string(&mut string).unwrap();
    let mut splits = string.split_whitespace();
    let X: u32 = u32::from_str(splits.next().unwrap().as_ref()).unwrap();
    let Y: u32 = u32::from_str(splits.next().unwrap().as_ref()).unwrap();
    let Z: u32 = u32::from_str(splits.next().unwrap().as_ref()).unwrap();
    println!("{}", (X-Z)/(Y+Z));
}


Measured memory_bytes: 4352
count = 1

def cal(k, num, digit):
  global count
  if digit == 0:
    if count == k:
      print(num)
      exit()

    count += 1

  else:
    base = int(str(num)[-digit - 1])
    bottom = base - 1 if base > 0 else base
    head = base + 2 if base < 9 else base + 1

    for i in range(bottom, head):
      i = i * 10**(digit - 1) if digit > 1 else i
      cal(k, num + i, digit - 1)


def main():
  k = int(input())

  digit = 0
  while True:
    for i in range(1, 10):
      cal(k, i * 10**digit, digit)

    digit += 1

main()


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define uni(x)      x.erase(unique(all(x)),x.end())
#define ub(x,y)     upper_bound(all(x),y)-x.begin()
#define lb(x,y)     lower_bound(all(x),y)-x.begin()
#define rep(i,n)    repl(i,0,n-1)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<ll>())
#define mkp(x,y)    make_pair(x,y)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)


int main(){
  cin.sync_with_stdio(false);
  ll n;
  cin >> n;
  DVector d(n,Vector(n));
  rep(i,n)rep(j,n)cin >> d[i][j];
  DVector t = d;
  ll flag = true;
  rep(i,n)rep(j,n)rep(k,n)flag = flag && (t[i][j] <= t[i][k] + t[k][j]);
  ll ans = 0;
  if(flag){
    rep(k,n)rep(i,n)rep(j,n)if((d[i][j] > 0 && d[i][k] > 0 && d[k][j] > 0 ) && d[i][j] == d[i][k] + d[k][j])d[i][j] = 0;
    rep(i,n)repl(j,i+1,n-1)ans+=d[i][j];
  }else{
    ans = -1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1664
import itertools
def main():
    N = int(input())
    syougen = [None]
    for _i in range(N):
        A = int(input())
        aa = []
        for _j in range(A):
            aa.append(tuple(int(c) for c in input().split(' ')))
        syougen.append(aa)
    #print(syougen)
    max_t = 0
    for baai in itertools.product([True, False], repeat=N):
        #print(baai)
        mujun = False
        for i in range(1, N+1):
            flag = baai[i-1]
            for x, y in syougen[i]:
                if flag:
                    if y==1 and baai[x-1]==False:
                        mujun=True
                        break
                    elif y==0 and baai[x-1]==True:
                        mujun=True
                        break
        if mujun:
            continue
        else:
            max_t = max(max_t, sum(baai))

    print(max_t)

if __name__ == "__main__":
    main()

Measured memory_bytes: 43884
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    if a[0] * a[1] %2 ==1:
        print("Yes")
    else:
        print("No")


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

int main(){
    int s;
    cin >> s;
    vector<int> a = {s};
    int num = s;
    int res = 0;
    for(int i = 0; i < 1000000; i++){
        if(num%2 == 0){
            num = num/2;      
        }
        else{num = num*3+1;}

        for (int j = 0; j < a.size(); j++) {
            if (a[j]==num){ 
                res = i+2;
                break;
                }
        }
        if (res > 0) break;
        a.push_back(num);
        //cout << num;
    }
    cout << res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,d,j,k,m,p,n,i,t,T,f1,f2,ans;

int main(){
    scanf("%lld%lld",&n,&k);
    i=0;
    while(n){
    	i++;
    	n/=k;
    }
    printf("%lld\n",i);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int n;
cin>>n;
char a[200005];
int w,r;
w=r=0;
for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]=='W')
            w++;
        else
            r++;
    }
int ans=0;
for(int i=n;i>n-w;i--)
    if(a[i]=='W')
    ans++;
    cout<<w-ans<<endl;
}


Measured memory_bytes: 3792
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e1 + 10;
class UnionFind
{
private:
	int p[N];
public:
	int size(int x)
	{
		int px = Find(x);
		return -p[px];
	}
	void init()
	{
		MEM(p, -1);
	}
	int Find(int x)
	{
		int root = x;
		while (p[root] >= 0) root = p[root];
		while (x != root)
		{
			int tmp = p[x];
			p[x] = root;
			x = tmp;
		}
		return root;
	}
	void Union(int x, int y)
	{
		int px = Find(x);
		int py = Find(y);
		if (size(px) > size(py)) swap(px, py);
		int total = size(px) + size(py);
		p[px] = py;
		p[py] = -total;
	}
} uf;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> vp(m);
	for (auto &p : vp)
	{
		cin >> p.first >> p.second;
	}
	int ans = 0;
	for (int i = 0; i < m; i++)
	{
		uf.init();
		for (int j = 0; j < m; j++)
		{
			if (j == i) continue;
			if (uf.Find(vp[j].first) != uf.Find(vp[j].second))
			{
				uf.Union(vp[j].first, vp[j].second);
			}
		}
		if (uf.size(1) != n) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
  string s,t;
  cin>>s>>t;
  int a=s.length();
  int c=0;
  for(int i=0;i<a;i++)
  {
      if(s[i]!=t[i])
         c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3748
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main (void){
        int N;
        char word[100][11];
        char a;
scanf("%d\n",&N);
scanf("%s\n",word[0] );
for (int i = 1; i < N; i++) {
  scanf("%s\n",word[i] );
  for (int j = 0; j < 11; j++) {
    if (word[i-1][j]=='\0') {
      break;
    }
    a=word[i-1][j];
  }
if (a!=word[i][0]) {
  printf("No\n" );
  return 0;
}
for (int j = 0; j < i; j++) {
  if (strcmp(word[i],word[j])==0) {
    printf("No\n" );
    return 0;
  }
}
}
printf("Yes\n" );
 
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

//bool flag = __builtin_add_overflow(a , b , &tmp);
//bool flag = __builtin_mul_overflow(a , b , &tmp);
//bool flag3= __builtin_sub_overflow(a , b , &tmp);

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-12;
const long long inf = 2e12 + 12;
const int MAXN = 2000006, MAXM = 102, Mod = 1000000007 , MAXLog = 20;


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n;
    cin >> n;
    vector<string> vs(n);
    for (int i = 0; i < n; ++i){
        cin >> vs[i];
        sort(vs[i].begin(), vs[i].end());
    }
    sort(vs.begin(), vs.end());

    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        int j = i;
        while (j < n && vs[j] == vs[i])
            ++j;
        ans += 1LL * (j - i) * (j - i - 1) / 2;
        i = j - 1;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 5760
#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>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
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 Per(i,sta,n) for(int i=n-1;i>=sta;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 long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,x[20],y[20];ll p[20];
ll shortest_x[100010][20],shortest_y[100010][20];
ll ans[20];

void pre_calc(int S,vector<int> &v){
  rep(i,n){
    shortest_x[S][i]=min(shortest_x[S][i],(ll)abs(x[i]));
    shortest_y[S][i]=min(shortest_y[S][i],(ll)abs(y[i]));
    for(int t:v){
      shortest_x[S][i]=min(shortest_x[S][i],(ll)abs(x[t]-x[i]));
      shortest_y[S][i]=min(shortest_y[S][i],(ll)abs(y[t]-y[i]));
    }
  }
}

void calc(int S){
  int S_=S;
  int Sx=0,Sy=0,num=0;
  rep(i,n){
    Sx<<=1;
    Sy<<=1;
    int r=S_%3;
    if(r==1)Sx+=1;
    if(r==2)Sy+=1;
    if(r!=0)num+=1;
    S_/=3;
    //cout << r << " ";
  }
  //cout << "" << endl;
  //cout << bitset<3>(Sx) << " " << bitset<3>(Sy) << endl;
  ll res=0;
  rep(i,n){
    res+=min(shortest_x[Sx][i],shortest_y[Sy][i])*p[i];
  }
  //cout << res << endl;
  ans[num]=min(ans[num],res);
}

void solve(){
  cin >> n;
  rep(i,n){
    cin >> x[i] >> y[i] >> p[i];
  }
  int U=(1 << n);
  rep(S,U){
    rep(i,n){
      shortest_x[S][i]=INF;
      shortest_y[S][i]=INF;
    }
  }
  rep(S,U){
    vector<int> v={};
    rep(i,n) if(S&(1 << i))v.push_back(i);
    pre_calc(S,v);
    //cout << bitset<3>(S) << endl;
    // rep(i,n) cout << shortest_x[S][i] << " ";
    // cout << "" << endl;
    // rep(i,n) cout << shortest_y[S][i] << " "; 
    // cout << "" << endl;
  }
  int P=1;rep(i,n) P*=3;
  rep(i,n+1){
    ans[i]=INF;
  }
  rep(S,P){
    calc(S);
  }
  rep(i,n+1){
    cout << ans[i] << endl;
  }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 13900
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

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; }




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}


void dfs(vector<ll> ls, vector<vector<ll>> way, int ){
  ll cur = ls.back();
  ls.pop_back();

  rep(i, 0, N){
    if(way[cur][i] != 0){

    }
  }

}

 
int main() {
  ll N, K;

  cin >> N >> K;

  vector<ll> A(N);
  rep(i, 0, N){
    cin >> A[i];
  }
  vector<int> B(N, -1);
  ll now = 1, init, cnt = 0;
  B[now-1] = 0;
  ll mod = 0;

  while(true){
    cnt++;
    now = A[now-1];
    if(B[now-1] == -1){
      B[now-1] = cnt;
    }else{
      mod = cnt - B[now-1];
      init = B[now-1];
      break;
    }
  }

  if(K < init){
    now = 1;
    while(true){
      if(K == 0){
        break;
      }
      now = A[now-1];
      K--;
    }
    cout << now << endl;
    return 0;
  }
  
  K -= init;
  K %= mod;

  while(true){
    if(K == 0){
      break;
    }
    now = A[now-1];
    K--;
  }

  cout << now << endl;


}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int P,Q,R;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>P>>Q>>R;
	cout<<(P+Q+R-max({P,Q,R}))<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root=z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;		      
}

void inorder(Node u){
    if (u->left != NIL) inorder(u->left);
    printf(" %d",u->key);
    if (u->right!=NIL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL) preorder(u->left);
  if(u->right!=NIL) preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24040
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    vector<string> W(N);
    rep(i, N) cin >> W.at(i);

    bool isOk1 = true;
    rep(i, N - 1) {
        if (W.at(i).back() != W.at(i + 1).front()) isOk1 = false;
    }

    bool isOk2 = true;
    map<string, int> table;
    rep(i, N) { // 初期化
        table[(W.at(i))] = 0;
    }
    rep(i, N) {
        table.at(W.at(i))++;
        if (table.at(W.at(i)) > 1) isOk2 = false;
    }

    string ans = (isOk1 && isOk2) ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

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

	vector<int32_t> A(N);
	int32_t first = 0, first_index = 0;
	for (int32_t i = 0; i < N; i++) {
		cin >> A[i];
		if (first < A[i]) {
			first = A[i];
			first_index = i;
		}
	}

	int32_t second = 0;
	for (int32_t i = 0; i < N; i++) {
		if (i == first_index)
			continue;
		second = max(second, A[i]);
	}

	for (int32_t i = 0; i < N; i++)
		cout << (i == first_index ? second : first) << endl;

	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main(){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	ll x=a/b;
	a-=x*b;
	ll ans=min(a,abs(a-b));
	printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using vpii = vector<pii>;

int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  int cnt = 0;
  rep(i, N-1){
    if(S[i] == S[i + 1]) cnt++;
  }

  cout << min(cnt + 2*K, N - 1) << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed compare_int(const void *a,const void *b){
  return *(int*)a-*(int*)b;
}

int main(void){
  int N,M;
  scanf("%lld%lld",&N,&M);

  int A[N+1];
  int B[N+1];
  for(int i = 1;i <= N;i++) scanf("%lld",&A[i]);

  A[0] = 0;
  for(int i = 1;i <= N;i++){
    A[i] = (A[i]+A[i-1])%M;
  }

  qsort(A,N+1,sizeof(int),compare_int);

  long long ans = 0;
  int j = 0;
  B[0] = 1;
  for(int i = 1;i <= N;i++){
    if(A[i] == A[i-1]) B[j]++;
    else B[++j] = 1;
  }

  for(int i = 0;i <= j;i++){
    ans += (B[i]*(B[i]-1))/2;
  }

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define DEBUG
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#else
#define s(...)
#endif
void show() {std::cout<<std::endl;}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

int main(){
    string K,D;
    cin>>K;
    cin>>D;
    //s(K);//,D);
    //auto w = new vector<vector<int>>(K, vector<int>(D));
    if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    return 0;
}

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

namespace AtCoder
{
    class Abc170C
    {
        public static void Main()
        {
            var xn = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var x = xn[0];
            var n = xn[1];

            if (n == 0)
            {
                Console.WriteLine(x);
                return;
            }

            var p = Console.ReadLine().Split(' ').Select(i => int.Parse(i));
            var q = Enumerable.Range(-1, 103).Where(i => !p.Contains(i)).OrderBy(i => i).ToArray();

            int min = int.MaxValue;
            int value = int.MaxValue;
            foreach (var i in q)
            {
                int d = Math.Abs(x - i);
                if (d < value)
                {
                    min = i;
                    value = d;
                }
            }
            Console.WriteLine(min);
        }
    }
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;


#define rep(i,n) for(ll i=0;i<n;i++)



int main() {

  cout<<fixed<<setprecision(10);

  string s;
  vint cnt(26,0);

  while(getline(cin, s)){
    rep(i,s.size()){
      if(s[i] >= 'A' && s[i] <= 'Z'){
        s[i] += ('a' - 'A');
      }

      if(s[i] < 'a' || s[i] > 'z') continue;
      cnt[s[i]-'a'] ++ ;
    }
  }

  rep(i,26){
    cout<<(char)('a'+i)<<" : "<<cnt[i]<<endl;
  }

  return 0;
}




//






Measured memory_bytes: 3224
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>

using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
int a[100005];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0)
                        {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0)
                   {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
            else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0)
                        {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0)
                     {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w)
                    printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

def solve(N,K,trees):
    trees.sort()
    
    diffs = [max_h-min_h for min_h,max_h in zip(trees,trees[K-1:])]
    ans = min(diffs)
    print(ans)
    return

solve(N,K,trees)

Measured memory_bytes: 11980
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

K = int(readline())
S = readline().decode().rstrip()

if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')



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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int m = Integer.parseInt(in.readLine());
    System.out.println(48-m);
  }
}

Measured memory_bytes: 32624
#include <bits/stdc++.h>
#define N 1000
using namespace std;
int ans,n;
int mem[5][4001];

int dfs(int x,int cnt,int I){
  if(cnt==4&&x==n)return 1;
  if(cnt==4||x>n) return 0;
  if(mem[cnt][x]) return mem[cnt][x];
  for(int i=I;i<=N;i++)mem[cnt][x]+=dfs(x+i,cnt+1,i);
  return mem[cnt][x];
}


long long dp[6][5001];

int main(){
   while(cin>>n){
     memset(dp,0,sizeof(dp));
     dp[0][0]=1;
     for(int i=0;i<4;i++)
       for(int j=0;j<=n;j++)
	 for(int k=0;j+k<=n&&k<=N;k++)dp[i+1][j+k]+=dp[i][j];
     cout << dp[4][n]<<endl;
   }
  return 0;
}

Measured memory_bytes: 1400
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	aArray, fArray := make([]int, n), make([]int, n)
	for i := range aArray {
		aArray[i] = nextInt()
	}
	sort.Sort(sort.IntSlice(aArray))
	for i := range fArray {
		fArray[i] = nextInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(fArray)))

	min, max := 0, fArray[0]*aArray[n-1]
	for min < max {
		x := (min + max) / 2
		kRemain := k
		for i := range aArray {
			require := aArray[i] - (x / fArray[i])
			if require > 0 {
				kRemain -= require
			}
		}
		switch {
		case kRemain >= 0:
			max = x
		case kRemain < 0:
			min = x + 1
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 6400
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


class combination():
    def __init__(self, mod):
        '''
        modを指定して初期化
        '''
        self.mod = mod
        self.fac = [1, 1]  # 階乗テーブル
        self.ifac = [1, 1]  # 階乗の逆元テーブル
        self.inv = [0, 1]  # 逆元計算用

    def calc(self, n, k):
        '''
        nCk%modを計算する
        '''
        if k < 0 or n < k:
            return 0
        self.make_tables(n)  # テーブル作成
        k = min(k, n - k)
        return self.fac[n] * (self.ifac[k] * self.ifac[n - k] %
                              self.mod) % self.mod

    def make_tables(self, n):
        '''
        階乗テーブル・階乗の逆元テーブルを作成
        '''
        for i in range(len(self.fac), n + 1):
            self.fac.append((self.fac[-1] * i) % self.mod)
            self.inv.append(
                (-self.inv[self.mod % i] * (self.mod // i)) % self.mod)
            self.ifac.append((self.ifac[-1] * self.inv[-1]) % self.mod)


mod = 998244353
comb = combination(mod)
n, m, k = inpl()
if m == 1:
    if k >= n - 1:
        print(1)
        exit()
    else:
        print(0)
        exit()
ans = 0
for i in range(min(n, k + 1)):
    ans += m * pow(m - 1, n - 1 - i, mod) * comb.calc(n - 1, i) % mod
    ans %= mod
print(ans)


Measured memory_bytes: 113612
/* AOJ 0085
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0085
 *
 */

#include <stdio.h>


#define DEBUG 0

int next[1001];



int main(){
    int m, n;
    int count;
    int i;
    int p, prev;

    while(scanf("%d %d", &n, &m)==2){
        if(m==0 && n==0){
            break;
        }

        for(i=1;i<n;i++){
            next[i]=i+1;
        }
        next[n] = 1;

        count = n;
        prev = 1;
        p = 1;
        while(count > 1){
            for(i=0;i<m-1;i++){
                prev = p;
                p = next[p];
            }
            if(DEBUG)
                printf("removing %d\n", p);
            next[prev] = next[p];
            p = next[p];
            count--;
        }
        printf("%d\n", p);

    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int K;
    cin >> K;

    int a, b;

    if(K % 2) {
        a = K / 2 + 1;
    } else {
        a = K / 2;
    }

    b = K / 2;

    cout << a * b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

// Binary indexed Tree(BIT)
template <typename T>
struct BIT{
    private:
    vector<T> array;
    const int n;

    public:
    // 初期化
    BIT(int _n) : array(_n+1,0),n(_n) {}

    // 1番目からi番目までの累積和を求める
    T sum(int i){
        T s = 0;
        while(i > 0){
            s += array[i];
            // LSB減算
            i -= i & -i;
        }
        return s;
    }
    
    // [i,j]の要素の総和
    T sum(int i,int j){
        // 1番目からi-1番目までの総和
        T ret_i = sum(i-1);
        // 1番目からj番目までの総和
        T ret_j = sum(j);
        // i番目からj番目までの総和
        return ret_j - ret_i;
    }

    // i番目に要素xを追加
    void add(int i,T x){
        while(i <= n){
            array[i] += x;
            // LSB加算
            i += i & -i;
        }
    }
};

int main(){
    ll N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int ng=0,ok=inf;
    int zero = N+1;
    while(ok-ng>1){
        int mid = (ok+ng)/2;
        ll sum = 0;
        BIT<int> bit(N*2+100);
        int now = 0;
        bit.add(now+zero,1);
        for(int i=0; i<N; i++){
            int val;
            if(A[i] <= mid){
                val = 1;
            }else{
                val = -1;
            }
            now += val;
            sum += bit.sum(zero+now-1);
            bit.add(zero+now,1);
        }
        if(sum > (N+1)*N/2/2) ok = mid;
        else ng = mid;
    }
    cout << ok << enld;
    return 0;
}

Measured memory_bytes: 1420
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int stoi(string s){
	int size=s.size(),res=0;
	for(int i=size-1;i>=0;i--){
		res+=(int)(s[i]-'0')*pow(10,size-1-i);
	}
	return res;
}

string itos(int n){
	int size=log(n)/log(10)+1;
	string s="";
	rep(i,size){
		s+=(char)(n/pow(10,size-1-i)+'0');
		n%=(int)pow(10,size-1-i);
	}
	if(size<4)rep(i,4-size)s='0'+s;
	return s;
}

int main(){
	string s,res[2];
	int ma,mi;
	while(cin>>s){
		if(s[0]=='0' && s[1]=='0' && s[2]=='0' && s[3]=='0')break;
		if(s[0]==s[1] && s[1]==s[2] && s[2]==s[3]){
			cout<<"NA"<<endl;
			continue;
		}
		int cnt=0;
		while(s!="6174"){
			cnt++;
			sort(s.begin(),s.end());
			mi=stoi(s);
			reverse(s.begin(),s.end());
			ma=stoi(s);
			s=itos(ma-mi);
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    FastIO
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
//#define int long long
using namespace std;

int m, d;

signed main() {
	cin >> m >> d;
	
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= min(99, d); j++) {
			if (j / 10 <= 1 || j % 10 <= 1) continue;
			if ((j / 10) * (j % 10) == i) {
				//cout << i << " " << j << endl;
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()

k = int(input())

lunlun_num = []

def dfs(s):
    if len(s) > 10:
        return
    s = list(s)
    s_last = int(s[-1])
    for i in range(s_last - 1, s_last + 2):
        if 0 <= i <= 9:
            s.append(str(i))
            lunlun_num.append(int("".join(s)))
            dfs("".join(s))
            s.pop()

for i in range(1, 10):
    dfs(str(i))
    lunlun_num.append(int(i))

lunlun_num.sort()
# print(lunlun_num)

print(lunlun_num[k - 1])



Measured memory_bytes: 116376
from operator import itemgetter

n, m = map(int, input().split())
city = []
pre = set()
for i in range(m):
    p, y = map(int, input().split())
    city.append((p, y, i))
    pre.add(p)
city.sort(key=itemgetter(0, 1))
ans = []
now = city[0][0]
count = 1
for i in range(m):
    if city[i][0] != now:
        now = city[i][0]
        count = 1
    bangou = "0" * (6 - len(str(now))) + str(now) +\
             "0" * (6 - len(str(count))) + str(count)
    ans.append((city[i][2], bangou))
    count += 1
for i in sorted(ans):
    print(i[1])

Measured memory_bytes: 40464
N = int(input())
H = list(map(int, input().split())) 
for i in range(1, N-1):
    if H[i] > H[i+1] or H[i-1] < H[i]:
        H[i] -= 1
        if H[i-1] > H[i] or H[i] > H[i+1]:
            print("No")
            break
    else:
        continue
else:
    print("Yes")

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n];
  ll b[n+1];
  for(ll i=0;i<n;i++){
    cin>>a[i];
    b[a[i]]=i;
  }
  //cout<<b[4]<<b[1]<<b[2]<<b[3];return 0;
  ll ans[n+1];
  set<ll> st;
  for(ll i=1;i<=n;i++){
    st.insert(b[i]);
    auto itr=st.find(b[i]);
    if(i==1){
      ans[i]=b[i]*(n-1-b[i])+n;
    }
    else{
      if(itr==st.begin()){
        itr++;
        ans[i]=b[i]*(*itr-b[i]-1)+*itr;
        continue;
      }
      itr++;
      if(itr==st.end()){
        itr--;
        itr--;
        ans[i]=(n-1-b[i])*(b[i]-*itr-1)+n-1-*itr;
        continue;
      }
      
      ll r=*itr;
      itr--;
      itr--;
      ll l=*itr;
      ans[i]=(r-b[i]-1)*(b[i]-l-1)+r-l-1;
      //cout<<l<<" "<<r<<endl;
    }
  }
  //for(auto itr=st.begin();itr!=st.end();itr++)cout<<*itr<<endl;
  ll sum=0;
  for(ll i=1;i<=n;i++){
    sum+=ans[i]*i;
    //cout<<ans[i]<<" ";
  }
  cout<<sum<<endl;
}
      
    
  

Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int bubbleSort(int A[], int N)
{
	int sw = 0;
	for(int i = 0; i < N; i++) {
		for(int j = N - 1; j >= i +1; j--) {
			if(A[j] < A[j-1]) {
				swap(A[j], A[j-1]);
				sw++;
			}
		}
	}
	return sw;
}

int main()
{
	int A[100], N;
	cin >> N;
	for(int i = 0; i< N; i++) cin >> A[i];
	int sw = bubbleSort(A, N);
	for(int i = 0; i < N; i++) {
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	return 0;
}



Measured memory_bytes: 3112
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL ll[400005],rr[400005],l[400005],r[400005];
LL stk[400005],tp = 0;
LL n,a[400005],tot = 0;

LL dp[25][400005];
LL LOG[400005];

void init(){
	LOG[0] = -1;
	for(LL i = 1;i <= n;i ++) LOG[i] = LOG[i >> 1] + 1;
	for(LL i = 0;i <= n;i ++) dp[0][i] = a[i];
	for(LL i = 1;i <= 20;i ++){
		for(LL j = 0;j <= n;j ++){
			if(j + (1 << (i - 1)) > n) break;
			dp[i][j] = max(dp[i - 1][j],dp[i - 1][j + (1 << (i - 1))]);
		}
	}
}

LL query(LL x,LL y){
	LL k = LOG[y - x + 1];
	return max(dp[k][x],dp[k][y - (1LL << k) + 1]);
}

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i <= n;i ++){
		l[i] = 0;
		r[i] = n + 1;
	}
	l[0] = 0; r[n + 1] = n + 1;
	
	tp = 0;
	for(LL i = 1;i <= n;i ++){
		while(tp && a[stk[tp]] < a[i]){
			r[stk[tp]] = i;
			tp --;
		}
		stk[++ tp] = i;
	}
	
	tp = 0;
	for(LL i = n;i >= 1;i --){
		while(tp && a[stk[tp]] < a[i]){
			l[stk[tp]] = i;
			tp --;
		}
		stk[++ tp] = i;
	}
	
	init();
	for(LL i = 1;i <= n;i ++){
		LL L = 0,R = l[i] - 1,mid,tmp = 0;
		while(L <= R){
			mid = (L + R) >> 1;
			if(query(mid,l[i] - 1) > a[i]){
				tmp = mid;
				L = mid + 1;
			}
			else R = mid - 1;
		}
		ll[i] = tmp;
	}
	for(LL i = 1;i <= n;i ++){
		LL L = r[i] + 1,R = n + 1,mid,tmp = n + 1;
		while(L <= R){
			mid = (L + R) >> 1;
			if(query(r[i] + 1,mid) > a[i]){
				tmp = mid;
				R = mid - 1;
			}
			else L = mid + 1;
		}
		rr[i] = tmp;
	}
	
//	for(LL i = 1;i <= n;i ++) cout << l[i] << ' ' << r[i] << ' ' << ll[i] << ' ' << rr[i] << endl;
	
	for(LL i = 1;i <= n;i ++){
		tot += a[i] * ((rr[i] - r[i]) * (i - l[i]));
		tot += a[i] * ((r[i] - i) * (l[i] - ll[i]));
//		cout << tot << endl;
	}
	
	cout << tot << endl;
	return 0;
}
//

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm


int main(){
  faster();
  int n;
  cin >> n;
  cout << (n+1)/2;
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;





int main()
{
//    ios::sync_with_stdio(0);
//    cin.tie(0);
    ll n;
    cin>>n;
    ll ar[n+10];
    for(ll i=1; i<=n; i++)
    {
        cin>>ar[i];
    }

    ll ans=0;

    for(ll i=1; i<=n; i++)
    {
        set<ll>st;
        st.insert(ar[i]);
        for(ll j=i+1; j<=n; j++)
        {
            if(st.find(ar[j])==st.end())
            {
                st.insert(ar[j]);
                for(ll k=j+1; k<=n; k++)
                {
                    if(st.find(ar[k])==st.end())
                    {
                        vll v;
                        v.pb(ar[i]);
                        v.pb(ar[j]);
                        v.pb(ar[k]);
                        sort(all(v));
                        if(v[0]+v[1]>v[2])
                            ans++;


                    }

                }
                st.erase(ar[j]);
            }
        }
    }

    cout<<ans<<nn;





}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 3632