akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

enum Type{
	None,
	Egg,
	Chiken,
};

int main(){

	Type pre = None,ans;

	int depth = 0,max_depth = 0;

	char buf[10001];
	scanf("%s",buf);

	for(int i = 0; buf[i] != '\0';){
		if(buf[i] == 'e'){
			if(pre == Egg){ //???????????????
				depth = 0;
				pre = None;
			}else{
				depth++;
				if(depth > max_depth){
					max_depth = depth;
					ans = Egg;
				}
				pre = Egg;
				i += 3;
			}
		}else{
			if(pre == Chiken){ //???????????????
				depth = 0;
				pre = None;
			}else{
				depth++;
				if(depth > max_depth){
					max_depth = depth;
					ans = Chiken;
				}
				pre = Chiken;
				i += 7;
			}
		}
	}

	if(ans == Egg){
		printf("egg\n");
	}else{
		printf("chicken\n");
	}


	return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <vector>
using namespace std;
const int MAX_N = 100010;
int U,V;
int N,M;
vector<int> edges[MAX_N];
int deg[MAX_N];
int step_limit;

bool visit[MAX_N];

bool dfs(int len, int start, int pos, int pre){
  visit[pos] = true;
  //  cout << len << " " << start << " " << pos << endl; 
  
  if(len == (N / 2)){
    if(start == 1){
      return true;
    }else{
      return dfs(1, 1, V, -1);
    }
  }else{

    for (int i = 0; i < edges[pos].size(); i++){
      if(visit[edges[pos][i]]){ continue; }
      if (pre == edges[pos][i]){ continue; }
      if (start == 0 && edges[pos][i] == V){ continue; }

      if(dfs(len + 1, start, edges[pos][i], pos)){
	return true;
      }
    }
  }

  visit[pos] = false;
  
  return false;
}

int main(){
  cin >> N >> U >> V;
  U--; V--;
  
  bool ok = true;

  for (int i = 0; i < N - 1; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;

    edges[a].push_back(b);
    edges[b].push_back(a);
  }



  ok = dfs(1, 0, U, -1);
  if (N % 2){
    ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 16532
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll claw[2000003];
ll infant[2000003];

 
int main() 
{
    speed
    ll n;cin>>n;
    map<string,int> m;
    vector<pair<int,string>> v;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    int maxi=0;
    for(auto u : m)
    {
        v.pb(mp(u.ss,u.ff));
        maxi=max(maxi,u.ss);
    }

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

    for(auto u : v)
    {
        if(u.ff==maxi)
        {
            cout<<u.ss<<endl;
        }
    }
}

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b,c;
  cin>>a>>b>>c;
  Int ans=0;
  chmax(ans,a*10+b+c);
  chmax(ans,a+b*10+c);
  chmax(ans,a+b+c*10);
  cout<<ans<<endl;
  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;

/*Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    x = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->left != NIL) x = y->left;
  else x = y->right;
  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  if(y != z) z->key = y->key;
  }
*/
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 == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){ 
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  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
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int M=sc.nextInt();
        int ans=0;
        PriorityQueue<Integer[]> ab=new PriorityQueue<>((p1,p2)->Integer.compare(p1[0], p2[0]));
        PriorityQueue<Integer> b=new PriorityQueue<>();

        for(int i=0;i<N;i++){
            Integer AB[]=new Integer[2];
            AB[0]=sc.nextInt();
            AB[1]=sc.nextInt();
            ab.offer(AB);
        }

        for(int day=1;day<=M;day++){
            Integer cab[];
            while(true){
                if(ab.size()>0){
                    cab=ab.poll();
                }else{
                    break;
                }
                
                if(cab[0]<=day){
                    b.offer(-cab[1]);
                }else{
                    ab.offer(cab);
                    break;
                }
            }
            if(b.size()>0){
                ans-=b.poll();
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 98828
class IdScore 
	def initialize(id=0,score=0,rank=0)
		@id, @score, @rank = id, score, rank
	end

	attr_accessor :id,:score,:rank
end

data = Array.new
while gets
	id,score = $_.split(',').map(&:to_i)
	break if id == 0 && score == 0
	data << IdScore.new(id,score,0)
	data.sort!{|p,q| p.score<=>q.score}.reverse!
end
rank = 1
0.upto(data.size-1) do |i|
	data[i].rank = rank
	break if i == data.size-1
	rank += 1 if data[i].score > data[i+1].score
end
data.sort!{|p,q| p.id<=>q.id}
while gets
	id = $_.to_i
	puts data[id-1].rank
end

Measured memory_bytes: 6116
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#include<map>
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define drep(i,n) for(int i=((int)n)-1;i>-1;i--)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007

typedef long long ll;

using namespace std;


int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
int gcd(int x, int y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
ll gcd(ll x, ll y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
void say(bool x){if(x){cout<<"Yes"<<endl;}else {cout<<"No"<<endl;}return;}

int dd[500][500],PP[2][100000];
int main()
{
    int n,m,Q;
    cin >>n >>m >>Q;
    int l,r;
    rep(i,m)
    {
        cin>>l>>r;
        l--;
        r--;
        dd[l][r]++;
    }
    rep(i,n)
    {
        rep(j,n-1)
        {
            dd[i][j+1]+=dd[i][j];
        }
    }
    rep(i,n)
    {
        drep(j,n-1)
        {
            dd[j][i]+=dd[j+1][i];
        }
    }
    int p,q;
    rep(i,Q)
    {
        cin>>p>>q;
        PP[0][i]=--p;
        PP[1][i]=--q;
    }
    rep(i,Q)
    {
        W(dd[PP[0][i]][PP[1][i]])
    }
    return 0;
}


Measured memory_bytes: 2688
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
  int A, B, T;
  cin >> A >> B >> T;
  
  int total_bis = 0;
  for(int i = A; i < T + 0.5;){
    total_bis += B;
    i += A;
  }
  
  cout << total_bis << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;

int main(void)
{
	string A, B; cin >> A >> B;
	int judge = 0;

	if (A.length() > B.length())judge = 1;
	else if (A.length() < B.length())judge = 2;
	else {
		rep(j,0,A.length()){
			if (A[j] > B[j]) {
				judge = 1;
				break;
			}
			else if (A[j] < B[j]) {
				judge = 2;
				break;
			}
		}
	}

	if (judge == 1)cout << "GREATER" << endl;
	else if (judge == 2)cout << "LESS" << endl;
	else cout << "EQUAL" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define TRAV(a, x) for(const auto& a : x)
#define ALL(x) x.begin(), x.end()
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

typedef long long ll;

ll n;
string s;

void solve() {
  int count  = 0;
  string check;
  for (int i=0; i<(int)s.length(); i++) {
    check = {s[i], s[i+1], s[i+2]};
    if (check == "ABC") count++;
    if (i + 2 == (int)s.length() -1) break;
  }
  cout << count;
}

void input() {
  cin >> n >> s;
}
 
int main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<limits>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 1e18
using ll = long long;
using namespace std;

int main(){
  ll n;  cin >> n;
  ll ans = 0;
  rep1(i,n/2){
    if(n-i != i) ans++;
  }
  cout << ans;
}


Measured memory_bytes: 256
n,q=map(int,input().split())
s=input()
a=[0]*n

for i in range(n-1):
  a[i+1]=a[i]+(1 if s[i:i+2]=='AC' else 0)

for _ in range(q):
  l,r=map(int,input().split())
  print(a[r-1]-a[l-1])

Measured memory_bytes: 7748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<double,ll,ll>T;
#define PI 3.14159265358979
const int MAX = 510000;
const int MOD = 1000000007;
//この設定だとn<10^7が限界。maxの０を一個増やせば100msかかるが一桁増やせる。
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll ans=0ll;
void solve(ll n,ll x){
  if(n==1ll){
  	if(x<=4){::ans+=(x-1ll);return;}
    else{::ans+=3ll;return;}
  }
  if(x==1ll){return;}
  if(x<=((ll)pow(2ll,n+1ll)-2ll)){
  	solve(n-1,x-1ll);return;
  }
  if(x==((ll)pow(2ll,n+1ll)-1ll)){
  	::ans+=((ll)pow(2ll,n)-1ll);
    ans++;
    return;
  }
  if(x==((ll)pow(2ll,n+2ll)-3ll)){
  	::ans+=2ll*((ll)pow(2ll,n)-1ll);
    ans++;//まんなかのぶん
    return;
  }
  	::ans+=((ll)pow(2ll,n)-1ll);
  	ans++;
  	x-=((ll)pow(2ll,n+1ll)-1ll);
  	solve(n-1,x);return;
}

int main(){
  ll N,X;
  cin>>N>>X;
  solve(N,X);
  cout<<::ans;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  double n, m;
  in2(n, m);
  kono(10);
  out(n / m);
  memi;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

vector<pair<int, int> > jou[100010];
// 1=違う,0=同じ

vector<int> v(100010, -1);
// 数字の情報

void dfs(int now) {
  for (int i = 0; i < jou[now].size(); i++) {
    if (v[jou[now][i].first] == -1) {
      v[jou[now][i].first] = (v[now] + jou[now][i].second) % 2;
      dfs(jou[now][i].first);
    }
  }
}

// ====================================================================

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

  int x, y, z;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> z;
    x--;
    y--;
    z %= 2;
    jou[x].push_back(make_pair(y, z));
    jou[y].push_back(make_pair(x, z));
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] == -1) {  // わからないなら
      count++;
      v[i] = 0;
      dfs(i);
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 10752
using System;
	using System.Collections.Generic;


	class A
	{
		public static void Main ()
		{

			string s = Console.ReadLine ();
			string p = Console.ReadLine ();
			string cmpData = null;

			for(int i=0;i<s.Length;i++){
				if(p[0] == s[i]){
					int x = i;
					cmpData = null;
					for (int j=0; j<p.Length; j++) {
						cmpData += s [x];
						x = (x + 1) % s.Length;
					}
					if (p == cmpData) {
						break;
					}			
				}
			}
			if (p == cmpData) {
				Console.WriteLine ("Yes");
			}else{
				Console.WriteLine ("No");
			}
		}
	}

Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void dfs(ll N, string s, char max) {
    if(s.length() == N) {
        cout << s << endl;
    } else {
        for(char add = 'a'; add <= max + 1; ++add) {
            dfs(N, s + add, (add < max) ? max : add);
        }
    }
}

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

    dfs(N, "a", 'a');

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const ll INF = 1e18 + 10;

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};

int N, M, K;
vector<int> G[200200];
vector<int> B[200200];

int main() {
    cin >> N >> M >> K;
    UnionFind uf(N);
    rep(i,M) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
        uf.unite(a,b);
    }
    rep(i,K) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (uf.root(a) == uf.root(b)) {
            B[a].push_back(b);
            B[b].push_back(a);
        }
    }
    rep(i,N) {
        cout << uf.size(i) - G[i].size() - B[i].size() - 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 19452
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int n, q;
int A[100100];
bool dp[5000];

//bool solve(int i, int m) {
//	if (i >= n || m < 0)return false;
//	if (m == 0 || dp[m])return dp[m] = true;
//	dp[m] |= solve(i + 1, m);
//	dp[m - A[i]] |= solve(i + 1, m - A[i]);
//	return dp[m] || dp[m - A[i]];
//}

void solve(int i, int sum) {
	dp[sum] = true;
	if (i == n)return;
	solve(i + 1, sum);
	solve(i + 1, sum + A[i]);
}

int main() {
	cin >> n;
	rep(i, n)cin >> A[i];
	solve(0, 0);
	cin >> q;
	rep(i, q) {
		int m;
		cin >> m;
		if (dp[m])cout << "yes" << endl;
		else cout << "no" << endl;
	}
}

Measured memory_bytes: 3100
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main() {
	speed;
	int n;
	int c[50], v[50];
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		int gap = c[i] - v[i];
		if (gap > 0)ans += gap;
	}
	cout << ans;
	ed;
	return 0;
}


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

using namespace std;

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

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

int main(){

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

	int n;
	cin >> n;

	n= n % 10;

	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
		cout << "hon" << endl;
	}else if(n == 0 || n == 1 || n == 6 || n == 8){
		cout << "pon" << endl;
	}else{
		cout << "bon" << endl;
	}

	return 0;
}

Measured memory_bytes: 3640
n=int(input())
h=[int(i) for i in input().split()]
h.append(10000)
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(n-1):
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]))
    dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]))
