akhauriyash/Code-Regression huggingface dataset:
s = gets.chomp.chars.reverse.map(&:to_i)
mods_of_digit = [1]
200000.times{|i| mods_of_digit.push(mods_of_digit.last * 10 % 2019)}
mods = []
s.each_with_index{|n, i|
    mod = n * mods_of_digit[i]
    mod += mods.last if !mods.empty?
    mods.push mod % 2019
}
counts = {}
counts.default = 0
mods.each{|it|
    counts[it] += 1
}
puts counts.each_value.map{|it| it * (it - 1) / 2}.inject(:+) + mods.count(0)


Measured memory_bytes: 31332
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===
template<typename T, typename Compare = less<T> >
struct SkewHeap {
    struct Node {
        T dat;
        Node *l, *r;

        Node (T dat): dat(dat), l(nullptr), r(nullptr) {};
    };

    Node *root;
    Compare cmp;

    SkewHeap (Compare cmp = Compare()): root(nullptr), cmp(cmp) {};

    Node *meld(Node *h1, Node *h2) {
        if (h1 == nullptr) return h2;
        else if (h2 == nullptr) return h1;

        if (cmp(h2->dat, h1->dat)) swap(h1, h2);

        h1->r = meld(h1->r, h2);
        swap(h1->l, h1->r);

        return h1;
    };

    void push(T dat) {
        Node *u = new Node(dat);
        root = meld(root, u);
    };

    T top() { return root->dat; };
    
    T pop() {
        assert(!empty());
        T ret = top();
        Node *rm = root;
        root = meld(root->l, root->r);
        delete rm;
        
        return ret;
    };

    void merge_with(SkewHeap &h) {
        root = meld(root, h);
        h.root = nullptr;
    };

    bool empty() { return root == nullptr; };
};
// MinHeap<T> = SkewHeap<T, less<T>>
// MaxHeap<T> = SkewHeap<T, greater<T>>
//===

int ABC141D() {
    llong n, m;
    llong a;
    SkewHeap<llong, greater<llong> > h;

    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a;
        h.push(a);
    }

    for (int i = 0; i < m; i++) {
        a = h.pop() / 2;
        h.push(a);
    }

    llong sum = 0;
    while (!h.empty()) {
        sum += h.pop();
    }

    cout << sum << endl;
    
    return 0;
}

int main() {
    return ABC141D();
}


Measured memory_bytes: 3328
#include<stdio.h>
int main()
{
    int N,M,C;
    scanf("%d %d %d",&N,&M,&C);

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

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

    int acCount = 0;
    int currentCodePoint;

    for (int i = 0; i < N; i++){
        currentCodePoint = C;
        for (int j = 0; j < M; j++){
            currentCodePoint = currentCodePoint + A[i][j]*B[j];
        }
        if (currentCodePoint > 0) acCount ++;
    }

    // 出力
    printf("%d\n", acCount);
    return 0;
}

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

int main(){
    int n, score1, score2;
    score1 = 0;
    score2 = 0;
    string str1, str2;
    cin >> n;
    for(int i=0; i < n ; i++){
        cin >> str1 >> str2;
        if(str1 == str2){
            score1++;
            score2++;
        }else if(str1 > str2){
            score1 += 3;
        } else {
            score2 += 3;
        }
    }
    cout << score1 << " " << score2 << endl;
    
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

int main(void){
  ll h,w,x,y;
  cin >> w >> h >> x >> y;
  cout << w*h/2. << ' ' << (int)(x==w/2. && y==h/2.) << endl;;
}

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

const int N = 1e5 + 10;

int n, m, d[N], v, to, use[N], mx;
vector<int>g[N];

void dfs(int v)
{
	//cout <<v <<" ";
	if (use[v] == 1)
	{
		return ;
	}
	use[v] = 1;
	if (g[v].size() == 0)
	{
		d[v] = 1;
		return ;
	}
	for (int e = 0; e < g[v].size(); e++)
	{
		int to = g[v][e];
		dfs(to);
		d[v] = max(d[v], d[to] + 1);
	}
}

int main ()
{
	cin >>n >>m;
	mx = -1;
	for (int i = 1; i <= m; i++)
	{
		cin >>v >>to;
		g[v].push_back(to);
	}
	for (int i = 1; i <= n; i++)
	{
		dfs(i);
	}
	for (int i = 1; i <= n; i++)
	{
		//cout <<i <<" - " <<d[i] <<"   ";
		mx = max(mx, d[i]);
	}
	cout <<mx - 1;
	return 0;
}

Measured memory_bytes: 8576
#include<iostream>
using namespace std;
string s;
int main()
{
	cin>>s;
	int ans=0;
	for(int i=0,j=s.size()-1;i<j;i++,j--)
		if(s[i]!=s[j])
			if(s[j]=='x')ans++,i--;
			else if(s[i]=='x')ans++,j++;
			else{cout<<-1<<endl;return 0;}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const ll MOD = 1e9+7;
int n;
vl x, a, c, d;

ll binpowMOD(ll a, ll b) {
    a %= MOD;
    ll ret = 1;
    while(b > 0) {
        if(b & 1)
            ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> n;
	x.resize(n+1);
	rep(i,1,n+1) {
		cin >> x[i];
	}
	a.resize(n+1);
	rep(i,1,n+1) {
		a[i] = binpowMOD((ll)i, MOD-2);
	}
	rep(i,1,n+1) {
		a[i] += a[i-1];
		a[i] %= MOD;
	}
	ll ret = 0;
	rep(i,1,n) {
		ret += (x[i+1]-x[i]) * a[i] % MOD;
		ret %= MOD;
	}
	rep(i,1,n) {
		ret = ret * i % MOD;
	}
	cout << ret << '\n';
	return 0;
}

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

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

  if (N == 1) {
    cout << "Hello World" << endl;
  } else if (N == 2) {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
}


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

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int count = 1;
    int flag = 0;

    for (int i = 0; i < n - 1; ++i) {
        if(a[i] == a[i + 1])continue;
        if(a[i] < a[i + 1]){
            if(flag == 2){
                flag = 0;
                count++;
            }else{
                flag = 1;
            }
        }
        if(a[i] > a[i + 1]){
            if(flag == 1){
                flag = 0;
                count++;
            }else{
                flag = 2;
            }
        }
    }
    print(count);
}

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

int main()
{
  int h, w;
  cin >> h >> w;

  vector<string> s(h);
  for (auto&& e : s) cin >> e;

  vector<vector<int>> grid(h + 1, vector<int>(w + 1));
  grid[0][0] = 1;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') continue;
      grid[i][j] %= 1000000007;
      grid[i][j + 1] += grid[i][j];
      grid[i + 1][j] += grid[i][j];
    }
  }

  cout << grid[h - 1][w - 1] << endl;
}


