akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;cin>>n;
	string s;cin>>s;
	vector<ll> t(n,0);
	for(ll i = 0; i < n; i++) {
		for(ll j = 1; j <= min(i,n - i); j++) {
			if(s[i] == 'R'){
				if(s[i - j] == 'G' && s[i + j] == 'B'){
					t[i] ++;
				}
				if(s[i - j] == 'B' && s[i + j] == 'G'){
					t[i]++;
				}
			}
			else if(s[i] == 'G'){
				if(s[i - j] == 'R' && s[i + j] == 'B'){
					t[i] ++;
				}
				if(s[i - j] == 'B' && s[i + j] == 'R'){
					t[i]++;
				}
			}
			else {
				if(s[i - j] == 'G' && s[i + j] == 'R'){
					t[i] ++;
				}
				if(s[i - j] == 'R' && s[i + j] == 'G'){
					t[i]++;
				}
			}
		}
	}
	// for(ll i = 0; i < n; i++) {
	// 	cout << t[i] << endl;
	// }
	vector<ll> cntr(n + 1,0);
	vector<ll> cntg(n + 1,0);
	vector<ll> cntb(n + 1,0);
	for(ll i = 0; i < n; i++) {
		if(s[i] == 'R'){
			cntr[i + 1] = cntr[i] + 1;
			cntg[i + 1] = cntg[i];
			cntb[i + 1] = cntb[i];
		}
		else if(s[i] == 'G'){
			cntg[i + 1] = cntg[i] + 1;
			cntb[i + 1] = cntb[i];
			cntr[i + 1] = cntr[i];


		}
		else{
			cntb[i + 1] = cntb[i] + 1;
			cntg[i + 1] = cntg[i];
			cntr[i + 1] = cntr[i];
		}
	}
	ll ans = 0;
	for(ll i = 1; i < n; i++) {
		if (s[i] == 'R'){
			ans += cntb[i] * (cntg[n] - cntg[i + 1]) + cntg[i] * (cntb[n] - cntb[i + 1]);
		}
		else if (s[i] == 'G'){
			ans += cntb[i] * (cntr[n] - cntr[i + 1]) + cntr[i] * (cntb[n] - cntb[i + 1]);
		}
		else {
			ans += cntr[i] * (cntg[n] - cntg[i + 1]) + cntg[i] * (cntr[n] - cntr[i + 1]);
		}
		ans -= t[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3720
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from fractions import gcd                    # for Python3.4.3


def main():
    mod = 10000007                  # 10^9+7
    inf = float('inf')
    input = sys.stdin.readline      # 改行文字が残ることに注意
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def ii():  return int(input())
    def mi():  return map(int, input().rstrip().split())
    def lmi(): return list(map(int, input().rstrip().split()))
    def li():  return list(input().rstrip())
    
    
    n = ii()
    s = input()
    ans = 0
    for i in range(n):
        if i+2 <= n-1 and s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
            ans += 1
    print(ans)
    

if __name__ == "__main__":
    main()

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

// 二分搜索
bool BinarySearch(int A[], int n, int key) {
    int left = 0 , right = n, mid;

    while (left < right) {
        mid = (left + right) / 2;
        if (key == A[mid])
            return true;

        if(key > A[mid])
            left = mid + 1;
        if (key < A[mid])
            right = mid;
    }
    return false;

}
int main() {
    int n, q, key;
    int sum = 0;
    int A[100000 + 10];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &key);
        if (BinarySearch(A, n, key))
            sum++;
    }
    printf("%d\n", sum);
}


Measured memory_bytes: 3620
N=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(N):
  if a[i] not in dic.keys():
    dic[a[i]]=1
  else:
    dic[a[i]]+=1
tmp=1
for v in dic.keys():
  cnt=dic[v]
  if cnt>=2:
    tmp+=(cnt*(cnt-1)//2)
for i in range(N):
  print(tmp-dic[a[i]])

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

int main() {
  int c[3][3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) cin >> c[i][j];
  }
  bool ans { true };
  for (int i = 1; i < 3; i++) {
    int diff { c[i][0] - c[i - 1][0] };
    for (int j = 1; j < 3; j++) {
      if (diff != c[i][j] - c[i - 1][j]) ans = false;
    }
  }
  for (int j = 1; j < 3; j++) {
    int diff { c[0][j] - c[0][j - 1] };
    for (int i = 1; i < 3; i++) {
      if (diff != c[i][j] - c[i][j - 1]) ans = false;
    }
  }
  cout << ( (ans) ? "Yes" : "No" ) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
for(auto &i : a) cin >> i;
int ans = 0;
sort(a.begin(), a.end());
for(int i = 0, j = 0; i < n; i++) {
while(a[i]-a[j] > 2) j++;
ans =max(ans, i-j+1);
}
cout << ans;
}

Measured memory_bytes: 640
from collections import deque

S = deque(input())
Q = int(input())
lst = deque()

for i in range(Q):
    tmp = list(input().split())
    lst.append(tmp)