print(dp[n-1])

Measured memory_bytes: 14052
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
a = LI()

xor = 0
for i in range(N):
    xor ^= a[i]

ans = []
for i in range(N):
    ans.append(xor^a[i])

print(*ans)

Measured memory_bytes: 109504
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
    long long N,K;
    cin>>N>>K;
    long long z=N%K;
    long long ans=min(z,K-z);
    cout<<ans<<endl;   
    return 0;
}

Measured memory_bytes: 3148
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_A&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    n = int(input())
    numbers = [int(x) for x in input().split()]
    numbers.reverse()
    print(*numbers)


if __name__ == '__main__':
    main(sys.argv[1:])
    

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

const ll INF = ll(1e18)+1;
ll n, k;

vector<ll> a;
bool f(ll x){
   ll count = 0;
   for(int i = 0; i < n; i++){
       if(a[i] < 0){
           int l = -1, r = n;
           while(l + 1 < r){
               int c = (l+r)/2;
               if(a[c] * a[i] < x) r = c;
               else l = c;
           }
           count += n - r;
       }
       else{
           int l = -1, r = n;
           while(l + 1 < r){
               int c = (l+r)/2;
               if(a[c] * a[i] < x) l = c;
               else r = c;
           }
           count += r;
       }
       if(a[i] * a[i] < x) count--;
   }
   count /= 2;
   return count < k;
}

