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


uint32_t bit_flag[17];
uint32_t bit_low_all[17];

std::vector<uint32_t> gen(const uint16_t n, const uint32_t a,
  const uint32_t b) {
  if (n == 0) {
    return {a, b};
  } else {
    std::bitset<17> bit(a^b);
    uint16_t diff = 0;
    for (uint16_t i = 0; i < 17; i++) {
      if (bit[16 - i]) {
        diff = 16 - i;
        break;
      }
    }
    bool a_diff_bit = (a & bit_flag[diff]) != 0;

    uint32_t a_v, b_v, c_v;
    if (diff == 0) {
      a_v = a >> 1;
      b_v = b >> 1;
      c_v = a_v ^ bit_flag[n - 1];
    } else if (diff == n) {
      a_v = a & bit_low_all[n - 1];
      b_v = b & bit_low_all[n - 1];
      c_v = a & bit_low_all[n - 1];
      c_v = a_v ^ bit_flag[0];
    } else {
      a_v = ((a & ~bit_low_all[diff]) >> 1) | (a & bit_low_all[diff - 1]);
      b_v = ((b & ~bit_low_all[diff]) >> 1) | (b & bit_low_all[diff - 1]);
      c_v = a_v ^ bit_flag[n - 1];
    }
    const auto before = gen(n - 1, a_v, c_v);
    const auto after = gen(n - 1, c_v, b_v);
    std::vector<uint32_t> result(before.size() + after.size());
    const auto itr
      = std::copy(before.cbegin(), before.cend(), result.begin());
    std::copy(after.cbegin(), after.cend(), itr);

    for (size_t i = 0; i < before.size(); i++) {
      if (diff == 0) {
        result[i] <<= 1;
        if (a_diff_bit) {
          result[i] |= bit_flag[0];
        }
      } else if (diff == n) {
        if (a_diff_bit) {
          result[i] |= bit_flag[n];
        }
      } else {
        result[i] = ((result[i] & ~bit_low_all[diff - 1]) << 1) |
          (result[i] & bit_low_all[diff - 1]);
        if (a_diff_bit) {
          result[i] |= bit_flag[diff];
        }
      }
    }
    for (size_t i = before.size(); i < before.size() + after.size(); i++) {
      if (diff == 0) {
        result[i] <<= 1;
        if (!a_diff_bit) {
          result[i] |= bit_flag[0];
        }
      } else if (diff == n) {
        if (!a_diff_bit) {
          result[i] |= bit_flag[n];
        }
      } else {
        result[i] = ((result[i] & ~bit_low_all[diff - 1]) << 1) |
          (result[i] & bit_low_all[diff - 1]);
        if (!a_diff_bit) {
          result[i] |= bit_flag[diff];
        }
      }
    }
    return result;
  }
}

