akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt(), l = in.nextInt(), r = in.nextInt();
        while (n != 0) {
            int[] a = new int[n + 1];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            a[n] = 1;

            int cnt = 0;
            for (int i = l; i <= r; i++) {
                for (int j = 0; j <= n; j++) {
                    if (i % a[j] == 0) {
                        if (j % 2 == 0) cnt++;
                        break;
                    }
                }
            }
            out.println(cnt);


            n = in.nextInt();
            l = in.nextInt();
            r = in.nextInt();
        }
        out.flush();
    }
}



Measured memory_bytes: 32932
import java.io.*;
import java.util.*;

public class Main {
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			
			int n = Integer.parseInt(br.readLine());
			
			Map<String, Integer> map = new HashMap<>();
			int max = 0, tmp = 0;
			for (int i = 0; i < n; i++) {
				String s = br.readLine();
				if (map.containsKey(s)) {
					tmp = map.get(s) + 1;
					map.replace(s, tmp);
					max = Math.max(max, tmp);
				} else {
					map.put(s, 1);
					max = Math.max(max, 1);
				}
			}
			List<String> list = new ArrayList<>();
			for (String key : map.keySet()) {
				if (map.get(key) == max)
					list.add(key);
			}
			Collections.sort(list);
			for (String s : list)
				out.println(s);
			out.flush();
		}
	}
}

Measured memory_bytes: 55380
m,d = map(int,input().split())

c = 0
if d < 20:
	print(0)
	exit()
for i in range(1,m+1,1):
	for k in range(20,d+1,1):
		d1 = k%10
		d2 = k//10
		if d1>=2 and d1*d2 == i:
			c+=1
