akhauriyash/Code-Regression huggingface dataset:
import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    countA = bisect.bisect_left(A, b)
    countC = len(C) - bisect.bisect(C, b)
    ans += countA * countC

print(ans)


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

int n, x[3][100010], mn[2];
ll cnt[2];

struct BIT{
	int dat[100010];
	void upd(int x){ for(; x <= n; x += x & -x) dat[x]++; }
	int pf(int x){
		int ret = 0;
		for(; x; x -= x & -x) ret += dat[x];
		return ret;
	}
	int get(int s, int e){ return pf(e) - pf(s - 1); }
} B[2];

void T_T(){ puts("No"); exit(0); }

int main(){
	scanf("%d", &n);
	for(int i = 0; i < 3; i++){
		for(int j = 1; j <= n; j++) scanf("%d", x[i] + j);
	}
	for(int i = 1; i <= n; i++){
		int q[3], r[3];
		for(int j = 0; j < 3; j++){
			x[j][i] += 2;
			q[j] = x[j][i] / 3;
			r[j] = x[j][i] % 3;
		}
		if(q[0] != q[1] || q[0] != q[2] || q[1] != q[2]) T_T();
		if((q[0] ^ i) & 1) T_T();
		if((r[1] - r[0]) * (r[2] - r[1]) < 0) T_T();
		if(r[0] > r[1]) mn[i % 2]++;
		cnt[i % 2] += B[i % 2].get(q[0], n);
		B[i % 2].upd(q[0]);
	}
	for(int i = 0; i < 2; i++) if((mn[i] ^ cnt[!i]) & 1) T_T();
	puts("Yes");
}

Measured memory_bytes: 2176
class UnionFind:
    def __init__(self, size):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数
        self.diff_potential = [0 for i in range(size)]#親ノードを基準としたポテンシャル

    def root(self, x): #root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        else:
            rx = self.root(self.parent[x]) #xをxの根rxに直接つなぎたい
            self.diff_potential[x] += self.diff_potential[self.parent[x]] #そのために，diff(rx,x)を計算
            self.parent[x] = rx #xをrxに直接つなげる
            return rx

    def merge(self, x, y, diffxy): #merge(x,y): xのいるグループと$y$のいるグループをまとめる
        diffxy = self.diff_potential[x] + diffxy - self.diff_potential[y] #diffxyをdiff(rx,ry)で置き換え
        x = self.root(x) #rxを新たにxと名づける
        y = self.root(y) #ryを新たにyと名づける
        if x == y:
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y=y,x
            diffxy = -diffxy
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        self.diff_potential[y] = diffxy #yの相対ポテンシャルを更新
        return True

    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue，違うならFalse
        return self.root(x) == self.root(y)
        
    def diff(self,x,y): #diff(x,y): xを基準としたyのポテンシャルを返す 
        if self.root(x) == self.root(y): #この時点でxの親はroot(x)
            return self.diff_potential[y] - self.diff_potential[x]
        else:
            return None

    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]
#>>>>>>>>>>>>>>EhdCutHere>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

n,m = list(map(int,input().split()))
p = list(map(lambda x: int(x)-1,input().split()))

uf = UnionFind(n)
for i in range(m):
    x,y=list(map(int,input().split()))
    uf.merge(x-1,y-1,0)

ans = 0
for i in range(n):
    if uf.issame(i,p[i]):
        ans += 1

print(ans)
#print([uf.root(i) for i in range(n)])
#print([uf.parent[i] for i in range(n)])
#print([uf.size(i) for i in range(n)])



Measured memory_bytes: 13812
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

struct Dscc {
public:

	//fst:belongs , scd:newedges
	pair<vector<vector<int>>, vector<vector<int>>>get(const vector<vector<int>>&edges) {
		nums.resize(edges.size());
		fill(nums.begin(), nums.end(), -1);
		vector<vector<int>>revedges(edges.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				revedges[j].push_back(i);
			}
		}
		int num = 0;
		for (int i = 0; i < edges.size(); ++i) {
			dfs(i, num, edges);
		}
		vector<int>big(nums.size());
		for (int i = 0; i < nums.size(); ++i) {
			big[nums[i]] = i;
		}
		reverse(big.begin(), big.end());
		unis.resize(edges.size());
		fill(unis.begin(), unis.end(), -1);
		num = 0;
		for (int i = 0; i < big.size(); ++i) {

			dfs2(big[i], num, revedges);
			num++;
		}
		vector<int>nums;
		for (int i = 0; i < unis.size(); ++i) {
			nums.push_back(unis[i]);
		}
		sort(nums.begin(), nums.end());
		nums.erase(unique(nums.begin(), nums.end()), nums.end());