reverse = 0
c = 1
for i in range(Q):

    if int(lst[i][0]) == 1:
        reverse += 1
        c += 1
    
    if int(lst[i][0]) == 2:
        if c%2 == 1:
            if int(lst[i][1]) == 1:
                S.appendleft(lst[i][2])
            else:
                S.append(lst[i][2])
        else:
            if int(lst[i][1]) == 2:
                S.appendleft(lst[i][2])
            else:
                S.append(lst[i][2])

if reverse%2 == 1:
    S.reverse()

ans = "".join(S)
print(ans)

Measured memory_bytes: 106712
N = int(input())
A = list(map(int, input().split()))

cnt = 0
min = 10**9
total = 0

for i in A:
    total += abs(i)
    if abs(i) < min:
            min = abs(i)
    if i < 0:
        cnt += 1
if cnt%2 == 1:
    print(total - 2*min)
else:
    print(total)

Measured memory_bytes: 14412
import sys

N = int(input())

S = [''] * N


def query(i):
    print(i)
    s = input()
    if s == 'Vacant':
        print(i)
        sys.exit()
    S[i] = s
    return s


query(0)
query(N - 1)
l = 0
r = N - 1
while r - l >= 2:
    m = (l + r) // 2
    if r - l == 2 and S[l] != S[r]:
        break
    query(m)
    if (m - l) % 2 == 0 and S[l] != S[m] or (m - l) % 2 == 1 and S[l] == S[m]:
        r = m
    else:
        l = m

for i in range(l, r + 1):
    if S[i] == '':
        print(i)
        break


Measured memory_bytes: 4424
let memoize n f =
  let dp = Hashtbl.create n in
  let rec get x =
    try Hashtbl.find dp x with
    | Not_found ->
        let result = f get x in
        Hashtbl.add dp x result;
        result in
  get

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let es = Array.make n [] in
  for i = 1 to m do
    Scanf.scanf "%d %d\n" @@ fun x y ->
      es.(x - 1) <- y - 1 :: es.(x - 1)
  done;
  let dp = memoize n @@ fun dp v ->
    List.fold_right (fun u -> max @@ 1 + dp u) es.(v) 0 in
  Printf.printf "%d\n" @@ Array.fold_left max min_int @@ Array.init n dp


Measured memory_bytes: 13568
n, m = [int(i) for i in input().split()]

l_max = 0
r_min = n+1
for i in range(m):
    a, b = [int(i) for i in input().split()]
    l_max = max(l_max, a)
    r_min = min(r_min, b)
print(max(0, r_min - l_max + 1))

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

