akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
  int N,M,A,i;
  scanf("%d",&N);
  scanf("%d",&M);
  for(i=0;i<M;i++){
    scanf("%d",&A);
    N-=A;
  }
  if(N<-1){
    N=-1;
  }
  printf("%d",N);
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0;i<n;i++)
#define reps(i,s,n) for(long long i=s;i<n;i++)
#define vec vector
#define inf (1LL<<60)
using namespace std;
using ll = long long;
vec<ll> h;
vec<ll> dp;

ll cost(ll n) {
	if (n == 0) return 0;
	if (n < 0) return inf;
	if (dp[n] != inf ) return dp[n];
	return dp[n] = min(cost(n - 1) + abs(h[n] - h[n - 1]), cost(n - 2) + abs(h[n] - h[n - 2]));
}

int main(void) {
	ll n;
	cin >> n;
	h = vec<ll>(n);
	dp = vec<ll>(n, inf);
	rep(i, n) cin >> h[i];
	cout << cost(n - 1) << endl;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	vl v(100000, 0);
	ll cnt = 0;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		v[a - 1] += b;
	}
	REP(i, v.size()) {
		cnt += v[i];
		if (cnt >= k) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, P> T;

const ll mod = 1000000007;
const ll INF = 1000000100;

ll N;
ll a[100010];
vector<ll> vec;

ll ans;

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

void init()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		vec.push_back(a[i]);
	}
}

void output()
{
	cout << ans << endl;
}

bool kiwosorasetai()
{
	ll sum[100010];
	for (int i = 0; i <= N; i++)
	{
		sum[i] = 0;
	}
	for (int i = 0; i < N; i++)
	{
		if (i)
		{
			sum[i + 1] = sum[i] - 1;
		}
		else
		{
			sum[i + 1] = sum[i] + 1;
		}
	}
	for (int i = 1; i < N; i++)
	{
		
	}
	return true;
}

void solve()
{
	sort(vec.begin(), vec.end());
	
	ll lb = -1, ub = vec.size();
	while (lb + 1 < ub)
	{
		ll mid = (lb + ub) / 2;
		
	}
}

int main()
{
	//init();

	//solve();

	ll a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22)
	{
		cout << "bust" << endl;
	}
	else
	{
		cout << "win" << endl;
	}

	//output();

	cin >> N;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,x,y;
	scanf("%d %d %d",&a,&b,&c);
	x=a+b;
	y=x-c;
	if(0<=y){
		printf("Yes\n");
	}
	else if(y<0){
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    if(n%k==0)
        cout<<"0";
    else
        cout<<"1";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e6+5,inf=1e18,mod=1e9+7;
#define test ll testcases;cin>>testcases; while(testcases--)
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))
const ld pi=3.141592653589793238;

bool check_prime(ll n)
{
	ll flag=0,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			flag=1;
			break;
		}
	}
	if(n==1)
	{
		return false;
	}
	else if(flag==0 || n==2 || n==3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

ll fastexpo(ll a,ll b,ll MOD) 
{
	ll result=1;
	while(b>0)
	{
		if(b%2==1)
		{
			result=(result*a)%MOD;
		}
		a=(a*a)%MOD;
		b=b/2;
	}
	return result;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d,c,x,y;
    ld p;
    cin>>n>>d;
    c=0;
    while(n--)
    {
    	cin>>x>>y;
    	p=x*x+y*y;
    	p=sqrt((ld)p);
    	if(p<=d)
    	{
    		c++;
    	}
    }
    cout<<c<<"\n";
	return 0;
}

Measured memory_bytes: 3700
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int e[4],i;
	for(i=0;i<4;i++)	scanf("%d",&e[i]);
	sort(e,e+4);
	if(e[0]==e[1] && e[2]==e[3])	printf("yes\n");
	else printf("no\n");
    return 0;
}


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

using namespace std;

typedef long long ll;
int main()
{
    ll n;
    cin>>n;

    ll arr[n];

    ll x=0;
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        x ^= arr[i];
    }

    for(int i=0;i<n;i++)
    {
        cout<<(x^arr[i])<<" ";
    }

    
    return 0;
}


