akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> C[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
 
  long ans = 0;
  for (int i = 0; i < N; i++) {
    auto Iter1 = lower_bound(A.begin(), A.end(), B[i]);
    auto Iter2 = upper_bound(C.begin(), C.end(), B[i]);
    long k1 = Iter1 - A.begin();
    long k2 = C.end() - Iter2;
    ans += k1 * k2;
  }
  cout << ans << "\n";
  return 0;
}

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

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

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

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

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int K, N; cin >> K >> N;
  auto ans = K*500 >= N ? "Yes" : "No";
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]

    return (s, )


def solve(s):
    
    result = 'No' 
    if s[2] == s[3] and s[4] == s[5]:
        result = 'Yes'
    
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    string s;
    cin >> s;
    if(s[0] == s[1] and s[0] == s[2]){
        cout << "Yes" << endl;
    }else if(s[3] == s[1] and s[3] == s[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
  long long a,b;
  cin>>a>>b;
  if(a>0 && b>0){
    cout<<"Positive"<<endl;
  }
  else if(a<=0 && b>=0){
    cout<<"Zero"<<endl;
  }
  else if(a<0 && b<0){
    if((b-a)%2==0){
      cout<<"Negative"<<endl;
    }
    else{
      cout<<"Positive"<<endl;
    }
  }
  return 0;
}

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

int main()
{
	lint N,a[100010]={},x;
	lint tmp;
	lint ans=0;
	
	cin >> N >> x;
	for(int i=0;i<N;i++)
	{
		cin >> a[i];
		if(a[i]>x)
		{
			ans+=(a[i]-x);
			a[i]=x;
		}
	}
	
	for(int i=0;i<N-1;i++)
	{
		tmp=a[i]+a[i+1];
		if(tmp>x)
		{
			ans+=(tmp-x);
			a[i+1]-=(tmp-x);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int n;
  cin >> n;
  if (n <= 999)
    cout << "ABC" << endl;
  else
    cout << "ABD" << endl;
}


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

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define DEBUG 1

int main(){

	lli n,k;
	map<lli,lli> m;
	cin>>n>>k;
	REP(i,n){
		lli s,num;
		cin>>s>>num;
		m[s]+=num;
	}
	lli sum=0;
	for(auto &e:m){
		sum += e.second;
		if(sum>=k){
			cout<<e.first<<endl;
			break;
		}
	}


	return 0;
}

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

int main()
{
  int a,b,c,d;
  int res=0;
  cin >> a>>b>>c>>d;

  res=max(a*b,c*d);

  cout << res << endl;
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define inf (int)(1e9)
#define MAXX 1.1529215e+18
#define INF 999999
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*--------------------------------------------*/
const int MAX_N=100001;
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool compare_by_b_greater(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}
int main(){
    int n;cin>>n;
    vector<P> odd(MAX_N);
    vector<P> even(MAX_N);//firstに値を,secondに頻度を格納
    V v(n+1);
    rep(i,n){
        cin>>v[i];
        if(i%2==0){
            even[v[i]].second++;
            even[v[i]].first=v[i];
        }
        else{
            odd[v[i]].second++;
            odd[v[i]].first=v[i];
        }
    }
    sort(ALL(odd),compare_by_b_greater);//pairのsecondについて逆順にsort
    sort(ALL(even),compare_by_b_greater);
    int a=odd[0].second;//最頻値が第一候補
    int b=even[0].second;
    int aa=odd[1].second;//第二候補
    int bb=even[1].second;//第二候補
    int av=odd[0].first;
    int bv=even[0].first;
    //printf("n=%d\n",n);
    //printf("a,b,aa,bb=%d,%d,%d,%d\n",a,b,aa,bb);
    //printf("av,bv=%d,%d\n",av,bv);
    int ans;
    if(av==bv){//偶奇の値が同じなら第二候補に
        ans=a+bb<b+aa?n-(b+aa):n-(a+bb);
    }else{
        ans=n-(a+b);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}

int main(){
  int n,m,c;
  cin>>n>>m>>c;
  vector<int>b(m);
  rep(i,m)cin>>b[i];
  vector<vector<int>>a(n,vector<int>(m));
  rep(i,n)rep(j,m)cin>>a[i][j];

  int tmp;
  int cnt=0;
  rep(i,n){
    tmp=0;
    rep(j,m){
      tmp+=a[i][j]*b[j];
    }
    if(tmp+c>0)cnt++;
  }

  cout<<cnt<<endl;
    
  return 0;
}


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

using namespace std;

const int IN=1e5+10;

int num[IN];
int num2[IN];
int num3[IN];


int main()
{
    int n;
    scanf("%d",&n);
    memset(num2,0,sizeof(num2));
    memset(num3,0,sizeof(num3));
    int flag=1;
    for(int i=0;i<n;i++){
        scanf("%d",&num[i]);
        if(flag){
            num2[num[i]]++;
            flag=0;
        }
        else{
            num3[num[i]]++;
            flag=1;
        }
    }
    int max1=0,imax1=0;
    int max2=0,imax2=0;
    for(int i=0;i<n;i+=2){
        if(num[i]==imax1||num[i]==imax2) continue;
        else{
            if(num2[num[i]]>max1){
                imax2=imax1;
                max2=max1;
                imax1=num[i];
                max1=num2[num[i]];
            }
            else if(num2[num[i]]>max2){
                max2=num2[num[i]];
                imax2=num[i];
            }
        }
    }
    int max3=0,imax3=0;
    int max4=0,imax4=0;
    for(int i=1;i<n;i+=2){
        if(num[i]==imax3||num[i]==imax4) continue;
        else{
            if(num3[num[i]]>max3){
                imax4=imax3;
                max4=max3;
                imax3=num[i];
                max3=num3[num[i]];
            }
            else if(num3[num[i]]>max2){
                max4=num3[num[i]];
                imax4=num[i];
            }
        }
    }
    int sum;
    if(imax1==imax3) sum=max(max1+max4,max2+max3);
    else sum=max1+max3;
    printf("%d",n-sum);
    return 0;
}


Measured memory_bytes: 1408
/**
 * @param {String} raw_input 入力
 */
function Main(raw_input) {
	const [ first, ...trail ] = raw_input.split("\n");
	const [n, m] = toNumArray(first);
	const aList = toNumArray(trail[0]);

	console.log(Math.max(-1, n - sum(aList)));
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

////////// ユーティリティ関数

/**
 * 文字列を数値配列
 * @param {String} str 文字列
 */
function toNumArray(str, delimitor = ' ') {
	return str.split(delimitor).map(s => parseInt(s, 10));
}

/**
 * 文字列をVigInt配列に変換する
 * @param {String} str 文字列
 */
function toBitIntArray(str, delimitor = ' ') {
	return str.split(delimitor).map(s => BigInt(s));
}

/**
 * 合計を出す
 * @param {Array<Number>} n 数値配列
 */
function sum(n) {
	return n.reduce((a, b) => a + b);
}

Measured memory_bytes: 30600
#include<stdio.h>
 
int main(void){
    int n, i, j, team[100], score[100], a, b, c, d;
    scanf("%d", &n);
    for (i = 0; i<n; i++){
        team[i] = 0;
    }
    for (i = 0; i<n*(n - 1) / 2; i++){
        scanf("%d%d%d%d", &a, &b, &c, &d);
        if (c>d){
            team[a - 1] += 3;
        }
        else if (c<d){
            team[b - 1] += 3;
        }
        else{
            team[a - 1]++;
            team[b - 1]++;
        }
    }
    for (i = 0; i<n; i++){
        score[i] = 1;
        for (j = 0; j<n; j++){
            if (team[i]<team[j]){
                score[i]++;
            }
        }
    }
    for (i = 0; i<n; i++){
        printf("%d\n", score[i]);
    }
    return 0;
}

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

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;

void add(int&a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

struct Matrix {
    vector<vector<int>> matrix;
    Matrix(int n){
        matrix.resize(n, vector<int> (n));
    }
    Matrix operator* (const Matrix & b) const {
        int n = matrix.size();
        Matrix c = Matrix(n);
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                for (int k = 0; k < n; k++){
                    add(c.matrix[i][k], mul(matrix[i][j], b.matrix[j][k]));
                }
            }
        }
        return c;
    }
};

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<vector<int>> a(n, vector<int> (n));
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    Matrix m(n);
    m.matrix = a;
    Matrix answer(n);
    for (int i = 0; i < n; i++){
        answer.matrix[i][i] = 1;
    }
    while(k){
        if (k & 1){
            answer = answer * m;
        }
        m = m * m;
        k = k / 2;
    }
    int total = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            add(total, answer.matrix[i][j]);
        }
    }
    cout << total;
    return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int a, b;
    cin >> a >> b;
    string aa = "", bb = "";
    rep(i, a) { aa += b + '0'; }
    rep(i, b) { bb += a + '0'; }

    if (aa > bb) {
        cout << bb << endl;
    } else {
        cout << aa << endl;
    }
    return 0;
}


Measured memory_bytes: 256
let rec for_fold a b v f = if a > b then v else for_fold (a+1) b (f a v) f

let modulo = 1000000007
let (+@) a b = (a + b) mod modulo
let ( *@) a b = (a * b) mod modulo
let rec modpow a n =
   if n = 0 then 1
   else if n mod 2 = 1 then a *@ (modpow a (n-1))
   else let h = modpow a (n/2) in h *@ h
let modinv a = modpow a (modulo - 2)

let fact =
   let ret = Array.init 200001 (max 1) in
   for i = 2 to 200000 do
      ret.(i) <- i *@ ret.(i-1);
   done;
   ret

let comb n k = fact.(n) *@ modinv fact.(k) *@ modinv fact.(n-k)

let () =
   Scanf.scanf "%d %d %d" @@ fun n m k ->
   let calc x y =
      comb (x*y-2) (k-2) *@ for_fold 1 (x-1) 0 (fun i s -> s +@ i *@ (x-i) *@ y *@ y)
   in
   calc n m +@ calc m n |> Printf.printf "%d\n"


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

#define FOR(i,start,end) for(int i=start; i<(int)(end); i++)
#define REP(i,n) FOR(i,0,n)


int main() {


    int h, w;
    while(1) {
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) {
            break;
        }
        REP(i, h) {
            REP(j, w) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<vector>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
ll D;
ll c[26];
ll s[366][26];
ll t[366];

ll total_max_score;
ll ft[366];

//スコア計算
ll score(ll days){
	ll ans=0;
	ll last[26];
	rep(i,26)last[i]=0;
	for(ll d=1;d<=days;d++){
		ans+=s[d][t[d]];
		last[t[d]]=d;
		rep(i,26){
			ans-=c[i]*(d-last[i]);
		}
	}
	return ans;
}

ll whole_score;
ll score_typ[26];
void recalc(ll i){
	ll ans=0;
	ll last=0;
	for(ll d=1;d<=D;d++){
		if(t[d]==i){
			ans+=s[d][i];
			last=d;
		}
		ans-=c[i]*(d-last);
	}
	whole_score-=score_typ[i];
	score_typ[i]=ans;
	whole_score+=score_typ[i];
}
void change(ll d,ll q){
	ll b=t[d];
	t[d]=q;
	recalc(b);
	recalc(q);
	if(whole_score>total_max_score){
		total_max_score=whole_score;
		for(ll d=1;d<=D;d++){
			ft[d]=t[d];	
		}
	}
}
void init_score(){
	total_max_score=-1e17;
	whole_score=0;
	rep(i,26){
		score_typ[i]=0;
		recalc(i);
	}
}

//貪欲法
void greedy(){
	for(ll d=1;d<=D;d++){
		ll ma=-1e17,pt=0;
		rep(i,26){
			t[d]=i;
			ll res=score(d);
			if(ma<res){
				ma=res;
				pt=i;
			}
		}
		t[d]=pt;
	}
}

//日程を√cに応じて分配
void distribute(){
	vector<ll> v;
	rep(i,26){
		for(ll x=1;x*x<=c[i];x++){
			v.push_back(x);
		}
	}
	for(ll d=1;d<=D;d++){
		t[d]=v[rand()%(ll)v.size()];
	}
}

//局所探索_改
void local_search(){
	rep(u,50000){//日付を一つ選んで、コンテストを変更
		ll d=rand()%D+1;
		ll q=rand()%26;
		ll b=t[d];
		ll bef_score=whole_score;
		change(d,q);
		ll aft_score=whole_score;
		if(bef_score>aft_score){
			change(d,b);
		}
	}
	rep(u,50000){//日付を二つ選んで、コンテストをswap
		ll bef_score=whole_score;
		ll d1,d2;
		do{
			d1=rand()%D+1;
			d2=rand()%D+1;
		}while(d1==d2);
		ll p=t[d1],q=t[d2];
		change(d1,q);
		change(d2,p);
		ll aft_score=whole_score;
		if(bef_score>aft_score){
			change(d1,p);
			change(d2,q);
		}
	}
}


int main(){
	//ifstream ifs("input.txt");
	cin>>D;
	rep(i,26)cin>>c[i];
	for(ll d=1;d<=D;d++)rep(j,26)cin>>s[d][j];
	greedy();
	//distribute();
	init_score();
	local_search();
	//ofstream ofs("output.txt");
	for(ll d=1;d<=D;d++){
		cout<<ft[d]+1<<"\n";
	}
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define ll long long
#define p 998244353
using namespace std;
int a[1010],b[1010];
int jc[1010],njc[1010],inv[1010];
vector<int>ret,E[1010],all[1010];
vector<int>mul(vector<int>x,vector<int>y){
	vector<int>ret;
	int n=x.size(),m=y.size();
	ret.resize(n+m-1);
	for(int i=0;i<n;i++)
	for(int j=0;j<m;j++)
	(ret[i+j]+=1ll*x[i]*y[j]%p)%=p;return ret;
}
void del(vector<int>&x,vector<int>y){
	int n=x.size(),m=y.size();
	x.resize(max(n,m));
	for(int i=0;i<m;i++)(x[i]-=y[i])%=p; 
}
void add(vector<int>&x,vector<int>y){
	int n=x.size(),m=y.size();
	x.resize(max(n,m));
	for(int i=0;i<m;i++)(x[i]+=y[i])%=p; 
}
int main(){
	int n;scanf("%d",&n);
	for(int i=0;i<2;i++)jc[i]=njc[i]=inv[i]=1;
	for(int i=2;i<=405;i++){
		jc[i]=1ll*jc[i-1]*i%p;
		inv[i]=1ll*inv[p%i]*(p-p/i)%p;
		njc[i]=1ll*njc[i-1]*inv[i]%p;
	}
	for(int i=0;i<n;i++)scanf("%d %d",&a[i],&b[i]); 
	int S=0,ans=0;
	for(int i=0;i<n;i++)S+=a[i];
	for(int i=0;i<n;i++){
		for(int k=0,P=1;k<b[i];k++,P=1ll*P*a[i]%p)E[i].push_back(1ll*P*njc[k]%p);
	}
	for(int i=0;i<n;i++){
		for(int k=S-a[i];k>=1;k--)if(all[k].size())
		del(all[a[i]+k],mul(E[i],all[k]));
		add(all[a[i]],E[i]);
	}
	for(int i=1;i<=S;i++){
		for(int j=0,u=inv[i];j<all[i].size();j++,u=1ll*u*inv[i]%p)
		(ans+=1ll*all[i][j]*u%p*jc[j]%p)%=p;
	}
	(ans+=p)%=p;
	cout<<1ll*ans*S%p;
	return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int year=0,month=0,day=0;
		int nensu=0;

		while(sc.hasNext()) {
			year=sc.nextInt();
			month=sc.nextInt();
			day=sc.nextInt();

			nensu=(year-1)*372+(month-1)*31+day;

			if(nensu<1867*372+8*31+8) {
				System.out.println("pre-meiji");
			}
			else if(nensu>=1867*372+8*31+8 && nensu<=1911*372+6*31+29) {
				System.out.println("meiji "+(year-1867)+" "+month+" "+day);
			}
			else if(nensu>=1911*372+6*31+30 && nensu<1925*372+11*31+25) {
				System.out.println("taisho "+(year-1911)+" "+month+" "+day);
			}
			else if(nensu>=1925*372+11*31+25 && nensu<=1988*372+7) {
				System.out.println("showa "+(year-1925)+" "+month+" "+day);
			}
			else {
				System.out.println("heisei "+(year-1988)+" "+month+" "+day);
			}
		}
	}
}


Measured memory_bytes: 26280
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>

using namespace std;



int main(void)
{
    double x1,y1,x2,y2,xq,yq;
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)!=EOF){
        double xr,yr;
        
        if(x1!=x2){
            double a,b;
            a=(y2-y1)/(x2-x1);
            b=-a*x1+y1;
            
            yq-=b;
            
            xr=(1-a*a)/(a*a+1)*xq+2*a/(a*a+1)*yq;
            yr=(a*a-1)/(a*a+1)*yq+2*a/(a*a+1)*xq+b;
        }else{
            yr=yq;
            xr=-xq;
        }
        
        cout<<fixed<<setprecision(6)<<xr<<" "<<yr<<endl;
    }
}

Measured memory_bytes: 1288
package main

import (
	"fmt"
)

func stdinput() (int, int, int) {
	var val, A, B int
	fmt.Scan(&val, &A, &B)
	return val, A, B
}
func main() {
	val, a, b := stdinput()
	d := val / (a + b)
	m := val % (a + b)
	if m > a {
		fmt.Println(d*a + a)
	} else {
		fmt.Println(d*a + m)
	}

}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
  int N,X,T,a;
    cin>>N>>X>>T;
      a=N/X;
      if(N%X>0){
          cout<<T*(a+1)<<endl;
          
      }
      else{
          cout<<T*a<<endl;
      }
}

Measured memory_bytes: 3636
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var init = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var n = init[0];
    var k = init[1];
    // var seq = ReadLine().Split(' ').Select(int.Parse).ToArray();

    // var ans = n == k ? 1 : (n + (k-2)) / (k - 1);
    // var ans = (n - k + k - 2) / (k-1) + 1;
    var ans = (n-1 + k-2) / (k-1);
    WriteLine(ans);
  }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const double Pi=acos(-1);
