akhauriyash/Code-Regression huggingface dataset:
use std::io::stdin;

fn input_ints() -> Vec<i64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => {
            st.split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect()
        }
        Err(_) => panic!("err"),
    }
}

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
struct Item {
    v: i64,
    w: i64,
}

impl Item {
    fn new(w: i64, v: i64) -> Item {
        Item { w: w, v: v }
    }
}

fn main() {
    let l = input_ints();
    let n = l[0];
    let weight = l[1];
    let mut items = Vec::new();

    for _ in 0..n {
        let l = input_ints();
        items.push(Item::new(l[0], l[1]))
    }

    let min_weight = items[0].w;

    let mut items_selected_by_weight = Vec::new();

    for w in min_weight..min_weight + 4 {
        let mut is: Vec<Item> = items.iter().filter(|x| x.w == w).cloned().collect();
        is.sort();
        is.reverse();
        items_selected_by_weight.push(is);
    }

    let mut v_max = 0;
    for i in 0..items_selected_by_weight[0].len() + 1 {
        let w1 = i as i64 * min_weight;
        if w1 > weight {
            continue;
        }
        let v1: i64 = items_selected_by_weight[0][0..i]
            .iter()
            .cloned()
            .map(|x| x.v)
            .sum();
        for j in 0..items_selected_by_weight[1].len() + 1 {
            let w2 = j as i64 * (min_weight + 1);
            if w1 + w2 > weight {
                continue;
            }
            let v2: i64 = items_selected_by_weight[1][0..j]
                .iter()
                .cloned()
                .map(|x| x.v)
                .sum();
            for k in 0..items_selected_by_weight[2].len() + 1 {
                let w3 = k as i64 * (min_weight + 2);
                if w1 + w2 + w3 > weight {
                    continue;
                }
                let v3: i64 = items_selected_by_weight[2][0..k]
                    .iter()
                    .cloned()
                    .map(|x| x.v)
                    .sum();
                for l in 0..items_selected_by_weight[3].len() + 1 {
                    let w4 = l as i64 * (min_weight + 3);
                    if w1 + w2 + w3 + w4 > weight {
                        continue;
                    }
                    let v4: i64 = items_selected_by_weight[3][0..l]
                        .iter()
                        .cloned()
                        .map(|x| x.v)
                        .sum();

                    if v_max < v1 + v2 + v3 + v4 {
                        v_max = v1 + v2 + v3 + v4;
                    }
                }
            }
        }
    }
    println!("{}", v_max);
}


Measured memory_bytes: 4352
s = input()
while s != "":
    if len(s) >= 5 and s[-5:] == 'dream':
        s = s[:-5]
    elif len(s) >= 7 and s[-7:] == 'dreamer':
        s = s[:-7]
    elif len(s) >= 5 and s[-5:] == 'erase':
        s = s[:-5]
    elif len(s) >= 6 and s[-6:] == 'eraser':
        s = s[:-6]
    else: break
print('YES' if s == "" else 'NO')

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);