int main(){
    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    ll l = -INF, r = INF;
    while(l + 1 < r){
        ll x = (l+r)/2;
        if(f(x)) l = x;
        else r = x;
    }
    cout << l << endl;
}

Measured memory_bytes: 1920
# coding: utf-8

# https://atcoder.jp/contests/abc095/tasks/arc096_b
# 16:55-17:08 chudan
# 12:45-13:08 done


def main():
    N, C = map(int, input().split())
    x = [None] * N
    v = [None] * N
    for i in range(N):
        x[i], v[i] = map(int, input().split())

    cal_clock = [None] * N
    cal = -x[0] + v[0]
    cal_clock[0] = cal if cal > 0 else 0
    for i in range(1, N):
        cal -= x[i] - x[i-1]
        cal += v[i]
        cal_clock[i] = cal if cal > cal_clock[i-1] else cal_clock[i-1]

    cal_anti = [None] * N
    cal = -(C-x[-1]) + v[-1]
    cal_anti[0] = cal if cal > 0 else 0
    for i in range(1, N):
        cal -= x[N-i] - x[N-1-i]
        cal += v[N-1-i]
        cal_anti[i] = cal if cal > cal_anti[i-1] else cal_anti[i-1]

    ans = max(cal_clock[-1], cal_anti[-1])  # 引き返さない場合
    for k in range(N-1):  # 途中で引き返す場合
        cand_1 = cal_clock[k] - x[k] + cal_anti[N-2-k]
        cand_2 = cal_anti[k] - (C-x[N-1-k]) + cal_clock[N-2-k]
        ans = max(ans, cand_1, cand_2)

    return ans


