akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

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

int n;

vector<int> ans;

int main() {
	int a, b; CI a >> b;

	if (a*b % 2)CO "Yes" EN;
	else CO "No" EN;

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    vector<int> v;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        v.push_back(a[i]);
    }

    sort(v.begin(), v.end(), greater<int>());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if ( i%2 == 0 ) {
            ans += v[i];
        } else {
            ans -= v[i];
        }
    }
    cout << ans << endl;
}


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        return;
    }

    public static string Solve()
    {
        int[] nums = new int[5];
        for (int i = 0; i < 5; i++)
        {
            nums[i] = ReadInt();
        }
        int k = ReadInt();
        for (int i = 0; i < 4; i++)
        {
            for (int j = i + 1; j < 5; j++)
            {
                if (nums[j] - nums[i] > k) return ":(";
            }
        }
        return "Yay!";
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
from sys import stdin, setrecursionlimit
from itertools import accumulate

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [True] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            for j in range(2 * i * (i + 1), m, 2 * i + 1):
                p[j] = False

    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


N = 10 ** 5
P = set(prime_numbers(N))
P = [n for n in P if (n + 1) // 2 in P]
a = [0] * (N + 1)
for n in P:
    a[n] = 1
a = list(accumulate(a))

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(a[r] - a[l - 1])


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define printd(x, f) cout << fixed << setprecision(f) << x << endl;

#define PB push_back
#define MP make_pair
#define F first
#define S second

#define INF 1000000000000
// #define MOD 10000007
#define MAXR 100000
#define PI acos(-1.0)


const long long MOD = 1000000007;

vll num(30, 0);
int main() {
    int N; string S; cin >> N >> S;

    for (auto c : S) num[c - 'a']++;
    long long res = 1;
    for (int i = 0; i < 26; ++i) {
        res *= num[i] + 1;
        res %= MOD;
    }
    cout << (res + MOD - 1) % MOD << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,m,x,cnt=0,a;
	cin>>n>>m>>x;
	rep(i,m){
	    cin>>a;
	    if(a>x)cnt++;
	}
	cout<<min(cnt,m-cnt);
	return 0;
}

Measured memory_bytes: 256
/* SmartCoder Apr 7, 2019 */
#include <bits/stdc++.h>
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end();i++)
#define present(c,x)  ( (c).find(x) !=(c).end())
#define cpresent(c,x) (find(all(c),x)!= (c).end() )
#define minei(x)  min_element(x.begin(),x.end())-(x).begin()
#define maxei(x)  max_element(x.begin(),x.end())-(x).begin()

#define uns(v)     sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())
#define acusum(x)  accumulate(x.begin(),x.end(),0)
#define acumul(x)  accumulate(x.begin(),x.end(),1, multiplies<int>());
#define bits(x)     __builtin_popcount( x )
#define oo INT_MAX
#define inf 1000000000

const double pi = acos(-1.0);
const double eps = 1e-11;
#define MAXN 100007
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
void fastIO() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll W[101], V[101];
ll dp[2][MAXN];
void copyOver(int r) {
	for (int i = 0; i < MAXN; i++) {
		dp[r % 2][i] = dp[1 - (r % 2)][i];
	}
}
int main() {
	fastIO();
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++) {
		cin >> W[i] >> V[i];
	}
	for (int i = 0; i <= MAXN; i++) {
		dp[0][i] = dp[1][i] = -1;
	}
	dp[1][0] = 0;
	for (int i = 0; i < n; i++) {
		copyOver(i);
		for (int j = MAXN - 1; j >= 0; j--) {
			if (dp[i % 2][j] == -1 || V[i] + j >= MAXN || W[i] + dp[i % 2][j] > w)
				continue;
			if (dp[i % 2][j + V[i]] == -1)
				dp[i % 2][j + V[i]] = W[i] + dp[i % 2][j];
			else
				dp[i % 2][j + V[i]] = min(dp[i % 2][j + V[i]], W[i] + dp[i % 2][j]);
		}
	}
	for (int i = MAXN - 1; i >= 0; i--) {
		if (dp[(n - 1) % 2][i] != -1) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1792
n = int(input())

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

count = 0
for i in range(1, n):
  if a[i-1] > a[i]:
    alpha = a[i-1] - a[i]
    a[i] = a[i] + alpha
    count = count + alpha 
  
print(count)

Measured memory_bytes: 32248
using System;
class Program
{
    public static void Main()
    {
        var str = Console.ReadLine();
        switch (str[0])
        {
            case 'A':
                Console.WriteLine($"T");
                break;
            case 'C':
                Console.WriteLine($"G");
                break;
            case 'T':
                Console.WriteLine($"A");
                break;
            case 'G':
                Console.WriteLine($"C");
                break;
            default:
                break;
        }
    }
}

Measured memory_bytes: 11092
n = int(input())
F = [[*map(int, input().split())] for _ in range(n)]
P = [[*map(int, input().split())] for _ in range(n)]

def c(i, open_patern):
    ret = 0
    for j in range(10):
        if open_patern>>j & 1: #open my shop
            if F[i][j]: ret += 1 # open your shop
    return ret

ans = -10000000*100
for i in range(1, 1<<10): # open pattern 10bit, i:[0~1,1~1]
    s = 0
    for j in range(n): # your shop
        cj = c(j, i)
        s += P[j][cj]
    ans = max(ans ,s)
print(ans)


Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 300005;

int n, m, q[MAXN], t[MAXN];
LL s[MAXN], f[MAXN], g[MAXN], h[MAXN], y[MAXN], pre[MAXN], suf[MAXN], b[MAXN];

inline void Dp(LL *f)
{
	int r;
	q[r = 1] = 0;
	for (int i = 1; i <= n; i ++)
	{
		s[i] = s[i - 1] + t[i];
		while (r > 1 && y[q[r]] - y[q[r - 1]] <= 1LL * i * (q[r] - q[r - 1]))
			r --;
		f[i] = max(f[i - 1], f[q[r]] - s[i] + s[q[r]] + (1LL * (i - q[r]) * (i - q[r] + 1) >> 1));
		y[i] = f[i] + s[i] + (1LL * i * (i - 1) >> 1);
		while (r > 1 && (y[i] - y[q[r]]) * (q[r] - q[r - 1]) >= (y[q[r]] - y[q[r - 1]]) * (i - q[r]))
			r --;
		q[++ r] = i;
	}
}

inline void Solve(int l, int r, LL *pre, LL *suf, LL *f)
{
	if (l == r)
		return (void)(f[l] = 1LL - t[l]);
	int mid = l + r - 1 >> 1, c = 0;
	Solve(l, mid, pre, suf, f);
	Solve(mid + 1, r, pre, suf, f);
	for (int i = l - 1; i < mid; i ++)
	{
		y[i] = pre[i] + s[i] + (1LL * i * (i - 1) >> 1);
		while (c > 1 && (y[i] - y[q[c]]) * (q[c] - q[c - 1]) >= (y[q[c]] - y[q[c - 1]]) * (i - q[c]))
			c --;
		q[++ c] = i;
	}
	for (int i = mid + 1; i <= r; i ++)
	{
		while (c > 1 && y[q[c]] - y[q[c - 1]] <= 1LL * i * (q[c] - q[c - 1]))
			c --;
		b[i] = pre[q[c]] - s[i] + s[q[c]] + (1LL * (i - q[c]) * (i - q[c] + 1) >> 1) + suf[i + 1];
	}
	for (int i = r - 1; i > mid; i --)
		b[i] = max(b[i], b[i + 1]);
	for (int i = mid + 1; i <= r; i ++)
		f[i] = max(f[i], b[i]);
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
		t[i] = Read();
	Dp(f);
	reverse(t + 1, t + n + 1);
	Dp(g);
	reverse(t + 1, t + n + 1);
	reverse(g + 1, g + n + 1);
	for (int i = 1; i <= n; i ++)
		s[i] = s[i - 1] + t[i];
	Solve(1, n, f, g, pre);
	reverse(t + 1, t + n + 1);
	reverse(f + 1, f + n + 1);
	reverse(g + 1, g + n + 1);
	for (int i = 1; i <= n; i ++)
		s[i] = s[i - 1] + t[i];
	Solve(1, n, g, f, suf);
	reverse(t + 1, t + n + 1);
	reverse(f + 1, f + n + 1);
	reverse(g + 1, g + n + 1);
	reverse(suf + 1, suf + n + 1);
	m = Read();
	while (m --)
	{
		int p = Read(), x = Read();
		printf("%lld\n", max(f[p - 1] + g[p + 1], max(pre[p], suf[p]) - x + t[p]));
	}
}


Measured memory_bytes: 23040
import sys
input = sys.stdin.readline

H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
loc = [None] * (H*W+1)
for y in range(H):
    for x in range(W):
        loc[A[y][x]] = (x, y)
power = [0] * (H*W+1)
for n in range(D+1, H*W+1):
    i, j = loc[n-D]
    x, y = loc[n]
    power[n] = power[n-D] + abs(x-i) + abs(y-j)
Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(power[R] - power[L])


Measured memory_bytes: 56536
N, *A = map(int, open(0).read().split())
cnt1 = cnt2 = cnt4 = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
    elif a % 2 == 0:
        cnt2 += 1
    else:
        cnt1 += 1

if cnt4 >= cnt1:
    print('Yes')
elif cnt4 == cnt1-1 and cnt2 == 0:
    print('Yes')
else:
    print('No')

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

int main(){
    int h, w, i, j, flag;
    flag = 0;
    scanf("%d %d", &h, &w);
    char buf[h][w];

    for(i = 0; i < h ;i++){
        scanf("%s", buf[i]);
    }

    // for(i = 0; i < h ;i++){
    //     for(j = 0; j < w; j++){
    //         printf("%c", buf[i][j]);
    //     }
    //     printf("\n");
    // }

    for(i = 0; i < h && !flag;i++){
        for(j = 0; j < w && !flag; j++){
            if(buf[i][j] == '.') continue;
            if(j > 0 && buf[i][j - 1] == '#') continue;
            if(j < w - 1 && buf[i][j + 1] == '#') continue;
            if(i > 0 && buf[i - 1][j] == '#') continue;
            if(i < h - 1 && buf[i + 1][j] == '#') continue;
            flag = 1;
        }
        if(flag) break;
    }

    printf("%s\n", flag ? "No" : "Yes");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int A, B, X;

//解法
void solve() {

	if (X >= A && A+B>=X) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}

	return;
}

int main() {
	//入力
	cin >> A >> B >> X;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        s: [String; n],
    }
    let mut map = HashMap::new();
    s.into_iter().for_each(|s| {
        *map.entry(s).or_insert(0usize) += 1usize;
    });
    println!("AC x {}", *map.entry("AC".to_string()).or_insert(0));
    println!("WA x {}", *map.entry("WA".to_string()).or_insert(0));
    println!("TLE x {}", *map.entry("TLE".to_string()).or_insert(0));
    println!("RE x {}", *map.entry("RE".to_string()).or_insert(0));
}


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

int main() {
    int N;
    cin >> N;
    set<string> st;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << (int)st.size() << endl;
    return 0;
}


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

using namespace std;

int n;
double dp[305][305][305];

double solve(int a, int b, int c) {
    if (dp[a][b][c] != -1.0) return dp[a][b][c];
    if (a == 0 && b == 0 && c == 0) return dp[a][b][c] = 0;
    
    double tot = 0.0;
    if (a - 1 >= 0) tot += (solve(a - 1, b, c) + 1.0) * (1.0 * a / n);
    if (b - 1 >= 0) tot += (solve(a + 1, b - 1, c) + 1.0) * (1.0 * b / n);
    if (c - 1 >= 0) tot += (solve(a, b + 1, c - 1) + 1.0) * (1.0 * c / n);
    tot += (n - a - b - c) * 1.0 / n;
    tot /= (1.0 - (n - a - b - c) * 1.0 / n);
    return dp[a][b][c] = tot;
}

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

    int ones = 0;
    int twos = 0;
    int threes = 0;

    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        if (x == 1) ones++;
        else if(x == 2) twos++;
        else threes++;
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) dp[i][j][k] = -1.0;
        }
    }

    printf("%.12lf\n", solve(ones, twos, threes));
}


