akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
using namespace std;

int H,W,K;
int sx,sy;
int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1};
char A[810][810];
int B[810][810] = {{0}},visited[810][810] = {0};
bool in(int x, int y){
	return 0<=x && x<=H-1 && 0<=y && y<=W-1;
}

void bfs(void){
	visited[sx][sy] = 1;
	B[sx][sy] = 0;
	queue<pair<int,int>> Q;
	Q.push({sx,sy});
	while(!Q.empty()){
		pair<int,int> p = Q.front();
		Q.pop();
		int x = p.first,y = p.second;
		for(int i=0;i<4;i++){
			int nx = x+dx[i],ny = y+dy[i];
			if(in(nx,ny) && visited[nx][ny]==0 && B[x][y]<K && A[nx][ny]=='.'){
				B[nx][ny] = B[x][y]+1;
				Q.push({nx,ny});
				visited[nx][ny] = 1;
			}
		}
	}
}

int main(){
	cin >> H >> W >> K;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> A[i][j];
			if(A[i][j]=='S'){
				sx = i; sy = j;
			}
		}
	}
	bfs();
	B[sx][sy] = 1;
	int ans = 1e9;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(B[i][j]!=0){
				int t = min(min(i,H-1-i),min(j,W-j-1));
				ans = min(ans,1+(t+K-1)/K);
				if(i==0 || i==H-1 || j==0 || j==W-1) ans = 1;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
int main() {
    int n;
    scanf("%d", &n);
	map<int, int> ma;
    rep(i, n) {
        int a;
        scanf("%d", &a);
        ma[a]++;
    }
    ll count = 0;
    for (auto itr : ma)
    {
        if(itr.second % 2 != 0) count++;
    }
    printf("%lld\n", count);
    return 0;
}

Measured memory_bytes: 8452
import sys
inp = sys.stdin.readline

class UnionFind:
  def __init__(self, n):
    self.tree = [-1] * n
  
  def union(self, a, b):
    a = self.root(a)
    b = self.root(b)
    if(a == b):
      return
    if(self.size(a) < self.size(b)):
      a, b = b, a
    self.tree[a] += self.tree[b]
    self.tree[b] = a
    
  def root(self, a):
    if(self.tree[a] < 0):
      return a
    res = self.root(self.tree[a])
    self.tree[a] = res
    return res
    
  def size(self, a):
    return -self.tree[self.root(a)]

N, M = map(int,inp().split())
A, B = [], []
for _ in range(M):
  a, b = map(int,inp().split())
  A.append(a-1)
  B.append(b-1)

uf = UnionFind(N)

res = N*(N-1)//2
result = [0] * M
for i in range(M-1, -1, -1):
  result[i] = res
  if(uf.root(A[i]) != uf.root(B[i])):
    res -= uf.size(A[i]) * uf.size(B[i])
    uf.union(A[i], B[i])

for r in result:
  print(r)

Measured memory_bytes: 16952
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

int main(){

	ll n;
	cin>>n;

	ll ans=0;

	for(ll i=1;i<=n;i++){
		if(i%3!=0 && i%5!=0){
			ans+=i;
		}
	}

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


Measured memory_bytes: 3640
import re
n, a, b, c, d = map(int, input().split())
road = input()
if c < d:
    if re.search('##', road[a:d]) is None:
        print('Yes')
    else:
        print('No')
 
elif c > d:
    if re.search('##', road[a:]) is None and re.search('\.\.\.', road[b-2:d+1]) is not None:
        print('Yes')
    else:
        print('No')

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

using namespace std;

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

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

ll N, A, B;
ll h[101010];

void solve() {
    cin >> N >> A >> B;
    rep(i,N) {
        cin >> h[i];
    }
    ll lo = 0, hi = (ll)1e9;
    ll mid;
    while (hi - lo > 1) {
        mid = (lo + hi) / 2;
        ll c = 0;
        rep(i,N) {
            ll d = A - B;
            if (h[i] > mid * B) c += (ll)ceil(1. * (h[i] - mid * B) / d);
        }
        if (c <= mid) {
            hi = mid;
        } else {
            lo = mid;
        }
    }
    cout << hi << endl;
}

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


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    int n, k, ans = 0;
    cin >> n >> k;

    while (n > 0) {
        ++ans;
        n /= k;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

int n, m;
vector <string> a, b;

bool check(int x, int y){
    if(x + m > n) return false;
    int k = 0;
    for(int i = x; i < x + m; i++){
        string s = a[i].substr(y, m);
        if(s != b[k++]) return false;
    }
    
    return true;
}

void solve(){
    int w, a, b;
    cin >> w >> a >> b;
    if(a + w <= b) cout << b - a - w;
    else if(b + w <= a) cout << a - b - w;
    else cout << 0;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


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

int main() {
  int N;
  long long D, cnt=0; 
  cin >> N >> D;
  vector<long long> X(N), Y(N);

  rep(i, N) {
    cin >> X[i] >> Y[i];
    if(sqrt((X[i]*X[i])+(Y[i]*Y[i])) <= D) cnt++;
  }
  cout << cnt << '\n';
}

Measured memory_bytes: 6492
#include <iostream>
#include <deque>
#include <algorithm>

using namespace std;

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

    deque<int> d;
    bool isReversed = false;

    for (int i = 0; i < n; i++) {
        int value;
        cin >> value;

        if (isReversed) {
            d.push_front(value);
        } else {
            d.push_back(value);
        }

        isReversed = !isReversed;
    }

    if (isReversed) {
        reverse(d.begin(), d.end());
    }

    for (auto& i : d) {
        cout << i << " ";
    }

    cout << endl;
}

Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Stack;
 

 class Main{
      static Stack<takara>stT=new Stack<takara>();
      static takara[] takaras;
      static int w , n;
      static int vesW,vesV;
      static int[][] m;
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{
             String line; int _case=0;
             while((line=br.readLine())!= null){
                 stT.clear();
                 w=Integer.parseInt(line);if(w==0)break;
                 n=Integer.parseInt(br.readLine());_case++;
                 takaras = new takara[n];
                 for(int i=0;i<n;i++){line=br.readLine();
                    String[] split= line.split(",");
                    int wei_t=Integer.parseInt(split[1]);int val_t=Integer.parseInt(split[0]);
                     takara t=new takara(wei_t, val_t);   takaras[i]=t;
                 }//fin.setup
                 m = new int[n+1][w+1];
                 for(int i=1;i<=n;i++){
                     for(int j=0;j<=w;j++){
                         int w_i=takaras[i-1].wei,p_i=takaras[i-1].val;
                         if(w_i<=j)m[i][j]=Math.max(m[i-1][j], m[i-1][j-w_i]+p_i);
                         else m[i][j]=m[i-1][j];
                     }
                 }
                 //System.out.println("aa");
                 
                 vesW=w;vesV=0;//cal(0);
                 vesV=m[n][w];
                 for(int ii=w;m[n][ii]==vesV;ii--){vesW=ii;}
                 System.out.println("Case "+_case+":");
                 System.out.println(vesV);System.out.println(vesW);
             }
             br.close();
         }catch(Exception e){}         
     }
     static void cal(int count){
         //System.out.print("cou"+count+" ");takaras[count].printt();System.out.println(" w"+totalW()+",v"+totalV());
         if(totalW()>w)return;
         if(totalV()>vesV){//System.out.println("bestV_over");for(takara t:stT)t.printt();System.out.println("");
             vesV=totalV();vesW=totalW();}
         else if(totalV()==vesV){//System.out.println("bestV");for(takara t:stT)t.printt();System.out.println("");
             if(totalW()<vesW)vesW=totalW();}
         if(n==count)return;
         stT.add(takaras[count]);cal(count+1);stT.pop();
         cal(count+1);
     }
     
     static int totalW(){int tw=0;for(takara t:stT)tw+=t.wei;return tw;}
     static int totalV(){int tw=0;for(takara t:stT)tw+=t.val;return tw;}
    
 }

class takara{
    int wei;int val;
    takara(int w,int v){this.wei=w;this.val=v;}
    void printt(){System.out.println("w"+wei+" v"+val);}
}

Measured memory_bytes: 30164
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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; }

//int A = 0xffffffff;

int main(){
    int N;
    cin >> N;
    vector<unsigned int> v(N);
    rep(i,N){
        cin >> v[i];
    }
    unsigned int sum = 0;
    for(int i=0; i<N; ++i){
        sum = sum ^ v[i];
    }
    rep(i,N){
        cout << (sum ^ v[i]) << endl;
    }

    return 0;
}


Measured memory_bytes: 4044
#include <cstdio>
inline char tc() {
	static char fl[100], *A = fl, *B = fl;
	return A == B && (B = (A = fl) + fread(fl, 1, 100, stdin), A == B) ?
	EOF :
																			*A++;
}
inline int read() {
	int a = 0;
	static char c;
	while ((c = tc()) < 48 || c > 57)
		;
	while (c >= 48 && c <= 57)
		a = a * 10 + c - 48, c = tc();
	return a;
}

int main() {
	int n, i;
	n = read();
	int a, count4 = 0, count2 = 0, odd = 0;
	for (i = 0; i < n; ++i) {
		a = read();
		if (a & 1) {
			odd++;
		} else if (!(a & 3)) {
			count4++;
		} else
			count2 = 1;
	}
	if (odd == 0 || odd + count2 <= count4 + 1) {
		puts("Yes");
		return 0;
	}
	puts("No");
}


Measured memory_bytes: 1532
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

int upper_bound(int a[], int n, int x)
{
	int l = 0;
	int h = n; // Not n - 1
	while (l < h)
	{
		int mid = (l + h) / 2;
		if (x <= a[mid])
		{
			h = mid;
		}
		else
		{
			l = mid + 1;
		}
	}
	return l;
}

int main(void)
{
	int n, nr = 0, ng = 0, nb = 0;
	long long sum = 0;
	char str[4001] = {
		0,
	};
	int r_arr[4001] = {
		0,
	};
	int g_arr[4001] = {
		0,
	};
	int b_arr[4001] = {
		0,
	};

	scanf("%d", &n);
	scanf("%s", str);

	for (int i = 0; i < n; i++)
		if (str[i] == 'R')
			r_arr[nr++] = i;
		else if (str[i] == 'G')
			g_arr[ng++] = i;
		else
			b_arr[nb++] = i;

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (str[i] == str[j])
				continue;

			if ((str[i] == 'R' && str[j] == 'G') || (str[i] == 'G' && str[j] == 'R'))
			{
				sum += nb - upper_bound(b_arr, nb, j);
				if ((2 * j - i) < n && str[2 * j - i] == 'B')
					sum--;
			}
			else if ((str[i] == 'R' && str[j] == 'B') || (str[i] == 'B' && str[j] == 'R'))
			{
				sum += ng - upper_bound(g_arr, ng, j);
				if ((2 * j - i) < n && str[2 * j - i] == 'G')
					sum--;
			}
			else if ((str[i] == 'G' && str[j] == 'B') || (str[i] == 'B' && str[j] == 'G'))
			{
				sum += nr - upper_bound(r_arr, nr, j);
				if ((2 * j - i) < n && str[2 * j - i] == 'R')
					sum--;
			}
		}
	}

	printf("%lld", sum);

	return 0;
}


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

