akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }
 
int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull a, b;
  cin >> a >> b;

  ull sub = max({a, b}) - min({a, b});
  if (sub % 2 == 0) {
    ull d = (ull)(sub / 2);
    cout << max({a, b}) - d << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import datetime

date_str = str(input())
date_formatted = datetime.datetime.strptime(date_str, "%Y/%m/%d")

heisei_end = "2019/04/30"
heisei_end_formatted = datetime.datetime.strptime(heisei_end, "%Y/%m/%d")

print("Heisei" if date_formatted <= heisei_end_formatted else "TBD")

Measured memory_bytes: 4592
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-6
//#define p 2173412051LL
#define sz 2

using namespace std;

int main() {
	int n, k, res = 0;
	scanf( "%d%d", &n, &k );
	while( n ) {
		++res;
		n /= k;
	}
	printf( "%d", res );
	return 0;
}

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

int dp[5010][5010];
int dpR[5010][5010];
//int dpSumR[5010][5010];
int A[5010];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	dp[0][0] = 1;
	{
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j <= K; ++j) {
				if (dp[i][j]) {
					dp[i+1][j] = 1;
					if (j + A[i] <= K) {
						dp[i + 1][j + A[i]] = 1;
					}
				}
			}
		}
	}
	dpR[0][1] = 1;
	{
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j <= K; ++j) {
				if (dpR[i][j+1]) {
					dpR[i+1][j+1] = 1;
					if (j + A[N - 1 - i] <= K) {
						dpR[i + 1][j + A[N - 1 - i]+1] = 1;
					}
				}
			}
		}
	} 
	{
		for (int i = 0; i < N+1; ++i) {
			for (int j = 1; j < K+2; ++j) {
				dpR[i][j] += dpR[i][j - 1];
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0;j<K;++j) {
			if (dp[i][j]) {
				if (dpR[N-i-1][K-j] > dpR[N-i-1][max(0, K - A[i]-j)]) {
					ans++;
					break;
				}
			}
		}
	}
	cout << N - ans <<  endl;
	return 0;
}

Measured memory_bytes: 199304
#from IPython import embed
N=int(input())
n = []

from collections import Counter

c = Counter()

for i in range(N):
    k = input().split()
    k[1] = int(k[1])
    k.append(i+1)
    n.append(k)
    c.update([k[0]])



n.sort()
#n = n[::-1]
prev = ""
l = []
cnt = 0
#print(c)
for a in n:
    #print(a)

    if c[a[0]] > 1:
        l.append(a[1:])
        #print(a[1:])
        cnt+=1
        #print(a[0])
        #embed()
        if cnt == c[a[0]]:
            l.sort()
            #print(l)
            for i in l[::-1]:
                print(i[1])
            cnt = 0
            l = []
    else:
        print(a[2])


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main(){
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <string>

using namespace std;

class Dice{
private:
	int top, bottom, north, east, west, south;
public:
	void setNumber(){
		int n1, n2, n3, n4, n5, n6;
		cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
		top = n1;
		south = n2;
		east = n3;
		west = n4;
		north = n5;
		bottom = n6;
	}

	void roll(){
		string command;
		cin >> command;
		for(int i = 0; i < command.length(); i++){
			switch(command[i]){
				case 'N': rollNorth(); break;
				case 'E': rollEast(); break;
				case 'W': rollWest(); break;
				case 'S': rollSouth(); break;
			}
		}
	}

	void rollNorth(){
		int tmp = north;
		north = top;
		top = south;
		south = bottom;
		bottom = tmp;
	}

	void rollEast(){
		int tmp = east;
		east = top;
		top = west;
		west = bottom;
		bottom = tmp;
	}

	void rollWest(){
		int tmp = west;
		west = top;
		top = east;
		east = bottom;
		bottom = tmp;
	}

	void rollSouth(){
		int tmp = south;
		south = top;
		top = north;
		north = bottom;
		bottom = tmp;
	}

	void rotateClockwise(){
		int tmp = south;
		south = east;
		east = north;
		north = west;
		west = tmp;
	}

	int getTop(){
		return top;
	}

	int getFront(){
		return south;
	}

	int getRight(){
		return east;
	}
};

int main(){
	Dice dice;
	dice.setNumber();
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int top, front;
		cin >> top >> front;
		while(true){
			if(dice.getTop() == top) break;
			dice.rollNorth();
			if(dice.getTop() == top) break;
			dice.rollEast();
		}
		while(dice.getFront() != front){
			dice.rotateClockwise();
		}
		cout << dice.getRight() << endl;
	}

	return 0;
}

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