print(main())


Measured memory_bytes: 20020
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 110;
const long double pi = acos(-1.0);
long long n;
long double x[maxn], y[maxn], ans;
long double solve() {
	long double r = rand(), nx, ny, ax=0, ay=0;
	r /= RAND_MAX;
	r *= 2*pi;
	for (int i = 0; i < n; ++i) {
		nx = cos(r)*x[i]-sin(r)*y[i];
		ny = sin(r)*x[i]+cos(r)*y[i];
		if (nx >= 0) {
			ax += nx;
			ay += ny;
		}
	}
	return sqrt(ax*ax+ay*ay);
}
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> x[i] >> y[i];
	for (int i = 0; i < 10000; ++i)
		ans = max(ans, solve());
	cout << setprecision(13) << ans<<endl;
}


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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

template<int64_t MOD>
class ModInt {
	typedef int64_t T;
	T x;

  public:
	ModInt(T value) {
		if (value < 0) value = (MOD - (-value) % MOD);
		x = value % MOD;
	}

	ModInt operator-() const {
		return ModInt(-x);
	}

	ModInt& operator+=(const ModInt& p) {
		if ((x += p.get()) >= MOD) x -= MOD;
		return *this;
	}

	ModInt& operator-=(const ModInt& p) {
		if ((x += MOD - p.get()) >= MOD) x -= MOD;
		return *this;
	}

	ModInt& operator*=(const ModInt& p) {
		x = x * p.get() % MOD;
		return *this;
	}

	ModInt& operator/=(const ModInt& p) {
		*this *= p.inverse();
		return *this;
	}

	ModInt& operator+=(const T& p) {
		return *this += ModInt(p);
	}

	ModInt& operator-=(const T& p) {
		return *this -= ModInt(p);
	}