int main(){
  vi bingo(9);
  vector<bool>ans(9,false);
  rep(i,9) cin >> bingo.at(i);
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int b;
    cin >> b;
    rep(j,9){
      if(bingo.at(j) == b){
        ans.at(j) = true;
      }
    }
  }
  if(ans.at(0) && ans.at(1) && ans.at(2)){
    cout << "Yes" << endl;
  }
  else if(ans.at(3) && ans.at(4) && ans.at(5)){
    cout << "Yes" << endl;
  }
  else if(ans.at(6) && ans.at(7) && ans.at(8)){
    cout << "Yes" << endl;
  }
  else if(ans.at(0) && ans.at(3) && ans.at(6)){
    cout << "Yes" << endl;
  }
  else if(ans.at(1) && ans.at(4) && ans.at(7)){
    cout << "Yes" << endl;
  }
  else if(ans.at(2) && ans.at(5) && ans.at(8)){
    cout << "Yes" << endl;
  }
  else if(ans.at(0) && ans.at(4) && ans.at(8)){
    cout << "Yes" << endl;
  }
  else if(ans.at(2) && ans.at(4) && ans.at(6)){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

const int mod=1e9+7;

signed main()
{   
    int N,K; cin>>N>>K;
    
    vector<vector<int> > P(N+1,vector<int>(K+1));
    for(int j=0;j<=K;j++) P[0][j]=1;

    for(int i=1;i<=N;i++){
        for(int j=1;j<=K;j++){
            if(i-j>=0){
                P[i][j]=(P[i][j-1]+P[i-j][j])%mod;
            }else{
                P[i][j]=P[i][j-1];
            }
        }
    }
    cout<<P[N][K]<<endl;
}



Measured memory_bytes: 10816
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	register int number_read=0,if_ok_read=1;
	char ch_read=getchar();
	while(ch_read<'0'||ch_read>'9')
	{
		if(ch_read=='-')
			if_ok_read=-1;
		ch_read=getchar();
	}
	while(ch_read>='0'&&ch_read<='9')
	{
		number_read=number_read*10+ch_read-'0';
		ch_read=getchar();
	}
	return number_read*if_ok_read;
}
inline void write(register int x_write)
{
    if(x_write<0)
	{
    	putchar('-');
		x_write=-x_write;
	}
    if(x_write>9)
		write(x_write/10);
    putchar(x_write%10+'0');
    return ;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	write(ceil((read()+read())/2.0));
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
//#define revstr(s) reverse(s.begin(),s.end())
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int n, m;
vector<P> v[1 << 17];
vector<int> u[1<<17],w[1<<17];
int exi[1 << 17];

ll t2[1 << 17];
ll it2[1 << 17];
void init() {
	t2[0] = 1;
	rep(i, (1 << 17) - 1) {
		t2[i + 1] = t2[i] * 2 % mod;
	}
	it2[0] = 1;
	ll key = (mod + 1) / 2;
	rep(i, (1 << 17) - 1) {
		it2[i + 1] = it2[i] * key%mod;
	}
}

ll dp[1 << 17][2];
int main() {
	cin >> n >> m; init();
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		int c; cin >> c;
		if (a == b) {
			if (c)exi[a] = -1;
			else exi[a] = 1;
		}
		else if (abs(a - b) == 1) {
			u[max(a, b)].push_back(c);
		}
		else if (abs(a - b) == 2) {
			w[max(a, b)].push_back(c);
		}
		else {
			v[max(a, b)].push_back({ min(a,b),c });
		}
	}
	dp[0][0] = dp[0][1] = 1;
	if (exi[0] == 1)dp[0][1] = 0;
	else if (exi[0] == -1)dp[0][0] = 0;
	rep1(i, n - 1) {
		int c = 0;
		sort(v[i].begin(), v[i].end());
		rep(j, v[i].size()) {
			if (j + 1 < v[i].size() && v[i][j].first == v[i][j + 1].first) {
				if ((v[i][j].second + v[i][j + 1].second) % 2) {
					cout << 0 << endl; return 0;
				}
				else {
					c++; j++;
				}
			}
			else c++;
		}
		if (u[i].size() >= 1)c++;
		if (w[i].size() >= 1)c++;
		if ((!(u[i].size() == 2 && (u[i][0] + u[i][1]) % 2)) && !(w[i].size() == 2 && (w[i][0] + w[i][1]) % 2)) {
			dp[i][0] += dp[i - 1][0] * t2[i] % mod*it2[c] % mod;
			dp[i][0] %= mod;
		}
		if ((!(u[i].size() == 2 && (u[i][0] + u[i][1]) % 2==0)) && !(w[i].size() == 2 && (w[i][0] + w[i][1]) % 2)) {
			dp[i][1] += dp[i - 1][0] * t2[i] % mod*it2[c] % mod;
			dp[i][1] %= mod;
		}
		if ((!(u[i].size() == 2 && (u[i][0] + u[i][1]) % 2==0)) && !(w[i].size() == 2 && (w[i][0] + w[i][1]) % 2==0)) {
			dp[i][0] += dp[i - 1][1] * t2[i] % mod*it2[c] % mod;
			dp[i][0] %= mod;
		}
		if ((!(u[i].size() == 2 && (u[i][0] + u[i][1]) % 2)) && !(w[i].size() == 2 && (w[i][0] + w[i][1]) % 2 == 0)) {
			dp[i][1] += dp[i - 1][1] * t2[i] % mod*it2[c] % mod;
			dp[i][1] %= mod;
		}

		if (exi[i] == -1) {
			dp[i][0] = 0;
		}
		else if(exi[i] == 1){
			dp[i][1] = 0;
		}
	}
	cout << (dp[n - 1][0] + dp[n - 1][1])%mod << endl;
	return 0;
}

Measured memory_bytes: 15104
#include<stdio.h>
int main()
{
	int a,b,c,d,e=0,f,g,h,i,j,k;
	for(d=1;d<=100;d++)
	{
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a==-1&&b==-1&&c==-1)
	{
		break;
	}
	if(a==-1||b==-1)
	{
		printf("F\n");
		continue;
	}
	
	e=a+b;
	if(e>=80)
	{
		printf("A\n");
		continue;
	}
	else if(e>=65)
	{
		printf("B\n");
		continue;
	}
	else if(e>=50||c>=50)
	{
		printf("C\n");
		continue;
	}
	else if(e>=30)
	{
		printf("D\n");
		continue;
	}
	else if(e<30)
	{
		printf("F\n");
		continue;
	}	
	}
}