using pii = pair<int, int>;
using vi = vector<int>;
using ll = long long;

int main() {
    vector<int> W(10), K(10);
    for(int i = 0; i < 10; ++i) {
        cin >> W[i];
    }
    for(int i = 0; i < 10; ++i) {
        cin >> K[i];
    }
    sort(rbegin(W), rend(W));
    sort(rbegin(K), rend(K));
    cout << W[0] + W[1] + W[2] << ' ' << K[0] + K[1] + K[2] << endl;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll =long long int;
const  int mod = 1e6;
typedef pair<int, int>pi;
int main()
{
	int n; cin >> n;
	string s; cin >> s;
	int c = 1;
	for (int i = 1; i < n; ++i) {
		if (s[i] != s[i - 1])c++;
	}
	cout << c;
	return 0;
}


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

one = sum(A)
for i in range(1, N, 2):
    one -= 2*A[i]

ans = [0]*N
ans[0] = one
for i in range(1, N):
    ans[i] = 2*A[i-1] - ans[i-1]

print(*ans)

Measured memory_bytes: 14028
// Last Change: 03/28/2020 21:52:39.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;

  vector<vector<int>> g(N, vector<int>());
  for (int i = 0; i < N - 1; ++i) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  g[X - 1].push_back(Y - 1);
  g[Y - 1].push_back(X - 1);

  vector<int> res(N);
  vector<vector<int>> already(N, vector<int>(N));
  for (int start = 0; start < N; ++start) {
    vector<int> visited(N);
    queue<pair<int, int>> qp;
    qp.push(make_pair(start, 0));

    while (!qp.empty()) {
      int pos = qp.front().first;
      int step = qp.front().second;
      qp.pop();

      if (already[start][pos] == 0) {
        ++res[step];
        already[pos][start] = 1;
      }

      for (auto &&e : g[pos]) {
        if (visited[e] == 1) {
          continue;
        }
        qp.push(make_pair(e, step + 1));
        visited[e] = 1;
      }
    }
  }

  for (int k = 1; k < N; ++k) {
    cout << res[k] << endl;
  }
}


Measured memory_bytes: 16128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
int L, n;
int main() {
	int i, j, k;
	scanf("%d", &L);
	n = 0;
	int p = 0;
	while((1<<n) <= L){
		if(L&(1<<n)) p++;
		n++;
	}
	printf("%d %d\n", n, 2*(n-1)+p-1);
	for(i = 1; i < n; i++) printf("%d %d %d\n%d %d %d\n", i, i+1, 0, i, i+1, 1<<i-1);
	int t = 1<<n-1;
	for(i = n-1; i >= 1; i--) if(L&(1<<i-1)){
		printf("%d %d %d\n", i, n, t);
		t += 1<<i-1;
	}
	return 0;
}

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

template<typename Monoid>
struct SegmentTree{
	using F=function<Monoid(Monoid, Monoid)>;
	int sz;
	vector<Monoid> seg;
	const F f;
	const Monoid e;

	SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
	}

	SegmentTree(int n, const F f, const Monoid &e, vector<Monoid> v): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
		for(int i=0; i<n; i++) seg[i+sz]=v[i];
		for(int i=sz-1; i>=1; i--){
			seg[i]=f(seg[2*i], seg[2*i+1]);
		}
	}

	void update(int k, const Monoid &x){
		k+=sz;
		seg[k]=x;
		while(k>1){
			k>>=1;
			seg[k]=f(seg[2*k], seg[2*k+1]);
		}
	}

	Monoid query(int a, int b){
		a+=sz, b+=sz;
		Monoid retl=e, retr=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) retr=f(seg[--b], retr);
			if(a&1) retl=f(retl, seg[a++]);
		}
		return f(retl, retr);
	}

	Monoid operator[](const int &k) const{
		return seg[k+sz];
	}
};

template<ll mod>
struct RollingHash{
	vector<ll> hash, power;

	RollingHash(const vector<int> &s, ll base=10007){
		int sz=s.size();
		hash.resize(sz+1);
		power.resize(sz+1);
		power[0]=1;
		for(int i=0; i<sz; i++){
			power[i+1]=power[i]*base%mod;
			hash[i+1]=(hash[i]*base+s[i])%mod;
		}
	}