		map<int, int>mp;
		for (int i = 0; i < nums.size(); ++i) {
			mp[nums[i]] = i;
		}
		for (int i = 0; i < unis.size(); ++i) {
			unis[i] = mp[unis[i]];
		}

		vector<vector<int>>belongs(nums.size());
		for (int i = 0; i < unis.size(); ++i) {
			belongs[unis[i]].push_back(i);
		}
		vector<vector<int>>newedges(nums.size());
		for (int i = 0; i < edges.size(); ++i) {
			for (auto j : edges[i]) {
				if (unis[i] != unis[j]) {
					newedges[unis[i]].push_back(unis[j]);
				}
			}
		}
		return make_pair(belongs, newedges);
	}
private:
	vector<int>nums;
	vector<int>unis;


	void dfs(const int id, int &num, const vector<vector<int>>&edges) {
		if (nums[id] != -1)return;
		else {
			nums[id] = -2;
			for (auto i : edges[id]) {
				dfs(i, num, edges);
			}
		}
		nums[id] = num++;
		return;
	}
	void dfs2(const int id, const int &num, const vector<vector<int>>&edges) {
		if (unis[id] != -1)return;
		else {
			unis[id] = -2;
			for (auto i : edges[id])
				dfs2(i, num, edges);
		}
		unis[id] = num;
		return;
	}

}dscc;

int main() {	
	int W,H;
	char c;
	cin>>W>>H>>c;
	vector<string>sts(H,string(W,'.'));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int num=0;
			if(i==0||i==H-1)num+=2;
			if(j==0||j==W-1)num++;

			if(num==2)sts[i][j]='-';
			if(num==1)sts[i][j]='|';
			if(num==3)sts[i][j]='+';

			if(j==W/2&&i==H/2)sts[i][j]=c;
		}
		cout<<sts[i]<<endl;
	}
	return 0;
}

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

