akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>l(n+2,0),r(n+2,0),a(n+1);
  rep(i,0,n+1)cin>>a[i];
  rrep(i,0,n+1){
    l[i]=(l[i+1]+1)/2+a[i];
    r[i]=r[i+1]+a[i];
  }
  //debug(l,n+1);debug(r,n+1);
  if(l[0]<=1&&1<=r[0]){
    ll now=1;
    res=1;
    rep(i,1,n+1){
      now=min(now*2,r[i]);
      res+=now;
      now-=a[i];
      //cout<<i spa now<<endl;
    }
    cout<<res<<endl;
  }
  else cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 5576
import sys
input = sys.stdin.readline
N,Q = [int(x) for x in input().split()]
E ={i: [] for i in range(1, N+1)}
q = []
for _ in range(N-1):
  u,v = [int(x) for x in input().split()]
  E[u].append(v)
  E[v].append(u)
for _ in range(Q):
  u,v = [int(x) for x in input().split()]
  q.append((u,v))
ans = [0]*(N)
for i in range(Q):
  ans[q[i][0]-1] += q[i][1]
stk = [1]
memo = [0]*(N)
while stk:
  l = stk.pop()
  if type(l) is int:
    l = [l]
  for i in l:
    if memo[i-1]!=0:
      continue
    memo[i-1]=1
    for j in E[i]:
      if memo[j-1]==0:
        #print(i,j)
        ans[j-1] += ans[i-1]
    stk.append(E[i])
    #print(stk)
print(*ans)

Measured memory_bytes: 98672
#include <iostream>
#include <cstdio>
#include <utility>

using namespace std;

void decode(char c, int &x, int &y) {
    x = (c-'A')/3;
    y = (c-'A')%3;
}

const int d[4][2] = {
    {1, 0}, {-1, 0}, {0, 1}, {0, -1}
};

