akhauriyash/Code-Regression huggingface dataset:
#include<queue>
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
inline int bits(int m) { return (1<<m)-1; }
using Double = double;
const Double INF = 1e100;

int N;
LL X[15], Y[15], A[15];

Double D[15][15];
Double cst[1<<15];
Double sum[1<<15];
bool dp[1<<15];

bool ok(Double mid) {
    Double need = 0;
    Double rest = 0;
    REP (i, N) {
	if (A[i] < mid) { need += mid - A[i]; }
	else { rest += A[i] - mid; }
    }
    if (need == 0) return true;
    if (rest < need) return false;

    REP (s, 1<<N) if (s) {
	REP (i, N) if (s>>i&1) {
	    sum[s] = sum[s^(1<<i)] + A[i];
	    break;
	}
    }

    memset(dp, 0, sizeof dp);
    dp[0] = true;
    REP (s, 1<<N) if (dp[s]) {
	int other = bits(N) ^ s;
	int sup = other & (other-1);
	int small = sup ^ other;
	for (int t=sup; ; t=(t-1)&sup) {
	    if (sum[t|small] - __builtin_popcount(t|small) * mid - cst[t|small] >= 0) dp[s|t|small] = true;
	    if (t == 0) break;
	}
    }

    return dp[bits(N)];
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%lld%lld%lld", X+i, Y+i, A+i);

    REP (t, N) REP (i, N-1) if (A[i] > A[i+1]) {
	swap(X[i], X[i+1]);
	swap(Y[i], Y[i+1]);
	swap(A[i], A[i+1]);
    }

    REP (i, N) REP (j, N) D[i][j] = hypot((Double)X[i]-X[j], (Double)Y[i]-Y[j]);
    REP (s, 1<<N) cst[s] = INF;
    REP (s, 1<<N) {
	if (__builtin_popcount(s) <= 1) cst[s] = 0;
	REP (i, N) if (s>>i&1) REP (j, N) if (~s>>j&1) amin(cst[s|1<<j], cst[s] + D[i][j]);
    }
    
    Double lo = *min_element(A, A+N), hi = *max_element(A, A+N);
    REP (t, 60) {
	Double mid = (lo + hi) / 2;
	(ok(mid)? lo: hi) = mid;
    }
    double ans = (lo + hi) / 2;
    printf("%.12f\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 768
import bisect
from collections import deque


n = int(input())
lines = deque()
for _ in range(n):
    a = int(input())

    index = bisect.bisect_left(lines, a)
    if index == 0:
        lines.appendleft(a)
        continue
    
    lines[index - 1] = a

print(len(lines))


Measured memory_bytes: 7284
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

void dfs(int v, Graph& g, vector<bool>& visited, set<int>& path) {
  visited[v] = true;
  path.insert(v);
  for (int nv : g[v]) {
    if (!visited[nv]) {
      dfs(nv, g, visited, path);
    }
  }
}

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

  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
    p[i] -= 1;
  }

  Graph g(n);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  int ans = 0;
  vector<bool> visited(n);
  for (int i = 0; i < n; ++i) {
    if (visited[i]) {
      continue;
    }
    set<int> path;
    dfs(i, g, visited, path);
    for (int x : path) {
      if (path.find(p[x]) != path.end()) {
        ans += 1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 18564
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
long long int MOD = 1000000007;
/*
cin >> n;
vi a(n);
rep(i,n)cin>>a[i];
*/
int n;
bool used[350];
int main(){
	string str;
	cin>>str;
	int cnt[30]={0};
	for(int i=0;i<str.size();i++){
		cnt[str[i]-'a']++;
	}
	int ma=0;
	for(int i=0;i<30;i++){
		ma=max(ma,cnt[i]);
	}
	//cout<<ma<<endl;
	int n=str.size();
	if(ma>(n+2)/3){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")



void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

/*階乗 a!*/
ll factorial(ll a){return a==1?a:a*factorial(a-1);}
/*順列の辞書順の番号*/
ll permutation(ll n, ll a[n]){
    ll ans=0;
    rep(i,0,n-1){
        ll c=0;
        rep(j,i+1,n) if(a[i]>a[j]) c++;
        ans+=c*factorial(n-i-1);
    }
    return ans;
}

int main(void){
    // char ;
    ll n;
    scanf("%lld",&n);
    ll p[n],q[n];
    rep(i,0,n){
        scanf("%lld",&p[i]);
    }
    rep(i,0,n){
        scanf("%lld",&q[i]);
    }
    printf("%lld\n",ABS(permutation(n,p)-permutation(n,q)));
    return 0;
}


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

int main(){
  int n=0;
  cin>>n;
  for(int i=0;i<n;i++){
    ll x;
    cin>>x;
    if(x%2==1){
      cout<<"first"<<endl;
      return 0;
    }
  }
  cout<<"second"<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

const int MAX_N = 1e5 + 5;

ll red [MAX_N];
ll green [MAX_N];
ll star [MAX_N];

int main () {
  ios::sync_with_stdio(false);
  
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;

  for (int i = 0; i < a; i++) {
    cin >> red[i];
  }
  for (int i = 0; i < b; i++) {
    cin >> green[i];
  }
  for (int i = 0; i < c; i++) {
    cin >> star[i];
  }

  sort(red, red + a, greater<ll>());
  sort(green, green + b, greater<ll>());
  sort(star, star + c, greater<ll>());

  ll ans = 0;
  vector<int> worst;
  for (int i = 0; i < x; i++) {
    ans += red[i];
    worst.push_back(red[i]);
  }
  for (int i = 0; i < y; i++) {
    ans += green[i];
    worst.push_back(green[i]);
  }

  sort(worst.begin(), worst.end(), greater<ll>());
  
  for (int i = 0; i < c; i++) {
    if (star[i] > worst.back()) {
      ans -= worst.back();
      worst.pop_back();
      ans += star[i];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3704
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int tmp;
		int pastaMin = Integer.MAX_VALUE;
		
		for(int i = 0; i < 3; i++) {
			tmp = sc.nextInt();
			
			if(pastaMin > tmp) {
				pastaMin = tmp;
			}
		}
		
		int juiceMin = Integer.MAX_VALUE;
		
		for(int i = 0; i < 2; i++) {
			tmp = sc.nextInt();
			
			if(juiceMin > tmp) {
				juiceMin = tmp;
			}
		}
		
		System.out.println(pastaMin + juiceMin - 50);
	}
}

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


long int max(long int a,long int b,long int c)
{
    long int max=a;
    if(max<b) max =b;
    if(max<c) max =c;
    return max;}

int main()
{
    long int H,W;
    cin >> H>>W;
    
    long int s[W];
    long int t[H];
    
    
    for (long int i=1;i<W;i++)
    {   long int A = H*i;
        long int x1 = (W-i)/2;
        long int x2 = H/2;
        long int C1 = H*x1;
        long int C2 = (W-i)*x2;
        long int S1 =max(abs(A-C1),abs(A-(H*W-A-C1)),abs(C1-(H*W-A-C1)));
        long int S2 =max(abs(A-C2),abs(A-(H*W-A-C2)),abs(C2-(H*W-A-C2)));
        s[i] = (S1< S2 ? S1:S2);
    }
    
    for (long int i=1;i<H;i++)
    {   long int A = W*i;
        long int x1 = (H-i)/2;
        long int x2 = W/2;
        long int C1 = W*x1;
        long int C2 = (H-i)*x2;
        long int S1 =max(abs(A-C1),abs(A-(H*W-A-C1)),abs(C1-(H*W-A-C1)));
        long int S2 =max(abs(A-C2),abs(A-(H*W-A-C2)),abs(C2-(H*W-A-C2)));
        t[i] = (S1< S2 ? S1:S2);}
    
    
    long int m1=s[1];
    for (long int i=2;i<W;i++){
        if (m1>s[i]) m1=s[i];}
    
    long int m2=t[1];
    for (long int i=2;i<H;i++){
        if (m2>t[i]) m2=t[i];}
    
    cout << (m1 < m2 ? m1:m2);
}





Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
    Scanner cin = new Scanner();
	  while (true)
	  {
	    int n = cin.nextInt(), m = cin.nextInt();
	    if (n == 0 && m == 0)
	    {
	      break;
	    }
	    bool[,] friend = new bool[n, n];
	    for (int i = 0; i < m; i++)
	    {
	      int a = cin.nextInt() - 1, b = cin.nextInt() - 1;
	      friend[a, b] = friend[b, a] = true;
	    }
	    for (int i = 0; i < n; i++)
	    {
	      friend[i, i] = true;
	    }
	    int ans = 0;
	    for (int i = 1; i < n; i++)
	    {
	      for (int j = 1; j < n; j++)
	      {
	        if (friend[0, j] && friend[j, i])
	        {
	          ans++;
	          break;
	        }
	      }
	    }
	    Console.WriteLine(ans);
	  }
	  return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner() {
		s = new string[0];
		i = 0;
	}

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

	public int nextInt() {
		return int.Parse(next());
	}

	public long nextLong() {
		return long.Parse(next());
	}

	public double nextDouble() {
		return double.Parse(next());
	}

}

Measured memory_bytes: 18524
class Node:

    def __init__(self, _id):
        self.id = _id
        self.left = None
        self.right = None
        self.parent = None

    def add_left(self, node):
        node.parent = self
        self.left = node

    def add_right(self, node):
        node.parent = self
        self.right = node

    @property
    def parent_id(self):
        if self.parent is None:
            return -1
        else:
            return self.parent.id

    @property
    def deg(self):
        count = 0
        if self.right is not None:
            count += 1
        if self.left is not None:
            count += 1
        return count

    @property
    def sibling_id(self):
        if self.parent is None or self.parent.deg == 1:
            return -1
        else:
            if self.parent.left == self:
                return self.parent.right.id if self.parent.right is not None else -1
            else:
                return self.parent.left.id if self.parent.left is not None else -1

    @property
    def node_type(self):
        if self.parent is None:
            return 'root'
        if self.left is None and self.right is None:
            return 'leaf'
        return 'internal node'

    @property
    def height(self):
        if self.left is None:
            left = -1
        else:
            left = self.left.height
        if self.right is None:
            right = -1
        else:
            right = self.right.height
        return max(left, right) + 1

    @property
    def depth(self):
        if self.parent is None:
            return 0
        else:
            return self.parent.depth + 1

    def __eq__(self, other):
        return self.id == other.id

    def __repr__(self):
        return 'node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(
            self.id, self.parent_id, self.sibling_id, self.deg, self.depth, self.height, self.node_type)


def main():
    n = int(input())
    nodes = [Node(i) for i in range(n)]
    for _ in range(n):
        ID, left, right = map(int, input().split(' '))
        if left != -1:
            nodes[ID].add_left(nodes[left])
        if right != -1:
            nodes[ID].add_right(nodes[right])
    for node in nodes:
        print(node)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5636
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cassert>
#include<climits>
#include<algorithm>
#include<vector>
#include<deque>
#include<map>
#include<set>
#include<sstream>
#include<cstring>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

#define MAX 25000
int K,S, dp[MAX];

int main() {
  cin >> K >> S;
  dp[0] = 1;
  rep(_,3) {
    for(int i=S;i>=0;--i) {
      rep(v,K+1) {
	dp[i+v] += dp[i];
      }
    }
  }
  cout << dp[S]/8 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end(); it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int main(){
    double q;
    while(cin >> q, q!=-1){
        double x = q / 2;
        while(abs(x * x * x - q) >= 0.00001 * q){
            x = x - (x * x * x - q) / (3 * x * x);
        }
        printf("%.6lf\n", x);
    }
}

Measured memory_bytes: 1232
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 200100;
struct edges
{
	int to, next;
}edge[maxn * 2];
int point[maxn] = {0}, te = 0;
void add(int a, int b)
{
	te ++;
	edge[te].to = b;
	edge[te].next = point[a];
	point[a] = te;
}
int n;
int len = 0, far;
void dfs(int now, int p, int dis)
{
	dis ++;
	if(dis > len)
	{
		far = now;
		len = dis;
	}
	for(int e = point[now]; e; e = edge[e].next)
		if(edge[e].to != p)
			dfs(edge[e].to, now, dis);
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i < n; i ++)
	{
		int a, b;
		cin >> a >> b;
		add(a, b);
		add(b, a);
	}
	dfs(1, 0, 0);
	dfs(far, 0, 0);
	if(len % 3 == 2)
		cout << "Second" << endl;
	else
		cout << "First" << endl;
	return 0;
}

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

long long gcd(long long a, long long b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

/*  lcm (a, b) : 2整数版
    入力：整数 a, b
    出力：aとbの最小公倍数
*/
long long lcm(long long a, long long b) {
    long long d = gcd(a, b);
    return a / d * b;
}

int main() {
    long long A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << fixed << setprecision(10) << 1.0*w*h/2 << " ";
  if(w == x*2 && h == y*2) cout << 1;
  else cout << 0;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int hantei(double x1, double y1, double x2, double y2, double r1, double r2)
{
  double d = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
  double sr = (r1+r2)*(r1+r2);
  double dr = (r1-r2)*(r1-r2);
  d = sqrt(d);
  sr = sqrt(sr);
  dr = sqrt(dr);
  if(d > sr){
    return 0;
  }else if(d < sr && dr < d){
    return  1;
  }else if(dr > d){
    return (r1>r2)? 2 : -2;
  }else{ 
    return 1;
  }
}

int main(void)
{
  int n, ans;
  double xa, ya, ra, xb, yb, rb;
  
  cin >> n;
  for(int i = 0 ; i < n ; i++){
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    ans = hantei(xa, ya, xb, yb, ra, rb);
    cout << ans << endl;
  }
  return 0;
}

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, i;
    int ans = 0;
    cin>>n;
    int a[n+1];
    a[0] = 0;
    for(i=1; i<n+1; i++){
        cin>>a[i];
    }
    int b[n+1];
    if(n%2 == 0){
        for(i=(n/2)+1; i<=n; i++){
            b[i] = a[i];
            if(b[i] == 1){
                ans++;
            }
        }
        for(i=n/2; i>=1; i--){
            int k = n/i;
            int tmp = 0;
            for(int l = 2; l <= k; l++){
                tmp += b[l*i];
            }
            if(tmp%2 == a[i]){
                b[i] = 0;
            }
            else{
                b[i] = 1;
                ans++;
            }
        }
    }
    else{
        for(i=(n+1)/2; i<=n; i++){
            b[i] = a[i];
            if(b[i] == 1){
                ans++;
            }
        }
        for(i=(n+1)/2 - 1; i>=1; i--){
            int k = n/i;
            int tmp = 0;
            for(int l = 2; l <= k; l++){
                tmp += b[l*i];
            }
            if(tmp%2 == a[i]){
                b[i] = 0;
            }
            else{
                b[i] = 1;
                ans++;
            }
        }
    }

    cout<<ans<<endl;
    for(i=1; i<=n; i++){
        if(b[i] == 1){
            cout<<i<<" ";
        }
    }
    cout<<endl;

//    for(i = 1; i<=n; i++){
//       cout<<b[i]<<endl;
//    }
        return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
#include <iostream>
#define Re register int

struct Edge{
	int to,next;
}e[100005];
int cnt,head[100005];
int N,M,d[100005],vis[100005],dp[100005],ans;

template <typename T> inline void read(T &var)
{
	T x=0; int w=0; char ch=0;
	while (!isdigit(ch)) w|=ch=='-',ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	var=w?-x:x;
}
inline void AddEdge(int u,int v) {e[++cnt]=(Edge){v,head[u]},head[u]=cnt;}
void Solve(int now)
{
	if (vis[now]) return; vis[now]=1;
	for (Re i=head[now];i;i=e[i].next)
		Solve(e[i].to),dp[now]=std::max(dp[now],dp[e[i].to]+1);
}
int main(int argc, char const *argv[])
{
	read(N),read(M);
	for (Re i=1,u,v; i<=M; ++i)
		read(u),read(v),AddEdge(u,v),++d[v];
	for (Re i=1; i<=N; ++i) if (!d[i]) Solve(i);
	for (Re i=1; i<=N; ++i) ans=std::max(ans,dp[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define REP(i,n) for((int)(i)=0;(i)<(int)(n);(i)++)
#define ll long long
 
using namespace std;
  
int main(){
  int N,M,sum = 0;
  double div;
  cin >> N >> M;
  vector<int> A(N);
  
  for(int i = 0;i < N;i++){
    cin >> A.at(i);
    sum += A.at(i);
  }
  div = (double)sum / (4 * (double)M);
  
   sort(A.begin(),A.end(),greater<int>());
   
  
   if(A.at(M-1) >= div){
     cout << "Yes" << endl;
   }else{
     cout << "No" << endl;
   }
  
    return 0;
}


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

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


Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
abd = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
pos = [-10**10 for i in range(n+1)]
for a,b,d in abd:
  graph[a].append((b,d))
  graph[b].append((a,-d))
stack = []
flg = 1
for i in range(1,n+1):
  if graph[i] and pos[i] == -10**10:
    stack.append(i)
    pos[i] = 0
    while stack:
      x = stack.pop()
      for y,d in graph[x]:
        if pos[y] == -10**10:
          pos[y] = pos[x]+d
          stack.append(y)
        else:
          if pos[y] != pos[x]+d:
            flg = 0
if flg:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 106588
package main

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

func min64(a,b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max64(a,b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		text := scanner.Text()
		tokens := strings.SplitN(text, " ", -1)

		a, _ := strconv.ParseInt(tokens[0], 10, 0)
		b, _ := strconv.ParseInt(tokens[1], 10, 0)
		c, _ := strconv.ParseInt(tokens[2], 10, 0)

		result := max64(c - (a - b), 0)
		fmt.Printf("%d", result)
	}

}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
int x=1,y=1;
while(1){
    cin >> x >> y;
    if ( x == 0 && y == 0 ) break;
    else if( x < y ) cout <<x<<" "<<y<<endl;
    else cout <<y<<" "<<x<<endl; 
}
return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    double a,b;
    cin>>a>>b;
    cout<<ceil((a+b)/2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int main()
{
	// freopen("ARC094-C.in", "r", stdin);
	int a, b, c, ans = 0; 
	scanf("%d%d%d", &a, &b, &c); 
	if ((a & 1) + (b & 1) + (c & 1) == 2)
	{
		ans++; 
		a += a & 1; 
		b += b & 1; 
		c += c & 1; 
	}
	else if ((a & 1) + (b & 1) + (c & 1) == 1)
	{
		ans++; 
		a += a & 1 ^ 1; 
		b += b & 1 ^ 1; 
		c += c & 1 ^ 1; 
	}
	int mx = std::max(a, std::max(b, c)); 
	printf("%d\n", ans + (mx - a + mx - b + mx - c >> 1));
	return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
using namespace std;
const int maxn=2e5+10;
typedef long long ll;
//pair<pair<ll,int>,int> p[maxn];
set<pair<pair<ll,int>,ll> > S;
set<pair<pair<ll,int>,ll> >::iterator it;
int n,m,A;
ll ans;
int a[maxn],b[maxn];
void solve(){
    ios::sync_with_stdio(false);
    cin>>n>>m>>A;
    for(int i=0;i<n;++i){
        cin>>a[i]>>b[i];
        S.insert(mp(mp(a[i],-1),i));
    }
    for(ll now=0,tmp;!S.empty();){
        it=S.begin();
        //S.erase(S.begin());
        if(it->first.second==-1){
            tmp=ceil(1.0*b[it->second]/A);
            if(now<tmp){
                ans+=tmp-now;
                S.insert(mp(mp(2ll*m+it->first.first,1),tmp-now));
                now=tmp;
            }
        }
        else{
            now-=it->second;
        }
        S.erase(S.begin());
    }
    cout<<ans<<endl;
}
int main(){
    solve();

    return 0;
}

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

int main(){
    int n;
    while(scanf("%d",&n), n){
        int v[100];
        rep(i,n)scanf("%d",v+i);
        int r=32;
        rep(i,1000){
            if(i&1){
                r -= min(r, v[(i/2)%n]);
            } else {
                r -= min(r, (r-1)%5);
            }
            printf("%d\n",r);
            if(r==0) break;
        }
    }
}

Measured memory_bytes: 1176
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << " ";
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define to_bin(b, n) bitset<b>(n) 
#define setBits(n) __builtin_popcountll(n) 
#define TC int t; cin >> t; while (t--) 

void Panda() {
    char c;
    cin >> c;
    if(isupper(c)) cout << 'A' << endl;
    else cout << 'a' << endl;
}
  
int32_t main() {
 
    FAST;
    Panda();

    return 0; 
} 

Measured memory_bytes: 3640
n=int(input())
s=[0]*n
t=[0]*n
for i in range(n):
    s[i],t[i]=map(str,input().split())
    t[i]=int(t[i])
x=input()
ans=0
k=0
for i in range(1,n):
    if s[i-1]==x:
        k=1
    if k==1:
        ans+=t[i]
print(ans)

Measured memory_bytes: 3064
N = int(input())
S = [int(input()) for i in range(N)]

ans = sum(S)
if ans % 10 == 0:
    d = [i for i in S if i % 10 != 0]
    if len(d):
        print(ans - min(d))
    else:
        print(0)
else:
    print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, L;
    cin >> N >> L;
    VEC(string) S(N);
    READVEC(S);
    sort(ALL(S));
    ostringstream out;
    FOR(i, 0, N)
        out << S[i];
    cout << out.str() << endl;
    return 0;
};


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>

using namespace std;
const int MAXN = 2e5 + 5;

int n, q, a[MAXN], cnt[MAXN];
long long sum;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i), cnt[a[i]]++, sum += a[i];
	}
	scanf("%d", &q);
	for (int b, c, i = 1; i <= q; i++) {
		scanf("%d%d", &b, &c);
		sum = sum + (long long)cnt[b] * (c - b);
		cnt[c] += cnt[b];
		cnt[b] = 0;
		printf("%lld\n", sum);
	}
	return 0;
} 

Measured memory_bytes: 4008
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main()
{
   int n;
   cin >> n;
   multiset<int> s;
   for (int i = 0; i < n; i++)
   {
      int a;
      cin >> a;
      s.insert(a);
   }
   int ans = 0;
   while (!s.empty())
   {
      int a = *(s.begin());
      if (s.count(a) == 1)
         ans++;
      for (int i = 1; i * a <= 1000000; i++)
      {
         s.erase(i * a);
      }
   }
   cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n, k, x, rez = 0;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x;
        if (x >= k) rez++;
    }
    cout << rez;
    return 0;
}


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

using namespace std;

int main()
{
	string n;
	string ans;

	cin >> n;

	if (n[0] == '7' || n[1] == '7' || n[2] == '7')
		ans = "Yes";
	else
		ans = "No";

	cout << ans << endl;

	return(0);
}


Measured memory_bytes: 3548
#include <iostream>
using namespace std;
int main(){
    int a[3],b[3];
    int c[5]={};
    cin>>a[0]>>b[0];
    cin>>a[1]>>b[1];
    cin>>a[2]>>b[2];
    for(int i=0;i<3;i++){
        c[a[i]]++;
        c[b[i]]++;
    }
    for(int i=1;i<=4;i++){
        if(c[i]>=3){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

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

int main() {
    int A, B;
    cin >> A >> B;

    for (int i = 0; i < 1250; ++i) {
        if (floor(i * 0.08) == A && floor(i * 0.1) == B) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int res;
    int busyDay = 0;
    while(m--){
        int t;
        cin >> t;
        busyDay = busyDay + t;
    }
    if(busyDay > n){
        res = -1;
    }
    else{
        res = n - busyDay;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int X,Y,Z,K;
int A[1010];
int B[1010];
int C[1010];
vector<int> V,V2,V3;

signed main(){
	cin>>X>>Y>>Z>>K;
	REP(i,X){
		cin>>A[i];
	}
	REP(i,Y){
		cin>>B[i];
	}
	REP(i,Z){
		cin>>C[i];
	}
	sort(A,A+X,greater<>());
	sort(B,B+Y,greater<>());
	sort(C,C+Z,greater<>());
	REP(i,X){
		REP(j,Y){
			V.push_back(A[i]+B[j]);
		}
	}
	sort(V.begin(),V.end(),greater<>());
	REP(i,min(K,V.size())){
		V2.push_back(V[i]);
	}
	REP(i,V2.size()){
		REP(j,Z){
			V3.push_back(V2[i]+C[j]);
		}
	}
	sort(V3.begin(),V3.end(),greater<>());
	REP(i,K){
		cout<<V3[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 43408
input()

result = 1
a = [int(x) for x in input().split()]
if 0 in a:
  print(0)
  exit()

for x in a:
  if result > 10 ** 18:
    print(-1)
    exit()
  result *= x
  
if result > 10 ** 18:
  print(-1)
else:
  print(result)

Measured memory_bytes: 21544
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B; cin >> A >> B;
    if (13 <= A) cout << B << endl;
    else if (6 <= A and A <= 12) cout << B/2 << endl;
    else cout << 0 << endl;
}

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

using namespace std;



int main(){


	long long n; cin >> n;

	long long record = 10000000000000;

	for(long long i = 1; i * i <= n; i++){
		if(n % i == 0){
			record = min(record, i + (n / i) - 2);
		}
	}



	cout << record << endl;






	return 0;
}

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

inline int read() {
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
int c[6];
int main() {
	for (int i=1;i<=5;++i) scanf("%d",&c[i]);
	for (int i=1;i<=5;++i) {
		if (!c[i]) {
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3828
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

int N, M;
map<int, bool> m;
string ans;
int main(){
    cin>>N>>M;
    ans="IMPOSSIBLE";
    REP(i,0,M){
        int a,b;
        cin>>a>>b;
        if(a==1) {
            if(m[b]){
                ans="POSSIBLE";
                break;
            }
            m[b]=true;
        }
        else if(b==N) {
            if(m[a]){
                ans="POSSIBLE";
                break;
            }
            m[a]=true;
        }

    }
    p(ans);
    return 0;
}

Measured memory_bytes: 9728
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    mi = 1
    ans = A[0] - 1 if A[0] != 1 else 0
    for a in A[1:]:
        if a <= mi + 1:
            mi = max(mi, a)
            continue
        ans += (a - 1) // (mi + 1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50904
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	int p, d1, d2;
	int a,b;

	while( cin >> n && n != 0 ){
		a = 0;
		b = 0;
		for( int i = 0;i < n;i++ ){
			cin >> p >> d1 >> d2;
			if( a < d1 + d2 ){ a = d1 + d2; b = p; }
		}
		cout << b << ' ' << a << endl;
	}
	return 0;


}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int X,Y,Z,K;cin>>X>>Y>>Z>>K;
    vector<long long>A(X),B(Y),C(Z);
    for(int i=0;i<X;i++)cin>>A[i];
    for(int i=0;i<Y;i++)cin>>B[i];
    for(int i=0;i<Z;i++)cin>>C[i];
    //cout<<" hi1"<<endl;

    vector<long long>AB;
    for(int i=0;i<X;i++) for(int j=0;j<Y;j++) AB.push_back(A[i]+B[j]);
    sort(AB.begin(),AB.end(),greater<long long>());
    AB.resize(K);
    //cout<<"hi2"<<endl;

    vector<long long>ABC;
    for(int i=0;i<AB.size();i++)for(int j=0;j<Z;j++)ABC.push_back(AB[i]+C[j]);
    sort(ABC.begin(),ABC.end(),greater<long long>());
    //cout<<"hi3"<<endl;
    for(int k=0;k<K;k++)cout<<ABC[k]<<endl;
}

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

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int>b(m);
  rep(i,m) cin >> b[i];
  
  int cnt = 0;
  rep(i,n){
    int sum = c;
    rep(j,m){
      int a;
      cin >> a;
      sum += a*b[j];
    }
    if(sum > 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n), y(m);
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  string ans = "War";
  int yMin = y[0], xMax = x.back();
  for (int i = X+1; i <= Y; i++) {
    if (xMax<i && i<=yMin) {
      ans = "No War";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())

c=[]
s=[]
f=[]

for i in range(n-1):
    x,y,z=map(int,input().split())
    c.append(x)
    s.append(y)
    f.append(z)
    
for i in range(n):
    ans=0
    if i<n-2:
        j=i
        ans=c[j]+s[j]
        while j<n-2:
            if ans>=s[j+1]:
                if ans%f[j+1]==0:
                    ans+=c[j+1]
                else:
                    ans+=c[j+1]+f[j+1]-ans%f[j+1]
            else:
                ans=c[j+1]+s[j+1]                
            j+=1
        print(ans)
    elif i==n-2:
        print(c[n-2]+s[n-2])
    elif i==n-1:
        print(0)

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  string s;cin>>s;
  int n = s.size();
  for(int i=0;i<n-1;i++){
    char nx = s[i+1];
    if(s[i]==nx){
      cout<<i+1<<' '<<i+2<<endl;
      return 0;
    }
    if(i<n-2&&s[i]==s[i+2]){
      cout<<i+1<<' '<<i+3<<endl;
      return 0;
    }
  }

  cout<<"-1 -1"<<endl;
  
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pii pair<int,int>
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
using namespace std;
const int N=500005;
int deg[N],p[N],q[N],n,k;
int ans[N],mx[N*4];
priority_queue<pii,vector<pii >,greater<pii > > que;
vector<int> e[N];
void change(int k,int l,int r,int p,int v){
	mx[k]=max(mx[k],v);
	if (l==r) return;
	int mid=(l+r)/2;
	if (p<=mid) change(k*2,l,mid,p,v);
	else change(k*2+1,mid+1,r,p,v);
}
int ask(int k,int l,int r,int x,int y){
	if (x>y) return 0;
	if (l==x&&r==y) return mx[k];
	int mid=(l+r)/2;
	if (y<=mid) return ask(k*2,l,mid,x,y);
	if (x>mid) return ask(k*2+1,mid+1,r,x,y);
	return max(ask(k*2,l,mid,x,mid),
			   ask(k*2+1,mid+1,r,mid+1,y));
}
int main(){
	scanf("%d%d",&n,&k);
	For(i,1,n) scanf("%d",&p[i]),q[p[i]]=i;
	For(i,1,n){
		int v=ask(1,1,n,q[i]+1,min(n,q[i]+k-1));
		if (v) e[v].push_back(i),deg[i]=1;
		else que.push(pii(q[i],i));
		change(1,1,n,q[i],i);
	}
	while (!que.empty()){
		int x=que.top().se; que.pop();
		for (int i:e[x]) que.push(pii(q[i],i));
		ans[++*ans]=x;
	}
	For(i,1,*ans) p[q[ans[i]]]=i;
	For(i,1,n) printf("%d\n",p[i]);
}

Measured memory_bytes: 44416
#include <bits/stdc++.h>
using namespace std;
long long R[10000005]={0};

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
vector<long long> enum_divisors1(long long N) {
    vector<long long> res1;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res1.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res1.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res1.begin(), res1.end());
    return res1;
}

int main(){
  long long n;
  cin>>n;
  long long ans=-1;
  const auto &res = enum_divisors(n);
  long long k;
for (int i = 1; i < res.size(); ++i){
  k=n;
  //cout << res[i] << " ";
  while(k%res[i]==0)k/=res[i];
  if(k%res[i]==1)ans++;
}
cout << endl;
const auto &res1 = enum_divisors1(n-1);
ans+= res1.size();
cout <<ans<< endl;

}


/*long long n,k;
cin>>n>>k;
long long p=0;
if(n>=k)p=n%k;
else p=n;
cout<<min(p,k-p)<<endl;
*/


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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

long long a[maxn];
int n,k,q,x;
void solve(){
    scanf("%d%d%d",&n,&k,&q);
    for(int i=1;i<=q;i++){
        scanf("%d",&x);
        ++a[x];
    }
    for(int i=1;i<=n;i++){
        if(q - a[i] < k){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 1408
//code
#include<iostream>
using namespace std;
long long n;
long long a[100005];
long long sum=0,ch1=0,ch2=0;
int main()
{
	cin>>n;
	int last=-1;  
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
		if(sum==0)
		{
			ch1++;
			if(last<0)
			    sum=1;
			else
			    sum=-1;
		}
		else
		if(sum<0&&last<0)
		{
			ch1+=(1-sum);
			sum=1;
		}
		else
		if(sum>0&&last>0)
		{
			ch1+=(sum+1);
			sum=-1;
		}
		last=sum;
	}
	sum=0;
	last=1;
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
		if(sum==0)
		{
			ch2++;
			if(last<0)
			    sum=1;
			else
			    sum=-1;
		}
		else
		if(sum<0&&last<0)
		{
			ch2+=(1-sum);
			sum=1;
		}
		else
		if(sum>0&&last>0)
		{
			ch2+=(sum+1);
			sum=-1;
		}
		last=sum;
	}
	cout<<min(ch1,ch2);	
	return 0;
}

Measured memory_bytes: 1024
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j;
	int N;
	char C;
	cin >> C;
	cout << char(C+1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <algorithm>
#include <stack>
#include <vector>
#include <string>
using namespace std;

int main(){
    int n, q, count=0;
    cin >> n;
    vector<int> S(n);
    for(int i=0; i<n; i++) cin >> S.at(i);
    cin >> q;
    vector<int> T(q);
    for(int i=0; i<q; i++) cin >> T.at(i);
    
    sort(S.begin(), S.end());
    S.erase(unique(S.begin(),S.end()), S.end());
    
    for(int i=0; i<S.size(); i++){
        for(int j=0; j<T.size(); j++){
            if(S.at(i) == T.at(j)) count++;
        }
    }
    cout << count << endl;
    
    return 0;
}


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


int main() {
  string s; cin >> s;
  string ans = "";
  int sum = 0;
  for(int i=0; i<(1<<3); i++){
    ans = "";
    ans.push_back(s[0]);
    sum = s[0]-'0';
    for(int j=0; j<3; j++){
      if((i>>j)&1){
        sum += s[j+1] - '0';
        ans.push_back('+');
        ans.push_back(s[j+1]);
      } else {
        sum -= s[j+1] - '0';
        ans.push_back('-');
        ans.push_back(s[j+1]);
      }
    }
    if(sum == 7){
      cout << ans << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


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

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

const int MOD = 1e+9 + 7;

int main()
{
    int N, X, Y, Z;
    cin >> N >> X >> Y >> Z;

    long long ans = 1;
    REP(i, N) ans = ans*10 % MOD;

    int S = (1<<(X+Y+Z))-1;  // X+Y+Z-1 個前までの状態を保持しておけば十分
	int C = (1<<(Z-1))|(1<<(Y+Z-1))|(1<<(X+Y+Z-1)); // XYZ が含まれる状態

    // dp[i][j]: i-1まで見たとき、直前が j で XYZ を含まない数列の数
    vector<vector<long long>> dp(N+1, vector<long long>((1<<(X+Y+Z))+1));
	dp[0][0] = 1;
    FOR(i, 1, N+1){
        REP(s, S+1){ // s: 直前の状態
            FOR(j, 1, 11){  // i 番目が j のとき
                int sn = (s<<j)|(1<<(j-1));  // 次の状態
                sn &= S;  // sn の bit 桁数を S 未満にする
                if((sn&C) != C){
                    dp[i][sn] += dp[i-1][s];
                    dp[i][sn] %= MOD;
                }
            }
        }
    }

    REP(i, S+1) ans = (ans-dp[N][i]) % MOD;
    cout << (ans+MOD)%MOD << endl;


    return 0;
}

Measured memory_bytes: 43520
N,K = map(int,input().split(" "))
p_list = list(map(int,input().split(" ")))
expect_val = []
for i in p_list:
    expect_val.append((i+1)/2)
max_val = 0
val = 0
for i in range(K):
    max_val += expect_val[i]
val = max_val
for i in range(N-K):
    val = val - expect_val[i] + expect_val[i+K]
    max_val = max(max_val,val)
print(max_val)


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

using namespace std;

const int INF=1000000007;

int d[202][202];

int main(){
        int N, M, R;
        cin>>N>>M>>R;
        vector <int> r;
        for(int i=0;i<R;i++){
                int rr;
                cin>>rr;
                r.push_back(rr-1);
        }
        sort(r.begin(), r.end());

        for(int i=0;i<202;i++){
                for(int j=0;j<202;j++){
                        if(i==j)
                                d[i][j]=0;
                        else
                                d[i][j]=INF;
                }
        }

        for(int i=0;i<M;i++){
                int a, b, c;
                cin>>a>>b>>c;
                d[a-1][b-1]=c;
                d[b-1][a-1]=c;
        }

        for(int k=0;k<N;k++){
                for(int i=0;i<N;i++){
                        for(int j=0;j<N;j++){
                                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
                        }
                }
        }
        int res=INF;
        do{
                int vres=0;
                for(int i=0;i<R-1;i++){
                        vres+=d[r[i]][r[i+1]];
                }
                res=min(vres, res);
        }while(next_permutation(r.begin(), r.end()));
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N, P = inpl()

def primes(N):
    sieve = [1] * (N+1)
    sieve[:2] = [0, 0]
    for i in range(N):
        if sieve[i]:
            for j in range(2*i, N+1, i):
                sieve[j] = 0
    P = []
    for i in range(N+1):
        if sieve[i]:
            P.append(i)
    return P

if N == 1:
    print(P)
else:
    ps = primes(10**6)
    
    ans = 1
    for p in ps:
        tmp = P * 1
        cnt = 0
        while tmp % p == 0:
            tmp = tmp // p
            cnt += 1
        ans *= p ** (cnt//N)
    
    print(ans)

Measured memory_bytes: 54000