akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<cmath>
#include<string>
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
#define ls id<<1,l,mid
#define rs id<<1|1,mid+1,r
#define OFF(x) memset(x,-1,sizeof x)
#define MEM(x) memset(x,0,sizeof x)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define Rep(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
typedef pair<int,int>pii;
const int maxn=1e5+50;
const int inf =0x3f3f3f3f;
const int MOD =1e9+7;

map<string,int> dp;
int dic[4][2]={1,0,-1,0,0,1,0,-1};

bool Check(int x,int y)
{
	return x>=0&&y>=0&&x<4&&y<4;
}

void bfs()
{
	queue<string> q;
	q.push("01234567");
	dp["01234567"]=0;
	while(!q.empty())
	{
		string now,nxt;
		now=q.front();q.pop();
		int x,y,z;
		for(z=0;z<8;z++)
		{
			if(!(now[z]-'0'))
				break;
		}
		x=z/4;y=z%4;
		for(int i=0;i<4;i++)
		{
			int newx=x+dic[i][0];
			int newy=y+dic[i][1];
			int newz=newx*4+newy;
			if(Check(newx,newy))
			{
				nxt=now;
				swap(nxt[z],nxt[newz]);
                if(dp.find(nxt)==dp.end())
                {
                	dp[nxt]=dp[now]+1;
				    q.push(nxt);
                }
			}
		}
	}
	
}

int main()
{
	bfs();
	string line;
	while(getline(cin,line))
	{
		line.erase(remove(line.begin(),line.end(),' '),line.end());
		cout<<dp[line]<<endl;
	}
	return 0; 
}

Measured memory_bytes: 5356
#include "bits/stdc++.h"
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
const ld eps = 1e-9;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a) {
    if(a<0)return -1;
    if(a>0)return 1;
    return 0;
}

template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}