Measured memory_bytes: 5248
import math
il = input().split()
A = int(il[0])
B = int(il[1])

flag = -1

for i in range(10, 1000+1):
    if(math.floor(i * 0.08) == A and math.floor(i * 0.1) == B):
        flag = i
        break
print(flag)


Measured memory_bytes: 3064
// AOJ 1032 Course Planning for Lazy Students
// 2018.2.28 bal4u

#include <stdio.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

#define QMAX 500000
typedef struct { int s, c; } Q;
Q q[QMAX+3]; int top, tail;
int c[22], r[22];
char mk[1<<20];

int bitcount(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main()
{
	int n, U, i, k, s;
	
	while (n = in()) {
		U = in();
		for (i = 0; i < n; i++) {
			c[i] = in(), r[i] = 0;
			k = in(); while (k--) r[i] |= 1 << in();
		}

		memset(mk, 0, sizeof(mk));
		q[0].s = q[0].c = 0, top = 0, tail = 1;
		while (top != tail) {
			s = q[top].s, k = q[top].c; if (++top == QMAX) top = 0;
			if (mk[s]) continue;
			mk[s] = 1;
			if (k >= U) break;
			for (i = 0; i < n; i++) if (!(s & (1<<i)) && (r[i] & s) == r[i]) {
				q[tail].s = s | (1<<i), q[tail].c = k + c[i];
				if (++tail == QMAX) tail = 0;
			}
		}
		printf("%d\n", bitcount(s));
	}
	return 0;
}


Measured memory_bytes: 6620
<?php
$n = trim(fgets(STDIN));
for($i=0; $i<$n; $i++){
    $arr[] = explode(" ", trim(fgets(STDIN)));
}

for($i=0; $i<$n; $i++){
    if($arr[$i][1] == 'BTC'){
        $arr[$i][0] = $arr[$i][0] * 380000;
    }
}
$ans = array_sum(array_column($arr, 0));
echo $ans;
?>


Measured memory_bytes: 4728
#include<cstdio>
#include<iostream>
#include<cstring>
#define re register
using namespace std;
typedef long long ll;
const int Maxn=3000000;
int n;
ll ans=0ll;
struct Double_Link{int pre,next;}dl[Maxn];
int a[Maxn],b[Maxn];
inline int read()
{
    int fl=1,rt=0; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') fl=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){rt=rt*10+ch-'0'; ch=getchar();}
    return fl*rt;
}
void read_ini()
{
	n=read();
	int x;
	for(re int i=1;i<=n;i++) x=read(),a[x]=i,b[i]=x;
	for(re int i=1;i<=n;i++) dl[i].next=i+1,dl[i].pre=i-1;
	for(re int i=n;i>=1;i--) dl[dl[a[i]].next].pre=dl[a[i]].pre,dl[dl[a[i]].pre].next=dl[a[i]].next;
	for(re int i=1;i<=n;i++) ans+=(ll)(i-dl[i].pre)*(ll)(dl[i].next-i)*(ll)b[i];
	printf("%lld\n",ans);
}
int main()
{
	read_ini();
	return 0;
}
/*
5
1 5 4 2 3
*/

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define inf 233366666
using namespace std;
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 deg[100005],head[100005],nxt[200005],v[200005];
int dp[100005],n,tot=0,root=-1,tar;
inline void add(int a,int b)
{tot++;nxt[tot]=head[a];head[a]=tot;v[tot]=b;}
void dfs(int pos,int f)
{int l,r,i,ts,num=0;
for (i=head[pos];i;i=nxt[i])
{if (v[i]==f) continue;
dfs(v[i],pos);num++;
}
int tp[num+2],sz=0;
for (i=head[pos];i;i=nxt[i])
{if (v[i]==f) continue;
tp[++sz]=dp[v[i]];
}
if (!(sz&1)) tp[++sz]=0;
sort(tp+1,tp+sz+1);
l=1;r=sz;ts=sz>>1;
while (l<=r)
{int mid=(l+r)>>1,p1=1,p2=sz,tag=1;
for (i=1;i<=ts;i++)
{if (p1==mid) p1++;
if (p2==mid) p2--;
if (tp[p1]+tp[p2]>tar) {tag=0;break;}
p1++;p2--;
}
if (tag) {r=mid-1;}
else {l=mid+1;}
}
if (l==sz+1) {dp[pos]=inf;}
else {dp[pos]=tp[l]+1;}
}
inline bool chk(int mid)
{tar=mid;dfs(root,0);
return (dp[root]<=mid+1);
}
int main (){
	int i,a,b,cnt=0;
	n=read();
	for (i=1;i<n;i++)
	{a=read();b=read();
	add(a,b);add(b,a);
	deg[a]++;deg[b]++;
	}
	for (i=1;i<=n;i++)
	{if (deg[i]&1)
	{cnt++;root=i;}
	}
	cnt>>=1;
	int l=1,r=n;
	while (l<=r)
	{int mid=(l+r)>>1;
	if (chk(mid)) {r=mid-1;}
	else {l=mid+1;}
	}
	printf ("%d %d\n",cnt,l);
	return 0;
}
	
	

Measured memory_bytes: 13952
class Dice:
    __slots__ = ['n1', 'n2', 'n3', 'n4', 'n5', 'n6']

    def __init__(self, n_tup):

        self.n1 = n_tup[0]
        self.n2 = n_tup[1]
        self.n3 = n_tup[2]
        self.n4 = n_tup[3]
        self.n5 = n_tup[4]
        self.n6 = n_tup[5]

    def roll(self, direction):
        if direction == "N":
            self.n1, self.n2, self.n6, self.n5 \
                = self.n2, self.n6, self.n5, self.n1
        elif direction == "E":
            self.n1, self.n3, self.n6, self.n4 \
                = self.n4, self.n1, self.n3, self.n6
        if direction == "S":
            self.n1, self.n2, self.n6, self.n5 \
                = self.n5, self.n1, self.n2, self.n6
        if direction == "W":
            self.n1, self.n3, self.n6, self.n4 \
                = self.n3, self.n6, self.n4, self.n1

dice = Dice([int(x) for x in input().split()])

cmd = input()
for i in range(len(cmd)):
    dice.roll(cmd[i])

print(dice.n1)

Measured memory_bytes: 7776
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val n = in.readInt
  val s = in.readLine

  val E = s.scanLeft(0)((acc, ch) => {
    if(ch == 'W') acc + 1 else acc
  }).init

  val W = s.scanRight(0) ((ch, acc) => {
    if(ch == 'E') acc +1 else acc
  }).tail

  val ans = (0 until n)./:(Int.MaxValue)((acc, i) => {
    val res = E(i) + W(i)
    acc min res
  })

  println(ans)
}