vector<ll> A;
vector<ll> F;
ll N;
ll binary_search(ll key,ll maximum) {
  ll answer=maximum;
  ll left=1,right=maximum;
  while (right >= left) {
    ll count=0;
    ll mid=left+(right-left)/2;
    for(ll i=0;i<N;i++){
      count+=max((ll)0,A.at(i)-mid/F.at(N-1-i));
    }
    //if (count<=key) return mid;
    if (count > key){left=mid+1;}
    else if (count <= key){right=mid-1;answer=min(answer,mid);}
    //cout<<left<<" "<<right<<" "<<"mid:"<<mid<<" count:"<<count<<endl;
  }
  return answer;
}
int main() {
  ll sumcost=0;
  ll K;
  cin>>N>>K;
  A.resize(N);
  F.resize(N);
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
    sumcost+=A.at(i);
  }
  for(ll i=0;i<N;i++){
    cin>>F.at(i);
  }
  if(sumcost<=K){cout<<0<<endl;}//k回も修行する必要がない時
  else{
    sort(A.begin(),A.end());
    sort(F.begin(),F.end());
    ll maxtime=A.at((ll)A.size()-1)*F.at((ll)F.size()-1);
    cout<<binary_search(K,maxtime); 
  }
}

Measured memory_bytes: 3328
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
	static int max;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		Data[] list = new Data[n+1];
		Calendar cal = Calendar.getInstance();
		cal.clear();
		cal.set(Calendar.YEAR, 1989);
		list[0] = new Data(cal,"kogakubu10gokan");
		int ans = 0;
		Calendar check = Calendar.getInstance();
		check.clear();
		check.set(Calendar.YEAR, q + 1988);
		
		
		for(int i = 1; i <= n; i++) {
			cal = Calendar.getInstance();
			cal.clear();
			cal.set(Calendar.YEAR, 1988 + sc.nextInt());
			if(check.compareTo(cal) >= 0) ans = i;
			list[i] = new Data(cal,sc.next());
			
			
		}
		System.out.println(list[ans].name);
		
		
	}
	static class Data {
		Calendar cal;
		String name;
		Data(Calendar a, String b) {
			cal = a;
			name = b;
		}
	}
}

