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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  ll ans = 0;
  int m = 1;
  for(int i = 0; i < n; i++) {
    int a; cin >> a;
    int b = (a + m - 1) / m - 1;
    ans += b;
    if(!b) m = max(m, a + 1);
    else m = max(m, 2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(n, k int) float64 {

        out := 0.0
        for i := 1; i < n+1; i++ {
                if i < k {
                        x := helper(i, k)
                        out += (1 / float64(n)) * x
                } else {
                        out += 1 / float64(n)
                }
        }
        return out
}

func helper(i, k int) float64 {
        x, out := i, 1.0
        for k > x {
                x *= 2
                out /= 2
        }
        return out
}

func main() {
        var n, k int
        fmt.Scan(&n, &k)
        fmt.Printf("%.12f\n", solution(n, k))
}

Measured memory_bytes: 1832
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			string num = Console.ReadLine();
			int n = int.Parse(num);
			

			for(int i = 1; i <= n; i++)
			{
				int x = i;
				if(x%3 == 0)
				{
					Console.Write(" {0}", i);
				}
				else 
				{
					while (x > 0)
					{
						if(x%10 == 3)
						{
							Console.Write(" {0}", i);
							break;
						}
						x /= 10;
					}
				}
				
			}
			Console.WriteLine();
		}
	}
}



Measured memory_bytes: 17896
#include <stdio.h>
#define MAX 1000