class Program {
    static int n, ans;

    static void Main() {
        n = NextInt();
        for (var i = 0; ; i++) {
            DFS(i, "0");
        }
    }

    static void DFS(int rest, string s) {
        if (rest == 0) {
            if (long.Parse(s) > n) {
                WriteLine(ans);
                Environment.Exit(0);
            }
            foreach (var v in "357") {
                if (!s.Contains(v + "")) {
                    return;
                }
            }
            ans++;
        } else {
            foreach (var c in "357") {
                DFS(rest - 1, s + c);
            }
        }
    }

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

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

Measured memory_bytes: 15312
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

vector<vector<int>> List;
int tmp[10];
bool used[10];
int N;

void dfs(int cur){
    if(cur >= N) {
        vector<int> nxt(N);
        for(int i = 0; i < N; ++i) nxt[i] = tmp[i];
        List.push_back(nxt);
        return ;
    }

    for(int i = 1; i <= N; ++i) if(!used[i]) {
        used[i] = true;
        tmp[cur] = i;
        dfs(cur+1);
        used[i] = false;
    }
}

void Permutation_init(){
    for(int i = 1; i <= N; ++i) used[i] = false;
    dfs(0);
}

int main()
{
    scanf("%d", &N);
    Permutation_init();
    vector<int> P(N), Q(N);
    for(int i = 0; i < N; ++i) scanf("%d", &P[i]);
    for(int i = 0; i < N; ++i) scanf("%d", &Q[i]);
    int a, b;
    for(int i = 0, i_len = List.size(); i < i_len; ++i) {
        if(List[i] == P) a = i;
        if(List[i] == Q) b = i;
    }
    printf("%d\n", abs(a-b));
    return 0;
}

Measured memory_bytes: 3256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


K = int(input())
result = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            add = gcd(i, j, k)
            result += add

print(result)


Measured memory_bytes: 69504
import java.io.IOException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		final int Q = sc.nextInt();
		
