akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	string s;
	int i;
	cin >> s;
	vi a(4);
	for (i = 0; i < 4; i++) {
		a[i] = s[i] - '0';
	}
	vi op(3);
	for (op[0] = 0; op[0] < 2; op[0]++) {
		for (op[1] = 0; op[1] < 2; op[1]++) {
			for (op[2] = 0; op[2] < 2; op[2]++) {
				int ans = a[0];
				for (i = 0; i < 3; i++) {
					if (op[i]) {
						ans += a[i + 1];
					}
					else {
						ans -= a[i + 1];
					}
					if (ans == 7) {
						cout << a[0];
						for (i = 0; i < 3; i++) {
							if (op[i]) {
								cout << "+" << a[i + 1];
							}
							else {
								cout << "-" << a[i + 1];
							}
						}
						cout << "=7" << endl;
						return 0;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 256
from collections import deque

y = [-1,0,1,0]
x = [0,-1,0,1]

def main():

    h,w = 0,0
    c = []

    def check(i,j):
        return 0<=i and i<h and 0<=j and j<w

    def bfs(a,b):
        res = 0
        d = deque()
        d.append([a,b])
        f = [[False]*w for _ in range(h)]
        while len(d):
            i,j = d.popleft()
            if not check(i,j):continue
            if c[i][j]=='#':continue
            if f[i][j]==True:continue
            res += 1
            f[i][j]=True
            for k in range(4):
                d.append([i+y[k],j+x[k]])
        return res

    while True:
        w,h = map(int,input().split())
        if h==0 and w==0:break
        c = []
        for i in range(h):
            c.append(input())
        res = 0
        for i in range(h):
            for j in range(w):
                if c[i][j]=='@':
                    res = bfs(i,j)
        print(res)

if __name__ == '__main__':
    main()




Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
const int zahlen=7400000;
int main(){
    int m,n;
    cin>>m>>n;
    while(m){
        int count=0;
        bool bench[zahlen];
        for(int i=0;i<zahlen;i++) bench[i]=true;
        for(int i=m;count<n;i++){
            if(bench[i]){
                for(int j=i;j<zahlen;j+=i) bench[j]=false;
                count++;
            }
        }
        for(int i=m;;i++){
            if(bench[i]){
                cout<<i<<endl;
                break;
            }
        }
        cin>>m>>n;
    }
    return 0;
}



Measured memory_bytes: 10312
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

int n, maxi;
vector<int> maxim(100001);
vector<int> graph[100001];
map<pair<int, int>, int> color;

void coloring(int from, int now_col, int to){
	if (from != 0){
		color.insert(make_pair(make_pair(from, to), now_col));
	}
	for (int i = 0; i < graph[to].size(); i++){
		coloring(to, (now_col+i)%maxi+1, graph[to][i]);
	}
}



int main(){
	cin >> n;
	vector<int> a(n-1), b(n-1);
	for (int i = 0; i < n-1; i++){
		cin >> a[i] >> b[i];
		graph[a[i]].push_back(b[i]);
		maxim[a[i]]++;
		maxim[b[i]]++;
		maxi = max(maxi, max(maxim[a[i]], maxim[b[i]]));
	}
	coloring(0, 0, 1);
	cout << maxi << endl;
	for (int i = 0; i < n-1; i++){
		cout << color.at(make_pair(a[i], b[i])) << endl;
	}
	return 0;
}

Measured memory_bytes: 12672
#include <iostream>

using namespace std;

int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if (n>=k){
    cout<<(k*x)+((n-k)*y)<<endl;
    }
    if (n<k){
        cout<<(n*x)<<endl;
    }
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,ans;
  cin>>a>>b;
  ans=a+b;
  if(ans>=24){
    cout<<ans-24<<'\n';
  }
  else{
    cout<<ans<<'\n';
  }
  return(0);
}


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

int main() {
    long long int n, m, ans = 0;
    cin >> n >> m;
    long long int x[m], diff[m];
    for(int i = 0; i < m; i++) cin >> x[i];
    sort(x, x + m);
    for(int i = 1; i < m; i++)  diff[i-1] = x[i] - x[i-1];
    sort(diff, diff + m - 1);
    for(int i = 0; i < m - n; i++) ans += diff[i];

    cout << ans << "\n";

}


Measured memory_bytes: 1792
n = int(input())
lst = [int(x) for x in input().split()]
d1 = {None : -1}
d2 = {None : -1}
for i in range(n // 2):
    if lst[2 * i] in d1:
        d1[lst[2 * i]] += 1
    else:
        d1[lst[2 * i]] = 0 # 登場回数
        
    if lst[2 * i + 1] in d2:
        d2[lst[2 * i + 1]] += 1
    else:
        d2[lst[2 * i + 1]] = 0
        

u1 = sorted(d1.items(), key = lambda x : x[1], reverse = True)
u2 = sorted(d2.items(), key = lambda x : x[1], reverse = True)

MAKE = lambda x : x[1] + 1

if u1[0][0] != u2[0][0]:
    a = MAKE(u1[0]) + MAKE(u2[0])
    print(n - a)
else:
    a1 = MAKE(u1[0]) + MAKE(u2[1])
    a2 = MAKE(u1[1]) + MAKE(u2[0])
    a = max(a1, a2)
    print(n - a)

Measured memory_bytes: 20904
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    string r1,r2,r3,r4;
    for(int i = 0; i < ty-sy; i++){
        r1.push_back('U');
        r2.push_back('D');
    }
    for(int i = 0; i < tx-sx; i++){
        r1.push_back('R');
        r2.push_back('L');
    }
    r3.push_back('L');
    r4.push_back('R');
    for(int i = 0; i < ty-sy+1; i++){
        r3.push_back('U');
        r4.push_back('D');
    }
    for(int i = 0; i < tx-sx+1; i++){
        r3.push_back('R');
        r4.push_back('L');
    }
    r3.push_back('D');
    r4.push_back('U');
    string ans;
    ans = r1+r2+r3+r4;
    cout << ans << endl;
}

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

int main(){
  int A, B;
  int ans;
  cin >> A >> B;
  ans = max(A+B,A-B);
  ans = max(ans, A*B);

  cout << ans << endl; 

  return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    int N;
    int t[100010], x[100010], y[100010];
    cin >> N;
    FOR(i, 1, N+1) cin >> t[i] >> x[i] >> y[i];

    int now = 0, pos_x = 0, pos_y = 0;
    FOR(i, 1, N+1){
        int diff, diff_x, diff_y;
        diff_x = abs(x[i] - pos_x);
        diff_y = abs(y[i] - pos_y);
        diff = diff_x + diff_y;
        if(t[i] - now < diff){
            cout << "No" << endl;
            return 0;
        }else if(t[i] - now > diff){
            if((t[i] - now - diff) % 2 == 1){
                cout << "No" << endl;
                return 0;
            }
        }
        now = t[i];
        pos_x = x[i];
        pos_y = y[i];
    }

    cout << "Yes" << endl;
    return 0;
}

/*****************************************************************************/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 1408
n, k = map(int, input().split())
rslt = 0
for i in range(k, n + 2):
    rslt += (n+1) * n // 2 - (n-i+1) * (n-i) // 2 - i * (i - 1) // 2 + 1
print(rslt % (10**9+7))

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

#define N_MAX 100
#define W_MAX 10000

int dp[W_MAX+1];
int v[N_MAX];
int w[N_MAX];

int main () {
  int N, W;
  cin >> N >> W;
  REP(i,N) cin >> v[i] >> w[i];
  fill(dp, dp + W_MAX + 1, 0);

  REP(i,N) {
    for(int j = 0; j <= W; j++) {
      if(j - w[i] >= 0) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    }
  }
  cout << dp[W] << endl;


  return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
}
	int s=0;
 for(int i=0;i<k;i++){
 	int mi=1001;
 	int q=0;
 	for(int j=0;j<n;j++){
 		if(a[j]<mi){
 			mi=a[j];
 			q=j;
		 }
	}
	s+=mi;
	a[q]=1001;
}
cout<<s;
return 0;
}

Measured memory_bytes: 3616
import collections

N = int(input())
A = collections.deque(list(map(int, input().split())))
A.appendleft(0)
A.append(0)

ac = []
for i in range(N+1):
    ac.append(abs(A[i]-A[i+1]))

travel_sum = sum(ac)
for i in range(N):
    # 訪れるのを取りやめた観光スポットの前後の移動金額を合計から引く
    ans = travel_sum-(ac[i]+ac[i+1])

    # 取りやめたことで発生する移動金額を加算する
    ans += abs(A[i]-A[i+2])
    print(ans)


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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int N;
bool flag;
int a[10];

void dfs(int idx, int l, int r) {
   if (idx == 10) {
      flag = true;
      return;
   }

   int val = a[idx];
   if (l < val) dfs(idx+1, val, r);
   if (r < val) dfs(idx+1, l, val);
}

int main() {
   int N;
   cin >> N;
   while (N--) {
      for (int i = 0; i < 10; i++) cin >> a[i];
      flag = false;
      dfs(0, -1, -1);
      puts(flag ? "YES" : "NO");
   }
   return 0;
}


Measured memory_bytes: 3080
//merge ha bubble (stable sort)
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define per(i, n) for(i=(n);i>0;i--)
#define repx(i, n, x) for(i=(x);i<(n);i++)
#define xper(i, n, x) for(i=(n);i>(x);i--)
#define pback push_back

//c++def
using namespace std;
typedef long long int ll;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
ll merge(int *a, int left, int mid, int right){
	ll cnt=0;
	int i;
	int j;
	int k;
	int n1=mid-left;
	int n2=right-mid;
	vector<int> L;
	vector<int> R;
	rep(i, n1) L.pback(a[left+i]);
	rep(i, n2) R.pback(a[mid+i]);
	L[n1] = 2e9;
	R[n2] = 2e9;
	for(i=0, j=0, k=left;k<right;k++){
		if(L[i]<=R[j]){
			a[k] = L[i];
			i++;
		}else{
			a[k] = R[j];
			j++;
			cnt += n1 - i;//mid-left-i == try_bubble_swap (ex. 5 2 1 is 1+1(merge swap)=2(bubble swap 1))
		}
	}
	return cnt;
}

ll mergesort(int *a, int left, int right){
	ll a1=0, a2=0, a3=0;
	if(left+1<right){
		int mid = (left+right)/2;
		a1 = mergesort(a, left, mid); //bunkatsu(recursion)
		a2 = mergesort(a, mid, right);
		a3 = merge(a, left, mid, right);
	}
	return a1+a2+a3;
}

int main(){
	int i;
	int n;
	cin >> n;
	int a[n];
	rep(i, n) scanf("%d",&a[i]);
	ll cnt = mergesort(a, 0, n);
	printf("%lld\n", cnt);
}



Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if ((c + b - 1) / b <= (a + d - 1)/d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    

  return 0;
}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main(void)
{
    int a, b, n;
    int x, y;
    while (1)
    {
        cin >> a >> b;
        if (!a && !b) break;
        int dp[16][16] = {{}};
        cin >> n;
        for (int i = 0; i < n; i++)
        {
            cin >> x >> y;
            dp[x - 1][y - 1] = -1;
        }
        if (!dp[0][0]) dp[0][0] = 1;
        for (x = 1; x < a; x++) dp[x][0] = ((dp[x - 1][0] == -1 || dp[x][0] == -1) ? -1 : 1);
        for (y = 1; y < b; y++) dp[0][y] = ((dp[0][y - 1] == -1 || dp[0][y] == -1) ? -1 : 1);
        for (x = 1; x < a; x++)
        {
            for (y = 1; y < b; y++)
            {
                if (dp[x][y]) continue;
                if (dp[x - 1][y] != -1) dp[x][y] += dp[x - 1][y];
                if (dp[x][y - 1] != -1) dp[x][y] += dp[x][y - 1];
            }
        }
        cout << ( (dp[a - 1][b - 1] > 0) ? dp[a - 1][b - 1] : 0) << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

func main() {
	fmt.Printf("%d\n", resolve(parseProblem(os.Stdin)))
}

const modulo = 998244353

func parseProblem(r io.Reader) (int, int, int) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	n, m, k := scanInt(sc), scanInt(sc), scanInt(sc)
	return n, m, k
}

func resolve(n, m, k int) int {
	moduloCombiInit(modulo)
	result := 0
	for i := 0; i <= k; i++ {
		result = moduloAdd(
			result,
			moduloMul(
				moduloMul(m, moduloCombi(n-1, i, modulo), modulo),
				moduloPow(m-1, n-1-i, modulo),
				modulo,
			),
			modulo,
		)
		// fmt.Printf("%d, %d, %d, %d¥n", i, p, cp, result)
		// fmt.Printf("%d, %d, %d, %d, %d¥n", i, p, cp, com, result)
	}
	return result
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func moduloAdd(a, b, modulo int) int {
	result := a%modulo + b%modulo
	if result < 0 {
		result += modulo
	}
	return result % modulo
}

func moduloSub(a, b, modulo int) int {
	result := a%modulo - b%modulo
	if result < 0 {
		result += modulo
	}
	return result % modulo
}

func moduloMul(a, b, modulo int) int {
	return a % modulo * b % modulo
}

func moduloDiv(a, b, modulo int) int {
	return a % moduloInv(b, modulo) % modulo
}

func moduloInv(a, modulo int) int {
	b := modulo
	u, v := 1, 0
	for b > 0 {
		t := a / b
		a, b = b, a-t*b
		u, v = v, u-t*v
	}
	u %= modulo
	if u < 0 {
		u += modulo
	}
	return u
}

func moduloPow(a, b, modulo int) int {
	if a == 1 {
		return 1
	}
	res := 1
	for b > 0 {
		if b&1 == 1 {
			res = res * a % modulo
		}
		a = a * a % modulo
		b >>= 1
	}
	return res
}

const length = 510000

var (
	_fac  = map[int][]int{}
	_finv = map[int][]int{}
	_inv  = map[int][]int{}
)

func moduloCombiInit(modulo int) {
	fac := make([]int, length)
	finv := make([]int, length)
	inv := make([]int, length)

	defer func() {
		_fac[modulo] = fac
		_finv[modulo] = finv
		_inv[modulo] = inv
	}()

	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < length; i++ {
		fac[i] = fac[i-1] * i % modulo
		inv[i] = modulo - inv[modulo%i]*(modulo/i)%modulo
		finv[i] = finv[i-1] * inv[i] % modulo
	}
}

func moduloCombi(n, k, modulo int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return _fac[modulo][n] * (_finv[modulo][k] * _finv[modulo][n-k] % modulo) % modulo
}

func moduloLog(a, b, modulo int) int {
	// log_a(b)
	a %= modulo
	b %= modulo
	m := int(math.Sqrt(float64(modulo)))

	// basy step
	values := map[int]int{}
	val := 1
	for i := 0; i < m+2; i++ {
		if _, ok := values[val]; !ok {
			values[val] = i
		}
		val = moduloMul(val, a, modulo)
	}

	// giant step
	compound := moduloInv(moduloPow(a, m, modulo), modulo)
	val = b
	for i := 0; i < m+2; i++ {
		if l, ok := values[val]; ok {
			return (i*m%modulo + l) % modulo
		}
		val = moduloMul(val, compound, modulo)
	}
	return -1
}


Measured memory_bytes: 14212
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N;
  vector<pair<int, vector<int>>> A(N, {0, vector<int>(N - 1)});
  using std::chrono::system_clock;
  system_clock::time_point start, lap;
  start = system_clock::now();
  for(int i = 0; i < N; ++i)
  {
    for(int number = 0; number < N - 1; ++number)
    {
      int aite; cin >> aite;
      --aite;
      A[i].second[number] = aite;
    }
  }

  int finished{};
  ll res{};
  int MAX_MACTH = N - 1;
  unordered_set<int> matched{};
  while(finished < N)
  {
    for(int i = 0; i < N; ++i)
    {
      lap = system_clock::now();
      auto d = std::chrono::duration_cast<std::chrono::milliseconds>(lap - start).count();
      if (d > 1800) {
        res = N * (N - 1) / 2;
        goto end;
      }
      if(A[i].first == MAX_MACTH)
      {
        continue;
      }
      int aite = A[i].second[A[i].first];
      if(A[aite].first == MAX_MACTH)
      {
        res = -1;
        break;
      }
      if(matched.find(aite) != matched.end())
      {
        continue;
      }
      if(matched.find(i) != matched.end())
      {
        continue;
      }
      int aitenoaite = A[aite].second[A[aite].first];
      if(aitenoaite == i)
      {
        ++A[i].first;
        ++A[aite].first;
        matched.emplace(i);
        matched.emplace(aite);
        if(A[i].first == MAX_MACTH) ++finished;
        if(A[aite].first == MAX_MACTH) ++finished;
      }
      else
      {
        continue;
      }
    }
    if(matched.empty()) res = -1;
    if(res == -1) break;

    matched.clear();
    ++res;
  }

end:
  cout << res << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 6272
#include <stdio.h>
#define N 100000
#define Q 50000

int main(){
  int n, q, i, j, left, right, mid, flag, flag2, num = 0;
  int s[N], t[Q];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &s[i]);
  }
  
  scanf("%d", &q);

  for(i = 0; i < q; i++){
    scanf("%d", &t[i]);
    left = 0;
    right = n;
    while(left < right){
      mid = (left + right) / 2;
      if(s[mid] == t[i]){
	num++;
	break;
      }else if(t[i] < s[mid]){
	right = mid;
      }else{
	left = mid + 1;
      }
    }
  }

  printf("%d\n", num);

  return 0;
}



Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = pow(10, 8);
int main(){
  int n;cin>>n;
  while(n--){
    double ax, ay, bx, by, cx, cy, dx, dy;
    cin>>ax>>ay>>bx>>by>>cx>>cy>>dx>>dy;
    bx-=ax;by-=ay;dx-=cx;dy-=cy;
    if(abs(bx*dy-dx*by)<1e-10)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <atcoder/all>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using namespace atcoder;

using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;

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

int main() {
    int t;
    cin >> t;
    rep (i, t) {
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3668
N, M=map(int, input().split())
mod=10**9+7
pre=-1
hole=[]
for i in range(M):
  a=int(input())
  hole.append(a-1-pre)
  pre=a
hole.append(N-pre)

  

dp=[0]*(N+3)
dp[1]=1
dp[2]=1
for i in range(3,N+3):
  dp[i]=(dp[i-1]+dp[i-2])%mod
if len(hole)==1:
  print(dp[N+1])
  exit()
#print(dp)
#print(hole)
ans=1
for h in hole:
  ans*=dp[h]
  ans%=mod
  
print(ans)


Measured memory_bytes: 7848
#include <bits/stdc++.h>
using namespace std ;
template < class R > inline void Readin( R &K ) {bool F=K=0;char C=getchar();while(C<'0'||C>'9')
{if(C=='-')F=1;C=getchar();}while(C<='9'&&C>='0')K=(K<<1)+(K<<3)+C-'0',C=getchar();if(F)K=-K;}
template < class R > inline bool Checkmax( R &A , R B ) { return A < B ? A = B , 1 : 0 ; }
template < class R > inline bool Checkmin( R &A , R B ) { return A > B ? A = B , 1 : 0 ; }
int N ;
map<long long,int> Map ;
map<long long,int>::iterator It ;
map<long long,long long> Inv ;
inline long long Squ( long long A ) {
	return A * A ;
}
inline void Sim( long long &A ) {
	long long B = 1 , C = 1 ;
	for(register int i = 1 ; ++i <= 2333 ; ) {
		int Times = 0 ;
		while( A % i == 0 ) {
			A /= i ;
			++Times ;
		}
		Times %= 3 ;
		if( Times ) B *= i , C *= i ;
		if( Times == 1 ) C *= i ;
		if( Times == 2 ) B *= i ;
	}
	if( Squ( (long long)sqrt( A ) ) == A )
		C *= (long long)sqrt( A ) ;
	else
		C *= A * A ;
	A = A * B ;
	if( Inv[A] ) assert( Inv[A] == C ) ;
	Inv[A] = C ;
}
int main() {
	Readin( N ) ;
	for(register int i = 0 ; ++i <= N ; ) {
		long long A ;
		Readin( A ) ;
		Sim( A ) ;
		++Map[A] ;
	}
	int Ans = 0 ;
	for( It = Map.begin() ; It != Map.end() ; ++It ) {
		if( It->first == Inv[It->first] ) ++Ans ;
			else if( It->second >= Map[Inv[It->first]] ) {
				Ans += It->second ;
				Map[Inv[It->first]] = 0 ;
			}
	}
	cout << Ans << endl ;
	return 0 ;
}

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


int main() {
  int n ; cin >> n;
  cout << 800*n - 200*(n/15) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define NIL NULL

struct node {
  int key;
  struct node *left;
  struct node *right;
  struct node *parent;
};
struct node *root;

void inorder(struct node *);
void preorder(struct node *);
void insert(int);
struct node *find(int);

int main()
{
  int i, x, n, key;
  char s[10];

  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf("%s", s);
    if(strcmp("insert", s) == 0) {
      scanf("%d", &x);
      insert(x);
    }
    else if(strcmp("print", s) == 0) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(strcmp("find", s) == 0) {
      scanf("%d", &key);
      if(find(key) != NIL)
	printf("yes\n");
      else
	printf("no\n");
    }
  }
  return 0;
}

void inorder(struct node *T)
{
  if(T != NIL) {
    if(T->left != NIL)
      inorder(T->left);
    printf(" %d", T->key);
    if(T->right != NIL)
      inorder(T->right);
  }
}

void preorder(struct node *T)
{
  printf(" %d", T->key);
  if(T != NIL) {
    if(T->left != NIL)
      preorder(T->left);
    if(T->right != NIL)
      preorder(T->right);
  }
}

void insert(int key)
{
  struct node *y = NIL;
  struct node *x = root;
  struct node *z;

  z = (struct node *)malloc(sizeof(struct node));
  z->key = key;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL) {
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;
  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

struct node *find(int key)
{
  struct node *x = root;
  while(x != NIL && key != x->key) {
    if(key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  return x;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define quick                    \
    ios::sync_with_stdio(false); \
    cin.tie(0);
#define time cerr << (0.1 * clock()) / CLOCKS_PER_SEC << endl;
#define mod 1000000007
typedef long long ll;
typedef pair<ll, ll> pl;
#define forn(n) for (ll i = 0; i < ll(n); i++)

// Linear Seive
vector<ll> Linearseive(ll n) {
    vector<bool> v(n + 1, true);
    vector<ll> primes;
    for (ll i = 2; i <= n; i++) {
        if (v[i]) {
            primes.pb(i);
        }
        for (int j = 0; j < primes.size() && i * primes[j] <= n; j++) {
            v[i * primes[j]] = false;

            if (i % primes[j] == 0) {
                break;
            }
        }
    }
    return primes;
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> v(n);
    vector<bool> visited(1e6 + 5);
    ll gd = 0;
    forn(n) {
        cin >> v[i];
        gd = __gcd(gd, v[i]);
    }
    if (gd > 1) {
        cout << "not coprime" << '\n';
        return;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 2; j * j <= v[i]; ++j) {
            if (v[i] % j == 0) {
                if (visited[j]) {
                    cout << "setwise coprime" << '\n';
                    return;
                }
                while (v[i] % j == 0) {
                    v[i] /= j;
                }
                visited[j] = true;
            }
        }
        if (v[i] > 1) {
            if (visited[v[i]]) {
                cout << "setwise coprime" << '\n';
                return;
            }
            visited[v[i]] = true;
        }
    }
    cout << "pairwise coprime" << '\n';
}

int main() {
    quick;
    solve();
    // ll t;
    // cin >> t;
    // while (t--) {
    //     solve();
    // }
}

Measured memory_bytes: 11340
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	m := make(map[int]int)
	for i := 0; i < n; i++ {
		m[nextInt()]++
	}

	ans := 0
	for _, v := range m {
		if v%2 == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}

func next() string {
	scanner.Scan()
	return scanner.Text()
}
func nextInt() int {
	i, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 7296
#include<stdio.h>
int main(){
    int a, b;
    int r = 0;
    scanf("%d %d",&a, &b);
    if(((a * b) % 2) == 1){
        r = 1;
        printf("%s\n", "Odd");
    }
    else printf("%s\n", "Even");
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi w(n);
    int sum=0;
    rep(i,n){
        cin>>w[i];
        sum+=w[i];
    }
    int ans = 1e9;
    rep(i,n+1){
        int a=0,b=0;
        rep(j,i) a+=w[j];
        chmin(ans,abs(a-(sum-a)));
    }
    cout<<ans<<endl;
    return 0;
}


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

N = int(input())
S = [input()[:-1] for _ in range(N)]
rl1, rl2 = [], []

for Si in S:
    l, r = 0, 0
    
    for i in range(len(Si)):
        if Si[i]=='(':
            l += 1
        else:
            if l==0:
                r += 1
            else:
                l -= 1
    
    if l-r>=0:
        rl1.append((r, l))
    else:
        rl2.append((r, l))
    
rl1.sort(key=lambda t: t[0])
rl2.sort(key=lambda t: t[1], reverse=True)
rl3 = rl1+rl2
bal = 0

for r, l in rl3:
    bal -= r
    
    if bal<0:
        print('No')
        exit()
    
    bal += l

if bal==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 206860
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

string res = "No";

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

    int X, Y;
    cin >> X >> Y;
    int B = (Y - (2 * X)) / 2;
    int A = X - B;
  // cout << A << B << endl;
    if (A + B == X && 2 * A + 4 * B == Y && 0 <= A && 0 <=B)
    {
        res = "Yes";
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3684
/****************** UTTAM_SINGH ******************/


#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define integer int
#define int long long
#define w(x) int x;cin>>x;while(x--)
#define what_is(x) cerr<<#x<<"="<<x<<endl;
#define fo(i,b)for(int i=0;i<b;i++)
#define mod 998244353

void kick2309()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
//global variables and fintion goes here
const int N = 10000007;
int A[N];



int32_t main()
{

	kick2309();
	//w(t)

	{
		int n;
		cin >> n;
		int ans;
		if (n % 1000 == 0)
		{
			cout << 0;
		}
		else cout << 1000 - n % 1000;
	}

#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}


Measured memory_bytes: 3636
n, x, m = map(int, input().split())
s = x
a = x
note = [0] * m
note[a] += 1
seq = []
for i in range(n-1):
    seq.append(a)
    a = a**2 % m
    if note[a] > 0:
        ind = seq.index(a)
        l = len(seq[ind:])
        n -= len(seq[:ind])
        syo, r = divmod(n, l)
        s = s + sum(seq[ind:]) * (syo-1)
        if r != 0:
            for j in range(ind, ind+r):
                s += seq[j]
        print(s)
        exit()
    if a == 0:
        print(s)
        exit()
    note[a] += 1
    s += a
print(s)


Measured memory_bytes: 12172
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

string s;
int n;
VVi dp;
Vi memo;

void init()
{
	cin >> s;
	n = SZ(s);
	dp.resize(n + 1, Vi(13, 0));
	dp[0][0] = 1;
	reverse(ALL(s));

	memo.resize(n);
	memo[0] = 1;
	REP1O(i, n)
	{
		memo[i] = memo[i - 1] * 10 % 13;
		if (memo[i] == 0) memo[i] = 13;
	}
}

inline int summod(int a, int b) { a += b; return (a > MOD) ? a - MOD : a; }
inline ll summod(ll a, ll b) { a += b; return (a > MOD) ? a - MOD : a; }

int main()
{
	init();

	REP(i, n)
	{
		if (s[i] != '?')
		{
			REP(j, 13)
			{
				int d = (s[i] - '0');
				int r = d * memo[i] % 13;
				dp[i + 1][(j + r) % 13] = summod(dp[i + 1][(j + r) % 13], dp[i][j]);
			}
		}
		else
		{
			REP(d, 10)
			{
				int r = d * memo[i] % 13;
				REP(j, 13)
					dp[i + 1][(j + r) % 13] = summod(dp[i + 1][(j + r) % 13], dp[i][j]);
			}
		}

	}

	cout << dp[n][5] << endl;
}


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

const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int p, q, r;
   cin >> p >> q >> r;
   int ans = p + q + r - max({p, q, r});
   cout << ans << endl;
   return 0;
}

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

int main()
{
	int l;
	cin >> l;
	printf("%.12lf\n", l*l*l/27.0);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c;
    if(a<=b&&c<=b) d=b;
    else if(b<=c&&a<=c) d=c;
    else d=a;
    cout<<a+b+c-d;
    return 0;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<tuple>
#include<queue>
#include<functional>
#define llint long long int
#define lldo long double
#define fir first
#define sec second
#define pub push_back
#define mp make_pair
#define mt make_tuple
#define res resize
const llint big=5e15;
const lldo pai=3.141592653589793238462643383279502884197;
void maxeq(int &a,int b){if(a<b){a=b;}}
bool mineq(llint &a,llint b){if(a>b){a=b;return true;}return false;}
using namespace std;
int solve(void){
	string xy;int d,L;cin>>xy>>d>>L;
	L*=1e5;
	int men;//??¢
	if(xy=="BC"){men=3;}
	else if(xy=="CD"){men=1;}
	else{men=2;}
	lldo zx=0,zy=0;//??§?¨?
	lldo kak=pai*5.0/3- d*pai/180.0;
	const lldo rot=sqrt((lldo)3.0);
	while(L--){
		zx+=1e-5*cos(kak);
		zy+=1e-5*sin(kak);
		if(zy<-rot/2.0){//???
			if(men==0){men=1;zx=-zx;zy=-rot-zy;kak+=pai;}
			else if(men==1){men=0;zx=-zx;zy=-rot-zy;kak+=pai;}
			else if(men==2){
				men=0;zx=0.25+zx/2;zy=-zx*rot;
				kak-=pai/3;
			}
			else if(men==3){
				men=0;zx=-0.25+zx/2;zy=zx*rot;
				kak+=pai/3;
			}
		}
		else if(zx/-zy<-rot/3.0){//??????
			if(men==0){
				men=3;
				kak-=pai/3;
				zy=-rot/2;
				zx=zx*2+0.5;
			}else{
				if(men==3){men=1;}
				else{men++;}
				kak+=pai/3;
				zx=-zx;
			}
		}
		else if(zx/-zy>rot/3.0){
			if(men==0){
				men=2;
				kak+=pai/3;
				zy=-rot/2;
				zx=zx*2-0.5;
			}else{
				if(men==1){men=3;}
				else{men--;}
				kak-=pai/3;
				zx=-zx;
			}
		}
	}
	return men;
}
int main(void){
	if(solve()==solve()){cout<<"YES"<<endl;}
	else{cout<<"NO"<<endl;}
	return 0;
}

Measured memory_bytes: 3492
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, q;
  string s;

  cin >> n >> q >> s;

  int sum[SIZE] = {};

  for(int i=0;i<n-1;i++){
    sum[i+1] = (s[i] == 'A' && s[i+1] == 'C') + sum[i];
  }

  for(int i=0;i<q;i++){
    int l, r;

    cin >> l >> r;

    r--;

    cout << sum[r] - sum[l-1] << endl;
  }

  return 0;
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S[2] == S[3] && S[4] == S[5]) cout << YES << endl;
    else cout << NO << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
     
using namespace std;
using namespace __gnu_pbds;
     
     
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define resz resize
#define ini ll_MAX
#define inl LLONG_MAX
#define MOD 1000000007
#define sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORR(i, a, b) for (ll i = a; i >= (b); i--)
#define F0RR(i, a) for (ll i = a; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define pbds tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
     
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
     
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
     
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using vpdd = vector<pdd>;
using vvpdd = vector<vpdd>;
     
ll mod(ll a,ll b)
{
    return (b+a%b)%b;
}
     
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll po(ll a,ll b)
{
    ll ans = 1;
    while(b--)
        ans*=a;
    return ans;
}
ll pom(ll a,ll b,ll mod)
{
    if(b==0)return 1;
    ll k = pom(a,b/2,mod);
    if(b%2==0)return (k*k)%mod;
    else return ((k*k)*mod*a)%mod;
}
     
ll sqdist(ll a,ll b,ll c,ll d)
{
    return (a-c)*(a-c)+(b-d)*(b-d);
}
ll fact(ll n)
{
    if(n==0)return 1;
    ll ans = 1;
    FOR(i,1,n+1)ans*=i;
    return ans;
}

ll n,k,p;
ll visited[100];
vll vec[100];
void dfs(ll k)
{
    visited[k]++;
    p++;
    FOR(i,0,vec[k].size())
    {
        if(!visited[vec[k][i]])
            dfs(vec[k][i]);
    }
}


     
void solve()
{
    int n,k,s;
    cin>>n>>k>>s;
    int p = 1000000000;
    if(s!=p)
    {
        FOR(i,0,k)cout<<s<<' ';
        FOR(i,k,n)cout<<p<<' ';
    }
    else
    {
        FOR(i,0,k)cout<<p<<' ';
        FOR(i,k,n)cout<<1<<' ';
    }
}
     
     
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    solve();
}

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

int main() {
    long long N, K, ave, max, ans;
    cin >> N >> K;
    vector<int>A(N);
    ave = 0;
    max = 0;
    for (long long i = 0; i < N; i++) {
        cin >> A[i];
        //ave += A[i];
        if (A[i] > max) {
            max = A[i];
        }
    }
    //ave = ceil(ave/(N+K));
    //long long l = ave;
    long long l = 0;
    long long r = max;
    long long sum = 0;
    long long mid;

    while (r - l > 1) {
        mid = l + (r - l) / 2;
        sum = 0;
        for (auto next : A) {
            sum += ceil((double)next/mid) - 1;
        }
        //cout << mid << ',' << sum << endl;
        if (sum <= K) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << r << endl;
 
    
}



Measured memory_bytes: 3920
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	private Scanner sc;

	private int[] lp;
	private int[] g = {200, 300, 500};
	private int[] price = {380, 550, 850};
	private int[] set = {5, 4, 3};
	
	private double[] off = {0.8, 0.85, 0.88};
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		String line = sc.nextLine();
		
		lp = new int[50];
		for (int i = 0; i < lp.length; i++) {
			lp[i] = -1;
		}
		
		while (line.equals("0") == false) {
			int total = Integer.parseInt(line);
			
			System.out.println(search(total));
			
			line = sc.nextLine();
		}
	}
	
	public int search(int total) {
		if (total < 0) return -1;
		if (total == 0) return 0;

		if (lp[total / 100 - 1] != -1) return lp[total / 100 - 1];
		
		int min = -1;
		
		for (int i = 0; i < 3; i++) {
			int tmp = search(total - (g[i] * set[i]));
			if (tmp != -1) {
				tmp = tmp + (int)(price[i] * set[i] * off[i]);
				if ((min == -1) || (min > tmp)) min = tmp;
			}

			tmp = search(total - (g[i]));
			if (tmp != -1) {
				tmp = tmp + price[i];
				if ((min == -1) || (min > tmp)) min = tmp;
			}
		}

		if (min != -1) lp[total / 100 - 1] = min;
		return min;
	}
}

Measured memory_bytes: 26128
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

using namespace std;

typedef long long LL;

int n, m, k;

int q;

int main() {

    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << "No";
    else if (a == b || a == c || b == c) cout << "Yes";
    else cout << "No";
    
}

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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());

    auto check = [&](auto mid){
        int64_t res = 0;
        for (auto &a: A)
            res += ceil(a / mid) - 1;
        return res <= k;
    };

    double l = 0, r = 1e10;
    for (int i = 0; i < 100; i++){
        auto mid = (l + r) / 2;
        (check(mid) ? r : l) = mid;
    }

    cout << int(ceil(r)) << endl;
}


Measured memory_bytes: 4060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String u = sc.next();
		
		if(s.equals(u)) {
			a--;
		}
		else {
			b--;
		}
		
		System.out.println(a+" "+b);
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
  //ビンゴカードのデータを取得
  vector<int> card(9);
  for(int i=0; i < 9; i++){
    cin >> card[i];
  }
  
  //ビンゴの読まれた番号を取得
  int N;
  cin >> N;
  vector<int> numbers(N);
  for(int i=0; i < N; i++){
    cin >> numbers[i];
  }
  
  vector<int> hole(9);
  for(int k=0; k < N; k++){
  for(int h=0; h < 9; h++){
    if(numbers[k]==card[h]){
      hole[h]=1; 
    }
  }
  }
  
  int bingo=0;
  //横
  for(int h=0; h < 3; h++){
    if(0 < hole[3*h]*hole[3*h+1]*hole[3*h+2]){
      bingo=1; 
    }
  }
  //縦
  for(int v=0; v < 3; v++){
    if(0 < hole[v]*hole[v+3]*hole[v+6]){
      bingo=1; 
    }
  }
  //斜め
  if(hole[0]*hole[4]*hole[8]>0){
    bingo=1;
  }
  if(hole[2]*hole[4]*hole[6]>0){
    bingo=1;
  }
  
  if(bingo == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  /*for(int h=0; h < 9; h++){
    cout << hole[h];
    if(h%3 == 2)
      cout << endl;
  }*/
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a + b == 15)
        cout << "+" << endl;
    else if (a * b == 15)
        cout << "*" << endl;
    else
        cout << "x" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110000];
main(){
    ll n;
    cin>>n;
    rep(i,0,n)cin>>a[i];
    ll ans=1;
    rep(i,0,n){
        if(a[i]%2==1)ans*=0;
    }
    if(ans==0)cout<<"first";
    else cout<<"second";
}

Measured memory_bytes: 1024