akhauriyash/Code-Regression huggingface dataset:
open System

let N,M,X,Y=stdin.ReadLine().Split()|>fun c -> int c.[0],int c.[1],int c.[2],int c.[3]
let x =stdin.ReadLine().Split()|>Array.map int
let y =stdin.ReadLine().Split()|>Array.map int
[<EntryPoint>]
let main argv =
    let xmax = max X (Array.max x)
    let ymin = min Y (Array.min y)
    if xmax<ymin then "No War" else "War"
    |>stdout.WriteLine
    0

Measured memory_bytes: 13268
/*
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/9/ITP1_9_D
*/
#include <bits/stdc++.h>
using namespace std;

void print(string str, int a, int b) {
    for (int i = a; i <= b; i++)
        cout << str[i];
    cout << endl;
}

void replace(string &str, int left, int right, string sub) {
    for (int i = left, j = 0; i <= right; i++, j++)
        str[i] = sub[j];
}

void reverse(string &str, int a, int b) {
    string cp = str;
    for (int i = 0; i < str.size(); i++) {
        if (a <= i && i <= b) {
            str[i] = cp[(a + b) - i];
        } else {
            str[i] = cp[i];
        }
    }
}

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

    string src;
    cin >> src;

    int loop, left, right;
    cin >> loop;
    for (int i = 0; i < loop; i++) {
        string str;
        cin >> str;

        if (str == "print") {
            cin >> left >> right;
            print(src, left, right);

        } else if (str == "reverse") {
            cin >> left >> right;
            reverse(src, left, right);

        } else if (str == "replace") {
            string subst;
            cin >> left >> right >> subst;
            replace(src, left, right, subst);
        }
    }
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>

using namespace std;
#define PI 3.14159265359
#define ll long long int

int main(void)
{
    ll ans = 0, H, A;
    cin >> H >> A;
    while(H > 0){
        H -= A;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
slist = []
for i in range(n):
    slist.append(input())

first_list = []
last_list = []
first = ""
last = ""
for i in range(n):
    s = slist[i]

    a_count = 0
    b_count = 0
    min_s = ""
    for c in s:
        if c == ")":
            b_count-=1
        else:
            b_count+=1
        if b_count < 0:
            b_count = 0
            a_count+= 1
    min_s = ")"* a_count + "("*b_count

    ai = a_count
    bi = b_count

    if ai == 0:
        first += min_s
    elif bi == 0:
        last += min_s
    elif bi-ai >= 0:
        first_list.append([min_s,ai])
    else:
        last_list.append([min_s,bi])

first_list= sorted(first_list, key=lambda s: s[1])
last_list= sorted(last_list, key=lambda s: s[1], reverse=True)

ans = first
for i in range(len(first_list)):
    ans += first_list[i][0]
for i in range(len(last_list)):
    ans += last_list[i][0]
ans += last

a_count = 0
b_count = 0
min_s = ""
for c in ans:
    if c == ")":
        b_count-=1
    else:
        b_count+=1
    if b_count < 0:
        b_count = 0
        a_count+= 1

if a_count == 0 and b_count == 0:
    print("Yes")
else:
    print("No")

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

using namespace std;

static const int INF = 1 << 28;
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

#define MOD 1000000007
#define D(x) cout << x << endl
#define d(x) cout << x

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;

int main() { 
  int x;
  cin >> x;
  ll sum = 0;
  int i;
  for (i = 1; sum < x; i++) {
    sum += i;
  }
  i--;
  ll cnt = 0;
  for (int j = i; j > 0; j--) {
    if (x - j >= 0) {
      x -= j;
      cnt++;
    } else {
      cnt++;
    }
  }
  D(cnt);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
int s[200005];
int main()
{
    int a,b;
    int n;

    scanf("%d",&n);
    int i;
    for(i=0; i<n; i++)
        scanf("%d",&s[i]);
    int m=s[0];
    int j=0;
    for(i=0; i<n; i++)
    {
        if(m<s[i])
        {
            m=s[i];
            j=i;
        }
    }
    int k=0;
    for(i=0; i<n; i++)
    {
        if(s[i]==m)
            k++;
    }
    int ma;
    if(j!=0)
        ma=s[j-1];
    else
        ma=s[j+1];
    if(k==1)
    {
        for(i=0; i<n; i++)
        {
            if(ma<s[i]&&s[i]<m)
            {
                ma=s[i];

            }

        }
        for(i=0; i<n; i++)
        {
            if(i!=j)
                printf("%d\n",m);
            else
                printf("%d\n",ma);
            }
    }
    else
        for(i=0; i<n; i++)
        {
            printf("%d\n",m);
        }
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a[100005],b[100005],c[100005],n,nowa,nowc;
    long long ans=0;
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%d",&a[i]);
    for (int i=0;i<n;i++) scanf("%d",&b[i]);
    for (int i=0;i<n;i++) scanf("%d",&c[i]);
    sort(a,a+n);sort(b,b+n);sort(c,c+n);
    nowa=0;nowc=0;
    for (int i=0;i<n;i++)
    {
        while ((a[nowa]<b[i])&&(nowa<n)) nowa++;
        while ((c[nowc]<=b[i])&&(nowc<n)) nowc++;
        ans=ans+(long long)nowa*(n-nowc);
    }
    printf("%lld",ans);
    return 0;
}



Measured memory_bytes: 1408
n = int(input())
p =[int(i) for i in input().split()]
counter = 0
for i in range(1, n-1):
    if p[i] > min(p[i-1],p[i+1]) and p[i] < max(p[i-1], p[i+1]):
        counter += 1
print(counter)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    
    vvl c(3, vl(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> c[i][j];
        }
    }
    
    ll b0 = c[0][0];
    ll b1 = c[0][1];
    ll b2 = c[0][2];
    ll a1 = c[1][0] - b0;
    ll a2 = c[2][0] - b0;
    
    if(a1+b1 == c[1][1] && a1+b2 == c[1][2] && a2+b1 == c[2][1] && a2+b2 == c[2][2]) {
        out("Yes");
    }
    else {
        out("No");
    }
 
    re0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace B_ABC166
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int n =s[0];
            int k = s[1];
            int[] ans = new int[n];
            for(int i = 0;i<k;i++){
                int[] d =Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse); 
                int[] a = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
                for(int j = 0;j<d[0];j++){
                    ans[a[j]-1]=-1;
                }
            }
            int ansi = 0;
            for(int i = 0;i<n;i++){
                if(ans[i]==0){
                    ansi++;
                }

            }
            WriteLine(ansi);

        }
    }
}


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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