print(c)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    vector<int> h(n);
    REP(i, n) cin >> h[i];

    vector<bool> ok(n, true);
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        if (h[a] <= h[b]) ok[a] = false;
        if (h[b] <= h[a]) ok[b] = false;
    }

    int count = 0;
    REP(i, n) if (ok[i]) count++;
    cout << count << '\n';
    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s.length() < 4){
        cout << "No" << "\n";
        return 0;
    }
    if(s.substr(0, 4) == "YAKI"){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }

    return 0;
}


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

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

    int N, M;
    cin >> N >> M;

    vector<vector<int> > x(N);
    vector<bool> c(N);
    vector<int> a(N);

    for(int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        x[A].push_back(B);
        x[B].push_back(A);
    }

    queue<pair<int, int> > q;

    q.push(make_pair(0, -1));

    while(!q.empty()) {
        int y = q.front().first;
        int z = q.front().second;
        q.pop();
        if(c[y]) continue;
        c[y] = true;
        a[y] = z + 1;
        for(int i = 0; i < x[y].size(); i++) {
            q.push(make_pair(x[y][i], y));
        }
    }

    cout << "Yes" << endl;

    for(int i = 1; i < N; i++) {
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 12408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=10000+10;
int n;
ll a[N];
int main() {
    while(cin >> n){
        ll x;
        ll n1=0,n2=0;
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        for(int i=0;i<n;i++){
            cin >> x;
            if(x>a[i]){
                if((x-a[i])%2==1){
                        n2++;n1+=((x+1)-a[i])/2;
                    }
                else {
                        n1+=(x-a[i])/2;
                    }
            }
            else {
                n2+=(a[i]-x);
            }
 
        }
 
        if(n1>=n2) 
            cout << "Yes";
        else {
            cout << "No";
        }
    }
 
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

#include <atcoder/all>
using namespace atcoder;


int main(){
    int n,m;
    cin >> n >> m;
    vector<ll> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    vector<ll> c = convolution(a,b);
    rep(i,n+m-1){
        cout << c[i] << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

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

	vector<int> alp(26, 0);
	string S;
	cin >> S;

	for(int i = 0; i < 4; i++){
		alp[S[i] - 'A']++;
	}

	rep(i, 26){
		if(alp[i] == 0) continue;
		if(alp[i] != 2){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    for (int i=0;;i++){
        if (i%2==0) C-=B;
        if (i%2==1) A-=D;
        if (A<=0 || C<=0) break;
    }
    if (A<=0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3628
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize, m: usize,
        mut ab: [(usize, usize); m],
    }
    ab.sort_by_key(|a| (a.1, a.0));
    let mut last = 0;
    let mut ans = 0;
    for &abi in &ab {
        if abi.0 < last {
            continue;
        } else {
            last = abi.1;
            ans += 1;
        }
    }

    println!("{}", ans);
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for (int i = 0; i < N; i++)
    {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (V[i] - C[i] >= 0)
        {
            ans += V[i] - C[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    ll n, a[112345];
    cin >> n;
    map<ll, ll> mp;
    rep(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }
    ll one = 0, two = 0;
    sort(a, a + n, greater<int>());
    rep(i,n){
        if(a[i]>one&&mp[a[i]]>=2){
            one = a[i];
            continue;
        }
        else if(a[i]>two&&mp[a[i]]>=2&&one!=a[i]){
            two = a[i];
        }
    }
    if(mp[one]>=4)
        cout << one * one << endl;
        else
            cout << one * two << endl;
        return 0;
}

Measured memory_bytes: 7296
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func NewSlice(h, w int) [][]byte {
	s := make([][]byte, h)
	for i := range s {
		s[i] = make([]byte, w)
	}
	return s
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	a, b := nextInt(), nextInt()
	a--
	b--

	k := 50
	h, w := 2*k, 2*k
	ans := NewSlice(h, w)
	for i := range ans {
		for j := range ans[i] {
			if i < k-1 {
				ans[i][j] = '#'
			} else {
				ans[i][j] = '.'
			}
		}
	}

	for i := 0; i < k-1 && a > 0; i += 2 {
		for j := 0; j < w && a > 0; j += 2 {
			ans[i][j] = '.'
			a--
		}
	}

	for i := k; i < h && b > 0; i += 2 {
		for j := 0; j < w && b > 0; j += 2 {
			ans[i][j] = '#'
			b--
		}
	}

	puts(h, w)
	for i := range ans {
		for j := range ans[i] {
			putf("%c", ans[i][j])
		}
		puts()
	}
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0  || b % 3 == 0 || (a + b) % 3 == 0) {
    printf("Possible\n");
  }
  else printf("Impossible\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;

class UnionFind {
public:
    vector<LL> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    LL size(int x) {
        return -data[root(x)];
    }
};;

int main(){
    LL N,M;cin >> N >> M;
    vector<pair<LL,LL>> E;
    for(int a = 0;a < M;a++){
        int b,c;cin >> b >> c;
        E.push_back({b-1,c-1});
    }
    UnionFind Uni(N);
    vector<LL> ans;
    LL v = (N*(N-1))/2;
    for(int a = M -1;a >= 0;a--){
        ans.push_back(v);
        if(Uni.findSet(E.at(a).first,E.at(a).second))continue;
        LL ins = (Uni.size(E.at(a).first)*(Uni.size(E.at(a).first)-1))/2 + (Uni.size(E.at(a).second)*(Uni.size(E.at(a).second)-1))/2;
        LL siz = Uni.size(E.at(a).first) + Uni.size(E.at(a).second);
        Uni.unionSet(E.at(a).first,E.at(a).second);
        v -= (siz*(siz-1))/2 - ins;
    }
    //ans.back() = v;
    //reverse(ans.begin(),ans.end());
    sort(ans.begin(),ans.end());
    for(int a = 0;a < ans.size();a++){
        cout<<ans.at(a)<<endl;
    }
}


Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 2e1, M = 1<<N;

int main() {
	int a;
	cin>>a;
	int ans = a + a * a + a * a * a;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fir first
#define sec second
using namespace std;
long long a[1003], b[1003], c[1003];
int x, y, z, k;


bool m[1003][1003][1003];
vector<pair<long long, pair<int, pair<int, int>>>> retu;//最初和




long long ret(const int i,const int j,const  int k) {
	long long an = 0;
	an = a[i] + b[j] + c[k];
	return an;
}

auto mape(long long aa,int bb, int cc, int dd) {
	return make_pair(aa, make_pair(bb, make_pair(cc, dd)));
}




int main() {
	retu.reserve(9000);
	cin >> x >> y >> z >> k;
	for (int i = 0; i < x; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < y; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < z; i++)
	{
		cin >> c[i];
	}
	sort(a, a + x, greater<long long>());
	sort(b, b + y, greater<long long>());
	sort(c, c + z, greater<long long>());
	

	m[0][0][0] = 1;
	int max = 1;
	retu.push_back(mape(ret(0,0,0),0,0,0));
	for (int i = 0; i < k; i++)
	{
		int k, l, o;
		k = retu[max - 1].sec.fir;
		l = retu[max - 1].sec.sec.fir;
		o = retu[max - 1].sec.sec.sec;
		cout << retu[max - 1].first << endl;
		retu.pop_back();
		max--;
		if (k<x-1&&m[k+1][l][o]!=1)
		{
			retu.push_back(mape(ret(k+1, l, o), k+1, l, o));
			max++;
			m[k + 1][l][o] = 1;
		}
		if (l < y - 1 && m[k][l+1][o] != 1)
		{
			retu.push_back(mape(ret(k, l+1, o), k, l+1, o));
			max++;
			m[k][l + 1][o] = 1;
		}
		if (o < z - 1 && m[k][l][o+1] != 1)
		{
			retu.push_back(mape(ret(k, l, o+1), k, l, o+1));
			max++;
			m[k][l][o + 1] = 1;
		}
		sort(retu.begin(), retu.begin() + max);
	}
}

Measured memory_bytes: 981376
#include <bits/stdc++.h>
using namespace std;
const int maxn = 700 + 10;
int n, m, tot, ans;
bool M[maxn][maxn], dp[maxn][maxn];
int col[maxn], cnt[maxn][2];
vector<int> E[maxn]; 
void dfs(int x)
{
	if(!col[x]) ++cnt[tot][0];
	else ++cnt[tot][1];
	for(auto v : E[x])
	{
		if(col[v] == -1)
		{
			col[v] = col[x] ^ 1;
			dfs(v);
		}
		else if(col[v] == col[x])
		{
			puts("-1");
			exit(0);
		}
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		M[u][v] = M[v][u] = 1;
	}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			if(i != j && !M[i][j])
				E[i].push_back(j);
	memset(col, -1, sizeof(col));
	for(int i = 1; i <= n; ++i)
		if(col[i] == -1)
		{
			++tot;
			col[i] = 0;
			dfs(i);
		}
	dp[0][0] = 1;
	for(int i = 1; i <= tot; ++i)
		for(int x = 0; x < 2; ++x)
			for(int j = cnt[i][x]; j < maxn; ++j)
				dp[i][j] |= dp[i - 1][j - cnt[i][x]];
	ans = n * (n - 1) / 2;
	for(int j = 0; j < maxn; ++j)
		if(dp[tot][j])
			ans = min(ans, j * (j - 1) / 2 + (n - j) * (n - j - 1) / 2);
	printf("%d\n", ans);
	return 0;
}
	
		
	 

Measured memory_bytes: 3072
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    lint N; cin >> N;
    int c4, c2;
    c4 = c2 = 0;
    REP(i, N){
        int x; cin >> x;
        if(x%4==0) c4++; 
        else if(x%2==0) c2++;
    }
    if(c4 >= N/2){
        cout << "Yes" << endl;
        return 0;
    }
    lint k = N - 2*c4;
    cout << (c2>=k? "Yes": "No") << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

d = deque()
s = input()
d.append(s)
rev = 0
q = int(input())

for i in range(q):
  query = list(input().split())
  if (int(query[0]) == 1):
    rev = (rev + 1) % 2
  else:
    if ((int(query[1]) + rev) % 2 == 0):
      d.append(query[2])
    else:
      d.appendleft(query[2])

ans = ''.join(list(d))
if rev == 1:
  ans = ans[::-1]

print(ans)




Measured memory_bytes: 6900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String[] lines;
      int m,f,r,sum;

      do {

        lines = br.readLine().split(" ");
        m = Integer.parseInt(lines[0]);
        f = Integer.parseInt(lines[1]);
        r = Integer.parseInt(lines[2]);
        sum = m + f;

        if ( m == -1 && f == -1 && r == -1) break;
        else if( m == -1 || f == -1 ) {
          System.out.println("F");
          continue;
        }

        if ( sum >= 80 ) System.out.println("A");
        else if ( sum >= 65 ) System.out.println("B");
        else if ( sum >= 50 ) System.out.println("C");
        else if ( sum >= 30 ) {
          if ( r >= 50 ) System.out.println("C");
          else System.out.println("D");
        } else System.out.println("F");
      } while( br.ready() );
    }
  }
}


Measured memory_bytes: 24120
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        final int H = sc.nextInt();
        final int N = sc.nextInt();
        int A[] = new int[N];
        for (int i = 0; i < N; i++)
            A[i] = sc.nextInt();
        int accum = 0;
        for (int i = 0; i < N; i++)
            accum += A[i];
        if (accum < H)
            out.println("No");
        else
            out.println("Yes");
        out.flush();
    }
}

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

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

    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()),A.end());

    if(A.size() % 2 != 0){
        cout << A.size() << endl;
    }else{
        cout << A.size() - 1 << endl;
    }

    return 0;

}

Measured memory_bytes: 640
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      double T=double.Parse(str[0]);
      double X=double.Parse(str[1]);
      Console.WriteLine(T/X);
    }
    
  }

}