main(){
  
  int i,j,v,N;
  int A[MAX];
  
  scanf("%d",&N);
  if(1>N && N>100) printf("error\n");
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(j=0;j<N-1;j++){
    printf("%d ",A[j]);
  }
  printf("%d\n",A[j]);

  for(i=1;i<N;i++){
    v = A[i];
    j = i-1;
    
    while(j >= 0 && A[j] > v){
      
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
    for(j=0;j<N-1;j++){
      printf("%d ",A[j]);
    }
    printf("%d",A[j]);
    printf("\n"); 
    
  }
  return 0;
}

Measured memory_bytes: 608
#include "bits/stdc++.h"

using namespace std;

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

	int a, b, c;

	cin >> a >> b >> c;

	if (b - a == c - b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> board(H, vector<int>(W, 0));
    for (int i = 0; i < H; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < W; ++j) {
            board[i][j] = (s[j] == '#' ? 1 : 0);
        }
    }
    int ans = 0;
    for (int i = 0; i < (1 << H); ++i) {
        for (int j = 0; j < (1 << W); ++j) {
            int blk = 0;
            for (int k = 0; k < H; ++k) {
                for (int l = 0; l < W; ++l) {
                    if (((i >> k) & 1 == 1) && ((j >> l) & 1 == 1)) {
                        if (board[k][l] == 1) blk++;
                    }
                }
            }
            if (blk == K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
#include<queue>
using namespace std;



int main(){
  int n; cin>>n;
  int h[110000];
  for(int i=0;i<n;i++)
  cin>>h[i];
  int dist1[110000],dist2[110000];
  for(int i=0;i<n-1;i++)
  dist1[i]=abs(h[i]-h[i+1]);
  for(int i=0;i<n-2;i++)
  dist2[i]=abs(h[i]-h[i+2]);

  int dp[110000]={0};dp[1]=dist1[0];
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+dist1[i-1],dp[i-2]+dist2[i-2]);
  }

  cout<<dp[n-1]<<endl;


}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define N 1000099
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define LL long long
// ios::sync_with_stdio(false);
using namespace std;
int n, num;
int head[N];
LL K, ans;
struct edge
{
    int v, nxt;
} ed[N];
void add(int u, int v)
{
    ed[++num].nxt = head[u];
    ed[num].v = v;
    head[u] = num;
}
void dfs(int u, int fa, int dep)
{
    int st = 0;
    if (dep)
        st = K - 2;
    else
        st = K - 1;
    for (int i = head[u]; i; i = ed[i].nxt)
    {
        int v = ed[i].v;
        if (v == fa) continue;
        ans = (ans * st) % MOD;
        st--;
        dfs(v, u, dep + 1);
    }
}
int main()
{
    cin >> n >> K;
    for (int i = 1, x, y; i < n; i++)
    {
        scanf("%d%d", &x, &y);
        add(x, y);
        add(y, x);
    }
    ans = K;
    dfs(1, 0, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10256
import java.util.*;
 
public class Main {
   
    private static int[][] ans = new int[11][331];
    private static ArrayDeque<Integer> q = new ArrayDeque<Integer>();
	private static Scanner sc  = new Scanner(System.in);
	private static int n, temp;
     
  
     
         
    public static void main(String[] args) {
    	 doing(1,0);
    	 while(sc.hasNextInt()){
            n = sc.nextInt();
            temp = sc.nextInt();
            if(n < 11 && temp < 331) System.out.println(ans[n][temp]);
            else System.out.println(0);
        }
    }   
    public static void doing(int a, int b){
        if(a == 11) return;
        for(int i =  0;i < 10;i++){
            if(q.contains(i) == false){
                q.push(i);
                ans[a][b + a *i]++;
                doing(a + 1,b + a * i);
                q.pop();
            }
        }
    }
}

Measured memory_bytes: 27588
#include <bits/stdc++.h>
using namespace std;
#define fin "qualB_E.inp"
#define fou "qualB_E.out"
#define ff(i, a, b) for(int i = a; i <= b; i ++)
#define fd(i, a, b) for(int i = a; i >= b; i --)
#define x first
#define y second
#define endl '\n'
typedef long long data;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1e5 + 10;
const int M = 5e5;

int n, q, k;
string s[N], p;
int num, tnext[M][26], endstr[M], f[M];
int cnt[N][26][26], smaller[N];

void read()
{
    cin >> n;
    ff(i, 1, n) cin >> s[i];
    cin >> q;
}
void build()
{
    num = 1;
    int u, v;
    ff(i, 1, n)
    {
        u = 1;
        ff(j, 1, s[i].size())
        {
            if (!tnext[u][s[i][j - 1] - 'a'])
                tnext[u][s[i][j - 1] - 'a'] = ++ num;
            u = tnext[u][s[i][j - 1] - 'a'];
        }
        endstr[u] = i;
    }
}
void visit(int u)
{
    int v;
    if (endstr[u]) f[u] = 1;
    ff(c, 0, 25)
    {
        v = tnext[u][c];
        if (v) visit(v);
        f[u] += f[v];
    }
}
void init()
{
    build();
    visit(1);
    int u, v, d;
    ff(k, 1, n)
    {
        u = 1;
        ff(i, 1, s[k].size())
        {
            d = s[k][i - 1] - 'a';
            ff(c, 0, 25)
                if (c != d)
                {
                    v = tnext[u][c];
                    if (v) cnt[k][c][d] += f[v];
                }
            u = tnext[u][d];
            if (endstr[u]) ++ smaller[k];
        }
    }
}
void solve()
{
    init();
    int ans;
    while (q --)
    {
        cin >> k >> p;
        ans = smaller[k];
        ff(u, 0, 24)
            ff(v, u + 1, 25)
            {
                ans += cnt[k][p[u] - 'a'][p[v] - 'a'];
                if (k == 1 && cnt[k][p[u] - 'a'][p[v] - 'a']);
            }
        cout << ans << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen(fin,"r",stdin), freopen(fou,"w",stdout);

    read();
    solve();
    return 0;
}


Measured memory_bytes: 280960
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N; cin >> N;
  cout << 180*(N-2) << endl;
  return 0;
}


Measured memory_bytes: 764
#include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
     
    using namespace std;
     
    typedef long long LL;
    const int MX=200011;
     
    int n;
    LL a[MX];
    struct Edge{int t,nxt;Edge(int _t=0,int _nxt=0):t(_t),nxt(_nxt){}}e[MX];
    int hed[MX],ec,D[MX];
    inline void ade(int f,int t){e[++ec]=Edge(t,hed[f]),hed[f]=ec;}
    LL clca[MX],cf[MX];
     
    #define FE(i) for(int (i)=hed[k];i;i=e[i].nxt)if(e[i].t!=f)
    void dfs(int k,int f){
    	if(D[k]==1){clca[k]=0,cf[k]=a[k];return;}
    	LL S=0,mxs=0;
    	FE(i)dfs(e[i].t,k),S+=cf[e[i].t],mxs=max(mxs,cf[e[i].t]);
    	cf[k]=2*a[k]-S;
    	clca[k]=S-a[k];
    	if(cf[k]<0||clca[k]<0)exit((puts("NO"),0));
    	if(S-mxs<clca[k])exit((puts("NO"),0));
    }
    int main(){
    	scanf("%d",&n);
    	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    	for(int i=1;i<n;i++){
    		static int u,v;scanf("%d%d",&u,&v);
    		ade(u,v),ade(v,u),++D[u],++D[v];
    	}
    	if(n==1)return puts(a[1]?"NO":"YES"),0;
    	if(n==2)return puts(a[1]==a[2]?"YES":"NO"),0;
    	int rot=0;
    	for(int i=1;i<=n;i++)if(D[i]>1){rot=i;break;}
    	dfs(rot,0);
    	if(cf[rot])return puts("NO"),0;
    	puts("YES");
    	return 0;
    }

Measured memory_bytes: 11776
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [n, k] <- getIntList
  print $ k * (k -1) ^ (n -1)


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

int main(){
string s1, s2;
cin >> s1 >> s2;
int N = s1.size(), ans = 0;
for(int i = 0; i < N; ++i){
	if(s1[i] != s2[i]) 
		ans++;
}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3904
//ABC051B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> t(n);
	long long int sigma = 0;
	for(int i=0;i<n;i++){
		cin >> t.at(i);
		sigma += t.at(i);
	}
	int m;
	cin >> m;
	int p, x;
	long long int ans;
	for(int i=0;i<m;i++){
		cin >> p >> x;
		ans = sigma - t.at(p-1) + x;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
xy = []
for i in range(n):
    a = int(input())
    xy.append([])
    for j in range(a):
        x, y = map(int, input().split())
        xy[i].append((x, y))

ans = 0
for i in range(2**n):
    flag = True
    for j in range(n):
        if (i >> j) & 1 == 0:
            continue
        for k in xy[j]:
            x, y = k[0], k[1]
            if not((1 & (i >> (x-1))) == y):
                flag = False
    if flag:
        ans = max(ans, bin(i).count("1"))
print(ans)


Measured memory_bytes: 3064
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

char a[4004];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r = 0, g = 0, b = 0;
    int n = gi();
    scanf("%s", a);
    for (int i = 0; i < n; i++)
        if (a[i] == 'R')
            r++;
        else if (a[i] == 'G')
            g++;
        else
            b++;

    int rr = 0, gg = 0, bb = 0;
    ll res = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 'R')
            r--;
        else if (a[i] == 'G')
            g--;
        else
            b--;
        if (a[i] == 'R')
            res += g*bb + gg*b;
        else if (a[i] == 'G')
            res += r*bb + rr*b;
        else
            res += r*gg + rr*g;
        for (int j = 1; i-j >= 0 && i+j < n; j++)
            if (a[i-j] != a[i] && a[i] != a[i+j] && a[i+j] != a[i-j])
                res--;
        if (a[i] == 'R')
            rr++;
        else if (a[i] == 'G')
            gg++;
        else
            bb++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3708
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	ll H;
	cin >> H;

	ll tmp = 63 - __builtin_clzll(H);
	
	ll kotae = 0;
	for (int i = tmp; i >= 0; i--) {
		kotae += 1ll << i;
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np
from itertools import *
# from collections import *

# S = input()
# N = int(input())
# K, N = [int(x) for x in input().split()]

N, M, X = [int(x) for x in input().split()]

r = [0] * M
b = []

for n in range(N):
    b += [[int(x) for x in input().split()]]
C = []

for n in range(N):
    C += list(combinations(b, n+1))

minm = -1

for c in C:
    c = np.array(c)
    if min(np.sum(c[:, 1:M+1], axis=0)) >= X:
        if minm == -1 or np.sum(c[:, 0]) < minm:
            minm = np.sum(c[:, 0])

print(minm)


Measured memory_bytes: 27700
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	K := getStdinInt()
	S := getStdin()

	if len(S) <= K {
		fmt.Print(S)
	} else {
		fmt.Printf("%s%s", S[:K], "...")
	}

	fmt.Printf("\n")
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	sc.Scan()
	rtn, _ := strconv.Atoi(sc.Text())
	return rtn
}
func getStdinIntArr() []int {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


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

#define mem(f, v) memset(f,v,sizeof(f))
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);

typedef long long ll;
const int maxn = 100010;
const int inf = ~(1u << 31u);
const ll linf = ~(1llu << 63u);

using namespace std;

struct node{
    string name;
    int val, id;
    node(string name, int val, int id) :
    name(name), val(val), id(id) {}
    bool operator < (const node &t) const{
        return name == t.name ? val > t.val : name < t.name;
    }
};

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector <node> d;
    for(int i = 1; i <= n; i ++){
        string str;
        int v;
        cin >> str >> v;
        d.emplace_back(str, v, i);
    }
    sort(d.begin(), d.end());
    for(auto &t : d) cout << t.id << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var n int
	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		var j int
		scanner.Scan()
		j, _ = strconv.Atoi(scanner.Text())
		a[i] = j
	}

	max1 := -1
	max2 := -1
	for _, v := range a {
		if v > max1 {
			max2 = max1
			max1 = v
		} else if v > max2 {
			max2 = v
		}
	}

	ans := make([]string, n)
	for i := 0; i < n; i++ {
		if a[i] != max1 {
			ans[i] = fmt.Sprint(max1)
		} else {
			ans[i] = fmt.Sprint(max2)
		}
	}

	buf := strings.Join(ans, "\n")

	fmt.Print(buf)
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a;
  vi A(a);
  vi AA;
  ll cnt=0;
  for(auto &aa:A){cin>>aa;AA.pb(aa);}
  sort(ALL(A));
  for(int i=0;i<a;i++)
    if(A[i]!=AA[i])cnt++;
  if(cnt==0||cnt==2)
  cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	return OUT(min(a, b) + min(c, d));
}


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

const int N = 200005;

struct edge {
	int w; int u; int v;
	bool operator < (const edge &other) const {
		return w < other.w;
	}
};
vector <edge> ed;

int n, m, ncolor;
int c[N];
int par[N];
long long res;

// DSU
int anc(int p) { return p == par[p] ? p : par[p] = anc(par[p]); }
void join(int p, int q) { par[p] = q; } // p = anc(p), q = anc(q)

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> n >> m >> ncolor;

	int more = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> c[i];
		if (!c[i]) ++more, c[i] = ncolor + more;
	}

	while(m--) {
		int u, v, w; cin >> u >> v >> w;
		ed.push_back({w, c[u], c[v]});
	}

	int tot = ncolor + more;

	for (int i = 1; i <= tot; ++i) par[i] = i;
	sort(ed.begin(), ed.end());

	int need = ncolor - 1;
	for (auto &e : ed) {
		int u = anc(e.u);
		int v = anc(e.v);
		if (u == v) continue;

		--need;
		join(u, v);
		res += e.w;

		if (!need) break;
	}

	if (!need) cout << res << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 2804
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			int[] a=new int[n+1];
			for(int i=0; i<n; i++) {
				a[i]=sc.nextInt();
			}
			int q=sc.nextInt();
			int[] m=new int[q+1];
			for(int i=0; i<q; i++) {
				m[i]=sc.nextInt();
			}
			int[] sum=new int[(1<<n)];
			for(int i=0; i<(1<<n); i++) {
				sum[i]=0;
				for(int j=0; j<n; j++) {
					if((1 & i>>j) == 1) {
						sum[i]+=a[j];
					}
				}
			}
			for(int i=0; i<q; i++) {
				int count=0;
				for(int j=0; j<(1<<n); j++) {
					if(m[i]==sum[j]) {
						count++;
						System.out.println("yes");
						break;
					}
				}
				if(count==0) {
					System.out.println("no");
				}
			}
			

		}
	}
}