Measured memory_bytes: 85216
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>

using namespace std;

typedef long long ll;

#define pb push_back
#define mp make_pair
#define F first
#define S second

int main()
{
	ios_base::sync_with_stdio(false);
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	for(int m = 0; m < n; m++)
	{
		if((n - m - 1) * c - m * d <= b - a && b - a <= d * (n - m - 1) - m * c)
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

class UnionFind {
	vector<int>par, sz;
public:
	UnionFind() {}
	UnionFind(int n) {
		par = sz = vector<int>(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (sz[x] > sz[y]) {
			par[y] = x;
			sz[x] += sz[y];
		}
		else {
			par[x] = y;
			sz[y] += sz[x];
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return sz[find(x)];
	}
};

int n;ll d;
ll a[300000];
UnionFind uf;

vector<P>loop(bool b){
	unordered_map<int,ll>mp;//連結成分ごとの最小値
	set<P>se;//コスト、連結成分
	vector<P>res;
	rep(i,n){
		int id=(b?n-i-1:i);
		if(se.empty()){
			res.push_back(P(INFL,-1));
		}
		else{
			auto it=se.begin();
			while(it!=se.end()&&it->second==uf.find(id))it++;
			if(it!=se.end()){
				res.push_back(P(d*i+it->first+a[i],it->second));
			}
			else{
				res.push_back(P(INFL,-1));
			}
		}
		ll cost=-i*d+a[i];
		if(!mp.count(uf.find(id))||cost<mp[uf.find(id)]){
			if(mp.count(uf.find(id)))se.erase(P(mp[uf.find(id)],uf.find(id)));
			mp[uf.find(id)]=cost;
			se.insert(P(cost,uf.find(id)));
		}
	}
	return res;
}
int main(){
	cin>>n>>d;
	rep(i,n)scanf("%lld",&a[i]);
	uf=UnionFind(n);
	ll ans=0;
	while(uf.size(0)!=n){
		auto res=loop(0);
		rep(i,n/2)swap(a[i],a[n-i-1]);
		auto res2=loop(1);
		rep(i,n/2){
			swap(a[i],a[n-i-1]);
			swap(res2[i],res2[n-i-1]);
		}
		unordered_map<int,P>mp;
		rep(i,n){
			if(!mp.count(uf.find(i))||mp[uf.find(i)]>res[i]){
				mp[uf.find(i)]=res[i];
			}
			if(!mp.count(uf.find(i))||mp[uf.find(i)]>res2[i]){
				mp[uf.find(i)]=res2[i];
			}
		}
		for(auto p:mp){
			if(p.second.first==INFL)continue;
			if(!uf.same(p.first,p.second.second)){
				uf.unite(p.first,p.second.second);
				ans+=p.second.first;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 31328
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  ans += 2*(x/11);

  if(x%11>6){
  	ans += 2;
  }else if(x%11>0){
  	ans += 1;
  }
  cout << ans <<endl;

  return 0;
}







Measured memory_bytes: 256
#include<stdio.h>
int main(){
double a,b,c,d,e,f,x,y;
while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
 y=(c*d-f*a)/(b*d-e*a);
 x=(c-b*y)/a;
 printf("%.3f %.3f\n",x,y);
 }
return 0;}

Measured memory_bytes: 1800
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int number = sc.nextInt();
    long[] list = new long[number];
    for(int i = 0; i < number; ++i){
      list[i] = sc.nextLong();
    }
    
   int count = 0;
    
    for(int i = 0; i < number; ++i){
      while(list[i] % 2 == 0){
        list[i] = list[i] / 2;
        count++;
      }
    }
    
    System.out.println(count);
    
  }
}

Measured memory_bytes: 47804
#include <iostream>
#include <vector>

using namespace std;

vector <pair <int, int> > v;

int a[100];

int main (){
    int n, idx = 1, maxx = 0;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        if (abs(a[i]) > abs(maxx)){
            maxx = a[i];
            idx = i;
        }
    }
    for (int i = 1; i <= n; i++){
        if (i == idx)
            continue;
        a[i] += maxx;
        v.push_back(make_pair(idx, i));
    }
    if (maxx < 0){
        for (int i = n; i >= 2; i--){
            v.push_back(make_pair(i, i - 1));
        }
    }
    else {
        for (int i = 1; i < n; i++)
            v.push_back(make_pair(i, i + 1));
    }
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++)
        cout << v[i].first << " " << v[i].second << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
const int mod = 1000000007;
typedef long long ll;
//------------------------------------------------------------------------

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

  int n,k; cin >> n >> k;
  vector<double> p(n),v(n);
  rep(i,n){
    cin >> p[i];
    v[i] = (double)p[i]*(p[i]+1)/(p[i]*2);
  }
  
  double ans=0;
  double tmp=0;
  rep(i,k) tmp+=v[i];
  ans = tmp;
  rep1(i,n-k){
    
    tmp = tmp - v[i-1] + v[i+k-1];
    ans = max(tmp,ans);
  }
  
  Dcout(ans);
  
 
    

  return 0;
}




Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int n,card;
void make_map(map<int,int>& col, map<int,int>& row, map<int,int>& dia, map<int,int>& rdia) {
	int temp;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cin >> temp;
			col[temp] = j + 1;
			row[temp] = i + 1;
			if (i == j) {
				dia[temp] = n+1;
			}
			if (i+j == n-1) {
				rdia[temp] = n+2;
			}
		}
	}
}