Measured memory_bytes: 4996
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define foru(i,a,n) for(ll i=(a); i<=(n); ++i)
#define ford(i,n,a) for(ll i=(n); i>=(a); --i)
using namespace std;
const int M = 101010;
const ll inf = 1e17;
ll n, m, w[111], v[111], dp[111][M];

int main(){
	//freopen("a.in","r",stdin);
	cin >>n >>m;
	foru(i,1,n) cin >>w[i] >>v[i];

	memset(dp,0,sizeof(dp));
	foru(i,1,n) foru(j,1,m){
		if(j < w[i])
			dp[i][j] = dp[i-1][j];
		else
			dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
	}
	cout <<dp[n][m];
	return 0;
}


Measured memory_bytes: 87808
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
#define mod 1000000007
#define mod2 998244353
#define double long double
#define pb push_back
#define swap(x,y) (x^=y^=x^=y)
#define TC int TESTCASE;cin>>TESTCASE;while(TESTCASE--)
#define oo 1500000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
using namespace std;
 
int modexpo(int x,int p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
 
int max(int a,int b){return (a>b?a:b);}
 
int min(int a,int b){return (a<b?a:b);}
 
struct edge{int u,v,w;edge(int a,int b,int c){u=a;v=b;w=c;}};
 
struct compare{
    bool operator() (const edge a, const edge b) const{
        if(a.u == b.u){
            if(a.v == b.v){
                return a.w < b.w;
            }
            return a.v < b.v;
        }
        return a.u < b.u;
    }
};

int32_t main(){
    IOS
    int a,b;
    cin >> a >> b;
    int lcm = a*b;
    lcm /= __gcd(a,b);
    cout<<lcm<<endl;
} 

Measured memory_bytes: 3656
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {   //引数は挿入する値
    Node *y = NIL;    //xの親
    Node *x = root;   //Tの根
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));   //追加する値の定義。与えられた順番に追加していくので、左右の子は存在しない
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while ( x != NIL ) {   //xがNILにたどり着いた時終了、その時のyがzの親となる
        y = x;   //親の設定(=root)、zの親の候補として1つ前の節点yを保持
        if ( z->key < x->key ) {   //x->keyにはrootの値が保持
            x = x->left;   //左の子へ移動
        } else {
            x = x->right;   //右の子へ移動
        }
    }
    
    z->parent = y;
    if ( y == NIL ) {   //Tが空の場合、最初に挿入した値を根とする
        root = z;
    } else {
        if ( z->key < y->key ) {
            y->left = z;   //zをyの左の子にする
        } else {
            y->right = z;   //zをyの右の子にする 
        }
    }
}

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;
    string com;
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ) {
        cin >> com;
        if ( com == "insert" ) {
            scanf("%d", &x);
            insert(x);
        } else if ( com == "print" ) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}


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

//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

int T;

const int mod = 1e9 + 7;
const int N = 2e5 + 10;

int n, k;
int a[N];