Measured memory_bytes: 31632
n=gets.to_i
a=gets.split.map &:to_i
b=gets.split.map &:to_i
m=0
for k in 0...n
sum=0
for i in 0..k
sum+=a[i]
end
for j in k...n
sum+=b[j]
end
m=sum if m<sum
end
p m

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

#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
typedef pair <int, int> pii;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, a;
	cin >> h >> a;
	cout << (h + a - 1) / a;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	// エラトステネスのふるい
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0;
    is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }

	vector <int> likeNum(MAX, 0);
	for (int ii = 1; ii < MAX; ++ii){
        if ( (!is_prime[ii]) || !is_prime[(ii+1)/2] ) {
        	likeNum[ii] = likeNum[ii-1];
        } else {
	        likeNum[ii] = likeNum[ii-1] + 1;        	
        }
	}

	int Q;
	cin >> Q;
	for (int ii = 0; ii < Q; ++ii){
		int l, r;
		cin >> l >> r;
		cout << likeNum[r] - likeNum[l-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        
        if( H == 0 && W == 0) break;
        
        for(int i = 0; i < H; i ++){
            for(int j = 0; j < W; j ++){
                cout<<"#";
            }
            cout << endl;
            
        }
        
        cout << endl;
        
    }
    return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define    ll   long long int
#define    sz   200010

using namespace std;


priority_queue<pair<ll,ll> >q;

int main()
{
    ll n,k,i,j,p,a,v,x,b;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>a;
        q.push({-a,i});
    }

    while(!q.empty())
    {
        x=q.top().second;
        q.pop();

        cout<<x<<" ";
    }
    cout<<endl;



    return 0;
}