	ll get(int l, int r) const{ // [l, r)
		ll ret=hash[r]-hash[l]*power[r-l]%mod+mod;
		if(ret>=mod) ret-=mod;
		return ret;
	}

	ll concat(ll h1, ll h2, int len2) const{ //h1+h2
		ll ret=h1*power[len2]%mod+h2;
		if(ret>=mod) ret-=mod;
		return ret;
	}
};

int main()
{
	int n, k;
	cin>>n>>k;
	vector<int> p(n);
	for(int i=0; i<n; i++){
		cin>>p[i];
	}
	RollingHash<1000000007> rh1(p, 123456789);
	RollingHash<924844033> rh2(p, 987654321);
	auto f=[&](Pi p1, Pi p2){
		ll h11=p1.first.first, h12=p1.first.second, h21=p2.first.first, h22=p2.first.second;
		int l1=p1.second, l2=p2.second;
		return Pi(P(rh1.concat(h11, h21, l2), rh2.concat(h12, h22, l2)), l1+l2);
	};
	SegmentTree<Pi> seg(n, f, Pi(P(0, 0), 0));
	for(int i=0; i<k; i++){
		seg.update(p[i], Pi(P(p[i], p[i]), 1));
	}
	set<P> st;
	Pi pm=seg.query(0, n);
	st.insert({rh1.concat(pm.first.first, rh1.get(k, n), n-k), rh2.concat(pm.first.second, rh2.get(k, n), n-k)});
	for(int i=k; i<n; i++){
		seg.update(p[i], Pi(P(p[i], p[i]), 1));
		seg.update(p[i-k], Pi(P(0, 0), 0));
		pm=seg.query(0, n);
		ll h1=rh1.concat(rh1.concat(rh1.get(0, i-k+1), pm.first.first, k), rh1.get(i+1, n), n-i-1);
		ll h2=rh2.concat(rh2.concat(rh2.get(0, i-k+1), pm.first.second, k), rh2.get(i+1, n), n-i-1);
		st.insert({h1, h2});
	}
	cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 32128
def main():
  s = input()
  ac = s.count('a')
  bc = s.count('b')
  cc = s.count('c')
  if abs(ac-bc) <= 1 and abs(bc-cc) <= 1 and abs(ac-cc) <= 1:
    print('YES')
  else:
    print('NO')
  
  
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

Measured memory_bytes: 5560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
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.at(0).at(i);
	}
	rep(i, n){
		cin >> a.at(1).at(i);
	}

	int ans = 0;
	rep(i, n){
		int add = 0;
		rep(j, n){
			if(j <= i) add += a.at(0).at(j);
			if(i <= j) add += a.at(1).at(j);
		}
		ans = max(ans, add);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll N,X,T;
  cin >> N >> X >> T;
  cout << (N+X-1)/X*T << endl;
  

}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
int main()
{
    ll a,b, ans=1;
    cin>>a>>b;
    ll v=__gcd(a,b);
    rep(i,2,sqrt(v)+1)
    {
        bool t = false;
        while (v % i == 0)
        {
            v /= i;
            if (!t)
            {
                ans += 1;
            }
            t = true;
        }
    }
    if (v > 1)
    {
        ans += 1;
    }
    cout << ans;
}
// #include <bits/stdc++.h>
// using namespace std;
// #define rep(i, a, b) for (ll i = (a); i < (b); i++)
// #define rep2(r, aa, bb) for (ll r = (aa)-1; r >= (bb); r--)
// #define be(x) (x.begin(), x.end())
// #define pb(t) push_back(t)
// #define ll long long
// #define mp(a, b) make_pair(a, b)
// ll checkPrimeNumber(ll n)
// {
//     bool flag = false;

