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

int main(){
  int n = 0;
  int six = 0;
  int sixon = 0;
  int one = 0;
  int oneon = 0;
  int nine = 0;
  int nineon = 0;
  int min = -1;
  cin >> n;
  for(int i=0;i<=n/9;i++){
    nineon = 0;
    sixon = 0;
    oneon = 0;
    nine = 9*i;
    one = (n-nine)%6;
    six = n-nine-one;
    while(nine != 0){
      nineon += nine % 9;
      nine = (nine - (nine % 9))/9;
    }
    while(six != 0){
      sixon += six % 6;
      six = (six - (six % 6))/6;
    }
    while(one != 0){
      oneon += one;
      one = 0;
    }
    
    if(min == -1 || min > sixon + nineon + oneon){
      min = sixon + nineon + oneon;
      //cout << oneon<< ","<< sixon << ","<< nineon << endl;
    }
  }
  cout << min << endl;
}
    
    

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
//#include <algorithm>
using namespace std;

int ConvStrToInt(std::string checkStr)
{
	return atoi(checkStr.c_str());
}
std::string ConvIntToStr(int checkNum)
{
	return std::to_string(checkNum);
}

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

	cin >> a;

	int counter = 0;
	std::string checkStr = ConvIntToStr(a);
	for (int i = 0; i < checkStr.length(); ++i)
	{
		if (checkStr[i] == '1')
		{
			++counter;
		}
	}
	cout << counter << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<cmath>
#include<algorithm>
using namespace std;

int main(void)
{
    long long N;
    cin >> N;

    vector<long long> v;
    for (int i = 1; i <= (int)sqrt(N) + 1; i++) {
        long long n = N / i;
        if (i*n == N) {
            v.push_back(i);
            v.push_back(n);
        }
    }

    sort(v.begin(), v.end());

    long long sum = 0;
    for (int i = 0; i < (int)v.size(); i++) {
        long long d = v[i] - 1;
        if (d == 0)
            continue;

        long long n = N / d;
        long long r = N % d;
        if (n == r)
            sum += d;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n + 1);
    vector<int> v(n + 1);
    REP(i, n){
        cin >> v[i + 1];
    }
    REP(i, m){
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }
    int ans = 0;
    REP(i, n){
        if(uf.find(i + 1) == uf.find(v[i + 1])){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def f(n):
    r = 2
    ret = 1
    for i in range(n, n-r, -1):
        ret *= i
    for i in range(1, r+1):
        ret //= i
    return ret * 2 + n


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo

@mt
def slv(N, M, A):
    A.sort(reverse=True)
    print(A)
    b = Bisect(f)

    i = b.bisect_left(M, 1, N)
    if f(i) != M:
        i -= 1
    l = f(i)

    ans = 0
    for j in range(i):
        ans += A[j] * 2
        ans += A[j] * (i-1)

    rem = M - l
    print(i, l, rem)
    j = 0
    while rem != 0:
        ans += A[j] + A[i]
        rem -= 1
        if rem == 0:
            break
        ans += A[j] + A[i]
        rem -= 1
        if rem == 0:
            break
        j += 1


    return ans

import numpy as np
def slv2(N, M, A):
    C = Counter(A)
    L = 1 << ((max(A)*2).bit_length() + 1)
    B = [C[i] for i in range(L)]
    D = np.fft.rfft(B)
    D *= D
    E = list(np.fft.irfft(D).real)
    ans = 0
    c = 0
    i = L - 1
    while c != M:
        n = int(round(E[i]))
        if c + n > M:
            n = M-c
        c += n
        ans += i * n
        i -= 1
        assert i != -1

    return ans

def main():
    N, M = read_int_n()
    A = read_int_n()
    print(slv2(N, M,A))

    # N = 10**5
    # M = random.randint(1, N**2)
    # A = [random.randint(1, 10**5) for _ in range(N)]
    # print(slv(N, M, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 64940
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	ll n, m;
	cin >> n >> m;
	vector<ll> P(m), Y(m);
	for (int i = 0; i < m; i++) cin >> P[i] >> Y[i], P[i]--;

	vector<vector<ll>> vals(n);
	for (int i = 0; i < m; i++)
	{
		vals[P[i]].push_back(Y[i]);
	}

	for (int v = 0; v < n; v++)
	{
		sort(vals[v].begin(), vals[v].end());
	}

	for (int i = 0; i < m; i++)
	{
		int v = P[i];
		printf("%06d", v + 1);

		int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
		printf("%06d\n", id + 1);
	}
}

Measured memory_bytes: 8576
# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()

# int(input())
# map(int, input().split())

a, b = map(int, input().split())

if 1 <= a <= 9 and 1 <= b <= 9:
    print(a * b)
else:
    print(-1)


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        String s = sc.next();
        long k = sc.nextLong();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                if ((long)(i + 1) == k) {
                    System.out.println(1);
                    break;
                }
            }
            else {
                System.out.println(s.charAt(i));
                break;
            }
        }
    }
}


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

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n)  for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    string s;
    cin >> s;

    cout << ((s == "ABC")?"ARC":"ABC");
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n,m,s[3000],t[3000];
ll md = 1000000007;
ll memo[2020][2020];
bool calc[2020][2020];
ll dp (ll x, ll y){
    if(x==0 || y==0)return 1;
    else if(calc[x][y])return memo[x][y];
    else{
        if(s[x]==t[y]){
            ll res;
            res = ((dp(x-1,y)%md) + (dp(x,y-1)%md)) % md;

            calc[x][y]=true;
            memo[x][y]=res;
            return res;
        }
        else{
            ll res;
            res = ((dp(x-1,y)%md) + (dp(x,y-1)%md)) % md;
            ll temp = dp(x-1,y-1);
            res = ((res%md) - (temp%md))%md;

            if(res<0)res+=md;
            calc[x][y]=true;
            memo[x][y]=res;
            return res;
        }
    }
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>s[i];
    for(int i=1;i<=m;i++)cin>>t[i];
    cout<<dp(n,m)<<newl;
}


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