int main(void){
    for(int x, h; cin >> x >> h, x; printf("%.6f\n", x * (x + 2 * sqrt(pow(x / 2., 2.) + pow(h, 2.)))));

    return 0;
}

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

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> a(h);

  for (int i = 0; i < h; i++)
  {
    cin >> a.at(i);
  }

  for (int i = -1; i < h + 1; i++)
  {
    for (int j = -1; j < w + 1; j++)
    {
      if (i == -1 || i == h || j == -1 || j == w)
      {
        cout << "#";
      }
      else if (j == 0)
      {
        cout << a.at(i);
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3592
N = gets.chomp.to_i
S = gets.chomp.split(//).map(&:to_i)

require "set"
dp = {}
0.upto(N-1) do |i|
  dp.keys.each do |k1|
    dp[k1].keys.each do |k2|
      dp[k1][k2] << S[i]
    end
    dp[k1][S[i]] ||= Set.new
  end
  dp[S[i]] ||= {}
end
ans = 0
dp.each do |k1, v1|
  v1.each do |k2, v2|
    ans += v2.size
  end
end
puts ans


Measured memory_bytes: 6140
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        long a = sc.nextLong();
        long v = sc.nextLong();
        long b = sc.nextLong();
        long w = sc.nextLong();
        long t = sc.nextLong();

        if(a==b&&v==w) {
            System.out.println("YES");
            return;
        }

        double dis = Math.abs((a-b)*1.0);
        double speedDiff =(v-w)*1.0;
        if(speedDiff<=0&&dis!=0) {
            System.out.println("NO");
        }else {
            System.out.println(dis/speedDiff>t?"NO":"YES");
        }
    }
}

Measured memory_bytes: 27080
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    string s;
    cin >> s;
    int n = (int) s.size();

    ll ans = 0, cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'B') ++cnt;
        else ans += cnt;
    }

    cout << ans << endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z;
string s, t;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s >> t;
	s+=t;
	ld val = stold(s);
	if(sqrt(val) == (ll)(sqrt(val))) {
		cout<<"Yes";
	} else {
		cout<<"No";
	}
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

const int N = 1e5 + 5;