		for(int q = 0; q < Q; q++){
			final int c = sc.nextInt();
			final int a = sc.nextInt();
			final int n = sc.nextInt();
			
			int count = 0;
			
			final int min_n = Math.min(c, Math.min(a, n));
			
			count += min_n;
			
			final int c_ = c - min_n;
			final int a_ = a - min_n;
			//System.out.println(c_ + " " + a_);
			
			final int min_a = Math.min(c_ / 2, a_);
			
			count += min_a;
			
			final int c__ = c_ - min_a * 2;
			
			count += c__ / 3;
			
			System.out.println(count);
			
			
		}
	}

}

Measured memory_bytes: 20500
module M = Map.Make (struct type t = int let compare = compare end)

let () =
    let split s =
        let rec loop i cur flag acc =
            if i = String.length s then ( if flag then cur :: acc else acc) else (
                match flag, s.[i] with
                | true,  ' ' -> loop (i + 1) "" false (cur :: acc)
                | false, ' ' -> loop (i + 1) "" false acc
                | true,  v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
                | false, v   -> loop (i + 1) (Printf.sprintf "%s%c" cur v) true acc
            )
        in
        List.map int_of_string (List.rev (loop 0 "" false []))
    in
    let main () =
        let n, k = Scanf.sscanf (read_line ()) "%d %d" (fun n k -> n, k) in
        let a = Array.of_list (split (read_line ())) in
        let arr = Array.make (n + 1) 0 in
        let rec loop i sum =
            if i < n then (
                let sum = sum + a.(i) - 1 in
                arr.(i + 1) <- sum mod k;
                loop (i + 1) sum
            )
        in
        loop 0 0;
        let add k v map = M.add k (v + try M.find k map with _ -> 0) map in
        let rec loop i map acc =
            if i > n then acc else
                let map = if i >= k then add arr.(i - k) (-1) map else map in
                let acc = acc + try M.find arr.(i) map with _ -> 0 in
                let map = add arr.(i) 1 map in
                loop (i + 1) map acc
        in
        let r = loop 1 (M.add 0 1 M.empty) 0 in
        Printf.printf "%d\n" r
    in
    main ()

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n; cin >> n;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	vector<int>b(n);
	rep(i, n)cin >> b[i];

	//準備
	vector<int>ar(n);
	ar[0] = a[0];
	for (int i = 1; i < n; i++) {
		ar[i] = a[i] + ar[i - 1];
	}

	vector<int>br(n);
	br[0] = b[0];
	for (int i = 1; i < n; i++) {
		br[i] = b[i] + br[i - 1];
	}

	int ans = 0;
	int now = 0;

	for (int i = 0; i < n; i++) {
		if (i == 0) {
			now = ar[0] + br[n - 1];
		}
		else {
			now = ar[i] + br[n - 1] - br[i - 1];
		}

		ans = max(ans, now);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int m;
    cin >> n >> m;
    ll gcd;
    ll tmp;
    ll d = m / n;
    rep_re(i, d){
        if(m % i == 0){
            gcd = i;
            tmp = gcd * n;
            if(tmp <= m){
                //cout << tmp << endl;
                cout << gcd << endl;
                return 0;
            }
        }
    }
}

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

