akhauriyash/Code-Regression huggingface dataset:
from collections import Counter


class fenwick_tree(object):
    def __init__(self, n):
        self.n = n
        self.data = [0] * n

    def __sum(self, r):
        s = 0
        while r > 0:
            s += self.data[r - 1]
            r -= r & -r
        return s

    def add(self, p, x):
        """ a[p] += xを行う"""
        assert 0 <= p and p < self.n
        p += 1
        while p <= self.n:
            self.data[p - 1] += x
            p += p & -p

    def sum(self, l, r):
        """a[l] + a[l+1] + .. + a[r-1]を返す"""
        assert 0 <= l and l <= r and r <= self.n
        return self.__sum(r) - self.__sum(l)


def calc_inversion(arr):
    N = len(arr)
    bit = fenwick_tree(N)
    atoi = {a: i for i, a in enumerate(arr)}
    res = 0
    for a in reversed(range(N)):
        i = atoi[a]
        res += bit.sum(0, i)
        bit.add(i, 1)
    return res


def calc_inv(arr):
    N = len(set(arr))
    atoi = {a: i for i, a in enumerate(sorted(set(arr)))}
    bit = fenwick_tree(N)
    res = 0
    for i, a in enumerate(arr):
        res += i - bit.sum(0, atoi[a] + 1)
        bit.add(atoi[a], 1)
    return res