Measured memory_bytes: 2544
N = int(input())
count = 0
x = 0
y = 0
t = 0

for i in range(N):
    t_i, x_i, y_i = map(int, input().split())
    way = abs(x_i - x) + abs(y_i - y)
    time = t_i - t

    if way <= time:
        if way % 2 == time % 2:
            count += 1
    x = x_i
    y = y_i
    t = t_i

if count == N:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};
use std::{cmp, fmt};

fn main() {
    let (s, w): (String, usize) = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        (sc.next(), sc.next())
    };
    let s = s.as_bytes();
    for k in 0..(s.len() + w - 1) / w {
        print!("{}", s[k * w] as char);
    }
    println!();
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
/*
csc -debug B.cs && mono --debug B.exe <<< "
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var N = cin.NextInt();
        var ans = 0;
        for (var i = 1; i <= N; i++)
            if (i.ToString().Length % 2 == 1)
                ans++;
        System.Console.WriteLine(ans);
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static string Join<T>(this IEnumerable<T> arr, string sep = " ") {
        return string.Join(sep, arr);
    }

    public static void Swap<T>(ref T a, ref T b) {
        var tmp = a;
        a = b;
        b = tmp;
    }

    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

Measured memory_bytes: 15188
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

   int n; cin>>n;

    int a = n % 10;

    set<int> s1 = {2, 4, 5, 7, 9}, s2 = {0, 1, 6, 8};

    if(s1.count(a))cout<<"hon\n";
    else if(s2.count(a))cout<<"pon\n";
    else cout<<"bon\n";

    







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3656
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


int main() {
	int n, m, a[10000], sum = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if (n >= sum) {
		cout << n - sum << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 3672
import numpy as np

s=input()
n=len(s)
ans=[0]*(n+1)
for i in range(n):
    if s[i] == "<":
        ans[i+1] = max(ans[i+1], ans[i]+1)

for i in reversed(range(n)):
    if s[i] == ">":
        ans[i] = max(ans[i+1]+1,ans[i])

print(sum(ans))

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

int main(int argc, char *argv[]) {
  string S, T;
  cin >> S;
  cin >> T;
  char c;
  vector<int> v;
  for(int i = 0; i < 26; i++) {
    c = 'a' + i;
    v.clear();
    for(int j = 0; j < S.length(); j++) {
      if(T[j] == c) {
        v.push_back(j);
      }
    }
    if(v.size() == 1 || v.size() == 0) {
      continue;
    }
    for(int k = 0; k < v.size()-1; k++) {
      if(S[v[k]] != S[v[k+1]]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  for(int i = 0; i < 26; i++) {
    c = 'a' + i;
    v.clear();
    for(int j = 0; j < S.length(); j++) {
      if(S[j] == c) {
        v.push_back(j);
      }
    }
    if(v.size() == 1 || v.size() == 0) {
      continue;
    }
    for(int k = 0; k < v.size()-1; k++) {
      if(T[v[k]] != T[v[k+1]]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int gcd(int a, int b, int c, vector<vector<vector<int>>> &memo){
    if (memo.at(a).at(b).at(c)!=0){
        return memo.at(a).at(b).at(c);
    }
    // compute 
    int tmp =  std::__gcd(a, b);
    memo.at(a).at(b).at(c) = std::__gcd(tmp, c);
    return memo.at(a).at(b).at(c);
}
int main()
{   
    int K;
    std::cin >> K;
    long sum=0;
    vector<vector<vector<int>>> memo(K+1, vector<vector<int>>(K+1, vector<int>(K+1, 0)));
    for(int i=1; i<=K; i++){
        for(int j=1; j<=K; j++){
            for(int k=1; k<=K; k++){
                sum += gcd(i, j, k, memo);
            }
        }
    }
 
    std::cout << sum<< std::endl;
}


Measured memory_bytes: 36692
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long int
#define AMAX 31000

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int N; cin>>N;
    int a[AMAX][2];
    for(int i = 0; i < AMAX; i++){
        a[i][0] = -1;
        a[i][1] = -1;
    }
    cin>>a[1][0]>>a[1][1];
    for(int i = 0; i < N-1; i++){
        int l,r; cin>>l>>r;
        for(int k = 1; k <= AMAX; k++){
            if(a[k][0]==-1){
                a[k][0]=l; a[k][1]=r; break;
            }else{
                if(a[k][0]>r || a[k][1]<l) continue;
                if(a[k][0]>l) a[k][0] = l;
                if(a[k][1]<r) a[k][1] = r;
                break;
            }
        }
    }
    int sum = 0;
    for(int i = 1; a[i][0]!=-1; i++){
        sum+=a[i][1]-a[i][0]+1;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 512
n,m = map(int, input().split())
A = list(map(int, input().split()))
c1 = 0
c2 = 0
for i in range(n-1):
  for k in range(n-1-i):
    if A[i] > A[k+1+i]:
      c1 += 1
for i in range(n):
  for k in range(n):
    if A[i] > A[k]:
      c2 += 1
c3 = (m * (m - 1) // 2)%(10**9+7)
c4 = (c3*c2)%(10**9+7)
c5 = (c1*m)%(10**9+7)
print(int((c4+c5)%(10**9+7)))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

set<string> se;

int n;

void dfs(string s, char mx){
  if(int(s.size()) == n) {
    cout << s << endl;
    return;
  }

  for(char c = 'a'; c <= mx+1; c++){
    string t = s;
    t += c;
    dfs(t, max(mx, c));
  }
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  dfs("", 'a'-1);
}


Measured memory_bytes: 1664
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val A, B, C, K = sc.nextInt

  @scala.annotation.tailrec
  def loop(A: Int = A, B: Int = B, C: Int = C, count: Int = 1): Boolean = {
    if (B > A && C > B) true
    else if (count > K) false
    else if (B <= A) loop(A, B * 2, C, count + 1)
    else if (C <= B) loop(A, B, C * 2, count + 1)
    else loop(A, B, C, count + 1)
  }

  val z = if (loop()) "Yes" else "No"
  println(z)
}


Measured memory_bytes: 55196
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    string s;
    cin>>s;
    if(s[0] >='A' && s[0]<='Z') cout<<"A\n";
    else cout<<"a\n";
    return 0;
    
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll p=998244353;
  ll dp[c-a+1][d-b+1];
  rep(i,c-a+1)rep(j,d-b+1)dp[i][j]=0;
  dp[0][0]=(ll)1;
  rep(i,c-a)dp[i+1][0]=(dp[i][0]*b)%p;
  rep(i,d-b)dp[0][i+1]=(dp[0][i]*a)%p;
  rep(i,c-a){
    rep(j,d-b){
      dp[i+1][j+1]=(p*p+dp[i+1][j]*((ll)i+1+a)+dp[i][j+1]*((ll)j+1+b)-dp[i][j]*((ll)i+a)%p*((ll)j+b))%p;
    }
  }
  cout << dp[c-a][d-b] << endl;
}


Measured memory_bytes: 73928
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if(n==0) break;
			boolean[][] map = new boolean[n * 2 + 1][n * 2 + 1];
			int[][] pos = new int[n + 1][2];
			pos[0][0] = n;
			pos[0][1] = n;
			map[pos[0][0]][pos[0][1]] = true;
			for (int i = 1; i < n; i++) {
				int index = sc.nextInt();
				int dir = sc.nextInt();
				int[] dx = { -1, 0, 1, 0 };
				int[] dy = { 0, -1, 0, 1 };
				pos[i][0] = pos[index][0] + dx[dir];
				pos[i][1] = pos[index][1] + dy[dir];
				map[pos[i][0]][pos[i][1]] = true;
			}
			int mini = n * 2 + 1;
			int maxi = 0;
			int minj = n * 2 + 1;
			int maxj = 0;
			for (int i = 0; i < n * 2 + 1; i++) {
				for (int j = 0; j < n * 2 + 1; j++) {
					if (map[i][j]) {
						if (mini > i)
							mini = i;
						if (minj > j)
							minj = j;
						if (maxi < i)
							maxi = i;
						if (maxj < j)
							maxj = j;
					}
				}
			}
			System.out.println((maxi - mini+1) + " " + (maxj - minj+1));
		}
	}

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

Measured memory_bytes: 13000
#include <stdio.h>
 
int main()
{
    int cards[4][13]={0};
    int i, j, n, num;
    char mark[] = "SHCD", m;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf(" %c %d", &m, &num);
        if(m=='S')      cards[0][num-1]++;
        else if(m=='H') cards[1][num-1]++;
        else if(m=='C') cards[2][num-1]++;
        else if(m=='D') cards[3][num-1]++;
    }
 
    for(i=0; i<4; i++) {
        for(j=0; j<13; j++) {
            if(!cards[i][j]) printf("%c %d\n", mark[i], j+1);
        }
    }
    return 0;
}

Measured memory_bytes: 596
program Coin;
var
  h, n, i, x, y, k : longint;
begin
     readln(n);
     readln(k);
     x := 1;
     y := 1;
     for i := 1 to n do begin
       if (x*2 > x+k) then
          x := x+k
       else
           x := x*2
     end;
     writeln(x);
end.

Measured memory_bytes: 128
N = int(input())
job = [list(map(int, input().split())) for i in range(N)]

job.sort(key = lambda x: x[1])

time = 0
flag = 0
for i in range(N):
    time += job[i][0]
    if time > job[i][1]:
        flag = 1 
    
if flag == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 53600
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Segment_Tree{
	private:
	int n;
	vi date;
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vi(2*n-1);
	}
	void Update(int k,int x){
		k+=n-1;
		date[k]+=x;
		while(k>0){
			k=(k-1)/2;
			date[k]=date[k*2+1]+date[k*2+2];
		}
	}
	int Query(int a,int b){
		a+=n-1;b+=n-1;
		int m=0;
		while(a<b){
			if(a%2==0) m+=date[a++];
			if(b%2==0) m+=date[--b];
			a/=2;b/=2;
		}
		return m;
	}
	int Open(int k){return date[k+n-1];}
};

int n,q;
vi a,c;
vip b;

int main(){
	scanf("%d%d",&n,&q);
	a=vi(n);
	c=vi(q);
	b=vip(q);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<q;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		l--,r--;
		b[i]={{r,l},i};
	}
	sort(b.begin(),b.end());
	int I=0;
	Segment_Tree st(n);
	vi d(n,-1);
	for(int i=0;i<n;i++){
		int x=a[i]-1;
		if(d[x]>=0) st.Update(d[x],-1);
		d[x]=i;
		st.Update(i,1);
		while(I<q&&b[I].first.first==i){
			c[b[I].second]=st.Query(b[I].first.second,n);
			I++;
		}
	}
	for(auto i:c)printf("%d\n",i);
}

Measured memory_bytes: 19572
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,k,x,cnt=0;
    cin>>n>>m;
    int ara[m+1];
    memset(ara,0,sizeof ara);
    for(i=0;i<n;i++)
    {
        cin>>k;
        for(j=0;j<k;j++)
        {
            cin>>x;
            ara[x]++;
        }
    }
    for(i=0;i<=m;i++)
    {
        if(ara[i]==n)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3680
A['   '];
M;
B, X, Y;
W, J, I;
main() {
  scanf("%d%d", &I, &M);
  for (; ~scanf("%d%d", &X, &Y);) {
    for (B = Y + 1, J = 1; J * J <= M; J++)
      I = (X + J - 1) / J, W = Y / J + 1, A[I]++, A[W < B ? W : B]--, B = I;
    for (I = 1; I < B; I++)
      (X - 1) / I < Y / I ? A[I]++, A[I + 1]-- : 0;
  }
  for (I = 1; I <= M; I++)
    A[I] += A[I - 1],
        printf("%d\n", A[I]);
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
namespace csx_std {
	using namespace std;
	typedef long long ll;
	#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
	#define For(i,a,b) for (register int i=(a);i>=(b);i--)
	#define mem(i,j) memset(i,j,sizeof(i))
	#define pii pair<int,int>
	#define MP make_pair
	#define fi first
	#define se second
	#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
	const int N=1e5+5;
	const int mod=1e9+7;
	inline int qpow(int x,int y) {int ret=1;for (;y;y>>=1,x=1LL*x*x%mod) if (y&1) ret=1LL*ret*x%mod;return ret;}
	inline int Inv(int x) {return qpow(x,mod-2);}
	inline void upd(int &x,int y) {x=(1LL*x+y)%mod;return;}
	inline int chkmax(int &x,int y) {return (x<y)?(x=y,1):0;}
	inline int chkmin(int &x,int y) {return (x>y)?(x=y,1):0;}
	inline int read()
	{
		int x=0,f=1;
		char c=getchar();
		while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
		while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
		return f*x;
	}
	inline void write(int x)
	{
		if (x<0) x=-x,putchar('-');
		if (x>9) write(x/10);
		putchar(x%10+'0');
		return;
	}
}
using namespace csx_std;
int a,b;
int main()
{
	a=read(),b=read();
	if (a<10&&b<10) write(a*b);
	else write(-1);
	return 0;
}

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

using namespace std;

const int MOD = 998244353;

int main()
{
  int a, b, t;
  
  cin >> a >> b >> t;
  
  float tt = t + 0.5f;
  int ans = 0;
  while (tt >= a) {
    tt -= a;
    ans += b;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,i,j;
  char s[10],t[10];
  while(scanf("%s %s",s,t),s[1]){
    a=b=0;
    for(i=0;i<4;i++){
      if(s[i]==t[i])a++;
      for(j=0;j<4;j++){
	if(s[i]==t[j])b++;
      }
    }
    printf("%d %d\n",a,b-a);
  }
  return 0;
}



Measured memory_bytes: 2584
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, X: int, Y: int, x: "List[int]", y: "List[int]"):
    x = max(x + [X])
    y = min(y + [Y])
    if x < y:
        print("No War")
    else:
        print("War")
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    y = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, X, Y, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   1000000000
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}



//=============================================ASIFAZAD==============================================//

const int N = 200010;
//vi inp(N);
int n, k;

bool ok(ll mid, vi& inp)
{
    ll an = 0;
    for(int i = 0;i < n;i++)
        an += (inp[i] - 1)/mid;
    return an <= k;
}



int32_t main()
{
    io;
    //int n, k;
    cin>>n>>k;
    vi a(n);
    for(int i= 0;i < n;i++)
        cin >>a[i];

    ll l = 1, h = 1000000000, mid, ans;
    while(l <= h)
    {
        mid = (l + h)/2;
        /*ll s = 0;
        for(int i = 0; i< n;i++)
            s += (a[i] - 1)/mid;*/
        if(ok(mid,a))
        {
            ans = mid;
            h = mid - 1;
        }
        else
            l = mid + 1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3936
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;
typedef pair<int, int> P;

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

