akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env ruby

if $0 == __FILE__
  N = gets.to_i
  A = gets.split(' ').map &:to_i

  A.sort!.reverse!

  alice = 0
  bob = 0
  A.each_with_index do |a, i|
    if i % 2 == 0
      alice += a
    else
      bob += a
    end
  end

  puts alice - bob
end


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int a[n], b[n];
  REP(i, n) cin>>a[i];
  REP(i, n) cin>>b[i];

  if(n==1){
    cout<<a[0]+b[0]<<endl;
    return 0;
  }

  int ans=0;
  int temp;
  REP(i, n){
    temp=0;
    REP(j, i+1) temp += a[j];
    FOR(j, i, n) temp += b[j];
    ans =max(ans, temp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, X;
	cin >> N >> X;
	vector<int> B(N);
	vector<int> L(N);
	vector<int> U(N);
	int res = 0;
	vector<pair<int, int> > P(N);
	int tot = 0;
	for (int i = 0; i < N; i++) {
		cin >> B[i] >> L[i] >> U[i];
		P[i].first = B[i] * L[i] + (X - B[i]) * U[i];
		P[i].second = i;

		
		tot += B[i] * L[i];
	}
	sort(P.rbegin(), P.rend());

	int tmp = 0;
	//cerr << tot << endl;
	for (int i = 0; i < N; i++) {
		//cerr << i << " " << P[i].first << endl;
		

		tmp += P[i].first;
		res += X;

		if (tmp >= tot) {
			int mn = X;
			//tmp -= P[i].first;
			for (int j = 0; j < N; j++) {
				int idx = P[j].second;

				int ok = X;
				int ng = -1;
				while (ok - ng > 1) {
					int m = (ok + ng) / 2;
					int z = 0;
					if (m <= B[idx]) {
						z = m * L[idx];
					}
					else {
						z = L[idx] * B[idx] + (m - B[idx]) * U[idx];
					}
					if (j <= i) {
						z -= P[j].first;
					}
					else {
						z -= P[i].first;
					}

					if (tmp + z >= tot) {
						ok = m;
					}
					else {
						ng = m;
					}

				}
				
				mn = min(mn, ok);
			}
			res += mn;
			res -= X;
			break;
		}
		
	}


	cout << res << endl;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> d(n + 1);
    vector<int> l(n);

    rep(i, n) {
        cin >> l[i];
        d[i + 1] = d[i] + l[i]; 
    }

    int ans = 0;
    rep(i, n + 1) {
        if (d[i] <= x) ans++;
        else break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFavoriteSound solver = new AFavoriteSound();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFavoriteSound {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            out.print(Math.min(C, B / A));

        }

    }
}



Measured memory_bytes: 23252
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <complex>
using namespace std;


int main() {
	int A,B;
	string S;
	cin >> A>>B>> S;
	for (int i = 0; i < A + B + 1; i++) {
		if (i != A) {
			if (S[i] == '-') { cout << "No" << endl; return 0; }
		}
		else
			if (S[i] != '-'){  cout << "No" << endl; return 0;}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

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

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";

int N, A;
vector<int> x(51);
vector<vector<ll>> dp(51, vector<ll>(50*50*2+1, -1));

ll calc(int index, int sum) {
    if ( sum < 0 || sum > 2*A*N ) return 0;
    if ( dp[index][sum] > -1 ) return dp[index][sum];

    if ( index == 0 ) {
        if ( sum-A*N == 0 ) return 1;
        else return 0;
    }
    dp[index][sum] = calc(index - 1, sum) + calc(index - 1, sum - x[index]);

    return dp[index][sum];
}

int main() {

    cin >> N >> A;
    for (int i = 1; i <= N; i++) {
        int temp;
        cin >> temp;
        x[i] = temp - A;
    }

    cout << (calc(N, A*N) - 1) << "\n";

    return 0;
}

Measured memory_bytes: 2304
from sys import stdin


def main() -> None:
    a, b, k = [int(next_str()) for _ in range(3)]

    for i in range(k):
        if i % 2 == 0:
            a //= 2
            b += a
        else:
            b //= 2
            a += b

    print(a, b)


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int w,a,b,t;
    while(scanf("%d%d%d",&w,&a,&b)==3)
    {
        if(a>=b)
        {
            t=a-w-b;
            if(t>0)
                printf("%d\n",t);
            else printf("0\n");
        }
        else {
            t=b-w-a;
            if(t>0)
                printf("%d\n",t);
            else printf("0\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans=0;
  if(k>a){
  	ans=a;
  	k-=a;
  }
  else {cout<<k<<endl;return 0;}
  if(k>b){
  	k-=b;
  }
  else {cout<<ans<<endl;return 0;}
  ans-=k;
  cout<<ans<<endl;return 0;
  return 0;
}

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

#define rc(x) return cout<<x<<endl,0

using namespace std;
long long a,b,c,k;
int main(){
		cin>>a>>b>>c>>k;
		if(k%2==1) cout<<b-a<<endl;
		else cout<<a-b<<endl;
	}	 		

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC141 E
#Z-algorithm

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def z_algorithm(s):
    n = len(s)
    Z = [0] * n
    Z[0] = n
    L,R = 0,0
    for i in range(1, n):
        if i >= R: #過去の結果が使えない
            L = R = i
            while R < n and s[R-L] == s[R]:
                R += 1
            Z[i] = R - L
        elif Z[i-L] < R-i:#過去の結果が全て使える
            Z[i] = Z[i - L]
        else:#過去の結果が一部使える
            L = i
            while R < n and s[R-L] == s[R]:
                R += 1
            Z[i] = R - L
    return Z

n = I()
s = input()
ans = 0
for i in range(n):
    Z = z_algorithm(s[i:])
    for j,z in enumerate(Z):
        if j < z:
            continue
        ans = max(ans,z)
print(ans)

Measured memory_bytes: 49884
n,a,h[7];
main(){
	for(;scanf("%d",&n),n;){
		for(;n--;){
			scanf("%d",&a);
			h[a>59?6:a/10]++;
		}
		for(;++n<7;h[n]=0)
			printf("%d\n",h[n]);
	}
	exit(0);
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	ll x;
	cin >> x;
	if(x <= 6) cout << 1 << endl;
	else if(x % 11 == 0) {
		cout << x / 11 * 2 << endl;
	} else {
		ll rsl = x / 11 * 2;
		x -= (x / 11 * 11);
		if(x > 6) rsl += 2;
		else rsl++;
	cout << rsl << endl;
	}
}




Measured memory_bytes: 256
require 'matrix'


n, m, _ = gets.split.map(&:to_i)

a = n.times.map do
      gets.split.map(&:to_i)
    end

b = m.times.map do
      gets.split.map(&:to_i)
    end

ma = Matrix.rows(a)
mb = Matrix.rows(b)
mc = ma * mb

mc.row_vectors.each {|row| puts row.to_a.join("\s")}


Measured memory_bytes: 7640
while True:
    n = 0
    int1 = input()
    int2 = [int(a) for a in int1]
    if int2[0] == int2[1] == int2[2] == int2[3]:
        if int2[0] == 0:
            break
        else:
            print("NA")
            continue
    else:
        while True:
            int1 = int(int1)
            if int1 == 6174:
                print(n)
                break
            else:
                int2.sort()
                num1 = int2[0] * 1000 + int2[1] * 100 + int2[2] * 10 + int2[3]
                int2.reverse()
                num2 = int2[0] * 1000 + int2[1] * 100 + int2[2] * 10 + int2[3]
                int1 = num2 - num1
                int2 = [int(b) for b in str(int1)]
                n += 1
                if len(int2) < 4:
                    int2.insert(0,0)
                continue


Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define FO(i, a, b) for (int i = a; i <= b; i++)
#define FE(i, a, b) for (int i = a; i < b; i++)
#define FR(i, a, b) for (int i = a; i >= b; i--)
#define R(i) i = read()

using namespace std;

int read() {
	int x = 0; char c = getchar();
	while((c != '-') && (c < 48 || c > 57)) x = x * 10 + c - 48, c = getchar();
	if(c == '-') {c = getchar(); while(c >= 48 && c<= 57) x = x * 10 - c + 48, c = getchar();}
	else while(c >= 48 && c<= 57) x = x * 10 + c - 48, c = getchar();
	return x;
}

int n, a, b, m;

char c[10000];

const int N = 400000;

int D[N], T[N];

int main() {
	cin >> n;
	FO(i, 1, n) cin >> D[i];
	cin >> m;
	FO(i, 1, m) cin >> T[i];
	sort(D + 1, D + n + 1), sort(T + 1, T + m + 1);
	int j = 1;
	FO(i, 1, m) {
		while(D[j] != T[i]) {
			j++;
			if(j > n) {
				cout << "NO";
				return 0;
			}
		}
		j++;
	}
	cout << "YES";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

struct BIT{
	int N;
	vector<int>bit;
	void add(int x,int y){
		while(x<=N){
			bit[x]+=y;x+=x&-x;
		}
	}
	int sum(int x){
		int res=0;
		while(x>0){
			res+=bit[x];x-=x&-x;
		}
		return res;
	}
	int lower_bound(int w){
		if(w<=0)return 0;
		int x=0;
		int k=1;while(k*2<=N)k*=2;
		for(;k>0;k/=2){
			if(x+k<=N&&bit[x+k]<w){
				w-=bit[x+k];
				x+=k;
			}
		}
		return x+1;
	}
	BIT(int x):N(x),bit(x+1){}
};
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,Q;cin>>N>>Q;
	BIT bit(N);
	rep(i,N){
		int a;cin>>a;
		bit.add(i+1,a);
	}
	while(Q--){
		int t,p,x;cin>>t>>p>>x;
		if(!t)bit.add(p+1,x);
		else cout<<bit.sum(x)-bit.sum(p)<<"\n";
	}
}

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

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

  if (N % (2 * D + 1) == 0){
    cout << N / (2 * D + 1) << endl;
  }
  else
  {
    cout << N / (2 * D + 1) + 1 << endl;
  }
  
}

Measured memory_bytes: 3588
import java.io.BufferedInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class Main{
    static Scanner s = new Scanner(new BufferedInputStream(System.in));
    public static void solution1(){
        int k = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();

        for(int i = a ; i <= b ; i++ ){
            if(i%k == 0){
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }

    public static void solution2(){

    }

    public static void solution3(){

    }
    public static void main(String[] args) {
        solution1();
    }
}

Measured memory_bytes: 35776
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    private static int cnt;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        shellSort(a, n);
    }

    private static void insertionSort(int[] a, int n, int g) {
        for (int i = g; i < n; i++) {
            int v = a[i];
            int j = i - g;
            while (j >= 0 && a[j] > v) {
                a[j+g] = a[j];
                j = j- g;
                cnt++;
            }
            a[j+g] = v;
        }
    }

    private static void shellSort(int[] a, int n) {
        cnt = 0;
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; Math.pow(2, i) - 1 <= n; i++) {
            al.add((int) Math.pow(2, i) - 1);
        }
        Integer[] g = al.toArray(new Integer[0]);
        int m = g.length;
        System.out.println(m);
        System.out.println(printArray(g));
        for (int i = m - 1; i >= 0; i--) {
            insertionSort(a, n, g[i]);
        }
        System.out.println(cnt);
        for (int i = 0; i < n; i++) {
            System.out.println(a[i]);
        }
    }

    private static String printArray(Integer[] a) {
        int length = a.length;
        String arrayString = "";
        for (int i = length - 1; i > 0; i--) {
            arrayString = arrayString + a[i] + " ";
        }
        arrayString = arrayString + a[0];
        return arrayString;
    }
}



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

using ll = long long int;

int n, k;

ll ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  for (int b = 1; b <= n; ++b) {
    int maxnum = b - 1;

    int cand_part = (maxnum >= k) ? maxnum - k + 1 : 0;

    int part_num = (n + 1) / b;
    int remain = (n + 1) % b;

    if (remain > 0) {
      int remain_maxnum = n % b;
      int remain_cand_part = (remain_maxnum >= k) ? remain_maxnum - k + 1 : 0;
      ans += cand_part * part_num + remain_cand_part;
    }
    else {
      ans += cand_part * part_num;
    }
  }

  if (k == 0) ans -= n;

  printf("%lld\n", ans);

	return 0;
}


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

const int MOD = 1000000007;
const int MAX =200000;

int main() {
  string s;
  cin >> s;
  if(s == "AAA" || s == "BBB") {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    deque<char> q;//double-ended queue
    for (char c : s)
        q.push_back(c);
    bool flip = false;
    int Q;
    cin >> Q;
    rep(qi, Q){
        int ty;
        cin >> ty;
        if(ty == 1){
            flip = !flip;// bool値で管理
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (flip)
                f = 3 - f; //!!
            if(f == 1){
                q.push_front(c);
            } else {
                q.push_back(c);
            }
        }
    }
    if(flip)
        reverse(q.begin(), q.end());
    string ans;
    for(char c : q)
        ans += c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
/* 
 * Project: Panasonic programing Contest A - Kth Term
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/03/14
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int k;
int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

void solve() {

    cout << a[k-1] << endl;

}

int main() {

    cin >> k;

    solve();

}


Measured memory_bytes: 256
//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //Your code goes here
            string input = Console.ReadLine();
            var number = int.Parse(input);
            int fee = 800;
            double discount =  number / 15;
             discount =Math.Floor(discount);
            
            double sum = fee * number;
            double discountSum = 200 * discount;
            
             Console.WriteLine(sum - discountSum);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <set>
#include <string>

using namespace std;


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cntA[n+2];
    int cntB[n+2];
    int ans=300001;
    cntA[0]=0;cntA[n+1]=0;
    cntB[0]=0;cntB[n+1]=0;
    for(int i=1;i<=n;i++){
        cntA[i]=0;
        cntB[i]=0;
        if (s[i-1]=='E'){
            cntA[i]++;
        }
        cntA[i]+=cntA[i-1];
    }
    for(int i=n;i>=1;i--){
        if (s[i-1]=='W'){
            cntB[i]++;
        }
        cntB[i]+=cntB[i+1];
    }
    int pos=0;
    for(int i=1;i<=n;i++){
//        cout << cntA[i] <<" "<<cntB[i] <<endl;
    }
    for(int i=1;i<=n;i++){
        ans= min(ans,cntA[n]-cntA[i]+cntB[1]-cntB[i]);
//            cout << cntA[n]-cntA[i] << " " << cntB[1]-cntB[i] <<endl;
        if (ans==cntA[n]-cntA[i]+cntB[1]-cntB[i]){
            pos=i;
        }
    }

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

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


int f[100000];
signed main(){
  int n, m;
  scanf("%lld%lld", &n, &m);
  rep(i,m){
    int x, y;
    scanf("%lld%lld", &x, &y);x--;y--;
    f[x]++;f[y]++;
  }
  int ans = 1;
  rep(i,n)if(f[i]%2 == 1)ans = 0;
  printf("%s\n", ans ? "YES" : "NO");
	return 0;
}









Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char k[30];
int main()
{
	int a,b,c,tot=0;
	scanf("%d%d%d",&a,&b,&c);
	scanf("%s",k);
	if((k[strlen(k)-1]-'0')%2==1) printf("%d",b-a);
	else printf("%d",a-b);
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e5+6;
int a[N];
void solve(){
	int n; 
	cin>>n; 
	string s; 
	cin>>s; 
	int cnt = 0;
	int mn = 0;
	for(int i=0;i<n;i++){
		if(s[i]=='(')cnt++;
		else cnt--;
		mn = min(mn,cnt);
	}
	mn = -mn;
	string ss = "";
	for(int i=0;i<mn;i++)ss+='(';
	for(int i=0;i<n;i++)ss+=s[i];
	cnt = 0;
	n = ss.size();
	for(int i=0;i<n;i++){
		if(ss[i]=='(')cnt++;
		else cnt--;
	}
	for(int i=0;i<cnt;i++){
		ss+=')';
	}
	cout<<ss<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


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

int main() {
    int N;
    int A;

    cin >> N >> A;

    int i;
    i = N % 500;

    if(i <= A){
        cout << "Yes" << endl;
     }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int N;
  cin>>N;
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin>>b.at(i);
  }
  vector<int> a(N);
  bool flag=true;
  for(int i=0;i<N;i++){
    bool sub=true;
    for(int j=N-i-1;j>=0;j--){
      if(b.at(j)==j+1){
        a.push_back(b.at(j));
        b.erase(b.begin()+j);
        sub=false;
        break;
      }
    }
    if(sub){
      flag=false;
      break;
    }
  }
  if(!flag){
    cout<<-1<<endl;
  }else{
    reverse(a.begin(),a.end());
    for(int i=0;i<N;i++){
      cout<<a.at(i)<<endl;
    }

  }

}


Measured memory_bytes: 256
// WEWEWEEEWWWE
package main

import (
	"fmt"
)

func main() {
	var size int
	var input string

	fmt.Scanf("%d", &size)
	fmt.Scanf("%s", &input)

	hoge := make([]int, size)

	x := 0
	for i := 0; i < size; i++ {
		hoge[i] = x
		if input[i] == 'W' {
			x++
		}
	}

	fuga := make([]int, size)

	y := 0
	for i := size - 1; i >= 0; i-- {
		fuga[i] = y
		if input[i] == 'E' {
			y++
		}
	}

	result := 9223372036854775807
	for i := 0; i < size; i++ {
		if result > hoge[i]+fuga[i] {
			result = hoge[i] + fuga[i]
		}
	}
	fmt.Printf("%d\n", result)
}


Measured memory_bytes: 7296
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] strs = str.split(" ");
        int a = Integer.parseInt(strs[0]);
        int b = Integer.parseInt(strs[1]);
        System.out.println(a*b + " " + 2*(a+b));
    }
}

Measured memory_bytes: 24024
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        N: usize,
        K: usize,
    }

    if K == 1 {
        println!("0");
        return;
    }

    // まずK人全員に1個ずつ配る
    // 1人だけ残りを得る
    let few: usize = 1;
    let most = N - (K - 1);

    let ans = most - few;
    println!("{}", ans);
}


Measured memory_bytes: 2168
N = int(input())
A = list(map(int, input().split()))

def to_bit(n):
    print(bin(n))

x = 0
for a in A:
    x = x^a
    # print(bin(x), x)

res = []
for a in A:
    res.append(x^a)
# print(res)
print(" ".join(map(str, res)))



Measured memory_bytes: 41836
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

mod_counter = Hash.new(0)
sum = 0
ans = 0

A.each_with_index do |a, index|
  sum = (sum + a) % M

  if sum == 0
    ans += 1
  end

  ans += mod_counter[sum]

  mod_counter[sum] += 1
end

puts ans


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

using namespace std;

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

int main(void)
{
	int n;
	cin >> n;
	vec<int> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n) a[i]--;
	int ans = 0;
	rep(i, n) if (a[a[i]] == i) ans++;
	ans /= 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
import java.util.*;

public class Main {
    static List<List<Integer>> ll = new LinkedList<>();
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        List<Integer> b = new ArrayList<>();
        populateList(a, n);
        populateList(b, n);

        LinkedList<Integer> arr = new LinkedList<>();
        per(arr, n, new boolean[n]);
        int ans1 = getN(ll, a);
        int ans2 = getN(ll, b);
        System.out.println(Math.abs(ans1-ans2));

    }

    static int getN(List<List<Integer>> sorted, List<Integer> arr) {
        int idx = 0;
        for (List<Integer> perms : sorted) {
            idx++;
            boolean flag = true;
            for (int i = 0; i < perms.size(); i++) {
                if (!perms.get(i).equals(arr.get(i))) {
                    flag = false;
                    break;
                }
            }
            if (flag)
                return idx;
        }
        return -1;
    }

    static void populateList(List<Integer> arr, int n) {
        for (int i = 0; i < n; i++) {
            arr.add(sc.nextInt());
        }
    }

    static void per(LinkedList<Integer> arr, int n, boolean[] mask){
        if (arr.size() == n) {
            ll.add(new LinkedList<>(arr));
            return;
        }

        for (int i = 0; i < n; i++) {
            if (!mask[i]) {
                arr.add(i+1);
                mask[i] = true;
                per(arr, n, mask);
                arr.removeLast();
                mask[i] = false;
            }
        }
    }
}

Measured memory_bytes: 50340
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve()
{
    string s;
    cin >> s;
    rep(i, s.size()) if (s[i] == ',') s[i] = ' ';
    cout << s << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3576
n=int(input())
a=list(map(int, input().split()))
count=[0]*(n+1)
for i in range(n):
  count[a[i]]+=1
cans=[i*(i-1)//2 for i in range(n+1)]
total=0
for i in range(1, n+1):
  total+=cans[count[i]]
for i in range(n):
  print(total-cans[count[a[i]]]+cans[count[a[i]]-1])

Measured memory_bytes: 26268
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans;
  if(s == "SUN")ans = 7;
  else if(s == "MON")ans = 6;
  else if(s == "TUE")ans = 5;
  else if(s == "WED")ans = 4;
  else if(s == "THU")ans = 3;
  else if(s == "FRI")ans = 2;
  else if(s == "SAT")ans = 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <queue>

using namespace std;
typedef long long ll;
ll waru = 1e9+7;

int main() {

	ll H, W;
	cin >> H >> W;
	vector<vector<ll > > K(H + 2, vector<ll >(W + 2, 0));

    string t;
	for(ll i = 1; i <= H; i++){
        cin >> t;
        for(ll j = 1; j <= W; j++){
            if(t.substr(j-1,1) == "."){
                K[i][j] = 1;
            }
        }
	}
    
    vector<vector<ll > > dp(H + 2, vector<ll >(W + 2, 0));
    dp[1][1] = 1;
	for(ll i = 1; i <= H; i++){
        for(ll j = 1; j <= W; j++){
            if(i == 1 && j == 1) continue;
            if(K[i][j] != 1) continue;
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            dp[i][j] %= waru;
        }
	}
    
    /*
	for(ll i = 1; i <= H; i++){
        for(ll j = 1; j <= W; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
	}
    */
    

    ll ans = dp[H][W] % waru;

    cout << ans  << endl;
      
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	// n-k個の部分はプラスのみを取ることができ、
	// 残りのk個は全て白に塗るか全て黒に塗るかの有利な方を選ぶ
    // O(n)で抑えるため、配列計算を工夫している

	ll n,k;
	cin >> n >> k;

	ll a[n];
	rep(i,n) cin >> a[i];

	ll all_nonzero = 0;
	rep(i,n) if(a[i] > 0) all_nonzero += a[i];

	ll k_nn = 0;
	rep(i,k) if(a[i] > 0) k_nn += a[i];

	ll k_nonzero[n-k+1];
	rep(i,n-k+1){
		k_nonzero[i] = k_nn;
		if(a[i] > 0) k_nn -= a[i];
		if(i+k < n && a[i+k] > 0) k_nn += a[i+k];
	}

	ll k_ov = 0;
	rep(i,k) k_ov += a[i];

	ll k_overzero[n-k+1];
	rep(i,n-k+1){
		k_overzero[i] = max(k_ov,0LL);
		k_ov -= a[i];
		if(i+k < n) k_ov += a[i+k];
	}

	ll ans = 0;
	rep(i,n-k+1) ans = max(ans,all_nonzero - k_nonzero[i] + k_overzero[i]);
	cout << ans << endl;	
}

Measured memory_bytes: 2560
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)

  def initialize
    @n = gets.to_s.to_i
    @a = Array.new(n) do
      x,y,h = gets.to_s.split.map{ |v| v.to_i }
      [h,y,x]
    end
    @a.sort!.reverse!
  end

  def solve
    0.upto(100) do |i|
      0.upto(100) do |j|
        return query(i,j) if valid?(i,j)
      end
    end
  end

  def valid?(i,j)
    hh = height(i,j,0)
    1.upto(n-1).all? do |k|
      h,y,x = a[k]
      h == [hh - manhattan(i,j,y,x), 0].max
    end
  end
  
  def manhattan(y1,x1,y2,x2)
    (y1-y2).abs + (x1-x2).abs
  end
  
  def query(i,j)
    h = height(i,j,0)
    [j,i,h]
  end

  def height(i,j,k)
    h,y,x = a[k]
    manhattan(i,j,y,x) + h
  end
  
  def show(ans)
    puts ans.join(" ")
  end
end

Problem.new.instance_eval do
  show(solve)
end


Measured memory_bytes: 14312
#include <stdio.h>
#include <string.h>

char X[1000];
char Y[1000];

int LCS()
{
  int i,j,lx,ly;
  lx=strlen(X);
  ly=strlen(Y);
  int Z[lx+1][ly+1];

  for(i=1;i<=lx;i++)
    {
      Z[i][0]=0;
    }
  for(j=0;j<=ly;j++)
    {
      Z[0][j]=0;
    }
  for(i=1;i<=lx;i++)
    {
      for(j=1;j<=ly;j++)
	{
	  if(X[i-1]==Y[j-1])
	    {
	      Z[i][j]=Z[i-1][j-1]+1;
	    }
	  else if(Z[i-1][j]>=Z[i][j-1])
	    {
	      Z[i][j]=Z[i-1][j];
	    }
	  else
	    {
	      Z[i][j]=Z[i][j-1];
	    }
	}
    }
  return Z[lx][ly];
}

main()
{
  int n,i;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%s%s",X,Y);
      printf("%d\n",LCS());
    }
  return 0;
}

Measured memory_bytes: 4512
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

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

    int i = 1;

    if(s == 1 || s == 2 || s == 4){
        cout << 4 << endl;
        return 0;
    }

    while(s != 1){
        if(s%2 == 0){
            s /= 2;
        }else{
            s = 3*s + 1;
        }
        i++;
    }

    cout << i+1 << endl;

    return 0;
}