Measured memory_bytes: 2040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int result = b;
		if(a <= 5){
			result = 0;
		}
		else if( a <= 12){
			result = b/2;
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(5e6),Finverse(5e6);
void Cinit(){// limit is 5e6 /// write Cinit&pw /// this takes 792ms at AtCoder
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=Factorial[i-1]*i%MOD;
  for(int i=0;i<5e6;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 1;if(k<0)return 0;
  int res=Factorial[n];
  res*=Finverse[k];res%=MOD;
  res*=Finverse[n-k];res%=MOD;
  return res;
}

/*
黒がなくなってる可能性と白がなくなってる可能性をそれぞれb_i,w_iとすると
(1-b_i-w_i)*1/2+w_i
更新は？
k回目でなくなってる可能性　(1/2)^k*nCk(k-1,B-1);
*/
int B,W;
int b[223456],w[223456];

signed main(){
  Cinit();
  cin>>B>>W;
  for(int i=B;i<B+W;i++)b[i]=nCk(i-1,B-1)*pw(pw(2,i),MOD-2)%MOD;
  for(int i=W;i<B+W;i++)w[i]=nCk(i-1,W-1)*pw(pw(2,i),MOD-2)%MOD;
  for(int i=0;i<B+W;i++)b[i+1]+=b[i],w[i+1]+=w[i],b[i+1]%=MOD,w[i+1]%=MOD;
  for(int i=1;i<=B+W;i++){
    int res=(1-b[i-1]-w[i-1])*pw(2,MOD-2)+w[i-1];
    res%=MOD;if(res<0)res+=MOD;
    cout<<res<<endl;
  }
}


Measured memory_bytes: 83456
use proconio::{input, fastout};
use std::time::{Duration, Instant};
use rand::prelude::*;

const TYPE_COUNT: usize = 26;

#[fastout]
fn main() {
    input! {
        d: usize,
        cc: [usize; TYPE_COUNT],
        ss: [[usize; TYPE_COUNT]; d],
    }
    let start = Instant::now();

    let mut last = vec![0; TYPE_COUNT];

    let mut ans = vec![];

    for s in ss.iter() {
        let mut max = 0;
        let mut index = 0;
        for (i, &x) in s.iter().enumerate() {
            let x = x + cc[i] * last[i] * 5;
            if max < x {
                max = x;
                index = i;
            }
        }
        for l in last.iter_mut() {
            *l += 1;
        }
        last[index] = 0;
        ans.push(index);
    }

    let mut score = calc_score(&cc, &ss, &ans);
    let mut rng = thread_rng();

    while Instant::now().duration_since(start) < Duration::from_millis(1900) {
        let mut dts = vec![];
        let mut olds = vec![];

        for _ in 0..(d/50)+1 {
            let day = rng.gen_range(0, d);
            let ty = rng.gen_range(0, 26);
            dts.push((day, ty));
            let old = ans[day];
            ans[day] = ty;
            olds.push((day, old));
        }

        let new_score = calc_score(&cc, &ss, &ans);
        if new_score < score {
            for (day, old) in olds.into_iter().rev() {
                ans[day] = old;
            }
        } else {
            score = new_score;
        }
    }

    for x in ans {
        println!("{}", x+1);
    }
    
}

fn calc_score(cc: &Vec<usize>, ss: &Vec<Vec<usize>>, tt: &Vec<usize>) -> isize {
    let mut last = vec![0; TYPE_COUNT];

    let mut v = 0;
    for (s, &t) in ss.iter().zip(tt.iter()) {
        v += s[t] as isize;
        for l in last.iter_mut() {
            *l += 1;
        }
        last[t] = 0;
        v -= last.iter().zip(cc.iter()).map(|(&l, &c)| (l * c) as isize).sum::<isize>();
    }
    v
}

Measured memory_bytes: 2764
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    H, W = MI()
    h = 0
    w = 0
    ans = 0

    if H == 1 or W == 1:
        print(1)
        return

    ans += ((W + 1) // 2) * ((H + 1) // 2)
    ans += (W // 2) * (H // 2)

    print(ans)


if __name__ == '__main__':
    main()


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,M;
    Scd2(N,M);

    int k = 0;
    int s;
    vector< vector<int> > sw(N);
    Rep(i,M){
        Scd(k);
        Rep(j,k){
            Scd(s);
            sw[s-1].push_back( i );
        }
    }


    vector< int > p(M);
    Rep(i,M){
        Scd(p[i]);
    }

    int al = 1 << N;

    int ans = 0;
    Rep(i,al){
        vector<int> u(M,0);
        k = 1;
        Rep(j,N){
            if( k & i )
                for( int t : sw[j] ){
                    u[t]++;
                }
            k <<= 1;
        }
        bool ok = true;
        Rep(j,M){
            ok = ok && ( u[j] % 2 == p[j] );
        }
        if( ok ) ans++;
    }

    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    ll N , K ,d ;
    cin >> N  >> K ;
    ll a[N] ;
    for(ll k = 0 ; k < N ; k++){
        a[k] = 0 ;
    }
    ll ans = 0 ;
    ll u ;
    for(ll i = 0 ; i < K ; i++){
        cin >> d  ;
        for(ll j = 0 ; j < d ; j++){
              cin >> u ;
              a[u-1]++ ;

        }


    }

    for(ll k = 0 ; k < N ; k++){
        if(a[k] == 0){
            ans ++ ;
        }
    }

    cout << ans << endl;
    
    return 0 ;
}

 


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#define LOCAL
#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int L = TEN(9);

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

	V<int> A;

	if (S != L) {
		rep(i, K) {
			A.pb(S);
		}
		rep(i, N-K) {
			A.pb(L);
		}
	} else {
		rep(i, K) A.pb(S);
		rep(i, N-K) {
			A.pb(S-1);
		}
	}

	assert(A.size() == N);
	rep(i, N) printf("%d%c", A[i], i == N-1 ? '\n' : ' ');

	return 0;
}

Measured memory_bytes: 1784
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
ll n,m;




//注意

vector<set<ll>> s(200020);
vector<pair<ll ,bool>> f(2000020);
deque<ll> q;


void search(){

   // cout<<endl;
    search();
}

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

    ll c,d,maxi=0,mini=INF,sum=0;
    string str;
    cin>>n>>m;
    vector<ll> a(m);
    vector<ll> b(m);
    s.resize(n);
    f.resize(n);
    rep(i,n) f[i].second=false;
    rep(i,m){
        cin>>c>>d;
        c--;
        d--;
        s[c].insert(d);
        s[d].insert(c);
    }
    q.push_back(0);
    while(!q.empty()){
    if(q.size()==0) continue;;
    ll num=q.front();
    q.pop_front();
    //if(f[num].second==true) return;
    //cout<<"num= "<<num<<" ";
    for(auto itr=s[num].begin();itr!=s[num].end();++itr){
        //cout<<*itr<<" ";
        if(f[*itr].second==false){
            f[*itr].second=true;
            f[*itr].first=num;
            q.push_back(*itr);
        }
    }
    }    ll flag=1;
    rep(i,n){
        if(f[i].second==false) flag=0;
    }
    if(flag==0) No;
    else{
        Yes;
        for(ll i=1;i<n;i++){
            cout<<f[i].first+1<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 66400
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k,ll p) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int a[100000], b[100000];
signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) 
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	int ma = a[0], t = 0, ma2 = b[n-1], y = n - 1;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] < a[i]) 
			t = i;
		ma = a[i];
	}
	for (int i = n - 2; i >= 0; i--) {
		if (b[i + 1] < b[i])
			y = i;
		ma2 = b[i];
	}
	if (ma != ma2 || t > y) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 1;
	for (int i = 1; i < t; i++) {
		if (a[i - 1] == a[i]) {
			ans *= a[i];
			ans %= Mod;
		}
	}
	for (int i = n - 2; i > t; i--) {
		if (b[i + 1] == b[i]) {
			ans *= b[i];
			ans %= Mod;
		}
	}
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void push(int);