bool check_line(int& count, map<int,int>& hash) {
	if (hash[card] > 0) {
		++count;
		if (count == n) {
			return true;
		}
	}
	return false;
}

int main(void) {
	int u,v,m;
	cin >> n >> u >> v >> m;
	map<int,int> rcol,ccol;
	map<int,int> rrow,crow;
	map<int,int> rdia,cdia;
	map<int,int> rrdia,crdia;
	if (n > 1) {
		make_map(rcol,rrow,rdia,rrdia);
		make_map(ccol,crow,cdia,crdia);
	}
	else {
		int temp;
		cin >> temp;
		rdia[temp] = 1;
		cin >> temp;
		cdia[temp] = 1;
	}

	int rc,cc;
	vector<int> rc_col(n,0),cc_col(n,0);
	vector<int> rc_row(n,0),cc_row(n,0);
	vector<int> rc_dia(2,0),cc_dia(2,0);
	rc = cc = 0;
	bool fin = false;
	for (int i = 0; i < m; ++i) {
		cin >> card;
		if (!fin) {
			if (check_line(rc_col[rcol[card]-1],rcol)) {
				++rc;
			}
			if (check_line(rc_row[rrow[card]-1],rrow)) {
				++rc;
			}
			if (check_line(rc_dia[0],rdia)) {
				++rc;
			}
			if (check_line(rc_dia[1],rrdia)) {
				++rc;
			}
			if (check_line(cc_col[ccol[card]-1],ccol)) {
				++cc;
			}
			if (check_line(cc_row[crow[card]-1],crow)) {
				++cc;
			}
			if (check_line(cc_dia[0],cdia)) {
				++cc;
			}
			if (check_line(cc_dia[1],crdia)) {
				++cc;
			}
			/*
				 if (rcol[card] > 0) {
				 ++rc_col[rcol[card]-1];
				 if (rc_col[rcol[card]-1] == n) {
				 ++rc;
				 }
				 }
				 if (rrow[card] > 0) {
				 ++rc_row[rrow[card]-1];
				 if (rc_row[rrow[card]-1] == n) {
				 ++rc;
				 }
				 }
				 if (rdia[card]) {
				 ++rc_dia[0];
				 if (rc_dia[0] == n) {
				 ++rc;
				 }
				 }
				 if (rrdia[card]) {
				 ++rc_dia[1];
				 if (rc_dia[1] == n) {
				 ++rc;
				 }
				 }
				 if (ccol[card] > 0) {
				 ++cc_col[ccol[card]-1];
				 if (cc_col[ccol[card]-1] == n) {
				 ++cc;
				 }
				 }
				 if (crow[card] > 0) {
				 ++cc_row[crow[card]-1];
				 if (cc_row[crow[card]-1] == n) {
				 ++cc;
				 }
				 }
				 if (cdia[card]) {
				 ++cc_dia[0];
				 if (cc_dia[0] == n) {
				 ++cc;
				 }
				 }
				 if (crdia[card]) {
				 ++cc_dia[1];
				 if (cc_dia[1] == n) {
				 ++cc;
				 }
				 }
				 */

			if (rc >= u && cc >= v) {
				cout << "DRAW" << endl;
				fin = true;
			}
			else if (rc >= u) {
				cout << "USAGI" << endl;
				fin = true;
			}
			else if (cc >= v) {
				cout << "NEKO" << endl;
				fin = true;
			}
		}
	}
	if (!fin) {
		cout << "DRAW" << endl;
	}
	return 0;
}