Measured memory_bytes: 256
K = int(input())
ans = []
R = [[] for _ in range(11)]
for i in range(1,10):
  R[0].append(i)
for i in range(1,11):
  R[i] = [10**i]
  if i > 1:
    for j in range(i-1):
      for r in R[i-2-j]:
        d = r//(10**(i-2-j))
        if d <= 1:
          R[i].append(10**i+r)
  for r in R[i-1]:
    d = r//(10**(i-1))
    for j in [-1,0,1]:
      if 1<= d+j <= 9:
        R[i].append((d+j)*(10**i)+r)
A = []
#print(sorted(R[0]))
#print(sorted(R[1]))
#print(sorted(R[2]))
#print(sorted(R[3]))
#print(sorted(R[4]))
#print(sorted(R[10]))
for i in range(11):
  for r in R[i]:
    A.append(r)
A.sort()
#print(len(A))
print(A[K-1])
       
            
            


Measured memory_bytes: 91440
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

ll r, c, n;

bool isedge(ll x, ll y) {
	return x == 0 || x == r || y == 0 || y == c;
}

ll top(ll x, ll y) {
	if (y == 0) {
		return x;
	} else if (x == r) {
		return r + y;
	} else if (y == c) {
		return 2 * r + c - x;
	} else {
		return 2 * r + 2 * c - y;
	}
}

