akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int N;
	void Solve()
	{
		var I = G;
		N = I[0];
		var K = I[1];
		var p = G;
		var q = G;
		for (var i = 0; i < N; i++) { p[i]--; q[i]--; }
		WriteLine(string.Join(" ", Calc(p, q, K).Select(i => i + 1)));
	}
	int[] Calc(int[] p, int[] q, int K)
	{
		if (K == 1) return p;
		if (K == 2) return q;
		if (K < 10) return Calc(q, Mult(q, Inv(p)), K - 1);
		K--;
		var ip = Inv(p);
		var iq = Inv(q);
		var x = Mult(q, ip, iq, p);
		var y = Mult(ip, q, p, iq);
		if (K % 6 == 0)
		{
			// 12
			// q.ip.iq.p.q.ip.iq.p.q.p.iq.ip.q.p.iq
			// x        .x        .q.p.iq.y
			// 18
			// q.ip.iq.p.q.ip.iq.p.q.ip.iq.p.q.p.iq.ip.q.p.iq.ip.q.p.iq
			// x      .x          .x        .q.p.iq.y        .y
			return Mult(Pow(x, K / 6), q, p, iq, Pow(y, K / 6 - 1));
		}
		if (K % 6 == 1)
		{
			// q.ip.iq.p.q.ip.iq.p.q.ip.q.p.iq.ip.q.p.iq
			// x        .x        .q.y        .y
			return Mult(Pow(x, K / 6), q, Pow(y, K / 6));
		}
		if (K % 6 == 2)
		{
			// q.ip
			// q.ip
			return Mult(Pow(x, K / 6), q, ip, Pow(y, K / 6));
		}
		if (K % 6 == 3)
		{
			// q.ip.iq
			// q.ip.iq
			return Mult(Pow(x, K / 6), q, ip, iq, Pow(y, K / 6));
		}
		if (K % 6 == 4)
		{
			// iq
			// iq
			return Mult(Pow(x, K / 6 + 1), iq, Pow(y, K / 6));
		}
		else
		{
			// p.iq
			// p.iq
			return Mult(Pow(x, K / 6 + 1), p, iq, Pow(y, K / 6));
		}
	}
	int[] Pow(int[] a, int b)
	{
		var p = MakeArray(N, i => i);
		var x = a;
		while (b > 0)
		{
			if ((b & 1) == 1) p = Mult(p, x);
			b >>= 1;
			x = Mult(x, x);
		}
		return p;
	}
	int[] Inv(int[] a)
	{
		var c = new int[N];
		for (var i = 0; i < N; i++) c[a[i]] = i;
		return c;
	}
	int[] Mult(params int[][] a)
	{
		if (a.Length == 0) return MakeArray(N, i => i);
		var x = a[0];
		for (var i = 1; i < a.Length; i++) x = Mult(x, a[i]);
		return x;
	}
	int[] Mult(int[] a, int[] b)
	{
		var c = new int[N];
		for (var i = 0; i < N; i++) c[i] = a[b[i]];
		return c;
	}
}


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

int main(void){
    int n,a,b,c;
    cin >> n;

    a = n / 100;
    b = n / 10 - 10 * a;
    c = n - a * 100 - b * 10;

    if(c==0 || c==1 || c==6 || c==8 ){
        cout << "pon" << endl;
    }else if(c==3){
        cout << "bon" << endl;
    }else{
        cout << "hon" << endl;
    }

    return 0;
}

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