bool check(LL x)
{
    LL cut = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] % x == 0)
            cut += a[i] / x - 1;
        else
            cut += a[i] / x;
    }
    if (cut <= k) return true;
    return false;
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (cin >> n >> k)
    {
        for (int i = 1; i <= n; ++i)
        {
            cin >> a[i];
        }

        LL lo = 1, hi = 1e9;
        while (lo + 1 < hi)
        {
            LL mid = (lo + hi) / 2;
            if (check(mid))
            {
                hi = mid;
            }
            else
            {
                lo = mid;
            }
        }

        LL ans;
        if (check(lo))
            ans = lo;
        else
            ans = hi;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4400
def resolve():
    # 整数 1 つ
    n = int(input())
    a = int(input())
    # 整数複数個
    # a, b, c = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    if n % 500 == 0:
        print("Yes")
    else:
        if n % 500 <= a:
            print("Yes")
        else:
            print("No")


resolve()

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

int main(){
    long long N,A,B;
    cin >> N >> A >> B;
    long long X[100000];
    for(int i=0;i<N;i++) cin >> X[i];

    long long f=0;
    
    for(int at=0;at<N-1;at++){
        if((X[at+1]-X[at])*A<B) f+=(X[at+1]-X[at])*A;
        else f+=B;
    }

    cout << f << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <limits>
#include <cassert>

#define seq(i, n) for (int i = 0; i < (n); i++)
#define seq2(i, f, t) for (int i = (f); i < (t); i++)
#define rev(i, n) for (int i = (n); i >= 0; i--)
#define rev2(i, f, t) for (int i = (f); i >= (t); i--)
#define all(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;

void solve(string s, string t) {
  for (int i = 0; i < s.length(); i++) {
    cout << s[i] << t[i];
  }
}

int main() {
  #ifdef TEST
    solve();
  #else
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;
    solve(s, t);
    cout << endl;
  #endif

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2505
#define M 5005
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
struct edge {
	int to,nxt,v;
} e[M];
vector<int>g[N];
int n,m,p,head[N],cnt[N],dis[N];
bool inq[N],mark[N];
queue<int>q;
int SPFA() {
	q.push(1),inq[1]=cnt[1]=1,dis[1]=0;
	while(!q.empty()) {
		int now=q.front();
		q.pop(),inq[now]=0;
		for(int i=head[now]; i; i=e[i].nxt) {
			int to=e[i].to,v=e[i].v;
			if(!mark[to])continue;
			if(dis[to]<dis[now]+v) {
				dis[to]=dis[now]+v;
				if(!inq[to]) {
					q.push(to),inq[to]=1;
					if(++cnt[to]>n)return -1;
				}
			}
		}
	}
	return max(0,dis[n]);
}
void init(){
	q.push(n),mark[n]=1;
	while(!q.empty()){
		int now=q.front();
		q.pop();
		for(int i=0;i<(int)g[now].size();i++){
			int to=g[now][i];
			if(mark[to])continue;
			q.push(to),mark[to]=1;
		}
	}
}
int main() {
	scanf("%d%d%d",&n,&m,&p);
	Ms(dis,-127);
	for(int i=1; i<=m; i++) {
		int s,t,v;
		scanf("%d%d%d",&s,&t,&v);
		g[t].push_back(s);
		e[i]=(edge)<%t,head[s],v-p%>;
		head[s]=i;
	}
	init();
	printf("%d\n",SPFA());
	return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import java.lang.Math.*


val MOD = 1_000_000_007L
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }

//val rd = debug.Reader("abc", "171", "d", "sample-1")
val rd = Reader()


fun solveD(N: Int, K: Long, A:Array<Int>): Int {
    var step = Array<Long>(N){-1}
    tailrec fun dfs(x: Int, sp:Long): Pair<Int, Long> {
        if (sp>=K) {
            return Pair(x, -1L);
        }

        if (step[x] >= 0L) {
            return Pair(x,sp)
        }

        step[x] = sp
        return dfs(A[x], sp + 1L)
    }

    var pos = dfs(0, 0L)
    if (pos.second < 0L) {
        return pos.first + 1;
    }

    val move = (K - step[pos.first]) % (pos.second - step[pos.first])

    tailrec fun dfs2(n: Long, x: Int): Int {
        if (n >= move) {
            return x
        }
        return dfs2(n + 1L, A[x])
    }

    return dfs2(0L, pos.first) + 1
}


fun main() {
    val (n,K) = rd.readListLong()
    val N = n.toInt()
    val a = rd.readListInt()
    var A = Array<Int>(N){0}
    for(i in 0 until N) {
        A[i] = a[i] - 1
    }

    val ans = solveD(N, K, A)

    println(ans)
}



class Main : Runnable {
    override fun run() { main() }
}
fun main(args: Array<String>) {
    Thread(null, Main(), "mainThread", 16 * 1024 * 1024).start()
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 72960
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
		    set.add(sc.nextInt());
		}
		int m = sc.nextInt();
		int count = 0;
		for (int i = 0; i < m; i++) {
		    if (set.contains(sc.nextInt())) {
		        count++;
		    }
		}
		System.out.println(count);
	}
	
}



Measured memory_bytes: 92580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int x;
  cin >> x;
  
  int a = x / 10;
  int b = x % 1000;

  if(a % 111 == 0 || b % 111 == 0 || x % 1111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}     


Measured memory_bytes: 256
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define NMAX 100000

int K = 1;
int C[NMAX+1];//child
int S[NMAX+1];//sibling
int colors[NMAX+1];

void dfs(int p, int p_color){
	for(int color=1, c=C[p]; c; c=S[c], color++){
		colors[c] = color==p_color? ++color: color;
		K = max(K, color);
		dfs(c, color);
	}
}

int main(){
	int N; cin>>N;
	int Q[N];
	rp(i, 1, N){
		int p; scanf("%d%d",&p,Q+i);
		S[Q[i]] = C[p];
		C[p] = Q[i];
	}
	dfs(1, 0);
	printf("%d\n", K);
	rp(i, 1, N) printf("%d\n", colors[Q[i]]);
}

Measured memory_bytes: 3968
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
using namespace std;
//整形Shift + alt + f　2回
//int x[101],y[101],h[101];
//int koya[100001][];
/*
//ユークリッドの互除法
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
*/
int n;
int main()
{
    cin >> n;

    if (n == 7 || n == 5 || n == 3)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] ar = new int[5];
		for(int i = 0; i < 5; i++) {
			ar[i] = stdIn.nextInt();
		}
		
		Arrays.sort(ar);
		System.out.print(ar[4]);
		for(int i = 3; i >= 0; i--) {
			System.out.print(" " + ar[i]);
		}
		System.out.println();
	}

}

