akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define SQ(x) (x)*(x)
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll mpow(ll a, ll n){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mod;
        a = a*a %mod;
        n>>=1;
    }
    return re;
}

ll inv (ll b){
    if (b==1) return b;
    return (mod-mod/b) * inv(mod%b) % mod;
}

const int maxn = 2e5+5;

int n; 
int f(int x){
    x += n;
    while (x>=n) x-=n;
    return x;
}

bool ok[maxn];

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

    cin>>n;
    vector<int> a(n), b(n);
    REP(i,n){
        cin>>a[i];
    }
    REP(i,n) cin>>b[i], ok[i] = b[i] == a[i];
    ll re = 0;
    priority_queue<pii> pq;
    REP(i,n){
        pq.push({b[i], i});
    }
    while (!pq.empty()){
        int i = pq.top().s; pq.pop();
        if (a[i] == b[i]) continue;
        // cout<<"CHG "<<i<<'\n';
        ll s = b[f(i-1)]+b[f(i+1)];
        // cout<<s<<' ';
        ll tk = (b[i] - a[i]) / s;
        if (tk==0) GG();
        re += tk;
        b[i] -= tk * s;
        if (b[i] == a[i]) continue;
        pq.push({b[i], i});
    }
    REP(i,n){
        if (b[i] != a[i]) GG();
    }
    cout<<re<<'\n';

    
} 

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
ll siz(ll n)
{
    ll now = 0;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            now++;
            if (i != n / i)
            {
                now++;
            }
        }
    }
    return now;
}
vector<ll> div(ll n)
{
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            res.push_back(i);
            if (i != n / i)
            {
                res.push_back(n / i);
            }
        }
    }
    return res;
}
int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    ans += siz(n - 1) - 1;
    vector<ll> a = div(n);
    rep2(i, 1, a.size())
    {
        ll m = n;
        while (m % a[i] == 0)
        {
            m /= a[i];
        }
        if (m % a[i] == 1)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(void) {
  char s;
  cin >> s;
  if(s == 'a' || s == 'e' || s == 'i' || s == 'o'||s=='u') {
    cout << "vowel" << endl;
  }else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3592
#include<stdio.h> 
long long GCD(long long int A,long long B) {
	if(B%A==0) 
		return A;
	else 
	{ 
		long long Temp=A; 
		A=B%A; 
		B=Temp; 
		return GCD(A,B); 
	} 
} 
int main() { 
	long long a,b; 
	long long n1,n2; 
	while(scanf("%lld%lld",&a,&b)!=EOF) { 
		if(a<b) 
			n1=GCD(a,b); 
		else 
			n1=GCD(b,a); 
		
		n2=a*b/n1; 
		
		printf("%lld %lld\n",n1,n2); 
	} 
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
a = 0
b = 0
for i in range(1,n+1):
    if i%k==0:
        a += 1
    elif k%2==0 and i%k==k//2:
        b += 1
if k%2==0:
    print(a**3+b**3)
else:
    print(a**3)


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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N, K;
  cin >> N >> K;

  if(K==1){
    cout << 0 << endl;
  }else{
    cout << N-K << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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

  unsigned long long  N,A,B;
  cin>>N>>A>>B;
  
  if((B-A)%2==0){
    cout<<(B-A)/2<<endl;

  }else{
   cout<< min(A-1,N-B)+1+(B-A-1)/2<<endl;

  }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  cin >> s;
  ll ans=0;
  rep(t,1<<(s.size()-1)) {
    ll x=0;
    rep(i,s.size()) {
      x*=10;
      x+=s[i]-'0';
      if(t&(1<<i)) {
        ans+=x;
        x=0;
      }
    }
    ans+=x;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    static final int MOD = 2019;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long L = sc.nextInt();
        long R = sc.nextInt();

        R = Math.min(R, L + 4038);
        long ans = 2018;

        for (long i = L; i <= R; i++) {
            for (long j = i + 1; j <= R; j++) {
                long x = i * j % 2019;
                ans = Math.min(ans, x);
            }
        }

        System.out.println(ans);

    }

}


Measured memory_bytes: 22228
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) REP(i,0,b)
#define maxn 100

string f(string a, string b){
	int s=a.length();
	rep(i,s){
		if(a[i]>b[i])return "GREATER";
		else if(a[i]<b[i])return "LESS";
	}
	return "EQUAL";
}

int main(){
	string a,b,c;
	while(cin>>a>>b){
		int na,nb;
		na=a.length();
		nb=b.length();
		if(na>nb)puts("GREATER");
		else if(na<nb)puts("LESS");
		else{
			cout<<f(a,b)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    table = [0] * (2*10**5+5)
    for i in range(len(a)):
        table[a[i]-1] += 1

    for i in range(n):
        print(table[i])


main()


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

int main()
{
	int N,M,C;
	int ret = 0,sum;

	cin >>	N >> M >> C;

	int *B = new int[M],*A = new int[M];
	for(int i = 0;i < M;++i)cin >> B[i];

	for(int i = 0;i < N;++i)
	{
		sum = 0;
		for(int j = 0;j < M;++j)
		{
			cin >>A[j];
			sum += A[j] * B[j];	
		}
		sum += C;

		ret += sum > 0;
	}

	cout << ret << endl;

	delete[] B,A;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

signed main(){
  int n,q;
  cin>>n>>q;
  vector<int> s(n),t(n),x(n),d(q);
  rep(i,n)cin>>s[i]>>t[i]>>x[i];
  rep(i,q)cin>>d[i];
  int INF=1111111111LL;
  d.pb(INF);
  vector<vector<int> > inn(q+1),ott(q+1);
  rep(i,n){
    int ok=q+1,ng=-1,mid;
    while(ok-ng>1){
	 mid=(ok+ng)/2;
	 if(d[mid]>=s[i]-x[i])ok=mid;
	 else ng=mid;
    }
    inn[ok].pb(x[i]);
    ok=q+1,ng=-1;
    while(ok-ng>1){
	 mid=(ok+ng)/2;
	 if(d[mid]>=t[i]-x[i])ok=mid;
	 else ng=mid;
    }
    ott[ok].pb(x[i]);
  }
  priority_queue<int,vector<int>,greater<int> > que;
  map<int,int> mp;
  rep(i,q){
    rep(j,sz(ott[i])){
	    // cout<<"ot "<<i<<" "<<ott[i][j]<<endl;
	 mp[ott[i][j]]--;
    }
    rep(j,sz(inn[i])){
	 //	 cout<<"in "<<i<<" "<<inn[i][j]<<endl;
	 que.push(inn[i][j]);
	 mp[inn[i][j]]++;
    }
    while(que.size()){
	 if(mp[que.top()])break;
	 que.pop();
    }
    if(que.size()==0)cout<<-1<<endl;
    else cout<<que.top()<<endl;
  }
  return 0;
}


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

using namespace std;

bool solve(int n) {
    vector<vector<int>> gems(21, vector<int>(21, 0));
    int y,x;
    for(int i=0;i<n;++i) {
        cin >> x >> y;
        gems[y][x] = 1;
    }

    int m, z;
    char direction;
    cin >> m;
    y = 10; x = 10;
    for(int k=0;k<m;++k) {
        cin >> direction >> z;
        for(int i=0;i<z;++i) {
            if(direction == 'N') {
                ++y;
            } else if(direction == 'S') {
                --y;
            } else if(direction == 'E') {
                ++x;
            } else {
                --x;
            }
            if(gems[y][x]) gems[y][x] = 0;
        }
    }

    for(int i=0;i<=20;++i) {
        for(int j=0;j<=20;++j) {
            if(gems[i][j]) return false;
        }
    }

    return  true;
}

int main() {
    int n;
    while(cin >> n, n) {
        cout << (solve(n)?"Yes":"No") << endl;
    }
}


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

int main(){
        int n;
        cin>>n;
        int ans=0;
        int a=999;
        for(int i=0; i<n; i++){
                int s;
                cin>>s;
                if(s%10!=0) a=min(a, s);
                ans+=s;
        }
        if(ans%10==0){
                if(a==999) ans=0;
                else ans-=a;
        }
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    // "sort"
)
var sc = bufio.NewScanner(os.Stdin)


func dump(a []int){
    for i, v := range a {
        if i > 0{
            fmt.Print(" ")
        }
        fmt.Print(v)
    }
    fmt.Println("")
}

func main() {
    sc.Split(bufio.ScanWords)
    // code goes here
    
    N := nextInt()
    A := make([]int, N)
    
    for i := 0; i < N; i += 1 {
        A[i] = nextInt()
    }
    
    dump(A)
    for i := 1; i < N; i += 1 {
        v := A[i]
        j := i-1
        for j >= 0 && v < A[j] {
            A[j+1] = A[j]
            j -= 1
        }
        A[j+1] = v
        dump(A)
    }
    
}



func nextInt() int {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}
func nextInt64() int64 {
    sc.Scan()
    v, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil { panic(e) }
    return v
}
func nextString() string {
    sc.Scan()
    return sc.Text()
}
func nextFloat() float64 {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}
func Max(x, y int) int { if x > y { return x }; return y }
func Min(x, y int) int { if x < y { return x }; return y }
func Abs(x int) int { if x > 0 { return x }; return -x }




Measured memory_bytes: 1148
import sys
import math
input = sys.stdin.readline

def main():
    H, W = map(int, input().split())

    if H%3 == 0 or W%3 == 0:
        print(0)
        return

    ans = int(1e10)
    for h in range(1, H):
        s1 = h * W
        tmp = (H - h) // 2
        s2 = tmp * W
        s3 = (H - h - tmp) * W
        ans = min(ans, max((s1, s2, s3)) - min((s1, s2, s3)))
        tmp = W // 2
        s2 = tmp * (H - h)
        s3 = (W - tmp) * (H - h)
        ans = min(ans, max((s1, s2, s3)) - min((s1, s2, s3)))
    for w in range(1, W):
        s1 = w * H
        tmp = (W - w) // 2
        s2 = tmp * H
        s3 = (W - w - tmp) * H
        ans = min(ans, max((s1, s2, s3)) - min((s1, s2, s3)))
        tmp = H // 2
        s2 = (W - w) * tmp
        s3 = (W - w) * (H - tmp)
        ans = min(ans, max((s1, s2, s3)) - min((s1, s2, s3)))
    
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void){
  string s;
  cin>>s;
  int b,e;
  for(int i = 0 ; i < s.size() ; i ++){
    if(s[i] == 'A'){
      b = i;
      break;
    }
  }

  for(int i = s.size() - 1  ; i > 0 ; i --){
    if(s[i] == 'Z'){
      e = i + 1;
      break;
    }
  }

  cout<<e-b<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  cout << "Christmas";
  if(n<25){
    cout << " Eve";
    if(n<24){
      cout << " Eve";
      if(n<23){
        cout << " Eve";
      }
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
sp = [[0]*3 for _ in range(n)]

for i in range(n):
    s, p = map(str, input().split())
    sp[i][0] = s
    sp[i][1] = int(p)*-1
    sp[i][2] = i + 1
sp.sort()

for i in range(n):
    print(sp[i][2])

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

int main (){
  int n = 0 ;
  cin >> n ;
  
  for ( int i = 0 ; i < n ; i++ ){
    string color ;
    cin >> color ;
    if ( color == "Y" ){
      cout << "Four" << endl ;
      break ;
    } else if ( ( i + 1 ) == n ){
      cout << "Three" << endl ;
      break ;
    } else {
    }
  }
}

Measured memory_bytes: 256
S = input()
Q = int(input())
revers_count = 0
mae = ""
ushiro = ""

for i in range(Q):
    Q_i = list(input().split())
    if Q_i[0] == "1":
        revers_count += 1
    else:
        if (Q_i[1] == "1" and revers_count % 2 == 0) or (Q_i[1] == "2" and revers_count % 2 == 1):
            mae = Q_i[2] + mae
        else:
            ushiro = ushiro + Q_i[2]

ans = mae + S + ushiro

if revers_count % 2 == 1:
    ans = ans[::-1]

print(ans)


Measured memory_bytes: 4352
str = input()
q = int(input())  # 命令の数
for i in range(q):
    order = input().split()
    if order[0] == "print":
        a = int(order[1])
        b = int(order[2])
        print(str[a:b+1])
    elif order[0] == "reverse":
        a = int(order[1])
        b = int(order[2])
        rev_str = "".join(list(reversed(str[a:b+1])))
        str = str[:a] + rev_str + str[b+1:]
    elif order[0] == "replace":
        a = int(order[1])
        b = int(order[2])
        str = str[:a] + order[3] + str[b+1:]


Measured memory_bytes: 5612
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char s[] = sc.next().toCharArray();
		char t[] = sc.next().toCharArray();
		Arrays.sort(s);
		Arrays.sort(t);
		String s2 = String.valueOf(s);
		String t2 = new StringBuilder(String.valueOf(t)).reverse().toString();
		if(s2.compareTo(t2) < 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


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

int main() {
	int e;
	while (scanf("%d", &e), e) {
		int Min = INT_MAX;
		for (int i = 0; i*i*i <= e; i++) {
			for (int j = 0; j*j <= e - i*i*i; j++) {
				Min = min(Min, i + j + e - i*i*i - j*j);
			}
		}
		printf("%d\n", Min);
	}
}

Measured memory_bytes: 3120
fn main() {
    let n: i32 = read_line_as_value();
    let v = read_line_as_vector::<i32>();

    let mut ans = 0;
    for i in 0..n {
        for j in i+1..n {
            ans += v[i as usize] * v[j as usize];
        }
    }
    println!("{}", ans);
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}


Measured memory_bytes: 2100
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
*/
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        int d=sc.nextInt();
        int[][] a=new int[h][w];
        int[] point=new int[90001];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                a[i][j]=sc.nextInt();
                point[a[i][j]]=i*w+j;
            }
        }
        long[] ds=new long[h*w+1];
        for (int i = 1; i <= h * w; i++) {
            if(i>d)ds[i]=ds[i-d]+abs(point[i]/w-point[i-d]/w)+abs(point[i]%w-point[i-d]%w);
        }
        int q=sc.nextInt();
        for (int i = 0; i < q; i++) {
            int l=sc.nextInt();
            int r=sc.nextInt();
            out.println(ds[r]-ds[l]);
        }
    }
}

Measured memory_bytes: 98308
#include<iostream>
#include<cmath>

int main(){
    size_t n, k;
    std::cin >> n >> k;

    double ans = 0.0;

    for(size_t i = 1; i <= n; i++){
        size_t cnt = 0, tmp = i;
        while(tmp < k){
            tmp *= 2;
            cnt++;
        }
        ans += (1.0 / n) * std::pow(0.5, cnt);
    }

    std::printf("%.9f\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    s = set()
    for _ in range(k):
        d = I()
        s |= set(LI())

    return n - len(s)


print(main())





Measured memory_bytes: 10984
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define M 200000

long long cnt = 0;
int A[M], L[M / 2 + 1], R[M / 2 + 1];
 
int merge(int l, int m, int r){
    int n1 = m - l, n2 = r - m, i, j;
    for(i = 0;i < n1;i++)L[i] = A[i + l];
    for(i = 0;i < n2;i++)R[i] = A[i + m];
    i = j = 0;
    for(int k = 0;k < r - l;k++){
        if(j == n2 || (i < n1 && L[i] <= R[j]))A[k + l] = L[i++];
        else A[k + l] = R[j++], cnt += n1 - i;
    }
}

int mergeSort(int l, int r){
    if(l + 1 < r){
        int m = (l + r) / 2;
        mergeSort(l, m);
        mergeSort(m, r);
        merge(l, m, r);
    }
}
 
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0;i < n;i++)scanf("%d", &A[i]);
	mergeSort(0, n);
	printf("%lld\n", cnt);
     
    return 0;
}

Measured memory_bytes: 4764
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
//#include<unordered_map>
//#include<unordered_set>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cstring>
#include <functional>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1Int<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P; 
const int N = 200005;
//////////////////////////////

int n;
string s;
int dp[N];

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

	memset(dp, 0, sizeof dp);

	cin >> s;
	n = s.size();
	dp[1] = 1;
	if (s[0] == s[1])dp[2] = 1;
	else dp[2] = 2;

	for (int i = 3; i <= n; i++) {
		if (s[i - 1] != s[i - 2]) dp[i] = dp[i - 1] + 1;
		else dp[i] = dp[i - 3] + 2;
	}

	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
int main(){
    int n, k;
    cin >> n >> k;
    ll x[n],ans=INF;
    for (int i = 0; i < n;i++){
        cin >> x[i];
    }
    for (int i = 0; i < n-k+1;i++){
        ll xl = x[i], xr = x[i + k-1];
        ans = min({abs(xl) + abs(xr - xl), abs(xr) + abs(xr - xl),ans});
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int N; cin >> N;
    int a[N];
    int count2 = 0, count4 = 0, Odd = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(a[i] % 4 == 0) count4++;
        else if(a[i] % 2 == 0) count2++;
        else Odd++;
    }
    if(count2){ // 2の倍数(4の倍数は除く)が存在
        if(count4 >= Odd){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else{
        if(count4 >= Odd-1){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
bool fuzzbizzCol(unsigned long num) {
    if (num % 3 == 0) {
        return true;
    }
    if (num % 5 == 0) {
        return true;
    }

    return false;
}

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

    unsigned long sum = 0;

    for(unsigned long i = 1; i <= stol(N); ++i){
        bool isFZ = fuzzbizzCol(i);
        if (!isFZ){
            sum += i;
        }
    }

    cout << sum;

    return 0;
}



Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
using namespace std;
#define ll long long
int main(){
    int N;cin>>N;
    vector<vector<int> > c(10,vector<int>(10,0));
    for(int i=1;i<=N;i++){
        string S=to_string(i);
        c[int(S[0]-'0')][int(S.back()-'0')]++;
    }
    ll ans=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            ans+=c[i][j]*c[j][i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
def main():
    N = int(input())
    X = [int(a) for a in input().split()]
    Xs = sorted(X)

    for i in range(len(X)):
        if  Xs[len(Xs)//2] > X[i]:
            print(Xs[len(Xs)//2])
        else:
            print(Xs[len(Xs)//2 - 1])

if __name__ == "__main__":
    main()

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

int sum[100][100];
int main() {
	int n; cin >> n;
	rep(i, n)rep(j, n)scanf("%d", &sum[i][j]);
	for (int i = 1; i < n; i++)rep(j, n)sum[i][j] += sum[i - 1][j];
	rep(i, n)for (int j = 1; j < n; j++)sum[i][j] += sum[i][j - 1];
	int Max = INT_MIN;
	rep(i, n)rep(j, n)rep(k, i + 1)rep(t, j + 1) {
		int cnt = sum[i][j];
		if (t)cnt -= sum[i][t - 1];
		if (k)cnt -= sum[k - 1][j];
		if (k&&t)cnt += sum[k - 1][t - 1];
		Max = max(Max, cnt);
	}
	cout << Max << endl;
}

Measured memory_bytes: 3248
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, m;
vector<int> G[100005];
bool used[100005];
int dp[100005];
vector<int> topo;
void tpsort(int v)
{
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(!used[G[v][i]]) tpsort(G[v][i]);
	}
	topo.push_back(v);
}
int main(void)
{
	cin >> n >> m;
	int u, v;
	for(int i = 0; i < m; i++){
		cin >> u >> v;
		G[u].push_back(v);
	}
	for(int i = 1; i <= n; i++) if(!used[i]) tpsort(i);
	reverse(topo.begin(), topo.end());
	for(int i = 0; i < topo.size(); i++){
		int v = topo[i];
		for(int j = 0; j < G[v].size(); j++){
			dp[G[v][j]] = max(dp[G[v][j]], dp[v]+1);
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) ans = max(ans, dp[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8056
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		int count = 0;
		int maxCount = 0;
		for(int i=0; i<S.length(); i++) {
			String a = S.substring(i,i+1);
			if(a.equals("A") || a.equals("C") ||a.equals("G") ||a.equals("T") ) {
				count++;
			} else {
				count = 0;
			}
			if(maxCount < count) {
				maxCount=count;
			}
		}
		System.out.println(maxCount);

	}
}


Measured memory_bytes: 22996
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,l,d,bt=0,t,x,bx=0,y,by=0,f=1;
  scanf("%d",&n);
  while(n--){
    scanf("%d %d %d",&t,&x,&y);
    l=abs(x-bx)+abs(y-by);
    d=t-bt;
    if(l>d||d%2-l%2)f=0;
    by=y;
    bx=x;
    bt=t;
  }
  printf("%s\n",f?"Yes":"No");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

struct P{
	int x, y;
	P(int x_, int y_){
		x = x_; y = y_;
	}
	P(){}
};

const int INF = 1e+8;
int W, H, sx, sy, gx, gy, dist;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
int d[1001][1001], h[1001][1001], dp[1001][1001], f[1001][1001];

void bfs(){
	for(int y=0 ; y < H ; y++ ){
		for(int x=0 ; x < W ; x++ ){
			d[y][x] = h[y][x] = INF;
		}
	}
	d[sy][sx] = 0;
	queue<P> q;
	q.push( P(sx,sy) );
	while( !q.empty() ){
		int x = q.front().x, y = q.front().y; q.pop();
		
		for(int i=0 ; i < 4 ; i++ ){
			int mx = (x + dx[i] + W) % W, my = (y + dy[i] + H) % H;
			
			if( d[y][x] + 1 < d[my][mx] ){
				d[my][mx] = d[y][x] + 1;
				q.push( P(mx,my) );
			}
		}
	}
	dist = d[gy][gx];
	h[gy][gx] = 0;
	q.push( P(gx,gy) );
	while( !q.empty() ){
		int x = q.front().x, y = q.front().y; q.pop();
		
		for(int i=0 ; i < 4 ; i++ ){
			int mx = (x + dx[i] + W) % W, my = (y + dy[i] + H) % H;
			
			if( h[y][x] + 1 < h[my][mx] ){
				h[my][mx] = h[y][x] + 1;
				q.push( P(mx,my) );
			}
		}
	}
}

void solve(){
	for(int y=0 ; y < H ; y++ ){
		for(int x=0 ; x < W ; x++ ){
			f[y][x] = d[y][x] + h[y][x];
			d[y][x] = INF;
			dp[y][x] = 0;
		}
	}
	dp[sy][sx] = 1;
	d[sy][sx] = 0;
	queue<P> q;
	q.push( P(sx,sy) );
	while( !q.empty() ){
		int x = q.front().x, y = q.front().y; q.pop();
		if( f[y][x] > dist ) continue;
		
		for(int i=0 ; i < 4 ; i++ ){
			int mx = (x + dx[i] + W) % W, my = (y + dy[i] + H) % H;
			
			if( d[y][x] + 1 <= d[my][mx] && f[my][mx] == dist ){
				dp[my][mx] = (dp[my][mx] + dp[y][x]) % 100000007;
				if( d[y][x] + 1 < d[my][mx] ){
					d[my][mx] = d[y][x] + 1;
					q.push( P(mx,my) );
				}
			}
		}
	}
}

int main(){
	cin >> W >> H >> sx >> sy >> gx >> gy;
	bfs();
	solve();
	cout << dp[gy][gx] << endl;
}

Measured memory_bytes: 16896
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  string s, t;
  char p[256] = {}, q[256] = {};
  bool used[256] = {};
  
  cin >> s >> t;

  for(int i='a';i<='z';i++){
    p[i] = i;
  }

  for(int i=0;i<s.size();i++){
    int o = 0;
    for(int j='a';j<='z';j++) if(p[j] == t[i]) o = j;
    swap(p[s[i]], p[o]);
  }

  bool f = true;
  
  for(int i=0;i<s.size();i++){
    f &= p[s[i]] == t[i];
  }

  puts(f ? "Yes" : "No");
  
  
  return 0;
}



Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int max_a = 20005;

int main(){
    int H, N; cin >> H >> N;
    vector<int> A(N), B(N);
    rep(i,N) cin >> A[i] >> B[i];

    vector<ll> dp(H+1, INF);
    dp[0] = 0;

    rep(i,N){
        rep(j, H+1){
            int nh = min(j + A[i], H);
            dp[nh] = min(dp[nh], dp[j]+B[i]);
        }        
    }
    
    cout << dp[H] << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define int long long

using namespace std;

int dp[3001][3001] = {};

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    double dp[3000] = {}, per;
    int n;
    cin >> n >> per;
    dp[0] = 1 - per, dp[1] = per;
    for (int i = 1; i < n; i++)
    {
        cin >> per;
        for (int j = n; j > 0; j--)
            dp[j] = dp[j - 1] * per + dp[j] * (1 - per);
        dp[0] *= 1 - per;
    }
    
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++)
        ans += dp[i];
    cout << fixed << setprecision(12) << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<cstdint>
#include<utility>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
int main(){
    LL n,a,b;
    cin>>n>>a>>b;
    LL t=a+b;
    cout<<(n/t)*a+min(a,(n%t))<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;
    for (int i = a; i <= b; i++)
    {
        if(i % k == 0)
        {
            cout << "OK" << endl;
            return;
        }
    }
    cout << "NG" << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3648
while 1:
    m,a,b = map(int, input().split())
    if m==0: break
    p = [int(input()) for i in range(m)]
    key = 0
    ans = 2
    for i in range(a,b+1):
        v = p[i-1]-p[i]
        if v >= key:
            ans = i
            key = v
    print(ans)



Measured memory_bytes: 5620
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Biscuits
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int cs[2];
ll cmbs[MAX_N + 1][MAX_N + 1];

/* subroutines */

ll powll(ll a, int b) { // a^b
  ll p = 1;
  while (b) {
    if (b & 1) p *= a;
    a *= a;
    b >>= 1;
  }
  return p;
}

/* main */

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

  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    cs[ai & 1]++;
  }
  int &en = cs[0], &on = cs[1];
  //printf("en=%d, on=%d\n", cs[0], cs[1]);

  for (int i = 0; i <= on; i++) {
    cmbs[i][0] = cmbs[i][i] = 1;
    for (int j = 1; j < i; j++)
      cmbs[i][j] = cmbs[i - 1][j - 1] + cmbs[i - 1][j];
  }

  ll osum = 0;
  for (int i = 0; i <= on; i++)
    if ((i & 1) == p) osum += cmbs[on][i];

  ll ans = osum * powll(2LL, en);
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
  int s;
  cin>>s;
  int X=s;
  int count=0;
  vector<int> vec(1000000);
  
  for(int i=0;i<1000000;i++){
    vec.at(i)=X;
    if(X%2==0)
      X=X/2;
    else
      X=3*X+1;
    
    for(int j=0;j<i;j++){
      if(vec.at(i)==vec.at(j)){
        cout<<i+1<<endl;
        count+=1;
        break;
      }
    }
    if(count!=0)
      break;
  }
}

Measured memory_bytes: 4096
# -*- coding: utf-8 -*-
from bisect import bisect_left

n = int(input())
l = sorted(list(map(int, input().split(' '))))

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        a = l[i]
        b = l[j]
        ab = a+b
        idx = bisect_left(l, ab)

        # b < c < idx
        ans += max(0, idx-j-1)

print(ans)

Measured memory_bytes: 3188
#include <iostream>
 
int main(){
  int k,a[5];
  std::cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>k;
  if(a[4]-a[0]<=k){
    std::cout<<"Yay!";
  }else{
    std::cout<<":(";
  }
  return 0;
}

Measured memory_bytes: 256
$n = <>;
@ary = split(" ",<>);
$cnt = 0;
for($i=0;$i<$n;$i++){
	if($ary[$i]!=$i +1){
    	$cnt++;
    }
}
if($cnt==0 or $cnt==2){
	print "YES";
} else {
	print "NO";
}

Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
bool v[5][5];
int X[110],Y[110];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    for(int i=1;i<=3;i++)
    {
    	for(int j=1;j<=3;j++)
    	{
    		int uf=read();
    		X[uf]=i,Y[uf]=j;
    	}
    }
    int n=read();
    for(int i=1;i<=n;i++)
    {
    	int uf=read();
    	v[X[uf]][Y[uf]]=true;
    }
    bool bk=false;
    for(int i=1;i<=3;i++)
    {
    	bool p1=true,p2=true;
    	for(int j=1;j<=3;j++)
		{
			if(v[i][j]==false)p1=false;
			if(v[j][i]==false)p2=false;
		}
		if(p1|p2==true)bk=true;
    }
    if(v[1][1]==true && v[2][2]==true && v[3][3]==true)bk=true;
    if(v[3][1]==true && v[2][2]==true && v[1][3]==true)bk=true;
    if(bk==true)puts("Yes");
    else puts("No");
    return 0;
}

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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()
#define allpt_r(v) (v).rbegin(), (v).rend()



const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(vector<T> v)
{
    if (v.size() == 0)
        return;
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}

template <typename T>
void show2dvec(vector<vector<T>> v)
{
    int n = v.size();
    rep(i, n) show1dvec(v[i]);
}

class Unionfind
{
    vector<int> p;

public:
    int find(int x);
    void unite(int x, int y);
    Unionfind(int n);
};

Unionfind::Unionfind(int n)
{
    for (int i = 0; i < n; i++)
    {
        p.push_back(i);
    }
}
int Unionfind::find(int x)
{
    while (p[x] != x)
    {
        p[x] = p[p[x]];
        x = p[x];
    }
    return x;
}

void Unionfind::unite(int x, int y)
{
    x = Unionfind::find(x);
    y = Unionfind::find(y);
    if (x != y)
    {
        p[x] = y;
    }
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, m, k, l;
    cin >> n >> m;
    vector<VI> lang(m + 1);

    rep(i, n)
    {
        cin >> k;
        rep(j, k)
        {
            cin >> l;
            lang[l].push_back(i);
        }
    }

    Unionfind person(n);
    rep(i, m + 1)
    {
        if (lang[i].size() >= 2)
        {
            rep(j, lang[i].size() - 1)
            {
                person.unite(lang[i][j], lang[i][j + 1]);
            }
        }
    }

    set<int> ans;
    rep(i, n) ans.insert(person.find(i));

    cout << ((ans.size() == 1) ? "YES" : "NO" ) << rt;



    return 0;
}


Measured memory_bytes: 4608
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

dic = {'r':p, 's':r, 'p':s}
score = 0
for i in range(k):
    flg = True
    for j in range(i, n-k, k):
        if t[j]==t[j+k] and flg:
            score -= dic[t[j]]
            flg = False
        else:
            flg = True

for i, j in dic.items():
    score += t.count(i)*j
print(score)

Measured memory_bytes: 3316
lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(lst[k - 1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, m;
    cin >> n >> m;
    vint a(n);
    rep(i, m)
    {
        int f, t;
        cin >> f >> t;
        f--;
        t--;
        a[f]++;
        a[t]++;
    }
    bool sat = true;
    rep(i, n)
    {
        if (a[i] % 2)
        {
            sat = false;
            break;
        }
    }

    cout << (sat ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d;
    e = (c/b);
    if(c%b!=0)
        e=e+1;
    if((a-(e-1)*d)>0)
    cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve(int t)
{
    ll i,j,n,m,ans=1,ct=0;
    cin >> n >> m;
    ll A[n+5];
    for(i=0; i<n; i++)
    {
        cin >> A[i];
        A[i] /= 2;
        ans = (ans*A[i])/__gcd(ans,A[i]);
    }
    for(i=n-1; i>=0; i--)
    {
        if((ans/A[i])%2==0)
        {
            cout <<0<<endl;
            return ;
        }
    }
    ct = m/ans;
    cout <<(ct+1)/2<<endl;
    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
   // cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}



Measured memory_bytes: 4368
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define debug(s, param) std::cerr << s << param << std::endl;

using namespace std;
using ll = long long;

void dfs(const vector<vector<int>>& vertices, vector<int>& points, int v, int p) {
  if (p != -1) points[v] += points[p];
  for (auto vertice : vertices[v]) {
    if (vertice == p) continue;
    dfs(vertices, points, vertice, v);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int>> vertices(n+1);
  rep (i, n-1) {
    int v1, v2;
    cin >> v1 >> v2;
    vertices[v1].emplace_back(v2);
    vertices[v2].emplace_back(v1);
  }
  vector<int> points(n+1, 0);
  rep (i, q) {
    int v, p;
    cin >> v >> p;
    points[v] += p;
  }
  dfs(vertices, points, 1, -1);
  for (int i = 1; i <= n; ++i) cout << points[i] << " "; cout << endl;
  return 0;
}

Measured memory_bytes: 27548
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskBB solver = new TaskBB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskBB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            String a = in.next();
            String b = in.next();
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < n; i++) {
                sb.append(a.charAt(i));
                sb.append(b.charAt(i));
            }
            out.println(sb.toString());
        }

    }
}



Measured memory_bytes: 21460
s = input()
t = input()
len_s = len(s)
len_t = len(t)

ans = len_t
for i in range(len_s-len_t+1):
    tmp = 0
    for j in range(len_t):
        if(s[i+j] != t[j]):
            tmp += 1
    ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 67528
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	k = 0.0
	for i in 1:n
		k += 1/a[i]
	end
	println(1/k)
end

main()

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

using namespace std;

const int mod = 998244353, N = 1e5 + 5;
int n, a[N], ans = 1;

int32_t main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + n + 1);

    for (int i = 1; i <= n; ++i) ans = (1LL * ans * __gcd(i - 1, a[i]) ) % mod;

    cout << ans;

    return 0;
}


Measured memory_bytes: 640
/****************************
*  Developer : joshi08
*  Date  :  05-07-2020
*  Year  :  2020
****************************/

#include <bits/stdc++.h>

#define lli long long int
#define mod 1000000007
#define fi first
#define se second
#define ii pair<lli, lli>
#define mp make_pair
#define endl '\n'
const double PI = 3.141592653589793238460;
lli gcd(lli a, lli b) { if (a == 0) return b; return gcd(b % a, a);}
lli max(lli a, lli b) {if (a > b) return a; else return b;}
lli min(lli a, lli b) {if (a < b) return a; else return b;}
lli power(lli a, lli n){ lli res = 1; while(n){ if(n%2==0){ a *= a; n /= 2; } else{ res *= a; n--; } } return res; }

using namespace std;

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

	lli n,i,j,k,m,s=0;
	vector<lli> a;
	
	cin>>n;
	
	for(i=0;i<n;i++)
	{
		cin>>k;
		a.push_back(k);
	}
	sort(a.rbegin(),a.rend());
	
	i=0;
	if(n>1)
	{
		n-=2;
		s+=a[i];
		i++;
	}
	
	while(n!=0)
	{
		if(n>1)
		{
			s+=a[i];
			s+=a[i];
			i++;
			n-=2;
		}
		else
		{
			s+=a[i];
			n--;
		}
		
	}
	
	cout<<s<<endl;

    return 0;
}



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

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    ll X;
    cin >> X;
    ll A,B;
    for (ll i=-1000; i<=1000; i++) {
        for (ll j=-1000; j<=1000; j++) {
            if (pow(i,5)-pow(j,5) == X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    // output
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 4072
N,K,Q = map(int, input().split())
score_lst = [0] * N

for i in range(Q):
    Ai = int(input())
    score_lst[Ai - 1] += 1

def_socre = K - Q
for j in score_lst:
    if def_socre + j > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, l;
  cin >> n >> l;
  vector<string> vec(n);
  for (int i; i < n; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  for (int i; i < n; i++){
    cout << vec.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256