//     for (ll i = 2; i <=sqrt(n); ++i)
//     {
//         if (n % i == 0)
//         {
//             flag = true;
//             break;
//         }
//     }
//     return flag;
// }
// ll main()
// {
//     ll a, b;
//     cin>>a>>b;
//     vector<ll> A;
//     rep(i,2,sqrt(__gcd(a,b)+4))
//     {
//         if(checkPrimeNumber(i))continue;
//         if(__gcd(a,b)%i==0)A.pb(i);
//     }
//     cout<<A.size()+1<<endl;
// }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
  ll r,g,b,n,x,c=0;
  cin>>r>>g>>b>>n;
  for (ll i = 0; i <=n; ++i)
  {
    fr(j,0,n+1)
    {
        x = n - r*i - g*j;
        if(x<0)
          break;
        if(x%b==0)
          c++;
    }
  }
  c(c);
}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N, Q = map(int, input().split())
    S = input().rstrip("\r\n")
    s = [0] * (N+1)
    s[0] = 0
    s[1] = 0
    for i in range(1, N):
        exists_AC = (S[i-1] == "A" and S[i] == "C")
        s[i+1] = s[i] + int(exists_AC)
    for _ in range(Q):
        l, r = map(int, input().split())
        print(s[r]-s[l])
if __name__ == "__main__":
    main()

Measured memory_bytes: 52696
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    A = [int(input()) for _ in range(4)]
    print(min(A[0], A[1]) + min(A[2], A[3]))


main()


Measured memory_bytes: 4860
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
    long ans = (n / (a + b)) * a;
    long r = n % (a + b);
    ans += Math.min(a, r);
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9+7;

int d;
vector<int> c;
vector<vector<int>> s;
vector<int> last(26, 0);

ll calculate(int date, int choice) {
    ll ans = 0;
    ans += s[date][choice];
    rep (i, 26) {
        ans -= last[i];
    }
    return ans;
}

vector<int> argsort(vector<int> v) {
    vector<int> indices(v.size());
    iota(indices.begin(), indices.end(), 0);
    // ソートする。
    sort(indices.begin(), indices.end(), [&v](int i1, int i2) {
        return v[i1] < v[i2];
    });
    return indices;
}

int greedy(int date) {
    vector<int> score(26, 0);
    rep (i, 26) {
        score[i] = s[date][i] + last[i] * c[i];
        last[i]++;
    }
    vector<int> indices = argsort(score);
    last[indices[25]] = 0;
    return indices[25];
}

int main() {
    cin >> d;
    c.resize(26);
    rep (i, c.size()) {
        scanf("%d", &c[i]);
    }
    s.resize(d, vector<int>(26));
    rep (i, d) {
        rep (j, c.size()) {
            cin >> s[i][j];
        }
    }
    ll default_score = 0;
    vector<int> default_res(d);
    rep (i, d) {
        default_res[i] = greedy(i);
        default_score += calculate(i, default_res[i]);
    }
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand26(0, 25), rand365(0, 364);
    /*
    rep (i, 1000) {
        int p = rand26(mt);
        int q = rand365(mt);
        auto changed_res = default_res;
        changed_res[p] = q;
        ll changed_score = 0;
        rep (j, d) {
            changed_score += calculate(j, changed_res[j]);
        }
        if (changed_score > default_score) {
            default_res = changed_res;
            default_score = changed_score;
        }
    }
     */
    rep (i, d) {
        cout << default_res[i] + 1 << endl;
    }
}




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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::string S;

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

    std::cin >> S;

    int N = S.size();
    int c1 = 0, c2 = 0;
    
    for(int i=0;i<N;++i){
        int c = i & 1;

        c1 += std::abs((S[i] - '0') - c);
        c2 += std::abs((S[i] - '0') - !c);
    }

    std::cout << std::min(c1, c2) << std::endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <map>

std::map<int, int> mp;
int n, a[201000];

