akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
    int n,A[5][4][11];
    /*初期化*/
    for (int i = 1;i <= 4; i++)
        for (int j = 1;j <= 3; j++)
            for (int k = 1;k <= 10; k++)
                A[i][j][k] = 0;
    /*入力*/
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int b,f,r,v;
        cin >> b >> f >> r >> v;
        A[b][f][r] += v;
    }
    /*出力*/
    for (int f = 1; f <= 4; f++)
    {
        if(f > 1)cout << "####################\n";
        for (int b = 1; b <= 3; b++)
        {
            for (int r = 1; r <= 10; r++)
            {
                cout << " " << A[f][b][r];
            }
            cout << endl;
        }
    }
    
return 0;
}


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

using namespace std;

using ll = long long;

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   vector<tuple<int, int, int>> edges;
   for (int i = 0; i < N - 1; ++i) {
      int v, u, w;
      cin >> v >> u >> w;
      --v, --u;
      edges.emplace_back(w, v, u);
   }
   sort(edges.begin(), edges.end());
   reverse(edges.begin(), edges.end());
   vector<int> par(N);
   vector<int> sz(N);
   vector<ll> add(N);
   iota(par.begin(), par.end(), 0);
   fill(sz.begin(), sz.end(), 1);
   function<int(int)> getPar = [&](int v) {
      if (v == par[v]) {
         return v;
      } else {
         return getPar(par[v]);
      }
   };
   function<ll(int)> getSum = [&](int v) {
      ll ans = add[v];
      if (v != par[v]) {
         ans += getSum(par[v]);
      }
      return ans;
   };
   for (auto e : edges) {
      int w, v, u;
      tie(w, v, u) = e;
      v = getPar(v), u = getPar(u);
      add[v] += ll(sz[u]) * w;
      add[u] += ll(sz[v]) * w;
      if (sz[v] < sz[u]) swap(v, u);
      par[u] = v;
      sz[v] += sz[u];
      add[u] -= add[v];
   }
   for (int i = 0; i < N; ++i) {
      cout << getSum(i) << "\n";
   }
}


Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint factorial(ll n) {
  mint answer = 1;
  while (n > 1) {
    answer *= n;
    n--;
  }
  return answer;
}

mint combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

mint permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

// setprecision(8) 桁数指定
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>

using namespace std;

typedef long long ll;

int N, K;
vector<vector<int>> graph;


int bfs1(int root)
{
	vector<int> used(N);
	vector<int> dist(N);
	
	queue<int> que;
	que.push(root);
	used[root] = 1;
	dist[root] = 0;

	int cnt = 1;
	while(!que.empty()) {
		int x = que.front(); que.pop();

		for(int to : graph[x]) {
			if(!used[to] && dist[x] < K / 2) {
				used[to] = 1;
				dist[to] = dist[x] + 1;
				que.push(to);
				cnt++;
			}
		}
	}

	return N - cnt;
}