	ModInt& operator*=(const T& p) {
		return *this *= ModInt(p);
	}

	ModInt& operator/=(const T& p) {
		return *this /= ModInt(p);
	}

	ModInt operator+(const ModInt& p) const {
		return ModInt(*this) += p;
	}

	ModInt operator-(const ModInt& p) const {
		return ModInt(*this) -= p;
	}

	ModInt operator*(const ModInt& p) const {
		return ModInt(*this) *= p;
	}

	ModInt operator/(const ModInt& p) const {
		return ModInt(*this) /= p;
	}

	ModInt operator+(const T& p) const {
		return ModInt(*this) += p;
	}

	ModInt operator-(const T& p) const {
		return ModInt(*this) -= p;
	}

	ModInt operator*(const T& p) const {
		return ModInt(*this) *= p;
	}

	ModInt operator/(const T& p) const {
		return ModInt(*this) /= p;
	}

	bool operator==(const ModInt& p) const {
		return x == p.get();
	}

	bool operator!=(const ModInt& p) const {
		return x != p.get();
	}

	bool operator==(const T& p) const {
		return x == ModInt(p);
	}

	bool operator!=(const T& p) {
		return x != ModInt(p);
	}

	ModInt inverse() const {
		int a = x, b = MOD, u = 1, v = 0;
		while (b) {
			int t = a / b;
			a -= t * b;
			u -= t * v;
			swap(a, b);
			swap(u, v);
		}
		return ModInt(u);
	}

	T get() const{
		return x;
	}

	friend ostream& operator<<(ostream& out,const ModInt& value){
	    out<<value.x;
	    return out;
	}
};

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 998244353;

    int n,s;
    cin>>n>>s;
    using moi=ModInt<MOD>;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    vector<vector<moi>> dp(n+1,vector<ModInt<MOD>>(s+1,ModInt<MOD>(0)));
    dp[0][0]=moi(1);
    rep(i,n){
        rep(j,s+1){
            dp[i+1][j]=dp[i][j]*2;
            if(j-a[i]>=0)dp[i+1][j]+=dp[i][j-a[i]];
        }
    }
    cout<<dp[n][s]<<endl;
}

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

using namespace std;
using ll = long long;
static const ll LIMIT = 10000000000000000ll;