int main() {
  long long a, b; cin >> a >> b;
  int k; cin >> k;
  
  if (b - a + 1 > k * 2) {
    for (long long i = a; i < a + k; i++) cout << i << endl;
    for (long long i = b - k + 1; i <= b; i++) cout << i << endl;
  } else {
    for (long long i = a; i <= b; i++) cout << i << endl;
  }
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect_left
from heapq import heappush, heappop
from scipy.sparse.csgraph import dijkstra

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def dijkstra(E, start):
    N_d = len(E)
    dist = [INF] * N_d
    dist[start] = 0
    q = [(0, start)]
    while q:
        dist_v, v = heappop(q)
        if dist[v] != dist_v:
            continue
        for u, dist_vu in E[v]:
            dist_u = dist_v + dist_vu
            if dist_u < dist[u]:
                dist[u] = dist_u
                heappush(q, (dist_u, u))
    return dist

n, m, s, t = MAP()

uvab = [LIST() for _ in range(m)]

A = [[] for _ in range(n+1)]
B = [[] for _ in range(n+1)]

for u, v, a, b in uvab:
	A[u].append((v, a))
	A[v].append((u, a))
	B[u].append((v, b))
	B[v].append((u, b))

distA = dijkstra(A, s)  # 円での移動(s->i)
distB = dijkstra(B, t)  # スヌークでの移動(t->i)

Ans = []
init = 10**15
ans = INF
for a, b in zip(distA[:0:-1], distB[:0:-1]):
	ans = min(ans, a+b)
	Ans.append(init-ans)
Ans = Ans[::-1]
print("\n".join(map(str, Ans)))


Measured memory_bytes: 115544
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        vll t(n);
        for (int i = 0; i < n; i++) {
            in >> t[i];
        }
        ll m;
        in >> m;
        for (int i = 0; i < m; i++) {
            ll p, x;
            in >> p >> x;
            p--;
            ll ans = 0;
            for (int i = 0; i < n; i++) {
                if (i == p) {
                    ans += x;
                }
                else {
                    ans += t[i];
                }
            }
            out << ans << '\n';
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
using namespace std;
signed main()
{
	fastio;
	int l,r,d;
	cin>>l>>r>>d;
	int sum=0;
	for(int i=l;i<=r;i++)
	{
		if(i%d==0)
		{
			sum++;
		}
	}
	cout<<sum;
		
return 0;
}


Measured memory_bytes: 3608
N,M=map(int,input().split())
k=[]
s=[]
for i in range(M):
  ks=list(map(int,input().split()))
  k.append(ks[0])
  tmp=[]
  for k_ in range(k[i]):
    tmp.append(ks[k_+1])
  s.append(tmp)
p=list(map(int, input().split()))

def judge(M,s,p,li_state):
  for i in range(M):
    sum_light=0
    for j in s[i]:
      if li_state[j-1]:sum_light+=1
    if sum_light%2!=p[i]:
      return False
  return True

def excute_numofLighton(i,M,N,s,p,li_state,num):
  if i>=N:
    if judge(M,s,p,li_state):
      num+=1
    return num
  li_state[i]=1
  num=excute_numofLighton(i+1,M,N,s,p,li_state,num)
  li_state[i]=0
  num=excute_numofLighton(i+1,M,N,s,p,li_state,num)
  return num

li_state =[0]*N
ans = 0
ans = excute_numofLighton(0,M,N,s,p,li_state,ans)
print(ans)

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

using namespace std;

typedef long long ll;

int rep_pow(int p) { // n^p
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        ll t = rep_pow(p / 2);
        return t * t % 2019;
    } else {
        return 10 * rep_pow(p - 1) % 2019;
    }
}

int main() {
    ll ans = 0;
    string s; cin >> s;
    vector<int> mods(2019);
    int cur = 0;
    for (int i = (int)s.size() - 1; i >= 0; i--) {
        int new_mod = cur + int(s[i] - '0') * rep_pow((int)s.size() - 1 - i);
        new_mod %= 2019;
        if (new_mod == 0)
            ans++;
        ans += mods[new_mod];
        mods[new_mod]++;
        cur = new_mod;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

void solve(){
  int n, k, q; cin >> n >> k >> q;
  int b[n]; for(int i = 0; i < n; i++) b[i] = k;
  for(int i = 0; i < q; i++){
    int a; cin >> a;
    b[a - 1]++;
  }
  for(int i = 0; i < n; i++){
    if(b[i] - q > 0) cout << "Yes\n";
    else cout << "No\n";
  }
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 1024
puts ($<.map{|l|(n=l.to_i)<1?0:(a=[]
n.times{|c|n,x,_,y=gets.split;a<<[30-x.to_i*3-y.to_i,c,n]}
a.sort.map{|s,c,n|[n,30-s]*?,}<<"")}-[0])*$/

Measured memory_bytes: 6116
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)

	switch n[len(n)-1] {
	case '2', '4', '5', '7', '9':
		fmt.Println("hon")
	case '0', '1', '6', '8':
		fmt.Println("pon")
	case '3':
		fmt.Println("bon")
	}
}


Measured memory_bytes: 1752
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
ll T,n,m;
int main() {
	cin>>n;
	double t=1.08;
	for(int i=1;i<=50000;i++){
		if((int)(t*i)==n){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
	return 0;
	
}



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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // 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)];
    }
};

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll N;
    cin >> N;

    ll MAX_c = 1e5 + 10;
    UnionFind uf(MAX_c*2);

    vector<ll> x(N), y(N);

    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }

    for(int i = 0; i < N; i++){
        uf.merge(x[i], y[i] + MAX_c);
    }

    map<ll, ll> mx, my;

    for(ll i = 0; i < MAX_c; i++) mx[uf.root(i)]++;
    for(ll i = MAX_c; i < 2 * MAX_c; i++) my[uf.root(i)]++;

    ll ans = 0;
    for(ll i = 0; i < 2 * MAX_c; i++) ans += mx[i] * my[i];

    cout << ans - N << endl;

    return 0;
}



Measured memory_bytes: 29952
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	n %= 10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)cout << "hon" << endl;
	if(n == 0 || n == 1 || n == 6 || n == 8)cout << "pon" << endl;
	if(n == 3)cout << "bon" << endl;
}