int main() {
	IOS();
	cin >> r >> c >> n;
	vector<P> edge;
	for (int i = 0; i < n; i++) {
		ll x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if (isedge(x1, y1) && isedge(x2, y2)) {
			ll p1 = top(x1, y1), p2 = top(x2, y2);
			edge.emplace_back(p1, i);
			edge.emplace_back(p2, i);
		}
	}
	sort(edge.begin(), edge.end());
	int m = edge.size();
	if (m <= 1) {
		dump("YES");
		return 0;
	}
	stack<ll> st;
	st.push(-1);
	for (int i = 0; i < m; i++) {
		if (st.top() != edge[i].second) {
			st.push(edge[i].second);
		} else {
			st.pop();
		}
	}
	dump(st.size() == 1 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 6384
N=int(input())
ans=[0]*N
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      temp=x**2+y**2+z**2+x*y+y*z+z*x
      if temp<=N:
        ans[temp-1]+=1
[print(x) for x in ans]


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

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

    ll N;

    cin >> N;
    vector<ll> array(N, 0);

    REP(i, N){ cin >> array[i]; }
    sort(array.begin(), array.end());
    reverse(array.begin(), array.end());

    ll total = 0;
    queue<ll> q;
    q.push(array[0]);
    for(int i = 1; i < N; i++ ){
            q.push(array[i]);
            q.push(array[i]);
            total += q.front();
            q.pop();
    }

    cout << total << endl;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a>d || c>b) cout << '0' << endl;
    else {
        cout << ((b>d)?d:b) - ((a>c)?a:c) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
/*
int b[1000000001];

int main() {
    ios::sync_with_stdio(false);
    cin.tie();
    int n;
    int x = 0;
    cin >> n;
    int a[n];
    for( int i = 0 ; i < n ; i++ ) cin >> a[i];
    sort( a , a + n );
    
    for( int i = 1 ; i <= a[n - 1] ; i++ ) b[i] = 0;
    
    for( int i = 0 ; i < n ; i++ ) {
        b[a[i]]++;
    }
        
    for( int i = 1 ; i <= a[n - 1] ; i++ ) {
        if( b[i] > 0 ) {
            if( i != b[i] ) {
                if( b[i] > i ) x += b[i] - i;
                else x += b[i];
            }
        }
    }

    cout << x;
}
*/

int main() {
    ios::sync_with_stdio(false);
    cin.tie();
    int n;
    int x = 0;
    cin >> n;
    int a[n];
    for( int i = 0 ; i < n ; i++ ) cin >> a[i];
    sort( a , a + n );
    
    for( int i = 0 ; i < n ; i++){
            int c = 1;
            if ( i == n - 1 && a[i] != c ) {
                   x += c; break; }
            else {
                for (int j = i + 1; j < n; j++){
                    if ( a[j] == a[i] ){
                        c++;
                        if( j == n-1 ) {
                            if ( a[i] > c ) x += c;
                            if ( a[i] < c ) x += c - a[i];
                            i = j;
                            break;
                        }
                    }
                    else {
                        if ( a[i] > c ) x += c;
                        if ( a[i] < c ) x += c - a[i];
                        i = j-1;
                        break;
                    }
                }
            }
    }
    cout << x;
}


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

int main(){
    int n,num,tmp,flag = 1,count = 0;
    cin >> n;
    
    vector<int> num_box;
    for(int i = 0; i < n; i++){
        cin >> num;
        num_box.push_back(num);
    }
    
    while(flag){
        flag = 0;
        for(int i = n -1; i > 0; i--){
            if(num_box[i] < num_box[i - 1]){
                tmp = num_box[i];
                num_box[i] = num_box[i - 1];
                num_box[i - 1] = tmp;
                flag = 1;
                count++;
            }
        }
    }
    cout << num_box[0];
    for(int i = 1; i < n; i++){
        cout <<' ' << num_box[i];
    }
    cout << endl << count << endl;
    
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> P;
constexpr ll mod = 1000000007;
int main() {
	char s[4];
	cin >> s;
	if (s[0] == s[1] && s[2] == s[3] && s[1] == s[2])
		cout << "No";
	else if (s[0] == s[1] && s[2] == s[3])
		cout << "Yes";
	else if (s[0] == s[2] && s[1] == s[3])
		cout << "Yes";
	else if (s[0] == s[3] && s[1] == s[2])
		cout << "Yes";
	else
		cout << "No";
}

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

using namespace std;

map < string, int > cnt;

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, mx = -1;
    cin >> n;
    string s;
    for (int i = 1; i <= n; ++i) {
        cin >> s;
        cnt[s]++;
    }
    set < string > ans;
    for (auto key : cnt) {
        if (key.second == mx) ans.insert(key.first);
        else if (key.second > mx) {
            mx = key.second, ans = {};
            ans.insert(key.first);
        }
    }
    for (auto key : ans) cout << key << '\n';
    return 0;
}



Measured memory_bytes: 33280
n=int(input())
pr=list(map(int,input().split()))
rate_color=[]
suge=0
for i in range(n):
    if pr[i]>=3200:
        suge+=1
pr=[x for x in pr if x<=3199]

def cl(x):
    if x<=399:
        return [0]
    elif 400<=x<=799:
        return [1]
    elif 800 <=x<=1199:
        return [2]
    elif 1200 <=x<=1599:
        return [3]
    elif 1600<=x<= 1999:
        return [4]
    elif 2000 <=x<=2399:
        return [5]
    elif 2400 <=x<=2799:
        return [6]
    elif 2800 <=x<=3199:
        return [7]

for i in range(len(pr)):
    x=pr[i]
    rate_color+=cl(x)
color=list(set(rate_color))
color_num=len(color)


max_num=color_num+suge
if color_num==0:
    mini_num=1
else:
    mini_num=color_num
print(mini_num,max_num)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
	int i;
	int Case[ 10000 ];
	for(i=0;i<10000;i++){
		scanf("%d",&Case[i]);
		if(Case[i]==0){
			break;
		}
	}
	for(i=0;i<10000;i++){
		if(Case[i]==0){
			break;
		}
		printf("Case %d: %d\n",i+1,Case[i]);
	}
	return 0;
}

Measured memory_bytes: 1784
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]