Measured memory_bytes: 219392
import java.util.*;
public class Main {
    public void solve() {
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        if (S.equals("SSS")) System.out.println(0);
        if (S.equals("SSR")) System.out.println(1);
        if (S.equals("SRS")) System.out.println(1);
        if (S.equals("RSS")) System.out.println(1);
        if (S.equals("RRS")) System.out.println(2);
        if (S.equals("RSR")) System.out.println(1);
        if (S.equals("SRR")) System.out.println(2);
        if (S.equals("RRR")) System.out.println(3);

    }

    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    int N;
    cin >> N;
    
    vl s = {1,10,10,4,10,10,4,10,10,2};
    vl a = {1,10,11,4,13,14,5,16,17,2};
    ll ans = 0;
    vi A;
    
    rep(i,N){
        int d,e;
        ll c;
        cin >> d >> c;
        if(d == 0) ans += c-1, e = d;
        else{
            while (c >= s[d]) {
                ll cc = c / s[d];
                ans += cc*a[d];
                c = c-cc*s[d]+cc;
            }
            e = d;
            while (c > 1) {
                c--;
                ans++;
                e += d;
                if(e/10 > 0){
                    ans++;
                    e = e%10 + e/10;
                }
            }
        }
        
        A.pb(e);
    }
    
    //outve(A);
    //cout << ans << endl;
    
