akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
 
using namespace std;
 
const int MAX_N = 100000;
const int MAX_Q = 100000;
const long long UB = 1000000000;
 
long long A[MAX_N];
int N;
 
long long eSum[MAX_N], oSum[MAX_N];
long long sum[MAX_N];
 
bool lt(int x, int a, int b){
	if(b < 0 || b >= N) return true;
	if(a < 0 || a >= N) return false;
	long long d1 = abs(x - A[a]);
	long long d2 = abs(x - A[b]);
	if(d1 < d2) return true;
	if(d1 == d2) return a < b;
	return false;
}
 
long long calc(int r, int d){
	if(r < 0) return 0;
	if(d == 0) return eSum[r];
	else if(d == 1) return oSum[r];
	else return sum[r];
}
 
long long calc(int l, int r, int d){
	if(l > r) return 0;
	return calc(r, d) - calc(l - 1, d);
}
 
long long query(int x){
	int lb = 1, ub = N + 1;
	while(ub - lb > 1){
		int mid = (lb + ub) / 2;
		int a = mid / 2;
		int b = mid / 2;
		if(a + b < mid) a++;
		int l = N - mid;
		int r = N - a - 1;
		// take [l, r]
		if(lt(x, r + 1, l)) ub = mid;
		else lb = mid;
	}
	// lb cards: no conflict
	int a = (lb + 1) / 2;
	int d = N % 2;
	long long ans = calc(0, N - lb - 1, d) + calc(N - lb, N - a - 1, -1);
	return sum[N - 1] - ans;
}
 
int main(){
	int Q;
	scanf("%d%d", &N, &Q);
	for(int i = 0; i < N; ++i) scanf("%lld", A + i);
	sum[0] = A[0];
	for(int i = 1; i < N; ++i) sum[i] = sum[i - 1] + A[i];
	eSum[0] = A[0];
	for(int i = 1; i < N; ++i) eSum[i] = eSum[i - 1] + (i % 2 == 0 ? A[i] : 0);
	oSum[0] = 0;
	for(int i = 1; i < N; ++i) oSum[i] = oSum[i - 1] + (i % 2 == 1 ? A[i] : 0);
	for(int i = 0; i < Q; ++i){
		long long x;
		scanf("%lld", &x);
		long long ans = query(x);
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4736
//#pragma comment(linker, "/stack:200000000") //  (UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")  // $ (UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define endl "\n"
#define int long long
#define ll long long
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define vi vector<int>
#define vii vector< vector<int> >
#define vpi vector< pair<int,int> >
#define pair <int, int> pii

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
    ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<"  ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int modpow(int x, int n, int mod)
{
	x %= mod ;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % mod ;
		x = x * x % mod ;
		n >>= 1 ;
	}
	return res;
}

const long long inf = 2e18 ;
const int mod = 1e9+7 ;
// const int mod = 998244353 ;
const int N = 1e5 + 10 ;

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

        int x;
        cin>>x;

        int y;
        cin>>y;

        if(500*x>=y) {
                cout<<"Yes";
        }
        else {
                cout<<"No";
        }
	

return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i, j, n, h, w;
    
    while(1){
        scanf("%d %d", &h, &w);
            if(h == 0 && w == 0){
                break;
            }
        
        for(i = 0; i < h; i++){
            for(j = 0; j < w; j++){
            if(i == 0 ||i == (h - 1) || j == 0 || j == (w - 1)){
                printf("#");
            }else{    printf(".");
            }
        }
        printf("\n");
    }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2048
X, N = map(int, input().split())
p_list = [int(i) for i in input().split()]

if N == 0:
    print(X)
elif X not in p_list:
    print(X)
else:
    check_list = []
    for i in range(1, 105+1):
        check_list.append(X-i)
        check_list.append(X+i)

    for el in check_list:
        if el not in p_list:
            break

    print(el)

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

#define ZERO_IQ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int main() {
    int n, m, a, b, c;
    cin >> n >> m >> a >> b >> c;
    string s;
    cin >> s;
    map<char, int> score;
    map<char, char> defeat;
    map<int, char> result;
    score['r'] = a;
    score['s'] = b;
    score['p'] = c;
    defeat['r'] = 'p';
    defeat['s'] = 'r';
    defeat['p'] = 's';
    long long summ = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'r') {
            if (result.count(i - m) && result[i - m] == 'p') {
                if ('r' != defeat[s[i + m]])result[i] = 'r';
                else if ('s' != defeat[s[i + m]])result[i] = 's';
                else result[i] = 's';
                continue;
            }
            summ += score['p'];
            result[i] = 'p';
        } else if (s[i] == 's') {
            if (result.count(i - m) && result[i - m] == 'r') {
                if ('p' != defeat[s[i + m]])result[i] = 'p';
                else if ('s' != defeat[s[i + m]])result[i] = 's';
                else result[i] = 's';
                continue;
            }
            summ += score['r'];
            result[i] = 'r';

        } else if (s[i] == 'p') {
            if (result.count(i - m) && result[i - m] == 's') {
                if ('p' != defeat[s[i + m]])result[i] = 'p';
                else if ('r' != defeat[s[i + m]])result[i] = 'r';
                else result[i] = 'p';
                continue;
            }
            summ += score['s'];
            result[i] = 's';
        }
    }
    cout << summ << endl;

    return 0;
}

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

