akhauriyash/Code-Regression huggingface dataset:
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll n;
vector<ll> a;
bool check(vector<ll> &bit, ll &r){
    if(r >= n) return false;
    for(int i = 0; i < 22; i++){
        if(a[r] & (1 << i)){
            if(bit[i] + 1 > 1){
                return false;
            }
        }
    }
    return true;
}
int main(void){
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<ll> bit(22, 0);
    ll r = 0;
    ll ans = 0;
    for(ll l = 0; l < n; l++){
        while(check(bit, r)){
            for(int i = 0; i < 22; i++){
                if(a[r] & (1 << i)){
                    bit[i]++;
                }
            }
            //cout << l << " " << r << endl;
            r++;
        }

        ans += (r - l);
        if(r == l) r++;

        for(int i = 0; i < 22; i++){
            if(a[l] & (1 << i)){
                bit[i]--;
            }
        }
    }
    cout << ans << endl;
}   

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

int main() {
	long long int N;
	cin >> N;
	long long int a = 1;
	for(long long int i = 1;i <= N;i++){
		a *= i;
		a %= 1000000007;
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

int h[1024*1500];
int w[1024*1500];

int main(){
  int n,m;
  while(scanf("%d%d",&n,&m), n+m){
    int hh[n];
    int ww[m];

    for(int i=0; i<n; i++)
      scanf("%d",&hh[i]);
    for(int i=0; i<m; i++)
      scanf("%d",&ww[i]);

    for(int i=0; i<n; i++){
      int sum = 0;
      for(int j=i; j<n; j++){
	sum += hh[j];
	h[sum]++;
      }
    }
    for(int i=0; i<m; i++){
      int sum = 0;
      for(int j=i; j<m; j++){
	sum += ww[j];
	w[sum]++;
      }
    }
    long long ans = 0;
    for(int i=0; i<1500*1024; i++){
      if(w[i] | h[i]){
	ans += (long long)w[i] * h[i];
	w[i] = h[i] = 0;
      }
    }

    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 12000
n = int(input())
l = list(map(int, input().split()))


def bubbleSort(a, n):
    flag = 1
    ans = 0
    while flag:
        flag = 0
        for j in range(n-1, 0, -1):
            if a[j] < a[j - 1]:
                a[j], a[j - 1] = a[j - 1], a[j]
                flag = 1
                ans += 1

    print(*a)
    print(ans)


bubbleSort(l, n)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  =  vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    long double a, b;
    cin >> a >> b;

    cout << (int) (a * b)  << endl;

    return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[125252];
char x[4][52] = {"dream","dreamer","erase","eraser"};

int main(){
  scanf("%s",s);
  n = strlen(s);
  int it = n;
  while(it > 0){
    bool flag = false;
    FORR(i,0,4){
      // x[i]
      int j = strlen(x[i]);
      if(it-j<0)continue;
      bool ok = true;
      REP(k,j){
        if(s[it-j+k]!=x[i][k]){
          ok=false;
          break;
        }
      }
      if(ok){
        it -= j;
        flag = true;
        break;
      }
    }
    if(!flag){
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


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

class ap{
    int_fast64_t mov[90], val[9][200][8];
public:
    constexpr ap(size_t t) : mov(), val(){
        for(auto& i : mov)i = -1;
        mov[0] = 0;
        size_t c = 1, d = 1;
        for(size_t i = 0; i < t; ++i){
            for(size_t j = 0; j < c; ++j){
                mov[j + d] = mov[j] + (1 << i);
            }
            d += c;
            c = d - c;
            for(size_t j = 0; j < 200; ++j){
                for(size_t l = 0; l < i; ++l){
                    val[i][j][l] = 0;
                }
            }
            val[i][0][0] = 1;
            for(size_t j = 1; j < 200; ++j){
                for(size_t kk = 0; kk < c; ++kk){
                    auto k = mov[kk];
                    for(size_t l = 0; l <= i; ++l){
                        if((k >> l) & 1){
                            val[i][j][l] -= val[i][j - 1][l];
                            val[i][j][l] += val[i][j - 1][l + 1];
                            val[i][j][l + 1] -= val[i][j - 1][l + 1];
                            val[i][j][l + 1] += val[i][j - 1][l];
                        }
                        val[i][j][l] += val[i][j - 1][l];
                    }
                    for(size_t l = 0; l <= i; ++l){
                        val[i][j][l] %= 1000000007;
                    }
                }
            }
        }
    }
    constexpr int_fast64_t ans(size_t i, size_t j, size_t k) const{
        return val[j - 1][i][k - 1];
    }
};

constexpr auto a = ap(8);

int main(){
    int_fast64_t H, W, K;
    cin >> H >> W >> K;

    cout << a.ans(H, W, K) << endl;
}


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

int main()
{
  int cnt[100005] = {0};
  int cn = 0;
  int N, A;
  int sum = 0;
  cin >> N;
  Rep(i, N) {
    cin >> A; cnt[A]++;
  }
  Rep(i, 100005) {
    if(cnt[i] >= 3) {
      int val = (cnt[i] - 1) / 2 * 2;
      sum += val, cnt[i] -= val;
    }
    if(cnt[i] == 2) cn++;
  }
  cout << N - sum - (cn + 1) / 2 * 2 << endl;
  return 0;
}
		    


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MP make_pair
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	string find; cin >> find;
	int n; cin >> n;
	int cnt = 0;
	rep(i, n) {
		string s; cin >> s; s += s;
		if ((int)s.find(find) != -1)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3180
import sys
input = sys.stdin.readline

H, W = (int(i) for i in input().split())
#e = [[i for i in input().split()] for i in range(H)]
e = []
for x in range(H):
    e.append(list(input()))

L = [[0] * W for i in [1] * H]
R = [[0] * W for i in [1] * H]
D = [[0] * W for i in [1] * H]
U = [[0] * W for i in [1] * H]
totalmax = 0

for i in range(H):
    for j in range(W):
        if e[i][j] == ".":
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
        if e[i][W-1-j] == ".":
            #print(i, W-1-j)
            if W-1-j == W-1:
                R[i][W-1-j] = 1
            else:
                R[i][W-1-j] = R[i][W-j] + 1
                #print(R[i][W-j-2])
            #print(R[i][W-j-1])
        if e[i][j] == ".":
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1
        if e[H-1-i][j] == ".":
            if H-1-i == H-1:
                D[H-1-i][j] = 1
            else:
                D[H-1-i][j] = D[H-i][j] + 1

for i in range(H):
    #print("")
    for j in range(W):
        totalmax = max(totalmax, L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
        #print(L[i][j],R[i][j], D[i][j], U[i][j], end="/")



print(totalmax)


Measured memory_bytes: 310920
# -*- coding: utf-8 -*-

def main():
    def _fibonacci(n,cache):
        if n in cache:
            return cache[n]

        elif n == 0 or n == 1:
            ret = 1
            cache[n] = ret
            return ret
        else:
            ret = _fibonacci(n - 1, cache) + _fibonacci(n - 2, cache)
            cache[n] = ret
            return ret

    N = int(raw_input())
    cache = {}
    return _fibonacci(N,cache)

print main()

Measured memory_bytes: 6272
import java.util.*;

class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int res = (X-A)%B;
    System.out.println(res);
  }
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll d;
  string s, n;
  cin >> d >> n;
  forll(i, 0, 2 * d + n.size())
	s += "0";
  forll(i, 0, n.size())
	s[i] = n[i];
  if (n == "100")
	s[2] = '1';
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>

int main() {
    std::set<int> s;
    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int t, x;
        std::cin >> t >> x;
        if (t == 0) {
            s.insert(x);
            std::cout << s.size() << std::endl;
        } else {
            std::cout << s.count(x) << std::endl;
        }
    }
}



Measured memory_bytes: 12376
import java.util.*;

public class Main {
  public static void main(String... args) {
    Scanner input = new Scanner(System.in);

    int n = input.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = input.nextInt();
    }

    Arrays.sort(a);
    int ans = 0;
    if (a[0] == 1) {
      if (n >= 2 && a[0] == a[1]) {
        ans = 0;
      } else {
        ans = 1;
      }
    } else {
			Set<Integer> removeLater = new HashSet<>();
      List<Integer> unique = new ArrayList<>();
      for (int i = 0; i < n;) {
        int cnt = 1;
        int j = i + 1;
        for (; j < n && a[i] == a[j]; j++) {
          cnt++;
        }
        unique.add(a[i]);
        if (cnt > 1) {
					removeLater.add(a[i]);
        }
        i = j;
      }
      if (unique.size() != 0) {
        int max = unique.get(unique.size() - 1);
        Set<Integer> set = new HashSet<>(unique);
        for (int i = 0; i < unique.size(); i++) {
          int v = unique.get(i);
          for (int j = 2 * v; j <= max; j += v) {
            set.remove(j);
          }
        }
				set.removeAll(removeLater);
        ans = set.size();
      }
    }



    System.out.println(ans);

  }
}

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

#define PI 3.1415 
  
int main(){
	
	float radius;
	float circum;
	
	scanf("%f",&radius);
	
	circum =(2 * PI * radius);
	
	
	printf("%f",circum);
	
	
	return 0;
	
}


Measured memory_bytes: 3816
#include <iostream>
#include <cstdio>
#include <stdio.h>

using namespace std;

int main(void)
{

	int val,count = 0;
	while (scanf("%d", &val) != EOF)
	{
		for (int a = 0; a < 10; a++)
		{
			for (int b = 0; b < 10; b++)
			{
				for (int c = 0; c < 10; c++)
				{
					for (int d = 0; d < 10; d++)
					{
						if (a + b + c + d == val)count++;

					}

				}


			}


		}

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

	}

}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a, b, c, d;
	cin >> a >> b >> c >> d;
	double temp = (double) a * b;
	temp /= 2;
	int yes = 0;
	if((double)c == (double)a / 2 && (double)d == (double)b / 2) yes = 1;	
	printf("%lf %d\n",temp, yes);
	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++)

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int a,b,c,n;
int l[10];
int ans = inf;

void dfs(int tmp_a,int tmp_b, int tmp_c,int now, int magic)
{
    if(now == n){
        if(tmp_a * tmp_b * tmp_c != 0){
            magic += abs(tmp_a-a);
            magic += abs(tmp_b-b);
            magic += abs(tmp_c-c);
            ans = min(magic,ans);
        }
    }else{
        if(tmp_a == 0){
            dfs(tmp_a+l[now],tmp_b,tmp_c,now+1,magic);
        }else{
            dfs(tmp_a+l[now],tmp_b,tmp_c,now+1,magic+10);
        }
        if(tmp_b == 0){
            dfs(tmp_a,tmp_b+l[now],tmp_c,now+1,magic);
        }else{
            dfs(tmp_a,tmp_b+l[now],tmp_c,now+1,magic+10);
        }
        if(tmp_c == 0){
            dfs(tmp_a,tmp_b,tmp_c+l[now],now+1,magic);
        }else{
            dfs(tmp_a,tmp_b,tmp_c+l[now],now+1,magic+10);
        }
        dfs(tmp_a,tmp_b,tmp_c,now+1,magic);
    }
}

int main()
{
    cin >> n >> a >> b >> c;
    rep(i,n) cin >> l[i];
    dfs(0,0,0,0,0);
    cout << ans << endl;

}

Measured memory_bytes: 256
// abc131c.cpp : Anti-Division
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll A,B,C,D; cin>>A>>B>>C>>D;
	ll E = C/__gcd(C, D)*D;
	ll n = B-A+1;
	ll c = (B/C-(A-1)/C) + (B/D-(A-1)/D) - (B/E-(A-1)/E);
	cout<< n-c << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = Long.parseLong(sc.next());
		List<Long> list = new ArrayList();
		long total = 0L;
		for(long i=1; i<=N; i++) {
			list.add(Long.parseLong(sc.next()));
		}
		Collections.sort(list);
		Collections.reverse(list);
		long aa = N/2;
		long aaa = N%2;
		total = list.get(0);
		for(int i=1;i<=aa-1;i++) {
			total += list.get(i) * 2;
		}
		if(aaa ==1) {
			total += list.get((int) ((N/2)));
		}

		System.out.println(total);


	}
}

Measured memory_bytes: 54860
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
ii0 = lambda: ii() - 1
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def divs_gen(n):
    for i in range(1, int(m**.5)+1):
        if n%i == 0:
            yield i
            if i != n//i:
                yield n//i


def main():
    N,K,Q = mis()
    A = [0]*N
    for _ in range(Q):
        A[ii()-1] += 1
    S = sum(A)
    for i in range(N):
        if K - S + A[i] <= 0:
            print('No')
        else:
            print('Yes')

main()


Measured memory_bytes: 4680
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	string s; cin >> s;
	ll ans = 0;
	for(ll i = 0; i < (1 << (s.size() - 1)); i++){
		ll po = i;
		ll koko = 0;
		queue<ll> q;
		for(ll j = 1; po; j++){
			if(po % 2) q.push(j);
			po /= 2;
		}
		q.push(s.size());
		while(q.size()){
			string yo = s.substr(koko, q.front() - koko);
			koko = q.front();
			q.pop();
			ans += stoll(yo);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    string o, e, ans;
    cin >> o >> e;
    rep(i, e.size()) {
        ans.push_back(o.at(i));
        ans.push_back(e.at(i));
    }
    if (o.size() - e.size() == 1) {
        ans.push_back(o.at(o.size() - 1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main() {
    long long n,k,tmp;
    cin>>n>>k;
    tmp=n%k;
   
    rep(i,999999999999999999){
    	if(tmp<llabs(tmp-k)){
    		break;
    	}else{
    		tmp=llabs(tmp-k);
    	}
    }
    cout<<tmp<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ITP1_1_C_Rectangle
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split( ' ' ).Select( int.Parse );
            Console.WriteLine( input.Aggregate( (acc, n) => acc * n ) + " " + input.Sum( n => n * 2 ) );
        }
    }
}

Measured memory_bytes: 5872
package main

import (
	"bufio"
	"fmt"
	"os"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextLine() string {
	scanner.Scan()
	return scanner.Text()
}

func reverse(s string) string {
	chars := []rune(s)
	for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
		chars[i], chars[j] = chars[j], chars[i]
	}
	return string(chars)
}

func main() {
	input := nextLine()
	rev := reverse(input)
	if input == rev {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 640
# 競プロ幼稚園に通う 2人の子供がキャンディーの取り合いをしています。
# 3個のキャンディーパックがあり、
# それぞれのパックにはキャンディーが a, b, c個入っています。
# えび先生はこの 3個のパックを、
# キャンディーの個数が等しくなるように 2人に分けようとしています。
# そのような分け方が可能かどうかを判定してください。
# ただし、キャンディーをパックから取り出すことはできず、
# それぞれのパックをそのままどちらかの子供にあげる必要があります。

# 制約
# 1 ≦ a, b, c ≦ 100

# 標準入力から、a, b, c の値を取得する
a, b, c = map(int,input().split())

result = "ret"
if (a + b) == c:
    result = "Yes"
elif (a + c) == b:
    result = "Yes"
elif (b + c) == a:
    result = "Yes"
else:
    result = "No"

print(result)


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

int main() {
    string s;
    cin >> s;
    if(s.at(0)!=s.at(1) && s.at(1)!=s.at(2) && s.at(2)!=s.at(0)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
const memoize = function(proc){
    const cache = {};

    const helper = (n) => {
        if(!cache[n]){
            cache[n] = proc(n);
        }
        return cache[n];
    }

    return helper;
}

const fib = memoize((n) => {
    if(n < 2){
        return 1;
    }
    return fib(n - 1) + fib(n - 2);
});

let input = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
console.log(fib(Number(input[0])));


Measured memory_bytes: 15384
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

ll N, K;
vector<ll> A;
vector<bool> visit;

int main()
{
//  ll ans;
  ll lk,lm;
  ll pos, start;
  ll rest;

  cin >> N >> K;
  A.resize(N+1);
  visit.resize(N+1);
  for (int i=1; i<=N; i++) {
    cin >> A[i];
    visit[i] = false;
  }

  pos=1;
  for (lk=0; lk<K; lk++) {
//printf("%lld ", pos);
    if (visit[pos]) break;
    visit[pos] = true;
    pos = A[pos];
  }
//printf("\n");
  if (lk>=K) {
    cout << pos << endl;
    return 0;
  }
//printf("lk = %lld K%%lk = %lld\n", lk, K%lk);
  start = pos;
  for (lm = 0; lm+lk<K; ) {
    pos = A[pos];
    lm++;
    if (pos == start) break;
  }
  if (lm+lk>=K) {
    cout << pos << endl;
    return 0;
  }
//printf("lm = %lld\n", lm);
  K-= lk;
  rest = K%lm;
  for (lm=0; lm<rest; lm++) {
    pos = A[pos];
  }
  cout << pos << endl;
  return 0;
}


Measured memory_bytes: 4784
import std.stdio, std.string, std.array, std.conv, std.algorithm;

long solve(long n, long m)
{
    if (2*n > m)
        return m / 2;
    
    auto ret = n;
    m -= n*2;
    ret += m/4;
    return ret;
}

void main()
{
    auto nm = readln.split.to!(long[]);
    writeln(solve(nm[0], nm[1]));
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
char a[12];
int cnt,what;
int main()
{
	scanf("%s",a+1);
	if(a[1]!='A') {printf("WA\n");return 0;}
	for(int i=strlen(a+1)-1;i>=3;--i) if(a[i]=='C') {what=i;cnt++;}
	if(cnt>1||(!cnt)) {printf("WA\n");return 0;}
	for(int i=strlen(a+1);i>=2;--i) if(i!=what&&a[i]>='A'&&a[i]<='Z') {printf("WA\n");return 0;}
	printf("AC\n");
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 20:58:20 2020

@author: NEC-PCuser
"""

S = input()

count = 0
ans = 0
for c in S:
	if c == 'R':
		count += 1
		continue
	elif count > ans:
		ans = count
	count = 0

if count > ans:
	ans = count
print(ans)

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define coutif(a,b,c) cout<<(a?b:c)
#define all(x) (x).begin(), (x).end()
#define uint usigned int
typedef vector <ll> vi;
ll MOD = 1e9+7;
ll l[1000111];
//vi v1[200005],v2;
//bool visit[200005]={false};
/*void bfs(ll n){
    queue<ll> q;
    q.push(n);
    visit[n]=true;
    while(!q.empty()){
        ll t=q.front();
        q.pop();
        v2.pb(t);
        for(ll i=0;i<v1[t].size();i++){
            if(visit[v1[t][i]]==false){
                q.push(v1[t][i]);
                visit[v1[t][i]]=true;
            }
        }
    }
}*/
/*void dfs(ll n){
    for(ll i=0;i<v1[n].size();i++)
    {
        ll y=v1[n][i];
        if(visit[y]==0)
        {
            v2.pb(y);
            visit[y]=1;
            dfs(y);
        }
    }
}*/
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    ll n,k,x=0,y=0,i,c;
    double ans=0;
    cin>>n>>k;
   // if(n==1 && k==1){ cout<<1; return 0;}
    x=min(n,k-1);
    for(i=1;i<=x;i++){
        c=0;
        y=i;
        while(y<k){
            y*=2;
            c++;
        }
        ans+=pow(0.5,c);
      //  cout<<c<<endl;
    }
    if(k<=n) ans+=(n-k+1);
    ans/=n;
    precision(ans,12);
	return 0;
}

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

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (i + 2 < N) {
            if (S.at(i) == 'A' && S.at(i + 1) == 'B' && S.at(i + 2) == 'C') {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

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

#define MAX 100000

int N;
int A[MAX];

int tbl[MAX + 1];

int main() {
	cin >> N;
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	for( int i = 0; i < N; i++ ) {
		tbl[A[i]]++;
	}
	int ans = 0;
	for( int i = 0; i < MAX + 1; i++ ) {
		if( tbl[i] ) {
			ans++;
		}
	}
	if( ans % 2 == 0 ) {
		ans--;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

/* 選択ソート (0オリジン) */
int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, mini;
  for(i=0; i<N-1; i++) {
    mini = i;
    for(j=i; j<N; j++) {
      if(A[j] < A[mini]) mini = j;
    }

  	t = A[i];
  	A[i] = A[mini];
  	A[mini] = t;

  	if(i != mini) sw++;
  }
  return sw;
}

int main(void) {
  int A[100], N, i, sw;
  scanf("%d", &N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  sw = selectionSort(A,N);

  for(i=0;i<N;i++) {
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}



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

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    
    vector<int> d(100);
    for(int i = 1; i <= min(a,b); i++){
        if(a%i == 0 && b%i == 0) d.push_back(i);
    }
    sort(d.rbegin(), d.rend());
    cout << d[k-1] << endl;
}

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++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    int N;
    cin >> N;
    int A = N%10;
    if(A==2||A==4||A==5||A==7||A==9)cout << "hon" << endl;
    if(A==0||A==1||A==6||A==8)cout << "pon" << endl;
    if(A==3)cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    class Program
    {


        static void Main(string[] args)
        {
            char[] ss = Console.ReadLine().ToCharArray();
            char[] t = Console.ReadLine().ToCharArray();

            int sslen = ss.Length;
            int tlen = t.Length;
            bool flag = false;
           
            for (int i = sslen - tlen; i >= 0; i--)
            {
                
                for(int j = 0; j < tlen; j++)
                {
                    if (ss[i + j] == '?')
                    {
                        if (j == tlen - 1) flag = true;
                        else continue;
                    }
                    else if (ss[i + j] == t[j])
                    {
                        if (j == tlen - 1) flag = true;
                        else continue;
                    }
                    else break;
                }

                if (flag)
                {
                    for(int j = 0; j < tlen; j++)
                    {
                        if (ss[i + j] == '?') ss[i + j] = t[j];
                    }
                    for(int j = 0; j < sslen; j++)
                    {
                        if (ss[j] == '?') ss[j] = 'a';
                    }
                    break;
                }

            }


            if (flag)
            {
                Console.WriteLine(String.Join("", ss));
            }
            else
            {
                Console.WriteLine("UNRESTORABLE");
            }
            
        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    
    ll n;
    ll a[200];
    ll cnt[20]={};
    ll ans=0;
    ll c=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(a[i]>=3200) c++;
        else cnt[a[i]/400]++;
    }
    rep(i,9){
        if(cnt[i]>0) ans++;
    }
    cout<<max(ans,1ll)<<" "<<ans+c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

int gcd(int a, int b){
    if(a < b) swap(a, b);
    
    while(b != 0){
        int t = a;
        a = b;
        b = t%b;
    }

    return a;
}

struct SegmentTree{
private:
    int n; // セグ木の葉の数, つまり２冪になっており,　全体の要素数は2*n-1
    vector<int> node;

public:
    SegmentTree(vector<int> v){
        int sz = (int)v.size();
        n = 1; while(n < sz) n*= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; ++i) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; --i) node[i] = gcd(node[2*i+1], node[2*i+2]);
    }

    // k番目(0-indexed)をvalに変更
    void update(int x, int val){
        x += (n-1);
        node[x] = val;
        while(x > 0){
            x = (x-1)/2;
            node[x] = gcd(node[2*x+1], node[2*x+2]);
        }
    }

    // [a,b)の最小値を求める
    // kは接点の番号、l、rはその接点が[l, r)に対応していることを表す
    // 外からはgetmin(a, b, 0, 0, n)と呼ぶ
    int getgcd(int a, int b, int k=0, int l=0, int r=-1){
        if(r < 0) r = n;
        // [a, b)と[l, r)が交差していなければinfを返す
        if(r <= a || b <= l) return 0;
        // [a,b) ⊃ [l, r)ならば、この接点の値
        if(a <= l && r <= b) return node[k];
        // そうでなければ二つの子の最小値
        int vl = getgcd(a, b, k*2+1, l, (l+r)/2);
        int vr = getgcd(a, b, k*2+2, (l+r)/2, r);
        return gcd(vl, vr);
    }
};


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

    SegmentTree seg(a);
    int ans = 0;
    for(int i=0; i<n; ++i){
        int tmp = gcd(seg.getgcd(0, i), seg.getgcd(i+1, n));
        chmax(ans, tmp);
    }

    cout << ans << endl;

    //cout << gcd(75, 0) << endl;

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cmath>
#include <set>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x, n;
	set <int> s;
	cin >> x >> n;
	while(n--){
		int y;
		cin >> y;
		s.insert(y);
	}
	int m = 10000, ans = 100000;
	for(int i = 101; i >= -101;i--) if(s.count(i) == 0){
		m = min(m, abs(x - i));
		if(m == abs(x-i)) ans = i;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

template <typename T>
set<T> factors(T a) {
    set<T> facs;
    for (T i = 1; i * i <= a; ++i) {
        if (a % i == 0) {
            facs.insert(i);
            facs.insert(a / i);
        }
    }
    return facs;
}

int main() {
    ll n, m;
    cin >> n >> m;
    ll ret = 1;
    auto facs = factors(m);
    for (auto &f : facs) {
        if (m / f >= n) {
            chmax(ret, f);
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
import heapq

def main():
    T = int(input())
    for _ in range(T):
        N = int(input())
        KLR = [tuple(map(int, input().split())) for _ in range(N)]
        KLR.sort()
        H = []
        T = []
        s = 0
        for k, l, r in KLR:
            s += r
            if l - r >= 0:
                heapq.heappush(H, (l - r, k))
                while len(H) > k:
                    T.append(heapq.heappop(H))
            else:
                T.append((l - r, k))
        s += sum(l for l, k in H)
        H = []
        T.sort(key = lambda x: -x[1])
        for l, k in T:
            heapq.heappush(H, (-l, N - k))
            while len(H) > N - k:
                s -= heapq.heappop(H)[0]

        print(s)
main()


Measured memory_bytes: 65744
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<double,double> P;
typedef long long ll;

const int mnn=1e5+1; int n,m;
priority_queue<ll, vector<ll>, greater<ll>> al, que[mnn];
ll a[mnn]; bool u[mnn]; vector<int> v[mnn];

void dfs(int from, int id) {
  //cout<<from<<" "<<id<<endl;
  que[id].push(a[from]);
  u[from]=true;
  for(int to:v[from]) {
    if (!u[to]) dfs(to, id);
  }
}

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<m;i++) {
    int x,y; cin>>x>>y;
    v[x].push_back(y); v[y].push_back(x);
  }
  int id = 0;
  for(int i=0;i<n;i++) {
    if (!u[i]) {dfs(i,id); id++;}
  }
  if (2 * (id-1) > n) return puts("Impossible") * 0;
  if (id == 1) return puts("0") * 0;
  ll ans=0;
  for(int i=0;i<id;i++) {
    ans += que[i].top(); que[i].pop();
    while(!que[i].empty()) {al.push(que[i].top()); que[i].pop();}
  }
  for(int i=0;i<id-2;i++) {
    ans += al.top(); al.pop();
  }
  cout<<ans<<endl;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef string str;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;

//0~nの範囲操作
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//1~nの範囲操作
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
//n~0を後ろから範囲操作
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
//出力後改行を
#define fin(ans) cout << (ans) << endl;
//出力後空白を
#define blank(ans) cout << (ans) << " ";
//２つの値をセットに\
sort -> p -> q
#define mp(p, q) make_pair(p, q)
//３つ以上の値をセットに(3より多いときはカッコ内を増やす)\
sort -> p -> q -> r
#define mt(p, q, r) make_tuple(p, q, r)
//配列全操作
#define all(a) a.begin(), a.end()

void Main()
{
  ll n, k, q; cin >> n >> k >> q;
  vll a(q); rep(i, q) cin >> a[i];
  map<ll, ll> ans;
  rep(i, n)
  {
    ans[i] = 0;
  }
  rep(i, q)
  {
    a[i]--;
    if(ans.count(a[i]))
    {
      ans[a[i]]++;
    }
  }
  rep(i, n)
  {
    if(k - q + ans[i] > 0) fin("Yes")
    else fin("No")
  }
  return;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

Measured memory_bytes: 9216
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int len = S.length();
    int ans = 0;
    if(len == 1) {
        cout << stoll(S) << endl;
        return 0;
    }
    rep(i, len) {
        int tmp = 1;
        int loop = 1;
        rep(j, len-2) loop *= 2;
        int keep = len - i - 1;
        while(loop > 0){
            rep(j, loop) {
                ans += (S[i] - '0') * tmp;
            }
            loop /= 2;
            if (keep > 0) tmp *= 10;
            keep--;
        }
        // dump(ans);
    }
    ans += stoll(S);
    cout << ans << endl;




    return 0;
}


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

int main() {
	int N, ans = 0, tmp;
	cin >> N;
	vector<int> A(N);
	for (int& i : A) cin >> i;
	for (int i = 1; i < N; ++i) {
		tmp = i - 1;
		for (int j = i; j < N; ++j) {
			if (A[tmp] > A[j]) tmp = j;
		}
		if (tmp != i - 1) ++ans;
		swap(A[tmp], A[i - 1]);
	}
	for (int i = 1; i < N; ++i) cout << A[i - 1] << ' ';
	cout << A[N - 1] << endl << ans << endl;
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <cmath>

using namespace std;

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

	int n, k;
	cin >> n >> k;

	vector<double> e(n);

	for (int i = 0; i < n; i++) {
		double p;
		cin >> p;
		e[i] = (1 + p) / 2;
	}

	vector<double> dp(n);
	dp[0] = e[0];
	for (int i = 1; i < n; i++) {
		dp[i] += dp[i - 1] + e[i];
		if (i - k >= 0) {
			dp[i] -= e[i - k];
		}
	}


	cout << *max_element(dp.begin(), dp.end()) << endl;

	return 0;
}

Measured memory_bytes: 3456
#include<stdio.h> 

int main(void)
{
  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  if (a != b && a != c && b != c) {
     printf("No");
  } else if ( a == b && a == c && b == c) {
    printf("No");
  } else {
    printf("Yes");
  }
  
}





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

int main()
{
	int n, m;
	int x[101], y[101];

	cin >> n >> m >> x[0] >> y[0];

	for (int i = 1; i <= n; i++)
		cin >> x[i];

	for (int i = 1; i <= m; i++)
		cin >> y[i];

	sort(x, x + n + 1);
	sort(y, y + m + 1);

	if (x[n] < y[0])
		cout << "No War" << endl;
	else
		cout << "War" << endl;
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  if (n == 1)
    cout << 1 << endl;
  
  else if (2 <= n && n < 4)
    cout << 2 << endl;
  
  else if (4 <= n && n < 8)
    cout << 4 << endl;
  
  else if (8 <= n && n < 16)
    cout << 8 << endl;
  
  else if (16 <= n && n < 32)
    cout << 16 << endl;
  
  else if (32 <= n && n < 64)
    cout << 32 << endl;
  
  else
    cout << 64 << endl;
  
  return 0;
}      

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

using namespace std;

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

	vector < int >rows(N);
	vector < set < int >>K;

	for (int i = 0; i < N; i++) {
		int r;
		cin >> r;
		rows.push_back(r);

		set < int >st;
		for (int j = 0; j < r; j++) {
			int c;
			cin >> c;
			st.insert(c);
		}
		K.push_back(st);
	}

	set < int >evelyone = K[0];
	for (int i = 1; i < N; i++) {
		set < int >tmp_set;
		set_intersection(evelyone.begin(), evelyone.end(), K[i].begin(),
				 K[i].end(), inserter(tmp_set,
						      tmp_set.begin()));
		evelyone.swap(tmp_set);
	}

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

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2151>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int N,M,L;
struct edge{
    ll to,cost,num;
    edge(){};
    edge(ll a,ll b,ll c):to(a),cost(b),num(c){};
};
ll solve(){
    ll res = 0;
    vector<vector<edge>> G(N);
    for(int i = 0; i < M;i++){
        ll u,v,cost,num; cin >> u >> v >> cost >> num;
        u--; v--;
        G[u].emplace_back(v,cost,num);
        G[v].emplace_back(u,cost,num);
    }
    vector<vector<ll>> dist(N,vector<ll>(L+1,LINF));
    dist[0][0] = 0;
    queue<pll> q; q.push({0,0});
    while(q.size()){
        ll n,len; tie(n,len) = q.front(); q.pop();
        for(auto& e:G[n]){
            if(dist[e.to][len] > dist[n][len] + e.num){
                dist[e.to][len] = dist[n][len] + e.num;
                q.push({e.to,len});
            }
            if(len + e.cost > L) continue;
            if(dist[e.to][len+e.cost] > dist[n][len]){
                dist[e.to][len+e.cost] = dist[n][len];
                q.push({e.to,len+e.cost});
            }
        }
    }
    res = *min_element(dist[N-1].begin(), dist[N-1].end());
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> N >> M >> L,N|M|L){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3496
g(){int x;scanf("%d",&x);x?x:exit(0);}
main(m,v,x){
  for(;;){double s=0,t=0,z=.01745329,e=.000001;
    for(v=360,m=g();--m;s+=sin(x*z))v-=(x=g());s+=sin(v*z);
    for(v=360,m=g();--m;t+=sin(x*z))v-=(x=g());t+=sin(v*z);
    puts(s>t+e?"1":s+e<t?"2":"0");
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i, v.size()){ cout << v[i] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

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

int mod = 1000000007;
//int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    int x, y, a;
    vec v(N, 0);
    REP(i, N - 1){
        cin >> x >> y >> a;
        v[x] ^= a;
        v[y] ^= a;
    }
    vec cnt(16, 0);
    for(int i: v) cnt[i]++;
    int ans = 0;
    int X = 0;
    REP(i, 15){
        ans += cnt[i + 1] / 2;
        if(cnt[i + 1] % 2) X ^= bit(i);
    }

    vec dp(bit(15), INF);
    dp[0] = 0;
    FOR(n, 1, 15 + 1){
        int comb = bit(n) - 1;
        while(comb < bit(15)){
            int tmp = 0;
            REP(i, 15) if((comb >> i) & 1) tmp ^= (i + 1);
            if(tmp == 0){
                REP(i, 15) REP(j, 15) if(i != j && ((comb >> i) & 1) && ((comb >> j) & 1)){
                    int k = ((i + 1) ^ (j + 1)) - 1;
                    if((comb >> k) & 1) Min(dp[comb], dp[comb ^ bit(i) ^ bit(j) ^ bit(k)] + 2);
                    else Min(dp[comb], dp[comb ^ bit(i) ^ bit(j) ^ bit(k)] + 1);
                }
            }

            x = comb & -comb, y = comb + x;
            comb = ((comb & ~y) / x >> 1) | y;
        }

    }
    ans += dp[X];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int a,b,c,s;
    while(~scanf("%d %d %d",&a,&b,&c))
    {
        s=a*100+b*10+c;
        if(s%4==0)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<cstdio>
#define s(A,B) std::sort(A,B);
int main(){
int W[10],K[10],p;
for(int i=0;i<20;i++)
scanf("%d",&p),(i<10)?W[i]=p:K[i-10]=p;
s(W,W+10);
s(K,K+10);
int Wp=W[7]+W[8]+W[9],Kp=K[7]+K[8]+K[9];
printf("%d %d\n",Wp,Kp);
}

Measured memory_bytes: 0
import math
N, M = map(int, input().split())

if abs(N-M) >= 2:
    print(0)
else:
    if N == M:
        print(((math.factorial(N)*math.factorial(M)*2)%(10**9+7)))
    else:
        print((math.factorial(N)*math.factorial(M))%(10**9+7))

Measured memory_bytes: 5192
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
#define fi first
#define se second
map<int,int> mp;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c*d/gcd(c,d);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
ll n,c,k;
cin>>n>>c>>k;
vector<ll> a(n);
for(int i=0;i<n;i++){
    cin>>a.at(i);
}
sort(a.begin(),a.end());
ll cnt=0,ans=1,cntp=1;
for(int i=0;i<n-1;i++){
    if(cntp+1<=c&&cnt+a.at(i+1)-a.at(i)<=k){
        cnt+=a.at(i+1)-a.at(i);
        cntp++;
    }
    else {
        ans++;
        cnt=0;
        cntp=1;
    }
}
cout<<ans<<endl;
}


Measured memory_bytes: 1024