Measured memory_bytes: 3600
N=input()
r=0
m=int(N[-1])
for i in range(len(N)-1,0,-1):
    n=m
    m=int(N[i-1])
    if n<5:
        r+=n
    elif n==5:
        if m<5:
            r+=n
        else:
            r+=10-n
            m+=1
    else:
        r+=10-n
        m+=1
r+=m if m<6 else 11-m
print(r)

Measured memory_bytes: 5492
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=5e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int bit[N],a[N],last[N],ans[N];
vector<pii> v[N];
void update(int idx,int val)
{
  if(idx==0) return;
  while(idx<N)
  {
    bit[idx]+=val;
    idx+=(idx&(-idx));
  }
}
int getSum(int idx)
{
  int sum=0;
  while(idx>=1)
  {
    sum+=bit[idx];
    idx-=(idx&(-idx));
  }
  return sum;
}
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int n,q;
  cin>>n>>q;
  for(int i=1;i<=n;i++) cin>>a[i];
  for(int i=1;i<=q;i++)
  {
    int l,r;
    cin>>l>>r;
    v[r].pu({l,i});
  }
  for(int i=1;i<=n;i++)
  {
    update(i,1);
    update(last[a[i]],-1);
    last[a[i]]=i;
    for(int j=0;j<v[i].size();j++)
    {
      int l=v[i][j].ff;
      int idx=v[i][j].ss;
      // cout<<getSum(i)<<" "<<getSum(l-1)<<" "<<l<<" "<<i<<" "<<idx<<endl;;
      ans[idx]=getSum(i)-getSum(l-1);
    }
  }
  for(int i=1;i<=q;i++) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 33220
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char a,b;
int main()
{
	cin>>a>>b;
	if(a>b)
		cout<<'>';
	else if(a==b)
		cout<<'=';
	else 
		cout<<'<';
	return 0;
}

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

ans = - v[0] * 2 + v[-1] * 2

for i in range(n - k + 1):
    s = v[i]
    g = v[i + k - 1]
    if s > 0 or g < 0:
        if s < 0:
            m = - s
        else:
            m = g
    else:
        m = min(-s * 2 + g, -s + 2 * g)
    ans = min(ans, m)
print(ans)

Measured memory_bytes: 14384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

ll n,m;
vector<bool>A;