int n, L = 1, tot, a[N];
bool vis[N];

int main()
{
	std::cin >> n; if (n == 1) return puts("No"), 0;
	while ((L << 1) <= n + 1) L <<= 1;
	if (L == n) return puts("No"), 0;
	puts("Yes");
	for (int i = 1; i < L; i <<= 1) vis[a[++tot] = i] = 1;
	for (int i = 1; i < L; i++) if (!vis[i]) a[++tot] = i;
	for (int i = 1; i < tot; i++) printf("%d %d\n", a[i], a[i + 1]);
	printf("%d %d\n", a[tot], a[1] + n);
	for (int i = 1; i < tot; i++) printf("%d %d\n", a[i] + n, a[i + 1] + n);
	for (int i = L; i < n; i += 2)
		printf("%d %d\n%d %d\n%d %d\n%d %d\n",
			i, n + 1, i + 1, i, 1, i + 1 + n, i + 1 + n, i + n);
	if (!(n & 1)) printf("%d %d\n%d %d\n",
		n, n * 2 - 1, n & -n, n * 2);
	return 0;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
#define rep(i, n) for(int (i) = (n); (i) < (n); (i)++)
using ll = long long;
using ull = unsigned long long;
ull mod = 1e9 + 7;
using namespace std;


int main(){

    int A, B; cin >> A >> B;
    if(A > 2 * B)cout << A - 2 * B;
    else cout << 0;

}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
a,b,c,d = iim()
cnt = 0
while a > 0 and c > 0:
    if cnt%2 == 0:
        c -= b
    else:
        a -= d
    cnt += 1

print('Yes' if cnt%2 == 1 else 'No')

Measured memory_bytes: 9204
import java.util.*;

public class Main {
       
    
    public static void main(String[] args){                
        Scanner input = new Scanner(System.in);
        String grab;
        Stack<Integer> stack = new Stack<Integer>();
        while (input.hasNext()) {                        
            grab = input.next();
            
            if (Character.isDigit(grab.charAt(0))) {
            stack.push(Integer.parseInt(grab));
            }//if
            else {
                int a = stack.pop();
                int b = stack.pop();
                if (grab.equals("+")){
                    stack.push(a + b);
                }//if 
                if (grab.equals("-")){ 
                stack.push(b - a);
                }//if
                if (grab.equals("*")){
                stack.push(b * a);
                }//if
            }//else
        }//while
        System.out.println(stack.pop());
    }//main            
}//Main




Measured memory_bytes: 26200
/*  ex9_1
    Rikuta  */
#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 10
//スタックの定義
typedef struct stack
{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;
//スタックの初期化
void initialize_stack(stack *string);
//データの追加
void push(stack *string, char elem);
//データの取り出し
void pop(stack *string);
//stackの出力
void print_stack(stack *string);

int main(void)
{   
    //スタックを宣言
    stack string;
    //スタックを初期化
    initialize_stack(&string);
    while (1)
    {   
        //受け取る変数の宣言
        char temp_char;
        //入力
        scanf("%c", &temp_char);
        //入力が終了なら終わり
        if (temp_char=='\n')
        {
            break;
        }
        //Bが入力されたらスタックをpop
        if (temp_char=='B')
        {
            pop(&string);
        }
        //0,1ならそれをスタックにpush
        if (temp_char=='0'||temp_char=='1')        
        {
            push(&string, temp_char);
        }
    }
    //スタックを出力
    print_stack(&string);

    return 0;
}

//スタックの初期化
void initialize_stack(stack *string)
{   
    //スタックの要素数と最大の大きさとtopを初期化
    string->count = 0;
    string->size = SIZE;
    string->top = &(string->data[SIZE]);
}

//データの追加
void push(stack *string, char elem)
{   
    //スタックの長さが最大を超えていたら標準エラー出力
    if (string->count >= string->size)
    {
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else
    {   
        //スタックのtopは一個戻り，戻ったtopに要素が入る．要素数が1増える．
        string->top--;
        *(string->top) = elem;
        string->count++;
    }
}

//データの取り出し
void pop(stack *string)
{   
    //データに何も入っていなかったら
    if (string->count > 0)
    {   
        //スタックのトップを奥へ，要素数が1減る
        string->top++;
        string->count--;
    }
}

void print_stack(stack *string)
{   
    //ポインタの宣言
    char *pointer;
    //ポインタはスタックの一番古い要素を指す
    pointer = string->top+string->count-1;
    for (int i = 0; i < string->count; i++)
    {   
        //ポインタがさす要素を新しくしながら出力していく．
        printf("%c", *(pointer--));
    }
    //改行
    printf("\n");
}


Measured memory_bytes: 1600
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <string>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vector<tuple<string,int,int>> table(n);
	for(int i=0;i<n;i++){
		string a;
		int b;
		cin>>a>>b;
		table[i]=make_tuple(a,b,i+1);
	}
	sort(table.begin(),table.end());
	string tmp=get<0>(table[0]);
	vector<pair<int,int>> table2;
	for(int i=0;i<n;i++){
		//cout<<tmp<<endl;
		if(tmp==get<0>(table[i])){
			table2.push_back(make_pair(get<1>(table[i]),get<2>(table[i])));
		}else{
			sort(table2.begin(),table2.end(),greater<pair<int,int>>());
			for(int i=0;i<table2.size();i++){
				cout<<table2[i].second<<endl;
			}
			table2.clear();
			if(i<n-1){
				tmp=get<0>(table[i]);
				table2.push_back(make_pair(get<1>(table[i]),get<2>(table[i])));
			}else{
				table2.push_back(make_pair(get<1>(table[i]),get<2>(table[i])));
			}
		}
	}
	sort(table2.begin(),table2.end(),greater<pair<int,int>>());
	for(int i=0;i<table2.size();i++){
		cout<<table2[i].second<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        if(a==b&&a!=c)
            System.out.println("Yes");
        else if(b==c&&a!=c)
            System.out.println("Yes");
        else if(a==c&&a!=b)
            System.out.println("Yes");
        else
            System.out.println("No");
        }
    }

Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define vi vector<ll>
const int N = 1e9 + 5;
ll t[24][60] = {0};
void solve() {
	ll p = 100;
	ll x; cin >> x;
	ll k = 0;
	while (p < x) {
		p += p * (0.01);
		k++;
		//cout << p << endl;
	}
	cout << k;


}
int main() {

	FASTIO;



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

Measured memory_bytes: 3596
from sys import stdin

N = int(stdin.readline().rstrip())

prev_x = 0
prev_y = 0
prev_t = 0

for n in range(N):
  t, x, y = [int(i) for i in stdin.readline().rstrip().split()]
  min_t = abs(x - prev_x) + abs(y - prev_y)
  if((t - prev_t < min_t) or ((t-prev_t-min_t) % 2 != 0)):
    print('No')
    exit()
  
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	vl a(n),b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	ll ans = 0;
	rep(bit,30){
		vl B;
		rep(i,n) B.push_back(b[i]%(1<<(bit+1)));
		sort(all(B));
		ll cnt = 0;
		ll beki = 1<<bit;
		rep(i,n){
			ll t = a[i] % (2*beki);
			if(t > beki){
				cnt += upper_bound(all(B),2*beki-1-t) - B.begin();
				cnt += B.end() - lower_bound(all(B),3*beki-t);
			}else{
				cnt += upper_bound(all(B),2*beki-1-t) - lower_bound(all(B),beki-t);
			}
		}
		if(cnt & 1) ans += beki;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7596
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (p[i] == i + 1) {
                continue;
            }
            count++;
        }
        if (count > 2) {
            System.out.println("NO");
            return;
        }
        System.out.println("YES");
    }

}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	int a,b;
	cin >> a >> b;
	if(a>b)swap(a,b);
	if(1)
	{
		rep(i,b)cout<<a;
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int diff = b - a;
        int sum = 0;

        for(int i = 0; i < diff; i++){
          sum = sum + i;
        }

        System.out.println(sum - a);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
//#define INF 9223372036854775807
//const ll mod=998244353;



int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    ll mod=1e18;
    bool ok=false,z=false;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
    	cin>>a[i];
    	if(a[i]==0) z=true;
    }
    if(z){
    	cout<<0;
    	return 0;
    }
    ll ans=1,u,prev_ans=0;
    for(ll i=0;i<n;i++){
    	ll u=a[i];
    	//string a=to_string(u);
    	//string b=to_string(ans);
    	//ll k=(a[0]-'0')*(b[0]-'0'),f=0;
    	//if(k>10) f=1;
    	//if(a.size()+b.size()-2+f>=18 && ans*u!=1e18){
    	//	ok=true;
    	//}
    	prev_ans=ans;
    	ans=ans*u;
    	if(ans>mod){
    		ok=true;
    		break;
    	}
    	if(ans<prev_ans){
    		ok=true;
    		break;
    	}
    }
    if(ok)
    	cout<<-1;
    else
    	cout<<ans;

    return 0;
}