Measured memory_bytes: 35032
#include <iostream>
#include <sstream>
#include <iomanip>
#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;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
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;
    cin >> N;
    VEC(int) counts(100001, 0);
    FOR(i, 0, N) {
        int a;
        cin >> a;
        counts[a]++;
    }

    int ones = 0, twos = 0;
    FOR(i, 0, 100001)
        if (counts[i] % 2 == 1)
            ones++;
        else if (counts[i] > 0)
            twos++;

    // while twos >= 2, ones += 2
    ones += twos / 2 * 2;
    cout << ones << endl;
    return 0;
};


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;



int main() {
	

	string  s;
	cin >> s;

	int n = s.size();
	int temp,nn;
	temp = 0;

	for (int i = 0; i < (n - 1) / 2; i++)
	{
		if (s[i] != s[n - i-1])
			temp += 1;
	}


	if (temp != 0)
	{
		cout << "No" << endl;

	}
	else
	{
		nn = n / 2;
		temp = 0;


		for (int i = 0; i < nn / 2; i++)
		{
			if (s[i] != s[nn - i-1])
				temp += 1;
		}

		if (temp != 0)
		{
			cout << "No" << endl;
		}
		else
		{
			temp = 0;
			for (int i = 0; i < nn / 2; i++)
			{
				if (s[i + n/2+1] != s[n-i-1])
					temp += 1;
			}
			if (temp != 0)
			{
				cout << "No" << endl;
			}
			else
			{
				cout << "Yes" << endl;

			}

		}




	}

	
	
	



	return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#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 INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
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);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

char s[200010];
int main(){
	ll n;
	scanf("%lld %s",&n,s);
	ll ans=1,c=0;
	rep(i,0,2*n){
		if((c%2==0)^(s[i]=='W')){
			//開く
			c++;
		}else{
			//閉じる
			ans=ans*c--%MOD;
		}
	}
	rep(i,1,n+1)ans=ans*i%MOD;
	printf("%lld",c==0?ans:0);
}

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


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;