int main(){
	ios_base::sync_with_stdio(false);
	ll k;
	cin >> k;
	const int n = 50;
	vector<ll> a(n, k / n + n - 1);
	for(int i = 0; i < k % n; ++i){
		for(int j = 0; j < n; ++j){
			if(j == i){
				a[j] += n;
			}else{
				a[j] -= 1;
			}
		}
	}
	cout << n << endl;
	for(const auto x : a){ cout << x << " "; }
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	long x, y,a,b,c;
	cin >> x;
	a = 1000001;
	b = -1000001;
	c = 0;
	for (; x > 0; x = x - 1) {
		cin >> y;
		if (a > y) {
			a=y;
		}
		if (b < y) {
			b = y;
		}
		c = c + y;
	}
	cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

vector<vector<vector<int>>> dp(201, vector<vector<int>>(201, vector<int>(201, -1)));

int sub(int x, int y, int z)
{
    int a, b, c;
    // 小さい順に入れる
    if(x < y)
    {
        a = x;
        b = y;
    }
    else
    {
        a = y;
        b = x;
    }
    
    if(z < a)
    {
        int temp = a;
        a = z;
        c = b;
        b = temp;
    }
    else if(z < b)
    {
        c = b;
        b = z;
    }
    else
    {
        c = z;
    }
    
    // 既に計算済み
    if(dp.at(a).at(b).at(c) != -1)
    {
        return dp.at(a).at(b).at(c);
    }

    // 未計算
    // 3つの最大公約数
    // →2つの最大公約数に1つ付け加える。
    int temp = 0;
    temp = gcd(a, b);
    int ret = 0;
    ret = gcd(temp, c);
    dp.at(a).at(b).at(c) = ret;
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);
    int k = 0;
    int sum = 0;
    cin >> k;
    FOR(i, 1, k+1)
    {
        FOR(j, 1, k+1)
        {
            FOR(l, 1, k+1)
            {
			  // cout << "gcd(" << i << "," << j << "," << l << "): " << sub(i, j, l) << endl;
              sum = sum + sub(i, j, l);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 36692
fn main() {
  let mut s: Vec<char> = read_vec();
  let mut k: usize = read();
  
  let len = s.len();
  for i in 0 .. len {
    let d = ('z' as usize - s[i] as usize + 1) % 26;
    if i == (len - 1) || k == 0 {
      if s[i] as u8 + (k % 26) as u8 > 'z' as u8 {
        s[i] = ('a' as u8 + (s[i] as u8 + (k % 26) as u8 - 'z' as u8 - 1)) as char;
      } else {
        s[i] = (s[i] as u8 + (k % 26) as u8) as char;
      }
      break;
    } else if d <= k {
      s[i] = 'a';
      k -= d;
    } else {
      continue;
    }
  }
  
  print_vec(&s);
}

fn read<T: std::str::FromStr>() -> T {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().parse::<T>().ok().unwrap()
}

fn read_vec() -> Vec<char> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().chars().collect()
}

fn print_vec<T: std::string::ToString>(vec: &Vec<T>) {
  let out = vec.iter().map(|e| e.to_string()).collect::<Vec<_>>().as_slice().join("").to_string();
  println!("{}", out);
}

Measured memory_bytes: 8444
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();

		if (b % a == 0) {
			System.out.println(a+b);
		} else {
			System.out.println(b-a);
		}

	}

}

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


void solve(){
    int x,n;
    cin>>x>>n;

    if(n==0){
        cout<<x;
        return;
    }
    else{
        set<int> p;
        int j;
        for (int i = 0; i < n; i++)
        {
            cin>>j;
            p.insert(j);
        }

        if(!(p.count(x))){
            cout<< x;
            return;
        }
        else{
            int i=1;
            while((p.count(x+i)) ){
                i++;
            }

            int k=1;
           while((p.count(x-k)) ){
                k++;
            }

            if(k<= i){
                cout<< x-k;
            }
            else{
                cout<<x+i;
            }
            return;
            
        }


    }
    
    return;

}

int main(){
   int t;
   t=1;
    while(t--){
        solve();
    }

}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
    static int ans;

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int hs[] = { 4, 1, 4, 1, 2, 1, 2, 1 };
        while (sc.hasNext()) {
            int ps[] = new int[8];
            for (int i = 0; i < 8; i++) {
                ps[i] = sc.nextInt();
            }
            int ans = 0;
            int max = 0;
            for (int i = 0; i < 8; i++) {
                String cs = "";
                int sum = 0;
                for (int j = 0; j < 8; j++) {
                    cs += hs[(i + j) % 8];
                    sum += Math.min(hs[(i + j) % 8], ps[j]);
                }
                if (max < sum) {
                    ans = Integer.parseInt(cs);
                    max = sum;

                } else if (max == sum) {
                    if (Integer.parseInt(cs) < ans) {
                        ans = Integer.parseInt(cs);
                    }
                }
            }
            char cs[] = Integer.toString(ans).toCharArray();
            boolean init = true;
            for (int i = 0; i < 8; i++) {
                if (init) {
                    init = false;
                } else
                    System.out.print(" ");
                System.out.print(cs[i]);
            }
            System.out.println();
        }

    }
}

Measured memory_bytes: 12000
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	char a,b;

	cin >> a >> b;

if(a == 'H' && b == 'H') cout << "H" << endl;
else if(a == 'D' && b == 'D') cout << "H" << endl;
else cout << "D" << endl;

	return 0;
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0351

#include<bits/stdc++.h>
const int N = 1505;
const int inf = 1e9;
using namespace std;

typedef pair <int, int> ii;
vector <ii> adj[N];
int n, m, d[N][N], ans, visit[N], f[N], ck[N];

void dijkstra(int S){
    for (int i = 1; i <= n; i++) d[S][i] = inf; d[S][S] = 0;
    priority_queue <ii, vector <ii>, greater<ii> > mq; mq.push(ii(d[S][S], S));
    while (mq.size()){
        ii z = mq.top(); mq.pop();
        int u = z.second, val = z.first;
        if (val != d[S][u]) continue;
        ans = max(ans, val);
        for (int i = 0; i < adj[u].size(); i++){
            int v = adj[u][i].first, cost = adj[u][i].second;
            if (d[S][v] > d[S][u] + cost){
                d[S][v] = d[S][u] + cost;
                mq.push(ii(d[S][v], v));
            }
        }
    }
}

