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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read() 	        freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n) 	        scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n) 	        scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%ull",&n)
#define ull             unsigned long long int
#define endll           pf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps 	        1e-18
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod 107
#define var    int i,j,k,n,m,z=0,c=0,t,x,y,l,r,mid
bool Check(ll  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(ll  N,int pos){	return N=N | (1LL<<pos);}
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};
ll a[100005];
int main()
{
    ll var;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        sfl(a[i]);
    }x=0;i=1;
    if(a[1]==1)i=2;
    for(;i<n;i++)
    {
        c++;
        if(c==k-1)
        {
            x++;c=0;
        }
    }
    if(c)x++;
    cout<<x<<endl;
}


Measured memory_bytes: 1024
#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,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

class Eratosthenes {
    vector<int> sieve;
public:
    Eratosthenes(int N) {
        sieve.resize(N + 1, 1);
        FOR(i, 2, N + 1) {
            for(int j = i;j <= N;j += i) {
                if(sieve[j] == 1) {
                    sieve[j] = i;
                }
            }
        }
    }

    map<int, int> sift(int n) {
        map<int, int> r;
        for(;1 < n;) {
            r[sieve[n]]++;
            n /= sieve[n];
        }
        return r;
    }
};

int main() {
    int N;
    cin >> N;
    Eratosthenes er(N);
    LL res = 0;
    FOR(i, 1, N) {
        auto sift = er.sift(i);
        LL c = 1;
        for(auto s : sift) {
            c *= s.second + 1;
        }
        res += c;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 7216
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int n;
    int i, ans = 0;
    
    cin >> n;
    
    int l[2*n];
    
    for(i = 0; i < 2*n; i++) {
        cin >> l[i];
    }
    
    sort(l, l+n*2, greater<int>());
    
    for(i = 0; i < 2*n; i += 2) {
        ans += l[i+1];
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
#define MOD 1000000007 
//ll dx[4] = {1,-1,0,0};
//ll dy[4] = {0,0,1,-1};

/*ll pasc[100][100];
ll getPasc(ll n,ll k){
  if(pasc[n][k]!=0){
    return pasc[n][k];
  }else{
    pasc[n][k] = getPasc(n-1,k-1)+getPasc(n-1,k);
    return pasc[n][k];
  }
}*/

int main(){
  string s;
  cin>>s;
  ll a[26];
  REP(i,26){
    a[i] = 0;
  }
  REP(i,s.length()){
    a[(int)s[i]-(int)'a']++;
  }
  string ans = "Yes";
  REP(i,26){
    if(a[i]%2!=0){
      ans = "No";
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char a[100005];
int main(){
	int ans=0;
	int i;
	scanf("%s",a);
	for(i=0;i<=strlen(a)-1;++i)	if(a[i]=='C')
									{
										ans++;
										break;
									}
	for(;i<=strlen(a)-1;++i)	if(a[i]=='F')
	{
		++ans;
		break;
	}
	if(ans==2)	printf("Yes");
	else	printf("No");
	return 0;
	
}	

Measured memory_bytes: 128
#include<bits/stdc++.h> 
#define MN 200000
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;
}
map<int,int> mp;
int n,a[MN+5];long long ans;
int main()
{
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	if(a[1]!=0) return 0*puts("-1"); 
	for(int i=2;i<=n;++i) if(a[i]>a[i-1]+1) return 0*puts("-1");
	for(int i=2;i<=n;++i) mp[a[i]-i]=max(mp[a[i]-i],a[i]);
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();++it) ans+=it->second;
	cout<<ans;
	return 0;
}



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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); VI(as, n);
  vector<ll> s; s.PB(0);
  REP(i, n){
    s.PB(s[i]);
    s[i + 1] += as[i];
  }
  vector<pair<ll, ll>> vl(n + 1, MP(0, 0)), vr(n + 1, MP(0, 0));
  REP(i, 2, n + 1){
    int j = lower_bound(s.begin(), s.end(), s[i] / 2) - s.begin();
    ll l = s[j - 1], r = s[j];
    ll dl = abs(s[i] - 2ll * l), dr = abs(s[i] - 2ll * r);
    if (dl < dr){
      vl[i] = MP(min(l, s[i] - l), max(l, s[i] - l));
    } else {
      vl[i] = MP(min(r, s[i] - r), max(r, s[i] - r));
    }
  }
  REP(i, n - 1){
    int j = lower_bound(s.begin(), s.end(), (s[n] - s[i]) / 2 + s[i]) - s.begin();
    ll l = s[j - 1] - s[i], r = s[j] - s[i];
    ll dl = abs(s[n] - s[i] - 2ll * l), dr = abs(s[n] - s[i] - 2ll * r);
    if (dl < dr){
      vr[i] = MP(min(l, s[n] - s[i] - l), max(l, s[n] - s[i] - l));
    } else {
      vr[i] = MP(min(r, s[n] - s[i] - r), max(r, s[n] - s[i] - r));
    }
  }
  ll ans = 1e18;
  REP(i, 2, n - 1){
    ans = min(ans, max(vl[i].second, vr[i].second) - min(vl[i].first, vr[i].first));
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 10992
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string S;
  cin >> S;
  long ans = 0;
  long blacks = 0;
  for (char c: S) {
    if (c == 'B') blacks++;
    else ans += blacks;
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 720
def check(aline):
    pools = []
    leftedge = []

    for i, c in enumerate(aline):
        if c == "\\":
            leftedge.append(i)
        elif c == "_":
            pass
        else:
            if leftedge:
                left = leftedge.pop()
                w = i - left

                while pools and left < pools[-1][0]:
                    w += pools.pop()[1]

                pools.append((left, w))

    return pools


if __name__ == '__main__':

    al = input().strip()
    ps = check(al)

    print(sum([x[1] for x in ps]))
    print(len(ps), *[x[1] for x in ps])


Measured memory_bytes: 6312
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
ll num[10][10];
const ll mod = 1000000007;
ll dp[101][10];
bool nthbit(int b, int i) {
	return (b & (1 << i)) > 0;
}
void add(long long &a, long long b) {
	a = (a + b) % mod;
}
void numberofAmidakuji(){
	int H, W, K;
	cin >> H >> W >> K;
	for (int i = 0; i < (1 << (W - 1)); i++)
	{
		bool ok = true;
		for (int j = 0; j < W - 2; j++)
		{
			if (nthbit(i, j) && nthbit(i, j + 1)) {

				ok = false;
				break;
			}
		}
		if (!ok) continue;
		vector<ll> P(W);
		for (int j = 0; j < W; j++)
		{
			P[j] = j;
		}
		for (int j = 0; j < W - 1; j++)
		{
			if (nthbit(i, j)) swap(P[j], P[j + 1]);
		}
		for (int j = 0; j < W; j++)
		{
			num[j][P[j]]++;
		}
	}
	dp[0][0] = 1;
	for (size_t h = 0; h < H; h++)
	{
		for (size_t w = 0; w < W; w++)
		{
			for (size_t k = 0; k < W; k++)
			{
				add(dp[h + 1][k], (dp[h][w] * num[w][k]) % mod);
			}
		}
	}
	cout << dp[H][K - 1] << endl;
}

int main() {
	numberofAmidakuji();
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}

int main() {
	int N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];
	
	int now = 1;
	for (int count = 0; count < N; count++) {
		if (a[now-1] == 2) { 
			print(count+1); 
			return 0;
		}
		now = a[now-1];
	}
	print(-1);
}

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

int main(){
	char p[5][6] =
	{{'a','f','k','p','u','z'},
	 {'b','g','l','q','v','.'},
	 {'c','h','m','r','w','?'},
	 {'d','i','n','s','x','!'},
	 {'e','j','o','t','y',' '}};
	string s;	
	while(cin >> s){
		bool flag = false;
		for(size_t i=0;i<s.size();i+=2){
			if(s[i]>'6' || s[i]<'1' || s[i+1]>'5' || s[i+1]<'1')
				flag = true;
		}
		if(flag||s.size()%2){
			cout << "NA" << endl;
		}else{
			for(size_t i=0;i<s.size();i+=2){
				cout << p[s[i+1]-'0'-1][s[i]-'0'-1];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[3];
  a[0]=n%10;
  n-=a[0];
  n/=10;
  a[1]=n%10;
  n-=a[1];
  n/=10;
  a[2]=n;
  for(int i=0;i<3;i++){
    if(a[i]==1) a[i]=9;
    else a[i]=1;
  }
  cout<<100*a[2]+10*a[1]+a[0]<<endl;
}

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

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

	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int &i: a) cin >> i;
	for (int &i: b) cin >> i;

	int ans = 998244353;
	for (int m = 0; m < (1 << n); m++) {
		if (__builtin_popcount(m) != n/2) continue;

		vector<pair<int, int>> e, o;
		for (int j = 0; j < n; j++) {
			if (m & (1 << j)) {
				if (j % 2) o.emplace_back(a[j], j);
				else o.emplace_back(b[j], j);
			} else {
				if (j % 2) e.emplace_back(b[j], j);
				else e.emplace_back(a[j], j);
			}
		} 
		sort(e.begin(), e.end());
		sort(o.begin(), o.end());

		vector<pair<int, int>> xd;
		for (int i = 0; i < e.size(); i++) {
			xd.push_back(e[i]);
			if (i < o.size()) xd.push_back(o[i]);
		}

		int tmp = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				if (xd[i].first > xd[j].first) tmp = 998244353;

				tmp += (xd[i].second > xd[j].second);
			}
		} 
		ans = min(ans, tmp);
	}
	cout << (ans == 998244353 ? -1 : ans) << '\n';

	return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long r,d,x;
	
	cin >> r >> d >> x;
	
	for(int i=0; i<10; i++){
		x = r*x - d;
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        aaa: [usize; n],
    }
    let mut cur_max = aaa[0];
    let mut ans = aaa.into_iter().fold(0usize, |r, a| {
        r + if cur_max < a {
            cur_max = a;
            0
        } else { cur_max - a }
    });
    println!("{}", ans);
}


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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a <= c && c <= b) ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 256
def main():
    mod = 10**9+7
    N = int(input())
    a = [list(map(int, input().split())) for _ in range(N)]
    dp = [0]*(1<<N)
    dp[0] = 1
    def bitcount(i): # i < 2^32
        i = i - ((i >> 1) & 0x55555555)
        i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
        return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24
    for s in range(1, 1<<N):
        women = []
        m = bitcount(s)-1
        for w in range(N):
            if a[m][w] == 1 and s&1<<w:
                dp[s]+=dp[s^(1<<w)]
                dp[s]%=mod
    print(dp[-1])
main()

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

int main() 
{
    lli a,b,c,k;
    cin >> a >> b >> c >> k;
    
    if(k<=a) cout<<k<<endl;
    else{
        lli ans = a;
        k-=a;
        
        if(k>0 && k<=b) ans+=0;
        k-=b;
        
        if(k>0 && k<=c) ans+=(k*(-1));
        k-=c;
        
        cout<<ans<<endl;
    }
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/*
	Things to remember : check for coners n = 1, pass references instead
*/
/* -------------------------------Solution Sarted--------------------------------------*/

//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5
const int INF = 100000000000005; // 1e15 +5

void solve(){
	int n;
	cin >> n;
	if(n >= 30){
		puts("Yes");
	}else{
		puts("No");
	}
	
}

signed main()
{
	faster;
#ifndef ONLINE_JUDGE
	freopen("ip.txt", "r", stdin);
	freopen("op.txt", "w", stdout);
#endif
	// int t; cin >> t; while(t--)
		solve();
	return 0;
}


//Author : Ankit Raj
//Problem Link :

/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs 
dfs
fenwik - BIT
binary_search
segment_tree
*/
	

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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

void solve() {
	string s;
	int cnt = 0;
	cin >> s;
	int n = (int)s.length();
	for (int i = 0; i < n; ++i) {
		if (s[i] == '0')
			++cnt;
	}

	cout << min(cnt,n-cnt) * 2 << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 512
import fractions
import random


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    # divisors.sort()
    return divisors


def is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


a, b = map(int, input().split())
gcd = fractions.gcd(a, b)
divisors = make_divisors(gcd)

ans = 1
for divisor in divisors:
    if is_prime3(divisor):
        ans += 1

print(ans)


Measured memory_bytes: 5724
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
return 0;}

Measured memory_bytes: 580
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a;
    scanf("%d", &a);
    //printf("%d %d\n", a, b);
    
    if(a>81 || a<1){
        printf("No");
        return 0;
    }
    
    if(a>=1 && a<=9){
        printf("Yes");
        return 0;
    }
    
    for(int i=2; i<=9; i++){
        if(a%i == 0){
            if(a/i <= 9){
                printf("Yes");
                return 0;
            }
        }
    }
    
    printf("No");
    return 0;
}


Measured memory_bytes: 256
data=input().split()
N=int(data[0])
M=int(data[1])
data_gate=[input().split() for i in range(M)]
data_min=[]
data_max=[]
for i in range(M):
    data_min.append(int(data_gate[i][0]))
    data_max.append(int(data_gate[i][1]))
m=max(data_min)
M=min(data_max)
if M>=m:
    ans=M-m+1
else:
    ans=0
print(ans)

Measured memory_bytes: 46200
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1.00001e9;
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
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;}
/*----------------------------------------------*/
int dp[110][101010]; 
int w[110],v[110];

signed main(){
  int n,W;
  cin>>n>>W;
  rep(i,n) cin>>w[i]>>v[i];
  rep(i,110)rep(j,101010) dp[i][j]=INF;
  
  dp[0][0]=0;
  rep(i,n+1)rep(j,101010){
    if(j>=v[i]) chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
    chmin(dp[i+1][j],dp[i][j]);
  }

  int ans=0;
  rep(j,101010) if(dp[n][j]<=W) ans=j;
  cout<<ans<<endl;
  // rep(i,n+1){
  //   rep(j,101010) if(dp[i][j]<INF) cout<<dp[i][j]<<"/"<<j<<" ";
  //   cout<<endl;
  // }
  return 0;
}


Measured memory_bytes: 87040
#include <iostream>
#include <algorithm>
using namespace std; 
int n, ans, a[100001];
int main(){
	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++)
        for (int j = i + 1; j <= n; j++)
            for (int k = j + 1; k <= n; k++) {
                if (a[i] + a[j] <= a[k] || 
                    a[i] + a[k] <= a[j] ||
                    a[j] + a[k] <= a[i] ) break;
                ans++;
            }
//    int cur = 1;
//    while (cur <= n - 2) {
//        for (int i = 1; i <= n - 1 -cur; i++) {
//            ans += upper_bound(a + cur + i + 2, a + n + 1, a[cur] + a[cur + i]) - a - cur - i - 1;
//            cout << ans << endl;
//        }
//        cur++;
//    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>
using namespace std;

int main(void){
    // Your code here!
    string a, b;
    
    cin >> a >> b;
    if((a == "H" && b == "H") || (a == "D" && b == "D"))
        cout << 'H' << endl;
    else
        cout << 'D' << endl;
        
    
    return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc164/tasks/abc164_c

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

    int main(void)
    {
        int i,l,flg = 0;
        char s[11],t[11];
        scanf("%s",&s);
        scanf("%s",&t);

        l = strlen(s);
        for(i=0;i<l;i++){
            if(s[i]!=t[i]){
                flg =  1;
                break;
            }
        }

        if(flg == 1){printf("No\n");}
        else{printf("Yes\n");}
        
        return 0;
    }

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

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

  int n = s.size();
  int count = 0;
  int ind = n - 1;
  long long ans = 0;
  while (ind >= 0){
    if (s.at(ind) == 'A') ans += count;
    else if (ind - 1 >= 0 && s.substr(ind - 1, 2) == "BC"){
      count++;
      ind--;
    }else{
      count = 0;
    }
    ind--;
  }

  cout << ans << endl;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    n = I()
    a = LI()
    ma = max(a)
    mi = min(a)
    r = []
    if abs(mi) > ma:
        i = a.index(mi)
        for j in range(n):
            if j == i:
                continue
            r.append('{} {}'.format(i+1, j+1))
        for j in range(n-1,0,-1):
            r.append('{} {}'.format(j+1, j))
    else:
        i = a.index(ma)
        for j in range(n):
            if j == i:
                continue
            r.append('{} {}'.format(i+1, j+1))
        for j in range(n-1):
            r.append('{} {}'.format(j+1, j+2))

    return '\n'.join([str(len(r))]+r)



print(main())




Measured memory_bytes: 67052
import java.util.*;

class Step implements Comparable<Step>{
  int b;
  long c;
  public Step( int d, long e ){
    b = d;
    c = e;
  }

  @Override
  public int compareTo( Step p ){
    if(this.c - p.c > 0) return 1;
    else if(this.c - p.c < 0) return -1;
    else return 0;
    //return (int)(this.c - p.c);
  }
}

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int n = sc.nextInt();
        // スペース区切りの整数の入力
        int m = sc.nextInt();
        //配列の宣言
        //int[] num = new int[n];
        long[] num = new long[n];

        for(int i = 0; i < n; i++){
            //num[i] = sc.nextInt();
            num[i] = sc.nextLong();
        }

        Arrays.sort(num);

        List<Step> list = new ArrayList<>();

        int b;
        long c;
        for(int i = 0; i < m; i++){
            b = sc.nextInt();
            c = sc.nextLong();
            list.add(new Step(b, c));
        }
        Collections.sort(list, Comparator.reverseOrder());
        //System.out.println(list);
        int k = 0, l;
        for(int i = 0; i < list.size(); i++){
            b = list.get(i).b;
            c = list.get(i).c;
            l = 0;
            //if(num[k] >= c) break;
            while(true){
                if(l < b && k < n && num[k] < c){
                    num[k] = c;
                    k++;
                    l++;
                }else{
                    break;
                }
            }
            if(k >= n) break;
            /*for(int j = 0; j < b; j++){
                if(num[j] < c){
                    num[j] = c;
                }else{
                    Arrays.sort(num);
                    break;
                }
            }
            if(num[b-1] == c) Arrays.sort(num);*/
        }

        long ans = 0;
        for(int i = 0; i < n; i++){
            ans += num[i];
        }

        // 出力
        System.out.println(ans);

    }

}