int main(void){
	int N;
	int T,A;
	std::cin>>N>>T>>A;
	int min=1000000;
	int min_num;

	for(int i=0;i<N;i++){
		int H;
		std::cin>>H;
		int temperture = T*1000 - (6 * H);
		int diff = abs(temperture - A*1000);
//		std::cout<<"temperture = " <<temperture<<" diff = "<<diff<<std::endl;
		if(diff < min){
			min = diff;	
			min_num = i;
		}
	}

	min_num++;

	std::cout<<min_num<<std::endl;
	return 0;
}


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

use std::cmp::{min, max};

fn main() {
    input! {
        n: usize,
        w: usize,
        wv: [(usize, usize); n],
    }

    // dp[item][limit]: item番目までの品物を、重さがlimitを超えないように選んだときの価値の総和の最大値
    let mut dp = vec![vec![0; w + 1]; n + 1];

    for item in 0..n {
        for limit_w in 0..w + 1 {
            let weight = wv[item].0;
            let value = wv[item].1;

            if limit_w >= weight {
                dp[item + 1][limit_w] = max(dp[item + 1][limit_w], dp[item][limit_w - weight] + value);
            }

            dp[item + 1][limit_w] = max(dp[item + 1][limit_w], dp[item][limit_w]);
        }
    }

    println!("{}", dp[n][w]);
}


Measured memory_bytes: 106748
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
	int x,a;
    cin>>x>>a;
    if(x<a)cout<<0<<endl;
    else cout<<10<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct BIT{
  ll M=1;
  vector<ll> dat;
  BIT(ll N){
    while(N>M) M*=2;
    dat.resize(M*2-1, 0);
  }
  void update(ll x, ll k){
    for(int i=k+1;i<=M;i+=(i&(-i))){
      dat[i] += x;
    }
  }
  ll sum(ll r){
    ll ret = 0;
    for(int k=r;k>0;k-=(k&(-k))) ret += dat[k];
    return ret;
  }

  ll query(ll l, ll r){
    return sum(r) - sum(l);
  }
};

int main(int argc, char const *argv[]) {
  ll n, q;std::cin >> n >> q;
  vll c(n);
  vvl x = VV(n, 0, 0, ll);
  re(i, n) {
    std::cin >> c[i];
    c[i]--;
    x[c[i]].push_back(i);
  }
  BIT seg(n+1);
  vll ans(q, 0);
  vector<vector<pair<ll, ll>>> d(n);
  for(int i=0;i<q;i++){
    ll l, r;std::cin >> l >> r;
    l--, r--;
    d[r].push_back(pair<ll, ll>(l, i));
  }
  for(int i=0;i<n;i++){
    ll now = c[i];
    auto itr = lower_bound(all(x[now]), i);
    ll pre = 0;
    if(itr!=x[now].begin()){
      itr--;
      pre = (*itr) + 1;
    }
    seg.update(1, i);
    if(pre!=0) seg.update(-1, pre-1);
    for(auto v:d[i]){
      ll l = v.first;
      ll idx = v.second;
      ans[idx] = seg.query(l, i+1);
    }
  }
  re(i, q) std::cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 71992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  for (int k = 1; k <= M; k++) {
    int idx = 0;
    while (idx != N - 1) {
      if ((A[idx] % k) > (A[idx + 1] % k)) {
        int tmp = A[idx];
        A[idx] = A[idx + 1];
        A[idx + 1] = tmp;
        idx++;
      } else {
        idx++;
      }
    }
  }
  for (int i : A) {
    cout << i << "\n";
  }
  return 0;
}


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


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = a + b, r = c + d;
    if(l>r) cout << "Left\n";
    else if(l==r) cout << "Balanced\n";
    else cout << "Right\n";
}


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

