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

const int N = 2e5;
const int inf = 1 << 30;
int ans[N], ds[N];

int main(void){
  typedef tuple<int, int, int> t3;
  int n, Q;
  priority_queue<t3, vector<t3>, greater<t3>> q;
  cin >> n >> Q;
  multiset<int> ms; ms.insert(inf);
  
  for (int i = 0; i < n; i++){
    int s, t, x;
    scanf("%d %d %d", &s, &t, &x);
    q.push(make_tuple(s - x, x, 1));
    q.push(make_tuple(t - x, x, 0));
  }

  for (int i = 0; i < Q; i++) scanf("%d", &ds[i]), ans[i] = -1;

  int cur = 0;
  while (!q.empty()){
    t3 e = q.top(); q.pop();
    int t, x, act, v;
    tie(t, x, act) = e; v = *ms.begin();
    while (cur < Q && ds[cur] < t)
      ans[cur++] = v;
    
    if (act) ms.insert(x);
    else ms.erase(ms.find(x));
  }

  for (int i = 0; i < Q; i++) printf("%d\n", ans[i] == inf ? -1 : ans[i]);
  return 0;
}


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

int main() {
  
  int arr[4] = {}; //P W G Yの4種類の配列
  int kosu; //入力した個数
  string color; //色
  cin >> kosu;
  
  for( int i = 0; i < kosu ; i++ ){
  	cin >> color;
    if (color == "P") arr[0]++;
    if (color == "W") arr[1]++;
    if (color == "G") arr[2]++;
    if (color == "Y") arr[3]++;
  }
  
  int count = 0;
  for( int i = 0 ; i < 4 ; i++ )
  {
    if(arr[i] > 0)
    {
      count++;
    }
  }  
  
  //3 three  4 fourと出力
  switch(count){
    case 3:
      cout << "Three" << endl;
      break;
    case 4:
      cout << "Four" << endl;
      break;      
  }
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)

count = 0

temp = []
temp2 = []
while len(L)>=3:
    a = L.pop()
    while len(L)>=2:
        b = L.pop()
        temp2.insert(0, b)
        if b == a:
            continue
        while L:
            c = L.pop()
            temp.insert(0, c)
            if c==b:
                continue
            if c >= a+b:
                break
            count +=1
        L = L + temp
        temp.clear()
    L.extend(temp2)
    temp2.clear()


print(count)



Measured memory_bytes: 9168
n = int(input())
a = [int(i) for i in input().split()]

max_a = max(a)
flag = [True for i in range(max_a+1)]

dup = set()
for i in range(n):
    if a[i] in dup:
        flag[a[i]] = False
    else:
        dup.add(a[i])
        for j in range(2*a[i], max_a+1, a[i]):
            flag[j] = False

ans = 0
for i in a:
    ans += flag[i]
print(ans)

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N; cin >> N;
  vi32 A(N); cin >> A;
  i64 ans = 0;
  int sum = 0;
  int orx = 0;
  for (int l = 0, r = 0; l < N; ) {
    while (r < N && sum + A[r] == (orx ^ A[r])) {
      sum += A[r];
      orx ^= A[r];
      r++;
    }
    ans += r - l;
    sum -= A[l];
    orx ^= A[l];
    l++;
    if (l >= r) r = l, sum = 0, orx = 0;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1024
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;


void main()
{
    while (true)
    {
        int h, w;
        readf("%d %d ", &h, &w);
        if (!h && !w)
            break;
        for (int y = 0; y < h; y++)
        {
            for (int x = 0; x < w; x++)
            {
                write((x + y % 2) % 2 ? "." : "#");
            }
            writeln();
        }
        writeln();
    }
}


Measured memory_bytes: 2440
from numpy import*
n,m=map(int,input().split())
l=[]
for i in range(m):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())

ans=0
for t in range(2**n):
    tmp=array([t>>s&1 for s in range(n)])
    if p==[sum(tmp[array(i)-1])%2for i in l]:
        ans+=1
print(ans)

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

using namespace std;