int main()
{
    // 入力
    int N,X,T;
    int result=0;
    cin >> N >> X >> T;

    //cout << "" << endl;
    // 計算
    if (N%X==0){
        result = N/X;
    } else {
        result = N/X+1;
    }

    // 出力
    cout << result*T << endl;
    return 0;  
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const int INF = 1 << 30;
const int MAXN = 110;

string s;
int main() {
    ios::sync_with_stdio(false);
    int n, ans = 0;
    cin >> n >> s;
    for(int i = 0; i < n; ++i){
        while(s[i] == s[i+1] && i+1 < n)
            ++i;
        ++ans;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
vector<int> a;
bool cmp (int i, int j) {
  return a[i] < a[j];
}
int main() {
  int n;
  cin >> n;
  int N = (1 << n);
  a.resize(N);
  vector<int> ret(N), M(N), m(N);
  for (int bs = 0; bs < N; bs++) cin >> a[bs];
  M[0] = 0;
  m[0] = 0;
  vector<int> rpr;
  for (int bs = 1; bs < N; bs++) {
    rpr.clear();
    rpr.emplace_back(bs);
    for (int i = 0; i < n; i++) if ((bs >> i) & 1) {
      int cs = bs ^ (1 << i);
      rpr.emplace_back(M[cs]);
      rpr.emplace_back(m[cs]);
    }
    sort(rpr.begin(), rpr.end(), cmp);
    rpr.resize(unique(rpr.begin(), rpr.end()) - rpr.begin());
    auto it = rpr.end();
    M[bs] = *(--it);
    m[bs] = *(--it);
    ret[bs] = a[M[bs]] + a[m[bs]];
  }
  int now = 0;
  for (int bs = 1; bs < N; bs++) {
    now = max(now, ret[bs]);
    cout << now << endl;
  }
  return 0;
}

Measured memory_bytes: 7168
n = int(input())
s = input()
ans = ''
cnt = 0
for i in s:
  if i == ')' and cnt == 0:
    ans = '(' + ans + ')'
  elif i == ')' and cnt > 0:
    cnt -= 1
    ans = ans + ')'
  else:
    cnt += 1
    ans = ans + '('
if cnt > 0:
  ans = ans + ')'*cnt
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
	int a,b,c[10]={0},d;
	d=0;
	for (a=0;a<10;a++)
	{
		scanf("%d",&b);
		c[a]=b;
	}
	for (a=0;a<10;a++)
	{
		d=d+c[a];
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 600
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		sc.close();
		
		char ss = s.charAt(0);
		char ls = s.charAt(s.length()-1);
		int n = s.length()-2;
		
		System.out.print(ss);
		System.out.print(n);
		System.out.print(ls);

	}

}


Measured memory_bytes: 21588
#include<algorithm>
#include<iostream>
#include<vector>
#include<string.h>

int main()
{
	int n;
	long long v[4001];
	std::vector<int> vec;
	
	while( 1 ){
		std::cin >> n;
	
		if( !n ) break;
		
		memset( v, 0, sizeof( v ) );
		vec.clear();
		
		while( n-- ){
			int num;
			long long a, b;
		 	std::cin >> num >> a >> b;
			
			v[num] += a * b;
			vec.push_back( num );
		}
		
		bool f = true;
		bool used[4001];
		
		memset( used, false, sizeof( used ) );
		
		for( std::vector<int>::iterator it = vec.begin(); it != vec.end(); it++ ){
			if( v[*it] >= 1000000 && !used[*it] ){
			 	std::cout << *it << std::endl;
				f = false;
				used[*it] = true;
			}
		}
		
		if( f ){
			std::cout << "NA" << std::endl;
		}
	}

 	return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int main() {
	int N;
	string buf;
	int cnt[4] = {0};
	string names[4] = { "AC", "WA", "TLE", "RE" };

	cin >> N;
	REP (i, N) {
		cin >> buf;
		REP (j, 4) {
			if (buf == names[j]) {
				cnt[j]++;
				break;
			}
		}
	}

	REP (i, 4) {
		cout << names[i] << " x " << cnt[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
	int n,a[101],i,c=0;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d",&a[i]);
	}
	
	i=0;
	
	while(i<n){
		if(a[i]==a[i+1]){
			c=c+1;	i=i+2;
		}
		if(a[i]!=a[i+1]){
			i=i+1;
		}
	}
		printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int x;
  cin >> x;
  int ans = 0;
  rep(i, a+1){
    rep(j, b+1){
      rep(k, c+1){
        if(x == (i*500) + (j*100) + (k*50)) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
ccc = list(map(int, input().split()))

score = 0
i1 = 0
i2 = -100
for i in range(n):
  i1 = aaa[i]
  if i1 == i2 + 1:
    score += ccc[i2 - 1]
  score += bbb[i1 - 1]
  i2 = aaa[i]

print(score)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=20;
int n,a[N],x[N][N],y[N][N],ans;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<a[i];j++)cin>>x[i][j]>>y[i][j];
    }
    for(int i=0;i<1<<n;i++){
        int tot=0,j;for(j=0;j<n;j++){
            if((i>>j)&1){
                tot++;
                int k;for(k=0;k<a[j];k++){
                    if(((i>>(x[j][k]-1))&1)!=y[j][k])break;
                }
                if(k!=a[j])break;
            }
        }
        if(j==n)ans=max(ans,tot);
    }
    return cout<<ans,0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
double dist(vector<int>& a, vector<int>& b){
  double retval = 0.;
  for(unsigned int i = 0; i < a.size(); i++){
    retval += (a[i] - b[i]) * (a[i] - b[i]);
  }
  return sqrt(retval);
}

int main()
{
  int n, d;
  cin >> n >> d;
  vector<vector<int>>x(n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      int a;
      cin >> a;
      x[i].push_back(a);
    }
  }
  int count = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i <= j) continue;
      double d = dist(x[i], x[j]);
      int id = static_cast<int>(d);
      if(d - id < 1e-9){
        //cout << d << " " << id << endl;
        count++;
      }
    }
  }
  cout << count;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  int a=0 ;
  cin >> s;
  for(int i=0; i<4; i++){
    if(s[i]=='+'){
      a = a + 1;
    }
    else if(s[i]=='-'){
      a = a - 1;
    }
  }
  cout << a << endl;

  return 0;
}

Measured memory_bytes: 256
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect


# from operator import mul

# sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())
a = getInputIntList()
b = getInputIntList()
c = getInputIntList()

a.sort()
b.sort()
c.sort()

ans = 0
for tmp in b:
    top = bisect.bisect_left(a, tmp)
    bottom = bisect.bisect_right(c, tmp)
    ans += top * (n-bottom)

print(ans)
















Measured memory_bytes: 24484
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define ll long long

bool prime(ll a)
{
    if(a==1)
        return false;
    if(a==2 || a==3)
        return true;
    if(a%2==0 || a%3==0)
        return false;
    
    for(ll i=5;i*i<=a;i+=6)
    {
        if(a%i==0 || a%(i+2)==0)
            return false;
    }
    return true;
}

ll solve(ll n,ll s,ll e)
{
    if(s*e>n)
    {
        return INT_MAX;
    }
    if(s*e == n)
    {
        return 0;
    }
    ll ans = INT_MAX;
    ans = min(ans,solve(n,s+1,e)+1);
    ans = min(ans,solve(n,s,e+1)+1);
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    // ll t;cin>>t;while(t--)
    {
    
        ll a;cin>>a;
        ll ans = 10000000000000;
        for(ll i=1;i*i<=a;i++)
        {
            if(a%i==0)
            {
                if(a/i==i)
                {
                    ans = min(ans,i-1+i-1);
                }
                else
                {
                    ans = min(ans,a/i+i-1-1);
                }
            }
        }
        cout<<ans<<endl;
        
    }
    
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a > 0 || c > 0) {
    c -= b;
    if(!(c > 0)) break;
    a -= d;
  }
  if(!(a > 0)) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3616
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	FIO
	
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5])puts("Yes");
	else puts("No");
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int          long long
#define pb          push_back
#define pii         pair<int,int> 
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007 
#define mem(x)      memset(x,0,sizeof(x));
#define what_is(x)  cout << #x << " is " << x << flush << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
using namespace std;
const int maxn = 100010;
int n;
int a[maxn];
int dp[maxn];
void solve(){
 	cin>>n;
 	rep(i,0,n)cin>>a[i];
 	dp[1] = abs(a[1]-a[0]);
 	rep(i,2,n)
 	{
 		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]-a[i-2]));
 	}
 	cout<<dp[n-1]<<endl;



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

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)

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

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main() {
  int n;
  cin >> n;
  vector<int> a(4);
  rep(i,n){
    string s;
    cin >> s;
    if(s=="AC") a[0]++;
    if(s=="WA") a[1]++;
    if(s=="TLE") a[2]++;
    if(s=="RE") a[3]++;

  }
  vector<string> str = {"AC ","WA ","TLE ","RE "};
  rep(i,4){
    cout << str[i] << "x " << a[i] << endl;
  }
}


