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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    int n = s.size();
    vec c(3, 0);
    rep(i, n){
        c[s[i]-'a']++;
    }
    rep(i, 3){
        if(c[i] == n/3 || c[i] == n/3+1);
        else{
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4608
import java.util.*;

class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int count = 0;
 
    if (a % 2 != 0) {
      count++;
    }
    if (b % 2 != 0) {
      count++;
    }
    if (count == 2) {
      System.out.println("Yes");
      return;
    }
    
    System.out.println("No");
  }
}

Measured memory_bytes: 21844
n=gets.to_i
n-=1

def f(n,l,m,s)
  if n==l
    print "a"
    puts s.join.tr("0-9","a-z")
  elsif l<n
    0.upto(m+1) do |i|
      s << i
      l=s.size
      m=s.max
      f(n,l,m,s)
      s.pop
    end
  end
end

f(n,0,0,[])

Measured memory_bytes: 3068
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()


x1,y1,x2,y2 = na()
x = x2-x1
y = y2-y1

print(x2-(y2-y1), y2+x2-x1, x1-y2+y1,y1+x2-x1)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

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

int main(void){

    int n; cin >> n;
    
    int i=1;
    int64_t sum = 0;
    rep(j, n){
        if(i % 3 == 0 || i % 5 == 0){
        } else {
            sum += i;
        }
        i++;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(2,vector<int>(N));
  rep(i,N) cin >> A[0][i];
  rep(i,N) cin >> A[1][i];
  int maxi = 0;
  for(int p=0;p<N;p++){
    int tmp = 0;
    for(int i=0;i<N;i++){
      if(i<=p) tmp += A[0][i];
      if(i>=p) tmp += A[1][i];
    }
    maxi = max(maxi,tmp);
  }
  cout << maxi << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long h=sc.nextLong();
		long w=sc.nextLong();
		long ans=Long.MAX_VALUE;
		for(long i=1; i<h; i++){
			long max=i*w;
			long min=i*w;
			long lo=Math.max(w,h-i);
			long sh=Math.min(w,h-i);
			if((h-i)%2==0 || w%2==0){
				max=Math.max(max,(h-i)*w/2);
				min=Math.min(min,(h-i)*w/2);
			}else{
				max=Math.max(max,(h-i)*w-lo/2*sh);
				min=Math.min(min,lo/2*sh);
			}
			ans=Math.min(ans,max-min);
		}
		for(long i=1; i<w; i++){
			long max=i*h;
			long min=i*h;
			long lo=Math.max(h,w-i);
			long sh=Math.min(h,w-i);
			if((w-i)%2==0 || h%2==0){
				max=Math.max(max,(w-i)*h/2);
				min=Math.min(min,(w-i)*h/2);
			}else{
				max=Math.max(max,(w-i)*h-lo/2*sh);
				min=Math.min(min,lo/2*sh);
			}
			ans=Math.min(ans,max-min);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23636
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;
ll INF=100000000000001;
vector<ll> value; // ノードの値を持つ配列
ll N;             // 葉の数
 
void update(ll i, ll x) {
    // i 番目の葉の値を x に変える
    i += N - 1; // i 番目の葉のノード番号
    value[i] = x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = min(value[i * 2 + 1],
                       value[i * 2 + 2]); // 左右の子の min を計算しなおす
    }
}
 
ll query(ll a, ll b, ll k, ll l, ll r) {
    // [a, b) の区間に対するクエリについて
    // ノード k （区間 [l, r) 担当）が答える
    if (r <= a || b <= l) return INF; // 区間が被らない場合は INF を返す
    if (a <= l && r <= b)
        return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
                         // に完全に含まれる
    else {
        ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
        return min(c1, c2); // 左右の子の値の min を取る
    }
}

signed main(){
    stin(s);
    sal(((s.sz==6&&s[2]==s[3]&&s[4]==s[5])?"Yes":"No"));
}

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

int main(){
  
  int N;
  cin >> N;
  map<long, long> m;
  for(int i = 0; i < N; i++){
    long tmp;
    cin >> tmp;
    if(m.count(tmp) == 0){
      m[tmp] = 1;
    } else {
      m[tmp] += 1;
    }
  }
  long cnt = 0;
  for(auto x: m){
    if(x.first > x.second){
      cnt += x.second;
    } else { 
      cnt += x.second - x.first;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 6272
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
#include <climits>
#include <unordered_map>
using namespace std;


int main() {
    int N, Z, W;
    cin>>N>>Z>>W;
    int a, b = 0;
    for (int i=0; i<N; i++) {
        a = b;
        cin>>b;
    }
    long long ans = abs(0LL + W - b);
    if (N > 1) ans = max(ans, abs(0LL + a - b));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int d, g;
    cin >> d >> g;

    int p[10], c[10];
    for (int i = 0; i < d; i++) {
        cin >> p[i] >> c[i];
    }

    int r = 1 << 30;
    for (int k = 0; k < 1 << d; k++) {
        int s = 0, t = 0;
        for (int i = 0; i < d; i++) {
            if (k & 1 << i) {
                s += (i + 1) * 100 * p[i] + c[i];
                t += p[i];
            }
        }
        if (s >= g) goto hoge;
        for (int i = d - 1; i >= 0; i--) {
            if (!(k & 1 << i)) {
                for (int j = 0; j < p[i] - 1; j++) {
                    s += (i + 1) * 100;
                    t++;
                    if (s >= g) goto hoge;
                }
            }
        }
    hoge:
        if (s >= g) {
            r = min(r, t);
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
table = [[0]*10 for _ in range(10)]

for i in range(1, N+1):
    s = str(i)
    e1 = int(s[0])
    e2 = int(s[-1])
    table[e1][e2] += 1

res = 0
for i in range(1, 10):
    for j in range(1, 10):
        res += table[i][j]*table[j][i]
print(res)

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

int main(void){
  int N;
  int i,tokuten, a[100];
  int alice, bob, tmp;
  
  if(scanf("%d", &N)==-1){
    exit(1);
  }
  
  for(i=0; i<N; i++){
    scanf("%d", &a[i]);
  }
  
  tokuten=0;
  for(i=0; i<N; i=i+2){
    tmp = arrayMaxValueIndex(a,N);
    alice = a[tmp];
    a[tmp] = 0;
    tmp = arrayMaxValueIndex(a,N);
    bob = a[tmp];
    a[tmp]= 0;
    tokuten +=  alice - bob;
  }
  
  printf("%d", tokuten);

  return 0;
}
    
int arrayMaxValueIndex(int array[], int n)
{
    int i, maxi;
    maxi = 0;
    for (i = 1; i < n; i++) {
        if (array[maxi] < array[i]) maxi = i;
    }
    return maxi;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul s;
  cin >> s;
  ul a, d; // (a, b), (c, d)
  ul b=0, t=1e9+1;
  while (t-b>1) {
    ul piv=(b+t)/2;
    if (piv*piv < s) b = piv;
    else t = piv;
  }
  a=t;
  d=(s-1)/a+1;
  b=a*d-s;
  cout << "0 0 " << a << " " << b << " 1 " << d << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, dp[100005][3];
  cin >> N;
  vector<int> a(N), b(N), c(N);
  rep(i, N) cin >> a[i] >> b[i] >> c[i];
  dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
  for(int i = 0; i < N; i++){
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a[i + 1];
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + b[i + 1];
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c[i + 1];
    //cerr << i + 1 << ' ' << dp[i + 1][0] << ' ' << dp[i + 1][1] << ' '<< dp[i + 1][2] << endl;
  }
  cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
  return 0;
}


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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	
	int i=0,j=n-1;
	int count =0;
	while(i<j){
		if(s[i]=='W' && s[j]=='R'){
			s[i] = 'R';
			s[j] = 'W';
			count++;
		}
		if(s[i]=='R') i++;
		if(s[j]=='W') j--;
		
	}
	cout<<count;
	
	
}

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

int main(int argc, char** argv) {
    int secretNum = 0;
    string str;
    while(getline(cin, str)) {
        for(unsigned int i=0; i<str.size(); ++i) {
            if(str[i] < '0' || '9' < str[i]) {
                str[i] = ' ';
            }
        }
        stringstream ss(str);
        int j;
        while(ss >> j) {
            secretNum += j;
        }
    }
    cout << secretNum << endl;
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
// #define space printf(" ")
#define endl '\n'
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define slld(x) scanf("%lld", &(x))
#define plld(x) printf("%lld", (x))
#define plldn(x) printf("%lld\n", (x))
#define sllf(x) scanf("%llf", &(x))
#define pllf(x) printf("%.9llf", (x))
#define pllfn(x) printf("%.9llf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin);freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

struct ST_Node
{

	ST_Node()
	{
		return;
	}
	void assign_value_(int val)
	{
		return;
	}
	void merge_nodes_(ST_Node& left, ST_Node& right)
	{
		return;
	}
};

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 50;



int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	ll x, y, ans = 0LL;
	cin >> x >> y;
	while(x <= y)
	{
		ans++;
		x <<= 1LL;
	}
	cout << ans;
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
//const int MAX=;
 
int main(){
	int N;
	cin>>N;
	int A[1<<18];
	rep(j,1<<N)cin>>A[j];
	
	
	int p[1<<18], q[1<<18];
	rep(j,1<<N){
		p[j]=A[j];
		q[j]=0;
	}
	
	rep(i,N)rep(j,1<<N)if((j & 1<<i)){
		int x[4];
		x[0]=p[j];x[1]=q[j];x[2]=p[j ^ (1<<i)];x[3]=q[j ^ (1<<i)];
		sort(x,x+4);
		p[j]=x[3];q[j]=x[2];
	}
	int s[1<<18];
	rep(j,1<<N){
		s[j]=p[j]+q[j];
	}
	int ans=0;
	rep1(j,(1<<N)-1){
		ans=max(ans,s[j]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 7168
#[derive(Debug, PartialEq)]
struct Frame {
    index: usize,
    value: i32,
}
#[cfg(test)]
mod tests;

fn main() {
    let n = read_usize();
    let v = read_line_vec(Some(n));
    let mut frames = parse_frame(v);
    let ave = frames.iter().fold(0, |a, b| a + b.value) as f64 / n as f64;
    let ans = find_frame(ave, frames);
    println!("{}", ans);
}

fn find_frame(ave: f64, frames: Vec<Frame>) -> i32 {
    let mut min_index = -1;
    let mut min_diff = 101.0;
    for i in frames {
        if (i.value as f64 - ave).abs() < min_diff {
            min_index = i.index as i32;
            min_diff = (i.value as f64 - ave).abs();
        }
    }
    min_index
}

fn parse_frame(v: Vec<String>) -> Vec<Frame> {
    let mut ans = Vec::with_capacity(v.len());
    for (i, e) in v.into_iter().enumerate() {
        ans.push(Frame {
            index: i,
            value: e.parse().unwrap(),
        });
    }
    ans
}

fn read_usize() -> usize {
    let handle = std::io::stdin();
    let mut buf = String::new();
    handle.read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn read_line_vec(cap: Option<usize>) -> Vec<String> {
    let handle = std::io::stdin();
    let mut buf = String::new();
    handle.read_line(&mut buf).unwrap();
    match cap {
        Some(n) => {
            let mut v: Vec<String> = Vec::with_capacity(n);
            v = buf
                .trim()
                .split_whitespace()
                .map(|a| a.parse().unwrap())
                .collect();
            v
        }
        None => buf
            .trim()
            .split_whitespace()
            .map(|a| a.parse().unwrap())
            .collect(),
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> N;
    vector<pi> a(N);
    REP(i, N) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(RALL(a));
    vvi dp(N + 1, vi(N + 1, -LLINF));
    dp[0][0] = 0;
    REP(i, N) {
        REP(l, N) {
            int r = i - l;
            if (r < 0)
                continue;
            chmax(dp[l + 1][r], dp[l][r] + a[i].first * abs(l - a[i].second));
            chmax(dp[l][r + 1], dp[l][r] + a[i].first * abs(N - 1 - r - a[i].second));
        }
    }
    REP(i, N) {
        REP(j, N) {
            chmax(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
}

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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		auto s = to_string(i);
		if (s.size() % 2 == 1)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a; cin >> a;
    
    cout << 3 * a * a << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Convert;
class Program
{
    static void Main(string[] args)
    {
        var input = ReadLine().Split(' ');
        var num = ToInt32(input[0]);
        var fig = ToInt32(input[1]);
        var lengths = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        Array.Sort(lengths);
        var sum = 0;
        for(var i = 0; i < fig; i++)
        {
            sum += lengths[num - i - 1];
        }
        WriteLine(sum);
    }
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define make_pair mp
typedef long long int ll;
typedef unsigned long long int ull;
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
    cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < 3; i++){
		if (s[i] == 'A')
			a++;
		else
			b++;
	}
	if (a * b == 0){
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<string>
using namespace std;


int main(){

  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  string ans="";
  sort(s.begin(),s.end());
  // for(int i=0;i<n;i++){
    // ans += sort(s[i].begin(),s[i].end());
  // }

  for(int i=0;i<n;i++){
    printf("%s",s[i].c_str());
    // cout << s[i] << endl;
  }
  // printf("\n");
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

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

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
		printf("res:%lld a:%lld\n", res,a);
	}
	return res;
}


lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/


int main()
{
    char S[10];

    scanf("%s", S);

    if (strcmp(S, "ABC") == 0)
        printf("ARC");
    else
        printf("ABC");
}



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



Measured memory_bytes: 2144
#AGC037-A Dividing a String
"""
分割した時に前の分割したものとかぶらないように
分割数を最大化せよ
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
s = readline().rstrip().decode('utf-8')

res = ""
ans = [""]
for i in s:
    if res == "":
        res += i
    else:
        res += i
    if ans[-1] != res:
        ans.append(res)
        res = ""
if res != "" and ans[-1] != res:
    ans.append(res)
print(len(ans)-1)


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

int main() {
  
  string S;
  cin >> S;
  
  int t=0;
  
  if(S.at(0) == 'o'){
    t+=100;
  }
  if(S.at(1) == 'o'){
    t+=100;
  }
  if(S.at(2) == 'o'){
    t+=100;
  }
  
  cout << 700+t << endl;
  
}


Measured memory_bytes: 3600
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    string S; cin >> S;
    list<char> str;
    REP(i, S.length()) str.PB(S[i]);
    int Q; cin >> Q;
    bool rev = false;
    REP(i, Q){
        int T; cin >> T;
        if(T == 1){
            rev = !rev;
        }else{
            int F; cin >> F;
            char C; cin >> C;
            if(F == 1){
                if(rev) str.PB(C);
                else str.push_front(C);
            }else{
                if(rev) str.push_front(C);
                else str.PB(C);
            }
        }
    }
    if(rev){
        str.reverse();
    }
    for(auto itr = str.begin(); itr != str.end(); ++itr)
        cout << *itr;
    cout << endl;
    return 0;
}


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

typedef long long LL;
const int N = 5005, M = 1e9+7;

LL power(LL a, LL p) {
    if (p == 0) return 1;
    LL ans = power(a, p/2);
    ans = (1LL*ans * ans)%M;
    if (p%2)    ans = (1LL*ans*a)%M;
    return ans;
}

LL fac[N], invfac[N];
void pre() {
    fac[0] = 1;
    for(LL i=1; i<N; i++)  fac[i] = (1LL*i*fac[i-1])%M;
    invfac[N-1] = power(fac[N-1], M-2);
    for (LL i=N-2; i>=0; i--)  invfac[i] = (1LL*invfac[i+1]*(i+1))%M;
}

LL C(LL n, LL r) {
    if (r<0 || r>n) return 0;
    LL denom = (1LL*invfac[r]*invfac[n-r])%M;
    return (1LL*fac[n]*denom)%M;
}


int iid = 0;
int to[N], comp[N];
LL pp[N];

void dfs(int u, int id) {
    if (comp[u])    return;
    comp[u] = id;
    if (to[u] == -1)    return;
    dfs(to[u], id);
    comp[u] = comp[to[u]];
}

int sz[N], head[N];

vector<LL> f(vector<LL> a, LL x) {
    int n = a.size();
    vector<LL> ans(n+1);
    for (int i=0; i<n; i++) ans[i] = a[i];
    for (int i=0; i<n; i++) ans[i+1] = (ans[i+1] + a[i]*x)%M;
    return ans;
}

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

    pre();
    int n;
    cin>>n;

    pp[0] = 1;
    for (int i=1; i<N; i++)     pp[i] = (pp[i-1]*(n-1))%M;

    for (int i=1; i<=n; i++)    cin>>to[i];

    for (int i=1; i<=n; i++) {
        dfs(i, iid+1);
        iid = max(iid, comp[i]);
    }

    for (int i=1; i<=n; i++) {
        sz[comp[i]]++;
        if (to[i] == -1)    head[comp[i]]=i;
    }

    vector<int> open;
    int closed = 0;


    for (int i=1; i<=iid; i++) {
        if (!head[i])       closed++;
        else open.push_back(sz[i]);
    }

    int k = open.size();
    LL ans = (closed*pp[k])%M;

    vector<LL> psum;
    psum.push_back(1);

    for (int i=0; i<k; i++) {
        int x = open[i];
        psum = f(psum, x);
    }
    assert(psum.size() == k+1);

    for (int i=1; i<psum.size(); i++) {
        if (i==1)   psum[i] -= k;
        LL ways = (fac[i-1]*pp[k-i])%M;
        ans = (ans + ways*psum[i])%M;
    }

    LL total = (n*pp[k])%M;
    ans = (total+M-ans)%M;
    cout<<ans<<endl;
}


Measured memory_bytes: 4096
#include <stdio.h>
#define N 101
int main(void){
	int i;
	int j;
	int n;
	int adj[N][N];
	int a, b, c;
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		for(j=1; j<=n; j++) adj[i][j]=0;
	}
	for(i=1; i<=n; i++){
		scanf("%d %d ", &a, &b);
		for(j=1;j<=b;j++){
			scanf("%d", &c);
			adj[a][c]=1;
		}
	}
	for(i=1; i<=n; i++){
		for(j=1; j<=n; j++){
			printf("%d", adj[i][j]);
			if(j!=n) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int N; cin >> N;
	if (N % 2 == 0) {
		cout << N * (N - 2) / 2 << endl;
		for (int i = 1; i <= N; i++) {
			for (int j = i + 1; j <= N; j++) {
				if (i + j != N + 1) cout << i << " " << j << endl;
			}
		}
	}
	else { 
		cout << (N - 1) * (N - 1) / 2 << endl;
		for (int i = 1; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (i + j != N) cout << i << " " << j << endl;
			}
		}
		for (int i = 1; i < N; i++) cout << i << " " << N << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


X = I()

for a in range(-118, 120):
    for b in range(-119, 119):
        if a ** 5 - b ** 5 == X:
            print(a, b)
            exit()


Measured memory_bytes: 9156
#include <iostream>

using namespace std;
using ll = long long;

int main() {
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    ll diff = B - A;
    for (ll p = 0; p < N; ++p) {
        // p個を正に固定する
        ll mi = C * p - D * (N - p - 1);
        ll ma = D * p - C * (N - p - 1);
        if (mi <= diff && diff <= ma) {
            cout << "YES" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

using namespace std;
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int K; cin >> K;
	REP(i,K) {
		cout << "ACL";
	}
	cout << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const double eps = 1e-10;
const double PI = 3.14159265358979323846;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second




int main() {
	ll m, f, b;
	cin >> m >> f >> b;
	if (b - m > f)cout << "NA" << endl;
	else cout << max(0LL, b - m) << endl;
	return 0;
}



Measured memory_bytes: 3116
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
    int n;
    cin >> n;
    
    int A[n], mi = 101, ma = -101;
    REP(i, n){
        cin >> A[i];
        mi = min(mi, A[i]);
        ma = max(ma, A[i]);
    }
    
    int ans = INT_MAX, total = 0;
    for(int i = mi; i <= ma; i++){
        REP(j, n){
            total += abs(i - A[j]) * abs(i - A[j]);
        }
        ans = min(ans, total);
        total = 0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
bool search(int *a,int n,int x) {
    int i=0;
    a[n]=x;
    while(a[i]!=x) i++;
    return i!=n;

}
int n;
int q;
int S[10004];


int main() {
    cin>>n;
    rep(i,n) cin>>S[i];
    cin>>q;
    int ans=0;
    rep(i,q) {
        int t;
        cin>>t;
        if(search(S,n,t)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    deque<char>res;
    string s;
    cin>>s;
    for(auto&x:s) res.push_back(x);
    int q;
    cin>>q;
    int cur=0;
    while(q--)
    {
        int t;
        cin>>t;
        if(t==1) cur^=1;
        else
        {
            int f;
            char c;
            cin>>f>>c;
            f--;
            int p=cur^f;
            if(p==0) res.push_front(c);
            else res.push_back(c);
        }
    }
    string ans;
    while(!res.empty())
    {
        ans+=res.front();
        res.pop_front();
    }
    if(cur) reverse(ans.begin(),ans.end());
    cout<<ans;
}



Measured memory_bytes: 1368
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll a,b; cin >> a >> b;
  FOR(i,1,1000){
    if(i*(i+1)/2-a == (i+1)*(i+2)/2-b){
      cout << i*(i+1)/2-a << endl;
      return 0;
    }
  }
}

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

const int N = 1e5 + 12;
int a[N], n, ans;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	for (int i = 0; i < n; i++)
		if(a[i] == i + 1){
			swap(a[i], a[i + 1]);
			ans++;
		}
	
	cout << ans;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,k,x,ans=0,i;
	cin >> n;
	cin >> k;
	for(i=0; i<n; ++i){
		cin >> x;
		ans += min(k-x,x);
	}
	ans *= 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def non_decreasing(N: int, A: list) -> list:
    res = []

    # まず、A の値を正か負に統一する。
    # なので、A に正と負の値が混在する場合のみ、min(A) と max(A)
    # の絶対値の大きい方を全体に足す。
    min_a, max_a = min(A), max(A)
    min_i, max_i = A.index(min_a), A.index(max_a)

    if min_a * max_a < 0:
        # 正と負の値が混在するのでどちらかに統一する。
        # ここの操作は N-1 回。
        if abs(min_a) < abs(max_a):
            # max_a を全体に加えて正の値のみにし、単調増加
            # するように修正する。
            res = [(max_i + 1, i + 1) for i in range(N) if i != max_i]
            for i in range(N):
                if i != max_i:
                    A[i] += max_a
            min_a += max_a
        else:
            # min_a を全体に加えて負の値のみにし、絶対値が
            # 単調減少するように修正する。
            res = [(min_i + 1, i + 1) for i in range(N) if i != min_i]
            for i in range(N):
                if i != min_i:
                    A[i] += min_a
            max_a += min_a

    # この操作が N-1 回。
    if max_a <= 0:
        # 全体が負の値なので、絶対値が単調減少するように N 番目の値から
        # 始めて i 番目の値を i-1 番目の値に足していく。
        res += [(i, i - 1) for i in range(N, 1, -1)]
        for i in range(N-1, 0, -1):
            A[i - 1] += A[i]

    else:
        # 全体が正の値なので、単調増加するように 1 番目の値から始めて i
        # 番目の値を i+1 番目の値に足していく。
        res += [(i, i + 1) for i in range(1, N)]
        for i in range(0, N - 1):
            A[i + 1] += A[i]

    # print(A)

    return res


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    ans = non_decreasing(N, A)
    print(len(ans))
    for x, y in ans:
        print(x, y)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args) {
 
    while(kbd.hasNext()){
        int a = kbd.nextInt();
        int b = kbd.nextInt();
     
        if(a==0 && b==0){
        ;
        }
        else{
        int x = a/b;
        int y = a%b;
        double c = a;
        double d = b;
        double z = c/d;
        System.out.printf("%d %d %f\n",x,y,z);
        }
    }
    }
}

Measured memory_bytes: 17188
#include<bits/stdc++.h>
using namespace std;
int sum, a[10000000], n, k;
bool cmp(int a, int b)
{
	return (a > b);
}
int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	sort(a, a+n, cmp);
	for (int i = 0; i< k; i++)
	{
		sum += a[i];
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 256
#include <iostream>
//#include <algorithm>
#include <vector>
//#include <string>
using namespace std;
//#include <stdio.h>
#define ll long long
 
int main(void)
{
    ll n, m, k, max = 0;
    cin >> n >> m >> k;
    vector<ll> a(n + 1), suma(n + 1), b(m + 1), sumb(m + 1);

    a.at(0) = 0;
    for(ll i = 1; i < n + 1; i++) {
        cin >> a.at(i);
        suma.at(i) = suma.at(i - 1) + a.at(i);
    }

    b.at(0) = 0;
    for(ll i = 1; i < m + 1; i++) {
        cin >> b.at(i);
        sumb.at(i) = sumb.at(i - 1) + b.at(i);
    }

    ll j = 0;
    for(ll i = n; i > -1; i--) {
        for(; j < m + 1; j++) {
            if(suma.at(i) + sumb.at(j) > k)
                break;
            if(max < i + j)
                max = i + j;
        }
    }

    cout << max;
}

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

int n, ans;

void init() {
	scanf("%d", &n);
}

void solve() {
	for(int i = 1; i <= n; i++) {
		int tmp = 0, use = i;
		while(use > 0) {
			tmp++;
			use /= 10;
		}
		if(tmp % 2 == 1) ++ans;
	}
	printf("%d", ans);
}

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


Measured memory_bytes: 256
import collections
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

if N < M:
    print("NO")
    exit(0)
tableD = collections.defaultdict(int)
tableT = collections.defaultdict(int)
for i in range(N):
    tableD[D[i]] += 1
for i in range(M):
    tableT[T[i]] += 1

for x in tableT:
    if tableD[x] >= tableT[x]:
        continue
    else:
        print("NO")
        exit(0)
print("YES")


Measured memory_bytes: 57056
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
using namespace std;

bool a[200];

int main()
{
	string s;
	cin >> s;
	if (s.size() == 26)
	{
		a[s[25]] = true;
		for (int i = 24; i >= 0; i--)
		{
			a[s[i]] = true;
			for (int j = s[i] + 1; j <= 'z'; j++)
			{
				if (a[j] == true)
				{
					cout << s.substr(0, i) + (char)j;
					return 0;
				}
			}
			if (i == 0)
			{
				cout << -1;
				return 0;
			}
		}
	}
	for (int i = 0; i < s.size(); i++)
	{
		a[s[i]]=true;
	}
	for (int i = 'a'; i <= 'z'; i++)
	{
		if (a[i] == false)
		{
			cout << s << (char)i;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int N, D, i = 1;
	cin >> N >> D;
	while(1){
		if((2 * D + 1) * i >= N){
			break;
		}
		i++;
	}
	cout << i << endl;
	return 0;
}

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

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

int main() {
  int N;
  cin >> N;
  vector<ll> T(N);
  for (int i = 0; i < N; i++) cin >> T[i];

  ll ans = T[0];
  for (int i = 0; i < N; i++) ans = lcm(ans, T[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
using System;
using System.Linq;
using System.Collections.Generic;

public class Program{
  public static void Main(){
    var n = Array.ConvertAll(Console.ReadLine().Split(' '), UInt16.Parse);
    ulong a = (ulong) n[1];
    for(var i=1; i<n[0]; i++) a*= (ulong)n[1]-1;
    Console.WriteLine(a.ToString());
  }
}


Measured memory_bytes: 11220
#include <stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    
    for(int i=1;i <10 ;i++){
        if(n % i == 0 &&n/i <10){
            puts("Yes\n");
            break;
            
        }
        else if(i==9){
            puts("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1624