    int sum = A[0];
    reps(i,1,A.size()){
        sum += A[i];
        ans++;
        if(sum/10 > 0){
            ans++;
            sum = sum/10+sum%10;
        }
    }
    
    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

bool dp[100010];

int main()
{
  int x;
  cin >> x;
  dp[0] = true;
  dp[100] = dp[101] = dp[102] = dp[103] = dp[104] = dp[105] = true;
  for (int i = 105; i <= x; ++i)
  {
    bool flag = false;
    for (int j = 0; j <= 5; ++j)
    {
      if (dp[i - 100 - j])
        flag = true;
    }
    dp[i] = flag ? true : false;
  }
  if (dp[x])
    cout << 1 << endl;
  else
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int K;
string S;

int main(){
	cin >> S >> K;
	vector<string> ss;
	for(char c='a'; c<='z'; c++){
		for(int i=0; i<S.size(); i++){
			if(S[i]!=c) continue;
			for(int j=0; j<5; j++){
				ss.push_back(S.substr(i, j+1));
			}
		}
		sort(ss.begin(), ss.end());
		auto it = unique(ss.begin(), ss.end());
		ss.resize(distance(ss.begin(), it));
		if(ss.size()>=K){
			cout << ss[K-1] << endl;
			return 0;
		}
	}


	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#include <functional>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //aからb - 1まで
#define p(x) cout<<x<<endl  //xを改行付きで出力
const int INF = 1000000007;  //最大値兼MOD
//  cin.tie(0);
//  ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
  double a;
  cin>>a;
  double ans = 0;
  rep1(i,a+1){
    if(i % 2 != 0)ans++;
  }
  cout<<ans / a<<endl;
  return 0;
}

Measured memory_bytes: 256
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vector<ll> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<ll> > vvi;
typedef vector<char> vc;

const ll INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9 + 7;
// const ll MAXN = 3e5;
const ld eps = 1e-6;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("tickets.in", "r", stdin);
       // freopen("tickets.out", "w", stdout);
#endif
}

void solve(){
    int n, k;
    cin >> n >> k;
    vi cnt(n+1, 0);
    for(int i=0; i<k; i++){
        int d;
        cin >> d;
        for(int j=0; j<d; j++){
            int beta;
            cin >> beta;
            cnt[beta]++;
        }
    }
    int ans = 0;
    for(int i=1; i<=n; i++)
        if(!cnt[i])
            ans++;
    cout << ans << endl;
} 

signed main() {
    fast_io();
    ll q = 1;
    // cout << fixed;
    // cin >> q;
    while(q--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include<math.h>
using namespace std;
int isprime(int x);
int main(void){
   int n,i,x,count;
   cin >> n;
   count = 0;
    for(i = 0; i < n; i++){
        cin >> x;
        if(isprime(x))
             count++;
   }
   cout << count << endl;
   return 0;
}

int isprime(int x){
    int i;
    if (x == 2)
        return true;
    else if(x < 2 || x%2 == 0)
        return false;
    else {
        i = 3;
        while(i <= sqrt(x)){
            if(x % i == 0)
                return false;
             i = i + 2;
        }
    }
    return true;
}


Measured memory_bytes: 3080
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let xs1 = xs[0].trim().split(' ').map(v=>parseInt(v,10));
   let xs2 = xs[1].trim().split(' ').map(v=>parseInt(v,10));
   
   const compare = (a, b) =>{
    return b - a;
  }
  
  let ans = xs2.sort(compare);
  let x = xs1[0] - xs1[1];
  
  let count = 0;
  for(let i=0; i<x; i++){
      count += ans[xs1[1]+i];
  }
  console.log(count);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 34628
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


if __name__ == "__main__":
    x = list(map(int,input().split()))
    for i in range(len(x)):
        if x[i] == 0:
            print(i+1)
            sys.exit()

Measured memory_bytes: 9552
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	const abc = "ABC"
	n := readI()
	s := readS()
	ans := 0
	for i := 0; i < n-2; i++ {
		if s[i:i+3] == abc {
			ans++
		}
	}
	fmt.Println(ans)
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int main() {
	int n;
	cin >> n;
	map<string, int> ma;
	for (int i = 0; i < n; ++i) {
		string str;
		cin >> str;
		sort(str.begin(), str.end());
		int before_size = ma.size();
		ma[str];
		if (ma.size() == before_size) {
			ma[str]++;
		}
	}
	llong ans = 0;
	for (auto itr = ma.begin(); itr != ma.end(); itr++){
		ans += (llong)itr->second * (itr->second + 1) / 2;
	}
	//auto ans = accumulate(ma.begin(), ma.end(), 0LL, [](llong acc, auto itr) {return acc + itr.second * (itr.second + 1) / 2; });
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vl=vector<ll>;
using Mat=vector<vl>;
const ll MOD=1e9+9;



Mat cross(const Mat& a,const Mat& b){
    Mat res(a.size(),vl(a.size(),0));
    for(int i=0;i<a.size();i++){
        for(int k=0;k<a.size();k++){
            for(int j=0;j<a.size();j++){
                res[i][j]+=a[i][k]*b[k][j];
                res[i][j]%=MOD;
            }
        }
    }
    return res;
}

vl cross(const Mat& a,const vl& b){
    vl res(a.size(),0);
    for(int i=0;i<a.size();i++){
        for(int j=0;j<a.size();j++){
            res[i]+=a[i][j]*b[j];
            res[i]%=MOD;
        }
    }
    return res;
}

ll solve(int w,ll h,int n){
    vector<Mat> cals;
    cals.resize(64,Mat(w,vl(w)));
    for(int j=0;j<w;j++){
        for(int k=0;k<w;k++){
            cals[0][j][k]=(abs(k-j)<=1);
        }
    }
    for(int j=0;j+1<cals.size();j++){
        cals[j+1]=cross(cals[j],cals[j]);
    }

    set<pair<int,int>> ob;
    set<ll> hs;
    for(int i=0;i<n;i++){
        int x;
        ll y;
        cin>>x>>y;
        x--,y--;
        hs.insert(y);
        ob.insert({x,y});
    }
    hs.insert(0);
    hs.insert(h-1);
    vector<ll> hv(hs.begin(),hs.end());
    vector<vector<ll>> dp(hv.size(),vector<ll>(w,0));
    dp[0][0]=1;
    for(int i=1;i<hv.size();i++){
        ll dist=hv[i]-hv[i-1];
        vector<ll> next=dp[i-1];
        for(int j=0;j<64 && dist;j++){
            if(dist%2) next=cross(cals[j],next);
            dist/=2;
        }
        for(int j=0;j<w;j++){
            if(!ob.count({j,hv[i]})) dp[i][j]=next[j];
        }
    }
    return dp[hv.size()-1][w-1];
}

int main(){
    int w,n;
    ll h;
    int i=0;
    while(cin>>w>>h>>n,w){
        i++;
        cout<<"Case "<<i<<": "<<solve(w,h,n)<<endl;
    }
    return 0;
}

Measured memory_bytes: 5704
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int sum = 0;
			for(int i=0;i<(n/4);i++) sum += sc.nextInt();
			System.out.println(sum);
		}
	}	
}

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

int main() {
  int count=0,ask=0;
  int N;
  cin>>N;
  vector<int>P(N);
  rep(i,N) cin>>P[i];
  ask=P[0];
  count++;
  for(int i=0;i<N;i++){
    if(ask>P[i]){
      count++;
      ask=P[i];
    }
  }
  cout<<count;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		DateTime st=DateTime.Now;
		var a=sc.La;
		long d=0;
		for(int i = 2;i<n;i++) {d^=a[i];}
		var ans=a[0]-Fu2(a[0],a[0]+a[1],d);
		Console.WriteLine(ans>=a[0]?-1:ans);
	}
	static long Fu2(long q,long o,long x){
		const int n=50;
		var dp=new long[n+1,2,2];
		for(int i=n;i>=0;i--){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){dp[i,j,k]=-1;}
			}
		}
		dp[n,1,0]=0;
		for(int i=n;i>0;i--){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					if(dp[i,j,k]==-1){continue;}
					for(int d=0;d<2;d++){
						for(int f=0;f<2;f++){
							if((d^f)!=((x>>(n-i))&1)){continue;}
							if(((d+f+k)&1)!=((o>>(n-i))&1)){continue;}
							dp[i-1,d!=((q>>(n-i))&1)?d>((q>>(n-i))&1)?0:1:j,(d+f+k)>>1]=Max(dp[i-1,d!=((q>>(n-i))&1)?d>((q>>(n-i))&1)?0:1:j,(d+f+k)>>1],dp[i,j,k]+(((long)d)<<(n-i)));
						}
					}
				}
			}
		}
		return dp[0,1,0];
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 29948
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