Measured memory_bytes: 3976
obj = input().strip().split(' ')

H = int(obj[0])
W = int(obj[1])
A = int(obj[2])
B = int(obj[3])

for i in range(B):
    print('1' * A + '0' * (W - A))
for i in range(H - B):
    print('0' * A + '1' * (W - A))


Measured memory_bytes: 39792
from collections import deque
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

A.append(-int(1e+15))
B.append(-int(1e+15))
C.append(-int(1e+15))

Aq = deque(A)
Bq = deque(B)
Ar = [Aq.popleft()]
Br = [Bq.popleft()]
maximum = min((len(A)-1) + (len(B)-1), K+1)
preA = Ar[0]
preB = Br[0]

while len(Ar) + len(Br) < maximum:
    if  Ar[0] - Aq[0] > Br[0] - Bq[0]:
        Br.append(Bq.popleft())
        preB = Br[-1]
    else:
        Ar.append(Aq.popleft())
        preA = Ar[-1]

AB = [Ar[i] + Br[j] for i in range(len(Ar)) for j in range(len(Br))]
AB = sorted(AB, reverse=True)

AB.append(-int(1e+15))

ABq = deque(AB)
Cq = deque(C)
ABr = [ABq.popleft()]
Cr = [Cq.popleft()]
maximum = min((len(AB)-1) + (len(C)-1), K+1)
preAB = ABr[0]
preC = Cr[0]
while len(ABr) + len(Cr) < maximum:
    if ABr[0] - ABq[0] > Cr[0] - Cq[0]:
        Cr.append(Cq.popleft())
        preC = Cr[-1]
    else:
        ABr.append(ABq.popleft())
        preAB = ABr[-1]