int top=0;
int S[1000];

int main(){
  char S[100];
  int top=0;
  int value1,value2;
 
  while(scanf("%s",S)!=EOF){
    
    if(S[0]=='+'){
      value1=pop();
      value2=pop();
      push(value1+value2);
    }
    else if(S[0]=='-'){
      value2=pop();
      value1=pop();
      push(value1-value2);

    }
    else if(S[0]=='*'){
      value1=pop();
      value2=pop();
      push(value1*value2);

    }
    else{
      push(atoi(S));
    }    
  }
 
  printf("%d\n",pop());

  return 0;
}

int pop(){
  top--;
  return S[top+1];
}

void push(int x){
  S[++top]=x;
}
  



Measured memory_bytes: 2144
//Waqt Ha Badal Jayega//

#include <bits/stdc++.h>
#include <stdint.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pi 3.1415926535897932
using namespace std;
/*-------------------------------------------------------------*/

//for (a*b)%mod

uint64_t mulmod(uint64_t a, uint64_t b, uint64_t m)
{
	long double x;
	uint64_t c;
	int64_t r;
	if (a >= m) a %= m;
	if (b >= m) b %= m;
	x = a;
	c = x * b / m;
	r = (int64_t)(a * b - c * m) % (int64_t)m;
	return r < 0 ? r + m : r;
}

/*-------------------------------------------------------------*/
ull binpowmod(ull a, ull b, ull m)
{
	ull res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res = ((res % m) * (a % m)) % m;
		}
		a = ((a % m) * (a % m)) % m;
		b >>= 1;
	}
	return res;
}
/*-------------------------------------------------------------*/

ll countsetbits(ll n)
{
	ll count = 0;
	while (n > 0)
	{
		n = n & (n - 1);
		count++;
	}
	return count;
}

/*-------------------------------------------------------------*/
ll binpow(ll a, ll b)
{
	ll res = 1;
	while (b > 0)
	{
		if (b & 1)
		{
			res *= a;
		}
		a *= a;
		b >>= 1;
	}
	return res;
}



/*-------------------------------------------------------------*/
ll binarysearch(ll l, ll r, ll a[], ll x)
{
	while (l <= r)
	{
		ll mid = l + ((r - l) / 2);

		if (a[mid] == x )
		{
			return mid ;
		}
		if (a[mid] < x)
		{
			l = mid + 1;
		}
		else
		{
			r = mid - 1;
		}
	}
	return -1;
}
/*--------------------------------------------------------------*/
//Adjacency list

/*vector<ll>adj[100005];

ll vis[100005];  //how many i-th node have been visited
void dfs(ll node)
{
	vis[node] = 1;
	for (ll child : adj[node])
	{
		if (!vis[child])
		{
			dfs(child);
		}
	}
}

*/
/*--------------------------------------------------------------*/
/* Upper bound of x gives numbers less than or equal to x */
ll countdig(ll n)
{
	ll count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}

// Bad day ! Luck matters > Stop Judging



/*-------------------------------------------------------------*/
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	ld a, b, h, m;
	cin >> a >> b >> h >> m;

	ld p = h + (m / 60);
	ld angle1 = ((2 * pi) / 12) * p;
	ld angle2 = ((2 * pi) / 60) * m;
	ld angle = angle1 - angle2;
	ld val = cos(angle);
	ld req = a * a + b * b - 2 * a * b * val;
	ld ans = sqrt(req);
	cout << fixed << setprecision(10) << ans << "\n";
	return 0;

}

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