void dfs(int u, int root){
    if (visit[u]) return;
    visit[u] = true;
    f[u] = d[root][u];
    for (int i = 0; i < adj[u].size(); i++){
        int v = adj[u][i].first, cost = adj[u][i].second;
        if (d[root][v] == d[root][u] + cost){
            dfs(v, root); f[u] = max(f[u], f[v]);
        }
    }
    if (f[u] == ans) ck[u] = 1;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int u, v, d; cin >> u >> v >> d;
        adj[u].push_back(ii(v, d));
        adj[v].push_back(ii(u, d));
    }
    for (int i = 1; i <= n; i++) dijkstra(i);
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++) visit[j] = 0;
        dfs(i, i);
    }
    int cnt = 0; for (int i = 1; i <= n; i++) if (!ck[i]) cnt++;
    cout << cnt << "\n";
    for (int i = 1; i <= n; i++) if (!ck[i]) cout << i << "\n";
}



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

using namespace std;

int main(){
    int n,m,p;
    int64_t  miss=0;
    int64_t answer =  0;
    cin >>n >> m;
    vector<int64_t> atcoder (n+1,0);
    vector<int64_t> penalty (n+1,0);
    string s;
    for(int i=0;i<m;i++){

        cin >>p >>s;
        
        if(s=="WA"){
            penalty[p]++;
        }else if(s=="AC"&& atcoder[p]==0){
            miss += penalty[p];
            atcoder[p] ++;
        } 
    }
    
    for(int j=0;j<n+1;j++){
        if(atcoder[j]) answer++;
    }
    cout <<answer<<"  "<<miss<<endl;
}

Measured memory_bytes: 1792
a = int(input())
h = list(map(int, input().strip().split()))



c = 0


d = [0] * len(h)

f = True
if len(h) == 1:
    f = True
elif len(h) == 2:
    if h[1] >= h[0]:
        f = True
    else:
        if h[0] == h[1] + 1:
            f = True
        else:
            f = False
else:
    for i in range(len(h)-1):
        if h[i] + 1 <= h[i+1]:
            #print('c1')
            if d[i+1] == 0:
                h[i+1] -= 1
                d[i+1] = 1
        elif h[i] == h[i+1] + 1:
            #print('c2')
            if i >= 1:
                if h[i-1] + 1 <= h[i]:
                    #print(i,h[i-1],h[i])
                    if d[i] == 0:
                        h[i] -= 1
                        d[i] = 1
                    else:
                        f = False
                        break
                    #print('sub')
                else:
                    #print('c2-2')
                    f = False
                    break
        else:
            #print('c3')
            if not h[i] == h[i+1]:
                #print('c4')
                f = False
                break
        #print(i,h)
#print(h)
if f:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14480
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int n = new java.util.Scanner(System.in).nextInt();
		System.out.println(fibonacci(n));
	}

	public static int fibonacci(int n) {
		int[] memo = new int[n+1];
		memo[0] = 1;
		memo[1] = 1;
		for (int i=2; i <= n; i++) {
			memo[i] = memo[i-1] + memo[i-2];
		}
		return memo[n];
	}
}

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

int main(){
  int n;
  cin >> n;
  int vec[n];
  for(int i=0;i<n;i++){
    cin >> vec[i];
  }

  for(int j=n-1;j>=0;j--){
    if(j==0){
      cout << vec[j] << endl;
    } else {
      cout << vec[j] << " ";
    }
  }
}



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