int main() {
    int n;
    cin >> n;
    int h[n];
    bool flag = true, only = true;
    rep(i, n) {
        cin >> h[i];
      	h[0]--;
        if (i > 1) {
            if (h[i] <= h[i - 1] && h[i - 1] > h[i - 2]) {
                h[i - 1]--;
            }
        }
    }
    rep(i, n) {
        if (i > 0) {
            if (h[i] < h[i - 1])
                flag = false;
        }
    }
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main(void){
    int n, l; cin >> n >> l;
    int sum = 0, ind = 1;
    for (int i = 1; i <= n; i++)
    {
        if(abs(l+i-1) < abs(l+ind-1)) ind = i;
        sum += l + i - 1;
    }
    cout << sum - (l+ind-1) << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
#define all(c) c.begin(),c.end()

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
const int inf=(int)1e9;
const double EPS=1e-9, INF=1e12;

const int dy[]={-1,0,1,0},dx[]={0,-1,0,1};
int p[1000*1000];
int root(int x){
	return x==p[x]?x:p[x]=root(p[x]);
}
void merge(int a,int b){
	a=root(a); b=root(b);
	if(a!=b)p[a]=b;
}
int h,w,g;
string in[1000];
int main(){
	cin>>w>>h;
	rep(i,h)cin>>in[i];
	rep(i,h*w){
		p[i]=i;
		if(in[i/w][i%w]=='t')g=i;
	}
	rep(i,h)rep(j,w)if(in[i][j]!='#'){
		rep(d,4){
			int y=i+dy[d],x=j+dx[d];
			if(0<=y&&y<h&&0<=x&&x<w&&in[y][x]!='#')
			merge(y*w+x,i*w+j);
		}
	}
	int n; cin>>n;
	if(root(g)==root(0)){
		cout<<0<<endl; return 0;
	}
	rep(i,n){
		int tx,ty; cin>>tx>>ty;
		in[ty][tx]='.';
		rep(d,4){
			int y=ty+dy[d],x=tx+dx[d];
			if(0<=y&&y<h&&0<=x&&x<w&&in[y][x]!='#')
			merge(y*w+x,ty*w+tx);
		}
		if(root(g)==root(0)){
			cout<<i+1<<endl; return 0;
		}
	}
	cout<<-1<<endl;
		
	return 0;
	
}

Measured memory_bytes: 5824
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		String str;
		
		if ((a==b || b==c || c==a) && !(a==b && b==c))
		{
			str = "Yes";
		} else {
			str = "No";
		}
		
		System.out.println(str);
	}
}

Measured memory_bytes: 22996