int main () {
  int n = in();
  vi p(n);
  rep(i,n) cin >> p[i];
  
  vi q = p;
  sort(q.begin(), q.end());

  int cnt = 0;
  rep(i,n) {
    if (p[i] != q[i]) cnt++;
  }

  if (cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

#include<string>

using namespace std;

int main(){
    string s,result;
    getline(cin,s);
    if(s == "Sunny") {result = "Cloudy";
    cout<<result;}
    else if(s == "Cloudy") {result = "Rainy";
    cout<<result;}
    else if(s == "Rainy") {result = "Sunny";
    cout<<result;}
    return 0;
}

Measured memory_bytes: 256
from collections import deque
def dfs(neigh,K):
    q = deque([K])
    d = [0]*N
    visited = [0]*N
    visited[K] = True
    while q:
        p = q.pop()
        for di,cost in neigh[p]:
            if visited[di]:
                continue
            d[di] = d[p]+cost
            visited[di] = True
            q.append(di)
    return d

N = int(input())
neigh = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    neigh[a-1].append((b-1,c))
    neigh[b-1].append((a-1,c))

Q,K = map(int,input().split())
d = dfs(neigh,K-1)
for i in range(Q):
    x,y = map(int,input().split())
    print(d[x-1]+d[y-1])


Measured memory_bytes: 85596
/*よくばりセット2019/07/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x>y?y:x;}
ll llmax(ll x,ll y){return x>y?x:y;}
ll llmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}

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

    int x=2*d+1;
    int ans;
    ans=n/x;
    if(n%x)ans++;
    
    printf("%d\n",ans);
    return 0;


}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
	"sort"
)

var a []int
var N int

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func main() {
	fmt.Scan(&N)
	tmp := 0
	a = make([]int, N)
	total := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&tmp)
		a[i] = tmp
		total += tmp
	}
	sort.Ints(a)
	fmt.Println(a[N-1] - a[0])

}


Measured memory_bytes: 512
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int h, n; cin >> h >> n;
	rep(i, n)
	{
		int a; cin >> a;
		h -= a;
	}
	if (h <= 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef vector<pii> vp;
typedef pair<int,pii> piii;

int OO = 2e9;
const double eps = 1e-9 ;
const int N = 200005;
int mx = -1e9 , mn = 1e9 ;
double arr[N] , arr2[N];
double dd[N];

int main()
{

    ll n , m , c , ans = 0 ,x , sum = 0;
    cin >> n >> m >> c;
    lp(i,m)
        cin >> arr[i];
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < m ; ++j){
            cin >> x;
            sum += (x*arr[j]);
        }
        if(sum+c > 0)
            ++ans;
        sum = 0;
    }
    cout << ans << endl;




    return 0;
}


Measured memory_bytes: 2304
N, K = map(int, input().split())
MOD = 10**9 + 7

if N < K:
    print(0)
else:
    ans = 0
    v = 1
    for i in range(K):
        if i % 2:
            ans -= pow(K-i, N, MOD) * v
        else:
            ans += pow(K-i, N, MOD) * v
        v = v * (K-i) * pow(i+1, MOD-2, MOD) % MOD
    print(ans % MOD)



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

#define ll long long
#define met(a, x) memset(a,x,sizeof(a))
#define inf 0x3f3f3f3f
#define ull unsigned long long
#define mp make_pair

using namespace std;
const int mod = 998244353;
const int N = 3e5 + 10;
const int M = 1e6 + 10;
ll fac[N], inv[N];

ll ksm(ll a, ll b) {
    ll ans = 1;
    while (b) {
        if (b % 2)
            ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
void init() {
    int i;
    fac[0] = 1;
    for (i = 1; i < N; i++) {
        fac[i] = (fac[i - 1] * i) % mod;
    }
    inv[N - 1] = ksm(fac[N - 1], mod - 2);
    for (i = N - 2; i >= 0; i--) {
        inv[i] = inv[i + 1] * (i + 1) % mod;
    }
}
long long C(ll n,ll m) {
    if (n < m) return 0;
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    init();
    for (ll i = 0; i <= n; i++) {
        if (a * i > k) {
            break;
        }
        if ((k - a * i) % b) {
            continue;
        }
        ll cnt = (k - a * i) / b;
        if (cnt > n) {
            continue;
        }
        ans = (ans + C(n, i) % mod * C(n, cnt) % mod + mod) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();

        int ansA = 0;
        int ansB = 0;

            outside: for(int a = -118;a <= 119;a++){
                for(int b = -119;b <= 118;b++){
                    if(fifthExponentiation(a) - fifthExponentiation(b) == x){
                        ansA = a;
                        ansB = b;
                        break outside;
                    }
                }
        }

        System.out.println(ansA + " " + ansB);
    }

    static int fifthExponentiation(int num){
        int answer = 1;
        for(int i = 1; i <= 5; i++){
            answer *= num;
        }
        return answer;
    }
}


Measured memory_bytes: 38628
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
int lcm(int a,int b){return a%b==0?(b):lcm(b,a%b);}//a>b
//=lcm(max(,),min(,));
int i,j,k,l;
static const int MAX_N=10e5;
long cc,dd,cd,cd_lcm;
int main(void){
	long a,b,c,d;
		cin >> a >> b >> c >> d;
	
	cc=b/c-(a-1)/c;
	dd=b/d-(a-1)/d;
	cd_lcm=lcm(max(c,d),min(c,d));
	cd_lcm=c*d/cd_lcm;
	cd=b/cd_lcm-(a-1)/cd_lcm;
	puts(b-a+1-(cc+dd-cd));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[200010], b[200010], u[200010], v[200010];
map<P, int> mp;
map<P, bool> bl;
int cnt1, cnt2, cnt3, cnt4, cnt5;
int beki[200010];
int ans = 1;

signed main() {
	cin >> n;
	beki[0] = 1;
	for (int i = 1; i <= n; i++)beki[i] = beki[i - 1] * 2 % mod;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (a[i] == 0 && b[i] == 0)cnt5++;
		else if (a[i] == 0) {
			if (b[i] < 0)cnt2++;
			else cnt1++;
		}
		else if (b[i] == 0) {
			if (a[i] < 0)cnt4++;
			else cnt3++;
		}
		else {
			int x = abs(a[i]), y = abs(b[i]);
			int p = gcd(x, y);
			int s = x / p, t = y / p;
			if (a[i] < 0 && b[i] < 0)s = -s, t = -t;
			else if (a[i] < 0)s = -s;
			else if (b[i] < 0)t = -t;
			u[i] = s, v[i] = t;
			mp[make_pair(s, t)]++;
		}
	}
	for (int i = 0; i < n; i++) {
		if (bl[make_pair(u[i], v[i])])continue;
		bl[make_pair(u[i], v[i])] = true;
		bl[make_pair(-u[i], -v[i])] = true;
		bl[make_pair(v[i], -u[i])] = true;
		bl[make_pair(-v[i], u[i])] = true;
		int cnt = 0;
		int p1 = mp[make_pair(u[i], v[i])], p2 = mp[make_pair(-u[i], -v[i])], q1 = mp[make_pair(v[i], -u[i])], q2 = mp[make_pair(-v[i], u[i])];
		cnt += beki[q1 + q2];
		cnt += beki[p1 + p2] - 1;
		cnt %= mod;
		ans = ans * cnt%mod;
	}
	int cnt = 0;
	cnt += beki[cnt1 + cnt2];
	cnt += beki[cnt3 + cnt4] - 1;
	cnt %= mod;
	ans = ans * cnt%mod;
	ans--;
	ans += cnt5;
	cout << (ans + mod) % mod << endl;
}

Measured memory_bytes: 111384
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);

	if (a < b) printf("a < b\n");
	if (a > b) printf("a > b\n");
	if (a == b) printf("a == b\n");
	return (0);
}

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

LL n,h,w,x,y,ans[10];
LL dx[9]={1,1,1,0,0,-1,-1,-1,0},dy[9]={-1,0,1,-1,1,-1,0,1,0};
map<pair<int,int>,int>Map;

int main()
{
	cin>>h>>w>>n;
	ans[0]=(h-2)*(w-2);
	for (int i=1; i<=n; ++i)
	{
		cin>>x>>y;
		for (int i=0; i<9; ++i)
		{
			LL X=x+dx[i],Y=y+dy[i];
			if (X<2 || X>h-1 || Y<2 || Y>w-1) continue;
			LL num=Map[make_pair(X,Y)]++;
			ans[num]--; ans[num+1]++;
		}
	}
	for (int i=0; i<=9; ++i) cout<<ans[i]<<endl;
}

Measured memory_bytes: 56448
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#define ll long long
#define max(x,y) (x)>(y)?(x):(y)
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1<<28;
const int maxn=100010;
const int maxm=1e2+10;
const int mod=1e9+7;

int main()
{
    //freopen("in.txt","r",stdin);
    ll n;
    while(~scanf("%lld",&n))
    {
        ll ans=1;
        for(ll i=1;i<=n;i++)
            ans=(ans*i)%mod;
        printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(true){
        a -= d;
        c -= b;
        if(c <= 0){
            out("Yes");
            return 0;
        }
        if(a <= 0) {
            out("No");
            return 0;
        }

    }
}

Measured memory_bytes: 3632
#define ll long long
#define pb push_back
#include<bits/stdc++.h>
using namespace std;
const int N = 200000;
int arr[N];
double dp[600][600];
vector<int> v;
int n, x, m;
void solve(){
	cin >> n >> m;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= m; j++) dp[i][j] = 0.0;
	}
	double pre[n + 1];
	for(int i = 0; i <= n; i++) pre[i] = 0.0;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
		pre[i + 1] = pre[i] + 1.0 * arr[i];
	}
	for(int i = 1; i <= n; i++){
		dp[i][1] = (pre[i] - pre[0]) / i;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 2; j <= m; j++){
			if(j > i) continue;
			dp[i][j] = dp[i][j - 1];
			for(int k = 1; k <= i; k++){
				double sss = 1.0 * (pre[i] - pre[k - 1]) / (1.0 * i - k + 1.0);
				if(k - 1 < j - 1 ) continue;
				double val = sss + dp[k - 1][j - 1];
				if(dp[i][j] <= val) dp[i][j] = val;
			//	cout << i << " -> " << j << " " << k << " " << val << endl;
			}
		}
	}
	printf("%.6lf\n", dp[n][m]);
}
//001095004368
int main(void){
	solve();
	return 0;
}


Measured memory_bytes: 5584
#include<iostream>
#include<vector>

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

using namespace std;

int main(){
    int N ;
    cin>>N;
    vector <long long>T(N);
    for(int i=0 ; i<N ; i++){
        cin>>T[i];
    }
    
    long long a=1;
    for(int i=0 ; i<N ; i++){
        a=a/gcd(a,T[i])*T[i];
    }
    cout<<a<<endl;
    return 0;
}


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

    int main()
    {
       long long int a,b,c,d;
        while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d))
        {
            if(a>=b)
            {
                if(c>=d)
                    printf("%lld\n",b+d);
                else printf("%lld\n",b+c);
            }

            else
            {
                if(c>=d)
                    printf("%lld\n",a+d);
                else printf("%lld\n",a+c);
            }
        }return 0;}



Measured memory_bytes: 128
N = int(input())
P = [list(map(int,input().split())) for _ in range(2)]
ans = sum(P[0]) + P[1][N-1]
p = ans

for i in range(N-1, 0, -1):
    p = p - P[0][i] + P[1][i-1]
    ans = max(p, ans)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const double INF = 1e10;
const double EPS = 1e-10;
typedef long double Double;

int main() {
  int n;
  cin>>n;
  while(n--) {
    Double a,b,c,d;
    cin>>a>>b>>c>>d;
    Double high=INF;
    Double low=-INF;
    b /= a; c /= a; d /= a; a = 1;
    
    REP(i,100) {
      Double mid = (high+low)/2;
      // printf("%0.10Lf %0.10Lf\n",low, high);
      // printf("%0.10Lf\n",a*mid*mid*mid+b*mid*mid+c*mid+d);
      Double now = mid*mid*mid+b*mid*mid+c*mid+d;
      if (now > 0)
        high = mid;
      else
        low = mid;
    }
    Double p = low;
    Double e = b+p;
    Double f = c+e*p;
//    printf("%0.10llf\n",x);
//    cout << e << " " << f << " " << g << endl;
    Double D = e*e-f*4;
//    cout << D << endl;

    Double ans[3];
    REP(i,3) ans[i] = 0;
    ans[0] = p;
    //cout << e << " " << f << " " << D << endl;
    if (D >= -EPS) {
      if (D<0) D=0;
      ans[1] = (-e+sqrt(D)) / 2;
      ans[2] = (-e-sqrt(D)) / 2;
    }
    int ans1=0,ans2=0;
    REP(i,3) {
      if (ans[i] > EPS) ans1++;
      else if (ans[i] < -EPS) ans2++;
      //cout << ans[i] << " ";
    }
    //cout << endl;
    cout << ans1 << " " << ans2 << endl;
    
  }
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    vector<int> lis(5);
    REP(i, 0, 5){cin >> lis[i];}
    int k; cin >> k;
    REP(i, 0, 4){
        REP(l, i+1, 5){
            if(lis[l] - lis[i] > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
}

Measured memory_bytes: 3524
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    string s;
    cin >> s;
    
    int w;
    cin >> w;

    for (int i = 0; i < s.length(); i+=w)
    {
        putchar(s[i]);
    }

    putchar('\n');
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,c;
    cin>>n>>m>>c;
    Vec b(m);
    rep(i,m){
        cin>>b[i];
    }
    ll ans=0;

    rep(i,n){
        ll tmp = 0;
        ll a = 0;
        rep(j,m){
            cin>>a;
            tmp+= a*b[j];
        }
        tmp+=c;
        if(tmp>0){
            ans++;
        }
    }

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


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;





int main() {

	int n, k;
	cin >> n >> k;
	int ans = 0;

	while (n > 0) {
		n /= k;
		ans++;
	}
	cout << ans << endl;

}




Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
int dp[3010][3010];
int main() {
    string s,t;
    cin >> s >> t;
    int sl = s.size();
    int tl = t.size();
    
    for(int i = 1; i <= sl; i++){
        for(int j = 1; j <= tl; j++){
            if(s.at(i-1) == t.at(j-1)){
                dp[i][j] = dp[i-1][j-1] + 1;
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    
    
    string ans;
    
    while(sl > 0 && tl > 0){
        if(dp[sl][tl] == dp[sl-1][tl]){
            sl--;
            continue;
        }
        if(dp[sl][tl] == dp[sl][tl-1]){
            tl--;
            continue;
        }
        ans += s.at(sl-1);
        sl--;
        tl--;
        
    }
    for(int i = ans.size()-1; i >= 0; i--){
        cout << ans.at(i);
    }
    cout << endl;
    
    
}

Measured memory_bytes: 35584
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  bool rev = 0;
  vector<char> a, b;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      rev ^= 1;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (rev == 0) {
          a.push_back(c);
        } else {
          b.push_back(c);
        }
      } else {
        if (rev == 0) {
          b.push_back(c);
        } else {
          a.push_back(c);
        }
      }
    }
  }
  if (rev == 0) {
    for (int i = a.size() - 1; i >= 0; --i) {
      cout << a[i];
    }
    cout << s;
    for (int i = 0; i < b.size(); ++i) {
      cout << b[i];
    }
    cout << endl;
  } else {
    reverse(s.begin(), s.end());
    for (int i = b.size() - 1; i >= 0; --i) {
      cout << b[i];
    }
    cout << s;
    for (int i = 0; i < a.size(); ++i) {
      cout << a[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    vi a(N), b(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];

    int psum=0, msum=0;
    rep(i, N) {
        int t = b[i]-a[i];
        if(t>0) psum += t/2;
        else if(t<0) msum += t*(-1);
    }   
    if(psum < msum) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

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

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

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

    map<string, int> m;
    int maximum = 0;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        m[S]++;
        chmax(maximum, m[S]);
    }

    vector<string> xs; 
    for (auto &p : m) {
        if (p.second == maximum) {
            xs.push_back(p.first);
        }
    }
    sort(xs.begin(), xs.end());

    for (auto &x : xs) {
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 26868
#include<stdio.h>


int main(void) {
    int n;
    double t,a;
    scanf("%d",&n);
    scanf("%lf%lf",&t,&a);

    double min = 1e30;
    int ans = -1;
    for (int i = 0; i < n; i++) {
        int h;
        scanf("%d", &h);
        double tp = a - (t - 0.006 * h);
        if (tp < 0 ) tp = -tp;
        if (min > tp) {
            min = tp;
            ans = i+1;
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int K;
    vector<int> A(3);
    rep(i, 3) cin >> A[i];

    cin >> K;

    sort(all(A));
    int ans = A[0] + A[1];

    rep(i, K) {
        A[2] *= 2;
    }

    cout << ans + A[2] << endl;
    return 0;
}

Measured memory_bytes: 3552
#pragma warning(disable:4996)
#include "bits/stdc++.h"
using namespace std;

//macro
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,a,b) for(int i=(int)(b) - 1;i>=(int)(a);i--)
#define rrep(i,n) RREP(i,0,n)
#define each(i, ctn) for (auto &&i : (ctn))
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define INF 114514810
#define INFL 1145148100000000000LL
#define EPS (1e-8)
#define MOD 1000000007
#define PI 3.141592653589793
#define equals(a,b)(fabs((a)-(b))<EPS)

//alias
using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vl = vector<ll>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<ll, ll>;
template<class T> using heap = priority_queue<T>;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;

//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H);	rep(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n)os << v[i] << (i == n - 1 ? "\n" : " "); return os; }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template<class T> inline void print(const T &x) { cout << x << '\n'; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;



int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int ans = 1;
	for (; ans < 1000000; ++ans) {
		int W = Z * (ans + 1) + Y * ans;
		if (W > X)break;
	}
	print(ans-1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,d,x,a;
    while(cin>>n>>d>>x){
        int sum=0,j=1;
        for(int i=1;i<=n;i++){
            cin>>a;
            sum++;
            j=1;
            while(j*a+1<=d){
                sum++;
                j++;
            }
        }
        sum+=x;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

ll product(int n)
{
    ll mul = 1;

    while(n)
    {
        mul *= n%10;
        if(n%10 == 1 || n%10 == 0) return 0;
        n = n/10;
    }

    return mul;
}


int main()
{
    fast

    ll a,b;
    cin>>a>>b;

    int count = 0;

    for(int i = 22;  i <= b; i++)
    {
        int mul = product(i);
        if(mul && mul <= a)
        {
            count++;
        }
    }

    cout<<count;
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = LIST()
A.sort()
a = A[0] + A[3]
b = A[2] + A[1]
# print(A)
print(abs(a - b))


Measured memory_bytes: 7104
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
 
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
 
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))
 
// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
 
// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;
 
int n,m;
vi g[125252];
int indeg[125252];
int len[125252], bef[125252];
 
int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    int x,y;
    scanf("%d%d",&x,&y);
    --x; --y;
    g[x].push_back(y);
    indeg[y]++;
  }
  fill(bef,bef+n,-1);
  stack<int> S;
  REP(i,n)if(indeg[i]==0)S.push(i);
  while(S.size()){
    int p = S.top(); S.pop();
    for(int to=0;to<g[p].size();to++){
      if(len[p]+1 > len[g[p][to]]){
        len[g[p][to]] = len[p]+1;
        bef[g[p][to]] = p;
      }
      indeg[g[p][to]]--;
      if(indeg[g[p][to]]==0)S.push(g[p][to]);
    }
  }
  printf("%d\n",*max_element(len,len+n));
  return 0;
}

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

using namespace std;
#define eps = (1e-10);
//点
struct Point{
    double x,y;
    Point(double _x=0,double _y=0):x(_x),y(_y){}
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double a){return Point(a*x,a*y);}
    Point operator / (double a){return Point(x/a,y/a);}
    double norm(){return x*x+y*y;}//模的平方
    double ABS() {return sqrt(norm());}//模
};
//线段
struct Segment{
    Point p1,p2;
};
double dot(Point a,Point b){
    return a.x*b.x+a.y*b.y;
}
double cross(Point a,Point b){
    return a.x*b.y-a.y*b.x;
}
vector<Point> polygon;
double Area(vector<Point> polygon){
    double ans=0;
    int n=(int)polygon.size();
    for(int i=0;i<n;i++){
        ans+=cross(polygon[i],polygon[(i+1)%n]);
    }
    return fabs(ans/2);
}
int main(){
    int n;
    scanf("%d",&n);
    double x,y;
    for(int i=0;i<n;i++){
        scanf("%lf %lf",&x,&y);
        polygon.push_back({x,y});
    }
    double ans=Area(polygon);
    printf("%.1lf\n",ans);
    return 0;
}


Measured memory_bytes: 3212
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b;
	cin >> n >> a >> b;
	int sum = 0;
	reps(i,n){
		int cnt = 0;
		int x = i;
		while(x > 0){
			cnt += x % 10;
			x /= 10;
		}
		if(a <= cnt && cnt <= b) sum += i;
	}
	cout << sum << '\n';
	return 0;
}


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

using i64 = int64_t;

using Graph = vector<vector<pair<int, int>>>;

i64 get_path(int prev, int u, int v, const Graph &tree){
    for(auto e: tree[u]){
        if(e.first == prev)continue;
        if(e.first == v)return ((i64)1<<e.second);
        else{
            i64 res = get_path(u, e.first, v, tree);
            if(res > 0)return res | ((i64)1<<e.second);
        }
    }
    return 0;
}

i64 pop_count(i64 n){
    i64 res = 0;
    while(n > 0){
        res += n & 1;
        n >>= 1;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> edges;
    Graph tree(n+1, vector<pair<int, int>>());
    for(int i=0;i<n-1;++i){
        int a, b;
        cin >> a >> b;
        edges.emplace_back(a, b);
        tree[a].emplace_back(b, i);
        tree[b].emplace_back(a, i);
    }

    int m;
    cin >> m;
    vector<pair<int, int>> constraints;
    for(int i=0;i<m;++i){
        int u, v;
        cin >> u >> v;
        constraints.emplace_back(u, v);
    }

    i64 num = 0;
    for(int i=1;i<(1<<m);++i){
        i64 es = 0;
        for(i64 j=0;j<m;++j){
            if(i&((i64)1<<j))es |= get_path(0, constraints[j].first, constraints[j].second, tree);
        }
        i64 pops = pop_count(es), bits = pop_count(i);
        num += (bits%2 ? 1 : -1) * ((i64)1<<(n-1-pops));
    }

    cout << ((i64)1<<(n-1)) - num << endl;

    return 0;
}

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

#ifdef ONLINE_JUDGE
#define lld I64
#endif

#define endl '\n'
#define ii pair<int,int>
#define ll long long
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define add push_back

int main(){ios_base::sync_with_stdio(false);

    int n, m, x, y;
    cin >> n >> m;
    vvi adj(n+1);
    vi a(n+1);
    
    for(int i=1; i<=n; ++i) cin >> a[i];
    while(m--){
        cin >> x >> y;
        adj[x].add(y);
        adj[y].add(x);
    }

    int ans = 0;
    for(int i=1; i<=n; ++i){
        int mx=-1;
        for(int v: adj[i]){
            mx = max(mx,a[v]);
        }
        ans += (a[i]>mx);
    }

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


Measured memory_bytes: 8776
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int[] x = new int[2];
		
		for(int i = 0; i < 2; i++)
			for(int j = 0; j < 4; j++)
				x[i] += sc.nextInt();
		
		System.out.println(Math.max(x[0], x[1]));
		
		sc.close();
	}
}

Measured memory_bytes: 17232
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

long gcd(long a, long b) {
    if(a > b) {
        swap(a, b);
    }
    if(b%a == 0) {
        return a;
    }
    return gcd(b%a, a);
}

bool test(long[] a, long k, long GCD) {
    if(reduce!max(0L, a) < k) {
        return false;
    }
    if(a.any!(x => x == k)) {
        return true;
    }
    if(a.length > 2 && GCD == 1) {
        return true;
    }
    return false;
}

void main(){
    long n, k;
    readlnTo(n, k);
    auto a = readLongs();
    a.sort();
    a = a.uniq().array();
    auto GCD = reduce!gcd(a[0], a);
    auto kGCD = gcd(k, GCD);
    k /= kGCD;
    a[] /= kGCD;
    GCD /= kGCD;
    writeln(test(a, k, GCD) ? "POSSIBLE": "IMPOSSIBLE");
}



Measured memory_bytes: 6964
import java.util.*;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        Map<Integer, Integer> map = new HashMap<>();
        
        for(int i = 1; i <= K; i++) {
            int d = Integer.parseInt(sc.next());
            for(int j = 1; j <= d; j++) {
                int a = Integer.parseInt(sc.next());
                if(map.containsKey(a)) {
                    continue;
                }else {
                    map.put(a, 1);
                }
            }
        }
        
        int count = 0;
        for(int i = 1; i <= N; i++) {
            if(map.containsKey(i)) {
                continue;
            }else {
                count++;
            }
        }
            
        System.out.println(count);
    }
}

Measured memory_bytes: 41376
n,k = map(int,input(). split())
allist = []
for i in range(k):
  d = input()
  a = input().split(" ")
  linta = [int(n) for n in a]
  allist.extend(linta)
alist = set(allist)
kotae = n-len(alist)
print(kotae)


Measured memory_bytes: 9180
class NormalInput {
  input: string[];
  pointer: number;
  constructor(raw: string) {
    this.input = raw.split(/ |\n/);
    this.pointer = 0;
  }
  int = (): number => {
    const ret = parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  };
  str = (): string => {
    const ret = this.input[this.pointer];
    this.pointer++;
    return ret;
  };
  strs = (length: number): string[] => {
    let ret: string[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.str());
    }
    return ret;
  };
  ints = (length: number): number[] => {
    let ret: number[] = [];
    for (let i = 0; i < length; i++) {
      ret.push(this.int());
    }
    return ret;
  };
}
function rep(a: number, b: number) {
  let arr = [];
  for (let i = a; i < b; i++) arr.push(i);
  return arr;
}
function Main({ int, str, strs, ints }: NormalInput) {
  const N = int();
  const S = str();
  const total = Array.from(S).reduce(
    ([r, g, b], c) => [
      r + (c === "R" ? 1 : 0),
      g + (c === "G" ? 1 : 0),
      b + (c === "B" ? 1 : 0),
    ],
    [0, 0, 0]
  );

  const first = total[0] * total[1] * total[2];
  let second = 0;
  rep(0, N).forEach((i) =>
    rep(i + 2, N).forEach((k) => {
      if ((i + k) % 2 == 0) {
        const j = (i + k) / 2;
        if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) {
          second += 1;
        }
      }
    })
  );
  console.log(first - second);
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 35432
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0, i##_len=(n); i<i##_len; ++i)



void solve(long long N, std::vector<long long> a){
  vector<long long> vec;
  long long legend = 0;
  REP(i, N) {
    if(a[i] >= 3200) legend++;
  }

  for(int i = 1; i <= 8; i++){
    long long count = 0;
    REP(j, N) {
      if(((i-1)*400) <= a[j] && a[j] < (i*400)) {
        count++;
        break;
      }
    }

    if(count != 0) vec.push_back(count);
  }

  long long ans1 = vec.size();
  long long ans = vec.size() + legend;
  cout << max(1ll, ans1) << " " << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
  }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <sstream>
#include <cstring>
#include <set>
#include <cctype>
#include <bitset>
#define IO                       \
    ios::sync_with_stdio(false); \
    // cin.tie(0);                  \
    // cout.tie(0);
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn = 1e6 + 100;
const int maxm = 1e6 + 10;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
// int dis[8][2] = {0, 1, 1, 0, 0, -1, -1, 0, 1, -1, 1, 1, -1, 1, -1, -1};
struct Node
{
    int x, y;
} a[109];
int main()
{
#ifdef ONLINE_JUDGE
#else
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    IO;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].x >> a[i].y;
    }
    int f = false;
    for (int i = 3; i <= n; i++)
    {
        if (a[i].x == a[i].y && a[i - 1].x == a[i - 1].y && a[i - 2].x == a[i - 2].y)
            f = true;
        if (f)
            break;
    }
    if (f)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

int Partition(int*,char*,int*,int,int);
void QuickSort(int*,char*,int*,int,int);
int isStable(int*,int*);

int n;

int main(){

  int A[100001],O[100001],i,r;
  char C[100001];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c",&C[i]);
    scanf("%d",&A[i]);
    O[i]=i;
    
  }

  QuickSort(A,C,O,0,n-1);
  
   if(isStable(A,O)!=0) printf("Stable\n");
  else printf("Not stable\n");
 

  for(i=0;i<n;i++)
    printf("%c %d\n",C[i],A[i]);

  
  return 0;
}

int Partition(int* A,char* C,int* O,int p,int r){

  int x,i,j,tmp,k;
  char c;
 
   x=A[r];
   i=p-1;

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      tmp=A[i];
      c=C[i];
      A[i]=A[j];
      C[i]=C[j];
      A[j]=tmp;
      C[j]=c;

      tmp=O[i];
      O[i]=O[j];
      O[j]=tmp;

    }
   
  }
    tmp=A[i+1];
    c=C[i+1];
    A[i+1]=A[r];
    C[i+1]=C[r];
    A[r]=tmp;
    C[r]=c;

    tmp=O[i+1];
    O[i+1]=O[r];
    O[r]=tmp;
  
    return i+1;
}

void QuickSort(int* A,char* C,int* O,int p,int r){

  int q;
  
  if(p<r){
    q=Partition(A,C,O,p,r);
    QuickSort(A,C,O,p,q-1);
    QuickSort(A,C,O,q+1,r);
  }
}

int isStable(int* A,int* O){

 int i;

 for(i=0;i<n;i++){
   if((A[i]==A[i+1])&&(O[i]>O[i+1])) return 0;
 }

  return 1;
}

Measured memory_bytes: 1484