int main() {
  int N;
  int K;
  int tmp = 1;

  cin >> N >> K;

  rep(i, N){
    if((2 * tmp) < (K + tmp)){
      tmp = 2 * tmp;
    }
    else{
      tmp += K;
    } 
  }
  cout << tmp << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;


int main() {

	ll N, M;
	cin >> N >> M;
	map<ll, ll> food;
	for (int i = 0; i < N; ++i) {
		ll num;
		cin >> num;
		for (int j = 0; j < num; ++j) {
			ll tmp;
			cin >> tmp;
			food[tmp] += 1;
		}
	}

	ll ans = 0;
	for (int i = 1; i <= M; ++i) {
		if (food[i] == N) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N, K, Q;
	cin >> N >> K >> Q;

	vector<int> A;
	inputVector(A, N);

	set<int> st;
	for (int num : A) {
		st.insert(num);
	}

	int ret = INT_MAX;
	for (int num : st) {
		vector<int> canUse;

		priority_queue<int> q;
		rep(i, N) {
			if (A[i] >= num) {
				q.push(-A[i]);
			} else {
				while (q.size() >= K) {
					canUse.push_back(-q.top());
					q.pop();
				}
				while (!q.empty()) q.pop();
			}
		}
		while (q.size() >= K) {
			canUse.push_back(-q.top());
			q.pop();
		}

		//cerr << "num:" << num << endl;
		//for (int num2 : canUse) cerr << num2 << " ";
		//cerr << endl;

		if (canUse.size() < Q) break;

		sort(all(canUse));

		ret = min(ret, canUse[Q - 1] - canUse[0]);
	}

	cout << ret << endl;

    return 0;
}


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

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

struct BiMatch{
  int n;
  vector<vector<int> > G;
  vector<int> match,used;
  
  BiMatch(){}
  BiMatch(int sz):n(sz),G(sz),match(sz),used(sz){}
  
  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  bool dfs(int v){
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
      int u=G[v][i],w=match[u];
      if(w<0||(!used[w]&&dfs(w))){
	match[v]=u;
	match[u]=v;
	return true;
      }
    }
    return false;
  }

  int build(){
    int res=0;
    fill(match.begin(),match.end(),-1);
    for(int v=0;v<n;v++){
      if(match[v]<0){
	fill(used.begin(),used.end(),0);
	if(dfs(v)){
	  res++;
	}
      }
    }
    return res;
  }
};

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	vector<PII> p[2];
	cin >> N;
	REP(j, 2){
		p[j].resize(N);
		REP(i, N){
			cin >> p[j][i].fs >> p[j][i].sc;
		}
		sort(all(p[j]), greater<PII>());
	}
	BiMatch bm(2*N);
	REP(i, N){
		REP(j, N){
			if(p[0][i].fs < p[1][j].fs && p[0][i].sc < p[1][j].sc){
				bm.add_edge(i, j+N);
			}
		}
	}
	cout << bm.build() << endl;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vi a(n);
    rep(i, n) a[i] = s[i] - '0';
    ll ans = 0;
    rep(i, 1<<(n-1)) {
        ll sum = 0, val = 0;
        rep(j, n-1) {
            val = val * 10 + a[j];
            if (i&(1<<j)) {
                sum += val;
                val = 0;
            }
        }
        val = val * 10 + a[n-1];
        sum += val;
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N;
	cin >> N;
	vector<int>a(N),b(N),c(N-1);
	REP(i,N){cin>>a[i];a[i]--;}
	REP(i,N)cin>>b[i];
	REP(i,N-1)cin>>c[i];
	int ans = 0;
	REP(i,N){
		ans += b[a[i]];
		if(i){
			if(a[i]-a[i-1]==1)ans+=c[a[i]-1];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
N=int(input())
S=[input() for i in range(N)]
a,b,c,d=0,0,0,0
for i in S:
    if i=="AC":
        a+=1
    if i=="WA":
        b+=1
    if i=="TLE":
        c+=1
    if i=="RE":
        d+=1
print("AC x {}".format(a))
print("WA x {}".format(b))
print("TLE x {}".format(c))
print("RE x {}".format(d))

Measured memory_bytes: 16168
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

ll gcd(ll a,ll b){return b ? gcd(b,a%b) :a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}

ll n;



    vector<pair<ll,ll>>p;
void fs(ll a){
    for(ll i=2;i*i<=n;i++){
        ll cnt=0;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        p.emplace_back(i,cnt);
    }
    return;
}


ll di[]={1,0,-1,0};
ll dj[]={0,-1,0,1};
int main()
{
 const ll m=1000000007;
 ll n;
 cin>>n;
 vector<ll>a(n);
 rep(i,n)cin>>a[i];
 vector<ll>v(n-1);
 ll sum=0;
 Rep(i,n)sum+=a[i];
 v[0]=sum;
 Rep(i,n-1){
     v[i]=(v[i-1]-a[i]);
 }  
 ll ans=0;
 rep(i,n-1){
     
         ans+=(a[i]%m * (v[i]%m))%m;
         ans%=m;
 }
 cout<<ans<<endl;
 
}
 




Measured memory_bytes: 6376
s=[i for i in input()]
dic={}
for i in range(4):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
flg=True        
for k,v in dic.items():
    if v != 2:
	    flg=False
print("Yes" if flg else "No")        

Measured memory_bytes: 3060