Measured memory_bytes: 27432
a=int(input())
l=[a,]
while True:
    if a%2==0:
        l.append(int(a/2))
        a=int(a/2)
    else:
        l.append((3*a)+1)
        a=(3*a)+1
    
    if len(l)!=len(set(l)):
        print(len(l))
        exit()

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> P;
typedef long double ld;

int main(void)
{
	int n, count_max = 0;
	P r[50];
	multimap<ll, ll> m;
	cin >> n;
	rep(i, n){
		ll a, b;
		cin >> a >> b;
		r[i] = make_pair(a, b);
		m.insert(r[i]);
	}
	sort(r, r + n);
	rep(x, n){
		rep(y, n){
			if(x == y) continue;
			int count = 0;
			ll p = r[x].first - r[y].first, q = r[x].second - r[y].second;
			rep(j, n){
				auto range = m.equal_range(r[j].first + p);
				for(auto it = range.first; it != range.second; it++){
					auto target = *it;
					if(target.second == r[j].second + q){
						count++;
						break;
					}
				}
			}
			chmax(count_max, count);
		}
	}
	cout << n - count_max << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,num,a[20];
	scanf("%d%d%d",&n,&num,&a[0]);
	for(int i=1;i<=10;++i) {
		a[i]=a[i-1]*n-num;
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    
    int N, Y;
    cin >> N >> Y;
    
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if(Y == ( 10000 * i ) + (5000 * j) + (1000 *(N - i -j)) && i + j <= N){
                cout << i << " " << j << " " << N - i - j << endl;
                return 0;
            }
        }
    }
    
    
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 888
N,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
A = sorted(A,key=lambda x:x[0])
cnt = 0
i = 0
while K>cnt:
    cnt += A[i][1]
    i += 1