int main() {
	string str;
	map <char, int > mp;
	cin >> str;
	for (int i = 0; i < str.size(); i++) {
		mp[str[i]]++;
	}
	char A[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h','i', 'j','k','l', 'm','n', 'o','p','q','r','s','t','u', 'v','w','x','y','z'};
	bool bb = true;
	for (int i = 0; i < 27; i++) {
		//printf(" %c %d", A[i], mp[A[i]]);
		if ((mp[A[i]] & 1)) bb = false;
		//break; 
	}
	//printf("%d\n", mp['f']);
	if (bb) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
debt :: Int -> Int
debt 0 = 100000
debt n = let res = truncate (1.05 * (realToFrac (debt (n-1))))
         in let resMod = (res `mod` 1000);
            in if resMod == 0 then res
            else res - resMod + 1000
main = getLine >>= putStrLn . show . debt . read

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	string s;
	while(cin >> s && s != "0")
	{
		int sum = 0;
		rep(i,s.size())
		{
			sum += s[i] - '0';
		}
		cout << sum << endl;
	}
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> L;
    int temp;
    rep(i,N){
        cin >> temp;
        L.push_back(temp);
    }

    sort(L.begin(),L.end());
    // std::for_each(L.begin(), L.end(), [](int x) {
    //     std::cout << x << std::endl;
    // });

    int count = 0;

    rep(i,N){
        for(int j=i+1;j<N;j++){
            for(int k=j+1;k<N;k++){
                //printf("%d,%d,%d\n",i,j,k);
                if((L[i]+L[j])>L[k]){
                    count += 1;
                }
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		int[] a = new int[n];
		int sum= 0;
		for(int i =0; i<n; i++){
			a[i]=sc.nextInt();
			sum+=a[i];
		}
		long[][][] dp=new long[n+1][n+1][sum+1];
		
		for(int i = 0; i<n+1; i++){
			for(int j = 0; j<n+1; j++){
				for(int k = 0; k<sum+1; k++){
					
					if(i>=1 && k<a[i-1]){
						dp[i][j][k]=dp[i-1][j][k];
					}else if(j>=1 && i>=1 && k>=a[i-1]){
						dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-a[i-1]];
					}else{
						dp[i][j][k]=0;
					}
					if(i==0 && j==0 && k==0){
						dp[0][0][0]=1;
					}
				}
			}
		}
		long ans=0;
		for(int i = 1; i<n+1; i++){
			if(i*q<=sum){
				ans+=dp[n][i][i*q];
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 85584
#-*-coding:utf-8-*-
import sys
import math
input=sys.stdin.readline

def main():
    maps=[]
    n = int(input())
    maps=list(map(int,input().split()))
    ans=0
    answers=[]

    for i in range(1,101):
        for data in maps:
            ans+=abs(i-data)**2
        answers.append(ans)
        ans=0
    print(min(answers))

if __name__=="__main__":
    main()

Measured memory_bytes: 9076
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug puts("orzyrt")
	#define debug(a...) fprintf(stderr,a);
#else
	#define Debug ('orzyrt')
	#define debug(a...) ('orzyrt')
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(a>b)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

const int n = 16;
int a,b;
int vis[22];
int main(){
	read(a);read(b);
	if(a<=8&&b<=8)puts("Yay!");
	else puts(":(");
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from bisect import bisect_left

def solve(A: int, B: int, Q: int, s: "List[int]", t: "List[int]", x: "List[int]"):
    for qi in range(Q):
        start = x[qi]
        nearest_s = bisect_left(s,start)
        nearest_t = bisect_left(t,start)

        left_s = s[nearest_s-1] if nearest_s != 0 else -10**12
        right_s = s[nearest_s] if nearest_s != A else 10**12
        left_t = t[nearest_t-1] if nearest_t != 0 else -10**12
        right_t = t[nearest_t] if nearest_t != B else 10**12
                
        leftleftdist = start - min(left_s,left_t) 
        rightrightdist = max(right_s,right_t)-start 
        leftrightdist = min(start-left_s+right_t-left_s, start-left_t+right_s-left_t)
        rightleftdist = min(right_t-start+right_t-left_s, right_s-start+right_s-left_t)
        answer = min(leftleftdist,rightrightdist,rightleftdist,leftrightdist)
    
        print(answer)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    s = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    t = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    x = [int(next(tokens)) for _ in range(Q)]  # type: "List[int]"
    solve(A, B, Q, s, t, x)

if __name__ == '__main__':
    main()


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

const int N = 5010;

int A[N], B[N]; char s[N];

inline void process(int t[], int n) {
    t[1] = s[1] == '1';
    for (int i = 2; i <= n; i++) t[i] = s[i] != s[i - 1];
}

int main() {
    int n; scanf("%d", &n);
    scanf("%s", s + 1), process(A, n), scanf("%s", s + 1), process(B, n);
    int ct = 0, ct1 = 0, res = 1e9;
    vector<int> wkr, zjk;
    for (int i = 1; i <= n; i++) {
        if (B[i]) wkr.push_back(i), ct1++;
        if (A[i]) zjk.push_back(i), ct++;
    }
    for (int t = -ct / 2 * 2; t <= ct1; t += 2) {
        int tp = 0, tmp = 0, tp1 = 0;
        for (int i = 1; i <= t; i++) tmp += wkr[tp++] - 1;
        for (int i = 1; i <= -t; i++) tmp += zjk[tp1++] - 1;
        for (int i = tp; i < wkr.size(); i++) {
            if (tp1 >= zjk.size()) tmp += n + 1 - wkr[tp++];
            else tmp += abs(wkr[tp++] - zjk[tp1++]);
        }
        for (int i = tp1; i < zjk.size(); i++) tmp += n + 1 - zjk[tp1++];
        res = min(res, tmp);
    }
    
    printf("%d\n", res);
}

Measured memory_bytes: 512
class SimpleCalculator:
    def calc(self, a, op, b):
        if op == '+':
            print a + b
        elif op == '-':
            print a - b
        elif op == '*':
            print a * b
        elif op == '/':
            print a / b

if __name__ == "__main__":
    sc = SimpleCalculator()
    while True:
        a, op, b = map(str, raw_input().split())
        if op == "?":
            break
        sc.calc(int(a), op, int(b))

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

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

    cout << ans << endl;

    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;


ll power(int x, int y)
{
    ll base = x;
    ll res = 1;
    while (y > 0)
    {
        if (y & 1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        y >>= 1;
    }
    return res;
}


int primes[1005];
void init()
{
    rep(i, 0, 1005) primes[i] = 1;

    primes[0] = primes[1] = 0;
    for(int i = 0; i * i < 1005; i++)
    if(primes[i])
    {
        for(int j = i; i * j < 1005; j++)
            primes[i*j] = 0;
    }
}

map<int, int> num_cnt;
void cnt_factor(int n)
{
    int cnt = 0;
    if (n < 2) return;

    rep(i, 0, 1005)
    if(primes[i] == 1)
    {
        while (n % i == 0)
        {
            n /= i;
            num_cnt[i]++;
        }
        if (n == 0) break;
    }
    return;
}

int main()
{
    init();
    ll n;
    cin >> n;

    rep(i, 2, n + 1)
        cnt_factor(i);

    ll ans = 1;
    for (auto n_c: num_cnt)
        ans = (ans * (n_c.second + 1)) % MOD;
    cout << ans << endl;
    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	vector<int>ss(26,1e9),tt(26,1e9);
	for(int i=0;i<s.size();++i){
		int j=s.at(i)-'a',k=t.at(i)-'a';
		if(ss.at(j)==1e9&&tt.at(k)==1e9){
			ss.at(j)=i,tt.at(k)=i;
		}
	}
	vector<int>sss(s.size()),ttt(s.size());
	for(int i=0;i<s.size();++i){
		int j=s.at(i)-'a',k=t.at(i)-'a';
		sss.at(i)=ss.at(j),ttt.at(i)=tt.at(k);
	}
	cout<<(sss==ttt?"Yes"s:"No"s)<<"\n"s;
}

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

int main(){
  int n;
  cin >> n;
  
  vector<int> up(n);
  vector<int> down(n);
  for (int i=0; i<n; i++){
    cin >> up.at(i);;
  }
  
  for (int i=0; i<n; i++){
    cin >> down.at(i);;
  }
  
  // すべての場合を計算する
  vector<int> sum(n, 0);
  for (int i=0; i<n; i++){   
    // i番目に下に行く
    
    for (int j=0; j<=i; j++){
      sum.at(i) += up.at(j);
    }
    for (int j=i; j<n; j++){
      sum.at(i) += down.at(j);
    }
  }
  
  sort(sum.begin(), sum.end());
  cout << sum.at(sum.size()-1) << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <map>

using namespace std;

void show(vector<int> &v) {
	for (auto x: v) {
		fprintf(stderr, "%5d ", x);
	}
	fprintf(stderr, "\n");
}

int main() {
	long long n;
	int x, m;
	cin >> n >> x >> m;

	map<int, int> nums;

	vector<int> a = {x};
	vector<int> v_st, v_loop;

	int loop_st = -1, loop_size = -1;
	for (int i = 1; i < n; i++) {
		int x = 1LL * a[i-1] * a[i-1] % m;
		auto it = nums.find(x);
		if (it != nums.end()) {
			loop_st = it->second;
			loop_size = a.size() - loop_st;

			v_st = a;
			v_st.erase(v_st.begin() + loop_st, v_st.end());

			v_loop = a;
			v_loop.erase(v_loop.begin(), v_loop.begin() + loop_st);
			break;
		}

		nums[x] = i;
		a.emplace_back(x);
	}
	if (v_loop.empty()) {
		v_st = a;
	}

// fprintf(stderr, "loop_st %d, loop_size %d, a.size %lu\n", loop_st, loop_size, a.size());
// show(v_st);
// show(v_loop);
// fprintf(stderr, "v_st   %lu\n", v_st.size());
// fprintf(stderr, "v_loop %lu\n", v_loop.size());


	long long rest = n - v_st.size();
	long long sum_st = 0, sum_loop = 0, sum_ed = 0;

	for (auto x: v_st) {
		sum_st += x;
	}

	if (!v_loop.empty()) {
		for (auto x: v_loop) {
			sum_loop += x;
		}
		sum_loop *= rest / v_loop.size();

		for (int i = 0; i < rest % v_loop.size(); i++) {
			sum_ed += v_loop[i];
		}
	}

	long long ans = sum_st + sum_loop + sum_ed;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5712
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,K,ans=0;

int main(){
    cin>>N>>K;
    int x[N];
    rep(i,N){
        cin>>x[i];
        ans+=min(x[i],abs(K-x[i]))*2;
    }
    out(ans);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <fstream>
#include <bitset>
#include <cassert>
using namespace std;
 
//#define int long long
#define double long double
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pb push_back
#define debug(x) cerr << #x << ": " << x << '\n';
#define ppoint(p) cout << #p << ' ' << p.x << ' ' << p.y << '\n';
#define fi first
#define se second
#define FOR(i, n) for (int i = 0; i < n; ++i)
//typedef long long ll;
typedef pair<int, int> pii;
 
template<typename T1, typename T2> inline bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template<typename T1, typename T2> inline bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };
 
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

const int N = 3e6 + 10;
int a = 3e6;
int cnt[N];

signed main() {
	fast();
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) cout << 'x';
	cout << '\n';
	return 0;
}

Measured memory_bytes: 256
/**
 *      ABC 109 A
 *      author  : kyomukyomupurin
 *      created : 
**/

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

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

    int A, B; cin >> A >> B;
    ((A * B) % 2 == 1) ? cout << "Yes" : cout << "No";

    
    return 0;
}


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

#define MAX_N 2000
int x[MAX_N][MAX_N];
int H, W, N;
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		H = 5; W = 5;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> x[i][j];
			}
			if (x[i][0] == 0) { x[i][0] = 0; }
			else { x[i][0] = 1; }
			for (int j = 1; j < W; j++) {
				if (x[i][j] == 0) {
					x[i][j] = 0;
				}
				else {
					x[i][j] = x[i][j - 1] + 1;
				}
			}
		}
		int maxn = 0;
		for (int i = 0; i < W; i++) {
			for (int j = 0; j < H; j++) {
				int X = x[j][i], cnt = 0;
				for (int k = j; k >= 0; k--) {
					cnt++; X = min(X, x[k][i]);
					if (X == 0) { break; }
					maxn = max(maxn, X*cnt);
				}
			}
		}
		cout << maxn << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

string s, t;

int main() {
	cin >> s >> t;
	
	int ans = 0;
	inc(i, 3) { if(s[i] == t[i]) { ans++; } }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int n;
    static int[][] bingo;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        bingo = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                bingo[i][j] = sc.nextInt();
            }
        }
        n = sc.nextInt();
        for (int i = 0; i <= n-1; i++) {
            int t = sc.nextInt();
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (bingo[j][k] == t) {
                        bingo[j][k] = -1;
                    }
                }
            }
        }
        boolean bl = false;
        //横
        if (bingo[0][0] == -1 && bingo[0][1] == -1 && bingo[0][2] == -1 ) bl = true;
        if (bingo[1][0] == -1 && bingo[1][1] == -1 && bingo[1][2] == -1 ) bl = true;
        if (bingo[2][0] == -1 && bingo[2][1] == -1 && bingo[2][2] == -1 ) bl = true;
        //縦
        if (bingo[0][0] == -1 && bingo[1][0] == -1 && bingo[2][0] == -1 ) bl = true;
        if (bingo[0][1] == -1 && bingo[1][1] == -1 && bingo[2][1] == -1 ) bl = true;
        if (bingo[0][2] == -1 && bingo[1][2] == -1 && bingo[2][2] == -1 ) bl = true;
        //斜め右
        if (bingo[0][0] == -1 && bingo[1][1] == -1 && bingo[2][2] == -1 ) bl = true;
        if (bingo[0][2] == -1 && bingo[1][1] == -1 && bingo[2][0] == -1 ) bl = true;

        System.out.println(bl?"Yes":"No");
    }

}

Measured memory_bytes: 23124
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math as mt
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
n, m = get_ints()
height = get_array()
ansli = [True] * n
for _ in range(m):
    a, b = get_ints()
    a-=1; b-=1;
    if height[a] > height[b]:
        ansli[b] = False
    elif height[a] < height[b]:
        ansli[a] = False
    elif height[a] == height[b]:
        ansli[a] = False
        ansli[b] = False
ans = 0
for i in ansli:
    if i:
        ans += 1
print(ans)


# #########################################################################################
'''
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
'''

Measured memory_bytes: 85856
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std;


int main() {

    int a, b, x;
    scanf("%d %d %d", &a, &b, &x);
    
    if (a <= x && a+b >= x)
        printf("YES");
    else
        printf("NO");
    
    return 0;
}



Measured memory_bytes: 256
/* A - Coffee */
#include <bits/stdc++.h>

using namespace std;

#define COUT_PRECISION 10

namespace abreto
{

void main(void)
{
    char s[6];
    cin >> s;
    cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No") << '\n';
}

} // namespace abreto

int main(void)
{
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(COUT_PRECISION);
    abreto::main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,f=0;
 long long a[200]={},cnt=0;
 cin>>n;
 for(int i=0;i<n;i++)
  cin>>a[i];
 while(1){
  for(int i=0;i<n;i++)
   if(a[i]%2==1){f=1;break;}
   else a[i]/=2;
  if(f==1)break;
  cnt++;
 }
 cout<<cnt<<endl; 
 return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class AtCoder{
  public static void Main(){

    string s = Console.ReadLine();
    char[] c = new char[s.Length];
    
    c = s.ToCharArray();
    Array.Sort(c);
    
    bool b = true;
    for (int i = 1; i < s.Length; i++){
        if(c[i] == c[i-1]){
            b = false;
            break;
        }
    }
    if(b) Console.WriteLine("yes");
    else Console.WriteLine("no");
  }
}


Measured memory_bytes: 13396
N,A,B = map(int,input().split())
if N-(N//(A+B))*(A+B) > 0:
    if N-(N//(A+B))*(A+B) - A > 0:
        print((N // (A + B)) * A + A)
    else:
        print((N//(A+B))*A + N-(N//(A+B))*(A+B))
else:
    print((N//(A+B))*A)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  ll res = 0;

  ll t = n / k;
  res +=  t * t * t;
  if (k % 2 == 0){
    if (n % k >= k/2)
      res += (t + 1) * (t + 1) * (t + 1);
    else
      res += t * t * t;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int is_prime(int a){
	int i;
	for(i = 2; i * i <= a; i++){
		if(a % i == 0){
			return 0;
		}
	}
	return 1;
}

int main(){
	int N, i, count = 0;
	scanf("%d", &N);
	for(i = 11; count < N; i += 10){
		if(is_prime(i) == 1){
			printf("%d ", i);
			count++;
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
// std input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),*  )) => {
        ( $(read_value!($iter, $t)),*  )
    };
    ($iter:expr, [ $t:tt ; $len:expr  ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    input!{
        _n: usize,
        ss: chars,
    }
    let mut ans:u64 = 0;
    let mut prev = '0';
    for s in ss {
        if s != prev {
            ans += 1;
            prev = s;
        }
    }
    println!("{}", ans);
}

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

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> p(N);
  for (ll i = 0; i < N; i++) {
    cin >> p[i].first >> p[i].second;
  }

  sort(p.begin(), p.end(), compare_by_b);

  ll past = 0;
  for (ll i = 0; i < N; i++) {
    past += p[i].first;
    if (past > p[i].second) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";

  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll n,k,i,dp[100000]={0};
  cin>>n>>k;
  ll a[n+1];
  for(i=0;i<n;i++)
    cin>>a[i];
  ll s;
  for(s=0;s<=k;s++)
  {
     dp[s]=0;
    for(i=0;i<n;i++)
    {
     
      if(s>=a[i]&&!dp[s-a[i]])
           dp[s]=1;
                      
    }
  }
                      if(dp[k])
                      cout<<"First"<<endl;
                      else
                      cout<<"Second"<<endl;
                  
    
  
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll x;
    cin >> x;
    ll n = 100004;
    vector<bool> primes(n, true);
    primes[0] = false;
    primes[1] = false;
    for (ll p = 2; p < n; ++p) {
        if (!primes[p]) {
                continue;
        }
        for (ll i = p + p; i < n; i += p) {
            if (i < n) {
                primes[i] = false;
            }
        }
    }
    ll res = 0;
    for (ll i = x; i < n; ++i) {
        if (primes[i]) {
            res = i;
            break;
        }
    }
    cout << res << endl;
}


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

int main()
{
	int a, b;
	cin >> a >> b;
	if(b-2*a<=a*2 && (b-2*a)%2 == 0 && b>=a*2)
	{
		cout << "Yes";
	} 
	else
	{
		cout << "No";
	}
}



Measured memory_bytes: 3636
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(void)
{
    int r;

    scanf("%d", &r);
    printf("%.10f\n", acos(-1) * r * 2);

    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()

bool isPalindrome(string s){
  string t = s;
  reverse(all(s));
  if(s == t) return true;
  return false;
}

int main(){
  string s;
  cin >> s;
  string t = s.substr(0, (s.size()-1)/2), u = s.substr((s.size()+3)/2-1);
  if(isPalindrome(s) && isPalindrome(t) && isPalindrome(u)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int, input().split()))
t=1
A.sort()
if A[0]==0:
    print(0)
    exit()
A.reverse()
for i in range(n):
    t*=A[i]
    if t>1000000000000000000:
        print(-1)
        exit()
print(t)
    


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

#define OM ios::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define pi 3.14159265358979323846
// typedef long long ll;
#define ll long long
 
/*LETS BEGIN WITH THE NAME OF MAHADEV*/

int main(){
	OM;
	int n;
	cin >> n;
	string s;
	cin >> s;
	int w = 0, r = 0;
	for(char c : s)
		c == 'W' ? ++w : ++r;
	int answer = 0;
	if(w){
		int i = 0;
		while(r){
			if(s[i++] == 'W')
				++answer;
			--r;
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 999;// 1e25;
static const ll MAX_N = 100001;

priority_queue<int> q;
int main() {
	ll n, m; cin >> n >> m;
	rep(i, 0, n) {
		ll a; cin >> a;
		q.push(a);
	}

	while (m--) {
		ll t = q.top(); q.pop();
		t /= 2;
		q.push(t);
	}
	ll ans = 0;
	while (!q.empty()) {
		ans += q.top(); q.pop();
	}

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

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
  int n;
  string s;
  cin>>n;
  vector<int> a(26,0);
  for(int i=0;i<n;++i){
    cin>>s;
    vector<int> b(26,0);
    for(auto c:s)++b[c-'a'];
    if(!i)a=b;
    else{
      for(int i=0;i<26;++i)a[i]=min(a[i],b[i]);
    }
  }
  s="";
  for(int i=0;i<26;++i){
    while(a[i]--)s+=(char)(i+'a');
  }
  cout<<s;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

typedef long long ll;
const int mod = 1000000007;

int main(){
    int N;
    string S;
    cin >> N >> S;
    map<char, int> cnt;
    for(int i = 0; i < N; ++i){
        cnt[S[i]]++;
    }
    
    ll ans = 1;
    for(auto it = cnt.begin(); it != cnt.end(); ++it){
        ans = ans * (it->second + 1);
        ans %= mod;
    }
    
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
//#define int ll
#define el '\n'
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
const ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

const int NN=17;
ll a[NN][NN], dp[1<<NN], sum[1<<NN];
///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

int n; cin>>n;
for(int i=0;i<n;++i) for(int j=0;j<n;++j) cin>>a[i][j];
for(int i=0;i<1<<n;++i){
	for(int j=0;j<n;++j) if((1<<j)&i)for(int k=j+1;k<n;++k){
		if(i&(1<<k)) sum[i]+=a[k][j];
	}
}
for(int i=1;i<n;++i){
	for(int sub=(1<<i)-1;sub;--sub){
		for(int grp=sub;grp;grp=(grp-1)&(sub)){
			dp[sub|(1<<i)]=max(dp[sub|(1<<i)], sum[grp|(1<<i)]+dp[sub^grp]);
		}
	}
}
DDD(sum[0], sum[3], sum[5]);
cout<<*max_element(dp, dp+(1<<n))<<el;


return 0;
}


Measured memory_bytes: 1280
## C
N, M = map( int, input().split() )
H = [0] + list(map(int, input().split()) )
X = [[] for x in range(N+1)]
for i in range(M):
    A, B = map(int, input().split())
    X[A].append(H[B])
    X[B].append(H[A])
rt = 0
for i in range(1, N+1):
    if len(X[i]) == 0:
        rt += 1
    elif H[i] > max(X[i]):
        rt += 1
print(rt)

Measured memory_bytes: 23060
import sys
A, B, C = list(map(int, input().split()))

cnt = 0
while A%2 == 0 and B%2 == 0 and C%2 == 0:
  tmp1 = B/2 + C/2
  tmp2 = C/2 + A/2
  tmp3 = A/2 + B/2
  A = tmp1
  B = tmp2
  C = tmp3
  cnt += 1
  if cnt >= 10**4:
    print("-1")
    sys.exit()
print(cnt)

Measured memory_bytes: 9136
#include <iostream>
#include <string>

using namespace std;

int main(){
   char s;
   cin >> s;
   switch (s) {
   case 'A':
      cout << 'T' << endl;
      break;
   case 'T':
      cout << 'A' << endl;
      break;
   case 'C':
      cout << 'G' << endl;
      break;
   case 'G':
      cout << 'C' << endl;
      break;
   default:
      break;
   }

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define my_max(a, b) ((a) > (b) ? (a) : (b))
#define my_min(a, b) ((a) < (b) ? (a) : (b))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rep(i, s, t) for(int i = (int)(s); i <= (int)(t); i++)
#define rev(i, t, s) for(int i = (int)(t); i >= (int)(s); i--)
#define lson rt << 1
#define rson rt << 1 | 1
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double lb;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<int> VI;
typedef std::vector<ll> VL;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> rbtree;
ll gcd(ll x, ll y){ return y % x == 0 ? x : gcd(y % x, x); }
template<class T>T my_abs(T a){ if(a < 0) a = -a; return a; }
inline ll read(){
    ll ret = 0, sign = 1;
    char c = getchar();
    while(c < '0' || c > '9'){ if(c == '-') sign = -1; c = getchar();}
    while(c >= '0' && c <= '9'){ ret = ret * 10 + c - '0'; c = getchar(); }
    return ret * sign;
}
inline void write(ll x){
    if(x < 0){
        putchar('-');
        x = -x;
    }
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

//void expand_stack_space(){
//    int size = 256 << 20; // 256MB
//    char *p = (char*)malloc(size) + size;
//    __asm__("movl %0, %%esp\n" :: "r"(p));
//}
int n, k;
int a[110];
int main(){
#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= k; ++i) {
        int d, x;
        scanf("%d", &d);
        while(d--) {
            scanf("%d", &x);
            ++a[x];
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i) if(a[i] == 0) ++ans;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3832
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define in cin >>
#define out cout <<
#define sort1(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
bool paircom (pair<int,int> p,pair<int,int> q){
return p.first<q.first;
}
int main() {
    string s;
 cin >> s;
 if(s=="ARC"){cout << "ABC" << endl;}else{
     cout << "ARC" << endl;

 }
}


Measured memory_bytes: 3632
n,a,b=map(int,input().split())
x=list(map(int,input().split()))

ans=0

for i in range(n-1):
    if (x[i+1]-x[i])*a>b:
        ans+=b
    else:
        ans+=(x[i+1]-x[i])*a

print(ans)

Measured memory_bytes: 62704
from itertools import groupby

A=input()
N=len(A)
A=[A[i] for i in range(0,N)]
A.sort()
data=groupby(A)
ans=N*(N-1)//2+1
for key, group in data:
    g=len(list(group))
    ans-=g*(g-1)//2

print(ans)

Measured memory_bytes: 61308
#include<iostream>
#include<fstream>

bool isPrime(int n){
	if (n <= 1)return false;
	if (n == 2)return true;
	if (n % 2 == 0)return false;

	for (int i = 3; i * i <= n; i++)
		if (n % i == 0)return false;

	return true;
}

int main(){
	using namespace std;

	//ifstream fin;
	//fin.open("input.txt");

	int n;
	int count;

	while (true){
		n = count = 0;

		cin >> n;
		if (n == 0)break;
		for (int i = n; i <= 2 * n - 1; i+=2){
			if (i == 1 || i == 2)count++;
			if (i % 2 == 0)i++;
			if (isPrime(i))count++;
		}
		if (isPrime(n))count--;
		cout << count << endl;

	}
	return 0;
}

Measured memory_bytes: 1160
while True:
    input_value = input()

    height, width = map(int, input_value.split())

    if height == 0 and width == 0:
        break

    edge = ''.join(['#'] * width)
    middle = ''.join(['#'] + ['.'] * (width - 2) + ['#'])

    frame = '\n'.join([edge] + [middle] * (height - 2) + [edge])

    print(frame)
    print()




Measured memory_bytes: 5640
// C++11
#include "bits/stdc++.h"
#include <sys/time.h>
#include <emmintrin.h>
#include <string>
#include <sstream>
#include <fstream>
#include <random>
#include <bitset>

using namespace std;

inline long long GetTSC() {
  long long lo, hi;
  asm volatile ("rdtsc": "=a"(lo), "=d"(hi));
  return lo + (hi << 32);
}
inline double GetSeconds() {
  return GetTSC() / 2.8e9;
}

const int M = 7368792;

void solve(){
  double starttime = GetSeconds();
  while(1){
    int n,m;
    cin >> m >> n;
    if(n==0 && m==0) break;
    bool a[M] = {};
    int j = m;
    for(int i=0; i<n; i++){
      while(a[j]) j++;
      for(int k=j; k<M; k+=j) a[k] = 1;
    }
    while(a[j]) j++;
    cout << j << endl;
  }

  return;
}

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




Measured memory_bytes: 10276
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n, k;
    cin >>n>>k;

    vector<ll> h(n);

    rep(i,0,n) cin >> h[i]; 

    ll c(0);
    rep(i,0,n) if (h[i] >= k) c++;

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.io.*;

class Main {
	static int fieldlen = 0;
	static int fieldstart = 0;
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
			
			char[] field = kb.readLine().toCharArray();
			fieldlen = field.length;
			int[] areas = new int[10000];
			int cnt, found, total;

			cnt = total = found  = 0;
            for( int i=0; i<fieldlen; i++ ) {
            	if( '/' != field[i] || '_' != field[i] ) {
	            	found = getArea( field, i );
	            	if( 0 < found ) {
	            		areas[cnt] = found;
	            		total += areas [cnt++];
	            		found = 0;
	            		i = fieldstart;
	            	}
            	}
            }
            
            StringBuilder output = new  StringBuilder( );
            output.append( total ).append( "\n" );
            output.append( cnt ).append( " " );
           	for( int i=0; i<cnt; i++ ) {
           		output.append( areas[i] ).append( " " );
         	}
         	output.deleteCharAt( output.lastIndexOf( " " ) );
         	System.out.println( output );

	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	}
	public static int getArea( char[] field, int start )
	{
		int i, area, cnt, s, t;
		area = cnt = s = t = 0;
		for( i=start; i<fieldlen; i++ ) {
            if( '\\'== field[i] ) {
            	cnt++;
            	t++;
            	area += cnt;
            } else if( 0 < cnt && '/' == field[i] ) {
            	area += cnt;
            	cnt--;
            	if( 0 == cnt ) { break; }
            } else if( '_' == field[i]  ) {
            	s += cnt;
            }
		}
		if( fieldlen == i ) { 
			area = 0;
		} else {
			area = ( area - t + s );
			fieldstart = i;
		}
		return area;
	}
}

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

int main(){
  int a,b,sum=0;
  cin >> a >> b;
  if(a < b){
    for(int i=0;i<b;i++){
      sum = sum*10 + a;
    }
  }
  else{
     for(int i=0;i<a;i++){
      sum = sum*10 + b;
    }
  }
    cout << sum <<endl;
}


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

using ll = long long;

int main() {
  int H, W, m; cin >> H >> W >> m;
  vector<int> bh(H);
  vector<int> bw(W);
  map<int, int> dup;
  for (int i = 0; i < m; ++i) {
    int h, w; cin >> h >> w;
    --h; --w;
    bh[h] += 1;
    bw[w] += 1;
    dup[h*W+w] += 1;
  }
  int mh = 0;
  int mw = 0;
  vector<int> ih, iw;
  for (int i = 0; i < H; ++i) {
    if (bh[i] > mh) {
      ih = {i};
    }
    else if (bh[i] == mh) {
      ih.push_back(i);
    }
    mh = max(mh, bh[i]);
  }
  for (int i = 0; i < W; ++i) {
    if (bw[i] > mw) {
      iw = {i};
    }
    else if (bw[i] == mw) {
      iw.push_back(i);
    }
    mw = max(mw, bw[i]);
  }
  int ans = mh+mw-1;
  for (int h: ih) {
    for (int w: iw) {
      int i = h*W+w;
      if (dup.find(i) == dup.end()) {
        ans += 1;
        cout << ans << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}



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

int main()
{
        int N, K;
        cin >> N >> K;
        vector<int> h(N, 0);
        for (int i = 0; i < N; ++i) {
                cin >> h[i];
        }
        vector<int> dp(N, 0);
        dp[0] = 0;
        for (int i = 1; i < N; ++i) {
                vector<int> tmp;
                for (int j = 1; j <= K; ++j) {
                        if (i-j < 0) continue;
                        tmp.push_back(abs(h[i]-h[i-j])+dp[i-j]);
                }
                sort(tmp.begin(), tmp.end());
                dp[i] = tmp[0];
        }
        cout << dp[N-1] << endl;


}


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

int main() {
  int N, M;
  cin >> N >> M;
  int count = 0;
  if (N < 2) {
    count += 0;
  }
  else {
    count += N * (N - 1) / 2;
  }
  if (M < 2) {
    count += 0;
  }
  else {
    count += M * (M - 1) / 2;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256