Measured memory_bytes: 3624
def main():
    islands, request_num = map(int, input().split())
    demolition = []
    requests = []
    for _ in range(request_num):
        requests.append(list(map(int, input().split())))
    requests.sort(key=lambda x: x[0], reverse=True)
    for begin, end in requests:
        if 0 < len(demolition) and begin <= demolition[-1] < end:
            continue
        else:
            demolition.append(begin)
    print(len(demolition))


if __name__ == '__main__':
    main()



Measured memory_bytes: 29088
import string as st
h,w = map(int,input().split())
l = [[str(i) for i in input().split()] for i in range(h)]
a = list(st.ascii_uppercase)
num = list(str(i) for i in range(1,27))
for i,j in zip(l,num):
    for x,y in zip(i,a):
        if x == 'snuke':
            print(y + j)

Measured memory_bytes: 3960
//
//  main.cpp
//  biggner20200419
//
//  Created by zer0 on 2020/04/19.
//  Copyright © 2020 zer0. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    long n,m;
    std::cin >> n >> m;
    long* pa = new long[m];
    for(int i=0; i<m; i++){
        std::cin >> pa[i];
    }
    
    long all=n;
    for(int i=0; i<m; i++){
         all-=pa[i];
    }
    
    if(all>=0){
        std::cout << all;
    }else{
        std::cout << "-1";
    }
    
    delete[] pa;
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> a(N);
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        ans ^= a[i];
    }

    Yes(ans == 0);
}