long long int fact(long long int k) {
	long long int sum = 1;
	for (long long int i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long int pow_mod(int a, int b) {
	long long int  ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

struct Box {
	int no;
	int isFact;
};

int main()
{
	long long int n, max = 0;

	cin >> n;

	vector<long long int> a(n + 1);

	vector<vector<Box>> x(n + 1);

	for (int i = 1; i <= n; i++) {

		cin >> a[i];

		vector<Box> _x(a[i]);

		for (int j = 0; j < a[i]; j++)
			cin >> _x[j].no >> _x[j].isFact;

		x[i] = _x;
	}

	vector<int> isFact(n + 1);
	int  factCnt = 0;
	bool isBreak = false;
	for (int i = 0; i < (int)pow(2, n); i++) {
		factCnt = 0;
		for (int j = 0; j < n; j++) {
			if (i % (int)pow(2, j + 1) >= (int)pow(2, j)) {
				isFact[j + 1] = true;
				factCnt++;
			}
			else
				isFact[j + 1] = false;
		}

		isBreak = false;
		for (int j = 1; j <= n; j++) {
			if (isFact[j] == 1) {
				for (int k = 0; k < a[j]; k++) {
					if (x[j][k].isFact != isFact[x[j][k].no]) {
						isBreak = true;
						break;
					}
				}
				if (isBreak)
					break;
			}
		}

		if (!isBreak && factCnt >= max)
			max = factCnt;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int an = a/b;
      if(a%b != 0) an+=1;
      
      System.out.println(an);
	}
 
}


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

using namespace std;

long N, slime[1<<9], dp[1<<9][1<<9], imos[1<<9];

long rec(int l = 0, int r = N)
{
	if (~dp[l][r]) return dp[l][r];
	if (l+1==r) return dp[l][r] = 0;
	long res = LONG_MAX;
	for (int p = l+1; p < r; p++)
	{
		res = min(res, rec(l, p)+rec(p, r)+imos[r]-imos[l]);
	}
	return dp[l][r] = res;
}

void solve()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> slime[i];
		imos[i+1] = imos[i] + slime[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << rec() << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 2304
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int total = 0;
        int A = stdIn.nextInt();
        int B = stdIn.nextInt();
        int T = stdIn.nextInt();
        for(int i=1;;i++) {
        	if((T-i*A)>=0)
        		total += B;
        	else
        		break;
        } 
        System.out.println(total);
	}
}

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

void main() {
    auto s = readln.split.map!(to!int).array;
    auto N = s[0];
    auto A = s[1].to!long;
    auto B = s[2].to!long;
    auto H = N.iota.map!(_ => readln.chomp.to!long).array;

    long hi = 10L ^^ 9 + 1;
    long lo = 0;

    while (hi - lo > 1) {
        auto mid = (hi + lo) / 2;
        long tmp = 0;
        foreach (i; 0..N) {
            if (H[i] - mid * B > 0)
                tmp += max(0, (H[i] - mid * B - 1) / (A - B) + 1);
        }
        if (tmp <= mid)
            hi = mid;
        else
            lo = mid;
    }

    hi.writeln;
}


Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1000000000;




int main(){
    int N,K;cin >> N >> K;
    vector<vector<LL>> dp(N+1,vector<LL>(K+1,0));
    dp[0][0]=1;
    for (int i = 0; i < N; i++) {
        int a;cin >> a;
        vector<LL> sum(K+2,0);
        for (int j = 0; j <= K; j++) {
            sum[j+1]=(sum[j]+dp[i][j])%mod;
        }
        for (int j = 0; j <= K; j++) {
            dp[i+1][j]=(sum[j+1]-sum[max(0,j-a)]+mod)%mod;
        }
    }
    cout << dp[N][K] << endl;
    return 0;
}




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

int main() {

    int r, g, b;
    cin >> r >> g >> b;
    if((100 * r + 10 * g + b) % 4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 384
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let k: usize = sc.read();
    if (n + 1) / 2 >= k {
        println!("YES");
    } else {
        println!("NO");
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <cstdio>

typedef long long LL;
const int MN = 100005;

int N, s, x[MN]; LL p[MN];

LL calc(int l, int r, int t) {
	if (s < x[l]) return x[r] - s;
	if (x[r] < s) return s - x[l];
	if (p[l] >= p[r]) return p[l] += p[r], calc(l, r - 1, l) + (t == r ? x[r] - x[l] : 0);
	else return p[r] += p[l], calc(l + 1, r, r) + (t == l ? x[r] - x[l] : 0);
}

int main() {
	scanf("%d%d", &N, &s);
	for (int i = 1; i <= N; ++i) scanf("%d%lld", &x[i], &p[i]);
	printf("%lld\n", calc(1, N, p[1] < p[N] ? 1 : N));
	return 0;
}

Measured memory_bytes: 5248
#include <stdio.h>

typedef struct {
	int ic;
	int hour;
	int min;
	char flag;
} DATA;

int main(void)
{
	DATA in, out;
	int len[6] = { 6, 7, 5, 5, 20, 15 };
	int rate[6][6] = { 300, 500, 600, 700, 1350, 1650,
					   NULL, 350, 450, 600, 1150, 1500,
					   NULL, NULL, 250, 400, 1000, 1350,
					   NULL, NULL, NULL, 250, 850, 1300,
					   NULL, NULL, NULL, NULL, 600, 1150,
					   NULL, NULL, NULL, NULL, NULL, 500};
					   
	int in_tmp, out_tmp;
	int length;
	int i;
	
	while (1){
		scanf("%d", &in_tmp);
		if (in_tmp == 0){
			break;
		}
		
		scanf("%d %d", &in.hour, &in.min);
		
		scanf("%d", &out_tmp);
		scanf("%d %d", &out.hour, &out.min);
		
		if (out_tmp < in_tmp){
			out_tmp ^= in_tmp;
			in_tmp ^= out_tmp;
			out_tmp ^= in_tmp;
		}
		
		in.ic = in_tmp;
		out.ic = out_tmp;
		
		length = 0;
		
		for (i = in.ic - 1; i < out.ic - 1; i++){
			length += len[i];
		}
		
		in.flag = 0;
		out.flag = 0;
		
		if ((in.hour == 17 && in.min >= 30 || in.hour > 17) && (in.hour == 19 && in.min <= 30 || in.hour < 19)){
			in.flag = 1;
		}
		
		if ((out.hour == 17 && out.min >= 30 || out.hour > 17) && (out.hour == 19 && out.min <= 30 || out.hour < 19)){
			out.flag = 1;
		}
		
		
		
		
		if (length <= 40 && (in.flag | out.flag) == 1){
			printf("%d\n", (rate[in.ic - 1][out.ic - 2] / 2) + ((rate[in.ic - 1][out.ic - 2] / 2) % 50));
		}
		
		else {
			printf("%d\n", rate[in.ic - 1][out.ic - 2]);
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int[] P=new int[N];

        for(int i=0; i<N; i++) {
        	P[i]=gi();
        }

        int c=0;   
        for (int i=1; i<N-1; i++) {
        	if((P[i]>P[i-1] && P[i]<P[i+1]) || (P[i]<P[i-1] && P[i]>P[i+1])) {
        		c++;
        	}
        }
        

        System.out.print(c);

//        if (b>=1 && b<=12) {
//        	if(a>=1 && a<=12) {
//        	    System.out.println("AMBIGUOUS");
//        	} else {
//        		System.out.println("MMYY");
//        	}
//        }else {
//        	if(a>=1 && a<=12) {
//        	    System.out.println("YYMM");
//        	} else {
//        		System.out.println("NA");
//        	}
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35540
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int a = in.i();
        int b = in.i();
        int c = in.i();
        int x = in.i();
        int y = in.i();
        int ans = min(
              a * x + b * y,
              b * f(y - x) + c * 2 * x,
              a * f(x - y) + c * 2 * y);
        out.println(ans);
    }

    static int min(int... a) {
        Arrays.sort(a);
        return a[0];
    }

    static int f(int a) {
        return a < 0 ? 0 : a;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = read(cbuf, 0, cbuf.length);
            } catch (IOException e) {}
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                back();
                break;
            }
        }
    }

    char[] s(final int N) {
        skip();
        char[] s = new char[N];
        for (int i = 0; i < s.length; i++) {
            s[i] = next();
        }
        return s;
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 32788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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 (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    string s;
    cin >> s;
    ll N;
    cin >> N;
    rep(i,N){
        string t;
        ll a, b;
        cin >> t >> a >> b;
        if(t=="print"){
            cout << s.substr(a, b-a+1)<<endl;
        }
        else if(t=="reverse"){
            reverse(s.begin() + a, s.begin() + b + 1);
        }
        else{
            string p;
            cin >> p;
            rep(i,b-a+1){
                s[a + i] = p[i];
            }
        }
    }
}


Measured memory_bytes: 3216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = x/1000;
		int b = x/100 -a*10;
		int c = x/10 -a*100 - b*10;
		int d = x-a*1000-b*100-c*10;


		if(a==b&&b==c||b==c&&c==d) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
	}


}


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

int main( int argc, char *argv[] )
{
int i;
int W;
int H;
int N;
int x;
int y;
int a;
int MinX;
int MaxX;
int MinY;
int MaxY;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> W;
	cin >> H;
	cin >> N;

	MinX = 0;
	MaxX = W;
	MinY = 0;
	MaxY = H;
	for( i = 0; i < N; i++ )
	{
		cin >> x;
		cin >> y;
		cin >> a;
		if( a == 1 )
		{
			if( MinX < x ) MinX = x;
		}
		else if( a == 2 )
		{
			if( MaxX > x ) MaxX = x;
		}
		else if( a == 3 )
		{
			if( MinY < y ) MinY = y;
		}
		else
		{
			if( MaxY > y ) MaxY = y;
		}
	}

	if( MaxX <= MinX || MaxY <= MinY )
		cout << 0 << endl;
	else
		cout << ( MaxX - MinX ) * ( MaxY - MinY ) << endl;

	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAX=1e5+4;
LL a[MAX];
LL root[MAX];




int main(){
        LL n,k;
        cin>>n>>k;
        double temp=1/(double)n;
        LL bound=(LL)pow(k,temp)+1;
        if(n==1)
        {
                cout<<k<<endl;
                exit(0);
        }
        if(k==1)
        {
                cout<<1<<endl;
                exit(0);
        }
        if(n==k)
        {
                cout<<1<<endl;
                exit(0);
        }
        LL ans=0;
       // cout<<bound;
        for(int i=1;i<=bound;i++)
        {
                LL tmp=pow(i,n-1);
                if(k%tmp==0)
                {
                        LL tmp2=k/tmp;
                        if(tmp2%i==0)
                        {
                                ans=i;
                        }
                }
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int v, w, x, y, z;
    std::cin >> v >> w >> x >> y >> z;

    char res = v == 0 ? '1' : 
               w == 0 ? '2' : 
               x == 0 ? '3' : 
               y == 0 ? '4' : '5';
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
double ma(double s) 
{ 
	double length = s / 3; 
	s -= length; 
	double breadth = s / 2; 
	double height = s - breadth; 
	return length * breadth * height; 
} 
int main()
{
    double n;
  cin>>n;
 printf("%.12lf",ma(n));

  return 0;
}

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

using namespace std;

typedef long long int ll;

ll getH(ll h){
    if(h == 1){
        return  1;
    }
    if(h == 0)return 0;
    return 1+ 2* getH(floor(h/2));
}

int main(){
    ll h;
    cin>>h;
    ll outCome = getH(h);
    cout<<outCome<<endl;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  [a, b, x] <- map read . words <$> getLine
  print $ solve a b x

solve :: Int -> Int -> Int -> Int
solve a b x = n - m + 1
  where
    m = if a `mod` x == 0 then a `div` x else a `div` x + 1
    n = b `div` x

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define INF (1 << 30)
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout << #x << ": " << x << endl
#define _DDEBUG(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x, y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    if (!v.empty())
    {
        out << '[';
        copy(v.begin(), v.end(), ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

/* template end */

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

    string s, t;
    cin >> s >> t;

    string ans = "No";
    int length = s.length();
    for (int i = 0; i < length; i++)
    {
        if (t == (s.substr(i) + s.substr(0, i)))
        {
            ans = "Yes";
        }
    }

#if DEBUG
    cout << "** RESULT **" << endl; // debug
#endif
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n, od = 0, ev = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 2)od++;
		else ev++;
	}
	if (od % 2) {
		cout << "NO" << endl;
	}
	else{
		cout << "YES" << endl;
	}
	return 0;
}

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

using ll = long long;

int main()
{
    int N, W; cin >> N >> W;

    auto values = array<vector<int>, 4>{};
    auto min_weight = 0LL;
    for (auto i = 0; i < N; i++)
    {
        int w, v; cin >> w >> v;
        if (i == 0) min_weight = w;
        values[w-min_weight].push_back(v);
    }

    for (auto& xs : values)
    {
        sort(begin(xs), end(xs), greater<int>());
        xs.insert(begin(xs), 0);
        for (auto i = 0; i+1 < int(xs.size()); i++)
            xs[i+1] += xs[i];
    }

    auto result = 0;
    for (auto i = 0; i < int(values[0].size()); i++)
        for (auto j = 0; j < int(values[1].size()); j++)
            for (auto k = 0; k < int(values[2].size()); k++)
                for (auto l = 0; l < int(values[3].size()); l++)
                    if (i*min_weight + j*(min_weight+1) + k*(min_weight+2) + l*(min_weight+3) <= W)
                        result = max(result, values[0][i] + values[1][j] + values[2][k] + values[3][l]);
    cout << result << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>

int main() {
  std::array<std::array<int, 13>, 4> cards {};
  for (int i=0; i<4; i++) cards.at(i).fill(0);

  std::array<char, 4> num2suit = {'S', 'H', 'C', 'D'};
  std::map<char, int> suit2num;
  for (int i=0; i<4; i++) suit2num[num2suit[i]] = i;

  auto read = [&](auto &cards, char suit, int rank){
                cards.at(suit2num[suit]).at(rank) = 1;
              };
  auto write = [&](auto &cards, int i, int j){
                 std::cout << num2suit[i] << ' ' << j+1 << std::endl;
               };

  int n;
  std::cin >> n;

  char suit;
  int rank;
  for (int i=0; i<n; i++)
    {
      std::cin >> suit >> rank;
      read(cards, suit, rank-1);
    }

  for (int i=0; i<4; i++)
    {
      for (int j=0; j<13; j++)
        {
          if (cards.at(i).at(j) == 0)
            write(cards, i, j);
        }
    }
 }



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

const int N = 3e5 + 100;
int n, m, num, ans, seg[300100 * 4]; vi p[300100];
#define lc(k) (k << 1)
#define rc(k) (k << 1 | 1)
void modify(int k, int l, int r, int x, int v) {
	if(l == r) return seg[k] += v, void();
	int mid = l + r >> 1;
	if(x <= mid) modify(lc(k), l, mid, x, v);
	else modify(rc(k), mid + 1, r, x, v);
	seg[k] = max(seg[lc(k)], seg[rc(k)]);
}
int query(int k, int l, int r, int L, int R) {
	if(L > R) return -1;
	if(L <= l && r <= R) return seg[k];
	int mid = l + r >> 1, ret = -1;
	if(L <= mid) ret = max(ret, query(lc(k), l, mid, L, R));
	if(R > mid) ret = max(ret, query(rc(k), mid + 1, r, L, R));
	return ret;
}
signed main() {
	scanf("%d %d %d", &n, &m, &num);
	for(int i = 1; i <= num; i++) {
		int x, y; scanf("%d %d", &x, &y);
		p[x].pb(y), modify(1, 1, m, y, 1);
	}
	for(int i = 1; i <= n; i++) {
		sort(p[i].begin(), p[i].end());
		int nw = p[i].size(), mx = -1;
		for(int j : p[i]) mx = max(mx, query(1, 1, m, j, j));
		ans = max(ans, nw + mx - 1);
		mx = -1; p[i].pb(m + 1);
		for(int j = 0, lst = 0; j < p[i].size(); lst = p[i][j++])
			mx = max(mx, query(1, 1, m, lst + 1, p[i][j] - 1));
		ans = max(ans, nw + mx);
	}
	printf("%d\n", ans);
	fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
	return 0;
	/* 取模直接除，爆零两行泪
	 * 不开ll见祖宗
	 */
}

Measured memory_bytes: 24852
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (x, a, b) = Slice3<long>();
            if (Abs(a - x) < Abs(b - x))
                WriteLine("A");
            else
                WriteLine("B");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27392
a,b,c,d=[int(i) for i in input().split()]

i=0
while True:
    if i==0:
        c-=b
        if c<=0:
            print("Yes")
            break
        else:
            i=1
            i=i%2
    else:
        a-=d
        if a<=0:
            print("No")
            break
        else:
            i=0

Measured memory_bytes: 9184