cnt = 0
for a in A:
    res = 0
    for i in zip(a,B):
        res += i[0] * i[1]
    res += C
    if(res > 0):
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    if(b == 1) {
        cout << 0 << endl;
        return 0;
    }

    int total = a;
    int count = 1;

    while(total < b) {
        total += (a - 1);
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
n=int(input())
s=input()
a=[[0]*n for i in range(n)]
buf=0
for i in range(n):
    for j in range(i+1,n):
        if i==0:
            if s[i]==s[j]:
                a[i][j]=1
            continue
        if s[i]==s[j]:
            a[i][j]=min(j-i,a[i-1][j-1]+1)
            buf=max(buf,a[i][j])
print(buf)

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


int main(void)
{
	long int i, j;
	long int n;
	long int sum;
	long int max;
	long int count;
	
	scanf("%ld", &n);
	
	
	printf("%ld\n", n * (n + 1) / 2 - n);
	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m;
int c[1000010];
struct Num{
	int x,y;
	bool operator <(const Num &rhs)const{
		return y<rhs.y;
	}
}a[1000010],b[1000010];
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)a[i].x=i,scanf("%d",&a[i].y);
	for(register int i=1;i<=n;i++)b[i].x=i,scanf("%d",&b[i].y);
	sort(a+1,a+n+1);sort(b+1,b+n+1);
	for(register int i=1;i<=n;i++)if(a[i].y>b[i].y)return printf("No"),0;
	for(register int i=1;i<n;i++)if(a[i+1].y<=b[i].y)return printf("Yes"),0;
	for(register int i=1;i<=n;i++)c[a[i].x]=b[i].x;
	for(register int i=1;c[i]!=1;i=c[i])m++;
	if(m==n-1)printf("No");
	else printf("Yes");
	return 0;
}

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