typedef long long               ll;
typedef long double             ld;


#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLOCK			 cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define PII              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

///knight moves:
///int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2};
///int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};


ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
}

ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}

void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

bool point(int a,int b,int c)
{
	return ((b<=c && b>=a) || (b>=c && b<=a));
}

int solve()
{
	int n;
	si(n);
	vi v;
	v.pb(0);
	forr(i,0,n) 
	{
		int x;
		si(x);
		v.pb(x);
	}
	
	v.pb(0);
	
	int tot=0;
	forr(i,1,v.size())
	{
		int temp=abs(v[i]-v[i-1]);
		tot+=abs(temp);
	}
	
	forr(i,1,v.size()-1)
	{
		int a=v[i-1];
		int b=v[i];
		int c=v[i+1];
		if(point(a,b,c)) pi(tot);
		else
		{
			int temp=tot;
			temp-=(abs(v[i]-v[i+1]));
			temp-=(abs(v[i-1]-v[i]));
			temp+=(abs(v[i-1]-v[i+1]));
			pi(temp);
		}
		nln;
	}
		
	
	
			
    return 0;
}


int main()
{
//    racecar;
//    cout<<fixed<<setprecision(6);
//    fileio();
    solve();
//	CLOCK;   
    return 0;
}



///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


Measured memory_bytes: 1784
S=input()
N=len(S)
ans=0
for i in range(2**(N-1)):
  formula=S[0]
  q="{:0>10b}".format(i)[::-1]
  #1<=N<=10なので長さは10で良い
  #また前から見て"+"を入れるか否か決定する為後ろ向きに並び替える
  for j in range(1,N):
    if int(q[j-1])&1:
      formula+="+"
      #qの見ている桁が1ならば"+"を入れる
    formula+=S[j]
    #次の桁を式に入れる
  ans+=eval(formula)    
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef struct{
  int x;
  int y;
}BILL;
typedef pair<int,int> P;
const int INF = (1<<20);
const int MAX = 1001;
BILL bill[MAX];
int pre[MAX],node[MAX];
int n,m;
vector<int> IN;

void init(){
  fill(pre,pre+MAX, -1);
  fill(node,node+MAX, INF);
}