int main() {
  uint16_t n;
  uint32_t a, b;
  std::cin >> n >> a >> b;

  bit_flag[0] = 1;
  bit_low_all[0] = 1;
  for (uint16_t i = 1; i < 17; i++) {
    bit_flag[i] = 2 * bit_flag[i - 1];
    bit_low_all[i] = bit_low_all[i - 1] + bit_flag[i];
  }

  std::bitset<17> bit(a^b);
  if (bit.count() % 2 == 0) {
    std::cout << "NO" << std::endl;
  } else {
    std::cout << "YES" << std::endl;
    const auto val = gen(n - 1, a, b);
    for (size_t i = 0; i < val.size(); i++) {
      std::cout << val[i];
      if (i + 1 != val.size()) {
        std::cout << " ";
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){

    ll n;
    cin >> n;

    string s;
    cin >> s;

    rep(i, 0, s.size()){
        if(s[i] + n > 'Z'){
            cout << char(s[i] + n - 'Z' + 'A' - 1);
        }else{
            cout << char(s[i] + n);
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FILEIN freopen("input.txt", "r", stdin)
using namespace std;

#define ll long long
#define endl "\n"

const ll INF = 1e9;

int main(){
    // FILEIN;
    string s;
    cin>>s;
    for(int i = 0; i<s.length(); i++){
        if(s[i] == s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
        if((i + 2 < s.length()) && s[i] == s[i + 2]){
            cout<<i + 1<<" "<<i + 3<<endl;
            return 0;
        }
    }
    cout<<"-1 -1"<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int n,r;
    cin>>n>>r;
    if(r==10)
    {
    	string s=to_string(n);
    	cout<<s.length();
    }
    else
    {
    	int cnt=0;
    	while(n>=1)
    	{
    		n/=r;
    		cnt++;
    	}
    	cout<<cnt;
    }
    return 0;
}		

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
class Range {
    using T = long long;
    class Iterator {
        T val, step, diff;
    public:
        Iterator(T v, T s, T d): val(v), step(s), diff(d) {}
        T operator*() { return val + diff; }
        bool operator!=(const Iterator &itr) { return step > 0 ? val < itr.val : val > itr.val; }
        Iterator operator++() { val += step; return *this; }
    };
    Iterator _begin, _end;
public:
    Range(T b, T e, T s, T d): _begin(b, s, d), _end(e, s, d) {
        if (s < 0) { _begin = Iterator(e - 1, s, d); _end = Iterator(b - 1, s, d); }
    }
    Range(T b, T e, T s): Range(b, e, s, 0) {}
    Range(T b, T e): Range(b, e, 1, 0) {}
    Range(T e): Range(0, e, 1, 0) {}
    Iterator begin() { return _begin; }
    Iterator end() { return _end; }
};
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin, n, m;
    vector<int> h(n);
    for (auto &hh : h) {
        cin, hh;
    }
    vector<vector<int>> G(n);
    for (auto i : Range(m)) {
        int a, b;
        cin, a, b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 0;
    for (ll i : Range(n)) {
        bool check = true;
        for (auto v : G[i]) {
            if (h[i] <= h[v]) {
                check = false;
            }
        }
        ans += check;
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 8740
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct process proc;

struct process {
    char name[11];
    int t;
    proc *prev;
    proc *next;
};

void add(proc *p, char s[11], int t) {
    int i;
    proc *new;
    new = (proc*)malloc(sizeof(proc));
    strcpy(new->name, s);
    new->t = t;
    p->next = new;
    new->prev = p;
}

void rm(proc *p) {
    p->prev->next = p->next;
    p->next->prev = p->prev;
}

int main() {
    int n, q;
    char name[11];
    int t, cnt = 0;
    int i;

    scanf("%d %d", &n, &q);
    proc *head = (proc*)malloc(sizeof(proc));
    proc *tail = head;
    for(i = 0; i < n; i++) {
        scanf("%s %d", name, &t);
        add(tail, name, t);
        tail = tail->next;
    }
    head = head->next;
    tail->next = head;
    head->prev = tail;

    proc *p = head;
    while(1) {
        if (p->t <= q) {
            cnt += p->t;
            printf("%s %d\n", p->name, cnt);
            if (p->next == p) break;
            else rm(p);
        } else {
            p->t -= q;
            cnt += q;
        }
        p = p->next;
    }
    return 0;
}

Measured memory_bytes: 4196
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t; using i64 = int64_t; using f64 = double_t; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(n, m, i) for (i32 i = (n); i < (m); ++i)
#define upto(n, m, i) for (i32 i = (n); i <= (m); ++i)
#define downto(n, m, i) for (i32 i = (n); i >= (m); --i)
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i64 n, x;
i64 a[2000], b[2000];

i32 main()
{
    cin >> n >> x;
    times(n, i) {
        cin >> a[i];
        b[i] = a[i];
    }

    i64 ans = LLONG_MAX;
    times(n, i) {
        i64 t = 0;
        times(n, j) {
            b[j] = min(b[j], a[(j-i+n)%n]);
            t += b[j];
        }
        t += x*i;
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}

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

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

    ll ans = -1;

    for(ll i = 0; i <= 10000; i++)
    {
        if(i * 8 / 100 == A && i * 10 / 100 == B)
        {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9;
int n,m,f[110][110];
char mp[110][110];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",mp[i]+1);
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)f[i][j]=INF;
	f[1][1]=(mp[1][1]=='#');
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j){
		if(i<n)f[i+1][j]=min(f[i+1][j],f[i][j]+(mp[i][j]=='.'&&mp[i+1][j]=='#'));
		if(j<m)f[i][j+1]=min(f[i][j+1],f[i][j]+(mp[i][j]=='.'&&mp[i][j+1]=='#'));
	}
	printf("%d",f[n][m]);
	return 0;
}

Measured memory_bytes: 256
import sys
N, M, P = map(int, input().split())

Edgeinv = [[] for _ in range(N+1)]
Edge = [[] for _ in range(N+1)]
inf = 2*10**10
Edgenum = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)]
for a, b, c in Edgenum:
    Edgeinv[b].append(a)
    Edge[a].append(b)

used = set([N])
stack = [N]
while stack:
    vn = stack.pop()
    for vf in Edgeinv[vn]:
        if vf not in used:
            used.add(vf)
            stack.append(vf)

used2 = set([1])
stack = [1]
while stack:
    vn = stack.pop()
    for vf in Edge[vn]:
        if vf not in used2:
            used2.add(vf)
            stack.append(vf)

Edgenum = [(a, b, c) for a, b, c in Edgenum if a in used and b in used]

used &= used2

dp = [-inf]*(N+1)
dp[1] = 0
for i in range(N-1):
    dp2 = dp[:]
    for a, b, c in Edgenum:
        dp2[b] = max(dp2[b], dp[a] + c - P)
    dp = dp2[:]

Dp = dp[:]
for i in range(N):
    dp2 = dp[:]
    for a, b, c in Edgenum:
        dp2[b] = max(dp2[b], dp[a] + c - P)
    dp = dp2[:]

if any(Dp[i] < dp2[i] for i in used):
    print(-1)
else:
    print(max(0, Dp[N]))


Measured memory_bytes: 50012
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    set<ll> v;
    ll n;cin>>n;
    REP(i,n){
        ll a;cin>>a;
        if(v.find(a)!=v.end()){
            v.erase(a);
        }else{
            v.insert(a);
        }
    }
    cout<<v.size()<<endl;
    return 0;
}


Measured memory_bytes: 8152
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, P = MI()
    A = LI()

    odd = 0
    even = 0
    for a in A:
        if a % 2 == 0:
            even += 1
        else:
            odd += 1
    if odd == 0:
        # 全て偶数
        if P == 0:
            print(pow(2, even))
        else:
            print(0)
    else:
        # 奇数が存在する
        # 一つの奇数に着目すると、それ以外の数の合計が奇数か偶数になるかによって
        # 選ぶ選ばないを選択することでPにすることができる
        print(pow(2, N-1))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9264
import math

n,k=map(int,input().split())
if k%2!=0:
    nums=math.floor(n/k)
    print(nums**3)
 
else:
    nums1=math.floor(2*n/k)

    if nums1%2==0:
        a=int(nums1/2)
        b=nums1-a
        print(a**3+b**3)
    
    
    if nums1%2!=0:
        a=int((nums1+1)/2)
        b=nums1-a
        print(a**3+b**3)

Measured memory_bytes: 3060
using System;

namespace LevelC
{
    class Program
    {
        static void Main(string[] args)
        {

            var x = int.Parse(Console.ReadLine());
            var buf = 0;
            for(int i = 1; i < x+1; i++)
            {
                for(int j = 1; j < x+1; j++)
                {
                    for(int k = 1; k < x+1; k++)
                    {
                        buf += Judge(i, j, k);
                    }
                }
            }

            Console.WriteLine(buf.ToString());
        }

        private static int Judge(int x,int y, int z)
        {
            var buf1 = Judge2(x, y);
            var buf2 = Judge2(buf1, z);
            return buf2;
        }

        private static int Judge2(int x,int y)
        {
            var Max = Math.Max(x, y);
            var Bigger = 0;
            var Min = 0;
            var buf = 0;

            if (Max > y) {
                Bigger = x;
                Min = y;

            }
            else if(Max > x)
            {
                Bigger = y;
                Min = x;
            }
            else
            {
                return x;
            }

            while (true)
            {
                buf = Bigger % Min;
                if (buf == 0)
                    return Min;
                else
                {
                    Bigger = Min;
                    Min = buf;
                }
            }
        }
    }

}


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

int main(){
    vector<int>x(3);
    rep(i,3)cin >> x[i];
    sort(all(x));
    int a = x[0],b = x[1],c = x[2];
    int sum = a+b+c;
    //cout << sum << " " << 3*c << endl;
    if(c%2 == sum%2)cout << (3*c-sum)/2 << endl;
    else cout << (3*c+3-sum)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int x, t;
  cin >> x >> t;
  cout << max(0, x-t) << endl;
  return 0;
}

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

int n,k;
int a[INF];
int mem[100005][3];

bool rec(int tot,int player)
{
	if(mem[tot][player]!=-1) return mem[tot][player];
	bool ans=false;
	if(player==0)
	{
		for(int i=0;i<n;i++)
		{
			if(tot-a[i]>0)
			{
				bool next=rec(tot-a[i],player^1);
				if(next==false)
				{
					ans=true;
				}
			}else
			if(tot-a[i]==0)
			{
				ans=ans|true;
			}
		}
	}else
	{
		for(int i=0;i<n;i++)
		{
			if(tot-a[i]>0)
			{
				bool next=rec(tot-a[i],player^1);
				if(next==false)
				{
					ans=true;
				}
			}else
			if(tot-a[i]==0)
			{
				ans=ans|true;
			}
		}
	}
	return mem[tot][player]=ans;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    memset(mem,-1,sizeof(mem));
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> a[i];
    bool ans=false;
	for(int i=0;i<n;i++)
	{
		bool next=rec(k-a[i],1);
		if(next==false)
		{
			ans=true;
		}
	}
	if(ans==true)
	{
		cout << "First" << "\n";
	}else
	{
		cout << "Second" << "\n";
	}
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define vec vector
#define fi first
#define se second
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define cout(a) cout << a << " "
#define vcout(v) rep(i,v.size()) cout(v[i]); cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
#define bit(x) (1ll<<(x))

int main(){
	ll n, q;
	cin >> n >> q;
	
	vec<vec<ll>> to(n);
	rep(i,n-1){
		ll a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	vec<ll> ans(n);
	
	rep(i,q){
		ll p, x;
		cin >> p >> x;
		--p;
		ans[p] += x;
	}
	
	function<void(ll,ll)> dfs;
	dfs = [&](ll v, ll par) -> void{
		for(int child : to[v]){
			if(child == par) continue; // 自分の親にはカウンタは足さない
			ans[child] += ans[v]; // 子に自分のカウンタを足す
			dfs(child, v);
		}
	};
	
	dfs(0,-1);
	
	vcout(ans);
	return 0;
}


Measured memory_bytes: 30464
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

struct Node {
    using NP = Node*;
    NP l, r;
    int sz, mi;
    Node(int sz) : sz(sz), l(nullptr), r(nullptr) {
        mi = TEN(9);
        if (sz == 1) return;
        l = new Node(sz/2);
        r = new Node(sz-sz/2);
    }
    void set(int k, int x) {
        if (sz == 1) {
            mi = min(mi, x);
            return;
        }
        if (k < sz/2) {
            l->set(k, x);
        } else {
            r->set(k-sz/2, x);
        }
        mi = min(l->mi, r->mi);
    }

    int get(int a, int b) {
        if (b <= 0 || sz <= a) return TEN(9);
        if (a <= 0 && sz <= b) return mi;
        return min(l->get(a, b), r->get(a-sz/2, b-sz/2));
    }
};

int main() {
    int off = 0;
    int n;
    scanf("%d", &n);
    V<int> b(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &(b[i]));
        if (!b[i]) {
            b[i]--;
            off++;
        }
    }
    VV<int> g(n+1);
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        int x, y;
        scanf("%d %d", &x, &y); x--;
        g[x].push_back(y);
    }
    Node* tr = new Node(n+10);
    for (int i = 0; i <= n; i++) {
        if (i) {
            tr->set(i, tr->get(i-1, i) + b[i-1]);
        } else {
            tr->set(0, 0);
        }
        for (int d: g[i]) {
            tr->set(d, tr->get(i, d));
        }
    }
    printf("%d\n", off + tr->get(n, n+1));
    return 0;
}


Measured memory_bytes: 23808
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */
/* include {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;
/* }}} */

// #define int long long

/* cpp template {{{ */
/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

bool same(vector<pair<int, ll> >& t, int num, ll p)
{
  bool ok = true;
  REP(i, t.size()){
    if (num == t[i].Fi){
      ok = false;
      t[i].Se += p;
      break;
    }
  }

  return ok;
}

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

  int n;
  while (cin >> n, n){
    vector<pair<int, ll> > table;
    REP(i, n){
      int num; ll price, cnt;
      cin >> num >> price >> cnt;
      if (same(table, num, price * cnt)){
        table.pb(mp(num, price * cnt));
      }
    }
    bool only = true;
    REP(i, table.size()){
      if (table[i].Se >= 1e6){
        print(table[i].Fi);
        only = false;
      }
      //cout << table[i].Fi << " " << table[i].Se << endl;
    }
    if (only) print("NA");
  }

  return (0);
}

Measured memory_bytes: 1248
N = int(input())
grid = []
for _ in range(N):
    grid.append(input())

col_info = [0] * N
for j in range(N):
    cnt = 0
    for i in range(N):
        if grid[i][j] == '#':
            cnt += 1
        else:
            cnt -= 1
    if cnt == N:
        col_info[j] = 1
    elif cnt == -N:
        col_info[j] = -1

if sum(col_info) == N:
    print(0)
    exit()
elif sum(col_info) == -N:
    print(-1)
    exit()

ans = 10**9
for i in range(N):
    ans_new = N - col_info.count(1)
    if col_info[i] == -1:
        ans_new += 1
    for j in range(N):
        if grid[i][j] == '.':
            ans_new += 1
    ans = min(ans, ans_new)

print(ans)


Measured memory_bytes: 41328
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

struct Combination
{
  int mod;
  vector< int64_t > mfact, rfact;

  Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod)
  {
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const
  {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const
  {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const
  {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const
  {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const
  {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const
  {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

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

    if (X > Y) {
        int tmp = Y;
        Y = X;
        X = tmp;
    }

    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
    }
    else {
        Combination c(10000000, 1000000007);
        int x = (X + Y) / 3;
        int k = X - x;
        cout << c.C(x, k) << endl;
    }

    return 0;
}


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

int Judge(char a, char b)
{
    if (b == 'D')
    {
        if (a == 'P')
        {
            return 2;
        }
        return 1;
    }
    return 0;
}

int main()
{
    string str;
    int count = 0;
    cin >> str;
    for (auto c : str)
    {
        if (c == '?')
            count++;
    }
    if(str[0] == '?'){
        str[0] = 'D';
    }

    for (int i = 1; i <= (int)str.size(); i++)
    {
        if(str[i] == '?'){
            if (Judge(str[i - 1], 'D') >= Judge(str[i - 1], 'P'))
            {
                str[i] = 'D';
            }
            else
            {
                str[i] = 'P';
            }
        }
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 3756
#include<algorithm>
#include<iostream>
#include<cstring>
#include<queue>
#include<string>
#include<cmath>
using namespace std;
const double eps=1e-16;
int main(){
	int n,t,A;
	cin>>n>>t>>A;
	int h[100005];
	double T[100005];
	int ans=1;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		T[i]=t-h[i]*0.006;
		if(fabs(T[i]-A)<fabs(T[ans]-A)){
			ans=i;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double bt=380000;
int n;
double a,ans;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=0;i<n;++i)
	{
		cin>>a>>s;
		if (s=="JPY") ans+=a;
		else ans+=a*bt;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

int main()
{
  long long int A, B, C, D; cin >> A >> B >> C >> D;

  auto func = [&](long long int X) {  
    //ユークリッドの互除法で最大公約数を求める
    long long int m = C;
    long long int n = D;
    while (m%n != 0) {
      long long int tmp = n;
      n = m%n;
      m = tmp;
    }

    // CDの最小公倍数を求める
    long long int l = C * D / n;

    return X - (X/C + X/D) + X/l;
  };
  long long int count = func(B) - func(A - 1);
  cout << count << endl;
}

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

long long n, a, s=1, mx=1e18, fl;
int main() {
	cin >> n;
	while(n--) {
		scanf("%lld", &a);
		if(!a) return puts("0"), 0;
		if(a > mx/s) fl = 1;
		else s *= a;
	}
	cout << (fl ? -1 : s);
	return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <string>
#include <math.h>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define bet(min,max,n) if (! (min < n && n < max) )
#define bet_omin(min,max,n) if (! (min <= n && n < max) )
#define bet_omax(min,max,n) if (! (min < n && n <= max) )
#define rep(i,n) for (int i = 0; i < n; i++)

typedef long long unsigned int ll;
using namespace std;

int main()
{
    string S;
    cin >> S;
    int v = 0;
        rep(i, (S.length() / 2)  ) {
            if(S[i] != S[S.length()-1-i]){
                v += 1;
            }
        }
    cout << v << endl;
    return 0;
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  vector<vector<int>> dp(N+5, vector<int>(N+5, 0));
  for (int i = N-1; i >= 0; i--) {
    for (int j = N-1; j >= 0; j--) {
      if (S.at(i) != S.at(j)) dp.at(i).at(j) = 0;
      else dp.at(i).at(j) = dp.at(i+1).at(j+1) + 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i >= j) continue;
      int tmp = min(dp.at(i).at(j), j-i);
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
}

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

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

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    if ((a % 2 == 1) && (i % 2 == 0))
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string s;
   cin >> s;
   bool flag = false;
   int n = s.length();
   for(int i = 0;i < s.length();i++) {
       if(s[i] != s[s.length()-i-1]) {
           flag = true;
       }
   }
   if(flag) {
       cout << "No" << endl;
       return 0;
   }
   for(int i = 0;i < (n-1)/2;i++) {
       if(s[i] != s[(n-1)/2-1-i]) {
           flag = true;
       }
   }
   if(flag) {
       cout << "No" << endl;
       return 0;
   }
   for(int i = (n+3)/2;i < n;i++) {
       if(s[i] != s[n-1-i]) {
           flag = true;
       }
   }
   if(flag) {
       cout << "No" << endl;
       return 0;
   } else {
       cout << "Yes" << endl;
   }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long gcd(long long a,long long b)
{
if(!b)return a;return gcd(b,a%b);
}
long long T,N,rez;
int main()
{
cin>>N;
cin>>rez;N--;
while(N--){cin>>T;rez=(rez/gcd(rez,T))*T;}
cout<<rez;
}

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 s = a+b;
		if(a+b>=24) {
			s -= 24;
		}
		
		System.out.println(s);

	}

}

Measured memory_bytes: 22608
#include<cstdio>
#include<algorithm>
#define N 100010

using namespace std;

int n, m, up_lim, ans;
int a[N], div_l[N], div_r[N], x_l[N], x_r[N], x_m[N];

int main(){
	int i, x, p, a0, t, l, r, mid;
	scanf("%d", &up_lim);
	scanf("%d", &n);
	for(i = 1; i <= n; ++i) scanf("%d", &a[i]);
	
	div_l[0] = -1; div_r[0] = up_lim + 1;
	x_l[0] = -1; x_m[0] = 0; x_r[0] = up_lim + 1;
	for(i = 1; i <= n; ++i){
		x = a[i] - a[i-1];
		
		div_l[i] = div_l[i-1]; div_r[i] = div_r[i-1];
		x_l[i] = x_l[i-1]; x_m[i] = x_m[i-1]; x_r[i] = x_r[i-1];
		if(i & 1){
			if(x_r[i] <= x){
				div_l[i] = up_lim;
				div_r[i] = up_lim + 1;
				x_l[i] = 0;
			} else {
				p = x - x_m[i];
				div_l[i] = max(min(div_r[i]-1, p), div_l[i]);
				if(x_l[i] <= x) x_l[i] = 0; else x_l[i] -= x;
				x_m[i] -= x; x_r[i] -= x;
			}
		} else {
			if(x_l[i] + x >= up_lim){
				div_l[i] = -1;
				div_r[i] = 0;
				x_r[i] = up_lim;
			} else {
				p = up_lim - x - x_m[i];
				div_r[i] = min(max(div_l[i]+1, p), div_r[i]);
				if(x_r[i] + x >= up_lim) x_r[i] = up_lim; else x_r[i] +=x;
				x_l[i] += x; x_m[i] += x;
			}
		}
	}
	
	scanf("%d", &m);
	for(i = 1; i <= m; ++i){
		scanf("%d %d", &t, &a0);
		p = 0; l = 1; r = n;
		while(l <= r){
			mid = l + r >> 1;
			if(t >= a[mid]) l = (p = mid) + 1; else r = mid - 1;
		}
		if(a0 <= div_l[p]) ans = x_l[p]; else
			if(a0 >= div_r[p]) ans = x_r[p]; else
				ans = a0 + x_m[p];
		if(p & 1){
			ans += t - a[p];
			ans = min(up_lim, ans);
		} else {
			ans -= t - a[p];
			ans = max(0, ans);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>
long long n, a, b, c, d, e;
int main() {
	scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
	n--;
	for (long long i = 0; i <= n; i++) {
		if (c * i - d * (n - i) <= a - b && a - b <= d * i - c * (n - i))e = 1;
	}
	if (e)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 128
import math
a,b,x = map(int,input().split())
if x >= a*a*b / 2:
    flag =1
    l = b-(x*2/(a*a)-b)
    res = math.atan(l/a)*180/math.pi
else:
    flag = 2
    l = x*2/(a*b)
    res = math.atan(b/l)*180/math.pi
print(res)



Measured memory_bytes: 3060
N = int(input())
S1 = input()
S2 = input()
 
result = 3
if N != 1:
    i=1
    while i < N:
        if i==1:
            result *= 2
        elif S1[i-1]==S2[i-1]:
            result *=2
        elif S1[i-1]!=S1[i]:
            if S1[i] != S2[i]:
                result *= 3
        i += 1
 
print(result%1000000007) 


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)


int dpx[8005][18000], dpy[8005][18000];


int main(){
    string s;
    int x,y;
    cin>>s>>x>>y;
    s+='T';
    int dx=0;
    for(auto &v: s){
        if(v=='F') dx++;
        else break;
    }
    vector<int> px, py;
    bool tate=true;
    int cnt=0;
    for(int i=dx; i<s.size(); ++i){
        if(s[i]=='T'){
            tate=!tate;
            if(cnt!=0){
                if(tate){
                    py.push_back(cnt);
                }else{
                    px.push_back(cnt);
                }
            }
            cnt=0;
        }else{
            cnt++;
        }
    }
    int lx=px.size(), ly=py.size();
    dpx[0][dx+9000]=1;
    dpy[0][9000]=1;
    rep(i,lx){
        rep(j,18000){
            if(j+px[i]<18000 && dpx[i][j+px[i]]==1 || j-px[i]>0 && dpx[i][j-px[i]]==1){
                dpx[i+1][j]=1;
            }
        }
    }
    rep(i,ly){
        rep(j,18000){
            if(j+py[i]<18000 && dpy[i][j+py[i]]==1 || j-py[i]>0 && dpy[i][j-py[i]]==1){
                dpy[i+1][j]=1;
            } 
        }
    }
    if(dpx[lx][9000+x]==1 && dpy[ly][9000+y]==1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 50928
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	if(s.size() % 2){
		cout << "No";
		return 0;
	}
	for(int i = 0; i < s.size(); i += 2){
		if(s.substr(i, 2) != "hi"){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 256
#include <stdio.h>
main()
{
  int h,n,s=0;
  scanf("%d%d",&h,&n);
  int a[n];
  for(int i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    s=s+a[i];
  }
  if(h<=s)
  {
    printf("Yes\n");
  }
  else
  {
     printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2004
#include<iostream>
#include<string>
using namespace std;
int main()
{
     string s;
     long long n,i,ac=0,wa=0,tle=0,re=0;
     cin>>n;
     for(i=1;i<=n;i++)
     {
         cin>>s;
         if(s[0]=='A')
         {
             ac++;
         }
         else if(s[0]=='W')
         {
             wa++;
         }
         else if(s[0]=='T')
         {
             tle++;
         }
         else if(s[0]=='R')
         {
             re++;
         }
     }
     cout<<"AC x "<<ac<<endl;
     cout<<"WA x "<<wa<<endl;
     cout<<"TLE x "<<tle<<endl;
     cout<<"RE x "<<re<<endl;
     return 0;

}

Measured memory_bytes: 3624
/**
*    created: 27.06.2020 18:26:40
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;
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;}

signed main() {

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

    int a, b;
    cin >> a >> b;
    int t = b - a;
    cout << t*(t+1)/2 - b << endl;
    return 0;
}

Measured memory_bytes: 3644
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[300005] = {};
ll C[2][300005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}



int main() {
	
	cin >> N;

	for (ll i = 0; i < N; i++) {
		cin >> A[i];
		B[A[i]-1] = i;
	}

	for (ll i = 0; i < N; i++) {
		cout << (i+1) * 40000 + B[i] << " ";
	}
	cout << endl;

	for (ll i = 0; i < N; i++) {
		cout << (N-i) * 40000 << " ";
	}

	cout << endl;

	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;



}


Measured memory_bytes: 8832
#include<iostream>
#include<string>
using namespace std;
int main(){
	
	int num;
	string i;
	int num2;
	
	cin>>num>>i>>num2;
	
	if(i=="+"){
	cout<<num + num2<<endl;
	}else{
	cout<<num - num2<<endl;
	}

	

return 0;

}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#define int long long

using namespace std;

typedef long long ll;

ll C[3010][3010], G[3010][3010], K1[3010], K2[3010], F[3010], n, P;

ll phi(ll x) {
    ll ans = 1;
    for(int i = 2; i * i <= x; i++) if(x % i == 0) {
        ans *= i - 1;
        x /= i;
        while(x % i == 0) x /= i, ans *= i;
    }
    if(x != 1) ans *= x - 1;
    return ans;
}

ll powmod(ll x, ll y, ll p) {
    ll ans = 1;
    while(y) {
        if(y & 1) ans = ans * x % p;
        x = x * x % p;
        y >>= 1;
    }
    return ans;
}

#undef int
int main() {
#define int long long
    scanf("%lld%lld", &n, &P);
    for(int i = 0; i <= n; i++) K2[i] = !i ? 2 : K2[i - 1] * K2[i - 1] % P, K1[i] = !i ? 1 : K1[i - 1] * 2 % P;
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= i; j++) {
            C[i][j] = !j ? 1 : (C[i - 1][j - 1] + C[i - 1][j]) % P;
            G[i][j] = !j ? 1 : (G[i - 1][j - 1] + G[i - 1][j] * (j + 1)) % P;
        }
    ll ans = 0, ph = phi(P);
    for(int i = 0; i <= n; i++)
        for(int j = 0, s = 1; j <= i; j++, s = s * K1[n - i] % P)
            ans = (ans + (i & 1 ? -1 : 1) * C[n][i] * G[i][j] % P * s % P * K2[n - i]) % P;
    printf("%lld\n", (ans % P + P) % P);
    return 0;
}

Measured memory_bytes: 139904
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	cout<<(H*W)-((h*W+H*w)-h*w)<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        BigInteger seed = new BigInteger("90000");
        BigInteger[] a = new BigInteger[N];
        //a[0]=seed.nextProbablePrime();
        for(int n=0;n<N;n++) a[n] = new BigInteger(sc.next());
        
        BigInteger m = BigInteger.ONE;
        for(int n=0;n<N;n++) m = m.multiply(a[n]);
        m = m.subtract(BigInteger.ONE);
        
        BigInteger ans = BigInteger.ZERO;
        for(int n=0;n<N;n++){
        	ans = ans.add(m.mod(a[n]));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 45596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e3 + 10;

vi g[N];
int d[N], cnt[N];
bool vis[N];

void bfs(int v) {
	queue<int> q;
	q.push(v);
	vis[v] = 1;
	while(!q.empty()) {
		int cur = q.front();
		q.pop();
		for(auto it : g[cur]) {
			if(!vis[it]) {
				vis[it] = 1;
				d[it] = d[cur] + 1;
				q.push(it);
			}
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	for(int i = 1; i < n; i++) {
		g[i].pb(i + 1);
		g[i + 1].pb(i);
	}
	int x, y;
	cin >> x >> y;
	g[x].pb(y);
	g[y].pb(x);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			vis[j] = 0;
			d[j] = 0;
		}
		bfs(i);
		for(int j = i + 1; j <= n; j++) {
			cnt[d[j]]++;
		}
	}
	for(int i = 1; i < n; i++) {
		cout << cnt[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
struct node
{
	int l,r,d;
}a[300010];
int n,m,bit[100010];
bool cmp(node x,node y)
{
	return x.d<y.d;
}
inline int lowbit(int x)
{
	return x&(-x);
}
void add(int x,int v)
{
	for (;x<=m;x+=lowbit(x))
	{
		bit[x]+=v; 
	}
}
int ask(int x)
{
	int res=0;
	for (;x;x-=lowbit(x))
	{
		res+=bit[x];
	}
	return res;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++)
	{
		scanf("%d%d",&a[i].l,&a[i].r);
		a[i].d=a[i].r-a[i].l+1;
	}
	sort(a,a+n,cmp);
	int k=0;
	for (int i=1;i<=m;i++)
	{
		while (k<n && a[k].d<i)
		{
			add(a[k].l,1);
			add(a[k].r+1,-1);
			k++;
		}
		int res=n-k;
		for (int j=i;j<=m;j+=i)
		{
			res+=ask(j);
		}
		printf("%d\n",res);
	}
    return 0;
}
//客舍并州已十霜，归心日夜忆咸阳。
//无端更渡桑乾水，却望并州是故乡。
//——刘皂《旅次朔方》

Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

int p = 37;
int n = p * p + p + 1;
vector<int> a[2020];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	for (int x = 0; x < p; x++)
		for (int y = 0; y < p; y++) {
			for (int z = 0; z < p; z++) {
				int t = y - z * x;
				t %= p;
				if (t < 0) t += p;
				a[z * p + t].push_back(x * p + y);
			}
			a[p * p + x].push_back(x * p + y);
		}
	for (int x = 0; x < p; x++)
		for (int y = 0; y < p; y++)
			a[p * x + y].push_back(p * p + x);
	for (int x = 0; x < p; x++)
		a[p * p + p].push_back(p * p + x);
	for (int i = 0; i <= p; i++)
		a[p * p + i].push_back(p * p + p);

	printf("%d %d\n", n, p + 1);
	for (int i = 0; i < n; i++) {
		for (int x : a[i])
			printf("%d ", x + 1);
		printf("\n");
	}


	return 0;
}


Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main() {
    int D;
    cin >> D;
    switch(D) {
        case 25:
            cout << "Christmas" << endl;
        break;
        case 24:
            cout << "Christmas Eve" << endl;
        break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
        break;
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
        break;
        default:
        break;
    }
    return 0;
}

Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
C = M.times.map{ gets.split.map(&:to_i) }
ans = 1000.times.find do |n|
  i = n.to_s
  i.size == N && C.all?{|s,d| i[s - 1].to_i == d }
end
puts ans || (-1)


Measured memory_bytes: 1788