#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)a.size())

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//DisjointSet(int n), DisjointSet.initSet(int n)
//DisjointSet.find(int n)
//DisjointSet.isSameSet(int i, int j)
//DisjointSet.merge(int i, int j)
// {{{ Disjoint Set
struct DisjointSet {
  vector<int> pset, setSize;
  int setNum;

  DisjointSet() {}
  DisjointSet(int n) {
    initSet(n);
  }

  void initSet(int n) {
    pset.resize(n);
    setSize.assign(n, 1);
    setNum = n;
    for (int i = 0; i < n; i++) pset[i] = i;
  }

  int find(int n) { return pset[n] == n ? n : (pset[n] = find(pset[n])); }

  bool isSameSet(int i, int j) { return find(i) == find(j); }

  void merge(int i, int j) {
    if(isSameSet(i, j)) return;
    setNum--;
    i = find(i);
    j = find(j);
    if(setSize[i] < setSize[j]) {
      pset[i] = j;
      setSize[j] += setSize[i];
    } else {
      pset[j] = i;
      setSize[i] += setSize[j];
    }
  }
};
// }}}

const int N = 2e5 + 5;

int n, md, mw;
int ans[N];
pii ed[N / 2];
pii ew[N / 2];
DisjointSet dd;
DisjointSet dw;
DisjointSet dmix;
vi ids[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> md >> mw;
  for (int i = 0; i < md; i++) {
    cin >> ed[i].first >> ed[i].second;
    ed[i].first--;
    ed[i].second--;
  }
  for (int i = 0; i < mw; i++) {
    cin >> ew[i].first >> ew[i].second;
    ew[i].first--;
    ew[i].second--;
  }
  dd.initSet(n);
  for (int i = 0; i < md; i++) {
    dd.merge(ed[i].first, ed[i].second);
  }
  dw.initSet(n);
  for (int i = 0; i < mw; i++) {
    if (dd.find(ew[i].first) == dd.find(ew[i].second)) {
      dw.merge(ew[i].first, ew[i].second);
    }
  }
  for (int i = 0; i < n; i++) {
    ids[dd.find(i)].push_back(dw.find(i));
  }
  for (int i = 0; i < n; i++) {
    sort(ALL(ids[i]));
    ids[i].erase(unique(ALL(ids[i])), end(ids[i]));
  }
  dmix.initSet(n);
  for (int i = 0; i < mw; i++) {
    if (dd.find(ew[i].first) != dd.find(ew[i].second)) {
      dmix.merge(dw.find(ew[i].first), dw.find(ew[i].second));
    }
  }
  for (int i = 0; i < n; i++) {
    map<int, int> m;
    for (int j : ids[i]) {
      m[dmix.find(j)] += dw.setSize[dw.find(j)];
    }
    for (int j : ids[i]) {
      ans[j] = m[dmix.find(j)];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[dw.find(i)] << (i + 1 == n ? '\n' : ' ');
  }
  return 0;
}



Measured memory_bytes: 18680
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] H = new int[N];
		ArrayList <Integer> point = new ArrayList<Integer>();
		
		H[0] = stdIn.nextInt();
		for(int i = 1; i < N; i++) {
			H[i] = stdIn.nextInt();
			if(H[i-1] < H[i]) {
				point.add(i-1);
			}
		}
		point.add(N-1);
		
		int max = 0;
		if(point.get(0) > max) {
			max = point.get(0);
		}
		for(int i = 0; i < point.size()-1; i++) {
			if(point.get(i+1)-point.get(i)-1 > max) {
				max = point.get(i+1)-point.get(i)-1;
			}
		}
		
		System.out.println(max);

	}

}

Measured memory_bytes: 60872
n = input()
a = raw_input()
an = len(a)
ans = 0
for i in range(n):
  w = raw_input()
  wn = len(w)
  f = False
  for s in range(wn):
    for d in range(1, wn):
      if s + d * (an - 1) < wn:
        ff = True
        for j in range(an):
          if a[j] != w[s + d * j]:
            ff = False
        if ff:
          f = True
  if f:
    ans += 1
print ans

Measured memory_bytes: 4240
K,N = input().split()

A = list(map(int, input().split()))

int(K)
int(N)

#Bは各距離とする
B = []
for i in range(0, len(A)-1):
    B.insert(i,A[i+1]-A[i])
B.insert(int(N)-1,int(K)-A[int(N)-1]+A[0])

ans = 0

for j in range(int(N)):
    ans += B[j]

ans -= max(B)

print(ans)

Measured memory_bytes: 25840
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    cout << s[0] << s.length() -2 << s.back() << endl;

    return 0;
}

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

int main()
{
  ll x; cin >> x;
  
  if(x<500) cout << (x/5)*5;
  else {
    ll y = (x/500)*1000;
    x=x-y/2;
    cout << y+(x/5)*5 ;
  }
  
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << (B / A <= C ? B / A : C) << endl;
}

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

const int N = 40 + 5, INF = 1e9;

int n, ma, mb, a[N], b[N], c[N], dp[405][405];

using ll = long long ;

ll gcd(ll a, ll b){
    return b ? gcd(b, a % b) : a;
}