Measured memory_bytes: 1024
/*
	Track and field Competition
*/
#include	<iostream>
#include	<cstdio>
#include	<vector>
#include	<utility>
#include	<algorithm>
#include	<functional>

using namespace std;

typedef pair<double, int> P_DI;

int main(void) {
	vector<P_DI> Group1, Group2, Group3, GroupMod;
	int buff_sc, c;
	double buff_tm;
	
	for(int i = 0; i < 8; i++) {
		cin >> buff_sc >> buff_tm;
		Group1.push_back( P_DI(buff_tm, buff_sc) );
	}
	for(int i = 0; i < 8; i++) {
		cin >> buff_sc >> buff_tm;
		Group2.push_back( P_DI(buff_tm, buff_sc) );
	}
	for(int i = 0; i < 8; i++) {
		cin >> buff_sc >> buff_tm;
		Group3.push_back( P_DI(buff_tm, buff_sc) );
	}
	sort(Group1.begin(), Group1.end());
	sort(Group2.begin(), Group2.end());
	sort(Group3.begin(), Group3.end());
	
	c = 1;
	vector<P_DI>::iterator it = Group1.begin();
	while(it != Group1.end()) {
		if(c < 3) {
			printf("%d %5.2f\n", (*it).second, (*it).first);
		} else {
			GroupMod.push_back( P_DI((*it).first, (*it).second) );
		}
		c++;
		it++;
	}
	c = 1;
	it = Group2.begin();
	while(it != Group2.end()) {
		if(c < 3) {
			printf("%d %5.2f\n", (*it).second, (*it).first);
		} else {
			GroupMod.push_back( P_DI((*it).first, (*it).second) );
		}
		c++;
		it++;
	}
	c = 1;
	it = Group3.begin();
	while(it != Group3.end()) {
		if(c < 3) {
			printf("%d %5.2f\n", (*it).second, (*it).first);
		} else {
			GroupMod.push_back( P_DI((*it).first, (*it).second) );
		}
		c++;
		it++;
	}
	
	sort(GroupMod.begin(), GroupMod.end());
	it = GroupMod.begin();
	for(int i = 0; i < 2; i++) {
		printf("%d %5.2f\n", (*it).second, (*it).first);
		it++;
	}
}

Measured memory_bytes: 1252
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>
#include <iomanip>
#include <queue>

using namespace std;
using ull = unsigned long long;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)