Measured memory_bytes: 17336
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#define rep(i,j,k) for(register int i = j; i <= k; ++i)
#define dow(i,j,k) for(register int i = j; i >= k; --i)
#define ll long long
#define mp make_pair
#define fi first
#define se second 
#define all(x) x.begin(),x.end()
using namespace std;

inline ll read() { 
    ll s = 0, t = 1; char c = getchar();
    while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
    while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
    return s * t;
}

const int N = 2e5+10, p = 1000000007;
inline void Max(ll &x,ll v) { if( v > x ) x = v; }
inline void Min(int &x,int v) { if( x > v ) x = v; }

int n, h[N], f[N][27], tot = 0; char c[N], ans[N]; bool vis[N], g[N][27];

int main() {
	scanf("%s",c+1);
	n = strlen(c+1);
	rep(i,1,n+1) h[i] = p;
	rep(i,1,n) { 
		int x = i - 1;
		while( x >= 0 && !f[x][c[i]-'a'] ) f[x--][c[i]-'a'] = i;
	}
	rep(i,0,n) rep(j,0,25) if( !f[i][j] ) f[i][j] = n + 1;
	h[0] = 0;
	rep(i,0,n) rep(j,0,25) Min(h[f[i][j]],h[i]+1);
	vis[n+1] = 1;
	dow(i,n,0) rep(j,0,25) if( h[f[i][j]] == h[i] + 1 && vis[f[i][j]] ) g[i][j] = vis[i] = 1;
	int x = 0;
	while( x <= n ) { 
		rep(i,0,25) if( g[x][i] ) { ans[++tot] = 'a' + i, x = f[x][i]; break; }
	}
	printf("%s\n",ans+1);
    return 0;
}

Measured memory_bytes: 28032
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;