void solve(){
    fill_n(&dp[0][0], 405*405, INF);
    dp[0][0] = 0;
    for (int i = 0; i < n; i++){
        for (int j = 400; j >= 0; j--){
            for (int k = 400; k >= 0; k--){
                if(dp[j][k]!=INF){
                    dp[j+a[i]][k+b[i]] = min(dp[j+a[i]][k+b[i]], dp[j][k] + c[i]);
                }
            }
        }
        
    }
    
    int ag = ma/gcd(ma, mb);
    int bg = mb/gcd(ma, mb);
    int ans = INF;
    for (int i = 1; i*ag <= 400&& i*bg<=400; i++){
        if(dp[i*ag][i*bg]!=INF) ans = min(ans, dp[i*ag][i*bg]);
        
    }
    if(ans!=INF)cout<<ans<<endl;
    else cout<<-1<<endl;
}


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>ma>>mb;
    for (int i = 0; i < n; i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    
    solve();
    
    
    
    return 0;
}


Measured memory_bytes: 896
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
import heapq
input=sys.stdin.readline
def resolve():
    n,m=map(int,input().split())
    A=list(map(lambda x:-(int(x)),input().split()))
    heapq.heapify(A)
    for _ in range(m):
        a=heapq.heappop(A)
        a=-a
        a=a>>1
        heapq.heappush(A,-a)
    print(-sum(A))

resolve()