int bfs2(int root1, int root2)
{
	vector<int> used(N);
	vector<int> dist(N);
	
	queue<int> que;
	que.push(root1);
	que.push(root2);
	used[root1] = 1;
	dist[root1] = 0;
	used[root2] = 1;
	dist[root2] = 0;
	
	int cnt = 2;
	while(!que.empty()) {
		int x = que.front(); que.pop();

		for(int to : graph[x]) {
			if(!used[to] && dist[x] < K / 2) {
				used[to] = 1;
				dist[to] = dist[x] + 1;
				que.push(to);
				cnt++;
			}
		}
	}

	return N - cnt;
}

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

	graph = vector<vector<int>>(N);

	for(int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		graph[a - 1].push_back(b - 1);
		graph[b - 1].push_back(a - 1);
	}

	int ans = N;
	if(K % 2 == 0) {
		for(int i = 0 ; i < N; ++i) {
			ans = min(ans, bfs1(i));
		}
	} else {
		for(int i = 0; i < N; ++i) {
			for(int to : graph[i]) {
				ans = min(ans, bfs2(i, to));
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
import math

n=input()
res=2

if n==2:
    print 1
    exit(0)
if n==3:
    print 2
    exit(0)
for i in xrange(2, int(math.sqrt(n)+1)):
    k=n
    while k>1:
        if k%i==0:
            k=k/i
        else:
            k=k%i
            break
        
    if k==1:
        res+=1

for i in xrange(2, int(math.sqrt(n))):
    if (n-1)%i==0:
        res+=1

print res

Measured memory_bytes: 29548
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

int main() {
	ll N;
	string S, S_front, S_back;
	cin >> N >> S;
	S_front = S.substr(0, S.size() / 2);
	S_back = S.substr(S.size() / 2,S.size()/2);
	if (S_front == S_back&&S.size()%2==0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
def q a,l,r
l<r&&(
i=l
(l..r-1).map{|j|a[j][2,20].to_i<=a[r][2,20].to_i&&(a[i],a[j]=a[j],a[i];i+=1)}
a[i],a[r]=a[r],a[i]
q a,l,i-1
q a,i+1,r
)
end
gets
a=$<.to_a
b=a.dup
q b,n=0,b.size-1
puts b==a.sort_by{|i|[i[2,20].to_i,n+=1]}?:Stable:"Not stable",b

Measured memory_bytes: 32308
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

cnt = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        cnt += bisect.bisect_left(L, L[i]+L[j]) - (j+1)

print(cnt)

Measured memory_bytes: 3188
def main_a():
    y, m, d = map(int, input().split())
    a = (y - 1) // 3
    b = (y - 1) % 3
    c = a * 590 + 195 * b 
    if y % 3:
        a = (m - 1) // 2
        b = (m - 1) % 2
        c += a * 39 + b * 20
    else:
        c += (m - 1) * 20
    c += d - 1
    print(196470 - c)
def a():
    n = int(input())
    for i in range(n):
        main_a()

def main_b():
    s = input()
    ans = []
    for i in range(1,len(s)):
        ans.append(s[:i] + s[i:])
        ans.append(s[i-1::-1] + s[i:])
        ans.append(s[i-1::-1] + s[len(s):i-1:-1])
        ans.append(s[:i] + s[len(s):i - 1:-1])
        ans.append(s[i:] + s[:i])
        ans.append(s[i:] + s[i - 1::-1])
        ans.append(s[len(s):i - 1:-1] + s[i - 1::-1])
        ans.append(s[len(s):i - 1:-1] + s[:i])
    print(len(set(ans)))

def b():
    n = int(input())
    for i in range(n):
        main_b()

b()


Measured memory_bytes: 5656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

long int gcd(long int x,long int y){
    if(x % y == 0){
        return y;
    }
    return gcd(y,x % y);
}

int main(){
    long int A,B;
    cin >> A >> B;
    
    long int GCD = gcd(A, B);
    long int ans = 1;
    for(long int i = 2; i * i <= gcd(A, B); ++i) {
        if(GCD % i == 0){
            ans++;
        while(GCD % i == 0) GCD /= i;
        }
    }
    if(GCD != 1) ans++;
    cout << ans << endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        var xy = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var x = xy[0];
        var y = xy[1];


        for(int i = 0; i < x + 1; i++)
        {
            for(int j = 0; j < x + 1; j++)
            {
                if (i + j != x) continue;
                if((i * 2) + (j * 4) == y){
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }

        Console.WriteLine("No");
    }
}

Measured memory_bytes: 28296
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int g[100][100];
int h[100][100];
int c[100];
double r[100][100];

int main(){
  while(true){
    int n = getInt();
    int m = getInt();
    int p = getInt();

    if(n+m+p == 0) break;

#define MAX 10000000
    REP(i,n) REP(j,n){
      g[i][j] = 0;
      h[i][j] = (i == j ? 0 : MAX);
    }

    REP(i,m){
      int a = getInt();
      int b = getInt();
      int c = getInt();

      h[a][b] = h[b][a] = g[a][b] = g[b][a] = c;
    }

    REP(i,p) c[i] = getInt();

    REP(k,n) REP(i,n) REP(j,n){
      h[i][j] = min(h[i][j], h[i][k] + h[k][j]);
    }

    REP(i,n) REP(j,n){
      if(g[i][j] == 0)
        r[i][j] = 0.0;
      else if(h[0][i] + g[i][j] + h[j][n-1] != h[0][n-1])
        r[i][j] = 0.0;
      else
        r[i][j] = 1.0;
    }

    REP(k,n) REP(i,n) REP(j,n){
      r[i][j] = r[i][j] + r[i][k] * r[k][j];
    }

    REP(i,p)
      printf("%.8f\n",r[0][c[i]]*r[c[i]][n-1]/r[0][n-1]);
    puts("");
  }
  return 0;
}

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

struct dice
{
    int x[6];
    void roll(char c)
    {
        int a;
        if (c == 'N')
        {
            a = x[0];
            x[0] = x[1];
            x[1] = x[5];
            x[5] = x[4];
            x[4] = a;
        }
        if (c == 'S')
        {
            a = x[0];
            x[0] = x[4];
            x[4] = x[5];
            x[5] = x[1];
            x[1] = a;
        }
        if (c == 'E')
        {
            a = x[0];
            x[0] = x[3];
            x[3] = x[5];
            x[5] = x[2];
            x[2] = a;
        }
        if (c == 'W')
        {
            a = x[0];
            x[0] = x[2];
            x[2] = x[5];
            x[5] = x[3];
            x[3] = a;
        }
    }
    int top(void)
    {
        return x[0];
    }
    int front(void)
    {
        return x[1];
    }
    int right(void)
    {
        return x[2];
    }
};

int main()
{
    dice d;
    for (int i = 0; i < 6; ++i)
        cin >> d.x[i];
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i)
    {
        int a, b, ans;
        cin >> a >> b;
        string s = "ENESNESNESNESENESNESNESNESENESNESNESNESENESNESNESNESNNESNESNESNESNNESNESNESNES";
        int n = s.size();
        for (int j = 0; j < n; ++j)
        {
            d.roll(s[j]);
            if (d.top() == a && d.front() == b)
                ans = d.right();
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>

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

//#define PI 3.14159265358979323846264338327950L
const double PI = acos(-1);
 
int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double th = double(h*60+m)/720 * 2*PI;
  double tm = double(m)/60 * 2*PI;
  double xh = a*cos(th), yh = a*sin(th);
  double xm = b*cos(tm), ym = b*sin(tm);
  double dx = xh-xm, dy = yh-ym;
  double ans = sqrt(dx*dx + dy*dy);
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    int N;
    ll D,A;
    cin>>N>>D>>A;
    vector<pair<ll,ll>> XH;
    rep(i,N){
        int x,h;
        cin>>x>>h;
        XH.push_back({x,h});
    }
    sort(all(XH));
    vector<ll> X(N),H(N);
    rep(i,N){
        X[i] = XH[i].first;
        H[i] = (XH[i].second + A - 1) / A;
    }
    ll ans = 0;

    queue<pair<ll,ll>> Q;
    ll Qsum = 0;
    rep(i,N){
        //古い情報から見ていって、今見ている位置に影響を与えない
        //爆発は除いていく
        while(!Q.empty() && Q.front().first < X[i]){
            Qsum -= Q.front().second;
            Q.pop();
        }
        //今までの爆発でできるやつ
        H[i] -= Qsum;
        //すでに死んでいたら何もしない
        if(H[i] <= 0)continue;
        ans += H[i];
        Q.push(make_pair(X[i]+2*D, H[i]));
        Qsum += H[i];
    }
    cout<<ans<<endl;
}

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> cost(N);
  vector<vector<int>> skills(N);
  for (int i = 0; i < N; ++i) {
  	cin >> cost[i];
    skills[i].resize(M);
    for (int j = 0; j < M; ++j) {
      cin >> skills[i][j];
    }
  }
  int MIN = INT_MAX;
  for (int i = (1 << N) - 1; i >= 0; --i) {
    int curr = i;
    int pos = 0;
    vector<int> takes;
    while (curr) {
      if (curr & 1) {
        takes.push_back(pos);
      }
      ++pos;
      curr >>= 1;
    }
    vector<int> dat;
    dat.assign(M, 0);
    int price = 0;
    for (auto &it : takes) {
      for (int j = 0; j < M; ++j) {
        dat[j] += skills[it][j];
      }
      price += cost[it];
    }
    bool valid = 1;
    for (int j = 0; j < M && valid; ++j) {
      valid = dat[j] >= X;
    }
    if (valid) MIN = min(MIN, price);
  }
  printf("%d\n", MIN != INT_MAX ? MIN : -1);
  return 0;
}

Measured memory_bytes: 3704
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int ac_num[51];
bool locked[51][11];
int wa_num[51][11];
ll penalty[51];
vi ans;
void correct(int tid,int pid,int time)
{
	if(locked[tid][pid])return;
	ac_num[tid]++;
	penalty[tid]+=wa_num[tid][pid]*1200+time;
	locked[tid][pid]=true;
	return ;
}
void wrong(int tid,int pid,int time)
{
	if(locked[tid][pid])return;
	wa_num[tid][pid]++;
	return ;
}
bool comp(int a,int b)
{
	if(ac_num[a]>ac_num[b])return true;
	else if(ac_num[a]<ac_num[b])return false;
	else
	{
		if(penalty[a]>penalty[b])return false;
		else if(penalty[a]<penalty[b])return true;
		else
		{
			if(a>b)return false;
			else return true;
		}
	}
}
int main()
{
	while(1)
	{
		ans.clear();
		memset(penalty,0,sizeof(penalty));
		memset(wa_num,0,sizeof(wa_num));
		memset(ac_num,0,sizeof(ac_num));
		memset(locked,0,sizeof(locked));
		int t,p,r;
		cin >> t >> p >> r;
		if(t==0&&p==0&&r==0)break;
		for(int i=0;i<r;i++)
		{
			int a,b,c;
			string s;
			cin >> a >> b >> c >> s;
			if(s[0]=='C')
			{
				correct(a,b,c);
			}
			else
			{
				wrong(a,b,c);
			}
		}
		for(int i=1;i<=t;i++)
		{
			ans.pb(i);
		}
		sort(ans.begin(),ans.end(),comp);
		for(int i=0;i<sz(ans);i++)
		{
			cout << ans[i] << ' ' << ac_num[ans[i]] << ' ' << penalty[ans[i]] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 163577857
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;if(m<0) return 0;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a;
    if(a==0)
        return b; 
    return gcd(b, a % b);  
      
}
#define MAXN 2005
int main()
{
    fastio();
   
    ll k,a,b;
    cin>>k>>a>>b;
    ll c = a/k;
    if(c*k==a || (c+1)*k<=b)
        cout<<"OK"<<endl;
    else
        cout<<"NG"<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<cassert>
#include<sstream>

using namespace std;

map<string,int> M;
bool isValid;

bool isAtom(string s){
  if(s.length() == 1) return 'A' <= s[0] && s[0] <= 'Z';
  if(s.length() == 2) return 'A' <= s[0] && s[0] <= 'Z' && 'a'<= s[1] && s[1] <= 'z';
  return false;
}

bool isNum(string s){
  for(int i = 0; i < s.length(); i++)
    if(s[i] < '0' || s[i] > '9') return false;
  return true;
}

bool isMol(string s){ return M[s] != 0; }

string rmPara(string s){
  if(s[0] != '(' || s[s.length()-1] != ')') return s;
  int p = 0;

  for(int i = 0; i < s.length()-1; i++){
    if(s[i] == '(') p++;
    if(s[i] == ')') p--;
    if(p == 0) return s;
  }
  return s.substr(1,s.length()-2);
}

bool isAtomNum(string s){
  if(s.length() < 2) return false;
  bool f = isAtom(s.substr(0,s.length()-1)) && isNum(s.substr(s.length()-1));
  if(s.length() > 2) f |= isAtom(s.substr(0,s.length()-2)) && isNum(s.substr(s.length()-2));
  return f;
}

bool isMolNum(string s){
  if(s[0] != '(') return false;
  
  string tmp = "";
  int p = 0;

  for(int i = 0; i < s.length(); i++){
    if(s[i] == '(') p++;
    if(s[i] == ')') p--;
    if(p == 0){
      tmp = s.substr(i+1);
      break;
    }
  }
  return tmp != "" && isNum(tmp);
}

int StrtoInt(string s){
  stringstream ss(s);
  int num;
  ss >> num;
  return num;
}

int isMolMol(string s){
  if(s[0] == '('){ //(Mol) Num
    string tmp = "";
    int p = 0;

    for(int i = 0; i < s.length(); i++){
      if(s[i] == '(') p++;
      if(s[i] == ')') p--;
      tmp += s[i];
      if(p == 0) break;
    }
   
    int S = tmp.length();

    for(int i = S; i < s.length(); i++){
      if(s[i] < '0' || s[i] > '9') break;
      tmp += s[i];
    }

    if(isMolNum(tmp)) return tmp.length();
  }

  int pos = 1;
  if(isAtom(s.substr(0,2))) pos = 2;
  for(int i = pos; i < s.length(); i++){
    if(s[i] < '0' || s[i] > '9') return i;
  }
  assert(false);
}

int solve(string s){
  
  // cout << "s " << s << endl;
  s = rmPara(s);

  if(isAtom(s)){
    if(M[s] == 0){
      isValid = false;
      return 1;
    }else return M[s];
  }else if(isAtomNum(s)){
    int pos;

    for(pos = 0; pos < s.length(); pos++){
      if('0' <= s[pos] && s[pos] <= '9') break; 
    }
  
    return solve(s.substr(0,pos)) * StrtoInt(s.substr(pos));
  }else if(isMolNum(s)){
    int pos;
    char c = s[s.length()-2];

    if('0' <= c && c <= '9') pos = 2;
    else pos = 1;
    
    return solve(s.substr(0,s.length()-pos))*StrtoInt(s.substr(s.length()-pos)); 
  }else {
    int pos = isMolMol(s);
    return solve(s.substr(0,pos)) + solve(s.substr(pos));
  }
}


int main(){

  string s;
  int num;

  while(cin >> s && s != "END_OF_FIRST_PART"){
    cin >> num;
    M[s] = num;
  }
  while(cin >> s && s != "0"){
    isValid = true;
    int ans = solve(s);
    if(isValid) cout << ans << endl;
    else cout << "UNKNOWN" << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    
    if(e-a>k){
        cout << ":(" << endl;
    }
    else{
        cout << "Yay!" << endl;
    }
}


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

using namespace std;
long long UCLN(long long a,long long b)
{
	if(b==0)
	{
		return a;
	}
	else
	{
		UCLN(b,a%b);
	}
}
long long BCNN(long long a,long long b)
{
	return a*b/UCLN(a,b);
}
int main(){
	long long a,b;
	cin>>a>>b;
	cout<<BCNN(a,b);
	return 0;
}

Measured memory_bytes: 256
import functools


def lcm(nums):
        return functools.reduce(multiple, nums)

def multiple(a, b):
    return a*b // euclid(a, b)

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

n = int(input())
l = []
for _ in range(n):
    a = int(input())
    l.append(a)

print(lcm(l))

Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	string str;
	cin >> str;
	
	int n = str.size();
	bool flag = true;
	REP(i,str.size()-2)
	{
		if(str[i] != str[i+2])flag = false;
	}
	if(str[0] == str[str.size()-1])n--;
	
	if(flag || n % 2 == 0)
	{
		cout << "Second" << endl;
	}
	else
	{
		cout << "First" << endl;
	}
		
	
	return 0;
}

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

struct Sta {
	int c, s, f;
};

int main() {
	int n;
	cin >> n;
	vector<Sta> sta(n - 1);
	for (int i = 0; i < n - 1; i++) {
		cin >> sta[i].c >> sta[i].s >> sta[i].f;
	}
	for (int i = 0; i < n; i++) {
		int ans = 0;
		for (int j = i; j < n - 1; j++) {
			if (ans < sta[j].s) ans = sta[j].s;
			if (ans % sta[j].f) ans = ans - (ans % sta[j].f) + sta[j].f;
			ans += sta[j].c;
		}
		cout << ans << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int m, mn, mx;
  while (cin >> m >> mn >> mx) {
    if (m == 0 && mn == 0 && mx == 0) break;
    int p[m];
    REP(i, m) cin >> p[i];
    mn--, mx--;
    int d = 0;
    int ans = -1;
    for (int i = mn; i <= mx; ++i) {
      int tmp = p[i] - p[i + 1];
      if (d <= tmp) {
        d = tmp;
        ans = i;
      }
    }
    cout << ans + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

using ll = long long;

int main() {
	string str;
	cin >> str;
	// std::cout << "debug str" << str << std::endl; // debug
	ll ans = 0;
	int m = 2019;
	int sum = 0; // only store value after mod
	int digit_like = 1;
	vector<int> remainder_counter(m);
	remainder_counter[0]++;
	for (auto itr = str.rbegin(); itr != str.rend(); itr++) {
		int n = *itr - '0';
		n *= digit_like;
		// std::cout << "debug n " << n << " digit_like " << digit_like << std::endl; // debug
		sum = (sum + n) % m;
		// std::cout << "debug sum " << sum << std::endl; // debug
		ans += remainder_counter[sum]; // do before remainder_counter increment
		remainder_counter[sum]++;
		// for nest
		digit_like = (digit_like * 10) % m;
	}
	// std::cout << "debug ans " << ans << std::endl; // debug
	cout << ans;


	// std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    if (A >= B) {
        ans += A;
        A--;
    }else{
        ans += B;
        B--;
    }
    if (A >= B) {
        ans += A;
        A--;
    }else{
        ans += B;
        B--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e14+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-12;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint count(llint w,llint h,llint v,llint x,llint y){
	llint ans=0;
	for(llint i=0;i<=v/h;i++){
		llint kyo=v*v-(i*h+y)*(i*h+y);
		if(kyo<0){continue;}
		llint z=sqrt(kyo);
		while((z+1)*(z+1)<=kyo){z++;}//誤差対策
		while(z*z>kyo){z--;}//誤差対策
		ans+=(z-x+w)/w;
	}
	return ans;
}

bool solve(void){
	llint w,h,v,t,x,y,p,q;cin>>w>>h>>v>>t>>x>>y>>p>>q;
	if(p>x){p=w-p;x=w-x;}
	if(q>y){q=h-q;y=h-y;}
	w*=2;h*=2;v*=t;
	llint ans=0;
	llint yoko[4]={x+p,x-p,w-x-p,w-x+p};
	llint tate[4]={y+q,y-q,h-y-q,h-y+q};
	for(int i=0;i<16;i++){
		ans+=count(w,h,v,yoko[i%4],tate[i/4]);
	}
	cout<<ans<<endl;
	return false;
}
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	while(solve()){}
	return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
#define  mx 10000000
#define m 44722

int ar[m+5],num;


int main()
{
    int val = 0,in=0;
    for(int i=1;i<mx;i++){

        //if(in>44715) cout<<val<<" "<<in<<endl;
        val+=i;
        if(in==44721+1) break;
        ar[++in] = val;

    }
    //cout<<in<<" "<<ar[in];
    scanf("%d",&num);
    //num=1000000000;

    if(num==1){
        cout<<")("<<endl;
        return 0;
    }
    else if(num==2){
        cout<<")()("<<endl;
        return 0;
    }
    else if(num==3){
        cout<<"))(("<<endl;
        return 0;
    }

    int idx;
    for(int i=1;i<=m;i++){
        if(num<=ar[i]){
            idx = i;
            break;
        }
    }
    //cout<<idx*2+5<<endl;
    int n = ar[idx];

    char x[idx*2+5];

    for(int i=1;i<=idx*2;i++){
        if(i<=idx) x[i] = ')';
        else x[i] = '(';
        //printf("%c",x[i]);
    }

    if(num==n){
        for(int i=1;i<=idx*2;i++) printf("%c",x[i]);
        cout<<endl;
    }
    else{
        int h=idx+1;
        for(int i=n-1;i>1;i--){

            swap(x[h],x[h-1]);
            if(num==i){
                for(int i=1;i<=idx*2;i++) printf("%c",x[i]);
                cout<<endl;
                break;
            }
            h--;
        }
    }

    return 0;
}

Measured memory_bytes: 3392
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  string s;
  cin>>s;
  int n;
  n = s.size();
  int cnt=0;
  REP(i,n){
    if(s[i]=='0'){
      cnt++;
    }
  }
  int ans;
  ans = 2*min(cnt,n-cnt);
  cout<<ans<<endl;
  return 0;
}


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

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mpq priority_queue<int,vector<int>,greater<int>>
#define debug(a) cerr << #a << ": " << a << endl
#define umii unordered_map<int64_t,int64_t>
#define ftt int t;cin>>t;for(int tt=1;tt<=t;++tt)
#define forr(i,n) for((i)=1;(i)<=(n);(i)++)
#define Rev(v) reverse(v.begin(),v.end());
#define Sort(v) sort(v.begin(),v.end());
#define mem(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<"\nhi"<<x<<"\n"
#define pq priority_queue<int>
#define dbg cout<<"\nhi\n"
#define sayy cout<<"YES\n"
#define sayn cout<<"NO\n"
#define int long long
#define double long double
#define pii pair<int,int>
#define mii map<int,int>
#define vb vector<bool>
#define vi vector<int>
#define eb emplace_back
#define nl cout<<"\n"
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define sp <<" "<<
#define se second
#define fi first

const int MOD = 1000000007;
const double PI = 3.1415926535898;
const int LIM = 100005;

using namespace std;

int fpow( int x,int y) {
    int temp;
    if(y == 0)
        return 1;
    temp = fpow(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;}

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

void sieve(int n) {
     bool prime[5*LIM];
     memset(prime, true, sizeof(prime));
     for (int p=2; p*p<=n; p++)
          if (prime[p] == true)
               for (int i=p*p; i<=n; i += p)
                    prime[i] = false;
     prime[1]=0;}

inline int read(){
    int p=1,ans=0;
    char ch=getchar();
    while(ch<48||ch>57)
    {
        if(ch=='-')p=-1;
        ch=getchar();
    }
    while(ch>=48&&ch<=57)
    {
        ans=(ans<<3)+(ans<<1)+ch-48;
        ch=getchar();
    }
    return ans*p;
}

unsigned long long fun(unsigned long long n)
{
    return (n*(n+1))/2;
}

/*int cnt, sum = 0, mid, mx = -1e17, mn = 1e17, a[2*LIM];
int n, m, d, t, i, j, k, l, r, x, y, z;
bool f, f1, f2;
string s;*/

//*************************************************************************************************************************


int32_t main()
{
    int x, y;
    cin>>x>>y;
    if(y < 2*x || y > 4*x)
    {
        cout<<"No";
     return 0;
    }
    if(y % 2 == 0)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}





Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
	GI(N);
	print((N-2)*180);
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,a[1005];
int main()
{
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",a+i);
    rep(i,1,n) {
        if(a[i]%2==0){
            if(a[i]%3!=0 && a[i]%5!=0){
                puts("DENIED");
                return 0;
            }
        }
    }
    puts("APPROVED");
    return 0;
}

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

int main(){
	int x,y,z,n,i,f;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		f=0;
		for(x=1;x<=sqrt(i);x++){
			for(y=1;y<=x;y++){
				for(z=1;z<=y;z++){
					if((x*x + y*y + z*z + x*y + y*z + z*x) == i){
						f+=6;
						if(x==y||y==z||x==z){
							f-=3;
						}
						if(x==y&&y==z){
							f-=2;
						}
					}
				}
			}
		}
		printf("%d\n", f);
	}	
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
#define rSORT(a, i) sort(all(a),(i))

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;
const int MAX_N = 110000; 
constexpr double EPS = 1E-11;

using namespace std;

//fixed << setprecision(10)


//レベルがnのバーガーの下からx枚に含まれるパティの数
//xの値に応じてレベルn-1のバーガーに関する問題にする
ll rec(int n, ll x) {
	if (n == 0)return 1;
	//レベルn - 1のバーガーの長さ
	ll len = (1LL << (n + 1)) - 3;
	//レベルn - 1のバーガーに含まれるパティ
	ll cnt = (1LL << n) - 1;

	if (x == 1)return 0;
	else if (x <= len + 1)return rec(n - 1, x - 1);
	else if (x == len + 2)return cnt + 1;
	else if (x <= (len + 1) * 2)return cnt + 1 + rec(n - 1, x - len - 2);
	else return cnt * 2 + 1;
}


int main() {
	int n; ll x;
	cin >> n >> x;
	cout << rec(n, x) << endl;
}

Measured memory_bytes: 256
s = gets.chomp.chars
#list = {"a" => 0, "b" => 0, "c" => 0, "d" => 0, "e" => 0, "f" => 0, "g" => 0, "h" => 0, "i" => 0, "j" => 0, "k" => 0, "l" => 0, "m" => 0, "n" => 0, "o" => 0, "p" => 0, "q" => 0, "r" => 0, "s" => 0, "t" => 0, "u" => 0, "v" => 0, "w" => 0, "x" => 0, "y" => 0, "z" => 0}
l = "abcdefghijklmnopqrstuvwxyz".chars

s.each do |i|
  l.delete(i)
end

if l.length > 0
  print l[0]
else
  print "None"
end

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

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(i,j,n) for(int i=j;i<(int)n;i++)
#define pb(x) push_back(x)
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define double long double
#define mp(x,y) make_pair(x,y)

typedef long long ll;

using namespace std;


 const int MAX = 5 * 100000 + 1;
 int fact [MAX];
     int MOD = 998244353;
     ll inv(ll x , ll mod){
        ll r, y;
        for(r = 1 , y = mod - 2 ; y != 0 ;x = x * x % mod, y>>=1)
            if ((y & 1) == 1)
                r = r * x % mod;
        return r;
    }
     int ncr (int n, int r) {
     	// cerr<<n<<" "<<r<<"\n";
     	if(r==0)return 1;
        return (int)((ll)fact[n] * ((inv(fact[r], MOD) * inv(fact[n - r], MOD)) % MOD) % MOD) % MOD;
    }
     
     void factorial () {
        fact[0] = fact[1] = 1;
        for (int i = 2; i < MAX; i++)
            fact[i] = (int)((ll)i * fact[i - 1] % MOD);
    }

ll sum[MAX];
ll mem[MAX];


int main() {

        
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n,A,B,k;
    cin>>n>>A>>B>>k;
    factorial();
    int MOD=998244353;
    ll res=0;
    REP(a,n+1){
    	if(1ll*a*A>k)continue;
    	ll r=k-1ll*a*A;
    	if(r%B==0){
    		ll b=r/B;
    		if(max(1ll*a,b)<=n)res+=1ll*ncr(n,a)*ncr(n,b)%MOD;
    		res%=MOD;
    	}
    }
    cout<<res<<"\n";
    
    return 0;
}

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

int main() {
  string a, b, c, d;
  cin >> a >> b >> c;
  d = a+b+c;
  int e = stoi(d);
  if (e%4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#define NIL 500009

int n;

void buildMaxHeap(int A[]){
  int i;
  for(i = n/2; i >= 1; i--){
   maxHeapify(A, i);
  }
}

void maxHeapify(int A[], int i){
  int l, r, largest, tmp;

  l = getLeft(i);
  r = getRight(i);
  if(l <= n && A[l] > A[i]){
    largest = l;
  }else{
    largest = i;
  }
  if(r <= n && A[r] > A[largest]){
    largest = r;
  }
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest);
  }
}

int getLeft(int i){
  i *= 2;
  if(i > n) return NIL;
  else return i;
}

int getRight(int i){
  i = i * 2 + 1;
  if(i > n) return NIL;
  else return i;
}

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

  int heap[n+1];
  for(i = 1; i <= n; i++){
    scanf("%d", &heap[i]);
  }

  buildMaxHeap(heap);
  
  for(i = 1; i <= n ; i++){
    printf(" %d", heap[i]);
  }
  printf("\n");
  return 0;
}

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


int main(){
    char S[100];
    cin >> S;

    bool answer = true;

    for(int i=0; i<strlen(S); i++){
        if(i%2 == 0){
            if(S[i] == 'L'){
                answer = false;
            }
        }
        if(i%2 != 0){
            if(S[i] == 'R'){
                answer = false;
            }
        }
    }

    if(answer){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
H = list(map(int,input().split()))

ans = "Yes"
# 左端は1下げてもデメリットはないので下げておく
H[0] -= 1
for i in range(N-1):
    if H[i] > H[i+1]:
        ans = "No"
        break
    elif H[i] < H[i+1]:
        H[i+1] -= 1

print(ans)

Measured memory_bytes: 14252
#include <iostream>

using namespace std;

int main(){
  int D,G,p[11],c[11];
  cin>>D>>G;
  for(int i=0;i<D;i++){
    cin>>p[i]>>c[i];
  }

  int ans=1e9;
  for(int mask=0;mask<(1<<D);mask++){
    int s=0,num=0,rest_max=-1;
    for(int i=0;i<D;i++){
      if(mask&(1<<i)){
        s+=100*(i+1)*p[i]+c[i];
        num+=p[i];
      }
      else{
        rest_max=i;
      }
    }
    if(s<G){
      int s1=100*(rest_max+1);
      int need=(G-s+s1-1)/s1;
      if(need>=p[rest_max]){
        continue;
      }
      num+=need;
    }
    ans=min(ans,num);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BPhuong ""
#define maxn  100005
#define maxm
#define fi(i,a,b) for(int i = a; i<= b; i++)
#define fid(i,a,b) for(int i = a; i>= b; i--)
#define se second
#define f first
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define bit(x, i) ((x>>i)&1)
#define oo 1e9
struct data{
    int x, y, z;
};
using namespace std;
int n, pa[maxn], mod;
ll  l[maxn][2];
vector <int> a[maxn];
void dfs(int u)
{
    l[u][1] = 1;
    l[u][0] = 1;
    for(int i = 0; i < a[u].size(); i++)
    {
        int v = a[u][i];
        if(pa[u] != v)
        {
            pa[v] = u;
            dfs(v);
            l[u][0] *= ( (l[v][1] + l[v][0]) % mod );
            l[u][1] *= l[v][0];
            l[u][0] %= mod;
            l[u][1] %= mod;
        }
    }
}
void nhap(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    //freopen(BPhuong".inp","r",stdin);
    //freopen(BPhuong".out","w",stdout);
    cin >> n;
    mod = 1e9 + 7;
    fi(i, 1, n-1)
    {
        int u, v;
        cin >> u >> v;
        a[u].pb(v);
        a[v].pb(u);
    }
}

void xuli(){
    dfs(1);
    cout << ( l[1][0] + l[1][1]) % mod;
}

int main(){
    nhap();
    xuli();
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  ll h, w;
  cin >> h >> w;
  ll m = h * w;

  if(h == 1 || w == 1) cout << 1 << endl;
  else if(m % 2 == 0) cout << m / 2 << endl;
  else cout << m / 2 + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;


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

	if (N >= 10) {
		cout << R << endl;
	}
	else {
		cout << R + 100 * (10 - N) << endl;
	}
	return 0;
} 

Measured memory_bytes: 3584
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

int main(){
int a,b,c;
cin>>a>>b;
if(a>b)
{
	c=a;
	a--;
}
else {
c=b;
b--;
}
if(a>b)
{
	c=c+a;
}
else c=c+b;

cout<<c;
return 0;

}


Measured memory_bytes: 256
H,W,K = gets.split.map(&:to_i)
C = H.times.map{ gets.chomp }
ans = 0
all = (0...H).sum{|h| C[h].count("#")}

(0...2**H).each do |hh|
  counth = []
  (0...H).each{|h| (0...W).each{|w| counth << [h,w] if C[h][w] == "#"} if hh & 2**h != 0}
  (0...2**W).each do |ww|
    counthw = counth.clone
    (0...W).each{|w| (0...H).each{|h| counthw << [h,w] if C[h][w] == "#"} if ww & 2**w != 0}
    ans += 1 if counthw.uniq.size == (all - K)
  end
end

puts ans

Measured memory_bytes: 14216