int main() {
  int x,a;
  cin>>x>>a;
  puts(x<a?"0":"10");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;

int main(){
    int n,m;
    std::cin >> n>>m;
    std::vector<int> si(n,1);
    std::vector<bool> b(n,0);
    b[0]=1;
    rep(i,m){
        int x,y;
        std::cin >> x>>y;
        x--;y--;
        si[x]--;si[y]++;
        if(b[x])b[y]=1;
        if(si[x]==0)b[x]=0;
    }
    int ans=0;
    rep(i,n){
        if(b[i])ans++;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 640
import sys
from math import sqrt
input = sys.stdin.readline
from heapq import heappop, heappush
xs, ys, xt, yt = map(int, input().split())
N = int(input())
INF = float('inf')
cost = [[INF] * (N + 2) for i in range(N + 2)]
D = [(xs, ys, 0)]
for i in range(N):
    x, y, r = map(int, input().split())
    D.append((x, y, r))
D.append((xt, yt, 0))

for i in range(N + 2):
    for j in range(i + 1, N + 2):
        k = max(0, sqrt((D[i][0] - D[j][0]) ** 2 + (D[i][1] - D[j][1]) ** 2) - D[i][2] - D[j][2])
        cost[i][j] = k
        cost[j][i] = k

visit = [0] * (N + 2)
visit[0] = 1
d = [INF] * (N + 2)
d[0] = 0
que = [(0, 0)]
while que:
    dist, v = heappop(que)
    if d[v] < dist:
        continue
    if v == N + 1:
        print(d[v])
        exit()
    visit[v] = 1
    for w in range(N + 2):
        if visit[w] == 0 and w != v and d[w] > d[v] + cost[v][w]:
            d[w] = d[v] + cost[v][w]
            heappush(que, (d[w], w))


Measured memory_bytes: 103132
import sys
n = int(input())
s = input()
l = []
for i in range(len(s)):
    l.append(s[i])

cnt = 0
for i in range(10):
    if str(i) in l:
        p = l.index(str(i))
        
        for j in range(10):
            if str(j) in l[p+1:]:
                q = l[p+1:].index(str(j))

                for k in range(10):
                    if str(k) in l[p+q+2:]:
                        cnt += 1


print(cnt)


        


    







        



Measured memory_bytes: 3700
#include<stdio.h>
#include<algorithm>

int main() {
	int p;
	int maxw, maxk;
	int max1 = 0, max2 = 0, max3 = 0;
	for (int i = 0; i < 10; ++i) {
		scanf("%d", &p);
		if (max3 < p) {
			max3 = p;
			if (max2 < max3) {
				std::swap(max2, max3);
				if (max1 < max2) {
					std::swap(max1, max2);
				}
			}
		}
	}
	maxw = max1 + max2 + max3;

	max1 = 0; max2 = 0; max3 = 0;
	for (int i = 0; i < 10; ++i) {
		scanf("%d", &p);
		if(max3 < p){
			max3 = p;
			if (max2 < max3) {
				std::swap(max2, max3);
				if (max1 < max2) {
					std::swap(max1, max2);
				}
			}
		}
	}
	maxk = max1 + max2 + max3;

	printf("%d %d\n", maxw, maxk);

	return 0;
}

Measured memory_bytes: 2576
#include <iostream>

using namespace std;

typedef long long ll;

int MOD = 1; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

ll modexp (ll a, int k, ll m) {
  if (k == 0) {
    return 1;
  } else if (k % 2 == 0) {
    ll half = modexp(a, k / 2, m);
    return (half * half) % m;
  } else {
    return (a * modexp(a, k - 1, m)) % m;
  }
}

const int MAX_N = 3e3 + 5;

Modint stirl [MAX_N][MAX_N];
Modint choose [MAX_N][MAX_N];
Modint sign [MAX_N];
Modint tpow [MAX_N * MAX_N];
Modint ttpow [MAX_N];

int main () {
  int n;
  cin >> n >> MOD;

  stirl[0][0] = 1;
  for (int i = 1; i <= n + 1; i++) {
    stirl[i][0] = 0;
    for (int j = 1; j <= n + 1; j++) {
      stirl[i][j] = Modint(j) * stirl[i - 1][j] + stirl[i - 1][j - 1];
    }
  }

  choose[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    choose[i][0] = 1;
    for (int j = 1; j <= n; j++) {
      choose[i][j] = choose[i - 1][j - 1] + choose[i - 1][j];
    }
  }

  sign[0] = 1;
  for (int i = 1; i <= n; i++) {
    sign[i] = sign[i - 1] * Modint(MOD - 1);
  }

  tpow[0] = 1;
  for (int i = 1; i <= n * n; i++) {
    tpow[i] = Modint(2) * tpow[i - 1];
  }

  for (int i = 0; i <= n; i++) {
    ttpow[i] = exp(Modint(2), modexp(2, i, MOD - 1));
  }

  Modint ans = exp(Modint(2), modexp(2, n, MOD - 1));
  for (int k = 1; k <= n; k++) {
    // calculate the # of ways such that the
    // numbers 1..k only appear in one or zero of
    // the given sets

    Modint ways (0);
    for (int m = 0; m <= k; m++) {
      // allocate m spaces for them
      Modint cur_ways = stirl[k + 1][m + 1]; // # of surjective maybe-empty
      cur_ways *= tpow[(n - k) * m]; // ways to complete these rows
      cur_ways *= ttpow[n - k]; // ways to pick other rows
      ways += cur_ways;
    }

    ans += sign[k] * choose[n][k] * ways;
  }

  cout << ans << endl;
}


Measured memory_bytes: 211968
/*/ Author: KaySeeKay /*/

#include<bits/stdc++.h>
using namespace std;	

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    if(n>0)
    s << arr[n - 1] ;
    s<< "]";
    return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __trace_out_var(a);
    cerr << "; ";
    __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int vis[N];
vector<int>v[N];
void dfs(int s){
	vis[s]=1;
	for(auto i :v[s])if(!vis[i])dfs(i);
}
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n , m;
		cin >> n >> m ;
		fm{
			int x,y;
			cin >>x>>y;
			v[x].pb(y);
			v[y].pb(x);
		}
		int ans =0;
		fn1{
			if(!vis[i])dfs(i),ans++;
		}
		cout << ans-1;
		
	
	}
	return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int k,x;cin>>k>>x&&k|x;){
		int l=x-(k-1),r=x+(k-1);
		for(int i=l;i<=r;i++)
			cout<<i<<"\n "[i<r];
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
  int n;
  while(cin>>n){
    if(n==-1) break;
    double x = 1, y = 0;
    for(int i=1; i<n; i++){
      double rad = atan2(y,x) + M_PI/2;
      x += cos(rad);
      y += sin(rad);
    }
    printf("%.2f\n%.2f\n",x,y);
  }
  return 0;
}


Measured memory_bytes: 3576
#define DEBUG 1
#include <bits/stdc++.h>
using namespace std;
typedef          char      s8;
typedef unsigned char      u8;
typedef          short    s16;
typedef unsigned short    u16;
typedef          int      s32;
typedef unsigned int      u32;
typedef          long int s64;
typedef unsigned long int u64;
typedef float             f32;
typedef double            f64;
#define rep(_i, _n) for (int _i = 0; _i < (int)(_n); _i++)
#if DEBUG
#define PHERE()			{ cerr << "L" << setw(3) << __LINE__ << ": PHERE" << clock() << endl; }
#define PVAL( _var )	{ cerr << "L" << setw(3) << __LINE__ << ":" << #_var "=" << (_var) << endl; }
#else
#define PHERE()
#define PVAL( _var )
#endif


int main()
{
	//////// 入力 ////////
	int N;
	cin >> N;
	
	unordered_map<string, int> sum;
	sum.insert( pair( "AC" , 0 ) );
	sum.insert( pair( "WA" , 0 ) );
	sum.insert( pair( "TLE", 0 ) );
	sum.insert( pair( "RE" , 0 ) );
	rep( i, N ) {
		string out;
		cin >> out;
		sum[out] += 1;
	}
	/////////////////////
	
	//////// 出力 ///////
	cout << "AC x "		<< sum.at("AC" ) << endl;
	cout << "WA x "		<< sum.at("WA" ) << endl;
	cout << "TLE x "	<< sum.at("TLE") << endl;
	cout << "RE x "		<< sum.at("RE" ) << endl;
	/////////////////////
	
	return 0;
}
#if 0
AC x 3
WA x 1
TLE x 2
RE x 0
#endif


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

int n,m[100][100];

int prim();

int main(){
  cin>>n;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>m[i][j];
      if(m[i][j]==-1)m[i][j]=200002;
    }
  }

  cout<<prim()<<endl;

}