template<typename T> inline void in(T &x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (isdigit(ch))  {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= f;
}

ll twop(int x) {
    return 1LL<<x;
}

template<typename A,typename B > inline void in(A&x,B&y) {
    in(x);
    in(y);
}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {
    in(x);
    in(y);
    in(z);
}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {
    in(x);
    in(y);
    in(z);
    in(d);
}


bitset<4000001>b;
int main() {
    b[0] = 1;
    int n;in(n);
    int sum = 0;
    REP(i,0,n){
        int c;in(c);
        b|=b<<c;
        sum+=c;
    }
    
    REP(i,(sum+1)/2,sum+1){
        if(b[i]){
            return printf("%d",i),0;
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}




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

int main() {
  int N;
  string S1, S2;
  cin >> N >> S1 >> S2;
  long long ans = 1;
  int i= 0;
  int tmp = -1;
  while (i < N) {
       if (S1[i] == S2[i]) {
           if (tmp < 0) ans = 3;
           else if (tmp == 0) ans *= 2;
           else ans *= 1;
           i++; tmp = 0;
           ans %= 1000000007;
       } else {
           if (tmp < 0) ans = 6;
           else if (tmp == 0) ans *= 2;
           else ans *= 3;
           i += 2; tmp = 1;
           ans %= 1000000007;
       }
   }
   ans %= 1000000007;
  cout << ans << endl;
}


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

void prians(bool answer) {
  if(!answer)
    cout << "Second" << endl;
  else
    cout << "First" << endl;
}

int n, k;
int a[100005] = {0};
bool dp[100005] = {0};

bool solve();

int main() {
  cin >> n >> k;
  for(int i = 0; i < n; ++i) cin >> a[i];
  prians(solve());
  return 0;
}

bool solve() {
  for(int i = 1; i <= k; ++i) {
    bool ch = 1;
    for(int j = 0; j < n && a[j] <= i; ++j)
      ch &= dp[i - a[j]];
    dp[i] = !ch;
  }
  return dp[k];
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cerr<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define ERROR  1e-9
#define pi (2*acos(0))
const ll mod = 998244353;
const int N = 1e5 +5;


void SOLVE(int cas)
{
    int n;
    scanf("%d",&n);
    vector<int>v(n),decrease(n),pos(n,-1);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&v[i]);
        v[i]--;

    }
    int maxi =0;
    for(int i=0;i<n;i++)
    {
        if(v[i]==0 || pos[v[i]-1]==-1)
        {
            decrease[v[i]] = 1;
        }
        else{
            decrease[v[i]] = 1+ decrease[v[i]-1];
        }
        pos[v[i]]=i;
    }
    maxi = *max_element(decrease.begin(),decrease.end());
    int ans = n-maxi;
    printf("%d\n",ans);
}


/*


*/



int main()
{
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        SOLVE(++cas);
    }

    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;

int main() {
  int K, S;

  cin >> K >> S;

  int ans = 0;
  int x, y, z;
  for (x = min(K,S); x >= 0; --x) {
    y = min(K, S - x);
    z = S - (x + y);
    if (y < z) break;
    ans += y - z + 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
typedef long long ll;
const int N=100005;
int n,m,head[N],now=0,vis[N],ok=0;
ll val[N],sym[N],l,r;
using namespace std;

struct node
{
	int t,w,next;
}adj[N<<1];
void add(int s,int t,int w)
{
	adj[++now]=(node){t,w,head[s]};
	head[s]=now;
}
void dfs(int s)
{
	int i;vis[s]=1;
	for (i=head[s];i;i=adj[i].next)
	{
		if (vis[adj[i].t])
		{
			if (sym[s]*sym[adj[i].t]==-1 && val[s]+val[adj[i].t]!=adj[i].w){ok=1;return;}
			if (sym[s]==sym[adj[i].t])
			{
				if (sym[s]==1)
				{
					ll t=1ll*adj[i].w-val[s]-val[adj[i].t];
					if (t<=0 || (t&1)){ok=1;return;}
					t>>=1;
					l=max(l,t),r=min(r,t);
				}
				else
				{
					ll t=1ll*adj[i].w-val[s]-val[adj[i].t];
					t=-t;
					if (t<=0 || (t&1)){ok=1;return;}
					t>>=1;
					l=max(l,t),r=min(r,t);
				}
			}
			continue;
		}
		val[adj[i].t]=1ll*adj[i].w-val[s];
		sym[adj[i].t]=-sym[s];dfs(adj[i].t);
		if (ok) return;
	}
}
int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	scanf ("%d %d",&n,&m);
	int i,s,t,w;
	for (i=1;i<=m;i++)
	{
		scanf ("%d %d %d",&s,&t,&w);
		add(s,t,w),add(t,s,w);
	}
	l=1,r=1ll<<60;sym[1]=1,dfs(1);
	if (ok){printf ("0");return 0;}
	for (i=2;i<=n;i++)
	{
		if (sym[i]==1) l=max(l,1ll-val[i]);
		else r=min(r,val[i]-1ll);
	}
	if (l>r) cout<<0;
	else cout<<r-l+1;
	return 0;
}


Measured memory_bytes: 8064
package main

import (
	"fmt"
)

func roundOne(a, b int) int {
	var c int
	switch ans := a * b; ans {
	case 3:
		c = 2
	case 2:
		c = 3
	case 6:
		c = 1
	}
	return c
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(roundOne(a, b))
}


Measured memory_bytes: 512
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
a.sort!
ps = []
m.times do |i|
  b, c = gets.split.map(&:to_i)
  ps << {
    :b => b,
    :c => c
  }
end
ps.sort! do |x, y|
  v = -1
  v = 1 if x[:c] < y[:c]
  v = 0 if x[:c] == y[:c]
  v
end
ans = 0

ps.each do |p|
  p[:b].times do |i|
    t = a.shift
    break if t == nil
    ans += [t, p[:c]].max
  end
  break if a.length == 0
end
a.each do |v|
  ans += v
end
puts ans


Measured memory_bytes: 38276
#include<stdio.h>
#define M 500000

void merge(int*,int,int,int);
void MergeSort(int*,int,int);

int count=0;
int main(){
  int n,i,A[M];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  MergeSort(A,0,n);
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);

  printf("%d\n",count);
  return 0;
}

void merge(int *A,int left,int mid,int right){
  int i,j,k,n1,n2,L[M],R[M];
  n1=mid-left;
  n2=right-mid;
    for(i=0;i<n1;i++){
      L[i]=A[left+i];
    }
    for(i=0;i<n2;i++){
      R[i]=A[mid+i];
    }
    L[n1]=999999999;
    R[n2]=999999999;
    i=0;
    j=0;
    for(k=left;k<right;k++){
      if(L[i]<=R[j]){
        A[k]=L[i];
        i++;
      }
      else{
        A[k]=R[j];
        j++;
      }
      count++;
    }
}

void MergeSort(int *A,int left,int right){
  int mid;
  if((left+1)<right){
    mid=(left+right)/2;
    MergeSort(A,left,mid);
    MergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}





Measured memory_bytes: 5712
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);

  int p[n];
  int min = 200001 , count = 0;
  for(int i = 0;i < n;i ++){
    scanf("%d",&p[i]);
    if(p[i] < min){
      min = p[i];
      count ++;
    }
  }

  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 896
def dfs(s, upper):
    if len(s) == N:
        print(s)
    else:
        cur = 'a'
        while cur <= upper:
            dfs(s + cur, chr(ord(cur) + 1) if cur == upper else upper)
            cur = chr(ord(cur) + 1)


N = int(input())
dfs('', 'a')

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

int main() {
	int N;
	cin >> N;
	ll A[N];
	for(int i = 0; i < N; i++) cin >> A[i];
	ll sum[N + 1];
	sum[0] = 0;
	for(int i = 0; i < N; i++) sum[i + 1] = sum[i] + A[i];
	sort(sum, sum + N + 1);
	ll ans = 0, cnt = 1;
	for(int i = 1; i < N + 1; i++) {
		if(sum[i - 1] == sum[i])
			cnt++;
		else {
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}
	ans += cnt * (cnt - 1) / 2;
	cout << ans;
	return 0;
}


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

int main() {
  ll n;
  string s;
  cin >> n >> s;
  vector<int> w(n + 1), e(n + 1);
  e[0]     = 0;
  w[n]     = 0;
  int i    = 0;
  int j    = n;
  int wCnt = 0, eCnt = 0;
  while (i < n && j > 0) {
    if (s[i] == 'E') {
      e[i + 1] = e[i] + 1;
      eCnt++;
    } else {
      e[i + 1] = e[i];
    }
    if (s[j - 1] == 'W') {
      w[j - 1] = w[j] + 1;
      wCnt++;
    } else {
      w[j - 1] = w[j];
    }
    i++;
    j--;
  }
  int mn = INT_MAX;
  for (int i = 0; i <= n; i++) {
    mn = min(mn, (wCnt - w[i]) + (eCnt - e[i]));
  }
  cout << mn << endl;
}

Measured memory_bytes: 3076
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;
const ll INF = 1e18 + 10 ;
const double EPS = 1e-6 ; 
signed main(){
    fastio
    int n ; 
    cin >> n ; 
    string s ;
    cin >> s ; 
    set<int> SET[26];
    for(int i = 0; i < n; i++){
        SET[s[i] - 'a'].insert(i) ; 
    }
    int q ;
    cin >> q ;
    while(q--){
        int t ;
        cin >> t ;
        if ( t == 1 ){
            int pos ; 
            char c ;
            cin >> pos >> c ;
            pos--;
            for(int i = 0; i < 26; i++){
                if ( SET[i].count(pos) ){
                    SET[i].erase(pos) ;
                    break;
                }
            }
            SET[c - 'a'].insert(pos) ;
        }
        else{
            int l , r ;
            cin >> l >> r ;
            l--, r--;
            int ans = 0 ;
            for(int i = 0; i < 26; i++){
                auto it = SET[i].lower_bound(l) ; 
                if ( it == SET[i].end() ) continue ; 
                if ( *it <= r ) ans++ ; 
            }
            cout << ans << endl;
        }
    }
    return 0; 
}

Measured memory_bytes: 26268
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int f(int n, int s, int a) {
	int r,i;
	if (n == 1)
		if (a <= s&&s <= 9) return 1;
		else return 0;
	r = 0;
	for (i = a; i <= 9&&i<s; i++) r += f(n - 1, s - i, i + 1);
	return r;
}
int main() {
	FILE *fp = stdin;
	int n, s;
	while (fscanf(fp,"%d%d",&n,&s)&&(n||s)){
		fprintf(stdout,"%d\n", f(n, s, 0));
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>

#define ll long long

using namespace std;

vector<vector<int>> g;
vector<vector<int>> dp;


int main(){
	int n, m;
	cin >> n >> m;
	g.resize(n, vector<int>());
	dp.resize(3, vector<int>(n, -1));

	for (int i = 0; i < m; i++) {
		int from, to;
		cin >> from >> to;
		from--;
		to--;
		g[from].push_back(to);
	}
	
	int start, end;
	cin >> start >> end;
	start--; end--;

	dp[2][start] = 0;

	deque<pair<int, int>> qu;
	qu.push_back(make_pair(start, 2));
	

	while (qu.size() > 0) {
		pair<int, int> pv = qu.front();
		qu.pop_front();
		int v = pv.first;
		int p = pv.second;
		int next = (p + 1) % 3;

		for (int i : g[v]) {
			if (dp[next][i] == -1) {
				if (next == 0) {
					dp[next][i] = dp[p][v] + 1;
					qu.push_back(make_pair(i, next));
				}else {
					dp[next][i] = dp[p][v];
					qu.push_front(make_pair(i, next));
				}
			}
		}
	}

	cout << dp[2][end];
}



Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
 int main() {
  string a,b,c;cin>>a>>b>>c;
  bool A=a.at(a.size()-1)==b.at(0);
  bool B=b.at(b.size()-1)==c.at(0);
  if(A&&B)
    cout<<"YES";
  else
    cout<<"NO";
}
    



Measured memory_bytes: 256
//In the name of Allah
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll [[maybe_unused]] = long long;
[[maybe_unused]] typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
    IO;
    int a, b;
    cin >> a >> b;
    cout << 2 * b - a;
    return 0;
}

Measured memory_bytes: 3608
N = int(input())
F= [list(map(int, input().split())) for _ in range(N)]
P= [list(map(int, input().split())) for _ in range(N)]

ans = -10000000000
for i in range(1, 2**10):
    tmp = 0
    for j in range(N):
        cnt = 0
        for k in range(10):
            if((i>>k)%2 == 1 and F[j][k] == 1):
                cnt += 1
        tmp += P[j][cnt]
    ans = max(ans, tmp)

print(ans)

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

int main(){
	int64_t K,N,ans=0;
    cin>>N>>K;
    vector<int64_t> H(N);
    for (int i=0;i<N;i++){
    	cin>>H.at(i);
    }
  sort(H.begin(), H.end());
  for(int i=0;i<N-K;i++){
  	ans+=H.at(i);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4756
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a,b=0;
	string s;
	cin >> s;
	a = s.size();
	for (int i = 0; i<a/2; i++) {
		if (s[i] != s[a - i-1])b++;
	}
	cout << b << endl;
	return 0;


}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Q = sc.nextInt();
    String S = sc.next();
    int count = 0;
    int[] Time = new int[N+1];
    int r;
    int l;
    Time[0] = 0;
    for(int i=1; i<=N; i++){
      if(i!=N && S.charAt(i-1)=='A' && S.charAt(i)=='C'){
        count++;
      }
      Time[i] = count;
    }
    
    for(int i=0; i<Q; i++){
      r = sc.nextInt();
      l = sc.nextInt();
      System.out.println(Time[l-1] - Time[r-1]);
    }
  }
}


Measured memory_bytes: 63696
#include<cstdio>
#include<iostream>
#define MAX 100000
#define NIL -1
struct Node{int p, l, r;};
Node T[MAX]; int D[MAX];
using namespace std;
void incur(int r, int d)
{
  D[r] = d;
  if(T[r].l != NIL) incur(T[r].l, d+1);
  if(T[r].r != NIL) incur(T[r].r, d);
}

void print(int v)
{
  printf("node %d: parent = %d, depth = %d, ", v, T[v].p, D[v]);
  if(T[v].p == NIL)
    printf("root, [");
  else if(T[v].l == NIL)
    printf("leaf, [");
  else printf("internal node, [");
  int c = T[v].l;
  int i=0;
  while(c != NIL)
  {
    if(i) printf(", ");
    printf("%d", c);
    c = T[c].r;
    i++;
  }
  printf("]\n");
}
int main()
{
  int left, root, v, num, temp;
  int n;
  scanf("%d", &n);
  for(int i=0; i<n; i++)
  {
    T[i].l = NIL; T[i].p = NIL; T[i].r = NIL;
  }
  for(int i=0; i<n; i++)
  {
    scanf("%d%d", &v, &num);
    for(int j=0; j<num; j++)
    {
      scanf("%d", &temp);
      if(j == 0) T[v].l = temp;
      else T[left].r = temp;
      left = temp;
      T[temp].p = v;
    }
  }
  for(int i=0; i<n; i++)
  {
    if(T[i].p == NIL) root = i;
  }
  incur(root, 0);
  for(int i=0; i<n; i++)
    print(i);

  return 0;
}



Measured memory_bytes: 4796
arr = Array.new(6, 0)
ans = 0
arr.size.times do |i|
	arr[i] = gets.to_i
	
end
(1..5).each do |j|
	num = arr[0] / arr[j]
	if arr[0] % arr[j] == 0
		num -= 1
	end
	
	if ans <= num
		ans = num
	end	
end
puts ans + 5

Measured memory_bytes: 1788
import math
a,b=map(int,input().split())
A=set(range(math.ceil(a/0.08),math.floor((a+1)/0.08)))
B=set(range(math.ceil(b/0.1),math.floor((b+1)/0.1)))
A_B=list(A&B)
print("-1" if len(A_B)==0 else min(A_B))

Measured memory_bytes: 3060
tbl = set()
for i in range(2):
    c = [int(x) for x in input().split()]
    for hm in zip(c[1::2], c[2::2]):
        #print(hm)
        tbl.add((hm[0],hm[1]))

L = []
for h, m in sorted(tbl):
    L.append("{}:{:02d}".format(h,m))

print(*L)




Measured memory_bytes: 5644
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int n,a,b,c,d;
string s;

int main() {
	cin >> n >> a >> b >> c >> d >> s;
	if (c<b)//ACbd
	{
		bool flag = 0;//1なら岩
		for (int i = a-1; i <= c-1; i++)
		{
			if (s[i] == '#') {
				if (flag)
				{
					cout << "No" << endl;
					return 0;
				}
				else {
					flag = true;
				}
			}
			else {
				flag = false;
			}
		}
		flag = 0;
		for (int i = b - 1; i <= d - 1; i++)
		{
			if (s[i] == '#') {
				if (flag)
				{
					cout << "No" << endl;
					return 0;
				}
				else {
					flag = true;
				}
			}
		}
		cout << "Yes" << endl;
		return 0;
	}
	else if (b < c&&c < d) {//AbCd
		bool flag = 0;//1なら岩
		for (int i = a - 1; i <= d - 1; i++)
		{
			if (s[i] == '#') {
				if (flag)
				{
					cout << "No" << endl;
					return 0;
				}
				else {
					flag = true;
				}
			}
			else {
				flag = false;
			}
		}
		/*int sr = 0;
		for (int i = b-2; i <= c; i++)
		{
			if (s[i]=='#')
			{
				sr++;
				if (b<=i&&i<=c&&sr>2)
				{
					cout << "Yes" << endl;
					return 0;
				}
				else {
					sr = 0;
				}
			}
		}
		*/
		cout << "Yes" << endl;
		return 0;
	}
	else {//AbdC
		bool flag = 0;//1なら岩
		for (int i = a - 1; i <= c - 1; i++)
		{
			if (s[i] == '#') {
				if (flag)
				{
					cout << "No" << endl;
					return 0;
				}
				else {
					flag = true;
				}
			}
			else {
				flag = false;
			}
		}
		int sr = 0;
		for (int i = b - 2; i <= d; i++)
		{
			if (s[i] == '.')
			{
				sr++;
				if (b <= i && i <= d && sr > 2)
				{
					cout << "Yes" << endl;
					return 0;
				}
			}
			else {
				sr = 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}
}

Measured memory_bytes: 640
//--- pA ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		// scanner.nextLine();
		String line = scanner.nextLine();

		int a = Integer.parseInt(line.split("\\s+")[0]);
		int b = Integer.parseInt(line.split("\\s+")[1]);
		int c = Integer.parseInt(line.split("\\s+")[2]);

		int cnt = 0;
		if (a == b) cnt ++;
		if (a == c) cnt ++;
		if (b == c) cnt ++;

		if (cnt == 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		return;
	}

	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define scn(n) scanf("%d",&n)
using namespace std;

int main() {
	
	int n;
	cin>>n;
	
	char arr[n+1];
	
	for(int i=0;i<n;i++)
	{
	    cin>>arr[i];
	}
	
	
	int i=0,j=n-1;
	int step=0;
	
	for(;i<=j;)
	{
	    if(arr[i]=='R' and arr[j]=='W')
	    {
	        i++;
	        j--;
	    }
	    else if(arr[i]=='W' and arr[j]=='R')
	    {
	        step++;
	        i++;
	        j--;
	    }
	    else if(arr[i]=='R' and arr[j]=='R')
	    {
	        i++;
	    }
	    else if(arr[i]=='W' and arr[j]=='W')
	    {
	        j--;
	    }
	}
	cout<<step;
	return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
long long n,i,j,k,l,a[100005],b[100005],du[100005],flag,y,z;
long long top,nex[200005],to[200005],fir[100005];
long long read(){
	char ch=getchar();
	long long x=0;
	while(ch<'0'||ch>'9')
		ch=getchar();
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x;
}
int lj(long long u,long long v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
	return 0;
}
int ss(long long u,long long v){
	if(flag==1)
		return 0;
	long long max1=0,sum=0;
	for(int top1=fir[v];top1;top1=nex[top1])
		if(to[top1]!=u){
			ss(v,to[top1]);
			sum+=b[to[top1]];
			max1=max(max1,b[to[top1]]);
		}
	if(du[v]==1){
		b[v]=a[v];
	}
	else{
		if(a[v]*2<sum||a[v]>sum){
			flag=1;
			return 0;
		}
		if(max1>a[v]){
			flag=1;
			return 0;
		}
		b[v]=2*a[v]-sum;
	}
	return 0;
}
int main(){
	n=read();
	for(i=1;i<=n;i++)
		a[i]=read();
	if(n==2){
		if(a[1]==a[2])
			printf("YES\n");
		else
			printf("NO\n");
		return 0;
	}
	for(i=1;i<n;i++){
		y=read();
		z=read();
		lj(y,z);
		lj(z,y);
		du[y]++;
		du[z]++;
	}
	for(i=1;i<=n;i++)
		if(du[i]!=1){
			ss(i,i);
			if(flag==0&&b[i]==0)
				printf("YES\n");
			else
				printf("NO\n");
			return 0;
		}
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=987654319;
const ll inf=1e15;
const ll N=3e5+10;
 
string s;
int n;
mypair ans;
bool chk(int len)
{
	int limit=len/2;
	vector<int> cnt(26,0);
	for(int i=0;i<len;i++) cnt[s[i]-'a']++;
	if(*max_element(all(cnt)) > limit )
	{
		ans.ff=1;
		ans.ss=len;
		return 1;
	}	
	for(int i=1;(i+len-1)<n;i++)
	{
		cnt[s[i-1]-'a']--;
		cnt[s[i+len-1]-'a']++;
		if(*max_element(all(cnt)) > limit )
		{
			ans.ff=i+1;
			ans.ss=i+len;
			return 1;
		}
	}	
	return 0;
} 
 
int main()
{
	boost;
	cin>>s;
	n=s.size();
	ans.ff=ans.ss=-1;

	chk(2);
	if(n>=3) chk(3);	
	cout<<ans.ff<<" "<<ans.ss;

  	return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
res = [-1] * n
f = True
for i in range(m):
    s, c = map(int, input().split())
    s -= 1 # 0 ind
    if res[s] == -1 or res[s] == c:
        res[s] = c
    else:
        f = False

if res[0] == -1 and n != 1:
    res[0] = 1

res = list(map(lambda x: x if x != -1 else 0, res))
#print(res)

num = int("".join(list(map(str, res))))
#print(res)
#print(num)

if len(str(num)) != n:
    f = False

if f is True:
    res = "".join(list(map(str, res)))
    print(res)
else: # False
    print(-1)

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

int id = INT_MAX;
int merge (int l, int r) {
	return min(l, r);
}

struct node {
	int val;
	int all;
	node *lch, *rch;
	unsigned int pri;
	int size;
	int sum;
	node(int v, unsigned int p) : val(v), all(v), pri(p), size(1), sum(v) {
		lch = rch = nullptr;
	}
};

random_device rd;

int count(node *t) { return t == nullptr ? 0 : t->size; }
int sum(node *t) { return t == nullptr ? 0 : t->sum; }
int que(node *t) { return t == nullptr ? id : t->all; }
node *update(node *t) {
	t->size = count(t->lch) + count(t->rch) + 1;
	t->sum = sum(t->lch) + sum(t->rch) + t->val;
	t->all = merge(que(t->lch), merge(t->val, que(t->rch)));
	return t;
}
node *merge(node *l, node *r) {
	if (l == nullptr || r == nullptr) return l == nullptr ? r : l;
	if (l->pri > r->pri) {
		l->rch = merge(l->rch, r);
		return update(l);
	}
	else {
		r->lch = merge(l, r->lch);
		return update(r);
	}
}
pair<node*, node*> split(node *t, int k) {
	if (t == nullptr) return make_pair(nullptr, nullptr);
	if (k <= count(t->lch)) {
		pair<node*, node*> s = split(t->lch, k);
		t->lch = s.second;
		return make_pair(s.first, update(t));
	}
	else {
		pair<node*, node*> s = split(t->rch, k - count(t->lch) - 1);
		t->rch = s.first;
		return make_pair(update(t), s.second);
	}
}
node *insert(node *t, int k, int v, unsigned int pri) {
	pair<node*, node*> s = split(t, k);
	node *r = merge(s.first, new node(v, pri));
	r = merge(r, s.second);
	return r;
}
node *erase(node *t, int k) {
	pair<node*, node*> s1 = split(t, k), s2 = split(s1.second, 1);
	if (s2.first != nullptr) delete s2.first;
	return merge(s1.first, s2.second);
}
node *find(node *t, int k) {
	if (t == nullptr) return t;
	int c = count(t->lch);
	return k < c ? find(t->lch, k) : k == c ? t : find(t->rch, k - (c + 1));
}
int find(node *t, int l, int r) {
	if (t == nullptr) return id;
	if (r < 0 || l >= count(t)) return id;
	if (l <= 0 && r >= count(t)) return t->all;
	int c = count(t->lch);
	return merge(t->lch == nullptr ? id : find(t->lch, l, r), merge(l <= c && c < r ? t->val : id, t->rch == nullptr ? id : find(t->rch, l - (c + 1), r - (c + 1))));
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	int n, q, com, x, y;
	cin >> n >> q;
	node* root = nullptr;
	for (int i = 0; i < n; i++) {
		root = insert(root, i, INT_MAX, rd());
	}
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", find(root, x, y + 1));
		}
		else {
			root = erase(root, x);
			root = insert(root, x, y, rd());
		}
	}
	return 0;
}

Measured memory_bytes: 7968
#include<stdio.h>

int main()
{
    int N,K,h,i,x=0;
    scanf("%d%d", &N, &K);
    for(i=1;i<=N;i++){
        scanf("%d", &h);
        if(h>=K){
            x++;
        }
    }
    printf("%d", x);
    return 0;
}


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

const LL MOD = 1000000000 + 7;
LL dp[41][1 << 16];

int main() {
	int n, x, y, z;
	cin >> n >> x >> y >> z;
	dp[0][0] = 1;
	int mask = (1 << (x + y + z - 1)) - 1;
	int xyz = (1 << (x + y + z - 1)) | (1 << (y + z - 1)) | (1 << (z - 1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < (1 << (x + y + z - 1)); j++) {
			for (int k = 1; k <= 10; k++) {
				int bit = (j << k) | (1 << (k - 1));
				if ((bit&xyz) == xyz)  continue;
				(dp[i + 1][bit&mask] += dp[i][j]) %= MOD;
			}
		}
	}
	LL ans = 1;
	for (int i = 0; i < n; i++) {
		(ans *= 10) %= MOD;
	}
	for (int i = 0; i < (1 << (x + y + z - 1)); i++) {
		ans = (ans - dp[n][i] + MOD) % MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 20736
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    string s[5];
    int idx = 0;
    while(cin >> s[idx++]);
    string temp = s[0];
    if(s[1].size() > 0){
        reverse(temp.begin(), temp.end());
        string temp2 = s[1];
        reverse(temp2.begin(), temp2.end());
        if(temp2 == s[0] && temp == s[1])
            return cout << "YES", 0;
        cout << "NO";
    }
    else{
        reverse(temp.begin(), temp.end());
        if(temp == s[0])
            return cout << "YES", 0;
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
def cond(n):
    L=(0,-1)
    for i in range(1,N):
        if a[i]>=n and a[i-1]>=n:
            L=(i,1)
        elif a[i]<n and a[i-1]<n:
            L=(i,0)

    R=(2*N-1,-1)
    for i in range(2*N-3,N-2,-1):
        if a[i]>=n and a[i+1]>=n:
            R=(i,1)
        elif a[i]<n and a[i+1]<n:
            R=(i,0)

    if L[1]==-1 and R[1]==-1:
        return a[0]>=n
    elif L[1]==-1:
        return R[1]==1
    elif R[1]==-1:
        return L[1]==1
    elif L[1]==R[1]:
        return R[1]==1
    else:
        if L[1]==0:
            return N-1-L[0]>R[0]-(N-1)
        else:
            return N-1-L[0]<R[0]-(N-1)


start=1
end=2*N-1
while end-start>1:
    test=(end+start)//2
    if cond(test):
        start=test
    else:
        end=test
if cond(end):
    print(end)
else:
    print(start)

Measured memory_bytes: 92140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    vi v;
    REP(i, 1, 1e3) {
        v.push_back(i*(i+1)*(i+2)/6);
        if(v.back() > 1e6) break;
    }
    vl dp1(1e6+10, INF), dp2(1e6+10, INF);
    dp1[0] = 0;
    dp2[0] = 0;
    for(auto&& x : v) {
        for(int i = 0; i+ x < dp1.size(); ++i) {
            chmin(dp1[i+x], dp1[i]+1);
            if(x&1LL) chmin(dp2[i+x], dp2[i]+1);
        }
    }
    int n;
    while(cin >> n && n) {
        cout << dp1[n] << " " << dp2[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 18280
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str = reader.readLine();
		int N = Integer.parseInt(str);
		String[] str_ary = reader.readLine().split("");
		int[] S = new int[N];
		for (int i = 0; i < N; i++) {
			S[i] = Integer.parseInt(str_ary[i]);
		}
		int ans = 0;
		for (int k = 0; k <= 999; k++) {
			int k1 = k / 100;
			int k2 = (k - k1*100) / 10;
			int k3 = k % 10;
			boolean flag1 = false;
			boolean flag2 = false;
			boolean flag3 = false;
			int keep1 = -1;
			int keep2 = -1;
			int keep3 = -1;
			for (int i = 0; i < N; i++) {
				if (S[i] == k1) {
					flag1 = true;
					keep1 = i;
					break;
				}
			}
			if (flag1) {
				for (int i = keep1+1; i < N; i++) {
					if (S[i] == k2) {
						flag2 = true;
						keep2 = i;
						break;
					}
				}
			}
			if (flag1 && flag2) {
				for (int i = keep2+1; i < N; i++) {
					if (S[i] == k3) {
						flag3 = true;
						keep3 = i;
						ans++;
						break;
					}
				}
			}
		}
		System.out.println(ans);
		
		
		//		int ans = N * (N-1) * (N-2) / 6;
		//		int[] kosuu = new int[9];
		//		for (int i = 0; i < N-2; i++) {
		//			for (int k = 1; k <= 9; k++) {
		//				if (S[i] == k) {
		//					kosuu[k]++;
		//				}
		//			}
		//		}
		
		
		
		//		int keep = 2;     //2, 1, 0とずらしていく
		//		for (int i = 0; i < N-2; i++) {
		//			for (int k = 0; k < i; k++) {
		//				if (S[i] == S[k]) {
		//					
		//				}
		//				
		//			}
		//		}
		
	}
}


Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    ll res = n/2-!(n%2);
    cout << res << endl;
}

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

using namespace std;

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

constexpr int N = 4000100;
constexpr int P = 1e9 + 7;
ll qpow(ll a, ll b) {
    ll ans = 1;
    for( ;b; b >>= 1, a = a * a % P) if(b & 1) ans = ans * a % P;
    return ans;
}

ll n, k, a[N];
ll dp[N], fc[N], inv[N];
ll C(ll n, ll m) {
    if(m > n || m < 0 || n < 0) return 0;
    return (fc[n] * inv[m]) % P * inv[n-m] % P;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    
    fc[0] = 1;
    rep(i, 1, n) fc[i] = (ll)fc[i - 1] * i % P;
    inv[n] = qpow(fc[n], P-2);
    per(i, n-1, 0) inv[i] = (ll)inv[i+1] * (i + 1) % P;

    rep(i, 0, n) {
        a[i] = C(n,i) * C(n-1,n-i-1) % P;
        // cout << i << ": " << a[i] << endl;
    }

    if(k > n) k = n;

    dp[0] = 1;
    dp[1] = a[1];
    dp[2] = a[0] + a[1] + a[2]; dp[2] %= P;
    dp[3] = ((a[0] + a[1])%P + (a[2] + a[3])%P)%P;
    rep(i, 4, k) {
        dp[i] = dp[i-1] + a[i];
        dp[i] %= P;
    }
    cout << dp[k] << "\n";
}

// k > n => k = n
// a[0] =1
// 1 1 1 1
// a[1] = C(4,1) * 3 C(4-1,4-1-1)=C(3,2)
// 0 2 1 1
// a[2] = C(4,2) * 3 C(4-1,4-2-1)
// 0 0 1 1
// C(n-1,n-i-1)
// 1 1 1 1
// 0 2 1 1
// 0 1 2 1
// 0 2 1 1
// 0 1 2 1



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

int f(int a, int b){
    int res = 1;
    for (int i = 0; i < b; i++){
	res *= a;
    }

    return res;
}

int main(){
    int x;
    cin >> x;

    int res = 1;
    for (int i = 2; i*i <= x; i++){
	int p = 2;
	while (f(i, p) <= x){
	    p++;
	}
	res = max(res, f(i, p-1));
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int k,a,b;
    while(cin>>k>>a>>b){
        int x=a/k;
        int y=b/k;
        int flag=0;
        for(int i=x;i<=y;i++){
            if(k*i>=a&&k*i<=b){
                cout<<"OK"<<endl;
                flag=1;
                break;
            }
        }
        if(!flag)cout<<"NG"<<endl;
    }
    return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll ans = 1;

void solve(int cur, int par, vector< vector<int> >& g, int K) {
    ll hoge = K - 1 - (par != -1);
    for (int nex : g[cur]) {
        if (par == nex) continue;
        (ans *= hoge) %= MOD;
        if (hoge == 0) break;
        solve(nex, cur, g, K);
        hoge--;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;
    vector< vector<int> > g(n);
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    solve(0, -1, g, K);
    cout << ans * K % MOD << endl;
    return 0;
}

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

int main()
{
	int n;
	string str;
	set<string> dic;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> str;
		if (str == "insert") {
			cin >> str;
			dic.insert(str);
		}
		else if (str == "find") {
			cin >> str;
			cout << (dic.find(str) != dic.end() ? "yes" : "no") << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 32588
n = int(input())
ans = 0
d = 2

while d*d <= n:
    if n%d != 0:
        d += 1
        continue
    
    z = d
#     print('z: {}'.format(z))

    while n%z == 0:
        n /= z
        z *= d
#         print('z: {}'.format(z))
        ans += 1
    
    while n%d == 0:
        n /= d

if n != 1:
    ans += 1
        
print(ans)

Measured memory_bytes: 9120
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val d = sc.nextInt()
    val c = Array(26) { sc.nextInt() }
    val s = Array(d) { Array(26) { sc.nextInt() } }
    val last = Array(26) { -1 }
    var score = 0L
    for (i in 0 until d) {
        val arr = Array(26) { 0 }
        for (t in 0 until 26) {
            arr[t] += s[i][t]
            for (j in 0 until 26) {
                if (j == t) continue
                arr[t] -= c[j] * (i - last[j])
            }
        }
        val max = arr.max()!!
        if (d % 50 == 0) {
            val rnd = Random()
            val r = rnd.nextInt(26)
            arr[r] = max
        }
        for (t in 0 until 26) {
            if (arr[t] == max) {
                println(t + 1)
                last[t] = i
                break
            }
        }
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

int main() {
 vector<int>vec(5);
  
  for(int i = 0; i<5; i++){
  cin >> vec.at(i);
  }
    for(int i = 0; i<5; i++){
    if(vec.at(i)==0){
    cout << i+1 << endl;
    }
    }
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D) {
  	cout << "Left" << endl;
  }
  else if (A+B == C+D) {
  	cout << "Balanced" << endl;
  }
  else {
  	cout << "Right" << endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<ll,ll> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi;

    int main(){
        
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    // #endif  

        fast; 
        int n,ans=0;
        cin>>n;
        int a[n],b[n];
        string s,s1,s2;
        rep(i,0,n) s+=(i+1+'0');
        rep(i,0,n) {
            cin>>a[i];
            s1+=a[i]+'0';
        }
        rep(i,0,n) {
            cin>>b[i];
            s2+=b[i]+'0';
        }
        string temp=s; 
        int j=0,k=0;
        do{
            k++;
            if(s1==temp) break;
        }
        while(next_permutation(all(temp)));
        do{
            j++;
            if(s2==s) break;
        }
        while(next_permutation(all(s)));
        cout<<abs(j-k);
        return 0;  
    }   
 
 
    //keep it simple stupid


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

int main(){
    int K, N; cin >> N >> K;
    vector<Int> H(N);
    rep(i, N) cin >> H[i];

    sort(H.begin(), H.begin()+N);

    Int ans = 1e10;
    rep(i, N-K+1){
        ans = min(ans, H[i+K-1] - H[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5 + 11;
int n, k, pos[N], head[N], nex[N<<1], to[N<<1], du[N], size;
int tree[N<<2];
int ans[N];
priority_queue<int, vector<int>, greater<int> >q;
int query(int p, int l, int r, int x, int y){
    if(l > y || r < x)return tree[0];
    if(l >= x && r <= y){
        return tree[p];
    }
    int mid = (l + r) >> 1, ls = p << 1, rs = ls | 1;
    return min(query(ls, l, mid, x, y), query(rs, mid + 1, r, x, y));
}
void gai(int p, int l, int r, int x, int v){
    if(l > x || r < x)return ;
    if(l == r && l == x){
       // printf("p=%d l=%d r=%d x=%d v=%d\n", p, l, r, x, v);
        tree[p] = v;
        return ;
    }
    int mid = (l + r) >> 1, ls = p << 1, rs = ls | 1;
    gai(ls, l, mid, x, v);
    gai(rs, mid + 1, r, x, v);
    tree[p] = min(tree[ls], tree[rs]);
    //printf("p=%d l=%d r=%d x=%d v=%d tree=%d\n", p, l, r, x, v, tree[p]);
}
void add(int x, int y){
    //printf("x=%d y=%d\n", x, y);
    nex[++size] = head[x];
    to[size] = y;
    head[x] = size;
    du[y]++;
}
int main(){
    cin>>n>>k;
    int x;
    for(int i = 1;i <= n; i++){
        scanf("%d", &x);
        pos[x] = i;
    }
    //for(int i = 1;i <= n; i++){
    //    printf("%d ", pos[i]);
    //}
    //puts("");
    memset(tree, 127 / 9, sizeof(tree));
    for(int i = n;i >= 1; i--){
        int up = query(1, 1, n, pos[i], min(n, pos[i] + k - 1));
        int down = query(1, 1, n, max(1, pos[i] - k + 1), pos[i]);
        if(up <= n)add(pos[i], pos[up]);
        if(down <= n)add(pos[i], pos[down]);
        gai(1, 1, n, pos[i], i);
        //printf("i=%d up=%d down=%d\n", i, up, down);
    }
    for(int i = 1;i <= n; i++){
        if(!du[i]){
            q.push(i);
          //  printf("i=%d pos[i]=%d\n", i, pos[i]);
        }
    }
    int now;
    for(int i = 1;i <= n; i++){
        now = ans[i] = q.top();
        q.pop();
        //printf("i=%d q.size=%d now=%d\n", i, q.size(), now);
        for(int j = head[now];j;j = nex[j]){
            du[to[j]]--;
            if(!du[to[j]]){
                q.push(to[j]);
        //        printf("i=%d v=%d\n", i, to[j]);
            }
        }
        //printf("i=%d now=%d\n", i, now);
    }
    for(int i = 1;i <= n; i++){
        pos[ans[i]] = i;
    }
    for(int i = 1;i <= n; i++){
        printf("%d\n", pos[i]);
    }
    return 0;
}

Measured memory_bytes: 27764
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    ll n, k; cin>>n>>k;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    ll ans = 0;
    for(int i=0; i<n; i++){
        ll cnt = 0, rcnt = 0;
        for(int j=0; j<n; j++){
            if(a[j] < a[i]) cnt++;
            if(i < j && a[i] > a[j]) rcnt++;
        }

        ans += (k * rcnt) + ((k * (k - 1) / 2) % MOD) * cnt % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<utility>
#include<functional>
#include<vector>
#include<cstdio>
#include<string>
#include<map>
using namespace std;
int main(void) {
	int a[3];
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	sort(a, a + 3);
	int c = (a[2] * 10) + a[1] + a[0];
	printf("%d\n", c);
}

Measured memory_bytes: 256