akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//nCr
long long Comb (long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);vlin(a,N);
  
  bool NG=false;
  
  rep(i,N){
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0)
        NG=true;
    }
  }
  
  if(NG)
    cout<<"DENIED";
  else cout<<"APPROVED";
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    char s[n];
    cin>>s;
    if(s[k-1]=='A') s[k-1]='a';
    else if(s[k-1]=='B') s[k-1]='b';
    else if(s[k-1]=='C') s[k-1]='c';
    cout<<s<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int small[] = {0, 20, 19, 20, 19, 20, 19, 20, 19, 20, 19};
int bigy = 20 * 10;
int smally = (19 + 20) * 5;

int main() {

	int n;
	cin >> n;
	rep(i, n){
		int y, m, d;
		cin >> y >> m >> d;
		
		if(y == 1000){
			cout << 0 << endl;
			continue;
		}
		ll ans = 0;
		ans += (((999 - y) / 3) * (2*smally + bigy));
		if((999 - y) % 3 == 1) ans += bigy;
		if((999 - y) % 3 == 2) ans += bigy + smally;
		REP(j, m + 1, 11) ans += (y % 3 == 0 ? 20 : small[j]);
		ans += (y % 3 == 0 ? 21 - d : small[m] - d + 1);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 2976
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

struct card {
    char suit;
    int value;
};

//マージソート用関数 merge, mergesort
void merge(card A[], int left, int mid, int right) {
    card L[50001], R[50001];
    int n1 = mid - left;
    int n2 = right - mid;
    
    for (int i = 0; i < n1 + 1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + 1 + i];

    L[n1 + 1].value = INFINITY;
    R[n2].value = INFINITY;

    int li = 0, rj = 0;
    for (int ak = left; ak < right + 1; ak++ ) {
        if (L[li].value <= R[rj].value) {
            A[ak] = L[li];
            li++;
        } else {
            A[ak] = R[rj];
            rj++;
        }
    }
}

void mergeSort(card A[], int left, int right) {
    if (left == right) return;

    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid + 1, right);
    merge(A, left, mid, right);
}

// クイックソート用関数 parttion, quickSort
int partition(card A[], int p, int r) {
    int base = A[r].value;

    int separator_idx = p-1;
    int exp_idx = p;

    for(; exp_idx <= r ; exp_idx++) {
        if(A[exp_idx].value <= base) {
            separator_idx++;
            swap(A[exp_idx], A[separator_idx]);
        }
    }
    return separator_idx;
}

void quickSort(card A[], int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quickSort(A, p, q - 1);
        quickSort(A, q + 1, r);
    }
}

int main(void) {
    int n;
    cin >> n;
    card A[100000], B[100000];
    bool stable = true;

    for (int i = 0; i < n; i++) {
        cin >> A[i].suit >> A[i].value;
        B[i] = A[i];
    }

    mergeSort(A, 0, n-1);
    quickSort(B, 0, n-1);

    for (int i = 0; i < n; i++) {
        if ( A[i].suit != B[i].suit ) stable = false;
    }

    if (stable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    for (int i = 0; i < n; i++) {
        cout << B[i].suit << " " << B[i].value << endl;
    }

    return 0;
}


Measured memory_bytes: 5376
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner kb=new Scanner(System.in);
        while(kb.hasNext()){
        	String str1=kb.next();
        	String str2=kb.next();
        	String str3=kb.next();
        	char a[]=str1.toCharArray();
        	char b[]=str2.toCharArray();
        	char c[]=str3.toCharArray();
        	System.out.print(a[0]);
        	System.out.print(b[1]);
        	System.out.println(c[2]);
        }
              
    }

}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main(){
    string s; cin >> s;
    s[5] = ' ',s[13] = ' ';
    print(s);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

    int a,b,c,d,res1,res2,co,i;
    cin>>a>>b>>c>>d;
    co=0;
    for(;;){

            c=c-b;

            if(c<=0){
                co=2;
                break;
            }

            a=a-d;

            if(a<=0){
                co=1;
                break;
            }

    }
    if(co==1){
        cout<<"No"<<endl;
    }
    else if(co==2){
        cout<<"Yes"<<endl;
    }


}



Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
	int i,flag,l;
    char a[200];
    char b[200];
	while(scanf("%s",&a)!=EOF)
	{
		flag=1;
		scanf("%s",&b);
		l=strlen(b);
		for(i=0;i<l;i++)
		{
			if(a[i]!=b[l-1-i])
			flag=0;
		}
		if(flag==1)
		printf("YES\n");
		else
		printf("NO\n");
		a[0]='\n';
		b[0]='\n';
		
	}
	
}