string abc = "abcdefghijklmnopqrstuvwxyz";

int main()
{
    char s;
    cin >> s;
    int memo = 0;
    rep(i, 26)
    {
        if (s == abc[i])
        {
            memo = i + 1;
            break;
        }
    }
    cout << abc[memo] << endl;
}

Measured memory_bytes: 256
import math
X = int(input())

def isSosu(n) :
    dest = int(math.sqrt(n))

    if n == 2 :
        return True

    for i in range(2, dest+2) :
        if n % i == 0 :
            return False

    return True


for j in range(X, 10**6) :
    if isSosu(j) :
        print(j)
        break




Measured memory_bytes: 3060
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

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

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    string S, T;
    cin >> S >> T;
    int len = S.length();

    vector<pair<char, char>> diff(1, make_pair(S[0], T[0]));
    for (int i = 0; i < len; i++) {
        char a = S[i];
        char b = T[i];
        int flag = 1;

        for (int j = 0; j < diff.size(); j++)
            if (a == diff[j].first && b == diff[j].second)
                flag = 0;

        if (flag)
            diff.push_back(make_pair(a, b));
    }

    string ans = "Yes";
    for (int i = 0; i < len; i++) {
        char a = S[i];
        char b = T[i];

        for (int j = 0; j < diff.size(); j++) {
            if (a == diff[j].first && b == diff[j].second) {
                ;
            } else if (a == diff[j].first || b == diff[j].second) {
                ans = "No";
            }
        }
    }

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


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