bool check(int x)
{
	mp.clear();
	int len = 0;
	for(int i = 1; i <= n; i++)
	{
		if(a[i] > len) 
		{
			len = a[i];
			std::map<int, int>::iterator it = mp.end();
			if(it != mp.begin())
			{
				--it;
				while(it -> first > a[i - 1])
				{
					std::map<int, int>::iterator tmp = it;
					if(it != mp.begin()) --it, mp.erase(tmp);
					else {mp.erase(tmp); break;} 
				}
			} 
		}
		else
		{
			if(a[i] < len) len = a[i];
			int j;
			for(j = len; j >= 1; j--)
			{
				if(x == 1) return false;
				++mp[j];
				if(mp[j] != x) break;
				else mp[j] = 0; 
			}
			if(j == 0) return false;
		}
	}
	return true;
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	int l = 1, r = n + 1;
	while(l < r)
	{
		int mid = l + r >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", r);
	return 0;
}

Measured memory_bytes: 9856
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    ll ans=1;
    ll N;
    cin>>N;
    ll prev[100100];
    rep(i,100100)prev[i]=0;
    prev[0]=3;
    ll A;
    rep(i,N){
        cin>>A;
        ans=(ans*prev[A])%MOD;
        prev[A]--;
        prev[A+1]++;
    }
    cout<<ans<<endl;



	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long


struct edge{int to,cost;};
typedef pair<int,int>P;
const int INF=LLONG_MAX/100;
#define fi first
#define se second


int N,M,C;
vector<edge>G[100000];
int dist[100000];
bool used[100000];
signed main(){
    cin.tie();
    ios_base::sync_with_stdio(false);
    int sum=0;
    cin>>N>>M>>C;
    for(int i=0;i<M;i++){
        int a,b,c;
        cin>>a>>b>>c;
        G[--a].push_back((edge){--b,c});
        G[b].push_back((edge){a,c});
        sum+=c;
    }


    fill_n(dist,N,INF);
    dist[0]=0;

    priority_queue<P,vector<P>,greater<P> >Q;
    Q.push(P(0,0));

    while(Q.size()){
        P p=Q.top();Q.pop();
        if(dist[p.se]<p.fi)continue;
        for(int i=0;i<G[p.se].size();i++){
            edge &e=G[p.se][i];
            if(dist[e.to]<=p.fi+e.cost)continue;
            dist[e.to]=p.fi+e.cost;
            Q.push(P(dist[e.to],e.to));
        }
    }

    vector<P>V;
    for(int i=0;i<N;i++)V.push_back(P(dist[i],i));
    sort(V.begin(),V.end());

    int mi=sum;

    //for(int i=0;i<N;i++)cout<<"dist["<<i<<"]="<<dist[i]<<endl;

    fill_n(used,N,false);
    int cur=0;
    while(cur<N){
        int to=cur;
        while(to<N&&V[to].fi==V[cur].fi){
            used[V[to].se]=true;
            for(int i=0;i<G[V[to].se].size();i++){
                edge &e=G[V[to].se][i];
                if(!used[e.to])continue;
                sum-=e.cost;
            }
            to++;
        }
        mi=min(mi,C*V[cur].fi+sum);
        cur=to;
        //cout<<V[cur].fi<<" "<<sum<<endl;
    }

    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 17448
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x[5];
    for (int i = 0; i < 5; i++)
    {
        cin >> x[i];
    }
    for (int i = 0; i < 5; i++)
    {
        if (x[i] == 0)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include<stdio.h>

#define MAX 10000

struct Node {
  int p,l,r;};

  struct Node tr[MAX];

  int n;

  void pre(int u){
    if(u==-1)return;
    printf(" %d",u);
    pre(tr[u].l);
    pre(tr[u].r);
  }

  void in(int u){
  if(u==-1)return;
  in(tr[u].l);
  printf(" %d",u);
  in(tr[u].r);
}

  void post(int u){
    if(u==-1)return;
    post(tr[u].l);
    post(tr[u].r);
    printf(" %d",u);
  }

  int main(){

  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    tr[i].p=-1;
  }

  for(i=0; i<n; i++){
  scanf("%d%d%d",&v,&l,&r);
  tr[v].l=l;
  tr[v].r=r;
  if(l !=-1) tr[l].p = v;
  if(r !=-1) tr[r].p = v;
}

  for(i=0; i<n; i++)
    if(tr[i].p ==-1) root=i;

  printf("Preorder\n");
  pre(root);
  printf("\n");
  printf("Inorder\n");
  in(root);
  printf("\n");
  printf("Postorder\n");
  post(root);
  printf("\n");

  return 0;
  }



Measured memory_bytes: 2096
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * --------------------------------------------------
 * Main Class
 * --------------------------------------------------
 */
public class Main {

	public void exec() throws IOException {
		Scanner input = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a = input.nextInt();
		int b = input.nextInt();
		boolean ret = false;
		if(a%3==0 || b%3==0 || (a+b)%3==0){
			ret=true;
		}
		out.println(ret ? "Possible":"Impossible");
		out.flush();
		input.close();
	}

	public static void main(String[] args) throws IOException {
//		long time = System.currentTimeMillis();
		new Main().exec();
//		System.out.println(System.currentTimeMillis() - time);
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n],dp[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        dp[i]=INT_MAX;
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+2;j++)
            dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod =1e9+7;
using cd= complex < double > ;
//const ll mod = 998244353;
ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
const ll N = 2e5+5;
void solve(){
	ll n;
	cin>>n;
	n=n%1000;
	if ( n!=0)
		n=1000-n;
	cout<<n<<'\n';
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

int main() {
    int n, i;
    cin >> n >> i;

    cout << n - i + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
 
n = int(input())
lst = [int(i) for i in sys.stdin.readline().split()]
arr = np.array(lst, np.int64)

mod = 10 ** 9 + 7
x_sum = 0

for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    x_sum += (c1 * (n - c1) * 2 ** i)
    x_sum %= mod
    arr >>= 1
print(x_sum)

Measured memory_bytes: 48768
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
int main(void) {
    char S[4];
    scanf("%s",&S);
   for (int i=0;i<3;i++){
     if (S[i]==S[i+1]) {printf("Bad");
                        return 0; }

   }
   printf("Good");
 return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const ll MX=1e17;
int m;ll pw;
int cal(ll n,ll m){
	if (n==1) return m==0?10:0;
	if (n==0) return m==0;
	if (m>10*n-9) return 0;
	int d=(10-m%10)%10;
	int v=10-d-(n==pw);
	return v*cal(n/100,abs(m-n*d+d)/10);
}
int main(){
	scanf("%d",&m);int ans=0;
	for (pw=1;pw*10<=m;pw*=10);
	for (;pw<=MX;pw*=10) ans+=cal(pw,m);
	printf("%d",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;

bool getPC(vector<int> &vec){
    map<int, bool> visited;
    for(int i = 0; i < vec.size(); i++){
        for(int j = 2; j <= sqrt(vec[i]); j++){
            if(vec[i] % j) continue;
            if(visited[j]) return false;
            visited[j] = true;
            while(vec[i] % j == 0){
                vec[i] /= j;
            }
        }
        if(vec[i] != 1 && visited[vec[i]]) return false;
        visited[vec[i]] = true;
    }
    return true;
}

bool getSC(vector<int> &vec){
    int temp = vec[0];
    for(int i = 1; i < vec.size(); i++){
        temp = __gcd(temp, vec[i]);
    }
    return temp == 1;
}

int32_t main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }
    bool sc = getSC(vec);
    bool pc = getPC(vec);
    if(pc){
        cout << "pairwise coprime" << endl;
    }else if(sc){
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }
}

Measured memory_bytes: 11204
#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() {
	ll N; cin >> N;
    vector<LP> lpv;
    rep(i, N){
        ll a, b; cin >> a >> b;
        lpv.push_back(make_pair(b, a));
    }
    sort(all(lpv));
    ll suma=0;
    rep(i, N){
        suma += lpv[i].second;
        if(suma > lpv[i].first){
            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: 10608
def resolve():
    A,B,M = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    min_price = min(a) + min(b)
    for i in range (M):
        x,y,c = map(int,input().split())
        min_price = min(a[x-1] + b[y-1] - c, min_price)
    print(min_price)
resolve()

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

int main(){
    
    int n,max_move=0,count=0;
    cin >> n;
    vector<int> h(n+1);
    h.at(0) = 0;
    for(int i=1;i<n+1;i++){
        cin >> h.at(i);
        if(h.at(i) < h.at(i-1)+1){
            count++;
        }else{
            max_move = max(count,max_move);
            count = 0;
        }
    }

    max_move = max(count,max_move);

    cout << max_move << endl;

    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = Console.ReadLine().Split();
            var ret = new List<int>();
            for (int i = 1; i < b.Length; i++)
            {
                int valA = 0;
                for (int j = 0; j < i; j++)
                {
                    valA += (int.Parse(b[j]));
                }
                int valB = 0;
                for (int j = i; j < a; j++)
                {
                    valB += int.Parse(b[j]);
                }

                var retVal = valA - valB;
                ret.Add(Math.Abs(retVal));
            }
            Console.WriteLine(ret.Min());

        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N, M;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S.at(i);
    cin >> M;
    vector<string> T(M);
    rep(i, M) cin >> T.at(i);

    int sum = 0;
    for(string s : S) {
        int tmp = 0;
        for(string l : S) {
            if(s == l) tmp++;
        }
        for(string t : T) {
            if(s == t) tmp--;
        }
        sum = max(sum, tmp);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
student_positions = [input().split() for _ in range(N)]
student_positions = [[int(a[0]), int(a[1])] for a in student_positions]
check_points = [input().split() for _ in range(M)]
check_points = [[int(a[0]), int(a[1])] for a in check_points]


def calc_manhattan_distance(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


def get_nearest_point(x, candidates):
    min_distance = 10 ** 10
    for idx, candidate in enumerate(candidates):
        distance = calc_manhattan_distance(x, candidate)
        if distance < min_distance:
            min_distance = distance
            nearest_point = idx
    return nearest_point


for p in student_positions:
    print(get_nearest_point(p, check_points)+1)


Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
    int n,l;
    scanf("%d",&n);
    int i;
    int max=0,sum=0;
    for(i=0;i<n;i++){
        scanf("%d",&l);
        if(l>max){
            max=l;
        }
        sum+=l;
    }

    sum-=max;//printf("%d,%d\n",max,sum);
    if(max<sum){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    string S, T;
    cin >> S >> T;
    bool flag = true;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i])
        {
            flag = false;
        }
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
import sys
import copy
sys.setrecursionlimit(1000000000)

def dfs(start, total, usedNodes):
    if start in usedNodes:
        return 0
    
    if total <= 1:
        return 1
    
    indices = findNodeIndex(start)
    if len(indices) == 0:
        return 0

    count = 0
    for i in indices:
        nextNode = PATHS[i][1] if PATHS[i][0] == start else PATHS[i][0]
        count += dfs(nextNode, total - 1, usedNodes + [start])
    return count

def findNodeIndex(node):
    return [i for (i, row) in filter(lambda x: (x[1][0] == node or x[1][1] == node), [(i, row) for i, row in enumerate(PATHS)])]

N, M = map(int, input().split())
PATHS = [list(map(int, input().split())) for _ in range(M)]
#start = findNodeIndex(1, PATHS)

print(dfs(1, N, []))

Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  ll n,p,q,ns;
  cin >> n;
  ns = (ll)sqrt(n);
  for(ll i = ns;i > 0;i--)
  {
      if(n % i == 0)
      {
          p = i;
          q = n/p;
          break;
      }
  }
  cout << p + q - 2 << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(int argc, char *argv[]){
  long long int a, b, x;
  scanf("%lld %lld %lld", &a, &b, &x);
  //printf("%lld %lld %lld\n", a, b, x);

  long long cnt = b/x - a/x;
  if((a%x) == 0) cnt++;

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

  return 0;
}


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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n ,m, x;

    cin >> n >> m >> x;

    int a[n+1];
    int sum1 = 0 ,sum2 = 0;
    //dump( sum1);

    for( int i = 1; i <= m; i++){
        cin >> a[i];
    }

    for( int i = 1; i <= m; i++){

        if( a[i] < x ){
            sum1++;
        }
        else{
            sum2 ++;
        }
        //dump( sum1);
    }

    if( sum1 >= sum2){ cout << sum2 << endl;}
    else{ cout << sum1 << endl; }


    return 0;
}


Measured memory_bytes: 256
Mod = 10**9+7
n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort.reverse
b = gets.split.map(&:to_i).sort.reverse
i = j = 0
ans = 1
(n*m).downto(1) do |num|
    while i+1 < n && num <= a[i+1]
        i += 1
    end
    while j+1 < m && num <= b[j+1]
        j += 1
    end
    if a[i] == num
        if b[j] != num
            ans *= j+1
        end
    elsif b[j] == num
        ans *= i+1
    else
        ans *= (i+1)*(j+1)-n*m+num
    end
    ans = 0 if ans <= 0
    ans %= Mod
end
ans = 0 if a.uniq.size < n || b.uniq.size < m || a[0] != n*m || b[0] != n*m
puts ans

Measured memory_bytes: 1912
#include<iostream>
#include<string.h>
#include<algorithm>
#define ll long long 
#define r(i,n) for(ll i=0;i<n;i++)
#define rp(i,a,b) for(ll i=a;i<b;i++)
#define ret return 
#define elif else if
using namespace std;
int main(){
	while(1){
	ll n;cin>>n;
	ll a[n][3];
	memset(a,0,sizeof(a));
	rp(i,1,n){cin>>a[i][0]>>a[i][1]>>a[i][2];}
		ll time=0;
	rp(i,1,n){
		rp(j,i,n){
		if(time<a[j][1]){time=a[j][1];}
		elif(time%a[j][2]==0){}
		else{time+=a[j][2]-(time%a[j][2]);}
		time+=a[j][0];
		}cout<<time<<endl;time=0;
	}cout<<0<<endl;
		ret 0;
	}	
}

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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n);

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    double sum = 0.0;
    for(int i = 0; i < n; i++){
        sum += double(1.0 / a[i]);
    }

    cout << 1.0/sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
    double a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    if(w>=v) cout << "NO" << endl;
    else{
        if(t>= abs(a-b)/(v-w)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    

}

Measured memory_bytes: 3720
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int A[1000000], n;

int main(){
  cin >> n;
  for(int i=0;i<n;i++) scanf("%d", &A[i]);

  int q, k, sum = 0;
  cin >> q;
  for(int i=0;i<q;i++){
    scanf("%d", &k);
    if( *lower_bound(A, A+n, k) == k) sum++;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1632
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int fa[maxn+5],sz[maxn+5];

int getfa(int x)
{
    if(fa[x]==x) return x;
    return fa[x]=getfa(fa[x]);
}

int main()
{
    int n,m; scanf("%d%d",&n,&m);
    rep(i,1,n) fa[i]=i,sz[i]=1;
    rep(i,1,m) 
    {
        int x,y; scanf("%d%d",&x,&y);
        int fx=getfa(x),fy=getfa(y);
        if(fx==fy) continue;
        sz[fx]+=sz[fy];
        fa[fy]=fx;
    }
    int ans=0;
    rep(i,1,n) if(getfa(i)==i) ans=max(ans,sz[i]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5664
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int [] array = new int[3];
        for(int i = 0; i < 3; i++)
            array[i] = scan.nextInt();

        Arrays.sort(array);

        int sum = 0;
        for( int i = 1; i < 3; i++){
            sum += array[i] - array[i-1];
        }
        System.out.println(sum);
    }
}


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


typedef long long ll;
typedef pair<int, int> P;

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  vector<bool> isp(1000000, true);
  isp[0] = false;
  isp[1] = false;
  for(int i=2; i<1000000; i++){
    if(isp[i]){
      for(int j=2; i*j<1000000; j++){
        isp[i*j] = false;
      }
    }
  }
  int x;
  cin >> x;
  for(int i=x; i<1000000; i++){
    if(isp[i]){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int a, in;
	while(cin >> a, a){
	for(int i = 0; i < 9; i++){
		cin >> in;
		a -= in;
	}
	cout << a << endl;
}
	return 0;
}


Measured memory_bytes: 2984
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define N ((ll)301*1000)
#define MOD ((ll)1e9+7)

ll n,m,fac[N];

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	if(abs(n-m)>1)return cout<<"0\n",0;
	fac[0]=1;
	for(int i=1;i<N;i++)fac[i]=(fac[i-1]*i)%MOD;
	ll ans=(fac[n]*fac[m])%MOD;
	if(n==m)ans*=2,ans%=MOD;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 2560
s = input()

odd  = [ (c in 'RUD') for i, c in enumerate(s) if i % 2 == 0 ]
even = [ (c in 'LUD') for i, c in enumerate(s) if i % 2 == 1 ]

if all(odd) and all(even):
  print('Yes')
else:
  print('No')


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    string a;
    cin >> a;

    if(a[0] >= 'A' && a[0] <= 'Z'){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }
}


Measured memory_bytes: 3628
fun main(args:Array<String>) {
  val n = readLine()!!.toInt()
  val (d, x) = readLine()!!.split(" ").map { it.toInt() }

  (1..n).map { 
    ( (d-1) / readLine()!!.toInt() ) + 1
  }.sum().let{ println(it+x) }
}

Measured memory_bytes: 37856
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>

using namespace std;

int main() {
	int N;
	int A[100001];
	int B[100001];
	cin >> N;
	for (int i = 0; i < N; i++) {
		B[i]=0;
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[A[i]-1] = i+1;
	}
	for (int i = 0; i < N; i++) {
		cout << B[i] << " ";
	}
	cout << endl;
	//system("pause");
	return 0;
}

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

int main() {
  int A, B, T;
  cin >> A >> B >> T;
  int ans = 0;
  ans = T/A * B;
  cout << ans << endl;
}

Measured memory_bytes: 3592