template <typename Input1, typename Input2, typename Output>
void zip(
	Input1 begin1, Input1 end1,
	Input2 begin2, Input2 end2,
	Output result) {
	auto it1 = begin1;
	auto it2 = begin2;
	while (it1 != end1 && it2 != end2) {
		result++ = std::make_pair(*it1++, *it2++);
	}
}

template <typename T, typename U>
std::vector<std::pair<T, U>> zip(
	std::vector<T> const & range1,
	std::vector<U> const & range2) {
	std::vector<std::pair<T, U>> result;

	zip(
		std::begin(range1), std::end(range1),
		std::begin(range2), std::end(range2),
		std::back_inserter(result));

	return result;
}


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

	vector<vector<ll>> V(N);
	for (ll i = 0; i < N - 1; i++) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		V[a].push_back(b);
		V[b].push_back(a);
	}
	// 辺の多さでソートした別物を用意する。
	vector<ll> num(N);
	iota(ALL(num), 0LL);
	auto zipped = zip(num, V);
	sort(ALL(zipped), [](auto x, auto y) {
		return x.second.size() > y.second.size();
	});


	vector<ll> W(N);
	for (ll i = 0; i < N; i++) {
		cin >> W[i];
	}
	sort(ALL(W));

	vector<ll> ans(N, -1);

	// ノード数が多い場所から幅優先探索して割り当てていく。
	vector<ll> W_copy = W;
	queue<ll> Q;
	Q.push(zipped.front().first);
	while (!Q.empty()) {
		ll node = Q.front();
		Q.pop();

		// 訪問済みとする。残っている中で最大の値を入れる。
		ans[node] = W_copy.back();
		W_copy.pop_back();

		// 隣接ノードを洗い出して、未訪問のみキューに入れる。
		for (const ll u: V[node]) {
			if (ans[u] != -1) continue;
			Q.push(u);
		}
	}

	ll sum = 0;
	for (size_t i = 0; i < N - 1; i++) {
		sum += W[i];
	}
	cout << sum << endl;

	for (size_t i = 0; i < N; i++) {
		cout << ans[i];
		if (i < N - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 2040
fun main() = Thread(null, ::abc174c, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc174c() {
    val k = readLine()!!.toLong()

    if (k % 2 == 0L) return println(-1)

    var rem = 0L
    var digit = 1L
    var answer = 0L

    repeat(k.toInt()) {
        rem += digit * 7
        rem %= k
        answer++
        if (rem == 0L) return println(answer)
        digit *= 10
        digit %= k
    }

    println(-1)
}


Measured memory_bytes: 34880
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int[] digsum = new int[100001];
        for (int i = 1; i < digsum.length; i++) {
            digsum[i] = digsum(i);
        }

        int result = Integer.MAX_VALUE;
        for (int i = 1; i <= n / 2; i++) {
            int sum = digsum[i] + digsum[n - i];
            result = Math.min(result, sum);
        }

        // 出力
        System.out.println(result);
    }

    public static int digsum(int num) {
        int sum = 0;
        while (num > 0) {
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)

int main() {
  int d, a;
  char c;
  double x = 0.0, y = 0.0, deg = 90.0;
  while (cin >> d >> c >> a, d | a) {
    x += d * cos(deg * PI / 180.0);
    y += d * sin(deg * PI / 180.0);
    deg -= a;
  }
  cout << (int)x << "\n" << (int)y << "\n";
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int a, b, c;
    string s;
    cin >> a >> b;
    //cin >> s;
    cout << max({a+b, a-b, a*b}) << "\n";
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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; }
//template end

template<typename M,typename N=M>
struct LazySegmentTree{
    using F=function<M(M,M)>; using G=function<M(M,N)>; using H=function<N(N,N)>;
    int sz,height; vector<M> data; vector<N> lazy;
    const F f;const G g; const H h; const M m1; const N n1;
    LazySegmentTree(int n,const F f,const G g,const H h,const M &m1,const N n1):f(f),g(g),h(h),m1(m1),n1(n1){
        sz=1,height=0; while(sz<n)sz<<=1,height++;
        data.assign(2*sz,m1); lazy.assign(2*sz,n1);
    }
    void build(vector<M> v){
        rep(i,0,v.size())data[i+sz]=v[i];
        rrep(k,sz-1,0)data[k]=f(data[2*k],data[2*k+1]);
    }
    M ref(int k){return lazy[k]==n1?data[k]:g(data[k],lazy[k]);}
    void recalc(int k){while(k>>=1)data[k]=f(ref(2*k),ref(2*k+1));}
    void thrust(int k){rrep(i,height,0)eval(k>>i);}
    void eval(int k){
        if(lazy[k]!=n1){
            lazy[2*k]=h(lazy[2*k],lazy[k]); lazy[2*k+1]=h(lazy[2*k+1],lazy[k]);
            data[k]=ref(k); lazy[k]=n1;
        }
    }
    void update(int a,int b,N x){
        thrust(a+=sz); thrust(b+=sz-1);
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1)lazy[l]=h(lazy[l],x),++l;
            if(r&1)--r,lazy[r]=h(lazy[r],x);
        }
        recalc(a); recalc(b);
    }
    M query(int a,int b){
        thrust(a+=sz); thrust(b+=sz-1);
        M L=m1,R=m1;
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1)L=f(L,ref(l++)); if(r&1)R=f(ref(--r),R);
        } return f(L,R);
    }
};