Measured memory_bytes: 18244
loop do
  a,b,c = gets.chomp.split.map(&:to_i)
  break if (a|b|c) == 0
  parts = Array.new(a + b + c + 1, 2)

  n = gets.chomp.to_i
  fail_list = []
  n.times do
    i,j,k,r = gets.chomp.split.map(&:to_i)
    if r == 1
      parts[i] = 1
      parts[j] = 1
      parts[k] = 1
    else
      fail_list << [i,j,k]
    end
  end

  fail_list.each do |comb|
    fails = []
    comb.each do |p|
      unless parts[p] == 1
        fails << p
      end
    end

    unless fails.size == 1
      next
    end

    parts[fails[0]] = 0
  end

  (1..parts.size-1).each do |i|
    puts parts[i]
  end
end

Measured memory_bytes: 6120
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n,l;cin >> n >> l;
    vector<int> ans(n);
    iota(ALL(ans),1);
    
    rep(i,n){
        ans[i] = ans[i] + l - 1;
    }
    int sumP = accumulate(ALL(ans),0);
    int Min = INF;
    int Mtmp = INF;
    rep(i,n){
        if(Mtmp > abs(ans[i])){
            Min = ans[i];
            Mtmp = abs(ans[i]);
        }
    }
    cout << sumP - Min << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            Integer[] A = new Integer[N];
            Integer[] B = new Integer[N];
            Integer[] C = new Integer[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }
            for (int i = 0; i < N; i++) {
                B[i] = in.nextInt();
            }
            for (int i = 0; i < N; i++) {
                C[i] = in.nextInt();
            }

            Arrays.sort(A);
            Arrays.sort(B);
            Arrays.sort(C);
            int i = 0, k = 0;
            long ans = 0;
            for (int j = 0; j < N; j++) {
                // A[i] < B[j] < C[k]
                while (i < N && A[i] < B[j]) i++;
                while (k < N && B[j] >= C[k]) k++;

                ans += 1L * i * (N - k);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main()
{
  int n, m, x, y;
  vector<pair<int, int>> a(50), b(50), c(50);

  cin >> n >> m;
  for (int i = 0; i < n; i++)
  {
    cin >> x >> y;
    a[i] = make_pair(x, y);
  }
  for (int i = 0; i < m; i++)
  {
    cin >> x >> y;
    b[i] = make_pair(x, y);
  }
  for (int i = 0; i < n; i++)
  {
    c[i] = make_pair(0, abs(a[i].first - b[0].first) + abs(a[i].second - b[0].second));
    for (int j = 1; j < m; j++)
    {
      if (c[i].second > abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second))
        c[i] = make_pair(j, abs(a[i].first - b[j].first) + abs(a[i].second - b[j].second));
    }
  }
  for (int i = 0; i < n; i++)
    cout << c[i].first + 1 << endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    student_count, checkpoint_count = map(int, input().split())
    student_points = [list(map(int, input().split())) for i in range(1, student_count + 1)]
    check_points = [list(map(int, input().split())) for i in range(1, checkpoint_count + 1)]
 
    for student_point_x, student_point_y in student_points:
        point_number = 0
        shortest_distance = float('inf')
        manhattan_distance = 0
 
        for i in range(len(check_points)):
            diff_x = abs(student_point_x - check_points[i][0])
            diff_y = abs(student_point_y - check_points[i][1])
            manhattan_distance = diff_x + diff_y
 
            if manhattan_distance < shortest_distance:
                shortest_distance = manhattan_distance
                point_number = i + 1
 
        print(point_number)

Measured memory_bytes: 3064
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, y = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    flag = False
    for i in range(n+1):
        for j in range(n-i+1):
            if (10000 * i) + (5000 * j) + (1000 * (n-i-j)) == y:
                print(i, j, (n-i-j))
                flag = True
                break
        if flag == True:
            break

    if flag == False:
        print("-1 -1 -1")
resolve()

Measured memory_bytes: 38768
import java.util.Scanner;

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

        if (s.endsWith("s")) {
            System.out.println(s + "es");
        } else {
            System.out.println(s + "s");
        }
    }
}