using namespace std;

using ll = long long;

struct UnionFind {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;
    vector<int> edge_num;

    UnionFind(int sz) : data(sz, -1), edge_num(sz, 0) {}

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (edge_num[x] + edge_num[y] + 1 > size(x) + size(y)) return false;
            if (data[x] > data[y]) swap(x, y);
            edge_num[x] += edge_num[y] + 1;
            data[x] += data[y];
            data[y] = x;
            edge_num[y] = 0;
        } else {
            if (edge_num[x] < size(x)) {
                edge_num[x]++;
                return true;
            } else {
                return false;
            }
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, H, W;
    cin >> n >> H >> W;
    vector< vector<int> > es;
    for (int i = 0; i < n; i++) {
        int r, c, a;
        cin >> r >> c >> a;
        r--;
        c--;
        c += H;
        es.push_back({a, r, c});
    }
    sort(es.begin(), es.end(), greater<>());

    UnionFind uf(H + W);
    ll ans = 0;
    for (vector<int>& e : es) {
        if (uf.unite(e[1], e[2])) ans += e[0];
    }

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

Measured memory_bytes: 7728
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 2005
#define INF 1000000005
#define INFLL (long long)1e18
#define PI 3.1415926535897
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int x,n;
    cin>>x>>n;
    map<int,int>m;
    REP(i,n){
        int a;
        cin>>a;
        m[a]++;
    }
    int ans=0;
    for(int i=0;;i++){
        if(m[x-i]==0){
            ans=x-i;
            break;
        }
        if(m[x+i]==0){
            ans=x+i;
            break;
        }
    }
    OUT(ans);
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N;
    while (cin >> N, N) {
        vector<int> cnt(26, 0);
        vector<char> ch(N);
        for (int i = 0; i < N; i++) {
            cin >> ch[i];
        }
         
        int mn = -1, mx = 0;
        bool found = 0;        
        for (int i = 0; i < N; i++) {
            int n = ch[i] - 'A';
            cnt[n]++;
            if (mx < cnt[n]) {
                mx = cnt[n];
                mn = n;
            }
                 
            int mx2 = 0;
            for (int j = 0; j < 26; j++) {
                if (j == mn) continue;
                mx2 = max(mx2, cnt[j]);
            }
            if (mx2 + (N - i - 1) < mx) {
                found = 1;
                cout << (char)(mn + 'A') << " " << i + 1 << endl;
                break;
            }
        }
        if (!found) {
            cout << "TIE" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3048