int prim(){
  int u,mn;
  int d[100],p[100],ck[100];
  
  for(int i=0;i<n;i++){
    d[i]=200002;
    p[i]=-1;
    ck[i]=0;
  }

  d[0]=0;

  while(1){
    mn=200002;
    u=-1;
    for(int i=0;i<n;i++){
      if(mn>d[i] && ck[i]!=2){
	u=i;
	mn=d[i];
      }
    }
    if(u==-1)break;
    ck[u]=2;
    for(int i=0;i<n;i++){
      if(ck[i]!=2 && m[u][i]!=200002){
	if(d[i]>m[u][i]){
	  d[i]=m[u][i];
	  p[i]=u;
	  ck[i]=1;
	}
      }
    }
  }
  int sum=0;
  for(int i=0;i<n;i++){
    if(p[i]!=-1)sum+=m[i][p[i]];
  }
  return(sum);
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int primax = 50000;
		int[] pri = new int[primax+10000];
		for(int i=2;i<=primax;i++) pri[i] = i;
		for(int i=2;i<=primax+1;i++){
			for(int j=i+i;j<=primax;j+=i){
					pri[j]=0;
			}
		}
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int count = 0;
			for(int i=0;i<n/2;i++){
				if(pri[i]>0 && pri[n-i]>0) count++;
			}
			if(n%2==0 && pri[n/2]>0) count++;
			System.out.println(count);
		}	
	}	
}