def main():
    S = input()
    N = len(S)
    C = Counter(S)

    odd = 0
    mid = ""
    for k, v in C.items():
        if v & 1:
            odd += 1
            mid = k

    if N % 2 == 0:  # 偶数
        if odd:
            return -1
        half = {k: v // 2 for k, v in C.items()}
        cnt = {k: 0 for k in C.keys()}
        label = []
        left = []
        right = []
        for i, s in enumerate(S):
            if cnt[s] < half[s]:
                label.append(0)
                left.append(s)
            else:
                label.append(1)
                right.append(s)
            cnt[s] += 1
        ans = calc_inv(label)

        pos = {k: [] for k in C.keys()}
        for i, s in enumerate(left):
            pos[s].append(i)
        label = []
        for s in right:
            label.append(pos[s].pop())
        ans += calc_inv(label[::-1])
        return ans

    else:  # 奇数
        if odd != 1:
            return -1
        half = {k: v // 2 for k, v in C.items()}
        cnt = {k: 0 for k in C.keys()}
        label = []
        right = []
        left = []
        seen = 0
        LL = 0  # midの右にあるL
        RR = 0  # midの左にあるR

        for i, s in enumerate(S):
            if s == mid and cnt[s] == half[s]:
                seen = 1
                cnt[s] += 1
                continue
            if cnt[s] < half[s]:
                label.append(0)
                left.append(s)
                if seen:
                    LL += 1
            else:
                label.append(1)
                right.append(s)
                if not seen:
                    RR += 1
            cnt[s] += 1
        ans = calc_inv(label)
        ans += RR + LL

        pos = {k: [] for k in C.keys()}
        for i, s in enumerate(left):
            pos[s].append(i)
        label = []
        for s in right:
            label.append(pos[s].pop())
        ans += calc_inv(label[::-1])
        return ans


print(main())

Measured memory_bytes: 31960
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<functional>
#include<set>
#include<unordered_map>
using namespace std;

vector<int>c[10000];
bool used[10000];
vector<int>V;
void DFS(int a) {
	used[a] = true;
	for (int i : c[a]) {
		if (!used[i])DFS(i);
	}
	V.push_back(a);
}
signed main() {
	int a, b; scanf("%d%d", &a, &b);
	for (int d = 0; d < b; d++) {
		int e, f; scanf("%d%d", &e, &f);
		c[f].push_back(e);
	}
	for (int i = 0; i < a; i++) {
		if (!used[i])DFS(i);
	}
	for (int i : V) {
		cout << i << endl;
	}
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
vector<vi> adj;
vi in_P;
deque<int> P;

bool check(int u, bool f) {
    for(int i=0;i<adj[u].size();i++) {
        int v = adj[u][i];
        if(!in_P[v]) {
            if(f) P.push_front(v);
            else P.push_back(v);
            in_P[v] = 1;
            return false;
        }
    }
    return true;
}

int n, m, u, v;
int main() {
    scanf("%d %d", &n, &m);
    adj.assign(n+1, vi());
    for(int i=0;i<m;i++) {
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    in_P.assign(n+1, 0);
    in_P[1] = 1;
    P.push_back(1);
    while(true) {
        if(check(P.front(), true) && check(P.back(), false)) break;
    }

    printf("%d\n", P.size());
    while(!P.empty()) {
        printf("%d ", P.front());
        P.pop_front();
    }printf("\n");

    


}


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

int main(){
 int S, h, m, s;
 cin >> S;
 h = S / 3600;
 m = S % 3600 / 60;
 s = S - 3600 * h - 60 * m;
 cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 1168
n=int(input())
counter=0
a=list(map(int,input().split()))
for i in range(n-1):
    if a[i]==i+1:
        counter+=1
        a[i],a[i+1]=a[i+1],a[i]
    else:
        pass
if a[n-1]==n:
    counter+=1
    a[n-2],a[n-1]=a[n-1],a[n-2]
print(counter)

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

const int INF = 1e9+5;
int main(){
    int n,k; cin>>n>>k;
    vector<int> h(n);
    for(int &x: h){
        cin>>x;
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i=0; i<n; ++i){
        for(int j= i+1; j<=i+k; ++j){
            if(j<n){
                dp[j] = min(dp[j], dp[i] + abs(h[i]-h[j]));
            }
                
        }
    }
    cout<<dp[n-1];
    return 0;
}

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

int N,Q,C[10010],A[10010] = {};
int T[100010],X[100010],D[100010];

int main(){
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> C[i];
    }
    cin >> Q;
    int ans = 0;
    for(int i=1;i<=Q;i++){
        cin >> T[i] >> X[i] >> D[i];
        if(T[i]==1) A[X[i]] += D[i];
        else A[X[i]] -= D[i];
        if(A[X[i]]<0 || C[X[i]]<A[X[i]]){
            ans = X[i];
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4300
#include <stdio.h>
#define MAX 10000

typedef struct{
  int p;
  int l;
  int r;
}Node;

void getDepth(Node*,int,int,int*);
int getSibling(Node*,int);
int getHeight(Node*,int);

int main(){
  int n,i,j,num,d,q[2],D[MAX],c[MAX];
  Node data[MAX];


  scanf("%d",&n);
   for(i=0;i<n;i++){
    data[i].p=-1;
    data[i].l=-1;
    data[i].r=-1;
    D[i]=0;
   }

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

    scanf("%d",&num);
    scanf("%d%d",&q[0],&q[1]);
        data[num].l=q[0];
        data[num].r=q[1];
         
        if(q[0]!=-1) {
            data[q[0]].p=num;
            c[num]++;
        }
        if(q[1]!=-1) {
            data[q[1]].p=num;
            c[num]++;
        }
    }

  

 for(i=0;i<n;i++){
   if(data[i].p==-1){
     d=i;
    }
 }
  getDepth(data,d,0,D);


  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, ",i,data[i].p,getSibling(data,i),c[i]);
    printf("depth = %d, height = %d, ",D[i],getHeight(data,i));
    if(data[i].p==-1){
      printf("root\n");
    }else if(data[i].l==-1&&data[i].r==-1){
      printf("leaf\n");
      continue;
    }else{
      printf("internal node\n");
    }
  }

  return 0;
}

void getDepth(Node *data,int x,int j,int *D){
   D[x]=j;
   if(data[x].r!=-1){
     getDepth(data,data[x].r,j+1,D);                               
   }
   if(data[x].l!=-1){
     getDepth(data,data[x].l,j+1,D);                                 
   }

}

int getSibling(Node *data,int x){
    
    if(data[x].p==-1) return -1;
    if(data[data[x].p].l!=x&&data[data[x].p].l!=-1)
    return data[data[x].p].l;
    if(data[data[x].p].r!=x&&data[data[x].p].r!=-1)
    return data[data[x].p].r;
    return -1;
}

 int getHeight(Node *data,int x){
     int h1=0,h2=0;
     if(data[x].l!=-1)
     h1=getHeight(data,data[x].l)+1;
     if(data[x].r!=-1)
     h2=getHeight(data,data[x].r)+1;

     if(h2<h1) return h1;
     else return h2;
 }


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
int N;
vector<vector <int> > p;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
bool isFind = false;
int safe(int i, int j) {
    return (0 <= i && i < 100000) && (0 <= j && j < 100000);
}
void f(int i, int j, int cnt, int index) {

    if (isFind == true)
        return;
    if (i < 0 || j < 0)
        return;
    if (cnt == p[index][0]) {
        if (i == p[index][1] && j == p[index][2]) {
            isFind = true;
        }
        return;
    }

    int dist = (abs(i-p[index][1]) + abs(j-p[index][2]));
    int t = p[index][0] - cnt;
    if (dist > t)
        return;

    if (t % 2 != dist % 2)
        return;


    f(i+1, j, cnt+1, index);
    f(i, j+1, cnt+1, index);
    f(i-1, j, cnt+1, index);
    f(i, j-1, cnt+1, index);

}


//x , y, time, postion
void g(int i, int j, int cnt, int index) {
    queue <vector<int> > q;
    int t, x, y;
    q.push({i, j, cnt});
    while (!q.empty()) {
        x = q.front()[0];
        y = q.front()[1];
        t = q.front()[2];
        q.pop();



        if (t == p[index][0]) {
            if (x == p[index][1] && y == p[index][2]) {
                isFind = true;
                break;
            }
        } else {
            int dist = (abs(x-p[index][1]) + abs(y-p[index][2]));
            int tt = p[index][0] - t;
            if (dist <= tt) {
                if (tt % 2 == dist % 2) {
                    q.push({x+1, y, t+1});
                    q.push({x-1, y, t+1});
                    q.push({x, y+1, t+1});
                    q.push({x, y-1, t+1});
                }
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> N;

    for (int i = 0; i < N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        p.push_back({a,b,c});
    }

    int x, y, time;
    x = y = time = 0;
    for (int i = 0; i < p.size(); i++) {
        isFind = false;
        int dist = (abs(x-p[i][1]) + abs(y-p[i][2]));
        int t = p[i][0] - time;
        if (dist <= t) {
            if (t % 2 == dist % 2)
                f(x, y, time, i);

            x = p[i][1];
            y = p[i][2];
            time = p[i][0];
        }
        else {
            cout << "No\n";
            return 0;
        }
        if (isFind == false) {
            cout << "No\n";
            return 0;
        }

    }
    cout <<"Yes\n";
    return 0;
}




Measured memory_bytes: 5680
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
    return 0;
}


Measured memory_bytes: 3528
import java.io.*;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str;
		str = br.readLine().split(" ");
		int N = Integer.parseInt(str[0]);
		int W = Integer.parseInt(str[1]);
		long[][] items = new long[N][2];
		for(int i=0; i<N; i++) {
			str = br.readLine().split(" ");
			items[i][0] = Long.parseLong(str[0]);
			items[i][1] = Long.parseLong(str[1]);
		}
		long[] dp = new long[W+1];
		for(int i=0; i<N; i++) {
			long we = items[i][0];
			for(int j=(int)(W-we); j>=0; j--) {
				dp[(int)(j+we)] = Math.max(dp[(int)(j+we)], dp[j]+items[i][1]);
			}
		}
		long ans = 0;
		for(int i=0; i<=W; i++) {
			//System.out.print(dp[i]+" ");
			ans = Math.max(ans, dp[i]);
		}
//		System.out.println();
		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
from collections import deque
import sys

def main():
    n, q = map(int,raw_input().split())
    Q = deque([])
    for i in xrange(n):
        a = raw_input().split()
        a[1] = int(a[1])
        Q.append(a)
    
    elaps = 0
    while len(Q) > 0:
        u = Q.popleft()
        a = min(u[1], q)
        u[1] -= a
        elaps += a
        if u[1] > 0:
            Q.append(u)
        else:
            print u[0], elaps
    return 0

main()

Measured memory_bytes: 18524
x = int(input())
 
if 400 <= x and x <= 599:
  print(8)
elif x <= 799:
  print(7)
elif x <= 999:
  print(6)
elif x <= 1199:
  print(5)
elif x <= 1399:
  print(4)
elif x <= 1599:
  print(3)
elif x <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9084
import java.util.Scanner;

class Main {
    private void digitNumber() {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int sum = sc.nextInt() + sc.nextInt();
            int c = 0;
            while (sum != 0) {
                c++;
                sum /= 10;
            }
            System.out.println(c);
        }
    }

    public static void main(String[] args) {
        (new Main()).digitNumber();
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n;
  cin >>n;
  ll a[n];
  for(ll i=0;i<n;i++) cin >>a[i];
  ll ans=10000000000;
  for(ll i=-100;i<=100;i++){
    ll sum=0;
    for(ll j=0;j<n;j++){
      sum+=(a[j]-i)*(a[j]-i);
    }
    ans=min(sum,ans);
  }
  cout <<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":\t";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll n, lim_w, ans = -1;
  cin >> n >> lim_w;
  vector<ll> v(n), w(n);
  REP(i, n) { cin >> w[i] >> v[i]; }
  // dp[i+1][j]=i番目までの品物を重さjまで詰めたときの価値の最大値
  ll dp[n + 1][lim_w + 1];
  REP(i, n + 1) {
    REP(j, lim_w + 1) { dp[i][j] = 0; }
  }
  REP(i, lim_w + 1) dp[0][i] = 0;
  REP(i, n + 1) dp[i][0] = 0;
  REP(j, lim_w+1) {
    REP(i, n) {
      if (j - w[i] >= 0)
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      else
        dp[i + 1][j] = dp[i][j];
    }
  }
  cout << dp[n][lim_w] << endl;

  return 0;
}


Measured memory_bytes: 82516
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;


int sum_object(int n){
  int sum = 0;
  while (n > 0) {
    sum += n%10;
    n /= 10;
    }
    return sum;
  }


int main() {
  int A, B, N, B_sum, A_sum;
  cin >> N;
  int sum_min;
  for (int k=1; k<=N-1; k++){
    B = k;
    A = N-B;
    B_sum = sum_object(B);
    A_sum = sum_object(A);
    if (k==1){
      sum_min = B_sum + A_sum;
    }
    if ((k>1)&&(sum_min>B_sum + A_sum)){
      sum_min = B_sum + A_sum;
    }
  }
  cout << sum_min << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void)
{
	int i, n, k, sum=0, count=0;

	cin>>n>>k;

	vector<int> a(n), c(n, 0);

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

	for(i=0; i<n; i++){
		if(c[i]) count++;
	}
	
	i=0;
	while(count>k){
		if(c[i]){
			count--;
			sum+=c[i];
		}
		i++;
	}
	cout<<sum<<endl;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

int main() {
  std::cout<<std::fixed<<std::setprecision(10);
  int N;
  cin >> N;

  int X = N / 1.08;

  if (floor(X*1.08) == N) {
    cout << X << endl;
    return 0;
  }

  if (floor((X+1)*1.08) == N) {
    cout << X+1 << endl;
    return 0;
  }

  if (floor((X-1)*1.08) == N) {
    cout << X-1 << endl;
    return 0;
  }

  cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String[] str = br.readLine().split(" ");
            int A = Integer.parseInt(str[0]);
            int B = Integer.parseInt(str[1]);
            int C = Integer.parseInt(str[2]);
            int K = Integer.parseInt(str[3]);

            int result = 0;

           for(int i = 0; i < 3; i++){
             if(A != 0){
              if(A > K){
                result += K;
                break;
              }else{
                result += A;
                K = K - A;
                A = 0;
                if(K == 0){
                   break; 
                }
              }
             }else if(B != 0){
               if(B > K){
                 break;
               }else{
                 K = K - B;
                 B = 0;
                 if(K == 0){
                   break;
                 }
               }
             }else if(C != 0){
               if(C > K){
                 result -= K;
                 break;
               }else{
                 result -= C;
                 K = K -C;
                 C = 0;
                 if(K ==0){
                   break;
                 }
               }
             }
           }

            System.out.println(result);
        }

    }
}

Measured memory_bytes: 32488
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> Nodes(N, 0);
  REP(i, M) {
    int a, b;
    cin >> a >> b, a--, b--;
    Nodes[a]++, Nodes[b]++;
  }
  int even = 0, odd = 0;
  REP(i, N) {
    if (Nodes[i] % 2 == 0) {
      even++;
    } else {
      odd++;
    }
  }
  if (odd != 0) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 3792
#include<stdio.h>
#include<stdlib.h>
int main(){
  long long n,i,d[200010],sum,a=0,min=1e18;
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&d[i]);
    sum+=d[i];
  }
  a=d[0];
  min=labs(a+a-sum);
  for(i=1;i<n-1;i++){
    a+=d[i];
    if(min>labs(a+a-sum))min=labs(a+a-sum);
  }
  printf("%lld\n",min);
  return 0;
}


Measured memory_bytes: 1664
N, A, B = map(int, input().split())
S = input()
ab = 0
b = 0

for i in range(N):
    if S[i] == 'a':
        if A + B > ab:
            print('Yes')
            ab += 1
        else:
            print('No')
    elif S[i] == 'b':
        if A + B > ab and b < B:
            print('Yes')
            ab += 1
            b +=1
        else:
            print('No')
    else:
        print('No')

Measured memory_bytes: 4016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int h = Integer.parseInt(tmpArray[0]);
			int m = Integer.parseInt(tmpArray[1]);
			int s = Integer.parseInt(tmpArray[2]);
			
			if(h == -1 && m == -1 && s == -1){
				break;
			}
			
			int sumOfSecond = h*3600 + m*60 + s;
			int remainTime = 120*60 - sumOfSecond;
			int remain3mode = remainTime*3;
			
			System.out.printf("%02d:%02d:%02d\n", hour(remainTime), minute(remainTime), second(remainTime));
			System.out.printf("%02d:%02d:%02d\n", hour(remain3mode), minute(remain3mode), second(remain3mode));
		}
	}
	
	static int hour(int second){
		return second/3600;
	}
	
	static int minute(int second){
		return (second%3600)/60;
	}
	
	static int second(int second){
		return (second%60);
	}

}

Measured memory_bytes: 24860
#include<iostream>
#include<vector>
#include<queue>

using namespace std;
using Graph=vector<vector<int>>;

void breadth_firstsearch(Graph &graph,int vertex,queue<int> qdata,vector<int> &distance){
  distance.at(vertex)=0;
  qdata.push(vertex);
  while(!qdata.empty()){
    int ver=qdata.front();
    qdata.pop();
    for(int v : graph.at(ver)){
      if(distance.at(v)!=-1) continue;
      distance.at(v)=distance.at(ver)+1;
      qdata.push(v);
    }
  }
}


int main(void) {
	int size, vnum, adjnum, temp;
	cin >> size;
	Graph graph(size);
	queue<int> qdata;
	vector<int> distance(size,-1);

	for (int i = 0; i < size; i++) {
		cin >> vnum >> adjnum;
		for (int j = 0; j < adjnum; j++) {
			cin >> temp;
			graph.at(vnum - 1).push_back(temp - 1);
		}
	}
  breadth_firstsearch(graph,0,qdata,distance);

	for (int i = 0; i < size; i++) {
		cout << i + 1 << " " <<distance.at(i)<< endl;
	}
	return 0;
}



Measured memory_bytes: 3156
#include <iostream>
int main(void){
	int n;
	std::cin>>n;
	while(n--){
		int a,i=3,b=0,c=0;
		for(;i--;){
			std::cin>>a;
			a*=a;
			b=a>b?a:b;
			c+=a;
		}
		std::cout<<(c==2*b?"YES\n":"NO\n");
	}
}

Measured memory_bytes: 1120
#include <iostream>
#include <string>
#define int long long

using namespace std;

int N;
int a;

signed main()
{
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        if ((i + 1) % 2 == 1 && a % 2 == 1)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3164
#include <stdio.h>
const char* str="23456789TJQKA";
int p[13];
int main(void)
{
    char t[2], h[4][13][2];
    int i, j;
    for(i=0;i<13;++i) p[str[i]]=i;
    while (scanf("%s", t), *t!='#') {
        int score[4]={0}, dealer=0, qx=0, qy=0, qz=0;
        char s=*t;
        for(i=0;i<4;++i) for(j=0;j<13;++j) scanf("%s", h[i][j]);
        for(j=0;j<13;++j) {
            int x=-1, y=-1, z=-1;
            for(i=0;i<4;++i) {
                char suit=h[i][j][1];
                int number=p[h[i][j][0]];
                if (suit==*t && x<number) {
                    x=number;
                    qx=i;
                }
                else if (suit==s && y<number) {
                    y=number;
                    qy=i;
                }
                else if (z<number) {
                    z=number;
                    qz=i;
                }
            }
            if (x>=0) {
                ++score[qx];
                dealer=qx;
            }
            else if (y>=0) {
                ++score[qy];
                dealer=qy;
            }
            else if (z>=0) {
                ++score[qz];
                dealer=qz;
            }
            s=h[dealer][j+1][1];
        }
        if (score[0]+score[2]>score[1]+score[3])
            printf("NS %d\n", score[0]+score[2]-6);
        else
            printf("EW %d\n", score[1]+score[3]-6);
    }
    return 0;
}

Measured memory_bytes: 536
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int N = 1000005;
LL f[N], p[N];

int main() {
//	freopen("a.in", "r", stdin);
	int n = read(), E = read(), T = read();
	for (int i = 1; i <= n; ++i) p[i] = read();
	LL Mn = 1e18;
	int j = 0;
	for (int i = 1; i <= n; ++i) {
		while (j <= i && 2 * (p[i] - p[j + 1]) > T) {
			Mn = min(Mn, f[j] - 2 * p[j + 1]);
			++ j;
		}
		if (j < i) f[i] = f[j] + T;
		f[i] = min(f[i], Mn + 2 * p[i]);
	}
	cout << f[n] + E;
	return 0;
}

Measured memory_bytes: 5120
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Sat Aug  4 19:15:43 2018
//
package main

import "fmt"

var N int

func main() {
	fmt.Scan(&N)
	if N%2 == 0 {
		fmt.Println(N)
		return
	}
	fmt.Println(2 * N)
}


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

int main() {
  int N, A, B, x=0, y=0;
  string S;
  cin >> N >> A >> B;
  cin >> S;
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == 'a' && x+y < A+B)
    {
      cout << "Yes" << endl;
      x++;
    }else if (S.at(i) == 'b' && x+y < A+B && y < B)
    {
      cout << "Yes" << endl;
      y++;
    }else
    {
      cout << "No" << endl;
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 896
import sys
s = input()
t = input()

check = [False]*30
for c in s:
    i = ord(c) - ord("a")
    check[i] = True

for c in t:
    i = ord(c) - ord("a")
    if not check[i]:
        print(-1)
        sys.exit()

dp = [[-1 for i in range(26)] for j in range(len(s))]

s = s + s

#
def ser(string :str,target :str,s :int):
    for i in range(s,len(string)):
        if string[i] == target:
            return i % (len(string)//2),i-1

# 指定した範囲に数字を埋める
def dig(ls,c,v,s,t):
    for i in range(s,t+1):
        ls[i][c] = v

for c in range(len(dp[0])):
    if not check[c]:continue
    i = 0
    while i < len(dp):
        start = i
        v,i = ser(s,chr(c+ord("a")),i+1)
        dig(dp,c,v,start,min(i,len(dp)-1))
        i += 1

# 最初にうまいことやるために
import copy
ls = [0 if s[0] == chr(i + ord("a")) else dp[0][i] for i in range(len(dp[0]))]
dp.append(ls)

ans = 0
i = -1
for char in t:
    ikari = dp[i][ord(char) - ord("a")]
    if i >= ikari:
        ans += 1
    i = ikari
print(ans * (len(dp)-1) + 1 + i)

Measured memory_bytes: 87016
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
    string str;
    priority_queue<int> q;

    for (int i = 0; i < 10 ; ++i) {
        getline(cin, str);
        int height = stoi(str.c_str());
        q.push(height);
    }

    for (int j = 0; j < 3; ++j) {
        cout << to_string(q.top()) << endl;
        q.pop();
    }

    return 0;
}

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

using namespace std;
struct city{
	int Y;
	int P;
	int id;
	int id2;
};
bool cmp(city a,city b){
	if( a.P < b.P)return true;
	else if(a.P == b.P){
		if( a.Y < b.Y)return true;
		else return false;
	}else return false;
}
bool cmp_byid(city a,city b){
	return a.id < b.id;
}
int main(void){
	int N,M;
	cin >> N >> M;
	city city[M];
	for(int i=0;i<M;i++){
		cin >> city[i].P >> city[i].Y;
		city[i].id = i;
	}
	sort(city,city+M,cmp);
	for(int i=0;i<M;i++){
		city[i].id2 = 1;
		while(city[i].P == city[i+1].P){
			i++;
			city[i].id2 =city[i-1].id2+1;
		}
	}
	sort(city,city+M,cmp_byid);
	for(int i=0;i<M;i++){
		printf("%06d%06d\n",city[i].P,city[i].id2);
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> V(N);
    for (int i = 0; i < N; i++) cin >> V.at(i);
    sort(V.begin(), V.end());
    double ans = (V.at(0) + V.at(1)) / 2.0;
    for (int i = 2; i < N; i++) ans = (ans + V.at(i)) / 2.0;
    cout << ans << "\n";
}

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

int main(){
  int64_t N;
  cin>>N;
  int i=(int)pow(N,0.5);
  for(;N%i!=0;i--){}
  int k,l;
  for(int j=i;j>0;j/=10)
    k++;
  for(int64_t j=N/i;j>0;j/=10)
    l++;
  cout<<max(k,l)<<endl;;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==1&&b==2){
   cout<<3; 
  }
  else if(a==1&&b==3){
   cout<<2; 
  }
  else if(a==2&&b==3){
   cout<<1; 
  }
  else if(a==2&&b==1){
    cout<<3;
  }
  else if(a==3&&b==1){
    cout<<2;
  }
  else if(a==3&&b==2){
    cout<<1;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
using PLL = pair<LL,LL>;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  LL W, H; cin >> W >> H;
  vector<PLL> xs;
  REP(i,W){
	LL x;
	cin >> x;
	xs.emplace_back(x, 0);
  }
  REP(i,H){
	LL x;
	cin >> x;
	xs.emplace_back(x, 1);
  }
  SORT(xs);

  LL ans = 0;
  REP(i,SZ(xs)){
	if(xs[i].SS == 0){
	  ans += xs[i].FF * (H + 1);
	  --W;
	}
	else{
	  ans += xs[i].FF * (W + 1);
	  --H;
	}
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4464
#include<stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while ( left < right ) {
    mid = (left + right) / 2;
    if ( key == A[mid] ) return 1;  /* key を発見 */
    if ( key > A[mid] ) left = mid + 1;  /* 後半を探索 */
    else if ( key < A[mid] ) right = mid;  /* 前半を探索 */
  }
  return 0;
}

int main() {
  int i, q, k, sum = 0;

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

  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &k);
    if ( binarySearch( k ) ) sum++;
  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 3008
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a, b, c, x, y;
    scanf("%ld %ld %ld %ld %ld", &a, &b, &c, &x, &y);
    
    long p=MIN(x,y);
    ll sum = MIN(a,2*c)*(x-p) + MIN(b,2*c)*(y-p) + MIN(a+b,c*2)*p;
    printf("%lld\n", sum);

    return 0;
}


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

int main(){
  	string str;
 	cin >> str;
  	int ones = 0;
 	for(int i = 0; i < (int)str.size(); ++i){
    	if(str[i] == '1'){
        	ones++;
        }
    }
  	int res = min(ones, (int)str.size() - ones) * 2;
  	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

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

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;cin>>n;
	string s;
	cin>>s;
	int ans=1;
	char cur=s.at(0);
	for(char c:s){
			if(c!=cur){
				cur=c;
				ans++;
			}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
using namespace std;

int digit[5];

int main() {
    for (int i = 0; i < 5; i++) {
        scanf("%d", &digit[i]);
    }
    sort(digit, digit+5);
    for (int i = 4; i> -1; i--) {
        if (i == 0) {printf("%d\n", digit[i]);}
        else {printf("%d ", digit[i]);}
    }
    return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int N;
   cin >> N;
   string S;
   cin >> S;
   vector<int> A(N);
   for (int i = 0; i < N; ++i) A[i] = S[i] - '0';
   {
      vector<int> B;
      for (int i = 0; i + 1 < N; ++i) {
         B.emplace_back(abs(A[i] - A[i + 1]));
      }
      A = B;
      N--;
   }
   auto solve = [&](vector<int> A) {
      int ans = 0;
      for (int i = 0; i < N; ++i) {
         if (((N - 1) & i) == i) {
            ans ^= A[i];
         }
      }
      return ans;
   };
   vector<int> B(N);
   for (int i = 0; i < N; ++i) B[i] = A[i] & 1;
   int p = solve(B);
   if (p == 1) {
      cout << "1\n";
      return 0;
   }
   bool one = false;
   for (int i = 0; i < N; ++i) one |= (A[i] == 1);
   if (one) {
      cout << "0\n";
      return 0;
   }
   for (int i = 0; i < N; ++i) B[i] = A[i] / 2;
   cout << solve(B) * 2 << "\n";
   return 0;
}


Measured memory_bytes: 13048
#include <bits/stdc++.h>
#define Rep(i, n) for (long long i = 0, i##_len = (n); i < i##_len; i++)
#define For(i, a, b) for (long long i = (a); i < b; i++)
typedef long long ll;

using namespace std;
int main()
{
    ll A, B;
    cin >> A >> B;
    cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

template <typename T>
struct edge {
  int from, to;
  T cost;
  edge(int t, T c) { to = t, cost = c; }
  edge(int f, int t, T c) { from = f, to = t, cost = c; }
};

template <typename T>
using Edges = vector<edge<T>>;
template <typename T>
using Graph = vector<Edges<T>>;

template <typename T>
vector<T> dijkstra(Graph<T>& G, int s) {
  const auto INF = numeric_limits<T>::max();  // Be careful not to overflow
  vector<T> dist(G.size(), INF);
  using Pli = pair<T, int>;
  priority_queue<Pli, vector<Pli>, greater<Pli>> que;
  dist[s] = 0;
  que.emplace(dist[s], s);  // cost, from
  while (!que.empty()) {
    Pli p = que.top();
    que.pop();
    T cost = p.first;
    int cur = p.second;
    if (dist[cur] < cost) continue;
    for (auto e : G[cur]) {
      auto next_cost = dist[cur] + e.cost;
      if (dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

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

  int n, m;
  cin >> n >> m;
  Graph<lint> G(n);
  int l, r;
  lint c;
  FOR(i, 1, n) G[i].emplace_back(i - 1, 0);
  rep(i, m) {
    cin >> l >> r >> c;
    l--, r--;
    G[l].emplace_back(r, c);
  }
  auto dist = dijkstra(G, 0);

  if (dist[n - 1] == numeric_limits<lint>::max()) {
    cout << -1 << endl;
  } else {
    cout << dist[n - 1] << endl;
  }

  return 0;
}

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

signed main(void){
 
  int N; cin >> N;
  map<string,int> mp;
  for(int i = 0; i < N; i++){ 
    string s; cin >> s;
    mp[s]++;
  }
  
  vector<pair<int,string>> ans;
  
  int cnt = 0;
  for(auto ne : mp){
    ans.push_back({-ne.second,ne.first});
    //-出現回数、stringの順
    cnt = max(cnt,ne.second);
  }
  
  sort(ans.begin(),ans.end());
  
  for(auto p : ans){
    if( p.first == -cnt){
    cout << p.second << endl;
    } 
  }

  return 0;
}

Measured memory_bytes: 30320
#include <iostream>
int main(int argc, char const *argv[]) {
  int a, b;
  std::cin >> a >> b;
  if (b % a == 0) {
    std::cout << a + b << std::endl;
  } else {
    std::cout << b - a << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}, block = 555;
const int inf = 1e9, N = 2e5 + 48, mod = 1e9 + 7, maxn = 2e5 + 11;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, dp[N], h[N], c;

struct line {
	int k, b;
	line () {
		k = 0;
		b = 0;		
	}

	line (int k1, int b1) {
		k = k1, b = b1;	
	}
};

vector < line > v;

db inter (line A, line B) {
	return (B.b - A.b + 0.0) / (A.k - B.k);
}

void add (int i) {
	line cur = *new line (-2*h[i], dp[i] + h[i]*h[i]);
	while (sz(v) > 1 && inter(cur, v.back()) < inter(v.back(), v[sz(v) - 2]))
		v.ppb();
	v.pb(cur);
}

int get (int x) {
	int l = 1, r = sz(v) - 1, j = 0;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (inter(v[mid], v[mid - 1]) <= x + 0.0) {
			l = mid + 1;
			j = mid;
		} else
			r = mid - 1;			
	}

	return x*v[j].k + v[j].b;
}


main () {
	cin >> n >> c;
	forn (i, 1, n)
		cin >> h[i];
	dp[1] = 0;
	add(1);

	forn (i, 2, n) {
		dp[i] = h[i] * h[i] + c + get(h[i]);
		add(i);
	}
	
	cout << dp[n] << endl;
}          
 

Measured memory_bytes: 14452
from itertools import accumulate
N, M, T = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Asum = list(accumulate(A, initial=0))
Bsum = list(accumulate(B, initial=0))

ans = 0
j = 0
for i in reversed(range(N + 1)):
    x = Asum[i]
    if x > T:
        continue
    while j < M and Bsum[j + 1] + x <= T:
        j += 1
    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47588
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    if len(s) == 2:
        if s[0] == s[1]:
            print(1, 2)
        else:
            print(-1, -1)
    else:
        for i in range(len(s)-2):
            ts = s[i:i+3]
            if ts[0] == ts[1] or ts[1] == ts[2] or ts[0] == ts[2]:
                print(i+1, i + 3)
                exit()
        print(-1, -1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39536
def theater(N: int, queries: list)->int:
    return sum(r - l + 1 for l, r in queries)


if __name__ == "__main__":
    N = int(input())
    queries = [tuple(int(s) for s in input().split()) for _ in range(N)]
    ans = theater(N, queries)
    print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int[] A = GetInts(N);

		var dict = new Dictionary<int, int>();
		var set = new SortedSet<int>();
		for(int i = 0; i < N; i++)
		{
			int current = 0;
			dict.TryGetValue(A[i], out current);
			dict[A[i]] = current + 1;
			set.Add(A[i]);
		}

		int ans = 0;
		int rest = N;
		while(set.Count > 0)
		{
			int max = set.Max;
			dict[max]--;
			if(dict[max] == 0)
				set.Remove(max);

			int k = 0;
			int tmp = max;
			while(tmp > 0)
			{
				k++;
				tmp >>= 1;
			}

			int pair = (1 << k) - max;
			if(!set.Contains(pair))
				continue;

			int current = dict[pair];
			dict[pair] = current - 1;			
			ans++;
			if(current == 1)
				set.Remove(pair);
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 50216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if (a.back() == b.front() && b.back() == c.front()) {
    YES();
  }
  else NO();
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;
typedef double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 _y0
#define kill _kill

//permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int two = 2;
const ld eps = 1e-8;
const ll INF = (ll)(1e18 + 239);
const int BIG = (int)(2e9 + 239);
const ll MOD = 1e9 + 7;
const ll MOD2 = (ll)MOD * (ll)MOD;

//random
#ifdef ONPC
mt19937_64 rnd(239);
#else
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

//constants
const int M = (int)(2e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 20;
const int T = (1 << 20) + 239;
const int B = 500;
const int X = 1e6 + 239;

int to[X][alf], k, in[X], cnt[X][alf], sum[X];

void push(string s)
{
    //cerr << s << "\n";
    int cur = 0;
    for (char x : s)
    {
        int d = x - 'a';
        if (to[cur][d] == -1)
            to[cur][d] = k++;
        cur = to[cur][d];
    }
    in[cur]++;
}

ll dfs(int p)
{
    ll ans = 0;
    sum[p] = 0;
    for (int d = 0; d < alf; d++)
        if (to[p][d] != -1)
        {
            int i = to[p][d];
            ans += dfs(i);
            sum[p] += sum[i];
            cnt[i][d] = sum[i];
            for (int x = 0; x < alf; x++)
                cnt[p][x] += cnt[i][x];
        }
    for (int d = 0; d < alf; d++)
        if (to[p][d] != -1)
        {
            int i = to[p][d];
            cnt[p][d] -= sum[i];
            ans += (ll)in[i] * (ll)cnt[p][d];
            cnt[p][d] += sum[i];
        }
    ans += (ll)in[p] * (ll)sum[p];
    sum[p] += in[p];
    return ans;
}

int32_t main()
{
#ifdef ONPC
    freopen("input", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    memset(to, -1, sizeof(to));
    k = 1;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        reverse(s.begin(), s.end());
        push(s);
    }
    cout << dfs(0) << "\n";
    return 0;
}

Measured memory_bytes: 315772
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        int ans1=0,ans2=0,ans3=0;
        int maxx=max(max(a,b),c);
        int minn=min(min(a,b),c);
        int mid=(a+b+c)-minn-maxx;
        while(1)
        {
 
            if(minn==mid && mid==maxx)
            {
                break;
            }
            if(mid<maxx && minn<maxx)
            {
                //cout<<"yes1"<<endl;
                mid++;
                minn++;
                ans1++;
            }
            else if(mid>=maxx && minn<maxx)
            {
                //cout<<"yes2"<<endl;
                minn+=2;
                ans1++;
            }
            else if(mid<maxx && minn>=maxx)
            {
               // cout<<"yes3"<<endl;
                mid+=2;
                ans1++;
            }
            int ans;
            ans=minn+maxx+mid;
            minn=min(minn,min(maxx,mid));
            maxx=max(max(maxx,mid),minn);
            mid=ans-minn-maxx;
        }
        cout<<ans1<<endl;
    }
}

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

using namespace std;

int main(){
  int N;
  string S;
  string alpha = "abcdefghijklmnopqrstuvwxyz";

  cin >> N;
  cin >> S;

  int count=0;
  int max_count=0;

  for(int i = 0; i<N;i++){
    for(int j = 0; j<26;j++){
      if((int)S.find(alpha[j]) < i && (int)S.find(alpha[j],i) != -1){
        count++;
      }
    }
    if(count > max_count){
      max_count = count;
    }
    count = 0;
  }

  cout << max_count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int a, b, i, j, k;
	bool solved = false;

	cin >> a >> b;
	for (i = 0; i <= a; i++) {
		j = a - i;
		if (i * 2 + j * 4 == b) solved = true;
	}
	if (solved) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;

int keta_Sum(int num){
    
    int sum = 0;
    while(num != 0){
        sum += num % 10;
        num /= 10;
    }
    
    return sum;
}

int main(){
    
    int N;
    cin >> N;
    
    int ans = INT_MAX;
    for(int A = 1; A < N; A++){
        int A_keta = keta_Sum(A);
        int B_keta = keta_Sum(N - A);
        // 各桁の和を計算いて最小値を求める
        ans = min(ans, A_keta + B_keta);
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3196