int main(){
  cin >> n >> m;
  A.assign(n+1,true);

  for(int i=0;i<m;i++){
    ll a;
    cin >> a;
    A[a] = false;
  }
  vector<ll>DP(n+1,0);

  DP[0]=1;
  if(A[1])DP[1]=1;
  for(int i=2;i<n+1;i++){
    if(A[i-1]) DP[i] += DP[i-1];
    if(A[i-2]) DP[i] += DP[i-2];
    DP[i] %= MOD;
  }
  cout<< DP[n] <<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
double dp[3010][3010];
int main() {
    int n;
    cin >> n;
    vector<double> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    dp[0][0] = 1.0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) {
            dp[i+1][j+1] += dp[i][j]*p[i];
            dp[i+1][j] += dp[i][j]*(1.0-p[i]);
        }
    }
    double ans = 0.0;
    for (int i = (n/2)+1; i <= n; ++i) {
        ans += dp[n][i];
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


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

int main() {
  //高さH，幅Wを宣言
  int H, W;
  cin >> H >> W;
  
  //文字列を宣言
  vector<vector<char>> s( H ,vector<char>(W));
  
  for (int i = 0; i < H; ++i){
    for (int j = 0; j < W; ++j){
      cin >> s.at(i).at(j) ;
    }
  }
  
  for (int i = 0; i < H+2; ++i){
    if(i == 0 || i == H+1){
      for (int j=0 ;j < W+2 ;++j ){
        cout << '#' ;
      }
      cout << endl;
    }
    else {
      cout << '#';	
        for (int j = 0; j < W; ++j){
        cout << s.at(i-1).at(j) ;
      }
      cout << '#' << endl;
   }
  }
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll long long
#define omar main
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//push_back make_pair emplace vector double float _unordered_map unodered_set queue stack sort begin end clear second first
using namespace std;

int omar() { fastIO
	int n; string str;
	cin >> n >> str;
	if (n%2) cout << "No" << endl;
	else {
		int l = 0, r = (n / 2);
		bool answer = 1;
		while (r != n){
			if (str[l] != str[r])answer = 0;
			if (!answer)break;
			++l;++r;
		} cout << ((answer)? "Yes" : "No") << endl;
	}
}


Measured memory_bytes: 3668
/*
* AUTHOR : Haoyang(Max) Chen
* INSTITUTION : Australian National Unversity
*/

#include <cmath>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

#define ll long long

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

	int l, ans=0;
	cin >> l;

	char input[l];
	cin >> input;

	vector<set<int>> a(10);
	for(int i = 0; i < l; ++i){
		int d = input[i] - '0'; // turn char into int
		a[d].insert(i);
	}

	for (int i = 0; i <= 9; ++i) {
		for (int j = 0; j <= 9; ++j) {
			for (int k = 0; k <= 9; ++k) {
				int pos = -1;
	            if (a[i].upper_bound(pos) == a[i].end()) continue;
	            pos = *a[i].upper_bound(pos);
	            if (a[j].upper_bound(pos) == a[j].end()) continue;
	            pos = *a[j].upper_bound(pos);
	            if (a[k].upper_bound(pos) == a[k].end()) continue;
	            pos = *a[k].upper_bound(pos);
	            ans++;
			}
		}
	}

	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	string S;
	cin >> S;
	int check = 0;
	int N = (int)S.size();
	if(S[0] != 'A')check = 1;
	int count = 0;
	int C = 0;
	for(int i=2;i<=N-2;i++){
		if(S[i] == 'C'){
			count++;
			C = i;
		}
	}
	if(count != 1)check = 1;
	for(int i=1;i<N;i++){
		if(S[i] < 'a' && i != C) check = 1;
	}
	if(check) cout << "WA" << endl;
	else cout << "AC" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=1e8;
const int oo=0x3f3f3f3f;
const double eps=1e-10;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,mod;
const int Maxn=1e5+5;
vector<int>G[Maxn];
int wayssubtree[Maxn],waysabove[Maxn];
int ans[Maxn];
void dfs1(int x,int par){
	wayssubtree[x]=1;
	rep(i,SZ(G[x])){
		int to=G[x][i];
		if(to==par)continue;
		dfs1(to,x);
		wayssubtree[x]=ll(wayssubtree[x])*(wayssubtree[to]+1)%mod;
	}
}
int cur[Maxn];
int pref[Maxn],suff[Maxn];
int ncur;
void dfs2(int x,int par){
	ncur=0;
	rep(i,SZ(G[x])){
		int to=G[x][i];
		if(to==par)continue;
		cur[ncur++]=to;
	}
	pref[0]=waysabove[x];rep(i,ncur)pref[i+1]=ll(pref[i])*(wayssubtree[cur[i]]+1)%mod;
	suff[ncur]=1;for(int i=ncur-1;i>=0;i--)suff[i]=ll(suff[i+1])*(wayssubtree[cur[i]]+1)%mod;
	rep(i,ncur){
		int to=cur[i];
		waysabove[to]=(ll(pref[i])*suff[i+1]+1)%mod;
	}

	rep(i,SZ(G[x])){//you cannot use "ncur" to dfs,because "ncur" may change in the leading process of dfs
		int to=G[x][i];
		if(to==par)continue;
		dfs2(to,x);
	}
}
void solve(){
	dfs1(0,-1);
	waysabove[0]=1;
	dfs2(0,-1);
	rep(i,n)ans[i]=ll(wayssubtree[i])*waysabove[i]%mod;
}
int main(){
	n=in();mod=in();
	rep(i,n-1){
		int u,v;
		u=in();v=in();
		u--;v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	solve();
	rep(i,n)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 13440
import itertools
n=int(input())
s=[input() for i in range(n)]
m=['M','A','R','C','H']
c=[0 for i in range(5)]
ans=0

for i in range(5):
    for j in range(n):
        if s[j][0].count(m[i])==1:
            c[i]+=1



for v in itertools.combinations(c, 3):
    ans+=v[0]*v[1]*v[2]
print(ans)

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

using namespace std;

int v[100], c[100];

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

	int n;

	cin >> n;

	for(int i = 0 ; i < n ; i++){
		cin >> v[i];
	}

	for(int i = 0 ; i < n ; i++){
		cin >> c[i];
	}

	int sum = 0;
	

	for(int i = 0 ; i < n ; i++){
		sum += max(0, v[i] - c[i]);
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()

N = list(map(int, input()))
K = int(input())


def solve():

    dp_sm = np.zeros((len(N), K + 1), np.int64)
    dp_lg = np.zeros((len(N), K + 1), np.int64)
    dp_sm[0][0] = 1
    dp_sm[0][1] = N[0] - 1
    dp_lg[0][0] = 0
    dp_lg[0][1] = 1

    for i in range(len(N) - 1):
        for j in range(K + 1):

            dp_sm[i + 1][j] += dp_sm[i][j]

            if N[i + 1] != 0:
                dp_sm[i + 1][j] += dp_lg[i][j]

            if j < K:
                dp_sm[i + 1][j + 1] += dp_sm[i][j] * 9

            if j < K and N[i + 1] != 0:
                dp_sm[i + 1][j + 1] += dp_lg[i][j] * (N[i + 1] - 1)
                dp_lg[i + 1][j + 1] += dp_lg[i][j]

            if N[i + 1] == 0:
                dp_lg[i + 1][j] += dp_lg[i][j]

    print(dp_sm[len(N) - 1][K] + dp_lg[len(N) - 1][K])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 12808
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#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 mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll n; cin >> n;
    vector<string> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    ll w = 0, x = 0, y = 0, z = 0;
    rep(i, 0, n){
        if(a[i] == "AC"){
            w++;
        }else if(a[i] == "WA"){
            x++;
        }else if(a[i] == "TLE"){
            y++;
        }else{
            z++;
        }
    }
    prt("AC x  "); prtl(w);
    prt("WA x  "); prtl(x);
    prt("TLE x  "); prtl(y);
    prt("RE x  "); prtl(z);
}




Measured memory_bytes: 6420
S = input()

flagYYMM = False
flagMMYY = False

T = S[2:]
T = int(T)
if 1 <= T <= 12:
    flagYYMM = True

T = S[:2]
T = int(T)
if 1 <= T <= 12:
    flagMMYY = True

if flagYYMM * flagMMYY == 1:
    ans = 'AMBIGUOUS'
elif flagYYMM == True:
    ans = 'YYMM'
elif flagMMYY == True:
    ans = 'MMYY'
else:
    ans = 'NA'

print(ans)


Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
	public void solve() {
		int K = ni();
		int X = ni();
		out.println(500 * K >= X ? "Yes" : "No");
	}
    static class PP{
    	public int key, val;
    	public PP(int key, int val) {
    		this.key = key;
    		this.val = val;
    	}
		public int getKey() {
			return key;
		}
		public void setKey(int key) {
			this.key = key;
		}
		public int getVal() {
			return val;
		}
		public void setVal(int val) {
			this.val = val;
		}
    }

    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 21844
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    s=chomp(readline())
    cnt=[Vector{Int}() for i in 1:3]
    color=[0 for i in 1:n]
    for i in 1:n
        if s[i]=='R'
            push!(cnt[1],i)
            color[i]=1
        elseif s[i]=='G'
            push!(cnt[2],i)
            color[i]=2
        else
            push!(cnt[3],i)
            color[i]=3
        end
    end
    l=[length(cnt[i]) for i in 1:3]
    ans=0
    for i in 1:n
        for j in i+1:n
            if s[i]==s[j]
                continue
            end
            if (s[i]=='R' && s[j]=='G') || (s[j]=='R' && s[i]=='G')
                res=searchsortedfirst(cnt[3],j)
                if l[3]<res
                    continue
                end
                ans+=l[3]-res+1
                if cnt[3][res]<=j+j-i<=n &&  color[j+j-i]==3
                    ans-=1
                end
            elseif (s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R')
                res=searchsortedfirst(cnt[2],j)
                if l[2]<res
                    continue
                end
                ans+=l[2]-res+1
                if cnt[2][res]<=j+j-i<=n && color[j+j-i]==2
                    ans-=1
                end
            else
                res=searchsortedfirst(cnt[1],j)
                if l[1]<res
                    continue
                end
                ans+=l[1]-res+1
                if cnt[1][res]<=j+j-i<=n &&  color[j+j-i]==1
                    ans-=1
                end
            end
        end
    end
    println(ans)
end
main()

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

int main(){
  int N;cin>>N;
  string S;cin>>S;
  
  int b=0,nb=0;//必要な(
  for(int i=0;i<N;i++){
    b+=(S[i]=='(')*2-1;
    if(b<0){nb++;b++;}
  }
  
  int c=0,nc=0;//必要な)
  for(int i=N-1;i>=0;i--){
    c+=(S[i]==')')*2-1;
    if(c<0){nc++;c++;}
  }
  string out="";
  for(int i=0;i<nb;i++)out+="(";
  out+=S;
  for(int i=0;i<nc;i++)out+=")";
  cout<<out;
  
}

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    print(sum((i & 1) & (a & 1) for i, a in enumerate(A)))
resolve()

Measured memory_bytes: 61792
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int a[102],b[102],c[10];

int main()
{
    NO_TLE
    int n,cnt=0,cnt2=0;
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)
    {
        if(a[i]>=1&&a[i]<=399)
        {
            c[1]++;
        }
        if(a[i]>=400&&a[i]<=799)
        {
            c[2]++;
        }
        if(a[i]>=800&&a[i]<1199)
        {
            c[3]++;
        }
        if(a[i]>=1200&&a[i]<=1599)
        {
            c[4]++;
        }
        if(a[i]>=1600&&a[i]<=1999)
        {
            c[5]++;
        }
        if(a[i]>=2000&&a[i]<=2399)
        {
            c[6]++;
        }
        if(a[i]>=2400&&a[i]<=2799)
        {
            c[7]++;
        }
        if(a[i]>=2800&&a[i]<=3199)
        {
            c[8]++;
        }
        if(a[i]>=3200)
        {
            cnt++;
        }
    }
    sort(c+1,c+9);
    rer(i,1,8)
    {
        if(c[i]!=0)
        {
            cnt2++;
        }
    }
    if(c[8]==0)cout<<'1'<<' '<<cnt<<endl;
    else cout<<cnt2<<' '<<cnt2+cnt<<endl;
    return 0;
}

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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

struct point{
    double x,y;
    
    point(double x=0,double y=0):x(x),y(y){}

    point operator + (point p){return point(x+p.x,y+p.y);}
    point operator - (point p){return point(x-p.x,y-p.y);}
    point operator * (point p){return point(x*p.x,y*p.y);}
    point operator / (point p){return point(x/p.x,y/p.y);}

    double abs(){return sqrt(norm());}
    double norm(){return x*x+y*y;}

    bool operator<(const point &p) const{
        return equals(x,p.x)?(y<p.y):(x<p.x);
    }

    bool operator==(const point &p) const{
        return equals(x,p.x)&&equals(y,p.y);
    }
};
double dot(point a,point b){
    return a.x*b.x+a.y*b.y;
}
double cross(point a,point b){
    return a.x*b.y-a.y*b.x;
}
bool isOrthogonal(point a,point b){
    return equals(dot(a,b),(0,0));
}
bool isOrthogonal(point a1,point a2,point b1,point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isParallel(point a,point b){
    return equals(cross(a,b),0.0);
}
bool isParallel(point a1,point a2,point b1,point b2){
    return isParallel(a1-a2,b1-b2);
}

int main(){
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int x1,y1,x2,y2,x3,y3,x4,y4;
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        point p0(x1,y1),p1(x2,y2),p2(x3,y3),p3(x4,y4);
        if(isOrthogonal(p0,p1,p2,p3)){
            cout<<"1\n";
        }else if(isParallel(p0,p1,p2,p3)){
            cout<<"2\n";
        }else{
            cout<<"0\n";
        }
    }
    return(0);
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,q;
vector<tuple<int,int,int> > v;
int main(){
    int si,ti,xi,di;
    cin>>n>>q;
    rep(i,n){
        cin>>si>>ti>>xi;
        v.pb(si-xi,1,xi);
        v.pb(ti-xi,-1,xi);
    }
    v.pb(1000100010,0,0);
    sort(v.begin(),v.end());
    int cur=0;
    set<int> st;
    rep(i,q){
        cin>>di;
        while(get<0>(v[cur])<=di){
            if(get<1>(v[cur])==1){
                st.insert(get<2>(v[cur]));
            }
            else{
                st.erase(get<2>(v[cur]));
            }
            ++cur;
        }
        if(st.size()==0){
            cout<<-1<<endl;
        }
        else{
            cout<<*st.begin()<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 15596
# -*- coding: utf-8 -*-

import numpy as np
import copy
from collections import deque

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

# マス目と距離保存のための箱を作成
d = []
mas = []
for i in range(n):
    mas.extend(list(map(list, input().split())))
    d.append([float("nan")] * m)


def tansaku(sx, sy, d):
    local_d = copy.deepcopy(d)
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sx, sy))
    local_d[sx][sy] = 0
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        for i in range(4):
            # 移動4方向をループ
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if (
                0 <= nx < n
                and 0 <= ny < m
                and mas[nx][ny] != "#"
                and not local_d[nx][ny] == local_d[nx][ny]
            ):
                # 移動できるならキューに入れ，その点の距離を p からの距離 +1 で確定する．最後Nan判定
                que.append((nx, ny))
                local_d[nx][ny] = local_d[p[0]][p[1]] + 1
    d_max = int(np.nanmax(np.array(local_d)))
    return d_max


dis = 0
for i in range(n):
    for j in range(m):
        if mas[i][j] != "#":
            dis_i = tansaku(i, j, d)
            if dis_i > dis:
                dis = copy.copy(dis_i)

print(dis)


Measured memory_bytes: 21120
MOD = 10**9+7

S = input()
N = len(S)
dp = [[0]*4 for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
    s = S[i]
    for j in range(4):
        if s == "?":
            dp[i+1][j] += dp[i][j]*3
        else:
            dp[i+1][j] += dp[i][j]
        dp[i+1][j] %= MOD
        if j < 3 and (s == "?" or s == "ABC"[j]):
            dp[i+1][j+1] += dp[i][j]
            dp[i+1][j+1] %= MOD
print(dp[N][3]%MOD)


Measured memory_bytes: 54252
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll K; string S; cin >> K >> S;
    if (S.size() <= K) cout << S << endl;
    else cout << S.substr(0, K) << "..." << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h> 

int main() { 
 double x[22], y[22], ans = 0; 
 int n = 0; 
 int l;
 while (scanf("%lf,%lf", &x[n], &y[n]) != -1) { 
  n++; 
 } 
 double s; 
 for (int i = 1; i < n; i++) { 
  s = (x[i] - x[0])*(y[(i + 1) % n] - y[0]) - (x[(i + 1) % n] - x[0])*(y[i] - y[0]); 
  if (s < 0)s = -s;
  ans += s;
 } 
 printf("%.8lf", ans/2.0); 
}


Measured memory_bytes: 2656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int N;
    string S;
    map<string, ll> T;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> S;
        sort(S.begin(), S.end());
        T[S]++;
    }
    ll ans = 0;
    /*for(auto& b : T){
        ll a = b.second;
        ans += (a) * (a - 1) / 2; 
    }*/
    for(map<string, ll>::iterator it = T.begin(); it != T.end(); it++){
        pair<string, ll> a = *it;
        ll c = a.second;
        ans += c * (c - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }


int main(){
    ll N, ans = 1;
    cin >> N;
    vector<ll> A(N, 0);
    for(int i = 0; i < N; i++) cin >> A[i];
    ll w = 0;
    for(int i = 0; i < N - 1; i++){
        if(w == 1 && A[i] < A[i + 1] || w == -1 && A[i] > A[i + 1]){
            ans++;
            w = 0;
        }
        else if(A[i] > A[i + 1] ) w = 1;
        else if(A[i] < A[i + 1] ) w = -1;
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 1024
f=lambda x:sum(map(int,str(x)))
ans=[]

def check(x):
    y=f(x)
    while ans:
        p=ans[-1]
        if p*y>x*f(p):ans.pop(-1)
        else:break
    ans.append(x)

k=int(input())
for i in range(1,100):
    check(i)
a,b=0,1
while a<1e12:
    for i in range(100,1000):
        check(i*b+a)
    a=a*10+9
    b*=10

for i in range(k):
    print(ans[i])

Measured memory_bytes: 3188
def main():
    H,W = list(map(int,input().split()))
    magic = [list(map(int,input().split())) for i in range(10)]
    wall = [list(map(int,input().split())) for i in range(H)]
    
    for k in range(10):
        for i in range(10):
            for j in range(10):
                magic[i][j] = min(magic[i][j],magic[i][k]+magic[k][j])
    
    ans = 0
    for h in range(H):
        for w in range(W):
            if wall[h][w] != -1:
                ans += magic[wall[h][w]][1]
    print(ans)
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
# -*- coding: utf-8 -*-
#include <bitset>

def judge(n, testimony, hypothesis):
    i = 0
    while i < n:
        if hypothesis & (1 << i):
            a, xlist, ylist = testimony[i]
            
            j = 0
            while j < a:                
                if (not (hypothesis & (1 << xlist[j])) and ylist[j] == 1) \
                    or ((hypothesis & (1 << xlist[j])) and ylist[j] != 1):
                    return False

                j += 1

        i += 1
    
    return True

# input
n = int(input())

i = 0
testimony = []
while i < n:
    a = int(input())
    xlist = []
    ylist = []

    j = 0
    while j < a:
        x, y = map(int, input().split())
        xlist.append(x - 1)
        ylist.append(y)

        j += 1

    tlist = [a, xlist, ylist]
    testimony.append(tlist)

    i += 1

# processing
num = 0

i = 0
bstr = ""
while i < n:
    bstr += "1"
    i += 1

b = int(bstr, 2)

hypothesis = 0b1
while hypothesis <= b:
    if judge(n, testimony, hypothesis):
        tnum = bin(hypothesis).count("1")
        if num < tnum:
            num = tnum

    hypothesis += 1

# output
print(num) 


Measured memory_bytes: 3064
import itertools as it
n,m,q=map(int, input().split())
x=[list(map(int, input().split())) for i in range(q)]
a,ans = [],0
for i in range(1,m+1):
    a.append(i)
b = list(it.combinations_with_replacement(a, n))
for i in range(0,len(b)):
    c = 0
    for j in range(0,len(x)):
        d,e,f = x[j][0],x[j][1],x[j][2]
        if b[i][e-1] - b[i][d-1] == f:
            c += x[j][3]
    if c > ans:
        ans = c
print(ans)

Measured memory_bytes: 21540
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;
void solve(){
	string s;
	cin>>s;
	sort(all(s));
	cout<<(s[0]==s[2]?"No":"Yes");
	
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
//#define endl "\n"
#define inf 1e18
#define mm 998244353

ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

/*
bool pp[1000001];
 
void func(){
	for(int i=2;i*i<=1000000;i++){
		if(pp[i]){
			for(int j=i*i;j<=1000000;j+=i) pp[j] = false;
		}
	}
}
*/

vector<ll> v;


void solve(){
	ll n; cin>>n;
	if(n == 1){
		cout<<0<<endl;
		return;
	}
	ll z = n;
	set<ll> s;
	ll m = 0;
	while(n%2 == 0){
		n /= 2;
		m++;
	}
	for(ll k=1;k<=m;k++){
		v.pb(pow(2,k));
	}
	for(ll i=3;i*i<=n;i += 2){
		m=0;
		while(n%i == 0){
			n /= i;
			m++;
		}
		for(ll k=1;k<=m;k++){
    		v.pb(pow(i,k));
    	}
	}
	if(n>2) v.pb(n);
	sort(all(v));
	ll y = 1;
		for(int i=0;i<v.size();i++){
			if(v[i] <= y) continue;
			if(z % v[i] == 0){
				z /= v[i];
				s.insert(v[i]);
				y = v[i];
			}
		}
	cout<<s.size()<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int n;
ll k;
vector<int> a, b;


bool check(ll x) { // a * b <= xにしなあかん
    
    ll sum = 0;
    rep(i, n) {
        ll tmp = x / b[i];
        sum += max(0LL, a[i] - tmp);
        // if (x == 1) cout << sum << endl;
    }
    if (sum <= k) return 1;
    
    return 0;
}

template<typename T>
void binary_search(T ok, T ng) {
    while (abs(ng - ok) > 1) {
        // cout << ok << " " << ng << endl;
        T mid = (ng + ok) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
}




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    cin >> n >> k;
    a.resize(n); // sortで事故る
    b.resize(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    sort(all(a));
    sort(all(b), greater<int>());
    // cout << endl; rep(i, n) cout << a[i] << " "; cout << endl;
    // rep(i, n) cout << b[i] << " "; cout << endl;
    binary_search((ll)1e15, (ll)-1);
   
    
}


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

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

    long long sum=0,partsum=0;
    if(K%2==1){
        for(int a=K;a<=N;a+=K){
           sum++;
        }
        sum=sum*sum*sum;
    }else{
        for(int a=K/2;a<=N;a+=K){
            sum++;
        }
        sum=sum*sum*sum;
        for(int a=K;a<=N;a+=K){
            partsum++;
        }
        sum+=partsum*partsum*partsum;
    }
    cout << sum << endl;
}    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int plus = a + b;
		int minus = a - b;
		int kakeru = a * b;
		System.out.println(Math.max(Math.max(plus, minus), kakeru));
	}
}


Measured memory_bytes: 21716
#map関数は、配列のすべての要素にアクセスすることが可能です。
#空白文字にはスペースや改行\n, タブ\tが含まれ、連続する空白文字はまとめて処理される。
N,M,K=map(int,input().split())

A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]

a=[0]
b=[0]

tmp_a=0
for i in A:
    tmp_a+=i
    a.append(tmp_a)
    
tmp_b=0
for i in B:
    tmp_b+=i
    b.append(tmp_b)
    


ans,j=0,M
for i in range(N+1):
    if a[i]>K:
        break
    while(1):
        if b[j]<=(K-a[i]):
            break
        j-=1
    ans=max(ans,i+j)
    
print(ans)

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

using namespace std;

const int MAXN = 10;

int n;

int x[MAXN];
int y[MAXN];
int v[MAXN];

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

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

	double ans = 0;

	do
	{
		double sum = 0;

		for(int j = 1 ; j < n ; j++)
		{
			int dx = x[ v[j] ] - x[ v[j + 1] ];
			int dy = y[ v[j] ] - y[ v[j + 1] ];

			double aux = dx*dx + dy*dy;
			sum += sqrt( aux );
		}

		ans += sum;
	} while( next_permutation( v + 1 , v + n + 1 ) );

	for(int i = 1 ; i <= n ; i++)
		ans /= i;

	printf("%.10f\n",ans);
}

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

int main(void) {
    int X, Y, A, B, C;
    std::cin >> X >> Y >> A >> B >> C;
    vector< int > p(A);
    for (int i = 0; i < A; i++) {
        cin >> p[i];
    }
    vector< int > q(B);
    for (int i = 0; i < B; i++) {
        cin >> q[i];
    }
    vector< int > r(C);
    for (int i = 0; i < C; i++) {
        cin >> r[i];
    }
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());
    reverse(p.begin(), p.end());
    reverse(q.begin(), q.end());
    reverse(r.begin(), r.end());
    vector< long long > t(X + Y);
    for (int i = 0; i < X; i++) {
        t[i] = p[i];
    }
    for (int i = 0; i < Y; i++) {
        t[X + i] = q[i];
    }
    sort(t.begin(), t.end());
    for (int i = 0; i < C && i < X + Y; i++) {
        if (t[i] < r[i]) {
            t[i] = r[i];
        } else {
            break;
        }
    }
    long long ans = 0;
    for (int i = 0; i < X + Y; i++) {
        ans += (long long)t[i];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2816