Measured memory_bytes: 20396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n,a,b; cin>>n>>a>>b;
  ll x = a+b;
  cout << n/x*a + min(n%x, a) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
 
  int A[100000],n,i,j,r,p,q,x,stac;
   
 scanf("%d",&n);
 for(i=1;i<=n;i++){
   scanf("%d",&A[i]);
 }
 p=1;
 r=n;
 x=A[r];
 i=p-1;
 for(j=p;j<=r-1;j++){
   if(A[j]<=x){
     i=i+1;
   stac=A[i];
   A[i]=A[j];
   A[j]=stac;
   }
 }
 stac=A[i+1];
 A[i+1]=A[r];
 A[r]=stac;
 q=i+1;
 for(i=1;i<=n;i++){
   if(i>1){
     printf(" ");
   }
   if(q==i)
     printf("[%d]",A[i]);
   else
   printf("%d",A[i]);
 }
 printf("\n");
 return 0;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int64_t> A(N);
  for(int i=0;i<N;++i) cin>>A[i];

  int64_t ans=1e10;
  
  for(int i=0;i+(K-1)<N;++i){
    if(A[i]>=0) ans = min(ans,A[i+K-1]);
    else if(A[i+K-1]<=0) ans = min(ans,-A[i]);
    else ans = min(ans,min(-2*A[i]+A[i+K-1],2*A[i+K-1]-A[i]));
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 1152
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/29 12:33:50 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	ll	n, p;
	cin >> n >> p;

	if (n == 1)
	{
		cout << p << endl;
		return ;
	}
	ll	ans;
	ans = 1;
	ll	end;
	end = sqrt(p);
	for (ll	i = 2; i <= end; i++)
	{
		ll	cnt;
		cnt = 0;
		while (p % i == 0)
		{
			p /= i;
			cnt++;
			if (cnt == n)
			{
				cnt = 0;
				ans *= i;
			}
		}
	}
	cout << ans << endl;
}
// END

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


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

int main(){
   int n, c=0;
   cin>>n;
   int a[n];
   for(int i=0; i<n; i++) cin>>a[i];
   //sort(a, a+n);
   //set<vector<int>> st;
   //vector<int> tmp;
   for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++)
        for(int k=j+1; k<n; k++)
        if(a[i]!=a[k] && a[j]!=a[k] && a[j]!=a[i] && a[i]+a[j]>a[k] && a[k]+a[j]>a[i] && a[i]+a[k]>a[j] ) c++;
   }
   cout<<c;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<string> VecS(N);
    rep(n,0,N) cin>>VecS.at(n);

    map<string,int> mp;
    for(auto s:VecS) mp[s]++;

    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}