Measured memory_bytes: 68296
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define N 2*10e5
#define precise cout<<fixed<<setprecision(10)
#pragma GCC optimize("O0")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#define rep(i,a,b) for(int i=a;i<b;i++)
#define min3(a,b,c) min(a,min(b,c))
#define nl cout<<"\n";
#define all(v) v.begin(),v.end()
#define F first
#define S second
typedef long long ll;
typedef vector<long long> vl;
typedef vector<pair<long,long>> vp;
void get(ll arr[],ll n){for(ll i=0;i<n;i++) cin>>arr[i];}
ll gcd(ll a,ll b);
ll binpow(ll a,ll b);
void solve()
{
	ll x,y;
	cin>>x>>y;
	ll f=0;
	rep(i,0,x+1)
	{
		if( (i*2 + (x-i)*4)==y)
		f=1;
		if(f==1) break;
	}
	if(f) cout<<"Yes";
	else cout<<"No";
}
int main()
{
 	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
	 	solve();
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}
ll binpow(ll a, ll b) {
   ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


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

int main() {
	int n[10];
	for(int i=0;i<10;i++){
		n[i] = 0;
		cin >> n[i];
	}
	sort(n,n+10,greater<int>());
	for(int i=0;i<3;i++)
		cout << n[i] << endl;
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    int N, M;
    std::cin >> N >> M;

    std::vector<int> cnt(M, 0);
    for (int i = 0; i < N; i++) {
        int K;
        std::cin >> K;
        for (int j = 0; j < K; j++) {
            int temp;
            std::cin >> temp;
            temp--;
            ++cnt[temp];
        }
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        if (cnt[i] == N) {
            ans++;
        }
    }

    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{

	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b/a) << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Pair<U, V>
{
    public final U first;   	// first field of a Pair
    public final V second;  	// second field of a Pair

    // Constructs a new Pair with specified values
    public Pair(U first, V second)
    {
        this.first = first;
        this.second = second;
    }

    @Override
    // Checks specified object is "equal to" current object or not
    public boolean equals(Object o)
    {
        if (this == o)
            return true;

        if (o == null || getClass() != o.getClass())
            return false;

        Pair<?, ?> pair = (Pair<?, ?>) o;

        // call equals() method of the underlying objects
        if (!first.equals(pair.first))
            return false;
        return second.equals(pair.second);
    }

    @Override
    // Computes hash code for an object to support hash tables
    public int hashCode()
    {
        // use hash codes of the underlying objects
        return 31 * first.hashCode() + second.hashCode();
    }

    @Override
    public String toString()
    {
        return "(" + first + ", " + second + ")";
    }

    // Factory method for creating a Typed Pair immutable instance
    public static <U, V> Pair<U, V> of(U a, V b)
    {
        // calls private constructor
        return new Pair<>(a, b);
    }
}

public class Main {

    static int n;
    static List<List<Pair>> list;

    static boolean judge(int bit) {

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

            if ((bit & (1 << i)) == 0) continue;

            for (Pair xy : list.get(i)) {
                Integer x = (Integer)xy.first;
                Integer y = (Integer)xy.second;

                if (y == 1 && (bit & (1 << x)) == 0) return false;
                if (y == 0 && (bit & (1 << x)) != 0) return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        list = new ArrayList<>();
        for (int i = 0; i < n; ++i) list.add(new ArrayList<>());

        for (int i = 0; i < n; ++i) {
            int a = sc.nextInt();
            for (int j = 0; j < a; ++j) {
                list.get(i).add(new Pair(sc.nextInt() - 1, sc.nextInt()));
            }
        }

        int res = 0;
        for (int bit = 0; bit < (1 << n); ++bit) {

            if (judge(bit)) {

                int count = 0;
                for (int i = 0; i < n; ++i) {
                    if ((bit & (1 << i)) != 0) ++count;
                }
                res = Math.max(res, count);
            }
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 26196
import numpy as np
N = int(input())
a = np.array([int(input()) for _ in range(N)])
m = 998244353
S = a.sum()

# 最初のt個の整数を塗り分け, Rの整数の和がrであるような場合の数
DP_A = np.zeros((N+1, S+1), dtype=np.int64)
# 最初のt個の整数を塗り分け, Rの整数の和がrで, Bの和が0であるような場合の数
DP_B = np.zeros((N+1, S+1), dtype=np.int64)

DP_A[0, 0] = 1
DP_B[0, 0] = 1

# for t in range(N):
#     for r in range(S + 1):
#         # t + 1番目の整数をRにしない -> G or Bにする
#         DP_A[t+1, r] = DP_A[t, r] * 2 % m
#         # t + 1番目の整数をRにする -> r-a(t+1)だった場合の数を追加
#         if r - a[t] >= 0:
#             DP_A[t+1, r] += DP_A[t, r - a[t]] % m
#         # t+1 番目の整数をRにしない -> Gを加える
#         DP_B[t+1, r] = DP_B[t, r] % m
#         # t + 1番目の整数をRにする -> r-a(t+1)だった場合の数を追加
#         if r - a[t] >= 0:
#             DP_B[t+1, r] += DP_B[t, r - a[t]] % m

for t in range(N):
    DP_A[t+1, :] = (DP_A[t, :]) * 2 % m
    DP_A[t+1, a[t]:] += DP_A[t, :-a[t]] % m
    DP_B[t+1, :] = (DP_B[t, :]) % m
    DP_B[t+1, a[t]:] += DP_B[t, :-a[t]] % m

res1 = DP_A[N, int(np.ceil(S/2)):].sum()
res2 = DP_B[N, int(np.ceil(S/2))] if S % 2 == 0 else 0
res = (3 ** N - res1 * 3 + res2 * 3) % m
print(res)

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

int main() {
  int a ;
 
  cin >> a ;
    if(a==2){ cout<<2<< endl;}
   else{
for(int s = a;s<1000000;s++){
    for(int i = 2;i<s ; i++ ){
      if (s % i <1){
        break;   }
      else if(i==s-1){
        cout << s << endl; 
      s=999999;}
   }}}}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.snd", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){
		int a,b,n;
		stringstream ss(str);

		ss >> a >> b >> n;
		if (a % b == 0){
			cout << '0' << endl;
			continue;
		} // end if

		while (a > b){
			a -= b;
		} // end if	

		int sum = 0;
		
		for (int i = 0; i < n; ++i){
			int c = (10*a)/b;
			int d = (10*a % b);
			a = d;
			sum += c;
		} // end for
		cout << sum << endl;

	} // end loop
		
	return 0;
}

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

int main() {
    int n;
    cin>>n;
    vector<long long>v;
    long long a;
    for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    int count=0;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            if(v.at(i)!=v.at(j)){
                for(int k=j;k<n;k++){
                    if(v.at(i)!=v.at(k) && v.at(j)!=v.at(k)){
                        if(v.at(i)+v.at(j)>v.at(k)){
                            count+=1;
                        }
                    }
                }
            }
        }
    }
    cout<<count<<endl;
    
    
    
        
        
    return 0;
    
    
}



Measured memory_bytes: 3616
def p_count(a, b):
    global l
    if b <= 0:
        return 0
    if a <= 0:
        return 1
    else:
        if b <= int(l[a][1]/2):
            return p_count(a-1, b-1)
        else:
            c = b - int(l[a][1]/2) - 1
            return l[a-1][0] + 1 + p_count(a-1, c)

l=list([[1,1]])
n,x = (int(i) for i in input().split())

for i in range(n):
    tmp = [(l[i][0]*2 + 1), (l[i][1]*2 + 3)]
    l.append(tmp)

print(p_count(n,x))

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


int main(){
    int n,q; cin >> n >> q;
    vector<int> x(n);
    string s; cin >> s;
    vector<vector<int>> v(q,vector<int>(2));
    rep(i,q){
        cin >> v[i][0] >> v[i][1];
    }
    rep(i,n-1){
        if(s[i]=='A' && s[i+1]=='C') x[i+1]=1;
        else x[i+1]=0;
    }
    vector<int> a(n+1,0);
    a[0]=0;
    rep2(i,n+1){
        a[i]=a[i-1]+(int)x[i-1];
    }
    rep(i,q){
        cout << a[v[i][1]]-a[v[i][0]] << endl;
    }
    // rep(i,n+1){
    //     cout << i << " " <<  a[i] << endl;
    // }
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Sum,A,B;
  cin>>N;
  B=N;
  for(int i=1;i<=N;i*=10){
    A=(N%(i*10))/i;
    N-=A*i;
    Sum+=A;
  }
  if(B%Sum==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000

int main() {
	int n, m;
	cin >> n >> m;
	int a[60], b[60];

	rep(i, m) cin >> a[i] >> b[i];

	int road[60];
	rep(i, n) road[i] = 0;

	rep(i, m) {
		road[a[i] - 1] += 1;
		road[b[i] - 1] += 1;
	}

	rep(i, n) cout << road[i] << endl;
	return 0;
}

Measured memory_bytes: 256