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

int main() {
    int N;
    cin >> N;
    vector <int> p(N);
    for (int i = 0; i < N; i++){
        cin >> p.at(i);
    }

    for (int i = 0; i < N; i++){
        if (p.at(i) % 2 == 0  && p.at(i) % 3 != 0 && p.at(i) % 5 != 0){
           cout << "DENIED" << endl;
           return 0; 
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
string w[110];
int main() {
  int n; cin >> n;
  rep(i, n) cin >> w[i];
  
  bool ok = true;
  set<string> s;
  s.insert(w[0]);
  for (int i = 1; i < n; i++) {
 	if (w[i][0] != w[i-1][w[i-1].size()-1]) ok = false;
    if (s.find(w[i]) != s.end()) ok = false;
    s.insert(w[i]);
  }
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, k;
int cnt = 1, ans;

signed main() {
	cin >> n >> k;
	while (cnt <= n) {
		cnt *= k;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]


N, M = map(int, input().split())

l_max = 1
r_min = N

for i in range(M):
    L, R = map(int, input().split())

    l_max = max(l_max, L)
    r_min = min(r_min, R)

print(max(r_min - l_max + 1, 0))


Measured memory_bytes: 40556
//最少全域木
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int G[103][103];
int V;
int NG[103][103];//新しくできるほう
int used[103];
int main(){
	int ans=0;
	cin>>V;
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
		cin>>G[i][j];
		}
	}
	for(int i=0;i<103;i++)for(int j=0;j<103;j++)NG[i][j]=-1;
	used[0]=1;
	for(int i=0;i<V;i++){
		int u=-1,a,b;
		for(int j=0;j<V;j++){
		if(used[j]==0)u=i;
		}
		if(u==-1)break;
		int now=99999999;
		for(int j=0;j<V;j++){
			for(int k=0;k<V;k++){
			if(now>G[j][k]&&G[j][k]!=-1&&used[j]==1&&used[k]==0){
			now=G[j][k];
			a=j,b=k;
			}
			}
		}
		ans+=G[a][b];
		used[b]=1;
		NG[a][b]=G[a][b];
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(void){
	int a, b, c, d, sec[101] = {}, done = 0;
	cin >> a >> b >> c >> d;
	for (int i = a; i < b; ++i){
		sec[i]++;
	}
	for (int i = c; i < d; ++i){
		sec[i]++;
	}
	for (int i = 0; i < 101; ++i){
		if (sec[i] == 2){
			done++;
		}
	}
	cout << done << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		String tmp;
		for (int j = n - 1; j > 0; j--) {
			for (int i = 0; i < j; i++) {
				if (s[i].compareTo(s[i + 1]) > 0) {
					tmp = s[i];
					s[i] = s[i + 1];
					s[i + 1] = tmp;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.print(s[i]);
		}
		System.out.println();
		sc.close();
	}
}

Measured memory_bytes: 21204
#include <iostream>

using namespace std;

int main(){
	string s;
	cin >> s;
	for (int i = 0; i < s.length() - 1; ++i) {
		if (s[i] == s[i + 1]) { 
			cout << i + 1 << " " << i + 2;
			return 0;
		}
	}
	for (int i = 0; i < s.length() - 2; ++i) {         // to check for substrings of length 3 like "aba"
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3;
			return 0;
		}	
	}
	cout << -1 << " " << -1;
	return 0;
}

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int s,g;cin>>s>>g;
    int ans;
    if(s<=g){
        if((s>=0&&g>=0)||(s<=0&&g<=0))ans=g-s;
        else ans=max(abs(s),abs(g))-min(abs(s),abs(g))+1;
    }
    else{
        int tmp=max(abs(s),abs(g))-min(abs(s),abs(g));
        if((s>0&&g>0)||(s<0&&g<0))ans=tmp+2;
        else ans=tmp+1;
    }
    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;

class UnionFind {
private:
	int height[1000], parent[1000];
	int size;
public:
	UnionFind(int size) : size(size) {
		for (int i = 0; i < size; ++i) {
			parent[i] = i;
		}
		fill(height, height+size, 0);
	}
	bool isUnited(int a, int b) {
		return root(a) == root(b);
	}
	int root(int n) {
		if (n == parent[n]) return n;
		return root(parent[n]);
	}
	void unite(int a, int b) {
		a = root(a), b = root(b);
		if (height[a] < height[b]) {
			parent[a] = b;
		}
		else if (height[a] > height[b]) {
			parent[b] = a;
		}
		else {
			parent[b] = a;
			height[b]++;
		}
	}
};

const int inf = 1e9;

int main() {
	int N; cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; ++i) {
		cin >> v[i];
	}
	map<int, int> m;
	for (int i = 0; i < N; ++i) {
		m[v[i]] = i;
	}
	vector<int> to = v;
	sort(to.begin(), to.end());

	UnionFind uf(N);
	for (int i = 0; i < N; ++i) {
		uf.unite(i, m[to[i]]);
	}
	map<int, int> g;
	vector<int> sum(N);
	vector<int> mn(N, inf);
	for (int i = 0; i < N; ++i) {
		int id = uf.root(i);
		sum[id] += v[i];
		mn[id] = min(mn[id], v[i]);
		g[id]++;
	}
	ll ans = 0;
	for (const pair<int, int>& p : g) {
		int i = p.first, n = p.second;
		ans += sum[i]-mn[i] + min(mn[i]*(n-1), (to[0]+mn[i])*2+to[0]*(n-1));
	}
/*
	ll ans = 0;
	for (int i = N-1; i >= 0; --i) {
		if (v[i] == to[i]) continue;
		int j = now[to[i]];
		swap(v[i], v[j]);
		now[v[i]] = j;
		now[v[j]] = i;
		ans += v[i]+v[j];
	}
*/
	cout << ans << endl;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def dfs(N, nodes, src):
    """ DFS(木、スタック、重みなし) """

    stack = [(src, -1, 0)]
    dist = [INF] * N
    while stack:
        u, prev, c = stack.pop()
        dist[u] = c
        for v in nodes[u]:
            if v != prev:
                stack.append((v, u, c+1))
    return dist

N = INT()
nodes = [[] for i in range(N)]
for i in range(N-1):
    a, b = MAP()
    a -= 1; b -= 1
    nodes[a].append(b)
    nodes[b].append(a)

# それぞれから最短距離
res1 = dfs(N, nodes, 0)
res2 = dfs(N, nodes, N-1)

cnt = 0
for i in range(N):
    # 相手より距離が近い場所(同値含む)は自分のマスにできる
    if res1[i] <= res2[i]:
        cnt += 1
# 自分のマスが半分超なら勝ち(半分ちょうどだと負ける)
if cnt > N // 2:
    print('Fennec')
else:
    print('Snuke')


Measured memory_bytes: 29092
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextInt();
		long w = sc.nextInt();
		int n = sc.nextInt();
		HashMap<Long, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
		    int hh = sc.nextInt() - 1;
		    int ww = sc.nextInt() - 1;
		    for (int j = 0; j < 3 && hh - j >= 0; j++) {
		        if (hh - j >= h - 2) {
		            continue;
		        }
		        for (int k = 0; k < 3 && ww - k >= 0; k++) {
		            if (ww - k >= w - 2) {
		                continue;
		            }
		            long key = (hh - j) * w + ww - k;
		            if (map.containsKey(key)) {
		                map.put(key, map.get(key) + 1);
		            } else {
		                map.put(key, 1);
		            }
		        }
		    }
		}
		long[] values = new long[10];
		for (int x : map.values()) {
		    values[x]++;
		}
		values[0] = (h - 2) * (w - 2) - map.size();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 10; i++) {
		    sb.append(values[i]).append("\n");
		}
		System.out.print(sb);
   }
}




Measured memory_bytes: 164992
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

constexpr int MOD = 1000000007;
ll modpow(ll n, ll r, ll mod) {
    if(r == 0) return 1;
    if(n == 0) return 0;
    if(r % 2 == 0) {
        ll tmp = modpow(n, r / 2, mod);
        return tmp * tmp % mod;
    }
    else {
        return n * modpow(n, r - 1, mod) % mod;
    }
}

int main(){
    ll r, D, x;
    read(r, D, x);
    for(int i = 0; i < 10; i++){
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
#include <iomanip>
#include <functional>
#include <stack>
#include <numeric>
#include <utility>
#include <queue>
#define PI 3.1415926535
#define FOR(i,n) for (int i=1; i<(n) ;i++)
#define INF 114514810

using namespace std;

int n, t, ans = 0;
int c2 = 0, c5 = 0;

int main(){
	while (true){
		cin >> n;
		if (n == 0) break;
		FOR(i, n + 1){
			t = i;
			while (t % 2 == 0){
				t /= 2;
				c2++;
			}
			t = i;
			while (t%5==0) {
				t /= 5;
				c5++;
			}
		}
		cout << min(c2, c5) << endl;
		c2 = c5 = 0;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll long long int
int main(void){
    // Your code here!
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 ll i,b,x;
 cin >> x;
 for(i=1;i<=sqrt(x);i++)
 {
  if(x%i==0)
  {
   for(b=-50000;b<=50000;b++)
   {
    if(i>=b)
    {
     if((ll)(pow(b+i,5)-pow(b,5))==x)
     {
      cout << b+i << " " << b;
      return 0;
     }
    }
   }
   if(i!=(x/i)){
   for(b=-50000;b<=50000;b++)
   {
    if((x/i)>=b)
    {
     if((ll)(pow(b+x/i,5)-pow(b,5))==x)
     {
      cout << b+x/i << " " << b;
      return 0;
     }
    }
   }
  }}
 }
 return 0;
}

Measured memory_bytes: 4276
n = int(input())
ans = float("Inf")
for i in range(1,int(n**0.5)+2):
    count = 0
    if n % i == 0:
        a = max(n//i,i)
        while a:
            a = a // 10
            count += 1
        ans = min(ans,count)
print(ans)

Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


n, x = inm()


def solve():
    if x == 1 or x == 2 * n - 1:
        print("No")
        return
    a = [None] * (2 * n - 1)

    m = (2 * n - 1) // 2
    a[m] = x
    a[m - 1] = x - 1
    a[m + 1] = x + 1
    y = 1
    for i in range(2 * n - 1):
        if i in [m - 1, m, m + 1]:
            continue
        if y in [x - 1, x, x + 1]:
            y = x + 2
        a[i] = y
        y += 1

    print("Yes")
    print(*a, sep="\n")


solve()


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

using namespace std;

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

    int n,p;
    while(cin>>n>>p,n&&p){
        int idx=0;
        vector<int> stones(n,0);
        int cup=p;
        while(true){
            if(cup){
                stones[idx]++;
                cup--;
            }
            else{
                cup+=stones[idx];
                stones[idx]=0;
            }
            if(stones[idx]==p) break;
            idx++;
            idx%=n;
        }
        cout<<idx<<endl;
    }
}

Measured memory_bytes: 3080
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <bitset>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M;
    cin >> N >> M;
    int all = (1 << M) - 1;
    FOR(i, 0, N) {
        int K;
        cin >> K;
        int one = 0;
        FOR(j, 0, K) {
            int f;
            cin >> f;
            f--;
            one |= 1 << f;
        }

        all &= one;
    }

    int ret = 0;
    FOR(bit, 0, 30)
        if (all & (1 << bit))
            ret++;
    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long dp[100000], h[100000];
int n, k;
long long calc(int u)
{

    if(dp[u] != -1)
        return dp[u];

    dp[u] = 1e18;
    for (int i = 1; i <= min(k, n-u-1); ++i) {
        dp[u] = min(dp[u], abs(h[u] - h[u+i]) + calc(u+i));
    }

    return dp[u];
}

int main( )
{
    memset(dp, -1, sizeof(dp));
    cin >> n >> k;
    dp[n-1] = 0;
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    cout << calc(0) << endl;
}

Measured memory_bytes: 6528
int_h, int_w = map(int,input().split())

ar_in = list()
for i in range(int_h):
    ar_in.append(list(input().split()))

print("#" * (int_w + 2))

for i in ar_in:
    print("#" + "".join(i) + "#")

print("#" * (int_w + 2))


Measured memory_bytes: 3060
import itertools
l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
    exit()
w = []
q = list(itertools.combinations(range(l,r+1),2))
for i in range(len(q)):
    w.append((q[i][0]*q[i][1])%2019)

print(min(w))

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

int main () {
  string S;
  cin >> S;
  int64_t result = 0, n = S.size();
  for (int i = 0; i < 1 << n - 1; i++) {
    int64_t index = 0, count = 1, add_num;
    bitset<9> plus(i);
    for (int j = n - 2; -1 < j; j--) {
      if (plus.test(j) & 1) {
        add_num = stol(S.substr(index, count));
        index = index + count;
        result += add_num;
        count = 1;
      } else count++;
    }
    add_num = stol(S.substr(index, n));
    result += add_num;
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int N, spe, K;
	int A[100009];
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int z = (N - K) % (K - 1);
	int ans = (N - K) / (K - 1);
	if (z == 0) cout << ans + 1 << endl;
	else cout << ans + 2 << endl;
}

Measured memory_bytes: 640
sx,sy,tx,ty = gets.split(" ")
route=""
sx=sx.to_i
sy=sy.to_i
tx=tx.to_i
ty=ty.to_i

if tx>sx
  ax,bx = sx,tx
else
  ax,bx = tx,sx
end
if ty>sy
  ay,by = sy,ty
else
  ay,by = ty,sy
end

h=(ty-sy).abs
w=(tx-sx).abs

route+="U"*h
route+="R"*w
route+="D"*h
route+="L"*w
route+="L"
route+="U"*(h+1)
route+="R"*(w+1)
route+="D"
route+="R"
route+="D"*(h+1)
route+="L"*(w+1)
route+="U"

if ty-sy>0
else
  route=route.gsub(/[UD]/,"U"=>"D","D"=>"U")
end

if tx-sx>0
else
  route=route.gsub(/[LR]/,"L"=>"R","R"=>"L")
end

print route

Measured memory_bytes: 1916
//40%	N<=1e3	Ai<=1e4
//100%	N<=1e6	Ai<=1e9
#include <cstdio>
typedef long long LL;
int main()
{
	int N, i, x, left = 0;
	LL ans = 0;
	scanf("%d", &N);
	for(i=0; i<N; ++i)
	{
		scanf("%d", &x);
		if(left && x)
			++ans, --x;
		ans += x>>1;
		left = x&1;
	}
	printf("%lld\n", ans);
}

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

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

int main(){
  
    int N;
    cin>>N;
    vector<int> S(N),A(N),B(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    for(int i=0;i<N;i++){
        if(i==0){
            A[0]=S[0];
            B[N-1]=S[N-1];
        }
        else{
            A[i]=gcd(A[i-1],S[i]);
            B[N-1-i]=gcd(B[N-i],S[N-1-i]);
        }
    }
    int ans=B[1];
    for(int i=1;i<N;i++){
        int t;
        if (i!=N-1) t=gcd(A[i-1],B[i+1]);
        else t=A[N-2];
        ans=max(ans,t);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1408
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long
#define pii pair<int,int>
#define x first
#define y second

const int N=55;
map<pii,int> cnt;
pii a[N];
int n,ma;

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i].x,a[i].y);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) ma=max(ma,++cnt[pii(a[j].x-a[i].x,a[j].y-a[i].y)]);
	write(n-ma);
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, n) {
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}
	int ans = inf;
	rep(bit, (1 << n)) {
		vector<int> tmp(m);
		int cnt = 0;
		rep(i, n) {
			if (bit & (1 << i)) {
				rep(j, m) tmp[j] += a[i][j];
				cnt += c[i];
			}
		}
		bool ok = true;
		rep(i, m) if (tmp[i] < x) ok = false;
		if (ok) mins(ans, cnt);
	}
	cout << (ans == inf ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 3664
fn main() {
    let s: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    if s[0] == 'R' && s[1] == 'R' && s[2] == 'R' {
        println!("3");
    } else if (s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R') {
        println!("2");
    } else if s[0] == 'R' || s[1] == 'R' || s[2] == 'R' {
        println!("1");
    } else {
        println!("0");
    }
}

Measured memory_bytes: 2076
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll a[N];
    rep(i, N){
        cin >> a[i];
    }
    sort(a, a + N);

    cout << a[N - 1] - a[0] << endl;

    return 0;
}

Measured memory_bytes: 3552
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int ans[11000];
int main(){
	for(int i=1;i*i<=10000;i++){
		for(int j=1;i*i+j*j+i*j<=10000;j++){
			for(int k=1;i*i+j*j+i*j+i*k+j*k+k*k<=10000;k++){
				ans[i*i+j*j+i*j+i*k+j*k+k*k]++;
			}
		}
	}
	int a;scanf("%d",&a);
	for(int i=1;i<=a;i++){
		printf("%d\n",ans[i]);
	}
}

Measured memory_bytes: 1740
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            int n = Integer.parseInt(sc.nextLine());
            String[] lslist = sc.nextLine().split(" ");
            int[] lary = new int[lslist.length];
            
            for(int i = 0; i < lslist.length; i++){
                lary[i] = Integer.parseInt(lslist[i]);
            }

            int max = lary[0];
            int lsum = lary[0];
            for(int i = 1; i < lary.length; i++){
                max = Math.max(lary[i], max);
                lsum += lary[i];
            }
            lsum -= max;
            
            if(lsum > max){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }

		}
    }
}

Measured memory_bytes: 21716
N = int(input())

N = N % 10
if N==0:
    print('pon')
elif N==1:
    print('pon')
elif N==2:
    print('hon')
elif N==3:
    print('bon')
elif N==4:
    print('hon')
elif N==5:
    print('hon')
elif N==6:
    print('pon')
elif N==7:
    print('hon')
elif N==8:
    print('pon')
elif N==9:
    print('hon')
    

Measured memory_bytes: 9192
#include "bits/stdc++.h"
using namespace std;
int main() {
	string const Alphabet = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
	string S;
	cin >> S;
	long long N;
	cin >> N;
	vector<int>A(S.size());
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 26; j++) {
			if (S.at(i) == Alphabet.at(j)) A.at(i) = j;
		}
	}
	for (int i = 0; i < S.size(); i++) {
		if (A.at(i) != 0) {
			if (N >= 26 - A.at(i)) {
				int sum = 26 - A.at(i);
				N -= sum;
				A.at(i) = 0;
			}
		}
	}
	if (N > 0){
		int const k = N % 26;
		A.at(S.size() - 1) += k;
	}
	for (int i = 0; i < S.size(); i++) {
		cout << Alphabet.at(A.at(i));
	}
	cout << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N;
const int Nmax=1e4+10;
ll A[Nmax];

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

int main(){
	cin >> N;
	for(int i=0; i<=N; i++) cin >> A[i];

	vector<bool> is_prime(N+1, true);
	is_prime[0] = is_prime[1] = false;
	for(int p=2; p*p<=N; p++){
		if(!is_prime[p]) continue;
		for(int j=2; p*j<=N; j++) is_prime[p*j]=false;
	}
	vector<int> primes;
	primes.push_back(2);
	for(int p=3; p<=N; p+=2){
		if(is_prime[p]){
			primes.push_back(p);
		}
	}

	ll g=abs(A[N]);
	for(int i=0; i<N; i++){
		g = gcd(g, abs(A[i]));
	}
	//cout << g << endl;

	vector<int> factor;
	for(int p=2; p*p<=g; p++){
		while(g%p==0){
			factor.push_back(p);
			g /= p;
		}
	}
	if(g>1) factor.push_back(g);

	vector<ll> x(N+1);
	for(int k=0; k<primes.size(); k++){
		int p = primes[k];
		for(int i=0; i<=N; i++) x[i] = A[i]%p;
		for(int i=0; i<=N-p; i++){
			x[i+p-1] = (x[i+p-1]+x[i])%p;
			x[i] = 0;
		}
		bool f=true;
		for(int i=0; i<=N; i++) f = f&&(x[i]==0);
		//cout << p << endl;
		//for(int i=0; i<=N; i++) cout << x[i] << (i==N?'\n':' ');
		if(f) factor.push_back(p);
	}

	sort(factor.begin(), factor.end());
	auto end = unique(factor.begin(), factor.end());
	for(auto i=factor.begin(); i!=end; i++){
		cout << *i << endl;
	}


	return 0;
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
long long dp[105][100005];
int main()
{
    int n,w;
    cin>>n>>w;
    int i,j;
    long long ww[n+1],v[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>ww[i]>>v[i];
    }
    dp[1][v[1]]=ww[1];
    for(i=2;i<=n;i++)
    {
        for(j=0;j<=100000;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(dp[i][j]==0)
            {
                dp[i][j]=1e18;
            }
            if(j==v[i])
            {
                dp[i][j]=min(dp[i][j],ww[i]);
            }
            else if((j-v[i])>=0&&dp[i-1][j-v[i]]>0&&dp[i-1][j-v[i]]!=1e18)
            {
                dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+ww[i]);
            }
        }
    }
    for(i=100000;i>=0;i--)
    {
        if(dp[n][i]>0&&dp[n][i]<=w)
        {
            cout<<i<<endl;
            return 0;
        }
    }
}


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

int main(){
	int a, b, d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a%b;
	f = (double)a / (double)b;
	printf("%d %d %.5lf\n",d,r,f);
	return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,res = 0;
    string str;
    cin>>str;
    map<char,int>mp;
    for(n = 0;n < str.size();n++)
    {


            mp[str[n]]++;

    }
    for(n = 0;n < str.size();n++)
       {
       if(mp[str[n]]>1)
       {
        res = 1;
        break;

       }

       }
    if(res==0)
       cout<<"yes\n";
    else
    cout<<"no"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  vector<P> itv(m);
  REP(i,m){
    cin >> itv[i].second >> itv[i].first;//終了時間，開始時間
  }
  int ans=0,t=0;
  VSORT(itv)
  REP(i,m){
    if(t <= itv[i].second){
      ans++;
      t = itv[i].first;
    }
  }
  cout << ans << endl;
}

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

namespace TYC
{
	typedef long long ll;
	const int N = 8005, M = 205, MAXN = 1 << 15 | 5, mod = 998244353, INV2 = (mod + 1) >> 1;

	int F[M][N], Fac[N], Inv[N], A[MAXN], B[MAXN], w[MAXN], rev[MAXN];

	inline int qpow(int x, int tim)
	{
		int ans = 1;
		for (; tim; tim >>= 1, x = (ll)x * x % mod)
			if (tim & 1)
				ans = (ll)ans * x % mod;
		return ans;
	}

	void init(const int n)
	{
		for (int i = 0; i < n; i++)
			rev[i] = (rev[i >> 1] >> 1) | ((i & 1) * (n >> 1));
		w[0] = 1, w[1] = qpow(3, (mod - 1) / n);
		for (int i = 2; i < n; i++)
			w[i] = (ll)w[i - 1] * w[1] % mod;
	}

	void NTT(int *a, const int n, const int type)
	{
		for (int i = 0; i < n; i++)
			if (i < rev[i])
				swap(a[i], a[rev[i]]);
		if (type)
			reverse(w + 1, w + n);
		for (int len = 1; len < n; len <<= 1)
			for (int i = 0; i < n; i += len << 1)
				for (int k = 0; k < len; k++)
				{
					int x = a[i + k], y = (ll)w[n / (len << 1) * k] * a[i + len + k] % mod;
					a[i + k] = (x + y) % mod;
					a[i + len + k] = (x - y + mod) % mod;
				}
		if (type)
		{
			reverse(w + 1, w + n);
			for (int i = 0, t = qpow(n, mod - 2); i < n; i++)
				a[i] = (ll)a[i] * t % mod;
		}
	}

	inline int C(const int x, const int y)
	{ return x < y ? 0 : (ll)Fac[x] * Inv[x - y] % mod * Inv[y] % mod; }

	void work()
	{
		int n, m;
		scanf("%d%d", &n, &m);
		int t = max(n++, m) + 2;
		Fac[0] = 1;
		for (int i = 1; i <= t; i++)
			Fac[i] = (ll)Fac[i - 1] * i % mod;
		Inv[t] = qpow(Fac[t], mod - 2);
		for (int i = t; i; i--)
			Inv[i - 1] = (ll)Inv[i] * i % mod;

		int len;
		for (len = 1; len < (n << 1); len <<= 1);
		init(len);
		F[0][0] = 1;
		for (int j = 1; j <= m; j++)
		{
			for (int i = 0; i < n; i++)
			{
				A[i] = (ll)F[j - 1][i] * Inv[i] % mod;	
				B[i] = Inv[i + 2];
			}
			B[0] = 0;
			memset(A + n, 0, sizeof(int[len - n]));
			memset(B + n, 0, sizeof(int[len - n]));
			NTT(A, len, 0);
			NTT(B, len, 0);
			for (int i = 0; i < len; i++)
				A[i] = (ll)A[i] * B[i] % mod;
			NTT(A, len, 1);
			for (int i = 0; i < n; i++)
				F[j][i] = (((ll)i * (i + 1) / 2 + 1) % mod * F[j - 1][i] % mod + (ll)A[i] * Fac[i + 2] % mod) % mod;
		}
		int ans = 0;
		for (int i = 0; i < n; i++)
			ans = (ans + (ll)F[m][i] * C(n - 1, i)) % mod;
		printf("%d\n", ans);
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 10340
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		long []arr =new long[n];
		long sum=0;
		HashMap<Long,Long> hm=new HashMap<>();
		for(int i=0;i<n;i++){
			arr[i]=scn.nextLong();
			sum+=arr[i];
			if(hm.containsKey(arr[i])){
				hm.put(arr[i],  hm.get(arr[i])+1l);
			}else{
				hm.put(arr[i], 1l);
			}
		}
		//System.out.println(sum);
        int q =scn.nextInt();
        StringBuilder sb=new StringBuilder();
        while(q-->0){
        	long b=scn.nextLong();
        	long c=scn.nextLong();
        	if(hm.containsKey(b)==false){
        		sb.append(sum+""+'\n');
        		continue;
        	}
        	long count = hm.get(b);
        	sum+=(c-b)*count;
        	hm.remove(b);
        	if(hm.containsKey(c)){
        		hm.put(c, hm.get(c)+count);
        	}else{
        		hm.put(c, count);
        	}
        	//System.out.println(sum);
        	sb.append(sum+""+'\n');
        	
        }
        System.out.print(sb);
	}

}

Measured memory_bytes: 71632
open System
let mutable s = Console.ReadLine().Split()
let n = int(s.[0])
let c = int(s.[1])
let mutable d : string array = Console.ReadLine().Split()
let mutable i = 1
while i < c do
    d <- Array.append d (Console.ReadLine().Split())
    i <- i + 1
let GetD = fun x y -> int(d.[(c * (x - 1) + y - 1)])
let mutable m0 : int array = Array.zeroCreate (n * n)
let mutable m1 : int array = Array.zeroCreate (n * n)
let mutable m2 : int array = Array.zeroCreate (n * n)
i <- 1
let mutable j = 1
let mutable p = 0
let mutable q = 0
let mutable r = 0
while i <= n do
    s <- Console.ReadLine().Split()
    while j <= n do
        if (i + j) % 3 = 0 then
            m0.[p] <- int(s.[j - 1])
            p <- p + 1
        if (i + j) % 3 = 1 then
            m1.[q] <- int(s.[j - 1])
            q <- q + 1
        if (i + j) % 3 = 2 then
            m2.[r] <- int(s.[j - 1])
            r <- r + 1
        j <- j + 1
    i <- i + 1
    j <- 1
i <- 0
let mutable d0 : int array = Array.zeroCreate c
let mutable d1 : int array = Array.zeroCreate c
let mutable d2 : int array = Array.zeroCreate c
while i < c do
    let mutable t = 0
    j <- 0
    while j < m0.Length do
        if m0.[j] <> 0 then
            t <- t + GetD m0.[j] (i + 1)
        j <- j + 1
    d0.[i] <- t
    t <- 0
    j <- 0
    while j < m1.Length do
        if m1.[j] <> 0 then
            t <- t + GetD m1.[j] (i + 1)
        j <- j + 1
    d1.[i] <- t
    t <- 0
    j <- 0
    while j < m2.Length do
        if m2.[j] <> 0 then
            t <- t + GetD m2.[j] (i + 1)
        j <- j + 1
    d2.[i] <- t
    i <- i + 1
let mutable ans = 250000000
let mutable k = 0
i <- 0
while i < c do
    j <- 0
    while j < c do
        k <- 0
        while k < c do
            if i <> j && j <> k && k <> i then
                ans <- min ans (d0.[i] + d1.[j] + d2.[k])
            k <- k + 1
        j <- j + 1
    i <- i + 1
printfn "%d" ans

Measured memory_bytes: 20692
def main():
    A, V = list(map(int, input().split(' ')))
    B, W = list(map(int, input().split(' ')))
    T = int(input())
    if (V - W) * T >= abs(A - B):
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
import sys
from fractions import gcd

PO = "POSSIBLE"
IM = "IMPOSSIBLE"
ans = ""


N, K = map(int, input().split())		# 5 7
a = list(map(int, input().split()))	# 1 2 3 4 5 ...

if max(a)<K:
	print(IM)
	sys.exit()

if K in a:
	print(PO)
	sys.exit()

g=a[0]
for i in range(1,N):
	g = gcd(g,a[i])
	if K%g==0:
		ans=PO
		break
else:
	ans=IM

print(ans)


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

int main(){
	int n;
	cin >> n;
	long long int sum=0;
	for(int i=0;i<=n;i++)
	{
		if(i % 3 != 0 && i % 5 !=0) sum+=i;
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <ctime>
#include <deque>
#include <ctime>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cassert>
#include <cstring>
#include <queue>
#include <random>

#define fi first
#define se second
#define ll long long
#define pii pair<int, int>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pll pair<long long, long long>
#define mp(x, y) make_pair((x), (y))

using namespace std;
const int INF = 1e9 + 100;

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

    int n, m;
    cin >> n >> m;
    vector<int> dp(1 << n, INF);
    dp[0] = 0;

    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        int cur = 0;
        for (int i = 0; i < b; ++i) {
            int x;
            cin >> x;
            x--;
            cur |= (1 << x);
        }
        for (int j = 0; j < (1 << n); ++j) {
            int to = (j | cur);
            dp[to] = min(dp[to], dp[j] + a);
        }
    }

    if (dp[(1 << n) - 1] == INF) {
        cout << -1 << endl;
    } else {
        cout << dp[(1 << n) - 1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] A = new int[N + 1];
		int[][] x = new int[N + 1][N + 1];
		int[][] y = new int[N + 1][N + 1];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			for (int j = 0; j < A[i]; j++) {
				x[i][j] = sc.nextInt();
				y[i][j] = sc.nextInt();
			}
		}

		int max = 0;

		for (int bit = 0; bit < (1 << N); bit++) {
			boolean flag = true;

			for (int i = 0; i < N; ++i) {
				if (((bit >> i) & 1) == 0) {
					continue;
				}
				for (int j = 0; j < A[i]; j++) {
					if ((((bit >> (x[i][j] - 1)) & 1) ^ y[i][j]) != 0) {
						flag = false;
					}
				}

			}
			if (flag)
				max = Math.max(max, counter(bit));

		}
		System.out.println(max);

	}

	// 正直者の人数カウンタ
	public static int counter(int x) {
		if (x == 0)
			return 0;
		return (x & 1) + counter(x >> 1);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22356
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

ll f(ll b, ll n) {
  if (n < b) return n;
  return f(b, n / b) + n % b;
}

int main() {
  ll N, S;
  cin >> N >> S;
  if (N == S) {
    cout << N + 1 << endl;
    return 0;
  }
  for(ll b = 2; b * b <= N; b++) {
    if (f(b, N) == S) {
      cout << b << endl;
      return 0;
    }
  }

  // ARC解説より:
  // ここで見つからなかった地点で、bはsqrt(N)より大きい
  // b が結構大きいので、Nはb進数で2桁になるはず
  // よって、N = pb + q, 1<=p<b, 0<=q<b　と表せる
  // pの範囲について、N = pb + q >= pb > p^2 となるため
  // p < sqrt(N)
  // pを全探索できる。pを決めると、p + q = S から
  // b = (N - q) / p = (N - S + p) / p = (N - S) / p + 1
  // と決まる。あとは、f(b, N) = Sかどうか確認すれば良い

  ll ans = -1;
  for(ll p = 1; p * p < N; p++) {
    if ((N - S) % p != 0) continue;
    ll b = (N - S) / p + 1;
    if (b <= 1) continue;
    if (f(b, N) == S) {
      ans = b;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define REPR(i,n) for(int i=(int)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(int i=(int)(b)-1,_a=(int)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	string s;
	while(cin>>N>>s) {
		ll r = 0;
		REP(i, N) r += s[i]=='R';
		
		cout<<(r > N-r ? "Yes":"No")<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> T(N), X(N), Y(N);
  for(int i = 0; i < N; ++i) cin >> T[i] >> X[i] >> Y[i];
  int x = 0, y = 0, t = 0;
  for(int i = 0; i < N; ++i){
    if(((abs(X[i]-x)+abs(Y[i]-y))%2 != (T[i]-t)%2) || ((abs(X[i]-x)+abs(Y[i]-y)) > (T[i]-t))){
      cout << "No" << endl;
      return 0;
    }
    x = X[i];
    y = Y[i];
    t = T[i];
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1408
line = readlines.map(&:chomp)

N = line[0].to_i
S = line[1]

w_cum = []
r_cum = []

wcum = 0
for i in 1..N do
  if S[i-1] == "W" then
    wcum += 1
  end
  w_cum[i-1] = wcum
  r_cum[i-1] = i - w_cum[i-1]
end
  
r_to_w = []
w_to_r = []
for i in 1..(N+1) do
  if i == 1 then
    r_to_w[i-1] = r_cum[N-1]
    w_to_r[i-1] = 0
  elsif i <= N then
    r_to_w[i-1] = r_cum[N-1] - r_cum[i-2]
    w_to_r[i-1] = w_cum[i-2]
  else
    r_to_w[i-1] = 0
    w_to_r[i-1] = w_cum[N-1]
  end
end
    
def max(x,y)
  if x > y then
    return x
  else
    return y
  end
end
  
num_alter = []
for i in 1..(N+1) do
  num_alter[i-1] = max(r_to_w[i-1],w_to_r[i-1])
end
  
ans = 10 ** 10
for i in 1..(N+1) do
  if num_alter[i-1] < ans then
    ans = num_alter[i-1]
  end
end
puts ans

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

#define say(a) cout<<a<<endl
#define say1(a,b) cout<<a<<" "<<b<<endl
#define loop(a,b) for(int i=a;i<b;i++)
#define pi acos(-1)
//vector<int> v[200009];

int main()
{
    int i,n,t=0,mx=0;
    scanf("%d",&n);
    int a[n+2];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }a[n]=a[n-1];
    for(i=1;i<n;i++)
    {
        if((a[i]<=a[i-1]))
        {
            t++;
        }else if((a[i]>a[i-1]))
        {
            mx=max(t,mx);
            t=0;

        }
    }mx=max(t,mx);
    say(mx);
}




Measured memory_bytes: 640
import statistics

N = int(input())
AB = [map(int, input().split()) for _ in range(N)]
A, B = [list(i) for i in zip(*AB)]


A_median = statistics.median(A)
B_median = statistics.median(B)
if N%2==0:
    print(int((B_median-A_median)*2)+1)
else:
    print(B_median-A_median+1)

Measured memory_bytes: 118412
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0, cur = 1;
	while (cur < B) {
		ans++;
		cur += A - 1;
	}
	
	cout << ans << endl;
	
	
	
	return 0;
}


Measured memory_bytes: 256