Measured memory_bytes: 128
text = input()
n = int(input())

for i in range(n):
    ins = input().split()
    if ins[0] == "print":
        a, b = int(ins[1]), int(ins[2])
        print(text[a:b + 1])
    elif ins[0] == "reverse":
        a, b = int(ins[1]), int(ins[2])
        text = text[:a] + text[a:b + 1][::-1] + text[b + 1:]
    elif ins[0] == "replace":
        a, b, p = int(ins[1]), int(ins[2]), ins[3]
        text = text[:a] + p + text[b + 1:]

Measured memory_bytes: 7664
// C - Good Sequence
#include <bits/stdc++.h>
using namespace std;
int C[100001];

int main(){
	int N; cin>>N;
	int ans = 0;
	for(int i=0; i<N; ++i){
		int a; scanf("%d",&a);
		ans++;
		if(a <= N)
			if(++C[a] == a) ans -= a;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
class BIT:

    def __init__(self, N):
        # NOTE: 1-indexed
        self.N = N
        self.data = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & (- i)
        return s

    def update(self, i, x):
        while i <= self.N:
            self.data[i] += x
            i += i & (- i)


def c2n(c):
    return ord(c) - ord('a')


def main():
    N = int(input())
    S = input()
    char_list = list(S)
    trees = [BIT(N) for _ in range(26)]
    for i, c in enumerate(S):
        trees[c2n(c)].update(i + 1, 1)
    Q = int(input())
    ans = list()
    for _ in range(Q):
        query = input().split()
        if query[0] == '1':
            _, i, c = query
            i = int(i) - 1
            before_c = char_list[i]
            char_list[i] = c
            trees[c2n(before_c)].update(i + 1, - 1)
            trees[c2n(c)].update(i + 1, 1)
        else:  # type '2'
            _, left, right = query
            left, right = int(left) - 1, int(right) - 1
            cnt = 0
            for i in range(26):
                n = trees[i].sum(right + 1) - trees[i].sum(left)
                if n > 0:
                    cnt += 1
            ans.append(cnt)
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 204180
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B);
  print((A * B) % 2 ? "Odd" : "Even");
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int main(){
  int r, D, x, pre;
  cin >> r >> D >> x;
  FOR(i, 1, 11){
    cout << r*x-D << endl;
    x = r*x-D;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >; // グラフ

// トポロジカルソートする
void rec(int v, const Graph &G, vector<bool> &seen, vector<int> &order) {
    seen[v] = true;
    for (auto next : G[v]) {
        if (seen[next]) continue; // 既に訪問済みなら探索しない
        rec(next, G, seen, order);
    }
    order.push_back(v);
}

int main() {
    int N, M; cin >> N >> M; // 頂点数と枝数
    Graph G(N); // 頂点数 N のグラフ
    for (int i = 0; i < M+N-1; ++i) {
        int a, b;
        cin >> a >> b; // ノード a からノード b へと有向辺を張る
        a--;b--;
        G[a].push_back(b);
    }

    // 探索
    vector<bool> seen(N, 0); // 初期状態では全ノードが未訪問
    vector<int> order; // トポロジカルソート順
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // 既に訪問済みなら探索しない
        rec(v, G, seen, order);
    }
    reverse(order.begin(), order.end()); // 逆順に
    map<int,int>b;
    for (auto v : order){
        for(auto x : G[v]){
            b[x]=v+1;
        }
    }
    for(int i=0;i<N;++i)cout<<b[i]<<endl;
}

Measured memory_bytes: 16632
#include<iostream>
#include<string>
#include<vector>

int main(void)
{
	std::string S;
	std::cin >> S;

	int n = S.length();
	std::vector<int> ans(n);
	
	for (int i = 0; i < 2; i++) {
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			if (S[j] == 'R') cnt++;
			else {
				ans[j - 1] += (cnt + 1) / 2;
				ans[j] += cnt / 2;
				cnt = 0;
			}
		}
		std::reverse(S.begin(), S.end());
		std::reverse(ans.begin(), ans.end());
		for (int j = 0; j < n; j++) {
			if (S[j] == 'R')	S[j] = 'L';
			else				S[j] = 'R';
		}

	}

	for (auto x : ans)
		std::cout << x << " ";
	std::cout << std::endl;
}

Measured memory_bytes: 1088
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn skip(pos: usize, target: usize, seq: &Vec<usize>) -> usize {
    let n = seq.len();
    let mut prev = target;
    for i in pos..n {
        if prev != seq[i] && seq[i] == target {
            return i;
        }
        prev = seq[i];
    }
    return n;
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let seq = read::<String>()
        .chars()
        .map(|c| (c as u8 - '0' as u8) as usize)
        .collect::<Vec<usize>>();
    let mut r = 0;
    while r < n && seq[r] == 1 {
        r += 1;
    }
    for _ in 0..k {
        r = skip(r, 0, &seq);
    }
    let mut l = 0;
    let mut ans = r - l;
    for _ in 0..n {
        r = skip(r, 0, &seq);
        l = skip(l, 1, &seq);
        ans = std::cmp::max(ans, r - l);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <queue>
using namespace std;
int main(){
	while(1){
		int n,k,num,max,tmp;
		queue<int> a;
		cin >> n >> k;
		if(!n&&!k) break;
		max=tmp=0;
		for(int i=0;i<k;i++){
			cin >> num;
			a.push(num);
			max+=num;
		}
		n-=k;
		tmp=max;
		while(n--){
			cin >> num;
			a.push(num);
			tmp+=a.back()-a.front();
			a.pop();
			if(max<tmp) max = tmp;
		}
		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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 main(){
ll n;
cin>>n;
bool flag = false;
for (ll i = 0; i < n; i++) {
    for (ll j = 0;j<n;j++){
        if (4 * i + 7 * j == n) flag = true;
    }
}
cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
	int n, x, p, i, j, k;
	
	while(scanf("%d", &n) != 0){
		if (n == 0) break;

		int a[n];

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

		x = a[0];

		for(i = 0; i < n; i++){
			p = 0;

			for(j = i; j < n; j++){
				p += a[j];
				if(x < p) x = p;
			}
		}

		printf("%d\n", x);
	}

	return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


signed main() {
    //my-code
    int N, M; cin >> N >> M;
    if(N%2 == 1) {
        REPS(i, 1, M+1) {
            cout << i << " " << 2*M-i+1 << endl;
        }
    } else {
        REPS(i, 1, (M+1)/2+1) {
            cout << i << " " << i+(((M+1)/2-i)*2+1) << endl;
        }
        REPS(i, 1, M/2+1) {
            cout << 1+(((M+1)/2-1)*2+1)+i << " " << 1+(((M+1)/2-1)*2+1)+i+(M/2-i+1)*2 << endl;
        }
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3640
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(ipt())
    for i in range(1,10**5):
        if i*(i+1)//2 > n:
            print("No")
            exit()
        elif i*(i+1)//2 == n:
            print("Yes")
            print(i+1)
            ans = [[] for j in range(i+1)]
            ni = 1
            for j in range(i,0,-1):
                for k in range(j):
                    ans[i-j].append(ni)
                    ans[i-k].append(ni)
                    ni += 1
            for j in ans:
                print(i," ".join(map(str,j)))
            exit()

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 14860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,i,j,tmp=0;
  cin>>n;
  
  vector <pair<string,pair<ll,ll> > > a(n);

  for(i=0;i<n;i++){
	cin>>a[i].first>>a[i].second.first;
    a[i].second.first*=-1;
    a[i].second.second=i+1;
  }
  
  sort(a.begin(),a.end());
  
  for(i=0;i<n;i++){
	cout<<a[i].second.second<<endl;
  }
}
  
  

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define cyes cout<<"Yes"<<endl;
#define cno cout<<"No"<<endl;
#define gcd __gcd
using namespace std;
signed main() {
  int n;
  cin>>n;
  vector<int>vec(n);
  int tab[n][100];
  bool can=false;
  rep(i,n) rep(j,100) tab[i][j]=0;
  int cnt=0;
  rep(i,n) {
    cin>>vec.at(i);
    rep(j,vec.at(i)) {
      tab[i][j]=1;
    }
  }
  unsort(vec);
  int a=vec.at(0);
  rep(i,a) {
    rep(j,n) {
      if(tab[j][i]==1) {
        can=true;
      }
      if(j!=0) {
        if(tab[j][i]==0&&can) {
          cnt++;
          can=false;
        }
      }
    }
    if(tab[n-1][i]==1) {
      cnt++;
    }
    can=false;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 384
n = gets.to_i
a,b = gets.split.map(&:to_i)
point = gets.split.map(&:to_i)
prob = [0,0,0]
(point.length).times{|i|
  if point[i] <= a
    prob[0] += 1
  elsif point[i] <= b
    prob[1] += 1
  else
    prob[2] += 1
  end}
prob.sort!
puts prob[0]


Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#include <algorithm>

int main()
{
    unsigned int N;
    unsigned int* A;
    unsigned int* count;
    std::cin >> N;
    A = new unsigned int[N];
    for(int i = 0; i < N; i++)
    {
        std::cin >> A[i];
    }
    count = new unsigned int[N];
    unsigned int answer = int(pow(10,9));
    for(int i = 0; i < N; i ++)
    {
        for(int j = 1;;j++)
        {
            if(A[i]%int(pow(2, j))==0)
            {
                count[i]++;
            }
            else
            {
                break;
            }
        }
        answer = std::min(answer,count[i]);
    }
    std::cout << answer << std::endl;
    return 0;
}

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

int main() {
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(a.rbegin(),a.rend());
  int sa=a[0]*2-a[1]-a[2];
  int kotae=sa/2;
  if (sa%2==1)kotae+=2;
  cout<<kotae<<endl;
  return 0;
}

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

int main() {
  size_t H, W;
  std::cin >> H >> W;

  size_t N;
  std::cin >> N;
  
  std::vector<size_t> a(N);
  for (size_t i=0; i<N; i++) {
    std::cin >> a[i];
  }

  size_t i=0;
  for (size_t y=0; y<H; y++) {
    std::vector<size_t> Row(W);
    for (size_t x=0; x<W; x++) {
      if (a[i] == 0) i++;
      if (y%2 == 0)
        Row[x] = i;
      else
        Row[W-x-1] = i;
      a[i]--;
    }
    for (size_t x=0; x<W; x++) {
      if (x>0) std::cout << ' ';
      std::cout << Row[x]+1;
    }
    std::cout << '\n';
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin >> p.at(i);
  sort(p.begin(),p.end());
  int ans=0;
  for(int i=0;i<k;i++) ans+=p.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 3628
"use strict";

var main = function main(input) {
  // 全部"."の時の挙動
  // とりあえずYES吐くようにして正解を確認する。そこからバグを推定。
  // NoがYesになっちゃってる
  // DB連携すればこれ解けるんじゃね？
  var args = input.split('\n');
  var H = args[0].split(' ')[0];
  var W = args[0].split(' ')[1];
  var s = [];
  var flagOut = true;

  for (var i = 1; i <= H; i++) {
    s.push(args[i]);
  } // 一つずつ参照していって上下左右に#なかったらNG


  for (var _i = 0; _i < H; _i++) {
    var line = s[_i].toString().split('');

    for (var j = 0; j < W; j++) {
      var flag = false;
      var target = line[j]; // console.log(`(${i}, ${j}): ${target}`);

      if (target != '#') {
        continue;
      } // 左端じゃなかったら左を見る


      if (j != 0) {
        if (line[j - 1] == '#') {
          // console.log(`in1`);
          flag = true;
          continue;
        }
      } // 右端じゃなかったら右を見る


      if (j < W - 1) {
        if (line[j + 1] == '#') {
          // console.log(`in2`);
          flag = true;
          continue;
        }
      } // 上端じゃなかったら上を見る


      if (_i != 0) {
        var up = s[_i - 1].toString().split('');

        if (up[j] == '#') {
          // console.log(`in3`);
          flag = true;
          continue;
        }
      } // 下端じゃなかったら下を見る


      if (_i < H - 1) {
        var down = s[_i + 1].toString().split('');

        if (down[j] == '#') {
          // console.log(`in4`);
          flag = true;
          continue;
        }
      }

      if (!flag) {
        flagOut = false;
        console.log("No");
        break;
      }
    }

    if (!flagOut) {
      break;
    }
  }

  if (flagOut) {
    console.log("Yes");
  }
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));

Measured memory_bytes: 7372
/// >>In The Name Of God
/// >>ALIREZANA

#include <bits/stdc++.h>
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define sz(x) (int)(x).size()
#define smin(x,y) (x) = min(x,y)
#define smax(x,y) (x) = max(x,y)
#define all(x) (x).begin(),(x).end()
#define mem(x,y) memset(x,y,sizeof(x))
#define _ ios_base::sync_with_stdio(0)\
                ,cin.tie(0),cout.tie(0);

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int M4 = 1e4+10, M5 = 1e5+10, M6 = 1e6+10;

int main()
{_
	ll a, b, c;
	cin >> a >> b >> c;
	for(int i = 0; i < 10; i++)
        cout << (c = (c*a-b)) << endl;
	return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int mod = 1e9+7;
const int N = 1e5+23;

int c[3];

void solve() {
  int n; scanf("%d", &n);
  long long ans = 1;
  for (int a, i = 0; i < n; ++i) {
    scanf("%d", &a);
    int cnt = 0, sel = 0;
    for (int j = 0; j < 3; ++j) {
      if (c[j] == a) {
	++cnt;
	sel = j;
      }
    }
    (ans *= cnt) %= mod;
    ++c[sel];
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int m, k;
  while (cin >> m >> k) {
    if ((m == 1 && k == 1)|| k >= (1 << m))  {
      cout << -1 << endl;
      continue;
    }
    if (k == 0) {
      REP(i, 1 << m)
      {
        printf("%d %d%c", i, i, (i == (1 << m) - 1) ? '\n' : ' ');
      }
      continue;
    }
    printf("0 %d 0", k);
    for (int i = 1; i < (1 << m); i++) if (i != k) printf(" %d", i);
    printf(" %d", k);
    for (int i = (1 << m) - 1; i >= 1; i--) if (i != k) printf(" %d", i);
    cout << endl;
  }
}


Measured memory_bytes: 1792
from collections import defaultdict as d
p=d(str)
n=int(input())
print(0, flush = True)
s = input()
if s == "Vacant": exit()
else:
    p[0]=s
    p[n]=s
    l=0
    r=n
    while 1:
        g=(l+r)//2
        print(g, flush = True)
        s = input()
        p[g]=s
        if s == "Vacant": break
        else:
            t=p[l]
            if ((g-l)%2!=0 and s!=t) or ((g-l)%2!=1 and s==t):
                l=g
            else:
                r=g
           

Measured memory_bytes: 3912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = 998244353;
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

vector<ll> FactorialInv, Factorial;

void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    Factorial[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = power(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

//modの値の確認をすること
int main(){
    ll n,k;
    cin >> n >> k;
    vl a(n);
    rep0(i, n)cin >> a[i];
    sort(all(a));
    ll ans = 0;
    rep0(i, k)ans += a[i];
    pf(ans);
    return 0;
}


Measured memory_bytes: 3632
while True:
    h,w = map(int,input().split())
    if h == w == 0:
        break
    for i in range(h):
        for j in range(w):
            if (i + j) % 2 == 0:
                print('#',end='')
            else:
                print('.',end='')
        print()
        
    print()


Measured memory_bytes: 7004
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> ab(m);
    for(int i = 0; i < m; ++i){
        cin >> ab.at(i).first;
        cin >> ab.at(i).second;
    }

    sort(ab.begin(), ab.end(), [](auto &left, auto &right) {
        return left.second < right.second;
    });

    ll ans = 0;
    ll prev = -1;
    for(auto p : ab){
        if(p.first > prev){
            ans += 1;
            prev = p.second - 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
	     int a = sc.nextInt();
	     int b = sc.nextInt();
	     if(a<b){
	    	 	System.out.println("a < b");
	     	}else if(a>b){
	     		System.out.println("a > b");
	     	}else{
	     		System.out.println("a == b");
	     	}
	}

}


Measured memory_bytes: 26080
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        String t = scan.next();
        int sb = scan.nextInt();
        int tb = scan.nextInt();
        String u = scan.next();
        scan.close();

        if(s.equals(u)) sb--;
        else if(t.equals(u)) tb--;

        System.out.println(sb + " " + tb);
    }
}

Measured memory_bytes: 23764
n = int(input())
a = list(map(int, input().split()))

a.sort()
kouho = set(i for i in range(1, 10**6+1))
ans = 0
for i in range(n):
    ai = a[i]
    tasu = True
    if i < n-1:
        if ai == a[i+1]:
            tasu = False
    if ai not in kouho:
        continue
    while ai <= 10**6:
        if ai in kouho:
            kouho.remove(ai)
        ai += a[i]
    if tasu:
        ans += 1
print(ans)

Measured memory_bytes: 179500
#include <bits/stdc++.h>
using namespace std;
ifstream f("A.in");
int N,K,d,x;
bool viz[101]={0};

int main()
{

    cin>>N>>K;
    for(int k=1;k<=K;k++)
    {
        cin>>d;
        for(int i=1;i<=d;i++)
        {
            cin>>x;
            viz[x]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=N;i++)
        if(!viz[i])ans++;
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 

#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
//const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

const int mod = 998244353;

struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}
};

vector< pair<int,int> > t[N];
vector< pair<int, int> > v;
map< pair<int,int>,int > tab;
bool vis[N];
int tmp[N];
void add(int u, int v){
	t[u].push_back(make_pair(v,0));
	t[v].push_back(make_pair(u,0));
}


int main(){
	clr(vis,false);
	int n; cin>> n;
	int a , b, k = 0;
	for(int i = 1; i <= n-1; i++){
		cin>> a >> b;
		add(a,b);
		v.push_back(make_pair(a,b));
		
		int x = t[a].size();
		int y = t[b].size();
		k = max(k,x);
		k = max(k,y);
	}
	
	queue< int > q;
	q.push(1);
	vis[1] = true;
	while(!q.empty()){
		
		int x = q.front();
		q.pop();
		vis[x] = true;
		
		int color = 0;
		//~ cout<<x<<":";
		for(int i = 0; i < (int)t[x].size(); i++){
			int y = t[x][i].f;
			//~ cout<<y<<" "<< "(x,y)"<<tab[{x,y}];
			if(tab[{x,y}] != 0){
				//~ cout<<"-"<<y<<"- ";
				color = tab[{x,y}];
			}
		}
		//~ cout<<endl;
		
		//~ cout<<"color:"<<color<<endl;
		
		int p = 0;
		for(int i = 1; i <=k ; i++)
			if(i != color){
				tmp[p] = i;
				p++;
				//~ cout<<i<<" "; 
			}
		//~ cout<<endl;	
		int c = 0;
		for(int i = 0; i < (int)t[x].size(); i++){
			int y = t[x][i].f;
			if(vis[y] == false && c < p){
				//~ cout<< x<< "<->"<<y<<" col:"<<tmp[c]<<endl;
				t[x][i].s = tmp[c];
				tab[{x,y}] = tmp[c];
				tab[{y,x}] = tmp[c];
				c++;
				q.push(y);
			}
		}
	}
	//~ cout<<endl;
	cout<<k<<endl;
	for(int i =0; i < (int)v.size(); i++){
		cout<< tab[v[i]]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 22388
#include<bits/stdc++.h>
using namespace std;
#define     siii(a,b,c)       scanf("%d%d%d",&a,&b,&c)
#define     si(a)             scanf("%d",&a)
#define     sii(a,b)          scanf("%d%d",&a,&b)
#define     sl(a)             scanf("%lld",&a);
#define     sll(a,b)          scanf("%lld%lld",&a,&b);
#define     slll(a,b,c)       scanf("%lld%lld%lld",&a,&b,&c);
#define     sd(a)             scanf("%lf",&a);
#define     sdd(a,b)          scanf("%lf%lf",&a,&b);
#define     pb(a)             push_back(a)
#define     deb(a)            printf("### %d ###\n",a)
#define     mp                make_pair
#define     pf                printf
#define     fl(a, b, c)       for(int a= b ;a<c;a++)
#define     mx                100000 //10^5
#define     fread             freopen("input.txt","r",stdin)
#define     CLR(a,b)          memset(a,b,sizeof(a))
#define     ll                long long
#define     D(x)              cout<<#x" = "<<x<<endl;
#define     sz                10000
#define     bl                printf("\n")
#define     spc               printf(" ")


int main()
{
    int t, b, ed;
    siii(t, b, ed);
    cout<<(ed/t)*b<<endl;




    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	ll cnt = 1;
	int a[1002] = { 0 };
	rep(i, 0, 1001) { a[i] = 1; }
	vector<int> v;
	for (int i = 2; i <= n; i++) {
		bool flag = true;
		for (int j = 2; j < i; j++) {
			if (i%j == 0) { 
				flag = false; 
			}
		}
		if (flag) { 
			v.push_back(i); 
		}
	}
	//rep(i, 0, 3)print("vec" << " " << v[i]);
	rep(i, 0, v.size()) { a[v[i]]++; }
	for (int i = 2; i <= n; i++) {
		for (int j = 2; j < i; j++) {
			if (i > 3 && i%j == 0 && find(v.begin(), v.end(), j) != v.end()) {
				//a[j] += i / j;
				int tmp = i;
				while (tmp%j == 0) {
					if (tmp%j == 0) { a[j]++; }
					tmp = tmp / j;
				}
			}
		}
	}

	for (int i = 2; i <= n; i++) { //print("a[i]" << " " << a[i]); 
	cnt *= a[i]; cnt %= 1000000007; 
	}
	print(cnt);
}

Measured memory_bytes: 256
inp = list(map(int, input().split()))
N = inp[0]
K = inp[1]
Q = inp[2]

ansum =[]

for count in range(N):
    ansum.append(0)

for count in range(Q):
    seikaisya = int(input())
    ansum[seikaisya-1] += 1

for count in range(N):

    if K - Q + ansum[count] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4680
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct Unionfind{
    vector<int> parents;
    int n;
    Unionfind(int n):n(n),parents(n,-1){ }

    int find(int x){
        if(parents[x] < 0) return x;
        else return parents[x] = find(parents[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y =  find(y);

        if(x==y) return;
        if(parents[x] > parents[y]) swap(x,y);
        parents[x] += parents[y];
        parents[y] = x;
    }  

   int size(int x){
       return -parents[find(x)];
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }

   vector<int> members(int x){
       int root = find(x);
       vector<int> member;
       for(int i=0;i<n;i++){
           if(find(i)==root ){
               member.push_back(i);
           }
       }
      return member;
  }

  int group_cnt(){
      int c = 0;
      rep(i,n){
          if(parents[i] < 0) ++c;
      }
      return c;
  }
};

int main(){
    int n,m;
    cin >> n >> m;
    Unionfind uf(n);
    int ans = n-m;
    rep(i,m){
        int x,y,tmp;
        cin >> x >> y >> tmp;
        --x;--y;
        if(uf.same(x,y)) ++ans;
        else uf.unite(x,y);
    }
    cout << ans << endl;
}

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

int main()
{
    long long int N;
    cin >> N;
    long long int sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 15 == 0)
        {
            continue;
        }
        else if (i % 3 == 0)
        {
            continue;  
        }
        else if (i % 5 == 0)
        {
            continue;
        }
        else
        {
            sum+= i; 
        } 
    }
    cout << sum << endl;
    return 0;  
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
using namespace std;

int main(){
  string S;
  cin >> S;
  int i,j;
  for (i = 1; i < 4; i++) {
 	 if (S.at(0) == S.at(i)) {
       break;
     }
  }
  if (i == 1) {
    if (S.at(2) == S.at(3) && S.at(1) != S.at(2)){
      j = 1;
    }
    else {
      j = 0;
    }
  }
  else if (i == 2) {
    if (S.at(1) == S.at(3) && S.at(1) != S.at(2)){
      j = 1;
    }
    else {
      j = 0;
    }
  }
  else if (i == 3) {
    if (S.at(1) == S.at(2) && S.at(3) != S.at(2)){
      j = 1;
    }
    else {
      j = 0;
    }
  }
  else {
    j = 0;
  }
  if (j == 0){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}
  
       
       

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

int main() {
  int n;
  cin >> n;
  vector <int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i+1 == vec.at(vec.at(i)-1)) {
      ans++;
    }
  }
  cout << ans/2 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define eps 0.000000001
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int main(){
	int x;cin>>x;
	if(x<30) puts("No");
	else puts("Yes");
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,A,B;
cin >> N >> A >> B;
string s;
cin >> s;
string a[100010];
int sum_d = 0;
int sum_f = 0;
for(int i = 0; i< s.size(); i++){
  if(s.at(i) == 'c') a[i] = "No";
  else if(s.at(i) == 'a'){
    if(A+B>sum_d){
      a[i] ="Yes";
      sum_d++;
    }
    else{
      a[i] ="No";
    }
  }
  else{
    if(A+B>sum_d && B > sum_f){
      a[i] ="Yes";
      sum_d++;
      sum_f++;
    }
    else{
      a[i] ="No";
    }
  }
}
for(int i = 0; i<s.size();i++){
  cout << a[i] << endl;
}
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/



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

    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i) cin >> a[i];

    int res = 0;
    for(int i=0; i<n; ++i){
        int t = a[i];
        while(t%2 == 0){
            ++res;
            t /= 2;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int n, k;
        read n >> k;
        if ( n % k ) echo 1 fin;
        else echo 0 fin;


        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256