akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
  int a,b;
  cin>>a>>b;
  if(a>=10||b>=10){
    cout<<-1<<endl;
  }
  else{
    cout<<a*b<<endl;
  }
}


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

using namespace std;

const int MAXN = 3e5 + 10;

int n, a[MAXN];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < 3*n; i++)	cin >> a[i];
	sort(a, a + 3*n);
	long long ans = 0;
	int cur = 3*n-2;
	for (int i = 0; i < n; i++){
		ans += a[cur];
		cur -= 2;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll N, M, V, P; cin >> N >> M >> V >> P;
  ll A[N]; rep(i,N) cin >> A[i]; sort(A,A+N);
  ll l = 0; while (A[N-P]-A[l]>M) l++;
  ll r = (N-1) - P; r = max(l,r);
  while(l!=r) {
    ll mid = (l+r)/2;
    ll num = 0;
    rep(i,N-(P-1)) {
      num += M - max((ll)0,A[i]-A[mid]);
    }
    // cout << mid << " " << num << endl;
    if (num>=(V-(P-1))*M) r = mid;
    else l = mid+1;
  }
  ll result = N - l;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] S = scanner.next().toCharArray();
    int[] res = new int[S.length];
    for (int i = 0; i < S.length;) {
      int rs = 0;
      while (S[i] == 'R') {
        i++;
        rs++;
      }
      int p = i - 1;
      int ls = 0;
      while (i < S.length && S[i] == 'L') {
        i++;
        ls++;
      }
      res[p] += (rs - rs / 2) + ls / 2;
      res[p + 1] = rs / 2 + (ls - ls / 2);
    }
    StringBuilder sb = new StringBuilder();
    for (int r : res) sb.append(r).append(' ');
    sb.setLength(sb.length() - 1);
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 28404
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] A = new int[n];
		String ans = "";
		for(int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}
		int a = partition(A, 0, n-1);
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++) {
			if(i != a) {
				sb.append(A[i]);
			}else {
				sb.append("[");
				sb.append(A[i]);
				sb.append("]");
			}
			if(i != n-1) {
				sb.append(" ");
			}else {
				ans = sb.toString();
			}
		}
		System.out.println(ans);
		sc.close();
	}
	int partition(int[] A, int p, int r) {
		int x = A[r];
		int i = p - 1;
		for(int j = p; j < r; j++) {
			if(A[j] <= x) {
				i++;
				int tmp = A[i];
				A[i] = A[j];
				A[j] = tmp;				
			}
		}
		int tmp2 = A[i+1];
		A[i+1] = A[r];
		A[r] = tmp2;
		return i + 1;
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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


Measured memory_bytes: 67672
unittest
{
	assert( [ "2 3 1", "1 1", "1 2", "2 2", "1 2" ].solve == "3" );
	assert( [ "10 3 2", "1 5", "2 8", "7 10", "1 7", "3 10" ].solve == "1\n1" );
	assert( [ "10 10 10", "1 6", "2 9", "4 5", "4 7", "4 7", "5 8", "6 6", "6 7", "7 9", "10 10", "1 8", "1 9", "1 10", "2 8", "2 9", "2 10", "3 8", "3 9", "3 10", "1 10" ].solve == "7\n9\n10\n6\n8\n9\n6\n7\n8\n10" );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	auto q = 0L;
	input.front.formattedRead!"%s %s %s"( n, m, q );
	auto lrs = new long[ 2 ][ m ];
	foreach( ref lr; lrs )
	{
		input.popFront;
		lr = input.front.split.to!( long[] );
	}
	auto pqs = new long[ 2 ][ q ];
	foreach( ref pq; pqs )
	{
		input.popFront;
		pq = input.front.split.to!( long[] );
	}
	
	// 区間の二次元累積和表を作成
	auto tss = new long[][]( 1 + n + 1, 1 + n + 1 );
	foreach( lr; lrs )
	{
		tss[ lr[ 0 ] ][ lr[ 1 ] ]++;
	}
	foreach( i; 0L .. tss.length.signed - 1 )
	{
		foreach( j; 0L .. tss.length.signed - 1 )
		{
			tss[ i + 1 ][ j ] += tss[ i ][ j ];
			tss[ i ][ j + 1 ] += tss[ i ][ j ];
			tss[ i + 1 ][ j + 1 ] -= tss[ i ][ j ];
		}
	}
	
	// 二次元累積和表からクエリの答えを取得
	auto anss = new long[ pqs.length ];
	foreach( ref ans, pq; lockstep( anss, pqs ) )
	{
		ans += tss[ pq[ 1 ] ][ pq[ 1 ] ] - tss[ pq[ 1 ] ][ pq[ 0 ] - 1 ] - tss[ pq[ 0 ] - 1 ][ pq[ 1 ] ] + tss[ pq[ 0 ] - 1 ][ pq[ 0 ] - 1 ];
	}
	return anss.to!( string[] ).join( "\n" );
}


Measured memory_bytes: 14416
#エラトステネスの篩
MAX = 101010
#iが素数だったら1(True)を、合成数であったら0(False)を返す配列を作ればよい
is_prime = [1]*MAX #最初は1(True)を入れておく
is_prime[0] = 0
is_prime[1] = 0 #[0]と[1]は当然非素数
for i in range(2,MAX):
    if is_prime[i] == 0:#もしもiが素数じゃなかったら
        continue #次の操作は行わず次のiの判定へ
    for j in range(i*2, MAX, i): #iが素数なら2i,3i,...は⇒
        is_prime[j] = 0 #合成数

#入力の受け取り
Q = int(input())
l = []
r = []
for i in range(Q):
    L,R=map(int,input().split())
    l.append(L)
    r.append(R)

#2017-like かどうか
MAX = 101010
a=[0]*MAX
for i in range(MAX+1):
    if i%2 == 0:
        continue
    elif is_prime[i] and is_prime[(i+1)//2]:#2017-likeならば⇒
        a[i] = 1 #配列a[i]を１（True）に書き換える

#累積和
s = [0]*(MAX+1)
for i in range(MAX):
    s[i+1] = s[i] + a[i]

#クエリ処理
for i in range(Q):
    print(s[r[i] + 1] - s[l[i]])


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    if(b == 0) return a;
    return gcd(b, a %b);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    ll a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    ll ans = a[0];
    for(int i=1;i<n;i++){
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;
}

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

//カードの変数を２つ用意
//各々バブル。選択ソートでソート。
//各々の答えを引っ張ってきて、同じであれば安定、違うなら不安定
//ソートはアルファベットも同様にソートする
struct Card{char suit,value;};

void bubbleSort(struct Card C1[],int n){//バブルソート

	int flag = 1;

	for(int i=0;flag;i++){//flagがtrueのときに動くsはソートし終わった文字数を表している
		flag = 0;

		for(int j = n-1;i<j;j--){//数列の一番最後の数字からだんだん下がっていく
			if(C1[j].value < C1[j-1].value){		//iより小さいとソートは終わってる
				swap(C1[j],C1[j-1]);//ソート中の数字より一個前の数字が小さければ交換
				flag = 1;
			}
		}
	}
}

void SelectionSort(struct Card C2[],int n){
	for(int i = 0;i < n;i++){
		int minj = i;

		//iより後でA[i]よりもっとも小さい値の添字を求める
		for(int j = i; j < n;j++){
			if(C2[j].value < C2[minj].value) minj = j;
		}

		if(i != minj) swap(C2[i],C2[minj]);
	}
}

bool isstable(struct Card C1[],struct Card C2[],int n){
	for(int i = 0;i<n;i++){
		if(C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main(){
	Card C1[100],C2[100]; 
	int n;
	char ch;
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> C1[i].suit >> C1[i].value;
		C2[i] = C1[i];
	}

	//for(int i = 0;i < n;i++)C2[i] = C1[i];

	bubbleSort(C1,n);
	SelectionSort(C2,n);

	//bubbleSort
	for(int i = 0;i < n;i++){
		if(i)cout << " ";
		cout << C1[i].suit << C1[i].value;
	}
	cout << endl;
	cout << "Stable" << endl;

	//SelectionSort
	for(int i = 0;i < n;i++){
		if(i)cout << " ";
		cout << C2[i].suit << C2[i].value;
	}

	cout << endl;

	if(isstable(C1,C2,n)){
		cout << "Stable" <<endl;
	}else{
		cout << "Not stable" <<endl;
	}

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  int non = 100;
  
  for(int i = 0; i < n; i++){//nこの数だけループ
    int a;
    cin >> a;
    while(a %2 == 0){
        a /= 2;
        ans++;
    }
    if(ans < non){
        non = ans;
    }
    ans = 0;
  }
  cout << non << endl;



}



Measured memory_bytes: 3548
"use strict"
function main(arg) {
    let data = arg.trim().split("\n")
    const S = data[0]
    const T = data[1]
    if (T.slice(0, S.length) === S) {
        console.log('Yes')
    } else {
        console.log('No')
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29576
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int Mod = 1e9 + 7;
LL x, y;

LL qwe(LL a, LL n) { //快速幂
    LL res = 1LL;
    while(n) {
        if(n & 1) res = res * a % Mod;
        a = a * a % Mod;
        n >>= 1LL;
    }
    return res % Mod;
}

LL inv(LL x) { //逆元
	return qwe(x, Mod - 2) % Mod;
}

LL C(LL n, LL m) { //组合数
	LL res = 1LL;
	for(LL i = 1, j = n; i <= m; i++, j--) {
		res = res * j % Mod;
		res = res * inv(i) % Mod;
	}
	return res % Mod;
}

int main() {
	cin >> x >> y;
	LL a = x - (x + y) / 3LL;
	LL b = y - (x + y) / 3LL;
	if((x + y) % 3) puts("0");
	else {
      if(a >= 0) cout << C(a + b, a) << endl;
      else puts("0");
    }
	return 0;
}

/*
设"右1下2"进行了a次, "下1右2"转移b次
题意转化为: 有a个1与b个0进行组合, 可以制造出多少不同的串
=> ans = C(a + b, a) = C(a + b, b)
*/

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# abc127/abc127_d
import sys
from operator import itemgetter

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))


def main():
    N, M = i2nn()
    A = [(1, x) for x in i2nn()]
    BC = [0] * M
    for j in range(M):
        BC[j] = tuple(i2nn())
    BC.extend(A)
    ABC = sorted(BC, key=itemgetter(1))
    sum = 0
    poped = ABC.pop()
    while N - poped[0] > 0:
        sum += poped[0] * poped[1]
        N -= poped[0]
        poped = ABC.pop()
    sum += poped[1] * N
    print(sum)
    return

main()


Measured memory_bytes: 33600
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

def solve():
    N, X, M = map(int, input().split())

    if N == 1:
        print(X)
        return

    A = X
    steps = [0] * M
    sms = [0] * M
    steps[A] = 1
    sms[A] = A
    sm = A
    ans = A
    rest = 0
    for i in range(2, N+1):
        A = (A*A) % M
        sm += A
        ans += A
        if steps[A] != 0:
            P = i - steps[A]
            v = sm - sms[A]
            rest = N - i
            ans += v * (rest//P)
            rest %= P
            break
        steps[A] = i
        sms[A] = sm

    for i in range(rest):
        A = (A*A) % M
        ans += A

    print(ans)


solve()


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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    int n;
    cin>>n;
    vector<int> v(3),el(3);
    for(int i=0;i<n;i++){
        cin>>el[0]>>el[1]>>el[2];
        vector<int> d(3);
        for(int j=0;j<3;j++){
            int mx=0;
            for(int k=0;k<3;k++){
                if(k!=j && v[k]>mx)mx=v[k];
            }
            d[j]=el[j]+mx;
        }
        v=d;
    }
    cout<<max({v[0],v[1],v[2]})<<"\n";
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

int main() {
    int n, a = 100000;
    cin >> n;
    for (int i = 0; i < n; i++) {
        a = static_cast<int>(ceil(a * 0.00105)) * 1000;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
 int N,K;
 cin >> N >> K;
 double ans=0;
 double p;
 for (int i=0; i<N; i++){
     p=i+1;
   for(int j=0; j<K; j++){
       if(p<K){
         p=p*2.0;  
       }
       else{
           ans+=((1.0/N)*pow(0.5,j));
           break;
       }
   }
 }
std::cout << std::setprecision(13) << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
//回答が整数の場合
int ans;
//整数値の入力
string n;
cin >> n;

int len=(int)(n.length());
int zero=0;
int ichi=0;
for(int i=0;i<len;i++){
  char z;
  z=n[i];
  if(z=='0'){zero++;}
  if(z=='1'){ichi++;}

}

if(zero>ichi){ans=ichi*2;}
else{ans=zero*2;}

//回答
cout << ans << endl;
return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    
    int K, S;
    cin >> K >> S;
    
    int ans = 0;
    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K; j++){
            int nokori = S - (i + j);
            if(nokori >= 0 && nokori <= K) ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3132
N, P = map(int, input().split())
biscuits = list(map(int, input().split()))
gu = 0
ki = 0
for i in range(N):
    if biscuits[i] % 2 == 0:
        gu += 1
    else:
        ki += 1
if P == 1 and ki == 0:
    print(0)
elif gu == N:
    print(pow(2,N))
else:
    print(pow(2,N-1))

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = Integer.parseInt(sc.nextLine());
		int g = Integer.parseInt(sc.nextLine());

		System.out.println(g * 2 - r);

		sc.close();
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int n;
ll k;
vector<ll> a, f;

bool check(const ll& x){
    ll res = 0;
    for(int i = 0; i < n; ++i){
        res += max(0ll, a[i] - x / f[i]);
    }
    return res <= k;
}

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

    cin >> n >> k;
    a.resize(n);
    f.resize(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    for(int i = 0; i < n; ++i)  cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>());
    
    ll lb = -1, ub = 1e+12;
    while(ub - lb > 1){
        ll mid = (lb + ub) / 2;
        if(check(mid))  ub = mid;
        else    lb = mid;
    }
    cout << ub << endl;
}

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

int main(){
    string S;
    bool flag=true;
    cin >> S;
    sort(begin(S), end(S));
    
    for(int i=1; i<S.size(); i++){
	if(S[i-1] == S[i])
	    flag=false;
    }
    cout <<(flag? "yes": "no")<<endl;
}


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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int c[n],s[n],f[n];
    for(int i=1;i<=n-1;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i=1;i<=n-1;i++){
        int ans=s[i]+c[i];
        for(int j=i+1;j<=n-1;j++){
            ans=max(ans,s[j]);
            while(ans%f[j]!=0){
                ans++;
            }
            ans+=c[j];
        }
        cout<<ans<<endl;
    }
    cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let read_ints () = Scanf.scanf "%d %d\n" (fun x y -> (x, y))

let dfs vs n =
  let d = Array.make n (-1) in
  let rec doit i j =
    d.(i) <- j;
    List.iter (fun v -> if d.(v) = (-1) then doit v j) vs.(i) in
  Array.iteri (fun i e -> if e = (-1) then doit i i) d;
  d

let solve n m =
  let g = Array.make n [] in
  for _ = 0 to m - 1 do
    match read_ints () with
    | (s, t) ->
      g.(s) <- t :: g.(s);
      g.(t) <- s :: g.(t);
  done;
  let v = dfs g n in
  let q = Scanf.scanf "%d\n" (fun i -> i) in
  for _ = 0 to q - 1 do
    match read_ints () with
    | (s, t) -> Printf.printf (if v.(s) = v.(t) then "yes\n" else "no\n")
  done

let () =
  match read_ints () with
  | (n, m) -> solve n m

Measured memory_bytes: 18032
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtC_prac
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[][] XL = new int[N][];
            for (int i = 0; i < N; i++) XL[i] = new int[2];
            for(int i = 0; i < N; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                int tmp1 = int.Parse(str[0]);
                int tmp2 = int.Parse(str[1]);
                XL[i][0] = tmp1-tmp2;
                XL[i][1] = tmp1+tmp2;
            }


            Array.Sort(XL, (a, b) => a[1] - b[1]);
            int ans = 0;
            int Finish = -1000000001;
            // Console.WriteLine(ArraytoString(XL));
            for(int i = 0; i < N; i++)
            {
                if(Finish <= XL[i][0])
                {
                    Finish = XL[i][1];
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
       

        static StringBuilder sb = new StringBuilder(1024);
        public static string ArraytoString<T>(T[][] arr, string sep = ", ", string rowSep = "\n",
    string start_bracket = "[", string end_bracket = "]")
        {
            sb.Length = 0;
            sb.Append(start_bracket);
            for (int i = 0; i < arr.Length; i++)
            {
                if (i > 0)
                {
                    sb.Append(sep);
                    sb.Append(rowSep);
                }

                sb.Append(start_bracket);

                for (int j = 0; j < arr[i].Length; j++)
                {
                    if (j > 0)
                    {
                        sb.Append(sep);
                    }
                    sb.Append(arr[i][j]);
                }
                sb.Append(end_bracket);
            }
            sb.Append(end_bracket);

            return sb.ToString();
        }
        
    }
}



/*
int N = int.Parse(Console.ReadLine());
string[] ABCD = Console.ReadLine().Split(' ');
int A = int.Parse(ABCD[0]); 
int B = int.Parse(ABCD[1]); 
int C = int.Parse(ABCD[2]); 
int D = int.Parse(ABCD[3]); 

string[][] Array = new string[x][];
for (int i = 0; i < x; i++) Array[i] = new string[y];

for(int i = 0; i < R; i++)
{
    for (int j = 0; j < C; j++) Console.Write($"{Visited[i,j]} ");
    Console.WriteLine();
}

*/


Measured memory_bytes: 21824
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int SIZE = 1000050;
long long N, P;
long long div_num[SIZE] = {};

int main(int argc, char **argv) {
    std::cin >> N >> P;
    
    if (N == 1) {
        std::cout << P << std::endl;
        return 0;
    }

    for (int i = 2; i < SIZE; i++) {
        while (P % i == 0) {
            div_num[i]++;
            P = P / i;
        }
    }

    long long ret = 1;
    for (int i = 2; i < SIZE; i++) {
        for (int j = 0; j < div_num[i] / N; j++) {
            ret = ret * i;
        }
    }

    std::cout << ret << std::endl;
    return 0;
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
const int mx=3005,mod=1e9+7;
char s[mx];
void add_self(int& a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}

int main()
{
	int n;
	cin>>n;
	scanf("%s",s) ;
	int dp[n+1][n+1],pref[n+1]={};
	memset(dp,0,sizeof(dp));
	dp[1][1]=1;
	for(int i=2;i<=n;i++)
	{
		for(int k=1;k<=i-1;k++)
		{
			pref[k]=(pref[k-1]+dp[i-1][k])%mod ;
		}
		for(int j=1;j<=i;j++)
		{
			int L,R;
			if(s[i-2]=='<') { L=1;R=j-1; }
			else { L=j,R=i-1; }
			if(L<=R)add_self(dp[i][j],(pref[R]-pref[L-1]+mod)%mod) ;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		add_self(ans,dp[n][i]) ;
	}
	cout<<ans<<"\n";
}

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

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	if(a+b>c+d)
	cout<<"Left";
	else if(a+b<c+d)
	cout<<"Right";
	else
	cout<<"Balanced";
	return 0;
	
}

Measured memory_bytes: 256
#include<iostream>
#define FORI(N) for(int i=0;i<N;i++)
#define FORL(N) for(int l=0;l<N;l++)
using namespace std;

int main()
{
	int n;
	int q;
	int ans=0;
	bool *b;
	b = new bool[1000000000];
	scanf("%d",&n);
	FORI(n)
	{
		int a;
		scanf("%d", &a);
		b[a] = true;
	}
	scanf("%d", &q);
	FORI(q)
	{
		int c;
		scanf("%d", &c);
		if (b[c] == true)
		{
			ans++;
		}

	}
	cout << ans << endl;
	delete[]b;
	return 0;
}

Measured memory_bytes: 3224
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 3910;

//head

int n;
ld dp[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  dp[0] = 1;
  cin >> n;
  rep(i, n) {
    ld p;
    cin >> p;
    for(int j = n; j > 0; j--) {
      dp[j] += dp[j-1] * p;
      dp[j-1] *= (1-p);
    }
  }

  cout << fixed << setprecision(20) << accumulate(dp+n/2+1, dp+n+1, 0.0) << endl;
}

Measured memory_bytes: 3800
n = int(input())
i = 1

while i <= n:
    x = i
    if x % 3 == 0:
        print("", i, end = "")
    else:
        while x % 10 != 3:
            if x == 0:
                break
            else:
                x //= 10
        else:
            print("", i, end = "")
    i += 1

print()



Measured memory_bytes: 6160
import collections
n=int(input())
N=list(map(int,input().split(" ")))
list_odd=N[::2]
list_even=N[1::2]
c_odd = collections.Counter(list_odd)
c_even = collections.Counter(list_even)
most_odd=c_odd.most_common()[0][1]
most_even=c_even.most_common()[0][1]
if (n<=2):
    print("0")
elif (len(list_even)==most_even and len(list_odd)==most_odd and c_odd.most_common()[0][0]==c_even.most_common()[0][0]):
    print(most_odd)
else:
    if(c_odd.most_common()[0][0]==c_even.most_common()[0][0]):
        M=max(c_odd.most_common()[1][1],c_even.most_common()[1][1])
        print(min((len(list_even)+len(list_odd)-M-most_odd),(len(list_even)+len(list_odd)-M-most_even)))
    else:
        print(len(list_even)+len(list_odd)-most_even-most_odd)
#c_odd.most_common()[0][0]==c_even.most_common()[0][0]

Measured memory_bytes: 19040
#include <iostream>
using namespace std;
int main(){
  int n,i;
  int temp;
  double ans = 100;
  cin >> n;
  for(i = 0;i < n;i++){
    ans *= 1.05;
    ans -= 0.01;
    temp = (int)ans;
    ans = (double)temp + 1;
  }
  cout << ans << "000" << endl;
  return(0);
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>

#define M 1046527
#define NIL (-1)
#define L 14

using std::cout;
using std::endl;
using std::cin;
using std::string;

char H[M][L];

int char2int(char ch){
  if(ch=='A') return 1;
  else if(ch=='C') return 2;     
  else if(ch=='G') return 3;     
  else if(ch=='T') return 4;     
  else return 0;
}

long long getKey(char *str){     
  long long sum=0,p=1;
  for(int i=0;i<strlen(str);i++){
    sum+=p*(char2int(str[i]));   
    p*=5;
  }  return sum;
}
  
int h1(int key){  return  key % M;
}

int h2(int key){
  return 1+(key%(M-1));
}

int h(int key, int i){
  return (h1(key)+i*h2(key)) % M;
}

int insert(char *str){
  long long key,i,h;
  key=getKey(str);
  i=0;
  while(true){
    h=(h1(key)+i*h2(key)) % M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
    i++;
  }
}

int search(char *str){
  long long key,i,h;
  key=getKey(str);
  i=0;
  while (true){
    h=(h1(key)+i*h2(key)) % M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h]) == 0) return 0;
    i++;
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++) H[i][0]=='\0';
  cin >> n;
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i'){
      insert(str);
    }else{
      if(search(str)) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 17528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

void warshall_floyd(const int& n, vector<vector<int>>& d) {
  rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
}

bool judge(const int& n, vector<vector<int>> d, pair<int, int>& bridge) {
  d[bridge.first][bridge.second] = d[bridge.second][bridge.first] = INF;
  warshall_floyd(n, d);
  rep(i, n) rep(j, n) {
    if (d[i][j] == INF) return false;
  }
  return true;
}

int main(int argc, char* argv[])
{
  int n, m;
  cin >> n >> m;
  vector<vector<int>> d(n, vector<int>(n, INF));
  rep(i, n) d[i][i] = 0;
  vector<pair<int, int>> bridges(m);

  rep(i, m) {
    int a, b;
    cin >> a >> b; a--; b--;
    d[a][b] = d[b][a] = 1;
    bridges[i] = make_pair(a, b);
  }

  int ans = 0;
  rep(i, m) {
    if (judge(n, d, bridges[i]) == false) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>

std::pair<double, double> direction(const std::string& first_edge, int degree, const int length) {
	const auto pi = std::acos(-1);
	const auto cx = 0.5;
	const auto cy = std::sqrt(3) / 2;
	double sin, cos;
	switch (first_edge.front()) {
	case 'B': break;
	case 'C': degree += 60; break;
	case 'D': degree += 120; break;
	default: throw 0;
	}
	sin = std::sin(degree * pi / 180);
	cos = std::cos(degree * pi / 180);
	return std::make_pair((cos - sin / cy * cx) * length, sin / cy * length);
}
int face(const std::pair<double, double> coordinate) {
	const int xi = (int)std::floor(coordinate.first) & 1;
	const int yi = (int)std::floor(coordinate.second) & 1;
	const auto xr = coordinate.first - (int)std::floor(coordinate.first);
	const auto yr = coordinate.second - (int)std::floor(coordinate.second);
	const int half = xr + yr > 1;
	return ((xi ^ yi) << 1) + (xi ^ half);
}
int main() {
	std::string xyp, xyq;
	int dp, lp, dq, lq;
	std::cin >> xyp >> dp >> lp >> xyq >> dq >> lq;
	const auto p = direction(xyp, dp, lp);
	const auto q = direction(xyq, dq, lq);
	std::cout << (face(p) == face(q) ? "YES\n" : "NO\n");
}



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

int n, m, q;
int a[55], b[55], c[55], d[55];
int sum, max_;
int row[15];

void dfs(int i, int cnt){
    row[cnt] = i;
    cnt++;
    if(cnt <= n) {
        for(int j = i; j <= m; j++){
            dfs(j, cnt);
        }
    }
    else {
        for(int j = 0; j < q; j++){
            if(row[b[j]] - row[a[j]] == c[j]){
                sum += d[j];
            }
        }
        max_ = max(sum, max_);
        sum = 0;
    }
}

int main(){
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    for(int i = 1; i <= 10; i++){
        dfs(i, 1);
    }
    cout << max_ << endl;
    return 0;
}

Measured memory_bytes: 3680
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    long ans = 0;
    if(m >= (2 * n)) {
      ans = n + ((m - (2 * n)) / 4);
    } else {
      ans = m / 2;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define Nmax 100008
ll n,m,x,y ,k,e,r,a,b,nb,c,test;
ll tab[Nmax]  ;
long double h,l;
string s , s1 ;

int main()
{
    cin >> n ; cout << n*n*n ;

}


Measured memory_bytes: 256
def main():
    n=int(input())
    a=list(map(int, input().split()))
    mod=10**9+7
    ans=((sum(a)%mod)**2)%mod
    for i in range(n):
      ans-=a[i]**2
      ans%=mod
    m=pow(2,mod-2,mod)
    print(ans*m%mod)   
main()

Measured memory_bytes: 31432
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string s; cin>>s;
	cout<<s.substr(0, 3)<<endl;
	return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    if (a > 0) {
        cout << (b/x-(a-1)/x) << endl;
    }
    else {
        cout << (b/x + 1) << endl;
    }
    return 0;
}


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

double P,E,T;

double f(int K,double L,double R){
	if(K==0)return abs( T - (L+R)*0.5 ) < E + 1e-10;
	else{
		double M = (L+R) * 0.5;
		if(M>T){
			return f(K-1,L,M) * (1-P) + f(K-1,M,R) * P;
		}else{
			return f(K-1,L,M) * P + f(K-1,M,R) * (1-P);
		}
	}
}
int main(){
	int K , L , R;
	cin >> K >> L >> R >> P >> E >> T;
	printf("%.7f\n",f(min(K,19),L,R));
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
	int n;cin>>n;int p,q;
	if(n==1){cout<<")("<<endl;return 0;}
	for(int i=1;i<=n;i++){
		int F=i*(i+1)/2;
		if(F>=n)break;
		if(F<n){
			p=i+1;q=n-(i*(i+1)/2);
		}
	}
	int cnt=0,cnt2=0;
	for(int i=1;i<=q;i++){cout<<')';cnt++;cnt2++;}
	if(q!=p){cout<<"()";cnt++;cnt2+=2;}
	while(cnt<p){cout<<')';cnt++;cnt2++;}
	while(cnt2<p*2){cout<<'(';cnt2++;}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
ll BASE = 26;
ll MOD1 = 1000000007LL;
ll MOD2 = 1000000009LL;
ll f(char c) {
  return c - 'a';
}
int main() {
  ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N;
  cin >> S;
  int lo = 0;
  int hi = N / 2;
  int ret = 0;
  while (lo <= hi) {
    int mi = (lo + hi) / 2;
    map<pair<ll,ll>, int> m;
    ll h1 = 0, h2 = 0, r1 = 1, r2 = 1;
    for (int i=0; i<mi; i++) {
      h1 = (h1 * BASE + f(S[i])) % MOD1;
      h2 = (h2 * BASE + f(S[i])) % MOD2;
      r1 = (r1 * BASE) % MOD1;
      r2 = (r2 * BASE) % MOD2;
    }
    m[make_pair(h1, h2)] = 0;
    bool ok = false;
    for (int i=mi; i<N; i++) {
      h1 = ((h1 * BASE + f(S[i]) - f(S[i-mi]) * r1) % MOD1 + MOD1) % MOD1;
      h2 = ((h2 * BASE + f(S[i]) - f(S[i-mi]) * r2) % MOD2 + MOD2) % MOD2;
      if (m.find(make_pair(h1, h2)) == m.end()) {
        m[make_pair(h1, h2)] = i - mi + 1;
      } else if (m[make_pair(h1, h2)] + mi <= i - mi + 1) {
        ok = true;
        break;
      }
    }
    if (ok) {
      ret = mi;
      lo = mi + 1;
    } else {
      hi = mi - 1;
    }
  }
  cout << ret << endl;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,w;
ll dp[125252];

int main(){
  scanf("%d%d",&n,&w);
  REP(i,n){
    int a,b;
    scanf("%d%d",&a,&b);
    FORR(j,0,w+1-a)CHMAX(dp[j+a],dp[j]+b);
  }
  printf("%lld\n",*(dp+w));
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t N, K, R, ans;
  cin >> N >> K;
  R=N%K;
  ans=min(R,(K-R));
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;

int main()
{
    
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    ans+=min(a , k);
    k-=min(a,k);
    k-=min(b,k);
    ans+=min(k,c) * -1;
    cout << ans ;
    
    
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(void){
    
    string s;
    cin >> s;
    if((s[0]==s[1]&&s[1]==s[2]) || (s[1]==s[2]&&s[2]==s[3]))cout<<"Yes";
    else cout <<"No";
    
    return 0;
    
}


Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
pc="pairwise coprime"
sc="setwise coprime"
nc="not coprime"
a.sort()
tmp=a[0]

for i in range(n):
    tmp=math.gcd(tmp,a[i])
if tmp!=1:
    print(nc)
    exit()

dic={}
for i in range(n):
    if a[i] in dic:
        dic[a[i]]+=1
    else:
        dic[a[i]]=1

ans=0
for i in range(a[-1]):
    now=i+1
    cnt=0
    # print(i)
    while now<=a[-1]:
        if now in dic:
            cnt+=dic[now]
        now+=i+1
    if cnt>1:
        ans=i+1

if ans!=1:
    print(sc)
else:
    print(pc)
# print(ans)

Measured memory_bytes: 241208
while True:
  N,X = map(int,input().split())
  if N==0 and X==0:
    break
  ans = 0
  for a in range(1,N+1):
    for b in range(a+1,N+1):
      if b >= N+1:
        break
      c = X-(a+b)
      if c > b and c <=N:
        ans +=1
  print("{:d}".format(ans))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N,M,X;
  int A[105];
  cin>>N>>M>>X;
  for(int t=0;t<M;t++){
    cin>>A[t];
  }

  int cont=0;
  for(int t=0;t<=X;t++){
    for(int i=0;i<M;i++){
      if(t==A[i])cont++;
    }
  }

  cout<<min(cont,M-cont)<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int X;
  cin >> X;
  int count = 2;
  vector<int> data(1,1);
  int a;
  while(count*count <= 1000) {
    a = count;
    a *= count;
    while(a <= 1000) {
      data.push_back(a);
      a *= count;
    }
    count++;
  }
  int ans = 1;
  for(int i = 0; i < data.size(); i++) {
    if(ans < data.at(i) && X >= data.at(i)) ans = data.at(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		var l = new int[n];
		var r = new int[n];
		l[0] = a[0];
		r[n - 1] = a[n - 1];
		for (int i = 1; i < n; i++)
		{
			l[i] = Gcd(l[i - 1], a[i]);
			r[n - 1 - i] = Gcd(r[n - i], a[n - 1 - i]);
		}

		var M1 = Math.Max(r[1], l[n - 2]);
		var M2 = n <= 2 ? 1 : Enumerable.Range(1, n - 2).Max(i => Gcd(l[i - 1], r[i + 1]));
		Console.WriteLine(Math.Max(M1, M2));
	}

	static int Gcd(int x, int y) { for (int r; (r = x % y) > 0; x = y, y = r) ; return y; }
}


Measured memory_bytes: 27100
#include <stdio.h>
#include <string.h>
#define max(p,q)((p)>(q)?(p):(q))

int dp[1010][1010];
char s[1010],t[1010];
int main(){
	int q;
	scanf("%d",&q);
	while(q--){
		scanf("%s%s",s,t);
		int n=strlen(s);
		int m=strlen(t);
		for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
			if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
		printf("%d\n",dp[n][m]);
	}
}


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

int n,m,arr[31],k,l,total;

int main(){
	cin>>n>>m;
	for(int i = 1;i <= n;i++){
		cin>>k;
		for(int j = 1;j <= k;j++){
			cin>>l;
			arr[l]++;
		}
	}
	for (int i = 1;i <= m;i ++){
		if (arr[i] == n){
			total++;
		}
	}
	cout<<total<<endl;
}


Measured memory_bytes: 256
N = int(input()) 
card = [int(i) for i in input().split()] 
card.sort(reverse=True)
alice = 0
bob = 0
for i in range(0,N):
    if(i&1):
        #print(card[i])
        bob+=card[i]
    else:
        #print(card[i])
        alice+=card[i]
ans = alice - bob
print(ans)
    

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

int main(){
    int n; cin>>n;
    rep(_,n){
        ll x[2][2], y[2][2];
        rep(i,2){
            rep(j,2){
                double x_,y_;
                cin >> x_ >> y_;
                x[i][j] = x_*1000000;
                y[i][j] = y_*1000000;
            }
        }
        ll dx1=x[0][0]-x[0][1], dy1=y[0][0]-y[0][1];
        ll dx2=x[1][0]-x[1][1], dy2=y[1][0]-y[1][1];
        dump(dx1,dx2,dy1,dy2);
        puts(dx1*dy2==dx2*dy1 ? "YES" : "NO");
    }
}

Measured memory_bytes: 1192
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    
    String tens = s.substring(0, 1);
    String ones = s.substring(1, 2);
    
    if (tens.equals("9") || ones.equals("9")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22612
from math import factorial

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

x, y = map(int, input().split())
if (x + y) % 3 != 0:
    print(0)
else:
    n = (x + y) // 3
    a = 2 * (x + y) // 3
    b = (x + y) // 3
    # print(a, b, n)
    if x > a or y > a:
        print(0)
    else:
        t = a-x
        # print(t)
        p = 10 ** 9 + 7
        # k = factorial(n) // factorial(t) // factorial(n - t)
        k = comb(n, n-t, p)
        # print(int(k % p))
        print(k)



Measured memory_bytes: 3192
#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 k;
  cin >> k;
  int x = 7;
  rep(i, k + 1) {
    if (x % k == 0) {
      cout << i + 1 << endl;
      return 0;
    }
    x = (x * 10 + 7) % k;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3632
from fractions import gcd
N,X=map(int,input().split(' '))
x=sorted(list(map(int,input().split(' ')))+[X],reverse=True)
x_dif=[x[i]-x[i+1] for i in range(N)]
ans = x_dif[0]
for i in x_dif:
    ans = gcd(ans,i)
print(ans)

Measured memory_bytes: 16280
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>

using namespace std;

int main(){
	uint16_t N;
	cin >> N;
	string *s;
	s = new string[N];
	for(uint16_t i = 0;i<N;++i)
		cin >> s[i];

	std::vector<uint16_t> A, B;
	uint32_t res = 0;

	for(uint16_t i = 0;i<N;++i){
		if(s[i][0] == 'B')
			B.push_back(i);
		if(s[i][s[i].size() - 1] == 'A')
			A.push_back(i);
		for(uint16_t j = 0;j<s[i].size() - 1;++j){
			if(s[i][j] == 'A')
				if(s[i][j+1]=='B')
					++res;
		}
	}

	if(A.size() + B.size() != 0){
		if(A.size() < B.size()){
			res += A.size();
		}else if(A.size() > B.size()){
			res += B.size();		
		}else{
			uint16_t cnt = 0;
			res += A.size();
			for(uint16_t i = 0;i<A.size();++i){
				if(A[i] == B[i])
					++cnt;
			}
			if(cnt == A.size())
				--res;
		}		
	}
	cout << res <<endl;

	return 0;
}


Measured memory_bytes: 896
N, M, X = map(int, input().split())

C = []
A = []
for n in range(N):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])

from itertools import combinations

costs =[]
for i in range(1,N+1):
    idx = list(range(N))
    comb = list(combinations(idx,i))
    for c in comb:
        scores = [0]*M
        cost = 0
        for j in c:
            cost += C[j]
            for m in range(M):
                scores[m] += A[j][m]

            check = [int(s>=X) for s in scores]

            if sum(check)==M:
                costs.append(cost)

if len(costs)>0:
    print(min(costs))
else:
    print(-1)


Measured memory_bytes: 74784
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var nums = map[int]int{}
	for i := 0; i < 3; i++ {
		num := nextInt()
		nums[num]++
	}
	for _, v := range nums {
		if v == 2 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 1772
# https://atcoder.jp/contests/abc094/tasks/arc095_b

import itertools
import collections
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    n = A[-1]
    pos = bisect.bisect(A, n//2)
    if n == A[pos]:
        r = A[pos-1]
    elif pos == 0:
        r = A[pos]
    else:
        r = A[pos] if abs(n/2-A[pos]) < abs(n/2-A[pos-1]) else A[pos-1]

    print("{} {}".format(n, r))


if __name__ == '__main__':
    main()


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

typedef long long ll;
ll const MOD = 1e9+7;

ll bar(int n){
    if(n <= 0){
        return 1;
    }else if(n == 1){
        return 2;
    }else{
        return bar(n-1) + bar(n-2);
    }
}

int main(void){
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<ll>> dp(h, vector<ll>(w+2, 0));
    dp[0][1] = bar(w-2);
    if(w > 1){
        dp[0][2] = bar(w-3);
    }

    for(int i=1; i<h; i++){
        for(int j=1; j<=w; j++){
            dp[i][j] = (dp[i-1][j]*bar(j-2)*bar(w-j-1)%MOD + dp[i-1][j-1]*bar(j-3)*bar(w-j-1)%MOD + dp[i-1][j+1]*bar(j-2)*bar(w-j-2)%MOD)%MOD;
        }
    }

    cout << dp[h-1][k] << endl;

    return 0;
}

Measured memory_bytes: 256