int main(){
	int n, k;
	cin >> n >> k;
	int a[n];
	map<int, int> m;

	for( int i = 0; i < n; ++i ){
		cin >> a[i];
		m[a[i]]++;
	}
	if( k < m.size() ){
		vector<int> v;
		for( auto u : m ){
			v.push_back(u.second);
		}
		sort(v.begin(), v.end());
		int out = 0;
		for( int i = 0; i < m.size()-k; ++i )
			out += v[i];
		
		cout << out << endl;
	} else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 11516
#include<stdio.h>


int main(void) {
	int a, b, c;

	scanf("%d%d%d", &a, &b, &c);
	if (a < b) {
		if (b < c) {
			if (c == a + b) {
				printf("Yes\n");
			}
			else {
				printf("No\n");
			}
		}
		else if (b == a + c) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	else if (a < c) {
		if (c == a + b) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	else {
		if (a == b + c) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}

}

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

#define ll long long

using namespace std;

const int MAXN = 1e5 + 10;
const int MAXM = 1e5 + 10;
const int INF = 0x3fffffff;
const int MOD = 1e9 + 7;

int n, m, k;
int tot, cnt, ans;
ll sum;

int a[MAXN], b[MAXN], c[MAXN], num[MAXN];

string s;

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


Measured memory_bytes: 5384
#include <stdio.h>
#include <string.h>

int main()
{
    int n,x = 0,max = 0;
    char s[101];

    scanf("%d %s",&n,s);

    int i;
    for (i = 0; i < n; i++)
    {
        if(s[i] == 'I')x++;
        else x--;

        if(max < x)max = x;
    }
    
    printf("%d",max);
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int x, y;
  cin >> x >> y;
  if ((x+y)%3) {
    cout << 0 << endl;
    return 0;
  }
  int n = (x+y)/3;
  x -= n; y -= n;
  if (x < 0 || y < 0) {
    cout << 0 << endl;
    return 0;
  }
  combination c(x+y);
  mint ans = c(x+y,x);
  cout << ans.x << endl;
  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);
#define max3(a,b,c) max(a,max(b,c)) 
#define mix3(a,b,c) mix(a,mix(b,c))

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int n;cin>>n;
    vi d(n);rep(i,n)cin>>d[i];

    int ans=0;
    rep(i,n){
        repa(j,i+1,n){
            ans+=d[i]*d[j];
        }
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader

fun main(args: Array<String>) {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val s = br.readLine()
    println(s.count { it == '1' })
}

fun err(print: Any) {
    System.err.println(print)
}

Measured memory_bytes: 31392
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    ll a,b,c,k;cin>>a>>b>>c>>k;
    if(k%2){
        cout<<b-a<<endl;
    }else{
        cout<<a-b<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> num(n);
    rep(i, n) {
        if ( s[i] == '(' ) {
            if ( i == 0 ) num[0] = 1;
            else if ( num[i-1] < 0 ) num[i] = 1;
            else                     num[i] = num[i-1] + 1;
        } 
        else if ( s[i] == ')' ) {
            if ( i == 0 ) num[0] = -1;
            else          num[i] = num[i-1] - 1;
        }
    }
    rep(i, n) {
        if ( num[i] < 0 ) s = "(" + s;
    }
    if ( num[n-1] > 0 ) {
        rep(i, num[n-1]) s = s + ")"; 
    }
    cout << s << endl;
    return 0;
}


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

_list = [-1]*(N+1)

for m in range(M):
  s,c = map(int, input().split())
  # 条件を満たさない
  if _list[s] != -1 and _list[s] != c:
    print(-1)
    exit()
  else:
    _list[s] = c
  
ans = ''
for idx, _ in enumerate(_list[1:]):
  if _ == -1:
    # 1桁目は1、そうでなかったら０にする
    if idx != 0:
      ans += '0'
    else:
      ans += '1'
  else:
    ans += str(_)

# 1桁目が0なのはNG
if N > 1 and ans[0] == '0':
  print(-1)
elif M == 0:
  if N == 1:
    print(0)
  elif N == 2:
    print(10)
  elif N == 3:
    print(100)
else:
  print(int(ans))

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int d, t, s;
	cin >> d >> t >> s;
	int kyo = t * s;
	if(kyo >= d){
		coY();
	} else {
		coN();
	}
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    string s;
    unsigned int K;
    cin >> s >> K;
    set<string> S;
    for (int a = 0; a < s.size(); ++a) {
        for(int b = 1; b <= min(K,(unsigned int)(s.size() - a)); b++){
            string sb = s.substr(a,b);
            if(S.count(sb) != 0){
                continue;
            }
            S.insert(sb);
        }
    }
    auto itr = S.begin();
    for (int i = 0; i < K - 1; ++i) {
        itr++;
    }
    cout << *itr << endl;


}


Measured memory_bytes: 1664
import sys
readline = sys.stdin.readline

MOD = 10**9+7
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci
frac, fraci = frac(2341398)
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%MOD

K = int(readline())
S = len(readline().strip())
ans = 0

M = 1341398
A = [1]*M
B = [1]*M
for i in range(1, M):
    A[i] = (A[i-1]*25)%MOD
    B[i] = (B[i-1]*26)%MOD

ans = 0

for i in range(K+1):
    ans = (ans+A[i]*B[K-i]*comb(i+S-1, i))%MOD

print(ans)



Measured memory_bytes: 170560
import sys
from collections import defaultdict
sys.setrecursionlimit(10**7)

class UnionFind():
    def __init__(self, N):
        self.N = N
        self.par = [n for n in range(N)]
        self.rank = [0 for _ in range(N)]

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def union(self, x, y):
        x = self.find(self.par[x])
        y = self.find(self.par[y])
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def isSame(self, x, y):
        return self.par[x] == self.par[y]

    def refresh(self):
        for p in range(N):
            self.find(p)

N, K, L = [int(x) for x in input().strip().split()]
road = UnionFind(N)
train = UnionFind(N)

for ｋ in range(K):
    p, q = [int(x) - 1 for x in input().strip().split()]
    road.union(p, q)
for l in range(L):
    r, s = [int(x) - 1 for x in input().strip().split()]
    train.union(r, s)

d = defaultdict(int)
for n in range(N):
    r = road.find(n)
    t = train.find(n)
    d[(r, t)] += 1

for n in range(N):
    print(d[(road.par[n], train.par[n])], end=' ')

Measured memory_bytes: 56132
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
vector<string>vs;
auto Depeth(string s){int a=0; rep(i,s.size())if(s[i] != '.')break;else ++a;return a;}
int cal(int idx){
    int depeth = Depeth(vs[idx]);
    char op = vs[idx][depeth];
    if(op != '*' and op != '+'/*if idx is numeric */) return op - '0' ;
    ++depeth;
    int res = -1;
    for(int i = idx + 1; i < vs.size();i++){
        if(vs[i] == "")continue;
        int kd = Depeth(vs[i]);
        char key = vs[i][kd];
        if(key == '+' or key == '*'){
            if(kd+1 <= depeth) break;
            res = (res  == -1 ? res = cal(i) : (op == '+' ? res += cal(i) : res *= cal(i)));
        } else {
            int val = key - '0';
            if(depeth == kd){
                if( op == '+')(res == -1 ? res = val : res += val);
                else ( res == -1 ? res = val : res *= val);
                vs[i] = "";
            } else {
                //WTF
            }
        }
    }
    vs[idx] = "";
    return res;
}

signed main(){
    int n;
    while(cin >> n,n){
        vs = vector<string>(n);
        for(auto && s : vs) cin >> s;
        cout << cal(0LL) << endl;
    }
}




Measured memory_bytes: 3152
from sys import exit
n, m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]
for x, a in enumerate(A):
    if x > n - m + 1:
        break
    for i in range(n - m + 1):
        if a[i: i + m] == B[0]:
            for j in range(m):
                if A[x + j][i: i + m] != B[j]:
                    break
            else:
                print("Yes")
                exit()
print("No")


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

int main()
{
    string z="";
   int size1=0;
   int countA=0,countW=0,countT=0,countR=0;
   string word[4]={"AC","WA","TLE","RE"};

   vector<string>in;
      vector<int>coun;
cin>>size1;
   for(int i=0;i<size1;i++){
    cin>>z;
    in.push_back(z);
   }

for(int i=0;i<in.size();i++){
    if(in[i]=="AC"){countA++;}
        else if(in[i]=="WA"){countW++;}
    else if(in[i]=="TLE"){countT++;}
    else if(in[i]=="RE"){countR++;}

}


coun.push_back(countA);
coun.push_back(countW);
coun.push_back(countT);
coun.push_back(countR);

for(int i=0;i<4;i++){

cout<<word[i]<<" "<<"x"<<" "<<coun[i]<<endl;}
    return 0;
}


Measured memory_bytes: 7416
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve()
{
    ll n;
    cin>>n;
    if(n==5 or n==3 or n==7)
    cout<<"YES";
    else
    cout<<"NO";

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " <<
#define outdicimal out << fixed << setprecision(10)//TODO 小数点以下の桁数の変更
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;


class ARounding {
public:
	void solve(std::istream& in, std::ostream& out) {
    int x,a;
    in >> x >> a;
    if(x < a){
      out << 0 << endl;
    }
    else{
      out << 10 << endl;
    }
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	ARounding solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m, c;
	cin >> n >> m >> c;
	int b[m];
	rep(i, m) cin >> b[i];
	int a[n][m];
	rep(i, n) rep(j, m) cin >> a[i][j];

	int ans[n];
	rep(i, n) ans[i] = c;
	rep(i, n) rep(j, m)
	{
		ans[i] += a[i][j] * b[j];
	}

	int out = 0;
	rep(i, n)
	{
		if(ans[i] > 0) out++;
	}

	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
n, k=map(int,input().split())
a=list(map(int,input().split()))

alr=[False]*n
alr[0]=True
now_in=0

if k<=2*(10**5)+1:
    for i in range(k):
        now_in=a[now_in]-1
    print(now_in+1)
    sys.exit()

#ループのスタートを見つける
for i in range(n+1):
    now_in=a[now_in]-1
    if alr[now_in] is False:
        alr[now_in]=True
    else:
        start=now_in
        break

count_r=0
now_in=start
for i in range(2*(10**5)+1):
    now_in=a[now_in]-1
    count_r+=1
    if now_in==start:
        break

now_in=0
count=0
while now_in!=start:
    now_in=a[now_in]-1
    count+=1

c=k-count
plus=c%count_r
for i in range(plus):
    now_in=a[now_in]-1

print(now_in+1)

Measured memory_bytes: 32404
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

bool h[1000010];
bool w[1000010];
int num[1000010];
int main(){
    int n,m; cin>>n>>m;
    bool flg=0;
    int a[n]; rep(i,n){cin>>a[i];if(h[a[i]])flg=1;h[a[i]]=1;}
    int b[m]; rep(i,m){cin>>b[i];if(w[b[i]])flg=1;w[b[i]]=1;}
    if(flg){cout<<0<<endl;return 0;}
    int hh=0,ww=0;
    long long ans=1;
    for(int i=n*m;i>0;i--){
        if(h[i]&&w[i]){
            hh++;
            ww++;
        }else if(h[i]){
            ans*=ww;
            hh++;
        }else if(w[i]){
            ans*=hh;
            ww++;
        }else{
            ans*=hh*ww-(n*m-i);
        }
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2304
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,k,cnt; cin>>n>>k;
    cout<<fixed<<setprecision(20);
    vector<ll> a(n,1);
    for(ll i=1;i<=n;i++){
        cnt=i;
        while(cnt<k){
            cnt*=2;
            a[i-1]*=2;
        }
    }
    ll sum=0;
    rep(i,n) sum+=a[0]/a[i];
    ld r=1;
    cout<<sum*r/(a[0]*n)<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
    string str;
    string ttr;
    cin >> str;
    cin >> ttr;
    int n;
    n = str.size();
    for(int i=0; i<n; i++){
        if(str[i] != ttr[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 3564
N = int(input())
ans = N*(N+1)*(N+2)//6
def func(s):
    u,v = map(int,s.split())
    u,v = min(u,v),max(u,v)
    return u*(N-v+1)
uv = [func(input()) for _ in range(N-1)]
ans -= sum(uv)
print(ans)

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

int main() {
  ll n,m; cin >> n >> m;
  ll ans;
  if (n==1 && m==1) ans = 1;
  else if (n==1 && m != 1) ans = m-2;
  else if (m==1 && n != 1) ans = n-2;
  else {
    ans = (n-2)*(m-2);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int H,N;
  cin >> H >> N;
  vector<int> waza(N);
  rep(i,N){
    cin >> waza.at(i);
  }
  
  int a = 0;
  rep(i,N){
    a+=waza.at(i);
  }
  
  if(a>=H){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
  
    
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1724
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), a = sc.nextInt()-1, b = sc.nextInt()-1, c = sc.nextInt()-1, d = sc.nextInt()-1;
        char[] S = sc.next().toCharArray();
        String res = "Yes";
        for(int i = a; i < c - 1; i++) {
            if(S[i + 1] == '#' && S[i + 2] == '#') res = "No";
        }
        for(int i = b; i < d - 1; i++) {
            if(S[i + 1] =='#' && S[i + 2] == '#') res = "No";
        }
        if(c > d) {
            boolean flag = false;
            for(int i = b; i <= d; i++) {
                if(S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
                    flag = true;
                    break;
                }
            }
            if(!flag) res = "No";
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 26148
// at coder beginner
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll  maxx=1e10+5;
void solve(){
    vll v(4,1);
    ll k;
    for(int i=0;i<2;i++){
        cin>>k;
        v[k]--;
    }
    //fr(i,1,4)
    //cout<<v[i]<<endl;
    fr(i,1,4){
        if(v[i]==1){
        cout<<i;break;}
    }
    
}
int main(){
    ll t=1;
//cin>>t;
ll k=1;
    while(k<=t){

     solve();
     k++;
    }
    return 0;
}


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

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

int main() {
    ll h, w;
    cin >> h >> w;
    ll ans = 0, cnt = (w + 1) / 2, num;

    if(h==1||w==1){
        cout << 1 << endl;
         return 0;
    }

    if (w % 2) { // 横が奇数
        if (h % 2) {
            num = (h + 1) / 2;
            cout << cnt * num + (cnt - 1) * (num - 1);
        } else {
            cout << (cnt + cnt - 1) * ((h + 1) / 2) << endl;
        }
    } else {
        cout << cnt * h << endl;
    }
    return 0;
}

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

using namespace std;

const int MX = 200005;

int n, root;
char str[MX];
int fst[MX], nxt[MX], v[MX], lnum;

void addeg(int nu, int nv)
{
	nxt[++lnum] = fst[nu];
	fst[nu] = lnum;
	v[lnum] = nv;
}

void input()
{
	scanf("%d", &n);
	for(int i=1; i<n; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		addeg(a, b);
		addeg(b, a);
	}
	scanf("%s", str+1);
	for(int i=1; i<=n; i++) if(str[i] == 'W') root = i;
}

int sum[MX], deg[MX], ans, mxl;

void dfs(int x, int f)
{
	sum[x] = (str[x] == 'W');
	for(int i=fst[x]; i; i=nxt[i])
	{
		int y = v[i];
		if(y == f) continue;
		dfs(y, x);
		sum[x] += sum[y];
		if(sum[y]) deg[x]++;
	}
	if(sum[x] && f) deg[x]++, ans+=2;
	ans += ((deg[x]&1)^(str[x]=='W'));
}

pair<int, int> calc(int x, int f)
{
	pair<int, int> best(0, - ((deg[x]&1)^1^(str[x]=='W')) + ((deg[x]&1)^(str[x]=='W')));
	for(int i=fst[x]; i; i=nxt[i])
	{
		int y = v[i];
		if(y==f || !sum[y]) continue;
		pair<int, int> tmp = calc(y, x);
		mxl = max(mxl, best.first+tmp.second+1);
		mxl = max(mxl, best.second+tmp.first+1);
		best.first = max(best.first, tmp.first + 1 - (deg[x]&1^1^(str[x]=='W')) + (deg[x]&1^(str[x]=='W')));
		best.second = max(best.second, tmp.second + 1 - (deg[x]&1^1^(str[x]=='W')) + (deg[x]&1^(str[x]=='W')));
	}
	return best;
}

void work()
{
	dfs(root, 0);
	calc(root, 0);
	//cout<<ans<<" "<<mxl<<endl;
	printf("%d\n", ans-mxl);
}

int main()
{
	input();
	work();
	return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int main(){
    int N; cin >> N;
    int x=800*N;
    int y=200*(N/15);
    cout << x-y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll val=b*d;
    val=max(val,a*c);
    val=max(val,a*d);
    val=max(val,b*c);
    val=max(val,b*d);
    cout<<val<<"\n";
}


Measured memory_bytes: 3648
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

const double pi=3.1415;
ll absc(ll a,ll b){return (a-b>0?a-b:b-a);
}
ll mini(ll a,ll b){return (a>b?b:a);}
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	return (a%b?gcd(a%b,b):b);
}
int main()
{
   int a,n,b,c,d;
   string t;
   cin>>n;
   vector<string>s(n);
   rep(i,n){
   	cin>>s[i];
   }
   sort(s.begin(),s.end());
   int ans=0;
   rep(i,n){
   	if(i==0||s[i-1]!=s[i])ans++;
   }
   cout<<ans;
}


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

#define mp make_pair
#define pb push_back
#define ll long long int
#define sd(x) scanf("%lld",&x)
#define inf 1e18+9
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define bits(x) __builtin_popcountll(x)
#define ld long double
#define test() ll test; cin>>test; while(test--)
#define fi first
#define se second


int main() {
	fastio;
	vector<ll> a;
	ll sum=0;
	a.pb(0);
	for(ll i=1;i<=100;i++) {
		sum+=i;
		a.pb(sum);
	}

	ll N;
	cin>>N;

	ll ans = 0;
	for(ll i=2;i*i<=N;i++) {
		if(N%i==0) {
			ll cnt = 0;
			while(N%i==0) {
				cnt++;
				N/=i;
			}
			ll indx = upper_bound(a.begin(),a.end(),cnt)-a.begin();
			indx--;
			if(a[indx]==cnt) {
				ans += indx;
			} else {
				ans += indx;
			}
		}
	}
	if(N>1) ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 3660
def enq(a,x)
  b = a[i=-1]
  until b.frozen?
    return a << x  if x >= (a=b)[-1]
    return a.unshift x  if x <= a[0]
    b = a[i = a.bsearch_index{|y| x < (y.frozen? ? y: y[0])}-1]
  end  if b && b=a
  a[i+9] or return a.insert i+1, x
  i>0 ? a[i]=[b,x] : enq(a[i+=1].to_a,x)  rescue a[i]=[x,a[i]]
end
def deq(a) r=a.pop; a[-1].frozen? or a.push *a.pop; r end
NS = 6; NM = (1<<NS)-1
SS = 13;SM = (1<<SS)-1
F =-> {gets.split.map &:to_i}
N,M,S = F[]
E = Array.new(N) {|i| [i] }
M.times {
  u,v,a,b = F[]
  E[u-1] << [v-1,a,b]
  E[v-1] << [u-1,a,b]
}
E.each {|e| c,d = F[]; e[0] = [e[0], [-c,-2500].max, d] }
Q,T,V = [[S,2500].min], {}, []
while T.size < N
  t = deq Q
  s = SM & t; t >>= SS
  n = NM & t; t >>= NS
  (v = V[n]) ? (next if v>=s || v>2500) : T[n] = -t
  V[n] = s
  E[n].each {|n,a,b| enq Q, (t-b<<NS+SS) + (n<<SS) + s-a  if s >= a }
end
puts (1...N).map{|i| T[i]}

Measured memory_bytes: 14412
# coding: utf-8

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def check(s):
    if s == "":
        return True
    if s[:5] in ["dream", "erase"]:
        return True
    return False


def main():
    S = input()
    i = 0
    l = len(S)
    while i < l:
        if S[i:i + 7] == "dreamer" and check(S[i + 7:]):
            i += 7
        elif S[i:i + 6] == "eraser" and check(S[i + 6:]):
            i += 6
        elif check(S[i:]):
            i += 5
        else:
            return False
    return True

if __name__ == "__main__":
    YESNO(main())


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

int main() {
  int n, v = 1, mv = 0, tmp, x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> tmp;
    if (abs(tmp) > mv) mv = abs(tmp), v = i, x = (tmp < 0) ? 1 : 0;
  }
  cout << 2 * n - 2 << endl;
  for (int i = 1; i <= n; i++)
    if (i != v) cout << v << " " << i << endl;
  if (x)
    for (int i = n; i > 1; i--) cout << i << " " << i - 1 << endl;
  else
    for (int i = 2; i <= n; i++) cout << i - 1 << " " << i << endl;
}


Measured memory_bytes: 256
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int a, b;
	cin >> a >> b;
	if(a <= 0 && b >= 0) cout << "Zero\n";
	else if(a < 0) cout << ((b - a) % 2 ? "Positive\n" : "Negative\n");
	else if(a > 0) cout << "Positive\n";
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	int a[3];
	for(int i=0; i<3; i++)	scanf("%d", a+i);
	sort(a, a+3);
	if(a[0]%2==0 || a[1]%2==0 || a[2]%2==0)	puts("0");
	else	printf("%lld\n", 1ll*a[0]*a[1]);
    
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

# 高速 組み合わせ
def C(n, r):
  a = 1
  b = 1
  for i in range(r):
    a = a*(n-i)
    b = b*(r-i)
  return((a//b))

from collections import Counter

N, M = map(int, input().split())
D = 1000000000 + 7

def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac


f = primes(M)
cntr = Counter(f)

ans = 1
for k,v in cntr.items():
    ans *= C(v+N-1,v) %D

print(ans%D)


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

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll oddcnt = 0;
    ll evencnt = 0;
    for(ll i = 0; i < N; i++)
    {
        cin >> A.at(i);
        if(A.at(i) % 2 == 0)evencnt++;
        else oddcnt++;
    }

    //cout << "hh" << endl;

    if(oddcnt % 2 != 0)cout << "NO";
    else cout << "YES";
    cout << endl;
   

    return 0;
    
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main(){
  int n;
  cin >> n;
  set<int> s;
  REP(i,n){
    int tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  int m;
  cin >> m;
  set<int> t;
  REP(i,m){
    int tmp;
    cin >> tmp;
    t.insert(tmp);
  }
  set<int> ans;
  set_union(ALL(s),ALL(t),inserter(ans,ans.end()));
  for(auto i:ans){
    cout << i << endl;
  }
}



Measured memory_bytes: 40596
#include<cstdio>
#include<algorithm>
#include<functional>

using namespace std;

int n,k[10001];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++)scanf("%d",&k[i]);
		sort(k,k+n,greater<int>());
		if(k[0]<2)printf("NA\n");
		else{
			int cnt=0;
			for(int i=0;i<n;i++){
				if(k[i]>=1)cnt++;
			}
			printf("%d\n",cnt+1);
		}
	}
	return 0;
}

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

int main(){
    int n;cin>>n;
    map<int,int>a;
    for(int i=0;i<n;++i){
        int x;cin>>x;
        a[x]++;
    }
    if(a[0]>0)cout<<0<<endl;
    else{
        vector<int>b,c(24,0);
        c[0]=1;
        if(a[12]>0)c[12]=1;
        for(int i=1;i<=12;++i){
            if(a[i]>2){
                cout<<0<<endl;
                return 0;
            }
            else if(a[i]==2){
                c[i]=1;
                c[24-i]=1;
            }
            else if(a[i]==1&&i!=12)b.push_back(i);
        }
        int ans=0;
        for(int i=0;i<(1<<b.size());++i){
            for(int j=0;j<b.size();++j){
                if((i>>j)&1){
                    c[24-b[j]]=1;
                }
                else c[b[j]]=1;
            }
            int cnt1=0,cnt2=100;
            for(int j=1;j<=23;++j){
                if(c[j]==0)cnt1++;
                else{
                    if(cnt2>cnt1)cnt2=cnt1;
                    cnt1=0;
                }
            }
            if(cnt1>0&&cnt2>cnt1)cnt2=cnt1;
            if(cnt2+1>ans)ans=cnt2+1;
            for(int j=0;j<b.size();++j){
                c[b[j]]=0;
                c[24-b[j]]=0;
            }
        }
        cout<<ans<<endl;
    }
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const ll MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  int n;cin>>n;
  vector<int> ps(n);
  REP(i,n) cin>>ps[i];

  // 現在存在している「(」の数と、今)を置いたら、そこの数字は何になるかだけ保存しておく
  int lcnt = 0;
  vector<int> nums;
  string res;
  REP(i,n) {
    if (!nums.empty() && ps[i]<nums.back()) {
      OUT(":(");
      return 0;
    }

    if (ps[i]>lcnt) {
      int gap = ps[i]-lcnt;
      REP(j,gap) {
        res.push_back('(');
        nums.push_back(lcnt+j+1);
      }
      lcnt += gap;
    }

    res.push_back(')');
    nums.pop_back();
  }
  OUT(res);

  return 0;
}


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

int main(void) {
    long n, k;
    cin >> n >> k;
    vector<vector<long>> b(4*k+1, vector<long>(4*k+1));
    vector<vector<long>> w(4*k+1, vector<long>(4*k+1));

    for(long i=0; i<n; i++) {
        long x, y;
        string c;
        cin >> x >> y >> c;
        x %= 2*k, y %= 2*k;
        x++, y++;
        (c[0] == 'B' ? b : w)[y][x]++;
        (c[0] == 'B' ? b : w)[y][x+2*k]++;
        (c[0] == 'B' ? b : w)[y+2*k][x]++;
        (c[0] == 'B' ? b : w)[y+2*k][x+2*k]++;
    }

    for(long i=1; i<=4*k; i++)
        for(long j=1; j<=4*k; j++)
            b[i][j] += b[i-1][j] + b[i][j-1] - b[i-1][j-1];

    for(long i=1; i<=4*k; i++)
        for(long j=1; j<=4*k; j++)
            w[i][j] += w[i-1][j] + w[i][j-1] - w[i-1][j-1];

    long r = 0;
    for(long i=0; i<2*k; i++)
    for(long j=0; j<2*k; j++) {
        long t = 0;
        t += b[i+k][j+k] - b[i+k][j] - b[i][j+k] + b[i][j];
        i+=k, j+=k;
        t += b[i+k][j+k] - b[i+k][j] - b[i][j+k] + b[i][j];

        i-=k;
        t += w[i+k][j+k] - w[i+k][j] - w[i][j+k] + w[i][j];
        i+=k, j-=k;
        t += w[i+k][j+k] - w[i+k][j] - w[i][j+k] + w[i][j];
        i-=k;

        r = max(r, t);
    }
    cout << r << endl;
}


Measured memory_bytes: 250624