ABC = [ABr[i] + Cr[j] for i in range(len(ABr)) for j in range(len(Cr))]
ABC = sorted(ABC, reverse=True)

for i in range(K):
    print(ABC[i])


Measured memory_bytes: 217888
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  int cnt = 0;
  rep(i, n) {
    if(s.substr(n-1-i,i+1) == t.substr(0, i+1)) {
      cnt = i + 1;
    }
  }

  cout << n + n - cnt << endl;

  return 0;
}


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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi="3.14159265359;
//###################################################################

int main(){
   int n=D();
   int a[n];
   for(int i=0;i<n;i++)a[i]=D();
   ll ans=0;
   for(int i=1;i<n;i++){
       if(a[i]<a[i-1]){
           ans+=a[i-1]-a[i];
           a[i]=a[i-1];
       }
   }
   cout<<ans;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

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

    vector<int> a(M);
    vector<int> b(M);

    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
    }

    vector<int> checker(N, 0);
    for (int i = 0; i < M; i++)
    {
        checker[a[i] - 1]++;
        checker[b[i] - 1]++;
    }

    for (int i = 0; i < N; i++)
    {
        cout << checker[i] << endl;
    }
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=998244353;
const int siz=2e5;
const int inf=1e9;
int main(){
	int N,K; cin>>N>>K;
	int A[N];
	rep(i,0,N) cin>>A[i];
	sort(A, A+N);
	int sum = 0;
	rep(i,0,K) sum += A[i];
	cout<<sum<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

const int mill=196471;
const int nYear=(19+20)*5;

int main(){ _;
  int n,y,m,d;
  cin>>n;
  REP(i,n){
    cin>>y>>m>>d;
    int days=mill;
    days-=nYear*(y-1)+5*((y-1)/3);
    REP(j,m-1)
      days-= (y%3==0||(j+1)%2==1) ? 20 : 19;
    days-=d;
    cout<<days<<endl;
  }
}

Measured memory_bytes: 1188
n = int(input())
xs = list(map(int, input().split()))

minx = min(xs)
maxx = max(xs)

cnt = 10**9
for i in range(minx, maxx + 1):
    all = 0
    for x in xs:
        all += (x - i)**2
    if cnt > all:
        cnt = all


print(cnt)


Measured memory_bytes: 3060
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function division(x)
	d = Dict{Int,Int}()
	i = 2
	while x > 1 || i <= sqrt(x)
		if x%i == 0
			x = div(x, i)
			if haskey(d,i)
				d[i] += 1
			else
				d[i] = 1
			end
		else
			i += 1
		end
	end
	return(d)
end

function abmp(a,b,p)
	if b == 0
		1
	elseif b%2 == 0
		k = abmp(a,div(b,2),p)
		(k*k)%p
	else
		(a*abmp(a,b-1,p))%p
	end
end

function combi(n,p)
	z = 1
	for i in 1:n
		z = z*i%p
	end
	fac = Array{Int}(n+1)
	inv = Array{Int}(n+1)
	inv[n+1] = abmp(z,p-2,p)
	for i in 0:n-1
		inv[n-i] = (inv[n+1-i]*(n-i))%p
	end
	for i in 0:n
		fac[i+1] = (((z*inv[i+1])%p)*inv[n+1-i])%p
	end
	fac
end


function main()
	n,m = readline() |> split |> parseMap
	d = division(m)
	count = 1
	for v in values(d)
		cmb = combi(n+v-1,1000000007)
		count = (count*cmb[v+1])%1000000007
	end
	println(count)
end

main()


Measured memory_bytes: 127660
s = list(input())

fl = True
fg = True
for i in range(len(s)):
    if (i+1)%2 == 1:
        if s[i] != "R" and s[i] != "U" and s[i] != "D":
            fl = False

    else:
        if s[i] != "L" and s[i] != "U" and s[i] != "D":
            fg = False

if fl and fg:
    print("Yes")
else:
    print("No")
        

Measured memory_bytes: 3064
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

fn main() {
    let n: usize = input();
    let a: i32 = input();
    let b: i32 = input();
    let c: i32 = input();
    let l: Vec<i32> = (0..n).map(|_| input()).collect();

    let m = vec![a, b, c];
    let mut v = vec![vec![]; 3];
    println!("{}", dfs(&mut v, &m, n, &l));
}

fn dfs(v: &mut Vec<Vec<i32>>, a: &Vec<i32>, n: usize, l: &Vec<i32>) -> i32 {
    if n == 0 {
        if v.iter().any(|v| v.is_empty()) {
            i32::max_value()
        } else {
            let mut ans = 0;
            for i in 0..3 {
                let nl = v[i].len();
                ans += 10 * (nl as i32 - 1);
                let sl: i32 = v[i].iter().sum();
                ans += i32::abs(a[i] - sl);
            }
            ans
        }
    } else {
        let mut ans = i32::max_value();
        ans = std::cmp::min(ans, dfs(v, a, n - 1, l));
        for i in 0..3 {
            v[i].push(l[n - 1]);
            ans = std::cmp::min(ans, dfs(v, a, n - 1, l));
            v[i].pop();
        }
        ans
    }
}


Measured memory_bytes: 4352
a=input()
l=a.split(" ")
n=int(l[0])
k=int(l[1])
f=input()
fruits=f.split(" ")
for d in range(0, len(fruits)):
    fruits[d]=int(fruits[d])
ans=0
b=0
while(b<k):
    g=min(fruits)
    ans+=g
    fruits.remove(g)
    b+=1
print(ans)

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

int main()
{
  string str, s;

  getline(cin, str);
  stringstream ss{str};

  int cnt = 0;
  int a,b;
  string op;
  while( getline(ss, s, ' ') ) {
    if(cnt==0)  a=stoi(s);
    else if(cnt==1)  op=s;
    else b=stoi(s);
    cnt ++;
  }

  if(op == "+")  cout << a + b;
  else cout << a-b;
  cout << endl;

  return(0);
}

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

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

bool linearSearch(int a[], int n, int x)
{
  int i = 0;
  a[n] = x;
  while(a[i] != x)
    i++;
  if(i == n)
    return false;
  return true;
}

int main()
{
  int n, q, ans = 0;
  cin >> n;
  int S[n + 1];
  REP(i, n)
    cin >> S[i];
  cin >> q;
  int T[q];
  REP(i, q)
    cin >> T[i];
  REP(i, q)
    if(linearSearch(S, n, T[i]))
      ans++;
  cout << ans << endl;
}    

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

int main () {
    
    int H, W;
    for (int i = 0;; i++) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;

        for (int j = 0; j < H; j++) {
            for (int k = 0; k < W; k++) {
                if (j == 0 || j == H-1 || k == 0 || k == W-1) {
                    cout << "#";
                }
                else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,b=2,c=0,d=0,e,n,m=0;
  c(n);
  bool r1=false,r2=false;
  string s[n];
  rep(i,0,n) c(s[i]);
  rep(i,0,n-1){
    if(s[i][s[i].size()-1]==s[i+1][0]) c++;
  }
  if(c==n-1) r1=true;
  sort(s,s+n);
  rep(i,0,n-1){
    if(s[i]==s[i+1]) d++;
  }
  if(d==0) r2=true;
  
  if(r1==1 && r2==1) co("Yes");
  else co("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int sum = 1;
	int ans = 0;
	while (sum < b) {
		sum += a - 1;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

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

    ll N, M;
    cin >> N >> M;
    vector<ll> k(M);
    vector<vector<ll>> s(10);
    REP(j, M) {
        cin >> k[j];
        REP(i, k[j]) {
            ll tmp;
            cin >> tmp;
            s[j].push_back(tmp - 1);
        }
    }
    vector<ll> p(M);
    REP(i, M) { cin >> p[i]; }

    debug(k);
    debug(s);
    debug(p);
    debug("------");

    // {0, 1, ..., n-1} の部分集合の全探索
    ll ans = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        vector<int> S;
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) {  // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        debug(S);
        ll mid_ans = 0;
        REP(i, M) {
            ll counter = 0;
            debug(s[i]);
            for (auto u : s[i]) {
                debug(u);
                if (binary_search(S.begin(), S.end(), u)) {
                    counter++;
                }
            }
            debug(counter, p[bit]);
            if (counter % 2 == p[i]) mid_ans++;
        }
        if (mid_ans == M) {
            ans++;
            debug("!!counted!!");
        }

        debug("------");
    }
    cout << ans << endl;

    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;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int A, B;
    cin >> A >> B;
    int ans = 0;
    if(A <= B * 2) {
        cout << 0 << endl;
        return 0;
    } else {
        cout << A - B * 2 << endl;
        return 0;
    }
}


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

int main(){
    int n,k,ans = 0,h;
    cin >> n >> k;
    for(int i = 0;i < n;i++){
        cin >> h;
        if(h >= k){
            ans++;
        }
    }

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

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

int main() {
  int n,m,c;
  cin >>n>>m>>c;
  int ans=0;
  vector<int> B(m);
  for (int i = 0; i < m; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < n; i++) {
    vector<int> A(m);
    for (int i = 0; i < m; i++) {
    cin >> A.at(i);
    }
    int www=0;
    for (int i = 0; i < m; i++){
    www+=B.at(i) * A.at(i);
    }
    www+=c;
    if (www>0){
    ans++;
    }
  }
  
  
  cout << ans << endl;
}


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

const int N = 110;

char a[N], b[N], c[N];

int main(){
	while(~scanf("%s %s %s", a, b, c)){
		if(a[strlen(a) - 1] == b[0] && b[strlen(b)-1] == c[0]){
			puts("YES");
		} else {
			puts("NO");
		}
	}
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        s: chars,
    }
    let h = s[0].clone();
    let mut x = vec!['0'; s.len()];
    if h == '0' {
        for i in 0..s.len() {
            if i % 2 == 0 {
                x[i] = '0';
            } else {
                x[i] = '1';
            }
        }
    } else {
        for i in 0..s.len() {
            if i % 2 == 0 {
                x[i] = '1';
            } else {
                x[i] = '0';
            }
        }
    }
    let mut time = 0;
    for i in 0..s.len() {
        if s[i] != x[i] {
            time+=1;
        }
    }
    println!("{}", time);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,x) for(int i = 0; i < x; i++)
typedef long long ll;
using namespace std;
const ll N = 1e9+7;

int main(){
    ll n; cin >> n;
    vector<pair<ll, ll>> ba(n);
    rep(i,n){
        int a,b; cin >> a >> b;
        ba[i] = make_pair(b,a);
    }
    sort(ba.begin(),ba.end());
    // rep(i,n) cout << ba[i].first << " " << ba[i].second << endl;
    ll time = 0;
    bool ok = true;
    rep(i,n){
        time += ba[i].second;
        if(time > ba[i].first){
            ok = false;
            break;
        }
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll A(N);
    for(ll i=0;i<N;i++)cin>>A[i];
    
    sort(ALL(A));
    
    ll ans=0;
    ll count=1;
    for(ll i=1;i<N;i++){
        if(A[i]==A[i-1])count++;
        else{
            if(count%2==1){
                ans++;
                //printf("i=%d\n",i);
            }
            count=1;
        }
    }
    if(count%2==1){
        ans++;
        //printf("i=%d\n",N);
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1152
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let a: i64 = input();
    let b: i64 = input();
    println!("{}", std::cmp::min(n * a, b));
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int n, a[10001] = { 0 };
	scanf("%d", &n);
	int* A = malloc(n * sizeof(int));
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
		++a[A[i]];
	}
	for (int i = 0, j = 0; i < n; ++i) {
		while (!a[j]) ++j;
		--a[j];
		A[i] = j;
	}
	for (int i = 0; i < n - 1; ++i) printf("%d ", A[i]);
	printf("%d\n", A[n - 1]);
	free(A);
	return 0;
}


Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

template <typename T>
T beki(T x, ll n){
  T res = 1;
  while(n > 0){
    if(n & 1) res *= x;
    x = x * x;
    n >>= 1;
  }
  return res;
}

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vvi m(H, vi(W, 0));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      char c;
      cin >> c;
      m.at(i).at(j) = c - '0';
    }
  }
  int result = 0;
  for(int i = 1; i < H; i++){
    for(int j = 0; j < W; j++){
      //m.at(i).at(j)を消した場合
      vvi mm = m;
      for(int k = i; k >= 1; k--){
        mm.at(k).at(j) = mm.at(k-1).at(j);
      }
      mm.at(0).at(j) = 0;

      bool repflag;
      int counter = 0;
      int res = 0;
      do{
        repflag = false;
        vector<vector<bool>> flag(H, vector<bool>(W, false));
        for(int k = 0; k < H; k++){
          for(int l = 0; l < W-K+1; l++){
            if(mm.at(k).at(l) == 0) continue;
            //消せるものにflagを立てる
            bool issame = true;
            for(int t = l; t < l+K; t++){
              if(mm.at(k).at(l) != mm.at(k).at(t)) issame = false;
            }
            if(issame){
              for(int t = l; t < l+K; t++){
                repflag = true;
                flag.at(k).at(t) = true;
              }
            }
          }
        }

        for(int k = 0; k < H; k++){
          for(int l = 0; l < W; l++){
            if(flag.at(k).at(l)){
              res += beki(2, counter) * mm.at(k).at(l);
              mm.at(k).at(l) = 0;
            }
          }
        }

        for(int k = H-1; k >= 1; k--){
          for(int l = 0; l < W; l++){
            if(mm.at(k).at(l) == 0){
              for(int t = k-1; t >= 0; t--){
                if(mm.at(t).at(l) != 0){
                  mm.at(k).at(l) = mm.at(t).at(l);
                  mm.at(t).at(l) = 0;
                  break;
                }
              }
            }
          }
        }


        counter++;
      }while(repflag);
      chmax(result, res);


    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int n;
int veven[100000];
int vodd[100000];

int main(){
    cin>>n;
    rep(i,n){
        int v;
        cin>>v;
        if(i%2==0) veven[v]++;
        else vodd[v]++;
    }

    pair<int,int> evenmax(0,0), evenmax2(-1,-1);
    pair<int,int>  oddmax(0,0),  oddmax2(-1,-1);
    rep(i,100000){
        if(veven[i]>evenmax.second){
            evenmax2=evenmax;
            evenmax=pair<int,int>(i,veven[i]);
        }else if(veven[i]>evenmax2.second){
            evenmax2=pair<int,int>(i,veven[i]);
        }
    }
    rep(i,100000){
        if(vodd[i]>oddmax.second){
            oddmax2=oddmax;
            oddmax=pair<int,int>(i,vodd[i]);
        }else if(vodd[i]>oddmax2.second){
            oddmax2=pair<int,int>(i,vodd[i]);
        }
    }

    int ans;
    if(evenmax.first!=oddmax.first){
        ans=n-evenmax.second-oddmax.second;
    }else{
        ans=min(n-evenmax.second-oddmax2.second,n-oddmax.second-evenmax2.second);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

int A,B;
int main(void){
    scanf("%d %d",&A,&B);
    ll int ans=0;
    if(A<=5){
        printf("0\n");
    }else if(A<=12){
        printf("%d\n",B/2);
    }else{
        printf("%d\n",B);
    }
}


Measured memory_bytes: 128