pair<int,int> memo[16][3][3];
pair<int, int> dfs(int n, int x, int y, int tx, int ty, int bx, int by) {
    if(memo[n][x][y].first != -1) return memo[n][x][y];

    if(x == bx && y == by) return memo[n][x][y] = make_pair(0, 1);
    if(n == 0) {
        if(x == tx && y == ty) return memo[n][x][y] = make_pair(1, 1);
        else return memo[n][x][y] = make_pair(0, 1);
    }
    pair<int, int> cnt = make_pair(0, 0);
    for(int i = 0; i < 4; ++i) {
        int nx = x + d[i][0];
        int ny = y + d[i][1];
        pair<int,int> tmp;
        if(nx < 0 || 3 <= nx || ny < 0 || 3 <= ny || (nx == bx && ny == by)) tmp = dfs(n-1, x, y, tx, ty, bx, by);
        else tmp = dfs(n-1, nx, ny, tx, ty, bx, by);
        cnt.first += tmp.first;
        cnt.second += tmp.second;
    }
    return memo[n][x][y] = cnt;
}

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;
        char S, T, B;
        cin >> S >> T >> B;

        int x, y;
        int tx, ty;
        int bx, by;
        decode(S, x, y);
        decode(T, tx, ty);
        decode(B, bx, by);

        for(int i = 0; i <= 15; ++i)
            for(int j = 0; j < 3; ++j)
                for(int k = 0; k < 3; ++k)
                    memo[i][j][k] = make_pair(-1, -1);
        pair<int, int> cnt = dfs(N, x, y, tx, ty, bx, by);
        printf("%.10f\n", (double)cnt.first / cnt.second);
    }
}

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

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
	{
		cout<<"bust"<<endl;
	}
	else
	{
		cout<<"win"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
x = 0
if b < 10:
    x = 10*a + b
elif b < 100:
    x = 100*a + b
else:
    x = 1000*a + b

if (x**0.5)%1 == 0:
    print("Yes")
else:
    print("No") 

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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;

  int result = pow(n, 3);

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 384
/*
AIZU ONLINE JUDGE ??????
Finding Missing Cards ???????????????
--------------------------------------------------------------*/

/*????????????????????????????????????*/
#include<iostream>//???????????????<iostream>?????????????????????
using namespace std;

/*???????????§???????????????????????????????±?????????¢??°?????????*/
int identify(char a){
	
	int index;
	
	if(a=='D'){index=4;}
	else if(a=='H'){index=2;}
	else if(a=='S'){index=1;}
	else if(a=='C'){index=3;}
	
	return index;
	
}

/*?????????????????????????????§?????????????°????????????¢??°?????????*/
char mark(int b){
	
	char outmark;
	
	if(b==4){outmark='D';}
	else if(b==2){outmark='H';}
	else if(b==1){outmark='S';}
	else if(b==3){outmark='C';}
	
	return outmark;
	
}

/*???????????¢??°*/
int main(){
	
	/*??°?????????????????°?????£?¨?*/
	int trump[14][5]={};//???????????°?????????
	int maisuu;
	cin>>maisuu;//????????????????????°?????\???
	
	
	/*?????????????????????????????\???*/
	int innumber;
	char inmark;//??\????????????????????°?????£?¨?
	
	for(int i=1;i<=maisuu;i++){
		
		cin>>inmark;
		cin>>innumber;
		trump[innumber][identify(inmark)]=1;
		
	}
	
	
	/*?????????????????????????????¨??¬*/
	for(int j=1;j<=4;j++){
	
		for(int k=1;k<=13;k++){
		
			if(trump[k][j]==0){
			
				cout<<mark(j)<<" "<<k<<"\n";
			
			}
		
		}
	
		
		
		
	}
	
	return 0;//??????
	
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define MOD 1000000007
#define int long long

signed main(){
	int n;cin>>n;
    int r=0;
    map<int,int> m;
    m[0]++;
    rep(i,n){
        int a;cin>>a;
        a+=r;
        m[a]++;
        r=a;
    }
    int ans=0;
    for(auto x:m){
        ans+=x.second*(x.second-1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

const int len=1000050;

inline int prev(int pos) {
    return (pos == 0) ? len - 1 : pos - 1;
}

inline int next(int pos) {
    return (pos == len - 1) ? 0 : pos + 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int n; cin >> n;
 
    vector<int> li(len);
    int fi=0, la=0;
 
    string op;
    int key;
    for (int i=0; i<n; ++i) {
        cin >> op;
        if (op[0] == 'i') {
            cin >> key;
            fi = prev(fi);
            li[fi] = key;
        } else if (op.size() > 6 && op[6] == 'F') {
            while (li[fi] == -1) {
                fi = next(fi);
            }
            fi = next(fi);
        } else if (op.size() > 6 && op[6] == 'L') {
            while (li[prev(la)] == -1) {
                la = prev(la);
            }
            la = prev(la);
        } else {
            cin >> key;
            for (int j=fi; j!=la; j=next(j)) {
                if (li[j] == key) {
                    li[j] = -1;
                    break;
                }
            }
        }
    }
 
    bool nospace = true;
    for (int i=fi; i!=la; i=next(i)) {
        if (li[i] == -1) continue;
        if (nospace) {
            cout << li[i];
            nospace = false;
        } else {
            cout << " " << li[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4968
#include<bits/stdc++.h>
using namespace std;
char a[100005];int l,i,ans;
int main(){
	scanf("%s",a);
	l=strlen(a);
	for(i=1;i<l;i++)
		if(a[i]!=a[i-1])
			ans++;
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  const int n = 3;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  cout << (arr[0] + arr[1] == arr[2] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long y = sc.nextLong();
		int ans = 0;
		while(x<=y){
			x*=2;
			ans++;
		}
		System.out.println(ans);
		return;
	}
}

Measured memory_bytes: 23636
#include <stdio.h>

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

    int i = 0, j;

    for(i=1; i<10; i++){
        for(j=0; j<10; j++){
            if(n == i * j){
                printf("Yes");
                return 0;
            }
        }
    }

    printf("No");  
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f

using namespace std;

int v[230010];

pair<int, int> arbp[550010];
pair<int, int> arbq[550010];

void build(pair<int, int>* arb, int par, int nod, int st, int dr)
{
    if(st == dr)
    {
        if((par && st % 2 == 0) || (!par && st % 2 != 0))
            arb[nod] = make_pair(v[st], st);
        else arb[nod] = make_pair(inf, inf);
        return;
    }
    int mij = (st + dr) / 2;
    build(arb, par, nod * 2, st, mij);
    build(arb, par, nod * 2 + 1, mij + 1, dr);
    arb[nod] = min(arb[nod * 2], arb[nod * 2 + 1]);
}

pair<int, int> query(pair<int, int>* arb, int nod, int st, int dr, int ist, int idr)
{
    if(ist <= st && dr <= idr)
    {
        return arb[nod];
    }
    int mij = (st + dr) / 2;
    pair<int, int> q1 = make_pair(inf, inf), q2 = make_pair(inf, inf);
    if(ist <= mij)
        q1 = query(arb, nod * 2, st, mij, ist, idr);
    if(idr > mij)
        q2 = query(arb, nod * 2 + 1, mij + 1, dr, ist, idr);
    return min(q1, q2);
}

int n;
using vecpair = vector<pair<int, int> >;
using parb = pair<int, int>*;

struct Node
{
    Node(int st, int dr, parb arb1, parb arb2) :
        st(st), dr(dr), arb1(arb1), arb2(arb2)
    {
        calcPair();
    }
    int st, dr;
    parb arb1, arb2;
    pair<int, int> p;
    pair<int, int> idx;

    void calcPair()
    {
        auto start = query(arb1, 1, 1, n, st, dr);
        auto fin = query(arb2, 1, 1, n, start.second + 1, dr);
        p = make_pair(start.first, fin.first);
        idx = make_pair(start.second, fin.second);
    }

    bool operator<(const Node& n) const
    {
        return p > n.p;
    }
};

int main()
{
    //freopen("in.in", "r", stdin);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    build(arbp, 1, 1, 1, n);
    build(arbq, 0, 1, 1, n);

    priority_queue<Node> q;
    q.push(Node(1, n, arbq, arbp));
    while(!q.empty())
    {
        Node n = q.top();
        cout << n.p.first << ' ' << n.p.second << ' ';
        q.pop();
        if(n.idx.first != n.st)
            q.push(Node(n.st, n.idx.first - 1, n.arb1, n.arb2));
        if(n.idx.first != n.idx.second - 1)
            q.push(Node(n.idx.first + 1, n.idx.second - 1, n.arb2, n.arb1));
        if(n.idx.second != n.dr)
            q.push(Node(n.idx.second + 1, n.dr, n.arb1, n.arb2));
    }

    return 0;
}


Measured memory_bytes: 13556
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var N = NextInt();
		var D = NextInt();
		var X = NextInt();

		for (var i = 0; i < N; i++) {
			var A = NextInt();
			X += 1 + (D - 1) / A;
		}
		WriteLine(X);
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}

Measured memory_bytes: 13268
#include <stdio.h>

int main(void)
{
	int N;
	int a[4];
	int L, S;
	int i, j, cnt, tmp;
	
	while (scanf("%d", &N) != EOF){
		if (N == 0000){
			break;
		}
		else if (N % 1111 == 0){
			printf("NA\n");
		}
		else {
		
			cnt = 0;
			while (N != 6174){
				a[0] = N / 1000;
				a[1] = N / 100 % 10;
				a[2] = N / 10 % 10;
				a[3] = N % 10;
				
				for (i = 0; i < 4; i++){
					for (j = 1; j < 4; j++){
						if (a[j - 1] < a[j]){
							tmp = a[j];
							a[j] = a[j - 1];
							a[j - 1] = tmp;
						}
					}
				}
				L = a[0] * 1000 + a[1] * 100 + a[2] * 10 + a[3];
				
				for (i = 0; i < 4; i++){
					for (j = 1; j < 4; j++){
						if (a[j - 1] > a[j]){
							tmp = a[j];
							a[j] = a[j - 1];
							a[j - 1] = tmp;
						}
					}
				}
				S = a[0] * 1000 + a[1] * 100 + a[2] * 10 + a[3];
				
				N = L - S;
				cnt++;
			}
			printf("%d\n", cnt);
		}
	}
	
	
	return (0);
}

Measured memory_bytes: 608
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define ll long long int
#define lim 100010
#define INF 1e9
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define ABS(x) ((x)>0?(x):-(x))


int main(void){
	int n,x;
	scanf("%d%d",&n,&x);
	int d=0;
	int c=1;
	int l;
	for(int i=0;i<n;i++){
		scanf("%d",&l);
		d+=l;
		if(d<=x)c++;
	}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    if((a-b)%2==0) cout<<(b-a)/2;
    else cout<<min(a+(b-a-1)/2,n-b+1+(b-a-1)/2);
}
   

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var N, M int
	fmt.Scan(&N, &M)

	ans := 0
	for i := 1 ; i <= N-1 ; i++{
		ans += i
	}
	for i := 1 ; i <= M-1 ; i++{
		ans += i
	}
	fmt.Println(ans)
}

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

void solve() {
  int n; cin >> n;
  vector<int> cnt(4, 0);
  const vector<string> d = {"AC", "WA", "TLE", "RE"};
  while (n--) {
    string s; cin >> s;
    for (int i=0; i<4; ++i) {
      if (s == d[i]) {
        ++cnt[i];
        break;
      }
    }
  }
  for (int i=0; i<4; ++i) {
    cout << d[i] << " x " << cnt[i] << '\n';
  }
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))

using lli = long long int;

std::vector<int> A, B;

inline bool subset(int a, int b){ // a ⊆ b
    return (a | b) == b;
} 

int main(void){
    // 入力
    int n, k; scanf("%d%d", &n, &k);
    A.resize(n); B.resize(n);
    REP(i, n) scanf("%d%d", &A[i], &B[i]);

    lli ans = 0;
    REP(i, n) if(subset(A[i], k)) ans += B[i];
    // 候補を全探索すればいい(はず)
    int t = 0;
    while((1 << t) <= k){
        lli subAns = 0;
        int tt = 1 << t; t++;
        int koho = (k | (tt - 1)) ^ tt;
        // ビットが立って居ないものはやらない
        if(koho > k) continue;
        
        REP(i, n) if(subset(A[i], koho)) subAns += B[i];
        
        if(ans < subAns) ans = subAns;
    }

    // 出力
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;

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

int main() {
    ios_base::sync_with_stdio(false);
    int k;
    cin >> k;
    ll ans=0;
    rep(a,k) {
        rep(b,k) {
            rep(c,k) ans+=gcd(a+1,gcd(b+1,c+1));
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    int M = 1 << N;

    vector<int> S(M);
    rep(i, M) cin >> S[i];

    sort(S.begin(), S.end());
    
    vector<bool> used(M, false);
    vector<int> V;
    V.push_back(S[M - 1]);
    used[M - 1] = true;

    rep(i, N) {
        int n = V.size();
        rep(j, n) {
            int index = lower_bound(S.begin(), S.end(), V[j]) - S.begin();
            if (!index) {
                puts("No");
                return 0;
            }
            index--;

            V.push_back(S[index]);
            used[index] = true;

            S.erase(S.begin() + index);
        }
    }

    puts("Yes");
}

Measured memory_bytes: 2428
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define abs(a) a > 0 ? a : -a
 
int main(void) {
  int a, b, c, ta = 0, tb = 0, tc = 0;
  while(scanf("%d%d%d", &a, &b, &c) != EOF) {
    int t;
    if(a < b) t = a, a = b, b = t;
    if(a < c) t = a, a = c, c = t;
    if(b < c) t = c, c = b, b = t;
    if(a >= b + c) break;
    double d;
    double at = (double)a, bt = (double)b, ct = (double)c;
    d = (bt * bt + ct * ct - at * at) / (2 * bt * ct);
    if(d < 0) {
      ta++;
    } else if(d > 0) {
      tb++;
    } else {
      tc++;
    }
  }
  printf("%d %d %d %d\n", ta + tb + tc, tc, tb, ta);
  return 0;
}


Measured memory_bytes: 2688
#!/usr/bin/ruby
def dfs(s,_l,_r)
	r=''
	i=_l
	n=nil
	while i<_r
		if ('0'..'9').include?(s[i])
			if !n
				n=s[i].to_i
			else
				n=n*10+s[i].to_i
			end
			i+=1
		elsif s[i]=='('
			n=1 if !n
			cnt=1
			j=i+1
			while cnt>0
				if s[j]=='('
					cnt+=1
				elsif s[j]==')'
					cnt-=1
				end
				j+=1
			end
			r0=dfs(s,i+1,j-1)
			n.times{
				r+=r0
				return r if r.size>$n
			}
			n=nil
			i=j
		else
			n=1 if !n
			r+=s[i]*n
			n=nil
			i+=1
		end
	end
	r
end
i=0
loop{
	s,_=gets.split
	break if s=='0'
	$n=_.to_i
	r=dfs(s,0,s.size)
	puts r.size>$n ? r[$n] : '0'
}

Measured memory_bytes: 17936
program pr3
  implicit none
  integer :: n, k, i
  integer(8),allocatable :: a(:)
  integer(8) :: r
  
  read(*,*) n, k
  allocate(a(n))
  read(*,*) a
  
  do i = k+1, n
     r = a(i) - a(i-k)
     if ( r >= 1 ) then
        write(*,'(a)') 'Yes'
     else
        write(*,'(a)') 'No'
     end if
  end do
  
  stop
end program pr3


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

int main(){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    
    if(0<=(x-r)&&(x+r)<=w&&(y-r)>=0&&(y+r)<=h){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;

}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
using namespace std;
int cal_min(int t){
  return t/100 * 60 + t%100;
}
int main(){
  int n;
  int st,ft;
  while(cin >> n >> st >> ft && n){
	vector<int> time(24*60+2,0);
	for(int i = 0;i < n;i++){
	  int q;
	  cin >> q;
	  for(int j = 0;j < q;j++){
		int ts,tf;
		cin >> ts >> tf;
		time[cal_min(ts)]++;
		time[cal_min(tf)]--;
	  }
	}
	for(int i = cal_min(st);i < cal_min(ft);i++){
	  time[i+1]+=time[i];
	}
	int ans = 0;
	int cnt = 0;
	for(int i = cal_min(st);i < cal_min(ft);i++){
	  if(time[i] == n){
		ans = max(ans,cnt);
		cnt = 0;
	  }
	  else{
		cnt++;
	  }
	}
	ans = max(ans,cnt);
	cout << ans << endl;

	
  }
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

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


int main()
{
	string S;
	cin >> S;
	if (S == "ABC")
		PRINT("ARC");
	else
		PRINT("ABC");
	return 0;
}


Measured memory_bytes: 3632
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
pow = 0
ans = 0
for a, b in zip(A, B):
    ans += a if pow >= a else pow
    a = 0 if pow >= a else a - pow
    ans += a if a <= b else b
    pow = b - a if b >= a else 0
ans += A[N] if pow >= A[N] else pow
print(ans)


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

const int MAXN = 2010;
const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int n, m, K;
int f[2][MAXN][2], pre[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m >> K;
	int now = 1, lst = 0, ans = 0;
	f[now][0][0] = 1;
	for (int len = 1, lim = (n + m - 1) / (K - 1); len <= lim; ++len) {
		std::swap(lst, now);
		for (int i = 0; i <= m; ++i) {
			reduce(pre[i] = f[lst][i][0] + f[lst][i][1] - mod);
			f[now][i][0] = pre[i];
			if (i) {
				reduce(pre[i] += pre[i - 1] - mod);
				f[now][i][1] = pre[i - 1];
				if (i - K >= 0) reduce(f[now][i][1] -= pre[i - K]);
			}
			if ((m - i) % (K - 1) == 0 && (K - 1) * len + 1 - i <= n)
				reduce(ans += f[now][i][1] - mod);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
//期望值:可能发生的事情的贡献*事情发生的概率 
//记dp[i][j][k]为当前剩下1个,2个,3个寿司的盘子时期望选择次数
//那么dp[i][j][k]=dp[i-1][j][k]*(i/n)+dp[i+1][j-1][k]*(j/n)+dp[i][j+1][k-1]*(k/n)+dp[i][j][k]*((n-i-j-k)/n)+1
//     目标      吃一个事件发生的贡献 吃两个事件发生的贡献 	吃三个事件发生的贡献    吃空事件发生的贡献      吃一次的花费
//dp[i][j][k]*((i+j+k)/n)=dp[i-1][j][k]*(i/n)+dp[i+1][j-1][k]*(j/n)+dp[i][j+1][k-1]*(k/n)+1;
//移项可得
//dp[i][j][k]*(i+j+k)=dp[i-1][j][k]*i+dp[i+1][j-1][k]*j+dp[i][j+1][k-1]*k+n
//dp[i][j][k]=dp[i-1][j][k]*i/(i+j+k)+dp[i+1][j-1][k]*j/(i+j+k)+dp[i][j+1][k-1]*k/(i+j+k)+n/(i+j+k)
#include<iostream>    
#include<cstdio>
#include<cstring>
using namespace std;
double dp[301][301][301];
int a[4],x,n;
double DFS(int a1,int a2,int a3)
{
	if(a1==0&&a2==0&&a3==0)
	{
		return 0;
	}
	if(dp[a1][a2][a3]>=0)
	{
		return dp[a1][a2][a3];
	}
	int sum=a1+a2+a3;
	dp[a1][a2][a3]=1.0*n/sum;
	if(a1)
	dp[a1][a2][a3]+=1.0*DFS(a1-1,a2,a3)*(1.0*a1/sum);
	if(a2)
	dp[a1][a2][a3]+=1.0*DFS(a1+1,a2-1,a3)*(1.0*a2/sum);
	if(a3)
	dp[a1][a2][a3]+=1.0*DFS(a1,a2+1,a3-1)*(1.0*a3/sum);
	return dp[a1][a2][a3];	
}
int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		a[x]++;
	}
	printf("%.15lf",DFS(a[1],a[2],a[3]));
	return 0;
}

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

int main(){
  int64_t X;
  cin >> X;
  int64_t a=100;
  for(int i=1;;i++){
    a*=1.01;
    if(a>=X){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>

using namespace std;
int main()
{
	string c;
	cin>>c;
	if (c.find("AC") != std::string::npos)
		puts("Yes");
	else
	cout<<"No";

	return 0;
}
	


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MOD 1000000007

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

int field[128][128];
int dx[2][6]={{-1,0,1,0,-1,-1},
	      {0,1,1,1,0,-1}};
int dy[2][6]={{-1,-1,0,1,1,0},
	      {-1,-1,0,1,1,0}};
int H, W;

void dfs(int y, int x){
  if(field[y][x]==1||field[y][x]==2) return;
  //  cout << y << " " << x << endl;
  field[y][x] = 2;
  for(int d = 0; d < 6; d++){
    int ny=y+dy[(y%2)][d], nx=x+dx[(y%2)][d];
    if(ny<0||ny>H+1||nx<0||nx>W+1) continue;
    dfs(ny, nx);
  }
  return;
}

int main(){
  cin >> W >> H;
  memset(field, -1, sizeof(field));
  rep(i, H) rep(j, W) cin >> field[i+1][j+1];
  for(int i = 0; i < H; i++){dfs(i, 0);dfs(i, W+1);}
  for(int i = 0; i < W; i++){dfs(0, i);dfs(H+1, i);}
  int res = 0;
  /*  for(int i = 0; i <= H+1; i++){
    for(int j = 0; j <= W+1; j++) cout << field[i][j] << " ";
    cout << endl;
    }*/
  for(int i = 0; i <= H+1; i++){
    for(int j = 0; j <= W+1; j++){
      if(field[i][j]!=2) continue;
      for(int d = 0; d < 6; d++){
	int ny=i+dy[(i%2)][d], nx=j+dx[(i%2)][d];
	if(ny<0||ny>H+1||nx<0||nx>W+1) continue;
	if(field[ny][nx]==1) res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}

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

using lli = long long;
using pii = pair<int, int>;
using pll = pair<lli, lli>;
using Double = long double;
template<typename T>
using Vector = vector<vector<T>>;
template<typename T>
using Prior = priority_queue<T>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;

#define IOS() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define X first
#define Y second
#define Push push_back
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()

void solve() {
	string s;
	cin >> s;

	int left = 0, mleft = 0, ans = 0;
	for (auto x : s) {
		left += x == 'g';
		if (x == 'g' and mleft) --mleft, ++ans;
		else if (x == 'g') ++mleft;
		else if (mleft) --mleft;
		else ++mleft, --ans;
	}

	cout << ans << "\n";
}

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

Measured memory_bytes: 512
package main

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

func main() {
	numMap := make(map[string]string)
	n := intStdin()
	for i := 0; i < n; i++ {
		s := strStdin()
		if _, ok := numMap[s]; ok {
			delete(numMap, s)
		} else {
			numMap[s] = ""
		}
	}
	fmt.Println(len(numMap))
}

/* template */
var sc = bufio.NewScanner(os.Stdin)

// 文字列を1行取得
func strStdin() (stringInput string) {
	sc.Scan()
	stringInput = sc.Text()
	stringInput = strings.TrimSpace(stringInput)
	return
}

// 整数値1つ取得
func intStdin() (num int) {
	stringInput := strStdin()
	num, _ = strconv.Atoi(strings.TrimSpace(stringInput))
	return
}

// 空白や空文字だけの値を除去したSplit()
func splitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}
	return
}

// デリミタで分割して文字列スライスを取得
func splitStrStdin(delim string) (stringReturned []string) {
	// 文字列で1行取得
	stringInput := strStdin()

	// 空白で分割
	stringReturned = splitWithoutEmpty(stringInput, delim)

	return
}
/* template */

Measured memory_bytes: 11264
n=int(input())
v=list(map(int,input().split()))
v.sort()
ans=0
for i in range(n-1):
    if i==0:
        t=(v[i]+v[i+1])/2
        ans=max(ans,t)
        continue    
    t=(t+v[i+1])/2
    ans=max(ans,t)
print(ans)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
ll N[maxn];
ll pre[maxn],en[maxn];
int main()
{
	int n;cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&N[i]);
	}
	for(int i=0;i<n;i++)
	{
		if(i==0)
		pre[i]=N[i];
		else pre[i]=__gcd(pre[i-1],N[i]);
		//cout<<"i:"<<i<<" "<<"pre:"<<pre[i]<<endl;
	}
	for(int i=n-1;i>=0;i--)
	{
		if(i==n-1) en[i]=N[i];
		else en[i]=__gcd(en[i+1],N[i]);
		//cout<<"i:"<<i<<" "<<"en:"<<en[i]<<endl;
	}
	ll maxx=0;
	for(int i=0;i<n;i++)
	{
		if(i==0) maxx=max(maxx,en[1]);
		else if(i==n-1) maxx=max(maxx,pre[n-2]);
		else maxx=max(maxx,__gcd(pre[i-1],en[i+1]));
	}
	cout<<maxx<<endl;
 } 

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

int main(){

int n;
cin >> n;
int a[n],sum=0;

for (int i = 0;i < n;i++) {
    cin >> a[i];
    sum += a[i]%2;
}
sort (a,a+n);
bool can = true;

if (sum%2 != 0){
    can = false;
}
if(can)
    cout << "YES" << endl;
else 
    cout << "NO" << endl;

}

Measured memory_bytes: 640
# A - 高橋君とホテルイージー

# 1  軒のホテルがあります。 このホテルの宿泊費は、次のようになっています。

# 最初の K 泊までは、1 泊あたり X 円
# K+1 泊目以降は、1 泊あたり Y 円

# このホテルに N 泊連続で宿泊する と 宿泊費は合計で何円になるか

# N 宿泊数　を標準入力から得る
N = int(input())
# K 最初の拍数　を標準入力から得る
K = int(input())
# X K日間の料金  を標準入力から得る
X = int(input())
# Y K+1~Nまでの料金 を標準入力から得る
Y = int(input())
# print(N, K, X, Y)

# K 泊までの料金を計算
# K * X
first_charge = K * X
# print(first_charge)

# K + 1 ~ N までの料金を計算
# (N - K) * Y
second_charge = (N - K) * Y
# print(second_charge)

# 合算
# K > N の場合は、N * X 円
if K >= N:
    answer = N * X
else:
    answer = first_charge + second_charge

# 結果を出力
print(answer)


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

int main(){
	int m,n;scanf("%d%d",&m,&n);
	int Max=0;
	rep(i,m){
		int cnt=0;
		rep(j,n){
			int a;scanf("%d",&a);
			if(a)cnt++;
		}
		Max=max(Max,cnt);
	}
	printf("%d\n",Max);
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define setbits __builtin_popcount 
#define big 1e9+7;
using namespace std;
ll n,k,flag,mod,m = big;
pair <ll,ll> p;
ll a[100005][3],dp[100005][3];
string s;
int main()
{
	IOS;
	ll b,j;
	cin>>n;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < 3; ++j)
			cin>>a[i][j];

	for (int i = 0; i < n; ++i)
	{
		for(int j = 0; j < 3; ++j)
			dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+a[i][j];
	}
	// for (int i = 0; i < n; ++i)
	// {
	// 	b = *max_element(a[i],a[i]+3);
	// 	dp[i] = b +dp[i-1]*(i != 0);
	// 	for (j = 0; j < 3; ++j)
	// 	{
	// 		if(b == a[i][j])
	// 		{
	// 			if(k == j)
	// 			{
	// 				if(p.second >= a[i][j])
	// 					p.first = i,p.second = a[i][j];
	// 				a[i][j] = -1;
	// 				dp[i] -= p.second - *max_element(a[p.first],a[p.first]+3);
	// 			}
	// 			else
	// 			{
	// 				flag = 0;
	// 				p.first = i,p.second = a[i][j];
	// 				a[i][j] = -1,k = j;
	// 			}
	// 			break;
	// 		}
	// 	}
	// 	cout<<dp[i]<<endl;
	// 	// dp[i] = min(dp[i-1],dp[i]);
	// }
	cout<<*max_element(dp[n-1],dp[n-1]+3);
    return 0;
}

Measured memory_bytes: 4992
n=int(raw_input())
d={}
for i in range(n):
    x=str(raw_input())
    try:
        d[x]+=1
    except:
        d[x]=0

key_max = max(d.keys(), key=(lambda k: d[k]))
x=d[key_max]
ans=[]
for i in d:
    if(d[i]==x):
        ans.append(i)
ans.sort()
for i in ans:
    print i

Measured memory_bytes: 35752
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		pr.println(n * n * n);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 22228
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s,sl="",sr=""; cin>>s;
    int q,cnt; cin>>q;
    rep(i,q){
        int t; cin>>t;
        if(t==1){
            cnt++;
        }
        else{
            int f; cin>>f;
            string c; cin>>c;
            if((f+cnt)%2) sl=sl+c;
            else sr=sr+c;
        }
    }
    reverse(al(sl));
    s=sl+s+sr;
    if(cnt%2){
        reverse(al(s));
        cout<<s<<endl;
    }
    else cout<<s<<endl;
}


Measured memory_bytes: 1408
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

bool used[100010];
int dp[100010];
vector<PII> g[100010];
bool flag;

void dfs(int x) {
  // cout << "x:" << x << endl;
  used[x] = true;
  for(PII i: g[x]) {
    // cout << "i:" << i.first << endl;
    if(!used[i.first]) {
      dp[i.first] = dp[x] + i.second;
      // cout << "dp:" << dp[i.first] << endl;
      // if(dp[i.first] > 1e9) {
      //   flag = false;
      //   break;
      // }
      dfs(i.first);
    } else {
      if(dp[i.first] != dp[x] + i.second) {
        flag = false;
        break;
      }
    }
  }
}

//グラフの隣接リスト
VI G[100010];
//頂点の入次数を管理
int h[100010];
signed main(void)
{
  int n, m;
  cin >> n >> m;
  REP(i, m) {
    int l, r, d;
    cin >> l >> r >> d;
    l--, r--;
    g[l].PB({r, d});
    G[l].PB(r);
    h[r]++;
  }

  int v = n;
  //入次数が0の頂点の集合
  stack<int> st;

  //入次数が0の頂点であればstに追加
  REP(i, v) if(h[i] == 0) st.push(i);

  //ソートされた後のグラフ
  VI ans;
  //stがなくなるまでループ
  while(st.size()) {
    //stの集合のから一つ取り出す
    int i = st.top(); st.pop();
    ans.push_back(i);
    for(auto& j: G[i]) {
      //隣接する頂点の入次数をマイナス1
      h[j]--;
      //これによって入次数が0になればstに追加
      if(h[j] == 0) st.push(j);
    }
  }

  if(ans.size() != n) {
    cout << "No" << endl;
    return 0;
  }

  REP(i, n) {
    if(!used[ans[i]]) {
      flag = true;
      dp[ans[i]] = 0;
      dfs(ans[i]);
      if(!flag) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 16888
import java.util.Scanner;

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

	public static void main(String[] args) {
		
		
		while ( sc.hasNext() ){
		
		double a = sc.nextInt();
		double b = sc.nextInt();
		
		
		double x = a * b ;
		double S = x / 3.305785 ;
		
				System.out.println( S );
	
		}

	}

}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

struct union_find {
  typedef vector<int> vi;
  vi par,rank,cnt;
  int n;

  union_find(int n) : n(n) {
    par = vi(n); rank = vi(n,0); cnt = vi(n,1);
    for (int i = 0; i < n; i++) par[i] = i;
  }

  int find(int a) {
    if (par[a] == a) return a;
    return par[a] = find(par[a]);
  }

  void unite(int a, int b) {
    a = find(a); b = find(b);

    if (a == b) return;
    if (rank[a] < rank[b]) {
      par[a] = b; cnt[b] += cnt[a];
    } else {
      par[b] = a; cnt[a] += cnt[b];
      if (rank[a] == rank[b]) rank[a]++;
    }
  }

  int count(int a) { return cnt[find(a)]; }

  bool same(int a, int b) { return find(a) == find(b); }
};

int n,m;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> m;

  union_find uf(n);

  forn(i,m) {
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    uf.unite(x,y);
  }

  set<int> s;
  forn(i,n) {
    s.insert(uf.find(i));
  }

  cout << s.size() << endl;

  return 0;
}


Measured memory_bytes: 6144
N,K=map(int,input().split())
S=[-1]*N
for _ in[0]*K:a,b=map(int,input().split());S[a-1]=b-1
dp=[0]*9
st,nd=S[:2]
if st+1:
 if nd+1:dp[st*3+nd]=1
 else:dp[st*3:st*4]=[1]*3
elif nd+1:dp[nd::3]=[1]*3
else:dp=[1]*9
for i in range(2,N):
 cur=S[i];tmp=[0]*9
 if cur+1:
  for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
 else:
  for cur in range(3):
   for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)
 dp=tmp[:]
print(sum(dp)%10000)


Measured memory_bytes: 5612
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll AmountStartBy(ll n){
    ll ret=0;
    for(ll tenPow=1;n*tenPow<=N;tenPow*=10){
        if((n+1)*tenPow<N){
            ret+=tenPow;
        }else{
            ret+=N-n*tenPow+1;
        }
    }
    return ret;
}
ll AmountEndWith(ll n,ll t){
    ll len=to_string(n).length();
    string s="1";
    for(ll i=0;i<len-2;i++){
        s+='0';
    }
    ll m=(len==1)?0:stoll(s);
    if(n%10>=t){
        return n/10+1;
    }else{
        return n/10;
    }
}
ll Amount(ll s,ll t){
    ll ret=0;
    for(ll tenPow=1;s*tenPow<=N;tenPow*=10){
        if((s+1)*tenPow>N && tenPow!=1 ){//最高桁数で、一桁目がs
            ret+=AmountEndWith(N-N/tenPow*tenPow,t);
            // cout<<"2:"<<AmountEndWith(N-N/tenPow*tenPow,t)<<endl;
        }else{
            if(tenPow==1){
                if(s!=t)continue;
                ret+=AmountEndWith(9,t);
                // cout<<"1:"<<AmountEndWith(9,t)<<endl;
            }else{
                ret+=AmountEndWith(tenPow-1,t);
                // cout<<"1:"<<AmountEndWith(tenPow-1,t)<<endl;
            }
        }
    }
    return ret;
}
int main(){
    cin>>N;
    ll ans=0;
    for(ll i=1;i<10;i++){
        for(ll j=1;j<10;j++){
            // if(Amount(i,j)*Amount(j,i)!=0){
            //     cout<<i<<","<<j<<":"<<Amount(i,j)<<endl;
            //     cout<<j<<","<<i<<":"<<Amount(j,i)<<endl;
            //     cout<<endl;
            // }
            ans+=Amount(i,j)*Amount(j,i); 
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define int         long long
#define ld          long double
#define fastio      ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define sz(x)       (int)x.size()
#define mod         1000000007
#define mod2        998244353

using namespace std;

/*int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n>>1))%mod)%mod;
    return power((a*a)%mod,n>>1)%mod;
}
int gcd(int a,int b)
{
    if(a%b == 0)return b;
    return gcd(b,a%b);
}*/
int n,k;

signed main()
{
    fastio;
    cin >> n >> k;
    if(n%k == 0)cout << 0;
    else cout << 1;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 998244353
#define INV_10 299473306
#define INF 1000000000
#define PI 3.14159265358979323846
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	double a, b, h, m, ang1, ang2, ang, ans;
	cin >> a >> b >> h >> m;
	ang1=(60.0*h+m)*2.0*PI/720.0;
	ang2=m*2.0*PI/60.0;
	ang=fabs(ang1-ang2);
	ans=sqrt(a*a+b*b-2*a*b*cos(ang));
	cout << fixed << setprecision(9) << ans << '\n';
}

Measured memory_bytes: 4304
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;

int main() {
	cin >> n;
	cout << n / 3 << endl;
}

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

#define int long long

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

int H, W, N;
int a[100000], b[100000];
int sum = 0;
int ans[9] = {};
map<int, set<int> > cds;
set<pair<int, int> > used;

signed main() {
    cin >> H >> W >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
        cds[a[i]].insert(b[i]);
    }
    for (int i = 0; i < N; i++) {
        for (int j = -1; j <= 1; j++) {
            for (int k = -1; k <= 1; k++) {
                if (used.find(make_pair(a[i] + j, b[i] + k)) != used.end() || a[i] + j <= 1 || a[i] + j >= H || b[i] + k <= 1 || b[i] + k >= W) {
                    continue;
                }
                used.insert(make_pair(a[i] + j, b[i] + k));
                int cur = 0;
                for (int l = -1; l <= 1; l++) {
                    for (int m = -1; m <= 1; m++) {
                        if (cds.find(a[i] + j + l) != cds.end() && cds[a[i] + j + l].find(b[i] + k + m) != cds[a[i] + j + l].end()) {
                            cur++;
                        }
                    }
                }
                ans[cur - 1]++;
                sum++;
            }
        }
    }
    cout << (H - 2) * (W - 2) - sum << endl;
    for (int i = 0; i < 9; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 72064
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;
  vector<int> vs(N);
  int sum = 0;
  F0R(i, N) {
    cin >> vs[i];
    sum += vs[i];
  }

  int result = 0;

  // i個取り出す
  FOR(i, 1, min(N + 1, K + 1)) {

    int rest = N - i;
    int trash = K - i;

    // 取らない宝石の位置
    F0R(j, i + 1) {

      // restを除き取り出す
      vector<int> as(i);
      if (j) copy(vs.begin(), vs.begin() + j, as.begin());
      if (j + rest < N) copy(vs.begin() + j + rest, vs.end(), as.begin() + j);
      sort(rng(as));
      //Print(as);

      // 戻せるだけ戻す
      int t = min<int>(lower_bound(rng(as), 0) - as.begin(), trash);
      int score = 0;
      FOR(k, t, i) {
        score += as[k];
      }
      chmax(result, score);
    }

  }
  cout << result;
}
#endif


Measured memory_bytes: 3632
//
//  main.cpp
//  ABC_098_B
//
//  Created by Joe Mori on 2020/06/08.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

//#include <iostream>
#include<bits/stdc++.h>
int main() {
    // insert code here...
    std::string str;
    int a;
    std::cin>>a;
    std::cin>>str;
    int c=0;
//    std::vector<std::string>b;
    int count=0,ans=0;
    for(int i=0;i<str.size()-1;i++){
        for(int j=0;j<=i;j++){
//            std::cout<<i<<"個:"<<j<<std::endl;
            for(int l=j;l>0;l--){
                if(str[j]==str[l-1]){
                    c=1;
                    break;
                }
            }
            if(c==1){
                c=0;
                continue;
            }
            for(int k=i+1;k<str.size();k++){
                if(str[j]==str[k]){
                    count++;
                    break;
                }
            }
        }
        ans=std::max(ans,count);
        count=0;
    }
    std::cout<<ans<<std::endl;
    return 0;
}


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

int main(){
    int A, B, i, a, b, c, d, tmp;
    int ans = 0;

    cin >> A >> B;

    for (i = A; i < B+1; i++){
        tmp = i;;
        a = tmp%10;
        tmp = tmp/10;
        b = tmp%10;
        tmp = tmp/100;
        c = tmp%10;
        d = tmp/10;

        if (a == d && b == c)
            ans++;
    }

        cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    ll A, B, N;
    cin>>A>>B>>N;
    ll x = min(B-1, N);
    cout<<(A*x)/B - A*(x/B)<<endl;
}



Measured memory_bytes: 3644