Measured memory_bytes: 6372
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> to[100010];
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> prev(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(int u: to[v]){
            if(dist[u] != INF) 
                continue;
            dist[u] = dist[v] + 1;
            prev[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;
    rep(i, n){
        if(i == 0) continue;
        int ans = prev [i];
        ++ans;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

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

	ll n, m;
	cin >> n >> m;

	ll ans = 0;
	if(n > 0) ans += n * (n - 1) / 2;
	if(m > 0) ans += m * (m - 1) / 2;

	cout << ans << endl;
}


Measured memory_bytes: 256
s = input()

if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
#include<stdio.h>
	int linearSearch(int);
	int n,q;
    int A[10000],T[10000];

int main(){
	int i,count=0;

	scanf("%d",&n);

	for(i=0 ; i<n ; i++){
		scanf("%d",&A[i]);
	}

	scanf("%d",&q);

	for(i=0 ; i<q ; i++){
		scanf("%d",&T[i]);
	}

	for(i=0 ; i<q ; i++){
		count += linearSearch(T[i]);
	}

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

	return 0;
}

int linearSearch(int x){
	int i;
	for(i=0 ; i<n ; i++){
		if(A[i]==x)return 1;
	}

	return 0;
}

Measured memory_bytes: 644
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){

	long long int number,ans,table[37],work,tmp;
	int base;
	char exp[13];

	while(true){
		scanf("%d %s",&base,exp);
		if(base == 0 && exp[0] == '0')break;

		for(int i = 0; i <= base; i++)table[i] = 0;

		work = base;
		for(int i = 2; i <= base; i++){
			while(work%i == 0){
				table[i]++;
				work /= i;
			}
		}

		number = 0;

		for(int i = 0; exp[i] != '\0'; i++){
			if(exp[i] >= '0' && exp[i] <= '9'){
				number = base*number + (exp[i] - '0');
			}else{
				number = base*number + (10+(exp[i] - 'A'));
			}
		}

		ans = 9223372036854775807;
		for(int i = 2; i <= base; i++){
			if(table[i] > 0){
				work = 0;
				tmp = number;
				while(tmp > 0){
					work += tmp/i;
					tmp /= i;
				}
				work /= table[i];
				ans = min(ans,work);
			}
		}

		printf("%lld\n",ans);
	}
    return 0;
}

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

using namespace std;

struct Point{
    double x,y;

    Point(){}
    Point(double x,double y) : x(x),y(y) {}

    Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
    Point operator * (const double &k)const{ return Point(x*k,y*k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double norm(const Point &p){ return dot(p,p); }

struct Segment{
    Point s,t;
    Segment(){}
    Segment(Point s,Point t) : s(s),t(t) {}
};

typedef Point Vector;

Point projection(const Segment &s,const Point &p){
    Vector b = s.t-s.s;
    double t = dot(p-s.s,b)/norm(b);
    return s.s+b*t;
}

int main(){
    int Q;
    Point p;
    Segment s;
    cin >> s.s.x >> s.s.y >> s.t.x >> s.t.y;
    cin >> Q;
    while(Q--){
        cin >> p.x >> p.y;
        Point q = projection(s,p);
        printf("%.12f %.12f\n",q.x,q.y);
    }
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);


 char A;
  cin>>A;
  int B=(int)A;
 // cout<<B;
  if(B>=65&&B<=90){
    cout<<"A"<<endl;
  }else{
    cout<<"a"<<endl;
  }
  
//  cout<<A<<endl;
}



Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		long a = 0;
		string ans = "No";
		while(true){
			if(N%7==0){
				ans = "Yes";
				break;
			}
			if(N<0){
				break;
			}
			N -= 4;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
N = gets.to_i
S = gets.chomp

max = 0
for i in 0..(N - 1) do
  l = S[0..i]
  r = S[(i+1)..(N-1)]

  count = 0
  'a'.upto('z') do |a|
    count += 1 if l.index(a) && r.index(a)
  end
  max = [max, count].max
end

puts max


Measured memory_bytes: 3836
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/27 15:57:15 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	int	n;
	cin >> n;

	vector<int>	V(n);
	rep(i, n)
		cin >> V.at(i);
	int	sum;
	sum = accumulate(V.begin(), V.end(), 0);
	int avg;
	if (sum > 0)
		avg = (sum + n / 2) / n;
	else
		avg = (sum - n / 2) / n;
	ll	ans;
	ans = 0;
	rep(i, n)
		ans += pow(avg - V.at(i), 2);
	cout << ans << endl;
}
// END

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


Measured memory_bytes: 256