Measured memory_bytes: 38404
/*
  Submitter: Nick Hudson
  Anumber: A01634984
  */

#include <iostream>

int main(){

  int in1, in2;

  std::cin>>in1>>in2;

  for(int ans = 1; ans<=3; ++ans ){
    if(in1 != ans && in2 != ans)
      std::cout<<ans;
  }


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N;
pair <int, int> A[205];
bool Use[205][205];
const int MOD = 998244353;
int Power[205];
int ans;
int Area(pair <int, int> a, pair <int, int> b, pair <int, int> c)
{
    return a.first * b.second + b.first * c.second + c.first * a.second - a.second * b.first - b.second * c.first - c.second * a.first;
}
void Read()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> A[i].first >> A[i].second;
    Power[0] = 1;
    for(int i = 1; i <= N; i++)
    {
        Power[i] = (1LL * Power[i - 1] * 2) % MOD;
    }
}
void Solve()
{
    ans = Power[N] - 1;
    if(ans < 0)
        ans += MOD;
    for(int i = 1; i <= N; i++)
    {
        ans--;
        if(ans < 0)
            ans += MOD;
        for(int j = i + 1; j <= N; j++)
        {
            if(Use[i][j] == 1)
            continue;
            int cnt = 1;
            for(int k = j + 1; k <= N; k++)
            {
                if(Area(A[i], A[j], A[k]) == 0)
                {
                    ++cnt;
                    Use[i][k] = 1;
                }
            }
            ans -= Power[cnt] - 1;
            if(ans < 0)
                ans += MOD;
        }
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
///线段树：
const int M=2e5+10;
const ll oo=1e9;
struct tree
{
    int l,r;
    ll data,add;
//    void show()
//    {
//        printf("%d %d %lld %lld\n",l,r,data,add);
//    }
};
struct segmenttree
{
    ll a[M];
    tree t[4*M];
    void build(int p,int l,int r)
    {
        t[p].r=r,t[p].l=l;
        if(r==l)
        {
            t[p].data=a[l];
            return;
        }
        int mid=(r+l)/2;
        build(2*p,l,mid);
        build(2*p+1,mid+1,r);
        t[p].data=min(t[2*p].data,t[2*p+1].data);
    }
    void spread(int p)
    {
        if(t[p].add!=oo)
        {
            t[2*p].data=min(t[p].add,t[2*p].data);
            t[2*p+1].data=min(t[p].add,t[2*p+1].data);;
            t[2*p].add=min(t[p].add,t[2*p].add);
            t[2*p+1].add=min(t[p].add,t[2*p+1].add);
            t[p].add=oo;
        }
    }
    void change(int p,int l,int r,ll d)
    {
        if(l<=t[p].l&&t[p].r<=r)
        {
            t[p].data=min(t[p].data,d);
            t[p].add=min(t[p].add,d);
            return;
        }
        spread(p);
        int mid=(t[p].l+t[p].r)/2;
        if(l<=mid) change(2*p,l,r,d);
        if(r>mid) change (2*p+1,l,r,d);
        t[p].data=min(t[2*p].data,t[2*p+1].data);

    }
    ll ask(int p,int l,int r)
    {
        if(t[p].l>=l&&t[p].r<=r) return t[p].data;
        spread(p);
        int mid=(t[p].l+t[p].r)/2;
        ll ans=oo;
        if(l<=mid) ans=min(ask(2*p,l,r),ans);
        if(r>mid) ans=min(ask(2*p+1,l,r),ans);
        return ans;
    }
    void changeone(int p,int x,int v)
    {
        if(t[p].l==t[p].r)
        {
            t[p].data=v;
            return;
        }
        spread(p);
        int mid=(t[p].l+t[p].r)/2;
        if(x<=mid) changeone(2*p,x,v);
        else changeone(2*p+1,x,v);
        t[p].data=min(t[2*p].data,t[2*p+1].data);
    }



}c,r;

int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=1;i<4*M;i++)
    {
        c.t[i].add=oo;
        r.t[i].add=oo;
    }
    for(int i=1;i<=n;i++)
    {
        c.a[i]=n;
        r.a[i]=n;
    }
    c.build(1,1,n);
    r.build(1,1,n);
    ll  res=(1LL*n-2)*(1LL*n-2);
    while(q--)
    {
        int op,x;
        scanf("%d%d",&op,&x);
        if(op==1)
        {
            int rr=c.ask(1,x,x);
            if(rr==1) continue;
            r.change(1,1,rr-1,x);
            res-=rr-2;
        }
        else
        {
            int rr=r.ask(1,x,x);
            if(rr==1) continue;
            c.change(1,1,rr-1,x);
            res-=rr-2;
        }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 44288
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> table;

int pow_int(int b, int p)
{
	int r = 1;
	for (int i = 0; i < p; i++)
	{
		r *= b;
	}

	return r;
}

void table_init()
{
	table.push_back(1);

	int b = 2, p = 2;

	while (true)
	{
		int ans = pow_int(b, p);

		if (b == 33)
			break;

		if (ans > 1024)
		{
			b++;
			p = 2;
		}
		else
		{
			p++;
			table.push_back(ans);
		}
		
	}

	sort(table.begin(), table.end());
}

int main(void)
{
	int x;
	cin >> x;

	table_init();

	int i = 0;

	while (true)
	{
		int ans = table[i];

		if (ans > x)
			break;

		i++;
	}

	cout << table[i - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define mod 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
int main(){
  int N; cin>>N;
  vvi F(N,vi(10)), P(N,vi(11));
  rep(i,N) rep(j,10) cin>>F[i][j];
  rep(i,N) rep(j,11) cin>>P[i][j];
  ll ans = -1e9;
  for(int i=1;i<(1<<10);i++){
    ll bene = 0;
    rep(j,N){
      int cnt = 0;
      rep(k,10) if(i & (1<<k) && F[j][k]) cnt++;
      bene += P[j][cnt];
    }
    ans = max(ans,bene);
  }
  cout<<ans<<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>;

int main() {
  int x;
  cin >> x;
  for (int a = 1; a < 1000; ++a) {
    ll a5 = 1;
    rep(i,5) a5 *= a;
    for (int b = -1000; b < 1000; ++b) {
      ll b5 = 1;
      rep(i,5) b5 *= b;
      if (a5-b5 == x) {
        printf("%d %d\n", a, b);
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3720
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h,w; //h=3, w=4
        while(true){
            h = sc.nextInt();
            w = sc.nextInt();

            if(w == 0 && h == 0) break;

            for(int i = 0 ; i < h ; i++){
                for(int j = 0 ; j < w ; j++) {
                System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

typedef struct node {
  int key;
  struct node *par;
  struct node *left;
  struct node *right;
} Node;

Node *root;

Node *makeNode(int key) {
  Node *new_node = (Node *)malloc(sizeof(Node));
  if(new_node == NULL) return NULL;
  new_node->key = key;
  new_node->par = NULL;
  new_node->left = NULL;
  new_node->right = NULL;
  return new_node;
}

void clearTree(Node *cur) {
  if(cur == NULL) return;
  clearTree(cur->left);
  clearTree(cur->right);
  free(cur);
}

void clear() {
  clearTree(root);
}

void insertNode(Node *new_node) {
  Node *par = NULL;
  Node *cur = root;
  while(cur != NULL) {
    par = cur;
    if(new_node->key < cur->key) cur = cur->left;
    else cur = cur->right;
  }
  new_node->par = par;
  if(par == NULL) root = new_node;
  else if(new_node->key < par->key) par->left = new_node;
  else par->right = new_node;
}

void insert(int key) {
  Node *new_node = makeNode(key);
  if(new_node == NULL) return;
  insertNode(new_node);
}

int findKey(int key, Node *cur) {
  if(cur == NULL) return 0;
  if(cur->key == key) return 1;
  if(key < cur->key) return findKey(key, cur->left);
  else return findKey(key, cur->right);
}

int find(int key) {
  return findKey(key, root);
}

void inOrder(Node *cur) {
  if(cur == NULL) return;
  inOrder(cur->left);
  printf(" %d", cur->key);
  inOrder(cur->right);
}

void preOrder(Node *cur) {
  if(cur == NULL) return;
  printf(" %d", cur->key);
  preOrder(cur->left);
  preOrder(cur->right);
}

void print() {
  inOrder(root); puts("");
  preOrder(root); puts("");
}

int main() {
  int m;
  int i;
  scanf("%d", &m);
  root = NULL;
  for(i = 0; i < m; i++) {
    char cmd[256];
    scanf("%s", cmd);
    if(strcmp(cmd, "insert") == 0) {
      int key;
      scanf("%d", &key);
      insert(key);
    } else if(strcmp(cmd, "find") == 0) {
      int key;
      scanf("%d", &key);
      puts((find(key) ? "yes" : "no"));
    } else if(strcmp(cmd, "print") == 0) {
      print();
    }
  }
  clear();

  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;



int main(){

  ll x;cin>>x;

  bool a[1000000];CLR(a,false);
  a[0]=false;
  a[1]=false;
  a[2]=false;
  for(int i=3;i<1e6;i++){
    if(!a[i]){
      // a[i]=false;
      for(int j=2*i;j<=1e6;j+=i){
        a[j]=true;
      }
    }
  }
  rep(i,0,1e6){
    // if(!a[i])out(i);
    if(i>=x&&!a[i]){
      out(i);
      return 0;
    }
  }




  return 0;
}


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

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

        // 1.08x = a
        // 1.10x = b

        int a, b;
        cin >> a >> b;
        for(int x = 1; x <= 100000; x++) {
                if((8*x)/100 == a && (10*x)/100 == b) {
                        cout << x << endl;
                        return 0;
                }
        }

        cout << -1 << endl;
}

Measured memory_bytes: 256
// E - Red and Green Apples
#include <bits/stdc++.h>
using namespace std;
#define allr(x) (x).rbegin(),(x).rend()
int in(){int x;cin>>x;return x;}

int main(){
	int X, Y, A, B, C; cin>>X>>Y>>A>>B>>C;
	int N = X + Y;
	vector<int> T, P(A), Q(B);
	while(A--) P[A] = in();
	while(B--) Q[B] = in();
	sort(allr(P)); sort(allr(Q));
	while(X--) T.push_back(P[X]);
	while(Y--) T.push_back(Q[Y]);
	while(C--) T.push_back(in());
	sort(allr(T));
	long long ans = 0;
	while(N--) ans += T[N];
	cout<< ans <<endl;
}

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

class Vec {
	double x,y;
	Vec(double x, double y) {
		this.x = x;
		this.y = y;
	}
	Vec add(Vec b) {
		return new Vec(this.x + b.x, this.y + b.y);
	}
	Vec sub(Vec b) {
		return new Vec(this.x - b.x, this.y - b.y);
	}
	Vec mul(double k) {
		return new Vec(this.x * k, this.y * k);
	}
	double abs() {
		return  Math.sqrt(this.x * this.x + this.y * this.y);
	}
	double dot(Vec b) {
		return  this.x * b.x + this.y * b.y;
	}
	double cross(Vec b) {
		return  this.x * b.y - this.y * b.x;
	}
}

/**
0.0,0.0
0.0,1.0 
1.0,1.0 
2.0,0.0 
1.0,-1.0 

**/
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Vec> a = new ArrayList<>();
		while(sc.hasNextLine()) {
			String line = sc.nextLine();
			if(line.equals("")) {
				break;
			}
			String[] t = line.split(",");
			double x = Double.parseDouble(t[0]);
			double y = Double.parseDouble(t[1]);
			a.add(new Vec(x, y));
		}
		double area = 0.0;
		for(int i = 2; i < a.size(); i++) {
			Vec p = a.get(i-1).sub(a.get(0));
			Vec q = a.get(i).sub(a.get(0));
			area += Math.abs(p.cross(q)) / 2.0;
		}
		System.out.printf("%.6f\n", area);
		sc.close();
	}
}


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

int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n / 2 << endl;
	}
	else {
		cout << n / 2 + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
//
//  atc1019.cpp
//  National Olympiad in Informatics in Provinces
//
//  Created by 黄子齐 on 2019/10/19.
//  Copyright © 2019 黄子齐. All rights reserved.
//

#include <stdio.h>
int a, b;
int main() {
//    freopen("mytestdata.in", "r", stdin);
    scanf("%d%d", &a, &b);
    if (a <= b*2) {
        printf("0\n");
    } else {
        printf("%d\n", a-b*2);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)

ll pow_2(ll n){
	if(n==0) return 1;
	else if(n%2==0) return pow_2(n/2)*pow_2(n/2)%mod;
	else return 2*pow_2(n-1);
}

int main(){
	ll n;
	cin >> n;
	ll cnt[n];
	ll r=n%2;
	for(ll i=0; i<n; i++) cnt[i]=0;
	bool flg=true;
	for(ll i=0; i<n; i++){
		ll a;
		cin >> a;
		if(a%2==r) flg=false;
		cnt[a]++;
	}
	
	if(r==1 && cnt[0]!=1) flg=false;
	for(ll i=1; i<=n-r; i++){
		if(i%2!=r && cnt[i]!=2) flg=false;
	}

	if(flg) cout << pow_2((n-r)/2) << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

using namespace std;

int main(){
	int n,m,tmp;
	scanf("%d %d",&n,&m);
	int** A = new int*[n];
	for(int i = 0; i < n; i++) A[i] = new int[m];
	int b[m];

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%d",&tmp);
			A[i][j] = tmp;
		}
	}
	for(int i = 0; i < m; i++){
		scanf("%d",&tmp);
		b[i] = tmp;
	}
	long long int sum;
	for(int i = 0; i < n; i++){
		sum = 0;
		for(int j = 0; j < m; j++){
			sum += A[i][j] * b[j];
		}
		printf("%lld\n",sum);
	}

	for(int i = 0; i < n; i++){
		delete[] A[i];
	}
	delete A;
}






Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
#define m  1000000007
typedef long long ll;

int main()
{
  ll n;
  cin>>n;
  ll i,j,sum=0,x=0;
  ll a[n];
  for(ll i;i<n;i++)
  {
    cin>>a[i];
    sum=sum+a[i];
   
  }
  for(ll i=0;i<n-1;i++)
  {
    sum=sum-a[i];
    x=x + sum%m*a[i]%m;
      x=x%m;
}
  cout<<x;
}


Measured memory_bytes: 5160
package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		n, k int
		s    string
	)

	fmt.Scan(&n, &k)
	fmt.Scan(&s)

	slice := strings.Split(s, "")
	slice[k-1] = strings.ToLower(slice[k-1])
	s = strings.Join(slice, "")

	fmt.Println(s)
}


Measured memory_bytes: 640