int main() {
	int N;
	cin >> N;
	string s, t;
	cin >> s >> t;
	for(int i = N-1;i >= 0;i--){
		if(s.substr(N-1-i,i+1) == t.substr(0,i+1)){
			cout << 2*N-i-1 << endl;
			return 0;
		}
	}
	cout << N*2 << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<ll> l(200001);
	map<ll, ll> mp;
	rep(i, n) {
		int a;
		cin >> a;
		l[a]++;
		mp[a]++;
	}
	sort(l.begin(), l.end());
	ll tmp = mp.size();
	ll ans = 0;
	rep(i, 200001) {
		if (tmp <= k) break;
		if (l[i] > 0) {
			ans += l[i];
			tmp--;
		}
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}



Measured memory_bytes: 17500
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
    	Scanner sc = new Scanner(System.in);
    	String str = sc.next();
    	char[] strChars = str.toCharArray();
    	for (int i = 1; i <= strChars.length; i++) {
    		if (i % 2 == 1) {
    			System.out.print(strChars[i - 1]);
    		}
    	}
    	System.out.println();
    }

}

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

struct hoge{
	int i;
	double bmi;
};

int main(){
	int ini, h, w, n, ans;
	double hm;
	hoge set[1000000];
	
	while(1){
		ans = 0;
		cin >>n;
		if(n == 0) break;
		for(int i = 0; i < n; i++){
			cin >>ini >>h >>w;
			hm = (h / 100.0) * (h / 100.0);
			set[i].i = ini;
			set[i].bmi = w / hm;
		}
		for(int i = 0; i < n; i++){
			if(abs(set[i].bmi - 22) < abs(set[ans].bmi - 22)){
				ans = i;
			}
		}
		cout <<set[ans].i <<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
int main() {
    ll h,n;
    cin >> h >> n;
    vector<ll>s;
    for (ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        s.push_back(x);
    }
    ll sum = 0;
    for (auto i = s.begin(); i != s.end(); i++) {
        sum += *i;
    }
    if(sum >= h) {
        cout <<"Yes" <<endl;
    }
    else {
        cout <<"No" <<endl;
    }
     return 0;
}


Measured memory_bytes: 1400
#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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    int ans = 0;
    REP(i, 1, min(K, N)) ans += X;
    REP(i, K + 1, N) ans += Y;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
'use strict';

function main(input) {
  const lines = input.split('\n');
  lines.pop();
  lines.forEach(line => {
    const s = line.split(' '),
      k = parseInt(s[0], 10),
      x = parseInt(s[1], 10);
    f(k, x);
  });
}

function f(k, x) {
  const r = k - 1;
  const min = -1000000,
    max = 1000000;
  let oMin = x - r,
    oMax = x + r;
  if (oMin < min) {
    oMin = min;
  }
  if (oMax > max) {
    oMax = max;
  }
  for(let i = oMin; i <= oMax; i++) {
    console.log(i);
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 9264
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class QQ
{
    public static void Main(String[] args)
    {
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= 9; j++)
            {
                Console.WriteLine(String.Format("{0}x{1}={2}",i,j,i*j));
            }
        }
    }
}

Measured memory_bytes: 9080
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  ll sum=0;
  vi A(n),B(m);
  for(auto &a:A)cin>>a;
  for(auto &b:B)cin>>b;
  for(int i=0;i<n-1;i++){
    sum+=((A[i+1]-A[i])*(n-1-i)%MOD*(i+1))%MOD;
    sum%=MOD;
  }
  ll ans=0;
  for(int i=0;i<m-1;i++){
    ans+=((B[i+1]-B[i])*(m-1-i)%MOD*(i+1)%MOD*(sum)%MOD)%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 55
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> x(n);
    vector<ll> y(n);
    vector<ll> xarr, yarr;

    rep(i, n) {
        cin >> x[i] >> y[i];
        xarr.push_back(x[i]);
        yarr.push_back(y[i]);
    }

    sort(xarr.begin(), xarr.end());
    sort(yarr.begin(), yarr.end());

    ll ans = 1LL * ((xarr[n-1]-xarr[0]) * (yarr[n-1]-yarr[0]));

    for(int x1=0; x1<n; ++x1) {
        for(int x2=x1+1; x2<n; ++x2) {
            for(int y1=0; y1<n; ++y1) {
                for(int y2=y1+1; y2<n; ++y2) {
                    int num = 0;
                    ll lx = xarr[x1], rx = xarr[x2];
                    ll by = yarr[y1], uy = yarr[y2];

                    for(int i=0; i<n; ++i) {
                        if(lx <= x[i] && rx >= x[i] && by <= y[i] && uy >= y[i]) ++num;
                    }

                    if (num >= k) ans = min(ans, 1LL * ((rx-lx)*(uy-by)));
                }
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll r,g,b,n;
  cin >> r >> g >> b >> n;
  ll ans=0;
  for(ll i=0;i*r<=n;i++){
    for(ll j=0;j*g+i*r<=n;j++){
      ll k=n-i*r-j*g;
      if(k%b==0)ans++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll a, b;
    cin >> a >> b;

    if(a > b) swap(a, b);
    if((b-a)%2) cout << "IMPOSSIBLE" << endl;
    else cout << a+(b-a)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll x[200001];
	ll xsum[200001]={};
	ll X;
	scan(N);scan(X);
	ll iniE=N*X;
	rep(i,N){
		scan(x[i]);
		xsum[i+1]=xsum[i]+x[i];
	}
	ll ans=INFl;
	rep1(i,N){
		ll dropE=X*i;
		ll carryE=5*xsum[N];
		int overflow=0;
		for(int j=N-2*i;j>0;j-=i){
			carryE+=2*xsum[j];
			if(carryE<0){
				overflow=1;
				break;
			}
		}
		if(overflow) continue;
		ans=min(ans,carryE+dropE+iniE);
	}
	prin(ans);
	return 0;
}


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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N;
  cin >> N;
  map<long long,long long> a;
  froop1(0,N){
    int c;
    cin >> c;
    if(a.count(c)){
      a[c]++;
    }else{
      a[c] = 1;
    }
  }
  long long M;
  cin >> M;
  long long sum = 0;
     for(pair<long long,long long> p : a){
     long long p1 = p.first;
     long long p2 = p.second;
    sum += p1 * p2;
   }
  froop1(0,M){
    long long d,e;
    cin >> d >> e;
     if(a.count(d)){
       if(a.count(e)){
         sum += (e - d)*a[d];
         a[e] += a[d];
         a.erase(d);
       }else{
       sum += (e - d)*a[d];
       a[e] = a[d];
       a.erase(d);
     }
     }
        cout << sum << endl;
}
}

Measured memory_bytes: 7488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;

vector<ll> maisu;
vector<ll> patemaisu;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> smalld, bigd;
    reps(i,1,(ll)(sqrt(m))+1){
        if(m%i==0){
            smalld.push_back(i);
            bigd.push_back(m/i);
        }
    }
    int numd = smalld.size();
    ll ans = 0;
    string flag = "No";
    rep(i,numd){
        if(n*bigd[i]<=m){
            flag = "Yes";
            ans = bigd[i];
            break;
        }
    }
    if(flag=="No"){
        repr(i,numd-1,-1){
            if(n*smalld[i]<=m){
                ans = smalld[i];
                break;
            }
        }
    }
    cout << ans;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

//constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	vii pairs(n);
	rep(i, n) cin >> pairs[i].first >> pairs[i].second;
	sort(ASC(pairs));

	priority_queue<int> pq;
	ll score = 0;
	int j = 0;

	rep(i, m) {

		while (j < n && pairs[j].first <= i + 1) {
			pq.push(pairs[j].second);
			j++;
		}

		if (!pq.empty()) {
			score += pq.top();
			pq.pop();
		}
	}
	cout << score << endl;
}

Measured memory_bytes: 1660
#include <iostream>

using namespace std;

bool solve(int* array, int v, int sum, int i, int N)
{
    if(sum == v) return true;
    if(i > N - 1 || sum > v) return false;
    return solve(array, v, sum, i+1, N) || solve(array, v, sum + array[i], i+1, N);
}

int main()
{
    int n, m, q;
    int array[20];
    cin >> n;
    for(int i=0;i<n;++i) cin >> array[i];
    cin >> m;
    for(int i=0;i<m;++i)
    {
        cin >> q;
        if(solve(array, q, 0, 0, n)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}



Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    ll n,t; cin >>n>>t;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    vector<ll> profit(n);
    ll mn = INFLL;
    for (ll i = 0; i < n; i++) {
        mn = min(mn, a[i]);
        profit[i] = a[i] - mn;
    }

    sort(profit.begin(), profit.end(), greater<ll>());

    ll ans = 1;
    ll mp = profit[0];
    for (ll i = 1; i < n; i++) {
        if (profit[i] == mp) {
            ans++;
        } else {
            break;
        } 
    }

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


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;


int main(void) {
	int n, q, s[100001], t[501];
	int count = 0;

	cin >> n;
	FOR(i, 1, n) {
		cin >> s[i];
	}
	cin >> q;
	FOR(i, 1, q) {
		cin >> t[i];
	}

	FOR(i, 1, q) {
		FOR(u, 1, n) {
			if (t[i] == s[u]) {
				count++;
				break;
			}
		}
	}

	cout << count << endl;
	return 0;
}


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

int main(void) {
    int p[5], k;
    for (int i = 0; i < 5; i++) {
        cin >> p[i];
    }
    cin >> k;
    sort(p, p + 5);
    if (p[4] - p[0] > k) {
        cout << ":(\n";
    } else {
        cout << "Yay!\n";
    }
}


Measured memory_bytes: 256
program am
implicit none
integer::N,A,B
character(10**5)::S
integer::CNT=0,CNTB=0

integer::i
read*,N,A,B
read*,S
do i=1,N
    select case(S(i:i))
    case("a")
        print"(A)",trim(merge("Yes","No ",CNT<A+B))
        CNT=CNT+1
    case("b")
        print"(A)",trim(merge("Yes","No ",CNT<A+B.and.CNTB<B))
        if(CNT<A+B.and.CNTB<B)CNT=CNT+1
        CNTB=CNTB+1
    case default
        print"(A)","No"
    end select
end do

end program am

Measured memory_bytes: 932
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

void solution(){
	int mod = 1e9 + 7;
	int n; cin >> n;
	vector<ll> a(n); for(auto& x : a) cin >> x;
	ll s = 0;
	for(ll x : a) s += x;
	s %= mod;
	ll ans = 0;
	for(ll x : a){
		s = (s - x + mod) % mod;
		ans = (ans + x * (s + mod) % mod) % mod;
	}
	cout << ans << endl;
}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
 
using namespace std;
 
int main(){
    ll N,M; cin >> N >> M;
    ll befans[N];
    ll AC[N];
    for (int i = 0; i < N; i++)
    {
        befans[i] = AC[i] = 0;
    }
    
    for (int i = 0; i < M; i++)
    {
        ll p; string s;
        cin >> p >> s;
        if(s == "AC") AC[p-1] = 1;
        else if(AC[p-1] == 0) befans[p-1]++;
    }
    ll ans1 = 0;
    ll ans2 = 0;
    for (int i = 0; i < N; i++)
    {
        ans1 += AC[i];
        if(AC[i] == 1) ans2 += befans[i];
    }
    cout << ans1 << " " << ans2 << endl;
}

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

const long long N=200000;
long long a[N],b[N];


int main(){
	
ios_base::sync_with_stdio(false);

long long n,i,j,ans;
ans=0;

cin>>n;

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

for(i=0;i<n;i++){
	for(j=i+1;j<n;j++)
ans+=a[i]*a[j];}

cout<<ans<<endl;

return 0;}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int k, a, b; std::cin >> k >> a >> b;
  bool ok = false;
  for (int i = a; i <= b; ++i) {
    if (i%k == 0) ok = true; 
  }
  if (ok) std::cout << "OK" << std::endl;
  else std::cout << "NG" << std::endl;
  
  return 0;
}

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

using namespace std;

#define LL           long long
#define ULL          long long unsigned
#define LD           long double
#define ff              first
#define ss              second
#define FOR(i,n)     for(int i=0;i<n;i++)
#define FLR(i,n)     for(LL i=0;i<n;i++)
#define RFOR(i,n)    for(int i=n-1;i>=0;i--)
#define RFLR(i,n)    for(LL i=n-1;i>=0;i--)
#define rep(i,a,b)   for(int i=a;i<=b;i++)
#define repl(i,a,b)  for(LL i=a;i<=b;i++)
#define fast         ios_base::sync_with_stdio(0);cin.tie(0);
#define all(a)       a.begin(),a.end()
#define ABS(x)       ((x)<0?-(x):(x))
#define NL           "\n"
#define pb           push_back
#define mk              make_pair
#define pi           acos(-1.0)
#define prec(n)      fixed << setprecision(n)
#define sq(a)          (a)*(a)
#define asi          cout<<"check"<<" ";
#define all_set(arr,val) memset(arr,val,sizeof(arr))

int main()
{
    fast;
    int i,j,k,ans,n,x;
    cin>>n;
    set<int>st;
    while(n--){
        cin>>x;
        if(st.find(x)==st.end())st.insert(x);
        else st.erase(x);
    }
    cout<<st.size();


}


Measured memory_bytes: 8172
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt(),k=sc.nextInt();
        int a=sc.nextInt();
        int m=a;
        int g=a;
        for (int i = 0; i < n - 1; i++) {
            int b=sc.nextInt();
            m=max(m,b);
            g=gcd(a,b);
            a=b;
        }
        if(k<=m&&k%g==0)out.println("POSSIBLE");
        else out.println("IMPOSSIBLE");
    }
    static int gcd(int a,int b){
        if(b==0)return a;
        return gcd(b,a%b);
    }
}

Measured memory_bytes: 47680
n,a,b=map(int,input().split())
if a%2==b%2:
  c=(b-a)//2
  if (c+1)*2<=b-a:
    c+=1
  print(c)
else:
  t=min(b-1+a,n-a+n-b+1)
  c=t//2
  if (c+1)*2<=t:
    c+=1
  print(c)

Measured memory_bytes: 38384
n = int(input())
a = list(map(int,input().split()))
mod = 1000000007
ans = 1
tmp = [0] * n
for i in range(n):
    if a[i] == 0:
        ans *= 3 - tmp[0]
        tmp[0] += 1
    else:
        ans *= tmp[a[i]-1] - tmp[a[i]]
        ans %= mod
        tmp[a[i]] += 1

print(ans)


Measured memory_bytes: 14524
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
const int N = 1e7;
ll total_days = 0;
vector<vector<int> > input(N);
int dp[N][3];
void solve()
{
	dp[0][0] = input[0][0];
	dp[0][1] = input[0][1];
	dp[0][2] = input[0][2];
  for(int i=1;i<total_days;i++)
	{
       dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + input[i][0];
       dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + input[i][1];
       dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + input[i][2];
         
	}
cout<<max(dp[total_days-1][0],max(dp[total_days-1][1],dp[total_days-1][2]));

}
int main()
{
/* freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout);
#endif
*/
cin>>total_days;
for(ll i=0;i<total_days;i++)
 for(ll j=0;j<3;j++)
 {
 	ll temp;
 	cin>>temp;
   input[i].pb(temp);
 }
solve();
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt = 0;
    for(int i = 0;i<n; ++i){
        string q="";
        q+=s[i];
        q+=s[i+1];
        q+=s[i+2];
        if(q=="ABC")cnt++;
    }
    cout<<cnt;
    return 0;
}


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

// グローバル変数
string s;

// 関数プロトタイプ
void input();
void solve();

int main(void)
{
    input();
    solve();  
}

// 標準入力
void input() {
    cin >> s;
}

void solve() {
    int tmp = 0;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if(s[i] == 'A') {
            tmp++;
        } else 
        if(s[i] == 'C') {
            tmp++;
        } else 
        if(s[i] == 'G') {
            tmp++;
        } else
        if(s[i] == 'T') {
            tmp++;
        } else {
            tmp = 0;
        }
        if(ans < tmp) {
            ans = tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 1000000007
#define ll long long int
#define fo(i,a,n) for(int i=a;i<n;i++)
#define ull unsigned long long int
#define pb push_back
#define eb emplace_back
using namespace std;

ll power(ll x, ll y) {
    ll res = 1;
    x = x % MAX;
    while (y > 0) {
        if (y & 1) {
            res = ((res)%MAX * (x)%MAX) % MAX;
        }
        y = y>>1; 
        x = ((x)%MAX*(x)%MAX) % MAX;
    }
    return res;
}


int main(){

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

    // int t;
    // cin>>t;
    // while(t--){
    // }
    ll n;
    cin>>n;

    ll ans = power(10,n);
    ll dub = power(8,n);
    ll fub = (power(9,n)%MAX + power(9,n)%MAX)%MAX;
    ans = ( ans + dub - fub + MAX)%MAX; 
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3608
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, k = LI()
    A = LI()

    C = [0]
    C2 = [0]
    for a in A:
        C.append(C[-1] + a)
        if a < 0: a = 0
        C2.append((C2[-1] + a))

    ans = 0
    # １つの[j, j+k)以外の全てのマスは白と黒好きに塗ることができる
    # ai > 0なら黒，それ以外は白に塗る
    for i in range(n - k + 1):
        ans = max(ans, max(C[i + k] - C[i], 0) + C2[i] + C2[-1] - C2[i + k])

    return ans


print(main())


Measured memory_bytes: 17992
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math


def main():
  n, k = map(int, input().split())
  p = 1.0
  v = 0
  c = 0

  while True:
    w = max(n - k + 1, 0)
    v += w * p
    c += w

    if k == 1:
      break

    n = min(k - 1, n)
    k = int(math.ceil(k / 2))
    p /= 2

  #print(h)
  print('{:.9f}'.format(v / c))


if __name__ == '__main__':
  main()



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int maxN = (int)1e5 + 10;
int x[maxN];
int y[maxN];
int t[maxN];
int n;
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("log.in", "r", stdin);
    //freopen("log.out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 1; i <= n; i++) {
        int p = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        if ((p % 2 == (t[i] - t[i - 1]) % 2) && p <= (t[i] - t[i - 1])) continue;
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 1408
n, m =  list(map(int, input().split()))
from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
if n <= 1:
    a = 0
else:
    a = combinations_count(n,2)
if m <= 1:
    b = 0
else:
    b = combinations_count(m,2)
print(a + b)

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

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

int main() {
	int x, y;
	cin >> x >> y;
	cout << gcd(x,y) << endl;
	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;
const int MOD = 1000000007;
const int INF = 1e9;

#define EPS (1e-7)
#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define tasu(x, y) (x+y)%MOD
#define kake(x, y) (x*y)%MOD

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	return ((m / gcd(m, n)) * n);
}


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

	if(X==7 || X== 5 ||X==3){
		cout << "YES" << endl;
	}  else {
		cout << "NO" << endl;
	}

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  set<string> ss;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    ss.insert(move(s));
  }
  cout << ss.size() << endl;
  return 0;
}


Measured memory_bytes: 19240