akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define rsrt(s) sort(s.rbegin(),s.rend())
#define all(x) x.begin(),x.end()
#define mem(a, b) memset(a, b, sizeof(a))

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



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

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    ll n,x;

    cin >> n >> x;

    vector <ll> b(n);
    for(auto &i : b) cin >> i;
    srt(b);

    int cnt=0;

    for(ll i=0;i<n-1;i++)
    {
        if(b[i]<=x)
        {
            x-=b[i];
            cnt++;
        }
    }
    if(b[n-1]==x) cnt++;

    cout << cnt << endl;



    //---------------------------------
    
    return 0;
}


Measured memory_bytes: 3632
from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

n,m = map(int,input().split())
L = list()
A = list(map(int,input().split()))
for a in A:
    L.append((a,1))
for i in range(m):
    bi,ci = map(int,input().split())
    L.append((ci,bi))
L.sort(reverse=True)
ans,num = 0,0
for ci,bi in L:
    if num+bi <=n:
        num += bi
        ans += ci*bi
    else:
        ans += ci*(n-num)
        break
print(ans)

Measured memory_bytes: 81260
#include <stdio.h>

int main(void) {
	int W, H, x, y, r;
	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	if( (x - r >= 0 && x + r <= W) && (y - r >= 0 && y + r <= H) ) 
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

int main(){
/*	#ifndef ONLINE_JUDGE
        freopen("/home/shubham/Desktop/Programming-CP/input.txt", "r", stdin);
        freopen("/home/shubham/Desktop/Programming-CP/output.txt", "w", stdout);
    #endif*/
    string t,s;
    cin>>s>>t;
    string w = t+s;
    cout<<w<<endl;


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(long long int i=0;i<c;++i)
int  main(){
 long long int a,b,c;
 cin >> a>> b >> c;
 if(c<=a){
   cout << a-c << " " << b << endl;
 }else if(c<=a+b){
   cout << 0 << " " << b-(c-a) << endl;
 }else{
   cout << 0<< " " << 0 << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1000006, M = 998244353;

int n;
int q[N];

int f[N];

int ast(int x, int n)
{
    int ans = 1;
    while (n)
    {
        if (n % 2 == 1)
            ans = (ans * 1LL * x) % M;
        x = (x * 1LL * x) % M;
        n /= 2;
    }
    return ans;
}

int main()
{
    scanf("%d", &n);
    while (n--)
    {
        int x;
        scanf("%d", &x);
        ++q[x];
    }
    int ans = 0;
    for (int i = N - 1; i >= 1; --i)
    {
        for (int j = i; j < N; j += i)
        {
            f[i] += (q[j] * 1LL * j) % M;
            f[i] %= M;
        }
        f[i] = (f[i] * 1LL * f[i]) % M;
        for (int j = i; j < N; j += i)
        {
            f[i] -= (q[j] * 1LL * j * 1LL * j) % M;
            f[i] += M;
            f[i] %= M;
        }
        f[i] = (f[i] * 1LL * ast(2, M - 2)) % M;
        for (int j = i + i; j < N; j += i)
        {
            f[i] -= f[j];
            f[i] += M;
            f[i] %= M;
        }
        ans = ans + (f[i] * 1LL * ast(i, M - 2)) % M;
        ans %= M;
    }
    printf("%d\n", ans);
    return 0;
}


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

struct UF {
	int par[100001];
	UF() { for (int i = 0; i < 100001; i++) par[i] = i; }
	int root(int x) { if (par[x] == x) return x; return par[x] = root(par[x]); }
	void marge(int x, int y) { par[root(x)] = root(y); }
};

string s;
int a[100001];
int n, l, r;
UF uf;
int Sum[100001];

int main() {
	int i;
	
	cin >> s;
	
	a[0] = s[0] - 'a';
	for (i = 0; i < (int)s.length() - 1; i++) {
		a[i + 1] = s[i + 1] - s[i];
		if (a[i + 1] < 0) a[i + 1] += 26;
	}
	a[s.length()] = 'a' - s[s.length() - 1] + 26;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> l >> r;
		uf.marge(l - 1, r);
	}
	for (i = 0; i <= s.length(); i++) {
		uf.marge(i, s.length() - i);
	}
	
	for (i = 0; i <= s.length(); i++) {
		//cout << "i = " << i << " " << uf.par[i] << " " << a[i] << endl;
		Sum[uf.par[i]] += a[i];
		Sum[uf.par[i]] %= 26;
	}
	
	for (i = 0; i <= s.length(); i++) {
		if (Sum[i] != 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 1408
import sys, os

if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

f = lambda:list(map(int,input().split()))

def get_qsa(file_name):
    audio, size = readfile(file_name)
    headers = {
        'Connection': 'keep-alive',
        'Content-Length': str(size)
    }

    
    parameter = {
                "request_id":int(time.time()*100),
                "th":1,
                "tht":"qf492_100fps",
                "the":1.000000,
                "thst":"neural"
                }
    res = requests.post(f"http://{config['ip']}:{config['port']}", timeout=120, data=audio, headers=headers, params = parameter)
    # print(res.url)

    res_json = res.json()
    # print(res_json.keys())


    if res_json['retmsg']!="success":
        raise Exception
    

    bin_str = res_json["th"][0]["feat"]
    bin_data = base64.b64decode(bin_str)

    bin2qsa_siren(bin_data, file_name)


def solve():
    n,m = f()
    g= []
    for _ in range(n):
        g.append([])

    for _ in range(m):
        a,b = f()
        g[a-1].append(b-1)
        g[b-1].append(a-1)

    import queue
    q = queue.Queue()
    q.put(0)
    vis = set()
    vis.add(0)
    d = {}
    d[0] = 0

    ans = {}
    while not q.empty():
        u = q.get()
        for v in g[u]:
            if v in vis:
                continue
            vis.add(v)
            d[v] = d[u] + 1
            ans[v] = u
            q.put(v)

    ok = 1
    for i in range(1, n):
        if i not in vis:
            ok = 0
    
    if ok == 0:
        print("No")
    else:
        print("Yes")
        for i in range(1, n):
            print(ans[i]+1)



       
    
solve()



Measured memory_bytes: 49904
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  char s[MAX];
  int n;
  scanf("%d", &n);
  scanf("%s", s);
  if (n % 2 != 0)
  {
    printf("No\n");
    return 0;
  }
  rep(i, 0, n / 2)
  {
    if (s[i] == s[i + n / 2])
      continue;
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[105];
int x;
int n;

int main() {
  int n;
  scanf("%d", &n);
  scanf("%d", &x);
  int ret = n;
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
    x -= l[i];
  }
  sort(l, l+n);
  printf("%d\n", ret + x/l[0]);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int main() {
  int N; cin >> N;
  cout << N * N * N << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	int n,m,X,Y;
	cin >> n >> m >> X >> Y;
	vector<int>x(n),y(m);
	for (int& p : x)cin >> p;
	for (int& p : y)cin >> p;
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	cout << (X < x[x.size() - 1] + 1 && y[0] <= Y && x[x.size()-1]+1 <= y[0] ? "No War" : "War") << endl;
}


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

int main(void){
  int num, selectNum;
  cin >> num >> selectNum;
  int A[num];
  int allVote = 0;
  for(int i = 0; i < num; i++){
    cin >> A[i];
    allVote += A[i];
  }
  int selectedNum = 0;
  for(int i = 0; i < num; i++){
    if(A[i] >= ((float)allVote / (4 * selectNum))){
      selectedNum++;
    }
  }
  if(selectedNum >= selectNum) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main(){
  long long a,b,c,k;cin>>a>>b>>c>>k;
  if(abs(a-b)<1000000000000000000)cout<<(k%2==0?a-b:b-a)<<endl;
  else cout<<"unfair"<<endl;
}



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

int main(void){
    int i,n,x[100],y[100];
    double p_1=0,p_2=0,p_3=0,p_0=0;

    scanf("%d",&n);
    
    for(i=0;i<n;i++)
        scanf("%d",&x[i]);
    for(i=0;i<n;i++)
        scanf("%d",&y[i]);
    
    for(i=0;i<n;i++){
        
    //p=1
        p_1 += abs(x[i]-y[i]);
    
    //p=2
        p_2 += pow(fabs((double)x[i]-y[i]),2.0);
    
    //p=3
        p_3 += pow(fabs((double)x[i]-y[i]),3.0);
    
    //p=endless
        if(p_0 < abs(x[i]-y[i])) p_0 = abs(x[i]-y[i]);
        
    }
    
    printf("%lf\n%lf\n%lf\n%lf\n", p_1, pow(p_2,1.0/2), pow(p_3,1.0/3), p_0);
    
    
    return 0;
}




Measured memory_bytes: 2144
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
l = len(set(a))
if l > 3:
	print("No")
elif l == 1:
	if a[0] == 0:
		print("Yes")
	else:
		print("No")
elif n%3 != 0:
	print("No")
elif l == 2:
	if 0 not in set(a):
		print("No")
	elif a.count(0) == n//3:
		print("Yes")
	else:
		print("No")
else:
	for x in list(set(a)):
		if a.count(x) != n//3:
			print("No")
			break
	else:
		if list(set(a))[0] ^ list(set(a))[1] == list(set(a))[2]:
			print("Yes")
		else:
			print("No")

Measured memory_bytes: 14468
a, b, c = map(int, input().split())
 
able = 0
if c - a - b <= 0:
  able = 0
else:
  if (c - a - b) ** 2 > 4 * a * b:
  	able = 1
  else:
    able = 0
    
if able:
  print("Yes")
else:
  print("No")

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

const int MAX_V = 100005;

struct gra
{
	int to;
	int w;
};

vector<gra> G[MAX_V];

int color[MAX_V]; //頂点の色 (1 or -1)

void init(int V)
{
	for (int i = 0; i <= V; ++i)
	{
		color[i] = 0;
	}
}


bool dfs(int v, int c) //頂点vをcで塗る
{
	color[v] = c;
	for (int i = 0; i < G[v].size(); ++i)
	{
		if (color[G[v][i].to] == 0) //まだ塗られていない
		{
			int temp = c;
			
			if (G[v][i].w % 2 == 1)
			{
				temp = -1 * c;
			}

			dfs(G[v][i].to, temp);
		}
	}

	return true;
}


int main()
{
	int N;
	cin >> N;
	int a,b,c;
	for (int i = 0; i < N-1; ++i)
	{
		cin >> a >> b >> c;
		gra temp;
		temp.to = b;
		temp.w = c;
		G[a].push_back(temp);

		temp.to = a;
		G[b].push_back(temp);
	}

	init(N);

	if (!dfs(1, 1))
	{
		cout << "-1" << endl;
		return 0;
	}

	for (int i = 1; i <= N; ++i)
	{
		if (color[i] == -1) cout << "0" << endl;
		else cout << color[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 8320
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	basicIO "io"
	"os"
	"strconv"
)

func main() {
	protagonist(os.Stdin, os.Stdout)
}

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

/*
func main() {
	h := &IntHeap{2, 1, 5}
	heap.Init(h)
	heap.Push(h, 3)
	fmt.Printf("minimum: %d\n", (*h)[0])
}
*/

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	N, _ := io.nextInt()
	M, _ := io.nextInt()

	h := &IntHeap{}

	for i := 0; i < N; i++ {
		n, _ := io.nextInt()
		heap.Push(h, n)
	}

	heap.Init(h)
	//	heap.Push(h, 3)
	for i := 0; i < M; i++ {
		heap.Push(h, heap.Pop(h).(int)/2)
	}

	val := 0
	for h.Len() > 0 {
		val += heap.Pop(h).(int)
	}
	io.PutInt(val)
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() (int, error) {
	io.Scanner.Scan()
	i, err := strconv.Atoi(io.Scanner.Text())
	return i, err
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 7552
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-10 22:43:29
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int64 a, b, c, k; cin >> a >> b >> c >> k;

  if (k <= a) {
    cout << k << endl;
  } else if (k <= a + b) {
    cout << a << endl;
  } else {
    int64 res = k - (a + b);
    cout << a - res << endl;
  }

  return 0;
}

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

using namespace std;

string toUpper(string s){
  string t=s;
  for(int i=0;i<s.size();i++){
    t[i]=toupper(s[i]);
  }
  return t;
}

int main(){
  string target,source;
  cin>>target;
  target=toUpper(target);

  int cnt=0;
  while(1){
    cin>>source;
    if(source=="END_OF_TEXT") break;
    source=toUpper(source);
    if(target==source) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}
    



Measured memory_bytes: 3180
import bisect

n,m=map(int,input().split())

ans=[]

re=[[] for _ in range(n)]



for _ in range(m):
  a=list(map(int,input().split()))
  re[a[0]-1].append(a[1])
  ans.append(a)
  
d=[]
for f in re:
  sor=[]
  
  new=sorted(list(set(f)))
  
  for i in f:
    c=bisect.bisect_left(new,i)
    sor.append(c+1)
    
  d.append(sor)
    
  
for x in ans:
  p=x[0]
  q=d[p-1].pop(0)
  print(str('{:0=6}'.format(p))+str('{:0=6}'.format(q)))
  



Measured memory_bytes: 50636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second

int main()
{
	cin.tie(0)->sync_with_stdio(0);
    double d,t,s;
    cin >> d >> t >> s;

    double v = d/s;
    if(v <= t)
    {
        cout << "Yes\n";
    }
    else cout << "No\n";
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int ans=0;
	for(int i=0;i<n;++i){
		int a; cin>>a;
		ans+=a-1;
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3648
s = input()
rcount = 0
ans = [0]*len(s)
for i in range(len(s)-1):
    if s[i] == "R" and s[i+1] == "R":
        rcount += 1
    elif s[i] == "R" and s[i+1] == "L":
        rcount += 1
        ans[i+1] += rcount // 2
        ans[i] += rcount - rcount//2
        rcount = 0
    else:
        rcount = 0
lcount = 0
for i in range(len(s)-1, 0, -1):
    if s[i] == "L" and s[i-1] == "L":
        lcount += 1
    elif s[i] == "L" and s[i-1] == "R":
        lcount += 1
        ans[i-1] += lcount // 2
        ans[i] += lcount - lcount//2
        lcount = 0
    else:
        lcount = 0
for i in range(len(ans)):
    ans[i] = str(ans[i])
print(" ".join(ans))

Measured memory_bytes: 80616
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, mx = 0; cin >> n;
	rep(i, n){
		int a; cin >> a;
		if(a == mx + 1) mx++;
	}
	cout << (mx ? n - mx : -1) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define mp make_pair
#define len(s) s.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rocknroll cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0)
#define pq priority_queue
#define pii pair < int, int >
#define pll pair < ll, ll >
#define debug cout << " ---------------------------------------- "
#define kektor vector

typedef long long ll;
typedef long double ld;
typedef double dbl;
typedef unsigned long long ull;

using namespace std;


signed main()
{
    rocknroll;
    int a[5];
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    sort(a, a + 5);
    int k = abs(a[4] - a[0]);
    int q;
    cin >> q;
    if (k <= q)
    {
        cout << "Yay!";
    }
    else
    {
        cout << ":(";
    }
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    mp[0] = 1;
    int sum = 0;
    long long answer = 0;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        sum += x;
        sum %= m;
        answer += mp[sum];
        ++mp[sum];
    }
    cout << answer;
}

Measured memory_bytes: 6500
import java.util.Scanner;

class Main {

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

        int k=stdIn.nextInt();

        int x=stdIn.nextInt();
        int y=stdIn.nextInt();
        int count=0;
        for(int i=x; i<=y; i++){
            if(i%k==0){
                count++;
            }
        }
        if(count>0){
            System.out.println("OK");
            
        }
        else{
            System.out.println("NG");
            
        }
        
        
    }

}

Measured memory_bytes: 35816
#include <cmath>
#include <cstdio>

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

using namespace std;

const double EPS=1e-8;

struct point3{
	double x,y,z;
	point3():x(0),y(0),z(0){}
	point3(double x,double y,double z):x(x),y(y),z(z){}
	point3 operator-(const point3 &a)const{ return point3(x-a.x,y-a.y,z-a.z); }
};

double dot(const point3 &a,const point3 &b){ return a.x*b.x+a.y*b.y+a.z*b.z; }

point3 cross(const point3 &a,const point3 &b){ return point3(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x); }

double abs(const point3 &a){ return sqrt(a.x*a.x+a.y*a.y+a.z*a.z); }

double area(const point3 &a,const point3 &b,const point3 &c){ return abs(cross(b-a,c-a))/2; }

int main(){
	point3 p0,p1,q1,q2,q3;
	scanf("%lf%lf%lf",&p0.x,&p0.y,&p0.z);
	scanf("%lf%lf%lf",&p1.x,&p1.y,&p1.z);
	scanf("%lf%lf%lf",&q1.x,&q1.y,&q1.z);
	scanf("%lf%lf%lf",&q2.x,&q2.y,&q2.z);
	scanf("%lf%lf%lf",&q3.x,&q3.y,&q3.z);

	// line: (x-x0)/a = (y-y0)/b = (z-z0)/c = t
	double a=(p1-p0).x,b=(p1-p0).y,c=(p1-p0).z;
	double x0=p0.x,y0=p0.y,z0=p0.z;

	// plane: d*(x-x1) + e*(y-y1) + f*(z-z1) = 0
	point3 r=cross(q2-q1,q3-q1);
	double d=r.x,e=r.y,f=r.z;
	double x1=q1.x,y1=q1.y,z1=q1.z;

	// the laser direction is parallel to the normal of the plane which contains triangle
	if(abs(a*d+b*e+c*f)<EPS){
		puts("HIT");
		return 0;
	}

	// x = a*t + x0, y = b*t + y0, z = c*t + z0
	// d*(a*t+x0-x1) + e*(b*t+y0-y1) + f*(c*t+z0-z1) = 0
	double t=(d*(x1-x0)+e*(y1-y0)+f*(z1-z0))/(a*d+b*e+c*f);
	point3 s(a*t+x0,b*t+y0,c*t+z0);

	if(area(s,q1,q2)+area(s,q2,q3)+area(s,q3,q1)>area(q1,q2,q3)+EPS){
		puts("HIT");
	}
	else{
		puts(dot(p0-s,p1-s)>EPS?"HIT":"MISS");
	}

	return 0;
}

Measured memory_bytes: 1036
/* Hello darkness my old friend, I've come to visit you again! */

#include<bits/stdc++.h>
#define lli long long int
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FORB(i,b,a) for(i=b;i>=a;i--)
#define mod 1000000007
#define PI 2*acos(0.0)
#define gs getline(cin,s)
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pb push_back
#define eb emplace_back
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1000000005
#define INF 1000000000000000005
#define io ios_base::sync_with_stdio(0);
#define ff first
#define ss second
using namespace std;

int main()
{
    io;
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    if(n==0)
    {
        if(k==100)
            cout<<101;
        else
            cout<<k;
        return 0;
    }
    if(n==1)
    {
        if(k==100)
            cout<<10100;
        else
            cout<<k*100;
        return 0;
    }
    if(n==2)
    {
        if(k==100)
            cout<<1010000;
        else
            cout<<k*10000;
    }
    return 0;
}

/* This is the end, beautiful friend! */


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        mut x: i128,
        k: i128,
        d: i128,
    }

    solve(x, k, d);
}

fn solve(mut x: i128, k: i128, d: i128) {
    // x は正として良い
    x = x.abs();

    // x が遠すぎてどれだけ引いても原点までたどり着かない場合
    if x >= k * d {
        println!("{}", x - k * d);
        return;
    }

    // 適当な回数で原点までたどり着く場合
    if x < k * d {
        // x が正である最小の値を z とする
        // z にたどり着くために動かした回数を y とする
        let y = x / d;
        let z = x - y * d;

        // 移動の残回数が偶数回の場合は、点 z が最小になるしかない
        if (k - y) % 2 == 0 {
            println!("{}", z);
            return;
        }
        // 移動の回数が奇数回の場合は、必ず移動しないといけないので、原点方向に動く
        else {
            println!("{}", (z - d).abs());
            return;
        }
    }
}


Measured memory_bytes: 2088
ARG_N, ARG_W = gets.split.map(&:to_i)
ARG_w = Array.new(ARG_N)
ARG_v = Array.new(ARG_N)
ARG_N.times do |i|
  ARG_w[i], ARG_v[i] = gets.split.map(&:to_i)
end

def max a,b
  a > b ? a : b
end

dp = Array.new(ARG_W+1, 0)
ARG_N.times do |i|
  w, v = ARG_w[i], ARG_v[i]
  ndp = Array.new(ARG_W+1, 0)
  dw = ARG_W
  while w <= dw do
    dp[dw] = max(dp[dw], v + dp[dw-w])
    dw-=1
  end
end

puts dp.max

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

int N;
vector<int> A;

bool f(int x, int n) {
	if (x > A[N-n]) return n == 1;
	int m = (int)(lower_bound(A.begin(), A.end(), x-(A[N-n]-x)) - A.begin());
	//cerr << n << " " << A[N-n] << " " << x-(A[N-n]-x) << " " << x << " " << m << " " << N-n - m << endl;
	return N-n - m >= n-1;
}

int main() {
	int Q;
	cin >> N >> Q;
	A.resize(N);
	for (auto& x : A) cin >> x;
	vector<long long> a(N+1), b(N+2);
	for (int i = N-1; i >= 0; -- i) a[i] = a[i+1] + A[i];
	for (int i = 0; i < N; ++ i) b[i+2] = b[i] + A[i];
	for (int tt = 0; tt < Q; ++ tt) {
		int x;
		cin >> x;
		int ll = 1, rr = N;
		while (rr-ll > 1) {
			int mm = (ll+rr)/2;
			if (f(x, mm)) {
				ll = mm;
			} else {
				rr = mm;
			}
		}
		//cerr << ll << " " << a[N-ll] << " " << N-(2*ll-1) << " " << b[N-(2*ll-1)] << endl;
		cout << a[N-ll] + b[N-(2*ll-1)] << endl;
	}
}


Measured memory_bytes: 3712
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int n;
int v[30];
int c[30];

int dfs(int i, int j) {
    if (i == n) return j;
    return max(dfs(i + 1, j + v[i] - c[i]), dfs(i + 1, j));
}

int main() {
    cin >> n;
    rep(i, 0, n) cin >> v[i];
    rep(i, 0, n) cin >> c[i];
    cout << dfs(0, 0) << endl;
}

Measured memory_bytes: 888
#include<stdio.h>

int main(void){

  int i,n,q,left,right,mid,count=0;
  int S[100000],T;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&T);
    
    left=0;
    right=n;
    
    while(left < right){
      mid=(left + right)/2;
      if(S[mid] == T){
	count++;
	break;
      }
      else if(S[mid] > T) right=mid;
      else left=mid+1;
    }
  }
  
  
  
  printf("%d\n",count);
  
  return 0;
}

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
#define mkp std::make_pair
#define V std::vector
typedef long long ll;
typedef double ff;
typedef std::pair <int, int> pii;
const int kN = 1e6 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 998244353, kInfLL = 0x3f3f3f3f3f3f3f3fLL;

ll QPow(ll a, ll b) {
	ll ans = 1, bas = a;
	for(; b; b >>= 1, bas = bas * bas % kMod) if(b & 1) ans = ans * bas % kMod;
	return ans;
}

bool Cmp(pii a, pii b) {
	if(a.se > 0 && b.se > 0)
		return a.fi > b.fi;
	else if(a.se < 0 && b.se < 0) return a.se + b.fi > b.se + a.fi;
	else return a.se > b.se;
}
char sq[kN]; int n; pii bs[kN];
std::priority_queue <int> que;
int main() { 
#ifndef ONLINE_JUDGE
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	int T = 1; //rd(T);
	while(T--) {
		rd(n);
		for(int i = 1; i <= n; ++i) {
			scanf("%s", sq + 1);
			int len = strlen(sq + 1);
			bs[i].fi = bs[i].se = 0;
			for(int j = 1; j <= len; ++j) {
				bs[i].se += (sq[j] == '(' ? 1 : -1);
				bs[i].fi = std::min(bs[i].se, bs[i].fi);
				sq[j] = 0;
			}
		}
		std::sort(bs + 1, bs + n + 1, Cmp);
		//for(int i = 1; i <= n; ++i) printf("%d %d\n", bs[i].fi, bs[i].se);
		int cur_top = 0;
		for(int i = 1; i <= n; ++i) {
			if(cur_top + bs[i].fi < 0) {
				printf("No\n");
				return 0;
			}
			cur_top += bs[i].se;
		}
		if(cur_top == 0) printf("Yes\n");
		else printf("No\n");
	} return 0;
}

Measured memory_bytes: 11500
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    auto s = readln.chomp;

    auto mae = s[0..2].to!int;
    auto ato = s[$-2..$].to!int;

    if (1 <= mae && mae <= 12 && 1 <= ato && ato <= 12) {
        writeln("AMBIGUOUS");
    }
    else if (1 <= mae && mae <= 12) {
        writeln("MMYY");
    }
    else if (1 <= ato && ato <= 12) {
        writeln("YYMM");
    }
    else {
        writeln("NA");
    }
}























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var intArray = IO.ReadIntArray();
			IO.Write(intArray[0] > intArray[1] ? "safe" : "unsafe");
		}
	}

	public static class IO
	{
		public static string   Read()								 { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')		 { return Read().Split(iSplitter); }
		public static int	   ReadInt()							 { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()							 { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static double   ReadDouble()							 { return double.Parse(Read()); }
		public static double[] ReadDoubleArray(char iSplitter = ' ') { return ReadArray().Select(iText => double.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()						 { return Read().ToCharArray(); }

		public static void Write(string iValue)									   { Console.WriteLine(iValue); }
		public static void Write(int iValue)									   { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue , string iJoinWord = " ") { Console.WriteLine(string.Join(iJoinWord , iValue)); }
		public static void Write(long iValue)									   { Console.WriteLine(iValue); }
		public static void Write(double iValue)									   { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)								   { Console.WriteLine(iValue); }
		public static void Write(bool iValue)									   { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i1 , i0); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}
		public static long CombinationNum(int iLeftNumber , int iRightNumber)
		{
			if(iRightNumber == 0) { return 1; }
			if(iLeftNumber == 0)  { return 0; }
			return iLeftNumber * CombinationNum(iLeftNumber - 1 , iRightNumber - 1) / iRightNumber;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


Measured memory_bytes: 28308
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class abc154_b
    {

#if TEST
        public void Test_Main()
#else
        public static void Main()
#endif
        {
            string s = Console.ReadLine();
            int l = s.Length;
            StringBuilder sb = new StringBuilder();
            for(int i=0;i<l;i++)
            {
                sb.Append("x");
            }
            println(sb.ToString());
        }


        private static void println(string s)
        {
            Console.WriteLine(s);
        }
#if TEST
#else
    }
}
#endif


Measured memory_bytes: 13140
field = input().split()
k, s = int(field[0]), int(field[1])

ls = [i for i in range(k+1)]

result = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - y - x
        if 0 <= z and z <= k:
            result += 1
print(result)

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

int main(){
    int N;
    int x[100] = {};
    int y[100] = {};
    int h[100] = {};
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> h[i];
    }
    int tmp;
    int X;
    int Y;
    for(int i=0;i<101;i++){
        for(int j=0; j<101; j++){
            for(int k=0; k<N; k++){
                if(h[k] > 0 ){
                    tmp = abs(i-x[k]) + abs(j-y[k]) + h[k];
                    for(int l=0; l<N; l++){
                        if(max(0, tmp - abs(i-x[l]) - abs(j-y[l])) != h[l]){
                            tmp = 0;
                            break;
                        }else if(l == N-1){
                            X = i;
                            Y = j;
                            i = 101;
                            j = 101;
                            k = N;
                        }
                    }
                }
            }
        }
    }
    cout << X << ' ' << Y << ' '<<tmp << endl;
}


Measured memory_bytes: 256
import sys
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b,gcdnum=0):
    if gcdnum==0:
        return a * b // gcd (a, b)
    else:
        return a * b // gcdnum

for line in sys.stdin:
    a,b = map(int,line.split())
    gcdnum = gcd(a,b)
    print "%d %d"%(gcdnum,lcm(a,b,gcdnum))

Measured memory_bytes: 6368
n, k = map(int, input().split())
p = list(map(int, input().split()))

m = [(e + 1)/ 2 for e in p]

t = sum(m[0:k])
result = t
for i in range(n-k):
   t -= m[i]
   t += m[i+k]
   if t > result:
      result = t

print(result)


Measured memory_bytes: 25060
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<Integer,Integer> hash = new HashMap<Integer,Integer>();
		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			Integer po = hash.get(a);
			if(po  == null){
				po = 0;
			}
			hash.put(a, po+1);	
		}
		int ans = 0;
		for(int i:hash.keySet()){
			Integer po = hash.get(i);
			if(po == null){
				continue;
			}else{
				if(po >= i){
					ans = ans + (po - i);
				}else{
					ans = ans + po;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 63364
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

vector<pair<ll, ll>> Pfact(ll num) {
    vector<pair<ll, ll>> res;
    for (ll i = 2; i * i <= num; i++) {
        ll cnt = 0;
        while (num % i == 0) {
            cnt++;
            num /= i;
        }
        if (cnt) res.emplace_back(i, cnt);
    }
    if (num != 1) res.emplace_back(make_pair(num, 1));
    return res;
}
  
int main() {
  ll N,p;
  cin >> N >> p;
  vector<pair<ll,ll>> a = Pfact(p);
  ll ans = 1;
  rep(i,sz(a)) {
    ll b = (a[i].second / N);
    ans *= pow(a[i].first,b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void)
{
    long long n, k ,q;

    cin >> n >> k >> q;

    long long *point = new long long[n];
    memset(point, 0, sizeof(long long) * n);
    
    long long a;
    for (long long i = 0; i < q; i ++) {
        cin >> a;
        point[a-1]++;
    }
    
    for (long long i = 0; i < n; i++) {
        if (k - (q - point[i]) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}

struct wa{
  int r;
  int c;
};

bool comp(const wa &a, const wa &b){
  if(a.r != b.r)return a.r < b.r;
  else return a.c < b.c;
}

ll power(ll x, ll p){
  ll tmp = p;
  ll curr = x;
  ll res = 1;
  while(tmp){
    if(tmp % 2 == 1)res = res * curr % mod;
    tmp /= 2;
    curr = curr * curr % mod;
  }
  return res;
}

ll fac[200001];
ll inv[200001];
ll dp[3001];

int main(int argc, char const* argv[])
{
  int h, w, n;
  cin >> h >> w >> n;
  vector<wa> vec(n);
  rep(i, n){
    cin >> vec[i].r >> vec[i].c;
    vec[i].r--; vec[i].c--;
  }
  fac[0] = inv[0] = 1;
  FOR(i, 1, 200001){
    fac[i] = (ll)i * fac[i-1] % mod;
    inv[i] = power(fac[i], mod - 2);
  }
  sort(all(vec), comp);
  rep(i, n){
    dp[i] = fac[vec[i].r + vec[i].c];
    dp[i] = dp[i] * inv[vec[i].r] % mod;
    dp[i] = dp[i] * inv[vec[i].c] % mod;
    rep(j, i){
      if(vec[i].r >= vec[j].r && vec[i].c >= vec[j].c){
        ll tmp = fac[vec[i].r-vec[j].r+vec[i].c-vec[j].c];
        tmp = tmp * inv[vec[i].r-vec[j].r] % mod;
        tmp = tmp * inv[vec[i].c-vec[j].c] % mod;
        dp[i] = (dp[i] - dp[j] * tmp) % mod;
        if(dp[i] < 0)dp[i] += mod;
      }
    }
  }
  ll res = fac[h + w - 2];
  res = res * inv[h-1] % mod;
  res = res * inv[w-1] % mod;
  rep(i, n){
    ll tmp = fac[h-1-vec[i].r+w-1-vec[i].c];
    tmp = tmp * inv[h-1-vec[i].r] % mod;
    tmp = tmp * inv[w-1-vec[i].c] % mod;
    res = (res - dp[i] * tmp) % mod;
    if(res < 0)res += mod;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 3456
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

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

static constexpr ull MOD = 1000000007;
static constexpr double pi = 3.14159265359;

int main() {
    int V[3];
    cin >> V[0] >> V[1] >> V[2];

    int ans = -1;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (i == j) continue;
            for (int k = 0; k < 3; ++k) {
                if (i == k || j == k) continue;
                ans = max(ans, 10 * V[i] + V[j] + V[k]);
                ans = max(ans, V[i] + 10 * V[j] + V[k]);
            }
        }
    }
    cout << ans << endl;
}


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

int main()
{
  int n,m;
  int now,max;
  int a,b;
  int flg = 0;

  cin >> n >> m;
  now = m;
  max = m;

  for(int i = 1;i <= n;i++)
    {
      cin >> a >> b;

      now += a;
      now -= b;
      
      if(max < now)
	{
	  max = now;
	}
      if(now < 0)
	{
	  max = 0;
	  flg = 1;
	}
    }
  if(flg ==1)
    {
      cout << '0' << endl;
    }
  else
    {
      cout << max << endl;
    }
}



Measured memory_bytes: 3084
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define efo(i,u,v) for(int i=BB[u],v=B[BB[u]][1];i;v=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=1e5+5;
ll ans;
int n,rt1,rt2,B0,BB[N],B[N<<1][3];
void link(int u,int v,int w)
{
	B[++B0][1]=v,B[B0][0]=BB[u],B[B0][2]=w,BB[u]=B0;
}
int findrt(int v,int fr=1)
{
	int num=1,mx=0;
	efo(i,v,u) if(u!=fr)
	{
		int t=findrt(u,v);
		mx=max(mx,t),num+=t;
	}
	if(mx<=n/2 && n-num<=n/2)
	{
		if(!rt1) rt1=v;
		else rt2=v;
	}
	return num;
}
void dfs(int v,int fr,ll s=0)
{
	ans+=s;
	efo(i,v,u) if(u!=fr) dfs(u,v,s+B[i][2]);
}
int main()
{
	int x,y,z;
	n=read();
	fo(i,1,n-1) x=read(),y=read(),z=read(),link(x,y,z),link(y,x,z);
	findrt(1);
	dfs(rt1,rt1);
	int mn=1e9;
	if(rt2)
		efo(i,rt1,v) if(v==rt2)
		{
			printf("%lld\n",ans+ans-B[i][2]);
			return 0;
		}
	efo(i,rt1,v) mn=min(mn,B[i][2]);
	printf("%lld",ans+ans-mn);
	return 0;
}

Measured memory_bytes: 6912
#include<cstdio>
#include<algorithm> 
#include<cstring>
using namespace std;
const int N=2e5+5;
int n,num,a[N],dp[N],pos[N][30];
char s[N];
void print(int p,int num)
{
	if(!num)return;
	for(int i=1;i<=26;i++)
	{
		if(pos[p][i]==n+1)
		{
			printf("%c",i+'a'-1);
			return;
		}
		if(dp[pos[p][i]]<dp[p])
		{
			printf("%c",i+'a'-1);
			print(pos[p][i],num-1);
			return;
		}
	}
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=26;i++)pos[n+1][i]=n+1;
	for(int i=n;i>=0;i--)
	{
		a[i]=s[i]-'a'+1;
		for(int j=1;j<=26;j++)pos[i][j]=pos[i+1][j];
		pos[i][a[i+1]]=i+1;
		dp[i]=n+1;
		for(int j=1;j<=26;j++)dp[i]=min(dp[i],dp[pos[i][j]]+1);
	}
	print(0,dp[0]);
	return 0;
}

Measured memory_bytes: 25344