int divide(int number){
  //百の位を消去
  int divide100 = number % 100;
  //十の位を消去
  int divide10 = divide100 % 10;
  return divide10;
}

int main(){
  int N;
  cin >> N;
  
  int x = divide(N);
  
  if(x == 3){
    cout << "bon";
  }
  else if(x == 0){
    cout << "pon";
  }
  else if(x == 1){
    cout << "pon";
  }
  else if(x == 6){
    cout << "pon";
  }
  else if(x == 8){
    cout << "pon";
  }
  else{
    cout << "hon";
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for(int i = 0, a; i < n; i++){
        cin >> a;
        pq.push(a);
    }
    while(m--){
        int temp = pq.top();
        pq.pop();
        pq.push(temp/2);
    }
    ll ans = 0;
    while(pq.size()){
        ans += pq.top();
        pq.pop();
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3872
#include <iostream>
using namespace std;
using ll = long long;

int main()
{
    ll n, a = 100LL;
    cin >> n;
    int cnt = 0;
    while (a < n)
    {
        a += a / 100LL;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3636
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long




int N;
int K;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  vector<int> h;
  cin >> N;
  cin >> K;
  h.resize(N);

  REP(i, N){
  	cin >> h[i];
  }
  vector<int> dp;
  dp.resize(N + 110, llINF);
  dp[0] = 0;
  for(int i = 0 ; i < N; i++){
  	for(int j = 1 ; j <= K; j++){
  		chmin(dp[i + j],dp[i] + abs(h[i + j] - h[i]));
  	}
  }

  cout << dp[N - 1] << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

template<typename T>
struct BIT {
  vector<vector<T> > array;
  const int n;
  const int m;
public:
  BIT(int _n, int _m)
  : array(_n + 1, vector<T>(_m + 1, 0)), n(_n), m(_m) {}

  // [1, 1]から[x, y]までの累積和
  T sum(int x, int y) {
    T s = 0;
    for (int i = x; i > 0; i -= i & -i) {
      for (int j = y; j > 0; j -= j & -j) {
        s += array[i][j];
      }
    }
    return s;
  }

  T sum(int x1, int y1, int x2, int y2) {
    return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1);
  }

  void add(int x, int y, T k) {
    for (int i = x; i <= n; i += i & -i) {
      for (int j = y; j <= m; j += j & -j) {
        array[i][j] += k;
      }
    }
  }
};


// editorial
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  cin >> a;
  vector<int> b(m);
  cin >> b;

  // a の i 文字目までと b の j 文字目までを考慮
  // この 2 文字を一致させる
  BIT<ll> dp(n + 1, m + 1);
  rep(i, n) rep(j, m) if (a[i] == b[j]) dp.add(i + 1, j + 1, 1);

  rep(i, n) rep(j, m) {
    if (a[i] != b[j]) continue;
    dp.add(i + 1, j + 1, dp.sum(1, 1, i, j) % mod);
  }

  int ans = 1; // 空
  add(ans, dp.sum(1, 1, n + 1, m + 1) % mod);
  cout << ans << endl;
}


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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


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

const int N=5e+5+5;
vector<int> st[4*N];
int a[N],c[N],b[N],n;

void build(int l=1,int r=n,int v=1)
{
	if(l==r)
	{
		st[v].push_back(a[l]);
		return;
	}
	build(l,(l+r)/2,2*v);
	build((l+r)/2+1,r,2*v+1);
	merge(st[2*v].begin(),st[2*v].end(),st[2*v+1].begin(),st[2*v+1].end(),back_inserter(st[v]));
}

int querry(int l,int r,int x,int tl=1,int tr=n,int v=1)
{
	if(l>r)
		return 0;
	if(l==tl&&r==tr)
	{
		int ans=upper_bound(st[v].begin(),st[v].end(),x)-st[v].begin();
		int y=st[v].size();
		ans=y-ans;
		return ans;

	}
	int tm=(tl+tr)/2;
	auto lft=querry(l,min(tm,r),x,tl,tm,2*v);
	auto rgt=querry(max(l,tm+1),r,x,tm+1,tr,2*v+1);
	int ans=lft+rgt;
	return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int q;
	cin>>n>>q;
	for(int i=1;i<=n;i++)
	{
		b[i]=INT_MAX;
		cin>>c[i];
	}
	for(int i=n;i>=1;i--)
	{
		a[i]=b[c[i]];
		b[c[i]]=i;
	}
	build();
	while(q--)
	{
		int l,r;
		cin>>l>>r;
		cout<<querry(l,r,r)<<"\n";	
	}
	
}





Measured memory_bytes: 121300
#include<stdio.h>

#define MAX_A 100000

int n;
int a;

int tbl[MAX_A];

int main(void)
{
	int ans;
	int i;
	
	scanf( "%d", &n );
	
	while( n-- ) {
		scanf( "%d", &a );
		if ( a > 0 ) tbl[a-1]++;
		tbl[a]++;
		if ( a < MAX_A-1 ) tbl[a+1]++;
	}
	
	ans = 0;
	for( i=0; i<MAX_A; i++ ) {
		if( ans < tbl[i] ) ans = tbl[i];
	}
	
	printf( "%d\n", ans );
	
	return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, k;
    string s;
    cin >> n >> k >> s;

    vector<pair<int, bool> > v(n);
    int i = 0;
    int j = 0;
    int ans = 0;
    while(j < n){
        while(j < n && s[j] == '1')
            ++ j;
        ans = max(ans, j - i);
        while(j < n && s[j] == '0')
            ++ j;
        -- k;
        if(k < 0){
            while(i < n && s[i] == '1')
                ++ i;
            while(i < n && s[i] == '0')
                ++ i;
        }
        ans = max(ans, j - i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl G = VV(100001, 0, 0, ll);
vll depth(100001, -1);
vll ans(100001, -1);

void init(ll now, ll from, ll d){
  depth[now] = d;
  for(auto to:G[now]){
    if(from==to) continue;
    init(to, now, d+1);
  }
}
void dfs(ll now, ll from, ll cnt);
vll solve(ll st);

int main(int argc, char const *argv[]) {
  // 始点pi = 1の点を決めれば状態が確定
  // 次数2以上の頂点が一直線に並んでいなければダメ
  // 始点の候補は次数2以上の頂点の直線の端の隣かつ次数1のもの
  ll n;std::cin >> n;
  // 次数2以上の頂点が一つもない場合
  if(n==2){
    std::cout << "1 2" << '\n';
    return 0;
  }
  for(int i=0;i<n-1;i++){
    ll a, b;scanf("%lld %lld", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  init(1, -1, 0);
  ll max_d = -1, idx = -1;
  for(int i=1;i<=n;i++){
    if(G[i].size()<2) continue;
    if(max_d<depth[i]) max_d = depth[i], idx = i;
  }
  // idxが端
  init(idx, -1, 0);
  // もし一直線に並んでいるなら全て深さが違うはず
  map<ll, ll> mp;
  for(int i=1;i<=n;i++){
    if(G[i].size()<2) continue;
    auto itr = mp.find(depth[i]);
    if(itr!=mp.end()){ // 次数2以上の頂点が枝分かれしている場合
      std::cout << -1 << '\n';
      exit(0);
    }
    mp.emplace(depth[i], i);
  }
  ll a = (*mp.begin()).second;
  ll b = (*--mp.end()).second;
  // 直線の端の隣の次数1の頂点2点が候補(2点が同じ場合でも問題ない)
  ll x, y;
  for(auto to:G[a]){
    if(G[to].size()==1){
      x = to;
      break;
    }
  }
  for(auto to:G[b]){
    if(G[to].size()==1){
      y = to;
      break;
    }
  }
  vll A = solve(x);
  vll B = solve(y);
  //for(int i=1;i<=n;i++) std::cout << A[i] << (i==n?"\n":" ");
  //for(int i=1;i<=n;i++) std::cout << B[i] << (i==n?"\n":" ");

  if(A<B){
    for(int i=1;i<=n;i++){
      std::cout << A[i] << (i==n?"\n":" ");
    }
  }else{
    for(int i=1;i<=n;i++){
      std::cout << B[i] << (i==n?"\n":" ");
    }
  }
  return 0;
}

void dfs(ll now, ll from, ll cnt){
  ll c = 0;
  ll two = -1;
  for(auto to:G[now]){
    if(to==from) continue;
    if(G[to].size()>1) two = to;
    else c++;
  }
  if(two==-1&&c==0) {
    ans[cnt] = cnt;
    return;
  }else if(two==-1&&c!=0){
    ans[cnt+c-1] = cnt;
    for(int i=cnt;i<cnt+c-1;i++) ans[i] = i+1;
    ans[cnt+c] = cnt+c;
  }else{
    ans[cnt+c] = cnt;
    for(int i=cnt;i<cnt+c;i++) ans[i] = i+1;
    dfs(two, now, cnt+c+1);
  }
}
vll solve(ll st){
  dfs(st, -1, 1);
  vll ret = ans;
  return ret;
}


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

int main() {
    int X;
    cin >> X;
    int sum = 0;
    for (int t = 1; t <= X; t++) {
        sum += t;
        if (sum >= X) {
            cout << t << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> fromSt(N+1), toEnd(N+1);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        if (a == 1) fromSt[b] = 1;
        if (b == N) toEnd[a] = 1;
    }
    for (int i = 1; i < N; i++) {
        if (fromSt[i] && toEnd[i]) {
            cout << "POSSIBLE" << '\n';
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << '\n';
}


Measured memory_bytes: 4844
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define numarr 20
#define BTCJPY 380000.0
using namespace std;
typedef long double ld;

int main() {
	int i, N;
	ld  x[numarr], ans = 0.0;
	string u[numarr];
	cin >> N;
	for (i = 0; i < N; i++)
	{
		cin >> x[i] >> u[i];
		if (u[i] == "JPY")
			ans += x[i];
		else ans += x[i] * BTCJPY;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
abc = [list(map(int, input().split())) for i in range(n)]

dp = [[0]*3 for i in range(n)]
dp[0] = abc[0]

for i in range(1,n):
    dp[i][0] = max(dp[i-1][1:3]) + abc[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + abc[i][1]
    dp[i][2] = max(dp[i-1][0:2]) + abc[i][2]
print(max(dp[n-1]))

Measured memory_bytes: 47280