print(A[i-1][0])

Measured memory_bytes: 90412
#include<bits/stdc++.h>
using namespace std;
int main() {
	int r, d, x;
	cin >> r >> d >> x;
	int a[11];
	a[0] = x;
	for (int i = 1; i < 11; i++) {
		a[i] = a[i - 1] * r - d;
		cout << a[i] << endl;
	}
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int r = 1;
	while (n > 1)
	{
		n = n >> 1;
		r = r << 1;
	}
	cout << r << endl;
	return 0;
}


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

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    while (cnt * a.at(i) + 1 <= d) {
      cnt++;
    }
    ans += cnt;
  }
  cout << ans + x << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main(void){
   int n,x,i,t=0;
   scanf("%d%d",&n,&x);
   int L[n];
   for(i=0;i<n;i++)
      scanf("%d",&L[i]);

   i=1;
   while((t<=x) && (i<=n)){
      t+=L[i-1];
      i++;
   }

   if(t>x) i--;
   printf("%d\n",i);
   return 0;
}

Measured memory_bytes: 128
// AOJ 2584: Broken Cipher Generator
// 2017.10.5 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <ctype.h>

char buf[85];
char ans[85];

char *parse(char *q, char *p);
char *reverse(char *q, int *w, char *p)
{
	char c, *t;

	p = parse(q, p);
	if (*p == ']') p++;
	t = q; while (*t) t++;
	*w = t-- -q;
	while (q < t) c = *q, *q = *t, *t = c, q++, t--; 
	return p;
}

char *parse(char *q, char *p)
{
	int k;

	while (*p) {
		k = 0;
		while (*p == '+' || *p == '-') {
			if (*p == '+') k++;	else k--;
			p++;
		}
		if (*p == '?') *q++ = 'A', p++;
		else if (isalpha(*p)) {
			k += (*p++ - 'A');
			if (k < 0) k = 26 + (k % 26);
			else k %= 26;
			*q++ = 'A' + k;
		} else if (*p == '[') {
			p = reverse(q, &k, p+1);
			q += k;
		} else break;      // ']'
	}
	*q = 0;
	return p;
}