double Getd(BILL a, BILL b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

void solve(int from, int to){
  init();
  node[from] = 0;
  priority_queue<P,vector<P>, greater<P> > Q;
  Q.push(P(node[from],from));
  //Q(distance,name)
  while(!Q.empty()){
    P now = Q.top(); Q.pop();
    if(now.first > node[now.second]) continue;
    for(int i = 0; i < IN.size(); i++){
      int next = IN[i];
      if(Getd(bill[now.second],bill[next]) <= 50 && Getd(bill[now.second],bill[next]) > 0)
	if(node[next] > now.first+Getd(bill[now.second],bill[next])){
	  node[next] = now.first+Getd(bill[now.second],bill[next]);
	  Q.push(P(node[next],next));
	  pre[next] = now.second;
	}
    }
  }

  vector<int> V;
  int prec = to;
  if(node[to] == INF) cout << "NA";
  else {
    V.push_back(to);
    while(pre[prec] != -1){
      V.push_back(pre[prec]);
      prec = pre[prec];
    }
  }
  reverse(V.begin(),V.end());
  for(int i = 0; i < V.size(); i++){
    if(i) cout << " ";
    cout << V[i];
  }
  cout << endl;
}

int main(){
  while(cin >> n && n){
    IN.clear();
    for(int i = 0; i < n; i++){
      int num;
      cin >> num;
      cin >> bill[num].x >> bill[num].y;
      IN.push_back(num);
    }
    cin >> m;
    for(int i = 0; i < m; i++){
      int f,t;
      cin >> f >> t;
      solve(f,t);
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
//#include <cmath>
//#include <cstdlib>
using namespace std;


int main(){
	/*input*/
	int n,T;
	cin >> n >> T;
	int c[100];
	int t[100];
	for(int i = 0; i < n; i++){
		cin >> c[i] >> t[i];
	}

	/*calc*/
    int ans = 1001;
    for(int i = 0; i < n; i++){
    	if(t[i] <= T) ans = min(ans, c[i]);
    }

    if(ans > 1000){
    	cout << "TLE" << endl;
    	return 0;
    }

    /*output*/
	cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <cstdio>

using namespace std;

int main(){
	int H,W;
	cin>>H>>W;
	vector<string> A(H);
	string a;
	int NbN=0;
	for(int i=0;i<H;i++){
		cin>>A[i];
		for(int j=0;j<W;j++){
			if(A[i][j]=='#') NbN++;
		}
	}
	int x=0,y=0;
	int cnt=1;
	if(A[y][x+1]=='#' && A[y+1][x]=='#'){
		cout<<"Impossible"<<endl;
		return 0;
	}

	if(A[y][x+1]=='#') x++;
	else if(A[y+1][x]=='#') y++;
	//cout<<y<<" "<<x<<endl;
	cnt++;
	while(x<W-1 || y<H-1 ){
		bool x_W=true;
		bool y_H=true;
		if(x>W-2){
			x_W=false;
		}
		if(y>H-2){
			y_H=false;
		}
		bool right=false;
		bool bottom=false;
		if(x_W && A[y][x+1]=='#'){
			cnt++;
			x++;
		}else if(y_H && A[y+1][x]=='#'){
		
			cnt++;
			y++;
		}else{
			cout<<"Impossible"<<endl;
			return 0;
		}
		//cout<<y<<" "<<x<<" "<<cnt<<endl;
	}
	//cout<<NbN<<" "<<cnt<<endl;
	if(cnt==NbN){
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;	
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int64 gcd(int64 A, int64 B) {
    return B == 0 ? A : gcd(B, A%B);
}

int64 lcm(int64 A, int64 B) {
    return A / gcd(A, B) * B;
}
 
int main() {
    int64 A, B, C, D; cin >> A >> B >> C >> D;
    int64 L = lcm(C, D);

    auto solve = [&](int64 X) {
        int64 v1 = X / C;
        int64 v2 = X / D;
        int64 v3 = X / L;
        return X - (v1 + v2 - v3);
    };

    cout << solve(B) - solve(A-1) << endl;
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N, K;
    vector<unsigned long> score(3);
    cin >> N >> K >> score[0] >> score[1] >> score[2];
    string T;
    cin >> T;
    vector<char> win{'s', 'p', 'r'};
    vector<vector<unsigned long>> dp(N, vector<unsigned long>(3));
    for(unsigned long i{0}; i < K; ++i)for(unsigned long k{0}; k < 3; ++k)dp[i][k] = (T[i] == win[k]) * score[k];
    for(unsigned long i{0}; i < K; ++i)for(unsigned long j{0}; j + i + K < N; j += K)for(unsigned long k{0}; k < 3; ++k)dp[i + j + K][k] = score[k] * (T[i + j + K] == win[k]) + max(dp[i + j][(k + 1) % 3], dp[i + j][(k + 2) % 3]);
    unsigned long ans{0};
    for(unsigned long i{0}; i < K; ++i)ans += *max_element(dp[N - i - 1].begin(), dp[N - i - 1].end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
//Life is inherently meaningless unless you find something which gives it meaning
 

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[102],b[102];
int main(){
    ll n;
    cin>>n;
    forn(i,n) cin>>a[i]>>b[i];
    ll f=0;
    for(ll i=0;i<=(n-3);i++){
        ll c=0;
        if(a[i]==b[i]) c++;
        if(a[i+1]==b[i+1]) c++;
        if(a[i+2]==b[i+2]) c++;
        if(c==3) f=1;
    }
    if(f==1) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3576
#include<iostream>
#include<stdio.h>

using namespace std;

int n;

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

    long long dp[n][n]; //for(int i=0; i<n; i++) for(int j=0; j<n; j++) dp[i][j]=1e18;

    for(int i=0; i<n; i++){
        dp[i][i]=0;
    }
    for(int i=1; i<n; i++) arr[i]+=arr[i-1];

    for(int wid=2; wid<=n; wid++){
        for(int i=0; i<=n-wid; i++){
            long long minm=1e18; long long cur;
            for(int j=i; j<i+wid-1; j++){
                cur=dp[i][j]+dp[j+1][i+wid-1]+arr[i+wid-1];
                if(i>0) cur-=arr[i-1];
                minm=min(cur,minm);
            }
            dp[i][i+wid-1]=minm;
        }
    }

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


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  vector<vector<char>> field(3, vector<char>(3));
  for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>field[i][j];
  cout<<field[0][0]<<field[1][1]<<field[2][2]<<endl;
}

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

int main(){
    int n, m, a, h, p, q;
    
    while(1){
        cin >> n >> m >> a;
        if(n == 0)
            break;

        vector< vector<int> > amida(n+1);
        for(int i=1; i<=n; i++)
            amida[i] = vector<int>(1001, i);

        for(int i=0; i<m; i++){
            cin >> h >> p >> q;
            amida[p][h] = q;
            amida[q][h] = p;
        }

        for(int i=0; i<1000; i++)
            a = amida[a][1000-i];
        cout << a << endl;
    }
  
    return 0;
}

Measured memory_bytes: 3360
#include<stdio.h>

int main(){
  int a, b, c, high, res;

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

  res = a+b+c;
  
  high=a;
  if(high<b) high=b;
  if(high<c) high=c;

  // res = a+b+c;
  res -=high;
  printf("%d\n", res);
  
  return 0;
}


Measured memory_bytes: 128
def is_int(s):
    try:
        i = int(s)
    except:
        return False
    return True

ARGS_COUNT = 2
stdin = input().split()

if (len(stdin) > ARGS_COUNT):
    print("Too many arguments.")
    exit()
elif (len(stdin) < ARGS_COUNT):
    print("Too few arguments.")
    exit()
elif (not is_int(stdin[0])):
    print("N is not a number.")
    exit()
elif (not is_int(stdin[1])):
    print("M is not a number.")
    exit()

N = int(stdin[0])
M = int(stdin[1])

if (N < 1 or N > 100000):
    print("Out of range at N.")
    exit()
elif (M < 1 or M > 100000):
    print("Out of range at M.")
    exit()

A = [[] for j in range(N)]

for i in range(0, N):
    stdin = input().split()

    if (len(stdin) > ARGS_COUNT):
        print("Too many arguments.")
        exit()
    elif (len(stdin) < ARGS_COUNT):
        print("Too few arguments.")
        exit()
    elif (not is_int(stdin[0])):
        print("A[%d] is not a number." % (i + 1))
        exit()
    elif (not is_int(stdin[1])):
        print("B[%d] is not a number." % (i + 1))
        exit()
    elif(int(stdin[0]) < 1 or int(stdin[0]) > 1000000000):
        print("Out of range at A[%d]." % (i + 1))
        exit()
    elif (int(stdin[1]) < 1 or int(stdin[1]) > 100000):
        print("Out of range at B[%d]." % (i + 1))
        exit()

    A[i].append(int(stdin[0]))
    A[i].append(int(stdin[1]))

Bsum = 0
for a in A:
    Bsum += a[1]

if (Bsum < M):
    print("Summed B are less than M.")
    exit()

stores = sorted(A)
charge = 0

for store in stores:
    if (M <= 0):
        break
    if (M - store[1] >= 0):
        charge += store[0] * store[1]
        M -= store[1]
    elif (M - store[1] < 0):
        charge += store[0] * M
        M = 0

print(charge)

Measured memory_bytes: 22400
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    double r;
    double pi = 3.14159265359;
    cin >> r;
    printf("%.16f %.16f\n", pi * r * r, 2 * pi * r);
}


Measured memory_bytes: 3180
import numpy as np
n, x = map(int, input().split())
A = np.array(input().split()[::-1]*2, dtype=np.int64)
B = A.copy()[:n]
ans = float("inf")
for k in range(n):
  t = x*k + B.sum()
  ans = min(ans, t)
  np.minimum(B, A[k+1:k+n+1], out=B)
print(ans)

Measured memory_bytes: 12508
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>

#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b);
int lcm(int a, int b);

void solve_A(){
    char c;
    cin >> c;
    printf("%c", c+1);
}

void solve_B(){
    int n, k, m, sum = 0;
    cin >> n >> k >> m;
    int a[n-1];
    rep(i,n-1){
        cin >> a[i];
        sum += a[i];
    }

    int b = m * n - sum;
    if(b <= 0) cout << "0";
    else if(b <= k) cout << b;
    else cout << "-1";

}

void solve_C(){
    ll n, m;
    cin >> n >> m;
    ll p[m];
    string s[m];
    
    ll ac[n];
    ll wa[n];
    rep(i,n) ac[i] = wa[i] = 0;

    rep(i,m){
        cin >> p[i] >> s[i];
        p[i] --;
        if(s[i] == "WA"){
            if(ac[p[i]] == 0) wa[p[i]] += 1;
        }
        
        if(s[i] == "AC") ac[p[i]] += 1;
    }

    ll ans_ac = 0, ans_wa = 0;
    rep(i,n){
        if(ac[i] != 0){
            ans_wa += wa[i];
            ans_ac ++;
        }
    }
    
    cout << ans_ac << " " << ans_wa; 
}

int main(void){
    solve_C();
    
    return 0;
}

int gcd(int a, int b){
    if(a < b) swap(a, b);

    int r = a % b;
    while(r != 0){
        a = b;  b = r;  r = a % b;
    }
    return b;
}

int lcm(int a, int b){
    return a * b / gcd(a, b);
}

Measured memory_bytes: 8064
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

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

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

int main()
{
	int l, r; cin >> l >> r;
	if (r - l + 1 >= 2019 || l == 0)cout << 0 << endl;
	else
	{
		int res = 1e7;
		for (int i = l; i < r; ++i)
		{
			for (int j = i + 1; j <= r; ++j)
			{
				chmin(res, ((i % 2019)*(j % 2019)) % 2019);
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 3628
import java.lang.Math

fun main(args: Array<String>)
{
    val s = readLine()!!.toCharArray()

    var easy = true
    for (i in 0..(s.size-1)) {
        if (i%2 == 0 && s[i] == 'L' || i%2 == 1 && s[i] == 'R') {
            easy = false
            break
        }
    }

    println(if(easy) "Yes" else "No")
 }

fun readInts(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun readLongs(): List<Long> = readLine()!!.split(" ").map(String::toLong)

fun readIntArr(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray()
fun readLongArr(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray()

fun readIntArrS(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArray()
fun readLongArrS(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArray()

fun readIntArrSD(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArrayDescending()
fun readLongArrSD(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArrayDescending()

fun readString() = readLine()!!


Measured memory_bytes: 31712
#include<stdio.h>

main(){
  int n,q,S[100000],T[50000],i,j,count=0;
  int left,mid,right;

  scanf("%d",&n);
  for(i=0 ; i<n ; i++) scanf("%d",&S[i]);

  scanf("%d",&q);

  for(j=0 ; j<q ; j++){
    scanf("%d",&T[j]);
  }
   
  for(j=0 ; j<q ; j++){ 
  left = 0;
  right = n;
  
    while(left < right){
      mid = (left + right) / 2;
      if(T[j] == S[mid]){
	count++;
	break;
      }
      else if(T[j] < S[mid]){
	right = mid;
      }
      else if(T[j] > S[mid]){
	left = mid + 1;
      }
    }
  }

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

  return 0;
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Keyence
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            string tar = "keyence";
            if (s.Equals(tar))
            {
                Console.WriteLine("YES");
                return;
            }
            for (int i = 0; i < s.Length; i++)
            {
                for (int j = i; j < s.Length - 1; j++)
                {
                    string trim = s.Substring(0, i);
                    trim += s.Substring(j + 1);
                    if (trim.Equals(tar))
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                }
            }
            Console.WriteLine("NO");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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 gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}

void solve(void){
    ll n;
    cin >> n;
    ll a[n];
    ll count = 0;
    rep(i,0,n) {
        cin >> a[i];
        if(a[i]%2 == 0){
            while(a[i]%2 == 0){
                a[i]/=2;
                count++;
            }
        }
    }
    cout << count << endl;
 
}

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int freq[1000009];
int main()
{
    int n;
    cin>>n;

    int x;

    for (int i=0; i<n-1; ++i)
    {
        cin>>x;
        freq[x-1]++;
    }
    for (int i=0; i<n; ++i)
    {
        cout<<freq[i]<<"\n";
    }

    
    
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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(15);
    ll N;
    cin >> N;

    vector<ll> A(N);

    REP(i, N){
        cin >> A[i];
    }

    ll right = 0;
    ll sum = 0;
    ll ans = 0;

    for(ll left=0; left<N; left++){
        while(right<N && (sum ^ A[right]) == (sum + A[right])){
            sum += A[right];
            right++;
        }
        ans += right - left;
        if(left == right) right++;
        else{
            sum -= A[left];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

const int N = 200200;
ll A[N], F[N];
ll n, k;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> k;
  for (int i=1; i<=n; ++i) {
    cin >> A[i];
  }
  for (int i=1; i<=n; ++i) {
    cin >> F[i];
  }
  sort(A+1, A+n+1);
  sort(F+1, F+n+1);
  reverse(F+1, F+n+1);

  ll lo = 0, hi = 1e18;
  while (lo < hi) 
  {
    ll mid = (lo+hi)/2;
    ll sum = 0;
    for (int i=1; i<=n; ++i) {
      if (A[i]*F[i] > mid) {
        sum += A[i] - mid/F[i];
      }
    }

    if (sum > k) {
      lo = mid+1;
    } else {
      hi = mid;
    }
  }
  cout << lo << endl;

  return 0;
}


Measured memory_bytes: 6780
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N,K;
	cin >> N>>K;
	ll A[N];
	for (ll i = 0; i < N; ++i) cin >> A[i];
 
	// 解法
	sort(A, A+N);
	ll GCD = A[0];
	REP(i,N) GCD = gcd(GCD, A[i]);
	ll GCD2 = gcd(GCD, K);
	// printf("GCD: %lld, K: %lld\n", GCD, K);
	
	//出力
	if (GCD!=GCD2) printf("IMPOSSIBLE\n");
	else if (K>A[N-1]) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <bitset>
#include <queue>


#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
using pll = pair<long long, long long>;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int rt(int x) {
        if (par[x] < 0) return x;
        else return par[x] = rt(par[x]);
    }
    
    bool issame(int x, int y) {
        return rt(x) == rt(y);
    }
    
    bool unite(int x, int y) {
        x = rt(x);
        y = rt(y);
        if (x == y)  return false;
        
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[rt(x)];
    }
};

int main() {
    int N, M; cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    rep (i, M) {
        cin >> X[i] >> Y[i] >> Z[i];
             --X[i], --Y[i], --Z[i];  
    } 
    UnionFind uf(N);
    rep (i, M) uf.unite(X[i], Y[i]);
    set<int> st;
    rep (i, N) st.insert(uf.rt(i));
    cout << (int)st.size() << endl;
    
}



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

int32_t main() {

    ios_base::sync_with_stdio(0); cin.tie(0);

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

    int sum = 0;
    for (int i = 1; i <= M; ++i) {
        int x; cin >> x;

        sum += x;
    }

    cout << (sum <= N ? N-sum : -1) << "\n";

}


Measured memory_bytes: 3596
n = int(input())
#日
d,x = input().split()
#合宿終了後のチョコレートの個数





#i人目のA日目に食べた数を数える
num = 0

#配列
a = []

#３人分
for i in range(n):
    a.append(int(input()))
    for j in range(int(d)):
        if a[i]*j +1 <= int(d):
            num += 1
    
    
    
    
            
print(num+int(x))

Measured memory_bytes: 3060
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func Min(x, y int) int {
  if x < y { return x }
  return y
}
func Max(x, y int) int {
  if x < y { return y }
  return x
}

func main() {
  HW := NextIntVec()
  H, W := HW[0], HW[1]
  M := make([][]int, H)
  for i := range M {
    M[i] = make([]int, W)
    S := NextLine()
    for j, s := range S {
      if s == '.' {
        M[i][j] = 1
      }
    }
  }
  L := H * W + 1
  G := make([][]int, H * W)
  for i := range G {
    G[i] = make([]int, H * W)
    for j := range G[i] {
      G[i][j] = L
    }
    h, w := i / W, i % W
    if M[h][w] < 1 { continue }
    G[i][i] = 0
    if 0 < h && 0 < M[h - 1][w] { G[i][i - W] = 1 }
    if h < H - 1 && 0 < M[h + 1][w] { G[i][i + W] = 1 }
    if 0 < w && 0 < M[h][w - 1] { G[i][i - 1] = 1 }
    if w < W - 1 && 0 < M[h][w + 1] { G[i][i + 1] = 1 }
  }
  N := H * W
  for k := 0; k < N; k++ {
    for i := 0; i < N; i++ {
      for j := 0; j < N; j++ {
        G[i][j] = Min(G[i][k] + G[k][j], G[i][j])
      }
    }
  }
  D := make([]int, N)
  for i, g := range G {
    for _, d := range g {
      if d < L { D[i] = Max(d, D[i]) }
    }
  }
  ans := 0
  for _, d := range D {
    if ans < d { ans = d }
  }
  Write(ans)
  Output()
}


Measured memory_bytes: 2048
#include<iostream>
using namespace std;
int a[100000], n, k, m, r;
inline void Div(int l, int s) {
	int p = l * 10, q = s;
	for (int i = 0; i < r + 10; i++) {
		a[i] += p / q; p = (p%q) * 10;
	}
}
int main() {
	while (true) {
		for (int i = 0; i < 10200; i++)a[i] = 0;
		cin >> n >> k >> m >> r; if (n == 0)break;
		Div(1, n);
		if (m == 1) { for (int i = 1; i < n; i++) { Div(1, n*i); } }
		for (int i = r + 10; i >= 1; i--) {
			if (a[i] >= 10) { a[i - 1] += a[i] / 10; a[i] %= 10; }
		}
		cout << a[0] / 10 << '.'; for (int i = 0; i < r; i++)cout << a[i] % 10; cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#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 a,b,k;
  cin >> a >> b >> k;
  I t;
  V v;
  t = max(a,b)+1;
  REP(i,t){
    if (i==0) continue;
    if (a % i == 0 && b % i == 0){
      v.push_back(i);
    }
  }
  SORT(v);
  REV(v);
  cout << v.at(k-1) << endl;
  return 0;
}



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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef complex<int> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

int main() {
  int n;
  while(cin >> n,n) {
    set<P> seiza;
    while(n--) {
      int x,y;cin>>x>>y;
      seiza.insert(P(x,y));
    }
    int m;
    cin >> m;
    set<P> stars;
    while(m--) {
      int x,y;cin>>x>>y;
      stars.insert(P(x,y));
    }
    P base = *seiza.begin();
    FOR(it,stars) {
      P d = *it-base;
      set<P>::iterator jt = seiza.begin();
      ++jt;
      for (;jt!=seiza.end(); ++jt)
        if (stars.count(*jt + d) == 0)
          break;
      if (jt == seiza.end()) {
        cout << d.real() << " " << d.imag() << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 0
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
string a,b;
signed main(){
	cin>>a>>b;
	if(a.size()+1!=b.size())	return puts("No"),0;
	for(int i=0;i<a.size();i++)	if(a[i]!=b[i]) return puts("No"),0;
	puts("Yes");
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
#define MAX_N 100
int selection_sort(int *arr, int size)
{
	int step = 0;
	for (int i = 0; i < size; i++)
	{
		int mini = i;
		for (int j = i; j < size; j++)
		{
			if (arr[j] < arr[mini])
			{
				mini = j;
			}
		}
		if (mini != i)
		{
			int temp = arr[i];
			arr[i] = arr[mini];
			arr[mini] = temp;
			step++;
		}
	}

	return step;
}
int main()
{
	int n;
	cin >> n;
	int arr[MAX_N];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int step = selection_sort(arr, n);
	for (int i = 0; i < n - 1; i++)
	{
		cout << arr[i] << ' ';
	}
	cout << arr[n - 1] << endl << step << endl;
	return 0;
}


Measured memory_bytes: 3112