vector<pair<int,int>> rng[200010];

int main(){
    int n,m; scanf("%d%d",&n,&m);
    rep(rot,0,m){
        int l,r,a; scanf("%d%d%d",&l,&r,&a);
        l--; r--;
        rng[r].push_back({l,a});
    }
    LazySegmentTree<ll> seg(n,
    [](ll a,ll b){return max(a,b);},
    [](ll a,ll b){return a+b;},
    [](ll a,ll b){return a+b;},0,0);
    rep(i,0,n){
        ll val=seg.query(0,i);
        seg.update(i,i+1,val);
        for(auto p:rng[i])seg.update(p.first,i+1,p.second);
    }
    printf("%lld\n",seg.query(0,n));
    return 0;
}

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

int main() {
  int n, a[10000], min = 1000000, max = -1000000;
  long sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    min = std::min(min, a[i]);
    max = std::max(max, a[i]);
    sum += a[i];
  }
  printf("%d %d %ld\n", min, max, sum);
  return 0;
}



Measured memory_bytes: 3244
#include<stdio.h>
int main(void){
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(a>c){
		d=a;
		a=c;
		c=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

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

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

int main(){ 
  int n, m;
  cin >> n >> m;
  vector<string> d(n);
  rep(i,n) cin >> d[i];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (d[i][j] == '#') cout << d[i][j];
      else {
      int cnt = 0;
      for (int k = 0; k < 8; k++) {
        int x = i + dx[k], y = j + dy[k];
        if (x < 0 || y < 0 || x >= n || y >= m) continue;
        if (d[x][y] == '#') cnt++;
      }
      cout << cnt;
      }
    }
    cout << endl;
  }

  return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main()
{
	int n, k,i;
	scanf("%d %d", &n, &k);
	
	long int h[200000];
	lop(i, n){
		scanf("%ld", &h[i]);
	}
	
	qsort(h, n, sizeof(long int), cmpnum);
	
	long int cnt=0, c=1;
	for(i=k; i<n; i++){
		if(h[i+1]==h[i]){
			c++;
		}else{
			cnt+=h[i]*c;
			c=1;
		}
	}
	printf("%ld", cnt);
	
return 0;
}

Measured memory_bytes: 3324
n = int(input())
mod = 10**9+7
prime=[]
for i in range(2,n+1):
    for k in range(len(prime)):
        if i % prime[k] == 0:
            break 
    else:
        prime.append(i)
fac = []
for i in range(len(prime)):
    fac.append(0)
for i in range(n+1):
    while i > 1:
        for k in range(len(prime)):
            while i % prime[k] == 0:
                i = i // prime[k]
                fac[k] += 1
count = 1
for i in range(len(fac)):
    count *= fac[i] + 1
    count %= mod
print(count)

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

int n;
vector<int> vi;



void retrive_odds(){
    for(int i = 0; i < vi.size(); ++i){
        if(vi[i] % 2 != 0 or vi[i] < 2){
            vi.erase(vi.begin()+i);
        }
    }

}


void solve(){
    int cnt = 0;
    int pre_cnt = -1;

    while(pre_cnt != cnt){
        //retrive_odds();

        pre_cnt = cnt;
        for(int i = 0; i < vi.size(); ++i){
            if(vi[i] % 2 == 0){
                vi[i] = vi[i] / 2;
                cnt += 1;
            }
        }
    }

    cout << cnt << endl;
    return ;
}

int main(){
    cin >> n;
    
    for(int i = 0; i < n; ++i){
        int tmp;

        cin >> tmp;
        if(tmp % 2 == 1) continue;
        vi.push_back(tmp);
    }

    solve();
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class AMultiplication1 {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int a,b;
        cin>>a>>b;
        cout<<a*b<<endl;
	}
};


int main() {
	AMultiplication1 solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    string S, a, b; cin >> S;
    rrep (i, 1, S.size()) {
        if (i % 2 == 0) {
            a += '1';
            b += '0';
        }
        else {
            a += '0';
            b += '1';
        }
    }

    int cnt_a = 0, cnt_b = 0;
    rep (i, 0, S.size()) {
        if (S[i] != a[i]) ++cnt_a;
        else if (S[i] != b[i]) ++cnt_b;
    }

    cout << min(cnt_a, cnt_b) << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
const ll mod = 998244353;
int ans[maxn];
ll b[maxn];
int main()
{
    int m,k;
    while(cin>>m>>k)
    {
        int md = (int)pow(2,m) - 1;
        if(k == 0)
        {
            for(int i = 0; i <= md; ++i)
                printf("%d %d%c",i,i,i==md?'\n':' ');
            continue;
        }
        
        if(k > md||((m==1)&&(k==1))){
            cout<<-1<<endl;
            continue;
        }
        
        int cnt = 0;
        for(int i = 0; i <= md; ++i)
        {
            if(i == k)continue;
            ans[cnt++] = i;
        }
        ans[cnt++] = k;
        for(int i = md; i >= 0; --i)
        {
            if(k == i)continue;
            ans[cnt++] = i;
        }
        ans[cnt++] = k;
        for(int i = 0; i < cnt; ++i)
            printf("%d%c",ans[i],i ==cnt-1?'\n':' ');
    }
}




















Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> k(M);
	vector<vector<int>> s(M);
	vector<int> p(M);
	for (int i = 0; i < M; ++i) {
		cin >> k[i];
		s[i].resize(k[i]);
		for (int j = 0; j < k[i]; ++j) {
			cin >> s[i][j];
			--s[i][j];
		}
	}
	for (int i = 0; i < M; ++i) {
		cin >> p[i];
	}

	int ans = 0;

	for (int m = 0; m < (1 << N); ++m) {
		int on = 0;
		for (int i = 0; i < M; ++i) {
			int t = 0;
			for (int j = 0; j < k[i]; ++j) {
				if (m & (1 << s[i][j])) {
					++t;
				}
			}
			if (t % 2 == p[i]) {
				++on;
			}
		}
		if (on == M) {
			++ans;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000],n,m,cnt,sum;

inline int read(){
	char cc=getchar();
	int f=1,num=0;
	while (cc<'0'||cc>'9'){
		if (cc=='-') f=-1;
		cc=getchar();
	}
	while (cc>='0'&&cc<='9'){
		num=(num<<1)+(num<<3)+(cc^48);
		cc=getchar();
	}
	return f*num;
}

int main(){
	n=read();m=read();
	for (int i=1;i<=n;i++){
		a[i]=read();
		sum+=a[i];
	}
	for (int i=1;i<=n;i++)
	 if (4*m*a[i]>=sum) cnt++;
	if (cnt>=m) puts("Yes");
	 else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e3+7;
const ll mod = 1e9+7;
int x,y;
void get(int a1,int b1,int a2,int b2)
{
    int a=a2-a1,b=b2-b1;
    x=a2-b;y=b2+a;
}
int main()
{
    int a1,b1,a2,b2,c1,d1,c2,d2;
    cin>>a1>>b1>>a2>>b2;
    get(a1,b1,a2,b2);
    c1=x;d1=y;
    get(a2,b2,c1,d1);
    c2=x;d2=y;
    cout<<c1<<' '<<d1<<' '<<c2<<' '<<d2<<'\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#define nil -1
#define max 500001
typedef struct{
  int key;
  int parent;
  int right;
  int left;
} node;
int parent(int);
int left(int);
int right(int);
void PrintData(void);
void buildMaxHeap(void);
void maxHeapify(int);
int H;
node data[max];

int main()
{
  int i;

  scanf("%d",&H);

  for(i = 0 ; i < H + 1 ; i++){
    data[i].parent = nil;
    data[i].right = nil;
    data[i].left = nil; }
  
  for(i = 1 ; i < H + 1 ; i++){
    scanf("%d",&data[i].key);
    if(i != 1) data[i].parent = parent(i); 
    if(left(i) < H + 1) data[i].left = left(i);
    if(right(i) < H + 1) data[i].right = right(i); }

  buildMaxHeap();
  
  PrintData();
  
  return 0;
}

int parent(int i)
{
  return i/2;
}

int left(int i)
{
  return 2*i;
}

int right(int i)
{
  return 2*i + 1;
}

void PrintData(void)
{
  int i;	

  for(i = 1 ; i < H + 1 ; i++) printf(" %d",data[i].key); 
  printf("\n"); 
     
}

void buildMaxHeap(void)
{
  int i;

  for(i = H/2 ; i >=1 ; i--) maxHeapify(i);

}

void maxHeapify(int i)
{
  int l, r, largest, ForKeep;

  l = left(i);
  r = right(i);

  if(l <= H && data[l].key > data[i].key) largest = l;
  else largest = i;

  if(r <= H && data[r].key > data[largest].key) largest = r;
  
  if(largest != i){
    ForKeep = data[i].key;
    data[i].key = data[largest].key;
    data[largest].key = ForKeep;
    maxHeapify(largest); }
}



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

int main() {
  int n,ans=0; cin>>n;
  vector<int> d(n);
  for (int i;i<n;i++){
    cin>>d[i];
  }
  for(int j;j<n-1;j++){
    for(int k=j+1;k<n;k++){
      ans+=d[j]*d[k];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	unsigned long long n;
	unsigned long long kake;
	unsigned long long kosuu;
	unsigned long long i;
	unsigned long long kakeru;
	while(1) {
		scanf("%llu",&n);
		if(n==0)break;
		kosuu=0;kake=1;
		for(i=1;i<=n;i++) {
			kakeru=i;
			while(kakeru%10==0) {
				kakeru/=10;
				kosuu++;
			}
			kake*=kakeru;
			kake=kake%1000000000000000LL;
			while(kake%10==0) {
				kake/=10;
				kosuu++;
			}
		}
		printf("%llu\n",kosuu);
	}
	return 0;
}

Measured memory_bytes: 0
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
S = input()
T = input()
cnt = 0
for i in range(len(S)):
    if S[i] != T[i]:
        cnt += 1
print(cnt)


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

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

    for(int i = 0 ;i < n ; i++)
    {
        cout <<a[i]<<b[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int M = stdIn.nextInt();
		int ans = N * (N - 1) / 2 + M * (M - 1) / 2;

		System.out.println(ans);
		stdIn.close();
	}
}

Measured memory_bytes: 35808
while True:
    n,x = [int(i) for i in input().split()]
    if n==x==0:break
    count=0

    for i in range(1,n+1):
        for j in range(1,n):
            for k in range(1,n-1):
                if i+j+k==x and i>j>k and not i==j==k:
                    count += 1
    print(count)

Measured memory_bytes: 7620
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

queue<int>q;

bool calc(){
  int W;cin>>W;
  if(W==0)return true;
  int N;cin>>N;

  int v[1010],w[1010];
  for(int t=1;t<=N;t++){
    char c;
    cin>>v[t]>>c>>w[t];
  }
  static int dp[1010][1010];  //dp[n][w]:=n個目までから、総重量w以下で選んだ時の最大総和価値
  memset(dp,0,sizeof(dp));

  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){

      if(w[i+1]>j){
        dp[i+1][j]=dp[i][j];
      }else{
        dp[i+1][j]=max(dp[i][j],dp[i][j-w[i+1]]+v[i+1]);
      }

    }
  }

  int ans_w;
  for(int w=0;w<=W;w++){
    if(dp[N][w]==dp[N][W]){
      ans_w=w;
      break;
    }
  }

  q.push(dp[N][W]);
  q.push(ans_w);
  return false;
}

signed main(){
  while(true){
    bool flag=calc();
    if(flag)break;
  }

  int t=1;
  while(!q.empty()){
    cout<<"Case "<<t<<":"<<"\n";
    cout<<q.front()<<"\n";q.pop();
    cout<<q.front()<<"\n";q.pop();
    t++;
  }
  return 0;
}



Measured memory_bytes: 11120
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    
    private static BufferedReader br;
    
	public static void main (String[] args) throws java.lang.Exception {
		br=  new BufferedReader(new InputStreamReader(System.in));
		long num = Long.parseLong(br.readLine());
		
		StringBuilder str = new StringBuilder();
		
	    while(num > 0){
	        int rem = (int)(num%26L);
	        if(rem == 0){
	            str.append('z');
	            num = num/26 -1;
	        }else{
	            char x = (char)(rem - 1 + 'a');
	            str.append(x);
	            num /= 26;
	        }
	    }
	    
	    System.out.println(str.reverse());
	}
}

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

signed main() {
  int N,K;
  cin >> N >> K;
  
  vector<int> A(N);
  for( int i = 0; i < N; i++ ){
    cin >> A.at(i);
  }
  
  int ans = ( (N-1) + (K-1) -1 ) / (K-1);
  cout << ans << endl;
  
}



Measured memory_bytes: 1024
<?php
//error_reporting(0);
$S = trim(fgets(STDIN));
//list($n,$m,$d) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));

if ($S<1200) {
  printf("ABC\n");
  exit;
}
if ($S<2800) {
  printf("ARC\n");
  exit;
}
printf("AGC\n");


Measured memory_bytes: 3700
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>


using namespace std;


int main() {

	int a;
	cin >> a;

	if (2800 <= a && a <= 4208) {
		cout << "AGC" << endl;
	}
	else if (1200 <= a && a <= 2799) {
		cout << "ARC" << endl;
	}
	else if (a <= 1199) {
		cout << "ABC" << endl;

	}
	

}



Measured memory_bytes: 256