int main()
{
	while (scanf("%s", buf) && *buf != '.') {
		parse(ans, buf);
		puts(ans);
	}
	return 0;
}

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

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

ll arr[10005];
ll rett(ll a, ll b, ll c)
{
	return a * (a + b) + b * (b + c) + c * (c + a);
}

int main()
{
	cio;

	int n;
	cin >> n;

	for(ll i = 1; i <= 100; i++)
		for (ll j = 1; j <= 100; j++)
		{
			for (ll k = 1; k <= 100; k++)
			{
				ll gop = rett(i, j, k);
				if (gop > n)
					break;
				arr[gop]++;
			}
		}

	for (int i = 1; i <= n; i++)
		cout << arr[i] << endl;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long A, long long B)
{
    ll num = gcd(A, B);
    ll N = num;
    ll ans = 1;
    for (ll i = 2; i < sqrt(N); i++)
    {
        if (num % i == 0)
        {
            bool isFirst = true;

            while (num % i == 0)
            {
                if (isFirst)
                {
                    ans++;
                    isFirst = false;
                }
                num /= i;
            }
        }

        if (num == 1)
        {
            break;
        }
    }
    if (num > sqrt(N))
    {
        if (num == N)
        {
            ans++;
        }
        else
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(input())
b=list(input())
c=list(input())
ans=0
for i in range(n):
    if a[i]!=b[i] and a[i]!=c[i] and b[i]!=c[i]:
        ans+=2
    elif a[i]==b[i] and b[i]!=c[i]:
        ans+=1
    elif a[i]==c[i] and b[i]!=c[i]:
        ans+=1
    elif c[i]==b[i] and a[i]!=c[i]:
        ans+=1
    else:
        ans+=0
print(ans)

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

int main(){
	int mountains[9] = {};

	for(int i = 0; i < 10; i++){
		cin >> mountains[i];
	}

	for(int i = 0; i < 3; i++){
		int maxIndex = 0;
		for(int j = 0; j < 10; j++){
			if(mountains[maxIndex] < mountains[j]){
				maxIndex = j;
			}
		}
		cout << mountains[maxIndex] << endl;
		mountains[maxIndex] = -1;
	}

	return 0;

}

Measured memory_bytes: 1160
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	// 1 <= N <= 2000
	// 1000 <= Y <= 2*10^7
	// Nは整数
	// Yは1000の倍数

	// ありえる場合は「1万円札 5千円札 千円札」の順番でかき
	// 1万円札=a, 5千円札=b, 千円札=c の枚数
	// ありえない場合は、「-1 -1 -1」で書く

	sc.Split(bufio.ScanWords)
	x := make([]int, 2)
	for i := 0; i < 2; i++ {
		x[i] = nextInt()
	}

	N := x[0]
	Y := x[1]

	count := 0
	// N = a + b + c
	// Y = 1000*a + 5000*b + 10000*c
	// Y = 1000*(N-b-c) + 5000*b + 10000*c
	for b := 0; b <= N; b++ {
		for c := 0; c <= N-b; c++ {
			if 1000*(N-b-c)+5000*b+10000*c == Y {
				fmt.Println(c, b, (N - b - c))
				count++
				break
			}
		}
		if count != 0 {
			break
		}
	}
	if count == 0 {
		fmt.Println(-1, -1, -1)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vl a(n + 2);
  vl dp(n+2, 0);
  a[0] = 0;
  for (ll i = 1; i <= n; i++){
    cin >> a[i];
    dp[a[i]]++;
  }
  ll sum = 0;
  for(ll i=1;i<=n;i++){
    sum += (dp[i] * (dp[i] - 1)) / 2;
  }
  for (ll i = 1; i <= n;i++){
    ll ans = sum - (dp[a[i]]-1);
    print(ans);
  }
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int n, k;
vector<vector<int>> e;

int dfs(int current, int parent, ll count) {
    int used = current == 0 ? 1 : 2;
    for (auto child : e[current]) {
        if (child == parent) {
            continue;
        }
        count = count * dfs(child, current, k - used) % MOD;
        used++;
    }
    return count;
}

int main() {
    cin >> n >> k;
    e.assign(n, vector<int>());
    int a, b;
    REP(i, n - 1) {
        cin >> a >> b;
        a--;
        b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    cout << dfs(0, -1, k) << endl; 
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
signed main() {
  int R,G,B,N;
  cin>>R>>G>>B>>N;
  int ans = 0;
  for (int r = 0; R*r <= N; r++) {
    for (int g = 0; R*r+G*g <= N; g++) {
      if (N > R*r+G*g && (N-R*r-G*g)%B == 0) {
        ans++;
      } else if (N == R*r+G*g) {
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        n:usize,
        a:[Chars;n]
    }
    // 4つ分並べて考える。
    let mut b = vec![vec![0u8; n]; n * 2];
    for i in 0..n {
        for j in 0..n {
            let u = (a[i][j] as u8) - ('a' as u8);
            b[i][j] = u;
            b[i + n][j] = u;
        }
    }
    let mut ans = 0;
    for i in 0..n {
        let mut flag = true;
        for x in 0..n {
            if !flag {
                break;
            }
            for y in 0..x {
                if b[i + x][y] != b[i + y][x] {
                    flag = false;
                    break;
                }
            }
        }
        if flag {
            ans += 1;
        }
    }

    ans *= n;
    println!("{}", ans);
}


Measured memory_bytes: 2804
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  long long N;cin>>N;
  vector<long long> A(N);
  for(long long i = 0; N > i; i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  if(N%2){
    long long a = 0;
    long long n = 1;
    long long m = N-1;
    long long t0 = A[0];
    long long t1 = A[0];
    while(n<m){
      a += abs(t0-A[m]);t0=A[m];m--;
      a += abs(t1-A[m]);t1=A[m];m--;
      if(n >= m)break;
      a += abs(t0-A[n]);t0=A[n];n++;
      a += abs(t1-A[n]);t1=A[n];n++;
    }
    sort(A.begin(),A.end(),greater<long long>());
    long long b = 0;
    n = 1;
    m = N-1;
    t0 = A[0];
    t1 = A[0];
    while(n<m){
      b += abs(t0-A[m]);t0=A[m];m--;
      b += abs(t1-A[m]);t1=A[m];m--;
      if(n >= m)break;
      b += abs(t0-A[n]);t0=A[n];n++;
      b += abs(t1-A[n]);t1=A[n];n++;
    }
    cout << max(a,b) << endl;

  }else{
    long long a = 0;
    long long n = 1;
    long long m = N-1;
    long long t0 = A[0];
    long long t1 = A[0];
    while(n<m){
      a += abs(t0-A[m]);t0=A[m];m--;
      a += abs(t1-A[m]);t1=A[m];m--;
      if(n >= m)break;
      a += abs(t0-A[n]);t0=A[n];n++;
      a += abs(t1-A[n]);t1=A[n];n++;
    }
    cout << a+max(abs(t1-A[n]),abs(t0-A[n])) << endl;
  }
}


Measured memory_bytes: 1024
// MODULAREXPONENTIATION
// NCR
// LOOP IN DIRECTED GRAPH
// DSU
// LIS
// DISTINCT_CHARACTER_BETWEEN_L_TO_R



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


typedef long long int ll;

vector<ll> adj[1000001]; 

ll i;
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define rep(i,st,end) for( i=st;i<end;i++)
#define repv(i,st,end) for( i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
  string na[]={"MON", "TUE", "WED", "THU", "FRI", "SAT","SUN"};
   string s;
   ll ans;
   cin>>s;
   for(i=0;i<7;i++)
   {
       if (na[i]==s)
       {
           ans=6-i;
          break;
       }
   }
  // cout<<"hello"<<ans<<"\n";
   if (ans==0)
   	ans=7;
   cout<<ans;
	return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define Int int64_t
using namespace std;
const Int M=(Int)(1e9+7);


Int N;

int main()
{
   int t;t=1;
   while(t--){
       string S,T;
       cin>>S>>T;
       Int ans=0;
       for(int i=0;i<S.length();++i){
           ans+=(S[i]!=T[i]);
       }
       cout<<ans<<"\n";
   }
}

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

void dfs(vector<vector<long long>> &distance, vector<int> &R, vector<bool> &check, int now, long long &ans, long long d){
    bool flag = false;
    for (int i = 1; i < R.size(); i++){
        if (check[i]){
            flag = true;
            check[i] = false;
            if (now == 0) d = 0;
            else d += distance[R[now]][R[i]];
            dfs(distance, R, check, i, ans, d);
            if (now == 0) d = 0;
            else d -= distance[R[now]][R[i]];
            check[i] = true;
        }
    }

    if (flag == false) ans = min(ans, d);
}

int main(){
    long long INF = 10'000'000'000;
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> R(r+1);
    vector<bool> check(r+1, true);
    for (int i = 1; i <= r; i++) cin >> R[i];
    vector<vector<long long>> distance(n+1, vector<long long>(n+1, INF));
    int a, b, c;
    for (int i = 0; i < m; i++){
        cin >> a >> b >> c;
        distance[a][b] = c;
        distance[b][a] = c;
    }

    for (int k = 1; k < n+1; k++){
        for (int i = 1; i < n+1; i++){
            for (int j = 1; j < n+1; j++){
                distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j]);
            }
        }
    }

    long long ans = 10'000'000'000;
    dfs(distance, R, check, 0, ans, 0);
    
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;


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

    if(a.front()) {
        cout << -1 << endl;
        return 0;
    }

    ll sum = 0;
    for(int i = 1; i < n; i++) {
        while(i < n-1 && a[i] < a[i + 1]) {
            if(a[i + 1] - a[i] != 1) {
                cout << -1 << endl; return 0;
            }
            i++;
        }
        sum += a[i];
        // cerr << i << endl;
    }
    cout << sum << endl;
}


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

using namespace std;

int N, A, B, C;
int l[1001];

int dfs(int cur, int a, int b, int c) {
  if (cur == N) {
    if (min({a, b, c}) > 0)
      return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    else
      return pow(10, 9);
  }
  int useA = dfs(cur + 1, a + l[cur], b, c) + 10;
  int useB = dfs(cur + 1, a, b + l[cur], c) + 10;
  int useC = dfs(cur + 1, a, b, c + l[cur]) + 10;
  int notUse = dfs(cur + 1, a, b, c);
  return min({useA, useB, useC, notUse});
}

int main() {
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  cout << dfs(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, m;
ll sum[51];
int main() {
    cin>>n>>m;
    REP(i, 0, n){
        ll k, a;
        cin>>k;
        REP(j, 0, k){
            cin>>a;
            sum[a-1]++;
        }
    }

    ll ans=0;
    REP(i, 0, m){
        if(sum[i]==n) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    long long ans = 0;
    vector<pair<int, int>> off(n);
    for(auto& x : off)
        cin >> x.fi >> x.se;
    
    sort(begin(off), end(off));
    for(auto& x : off) {
        if(m < x.se) {
            ans += 1ll * m * x.fi;
            break;
        } else {
            m -= x.se;
            ans += 1ll * x.fi * x.se;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
#define int long long

const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<double>x(n), y(n);
	rep(i, n)cin >> x[i] >> y[i];
	double ans = 0;
	double tmp2 = 1;
	for (int i = n; i >= 1; i--)tmp2 *= i;
	VE tmp(n);
	rep(i, n)tmp[i] = i;
	do {
		double now = 0;
		rep(i, n - 1) {
			now += sqrt((x[tmp[i]] - x[tmp[i + 1]])*(x[tmp[i]] - x[tmp[i + 1]]) + (y[tmp[i]] - y[tmp[i + 1]])*(y[tmp[i]] - y[tmp[i + 1]]));
		}
		ans += now;
	} while (next_permutation(ALL(tmp)));
	
	cout << fixed<<setprecision(15)<<ans / tmp2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(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((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    ll n, k;
    cin >> n >> k;
    if(n >= k)
        n %= k;
    cout << min(n, k-n) << endl;

    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, n, t;std::cin >> n >> t;
  ll m=0, mc=0, minc=0;
  multiset<ll> s;
  re(i, n){
    std::cin >> a;
    s.insert(a);
    if(a-*s.begin()>m) m =a-*s.begin(), mc=1, minc=s.count(*s.begin());
    else if(a-*s.begin() == m) {
      mc++;
      minc += s.count(*s.begin());
    }
  }
  std::cout << min(mc, minc) << '\n';
  return 0;
}


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

inline void Main() {
  // code
  int n, b, r = 0;
  int a[20], c[20];
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    cin >> b;
    r += b;
  }
  rep(i, n) cin >> c[i];
  rep(i, n-1) {
    if(a[i+1] - a[i] == 1) {
      r += c[a[i]-1];
    }
  }
  cout << r << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256