Measured memory_bytes: 95856
#include <cstdio>
#include <iostream>
using namespace std;
#define mod 1000000007
int x[100010];
 
int main(){
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    x[k]++;
  }
  if (n % 2 == 1) {
    bool flag = true;
    long long ans = 1;
    if (x[0] != 1) flag = false;
    for (int i = 2; i < n; i += 2) {
      if (x[i] != 2) flag = false;
      ans *= 2;
      ans %= mod;
    }
    if (!flag) cout << 0 << endl;
    else cout << ans << endl;
  } else {
    bool flag = true;
    long long ans = 1;
    for (int i = 1; i < n; i += 2) {
      if (x[i] != 2) flag = false;
      ans *= 2;
      ans %= mod;
    }
    if (!flag) cout << 0 << endl;
    else cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;


void solve(){
    int a, b;
    cin >> a >> b;
    int ans = -1;
    for(int i = 1; i <= 10000; i++){
        int opA = floor( (double)i * 0.08);
        int opB = floor( (double)i * 0.1);
        if(opA == a && opB == b){
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}


int main(){
    //int t; cin >> t;
    //while(t--) solve();
    solve();
    return 0;
}


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

int main() {
	int N, D;
	cin >> N >> D;
	vector<vector<int>> X(N, vector<int>(D));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) cin >> X[i][j];
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int A = 0;
			for (int k = 0; k < D; k++) A += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
			int B = sqrt(A);
			if (B * B == A) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
def main():
  H, W, A, B = map(int, input().split())
  ans = [['0']*W for _ in range(H)]
  for i in range(H):
    for j in range(W):
      if (i < B and j < A) or (i >= B and j >= A):
        ans[i][j] = '1'
  for i in range(H):
    print(''.join(ans[i]))
    
if __name__ == "__main__":
  main()

Measured memory_bytes: 16632
n = int(input())
s = [0 for i in range(n)]
for i in range(n):
    s[i] = input()
    
m = int(input())
t = [0 for i in range(m)]
for i in range(m):
    t[i] = input()


#重複削除
s_set = list(set(s))
t_set = list(set(t))


#sの中身を確認して数える
deff_max = 0
for i in s_set:
    s_cnt = s.count(i)
    t_cnt = t.count(i)
    
    deff = s_cnt - t_cnt
    
    if deff_max < deff:
        deff_max = deff

print(deff_max)

Measured memory_bytes: 3064
c,d,t,u,sz,n;
long s;
char x[18],buf[5<<17];
main()
{
	n=read(0,buf,5<<17);
	c=*buf;
	for(;++sz<n;)
	{
		++t;
		d=buf[sz];
		if(c!=d)
		{
			s+=(long)t*(t+1)>>1;
			if(c=='>')s-=t<u?t:u;
			u=t;
			t=0;
			c=d;
		}
	}
	t=17;
	do{
		x[--t]=s%10+'0';
		s/=10;
	}while(s);
	write(1,x+t,17-t);
}


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

int main () {
  int x, y;
  cin >> x >> y;
  
  vector<vector<int>> data = {
    {1,3,5,7,8,10,12},
    {4,6,9,11},
    {2},
  };
  
  bool ans = false;
  
  for (int i = 0; i < 3; i++) {
   for (int j = 0; j < 7; j++) {
     for (int a : data.at(i)) {
       if (a == x) {
         for (int b : data.at(i)) {
           if (b == y) {
             ans = true;
           }
         }
       }
     }
   }
  }
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(int argc, char* argv[]) {
  int n, *h;
  scanf("%d", &n);
  h = (int *)malloc(n * sizeof(int));

  int i = 0;
  for (i=0; i < n; i++) {
    scanf("%d", &h[i]);
  }

  for (i = n-2; i >= 0; i--) {
    if (h[i+1] - h[i] >= 0) {
      continue;
    } else if (h[i+1] - h[i] < 0) {
      h[i]--;
      if (h[i+1] - h[i] >= 0) {
	continue;
      } else if (h[i+1] - h[i] < 0) {
	printf("No\n");
	return 0;
      }
    }
  }

  printf("Yes\n");

  free(h);
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  rep(i, b) cout << a;
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

def main():
    lines = sys.stdin.readlines()
    input_num = 0
    ans = []
    for line in lines:
        # print(line)
        # rm '\n' from string of a line
        line = line.strip('\n')
        input_num = int(line)
        n = input_num
        # print input_num
        print "",
        index_num = 1
        flag = 0
        while True:
            # END CHECKNUM
            if index_num != 1 or flag == 1:
                if (index_num + 1) > n:
                    break
                else:
                    index_num += 1 # Go on below
            else:
                flag = 1
            x = index_num
            if x % 3 == 0:
                print index_num,
                continue
            if x % 10 == 3:
                print index_num,
                continue
            else:
                while x > 0:
                    x /= 10
                    if x % 10 == 3:
                        print index_num,
                        break

        break


if __name__ == "__main__":
    main()

Measured memory_bytes: 6472
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
using namespace std;
int main(){
	char ch;
	int count[26];
	for (int i = 0; i < 26; i++){
		count[i] = 0;
	}

	while (cin >> ch){
		if (islower(ch)){
			count[ch - 'a']++;
		}
		else if (isupper(ch)){
			count[ch - 'A']++;
		}
	}
	
	for (int i = 0; i < 26; i++){
		printf("%c : %d\n", 'a' + i, count[i]);
	}
	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int Array(int x[],int n){
    for(int i=0;i<n;i++){
        cin >> x[i] ;
    }
    return *x;
}

int main(){
    string s;
    cin >> s;
    int n=s.size();
    for(int i=0;i<n;i++){
        cout << 'x' ;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

char mp[60][60];
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int32_t main() {
    fastIO();
    
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; ++i) cin >> (mp[i] + 1);
    
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (mp[i][j] == '#') cout << "#";
            else {
                int cnt = 0;
                for (int dir = 0; dir < 8; ++dir) {
                    if (mp[i + dx[dir]][j + dy[dir]] == '#') ++cnt;
                }
                cout << cnt;
            }
        }
        cout << "\n";
    }
    
    return 0;
}

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

int main(void){
    // Your code here!
    
    int r;
    (1 <= r) && (r <= 100);
    int s;
    
    
    scanf("%d", &r);
    s = pow(r,2);
    printf("%d",s);
    
    return 0;
    
}


Measured memory_bytes: 128
sx, sy, tx, ty = map(int, input().split())
ans = ""
gx, gy = (tx - sx, ty - sy)
# go
ans += "R" * gx + "U" * gy
ans += "R" + "D" * (gy + 1) + "L" * (gx + 1) + "U"

# return
ans += "U" * gy + "R" * gx
ans += "U" + "L" * (gx + 1) + "D" * (gy + 1) + "R"

print(ans)


Measured memory_bytes: 38256
fn find_minimum(sizes: &Vec<Vec<u32>>) -> u32 {
    let n_matrices = sizes.len();
    let mut n_multiply: Vec<Vec<u32>> = vec![vec![0; n_matrices]; n_matrices];
    for diff in 1..n_matrices {
        for i in 0..(n_matrices - diff) {
            let j = i + diff;

            // println!("{}, {}", i, j);
            if diff == 1 {
                assert_eq!(sizes[i][1], sizes[j][0]);
                n_multiply[i][j] = sizes[i][0] * sizes[i][1] * sizes[j][1];
            } else {
                n_multiply[i][j] = (i..j)
                    .map(|k| {
                        n_multiply[i][k] + n_multiply[k + 1][j]
                            + sizes[i][0] * sizes[k + 1][0] * sizes[j][1]
                    })
                    .fold(std::u32::MAX, |min, x| std::cmp::min(min, x));
            }
        }
    }

    // for row in n_multiply {
    //     println!("{:?}", row);
    // }

    n_multiply[0][n_matrices - 1]
}
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let n = line.trim().parse::<usize>().unwrap();

    let mut sizes: Vec<Vec<u32>> = Vec::new();
    for _ in 0..n {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        let inputs: Vec<u32> = line.split_whitespace()
            .map(|e| e.parse::<u32>().ok().unwrap())
            .collect::<Vec<u32>>();
        sizes.push(inputs);
    }

    //    println!("{:?}", sizes);

    let mcm = find_minimum(&sizes);
    println!("{}", mcm);
}



Measured memory_bytes: 5044
import java.util.Scanner
import kotlin.math.*

fun main() {
	val scn = Scanner(System.`in`)
	val a = scn.nextInt()
	val b = scn.nextDouble()
	val c = scn.nextInt()
	val d = scn.nextDouble()
	println(if (ceil(a/d) >= ceil(c/b)) "Yes" else "No")
}

Measured memory_bytes: 37764
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
vector<LL>v;
LL v2[100001];
int N;
int main(){
	cin>>N;
	REP(i,N){
	    LL a;
	    cin>>a;
	    v.push_back(a);
	    v2[i]=a;
	}
	sort(v2,v2+N);
	int ans=0;
	for(int i=0;i<N;i+=2){
	   int a=lower_bound(v2,v2+N,v[i])-v2;
	   if(a%2!=0){
	      ans++;
	   } 
	}
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+1;
bool prime (ll x){
    for (ll i=2;i<=sqrtl(x);i++){
        if (x%i==0)
            return false;
    }
    return true;

}

int main()
{
    FASTINOUT;
    ll x,y;
    cin>>x>>y;
    ll g=__gcd(x,y);
    set<ll>s;
    for (ll i=1;i<=sqrtl(g);i++){
        if (g%i==0){
            s.insert(i);
            s.insert(g/i);
        }
    }
    //cout<<g<<endl;
    vector<ll>v(s.begin(),s.end());
   /* for (int i=0;i<v.size();i++)
        cout<<v[i]<<" ";*/
    int c=0;
    int ls=v.size()-1;
    for (int i=0;i<v.size();i++){
       if (prime(v[i]))
        c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 640
# include <iostream>
# include <cstdio>
using namespace std;
const int N = 3e5 + 12;
int nex[N][22],a[N],n;long long ans;
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)scanf("%d",&a[i]);
	for(int j = 0;j <= 20;j++)nex[n + 1][j] = nex[n + 2][j] = n + 1;
	for(int i = n;i >= 1;i--)
	 for(int j = 0;j <= 20;j++)nex[i][j] = (a[i] >> j & 1) ? i : nex[i + 1][j];
	for(int i = 1;i <= n;i++)
	{
		int mx = N;
		for(int j = 0;j <= 20;j++)
		mx = min(nex[nex[i][j] + 1][j],mx);
		ans += mx - i;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 18304
import re

def calc(op, a, b):
    if op == '+' :
        return a + b
    elif op == '-':
        return a - b
    elif op == '*':
        return a * b
    elif op == '/':
        return a // b
    
    return None

EOL = re.compile(r'^\w+\s\?\s\w+$')
MAX = 20000

for _ in range(MAX):
    line = input()
    if EOL.match(line):
        break
    
    a,op,b = line.split()
    print(calc(op, int(a), int(b)))


Measured memory_bytes: 6540
import java.util.Arrays;
import java.util.Scanner;

class Main {
	double[][] p = new double[2][6];

	void run() {
		Scanner sc = new Scanner(System.in);
		int Na = sc.nextInt();
		int Nb = sc.nextInt();
		long[] xa = new long[Na];
		long[] ya = new long[Na];
		long[] xb = new long[Nb];
		long[] yb = new long[Nb];
		for (int i = 0; i < Na; ++i) {
			xa[i] = sc.nextLong();
			ya[i] = sc.nextLong();
		}
		for (int i = 0; i < Nb; ++i) {
			xb[i] = sc.nextLong();
			yb[i] = sc.nextLong();
		}

		double ans = Double.MAX_VALUE / 3;
		for (int t = 0; t < 2; ++t) {
			for (int i = 0; i < Na; ++i) {
				for (int j = 0; j < Na; ++j) {
					if (cross(xa[0], ya[0], xa[i], ya[i], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[i], ya[i], xa[j], ya[j], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[j], ya[j], xa[1], ya[1], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					ans = Math.min(ans, dist(xa[0], ya[0], xa[i], ya[i]) + dist(xa[i], ya[i], xa[j], ya[j])
							+ dist(xa[j], ya[j], xa[1], ya[1]) + dist(xb[0], yb[0], xb[1], yb[1]));
				}
			}
			Na ^= Nb;
			Nb ^= Na;
			Na ^= Nb;
			long[] tmp = new long[Na];
			tmp = Arrays.copyOf(xa, xa.length);
			xa = Arrays.copyOf(xb, xb.length);
			xb = Arrays.copyOf(tmp, tmp.length);
			tmp = Arrays.copyOf(ya, ya.length);
			ya = Arrays.copyOf(yb, yb.length);
			yb = Arrays.copyOf(tmp, tmp.length);
		}
		System.out.println(ans >= Double.MAX_VALUE / 4 ? "-1" : ans);
	}

	double dist(long xa, long ya, long xb, long yb) {
		long dx = xa - xb;
		long dy = ya - yb;
		return Math.sqrt(dx * dx + dy * dy);
	}

	boolean cross(long xa1, long ya1, long xb1, long yb1, long xa2, long ya2, long xb2, long yb2) {
		long v = f(xa1, ya1, xb1, yb1, xa2, ya2) * f(xa1, ya1, xb1, yb1, xb2, yb2);
		long u = f(xa2, ya2, xb2, yb2, xa1, ya1) * f(xa2, ya2, xb2, yb2, xb1, yb1);
		return v <= 0 && u <= 0;
	}

	long f(long xa, long ya, long xb, long yb, long x, long y) {
		return (ya - yb) * (x - xa) - (y - ya) * (xa - xb);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

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


Measured memory_bytes: 37288
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   int n,k; cin >> n >> k;
   vector<vector<int> > v(n+1);
   rep(i,0,k){
      int x; cin >> x;
      rep(j,0,x){
         int u; cin >> u;
         v[u].pb(i+1);
      }
   }
   int ans = 0;
   rep(i,0,n){
      if(sz(v[i+1]) == 0) ans++;
   }
   cout << ans << "\n";
}

Measured memory_bytes: 3740
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i=s.length()/2-1;i>=1;i--){
        if(s.substr(0,i)==s.substr(i,i)){
            cout << i*2 << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  string o, e;
  cin >> o >> e;
  for (int i = 0; i < int(e.size()); ++i) cout << o[i] << e[i];
  if (o.size() > e.size()) cout << o.back();
  cout << endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int st[1000003][5];
string q;
int dmc(int g,int k)
{
    if(g==q.length())return k;
    if(st[g][k]!=1e9)return st[g][k];
    int z;
    if(!k)z=min((dmc(g+1,0)+(q[g]-'0')),(dmc(g+1,1)+10-(q[g]-'0')));
    else z=min(dmc(g+1,0)+1+(q[g]-'0'),dmc(g+1,1)+10-((q[g]-'0')+1));
    return st[g][k]=z;
}
int main()
{
    int g;
    cin>>q;
    reverse(q.begin(),q.end());
    for(g=0;q[g];g++)st[g][0]=st[g][1]=1e9;
    printf("%d\n",dmc(0,0));
    return 0;
}


Measured memory_bytes: 70696
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  I n,m,c;
  cin >> n >> m >> c;
  V b(m);
  VIN(b);
  I t=0;
  REP(i,n){
    I cc=0;
    V a(m);
    VIN(a);
    REP(j,m){
      cc += a.at(j) * b.at(j);
    }
    if (cc + c > 0){
      t++;
    }
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 256
import math
n, k = map(int, input().split())
def better(l, ans, k):
    for i in range(2, n):
        #print(myarr(ans, k, i, l), ans)
        yy, xx = myarr(ans, k, i, l)
        ans[i] = min(func(yy, l[i], xx))
        #print(ans[i],func(yy, l[i], xx))
    return ans
def myarr(l, k, i, y):
    if i-k<0:
        return l[0:i], y[0:i]
    else:
        return l[(i-k):i], y[(i-k):i]
def func(l, i, xx):
    #print(l, xx, i)
    c = 0
    for a in l:
        #print(c)
        l[c]+=abs(i-xx[c])
        c+=1
    return l
l = list(map(int, input().split()))
ans = [0] * n
ans[1] = abs(l[1]-l[0])
print(better(l, ans, k)[len(ans)-1])

Measured memory_bytes: 20904
n, m = map(int, input().split())
tree = [-i for i in range(n+1)]
rank = [1 for _i in range(n+1)]
def search_root(num, tree=tree):
    if tree[num] < 0:
        return num
    else:
        tree[num] = search_root(tree[num])
        return tree[num]

for _i in range(m):
    x, y, z = map(int, input().split())
    x, y = [search_root(x), search_root(y)]
    if x==y:
        continue
    else:
        if rank[x]<rank[y]:
            rank[y] += 1
            tree[x] = y
        else:
            rank[x] += 1
            tree[y] = x
print(sum(1 for i in tree if i<0))

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }
    ll ans = 1;
    N -= K;
    K--;
    ans += (N + K - 1) / K;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

char str[100001][11];
int n;

int cmp(const void *a,const void *b)
{
    return strcmp((const char *)a,(const char *)b);
}

int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<10;j++)
			cin>>str[i][j];
		for(int p=0;p<10;p++)
			for(int q=p+1;q<10;q++)
			{
				if(str[i][p]>str[i][q])
				{
					int tmp=str[i][p];
					str[i][p]=str[i][q],str[i][q]=tmp;
				}
			}
	}
	qsort(str,n,sizeof(str[0]),cmp);
	long long cnt=0;
	long long ans=0;
	str[n][0]='A';
	for(int i=1;i<=n;i++)
	{
		if(!strcmp(str[i],str[i-1]))
		{
			cnt++;
		}
		else
		{
			ans+=(long long)(cnt*(cnt+1)/2);
			cnt=0;
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 2428
import java.util.*;
import static java.lang.System.out;
import static java.lang.Math.*;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    while(scan.hasNext()){
      double x[] = new double[4];
      double y[] = new double[4];
      for(int i=0;i<4;i++){
        x[i] = scan.nextDouble();
        y[i] = scan.nextDouble();
      }
      boolean ok = true;
      if(x[0] > x[3]) ok = false;
      if(y[0] > y[3]) ok = false;
      if(x[2] > x[1]) ok = false;
      if(y[2] > y[1]) ok = false;
      if(ok) out.println("YES");
      else out.println("NO");
    }
  }
}

Measured memory_bytes: 20860