akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
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> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 200010;

int main(){
    int n, w;
    while(scanf("%d%d", &n, &w) && n){
        int v[n], M = 0, h = 0;
        map<int, int> mp;
        rep(i, n){
            scanf("%d", &v[i]);
            int x = v[i] / w;
            ++mp[x];
            chmax(M, x);
            chmax(h, mp[x]);
        }
        double ans = 0.01;
        for(auto &p: mp) ans += 1.0 * p.se/h * (1 - 1.0/M * p.fi);
        printf("%.20lf\n", ans);
    }
}


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

int main() {
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int num = 0;
	int num_max = 0;
	int N;
	scanf("%d", &N);
	// printf("%d\n", N);

	vector<int> A(N);
	vector<vector<int>> B(N, vector<int>(N, 2));
	// B[i][j]: i番目の人曰くj番目の人は0:不親切1:正直者2:言及なし

	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		// printf("%d\n", A[i]);
		for (int j = 0; j < A[i]; j++) {
			int x, y;
			scanf("%d %d", &x, &y);
			B[i][x - 1] = y;
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			// printf("%d ", B[i][j]);
		}
		// printf("\n");
	}

	for (int a = (1 << N) - 1; a >= 0; a--) {
		num = 0;
		for (int i = 0; i < N; i++) {
			if ((a >> i) & 0b1) {  // i\in{0,N-1}が正直者と仮定
				for (int j = 0; j < N; j++) {
					if ((B[i][j] != 2) && (((a >> j) & 0b1) != B[i][j])) {
						// cout << bitset<15>(a) << " is NG in " << i << " " <<
						// j
						//      << "\n";
						goto NG;
					}
				}
			}
		}
	OK:
		for (int i = 0; i < N; i++) {
			num += ((a >> i) & 0b1);
		}
		// cout << bitset<15>(a) << " is OK: num = " << num << "\n";
		num_max = max(num_max, num);
		continue;
	NG:
		continue;
	}
	cout << num_max;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long n;
	long long ans = 0;
	cin >> n;
	for (long long i = 1; i < n; i++) {
		ans += (n - 1) / i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


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 / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;

	map<ll, ll> dic;
	ll sum = 0;
	ll ans = 0;
	dic[0] = 1;
	rep(i, 0, N) {
		ll A;
		std::cin >> A;
		sum += A;
		ans += dic[sum];
		dic[sum]++;
	}
	std::cout << ans << endl;

	return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, K; cin >> N >> K;

    int ans = 1;
    while(N>0){
        if(ans + K < ans * 2) ans += K;
        else ans*=2;
        N--;
    }
    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 v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int N;

void stringEq(vector<char> a, char mx){
	if(a.size() == N){
		rep(i, N){
			cout << a.at(i);
		}
		cout << endl;
		return;
	}
	int t = mx-97+2;
	rep(i, t){
		char b = 97 + i;
		vector<char> c = a;
		c.push_back(b);
		stringEq(c, max(b, mx));
	}
}

int main(){
	cin >> N;
	vector<char> a(0);
	char c = 'a';
	a.push_back(c);
	stringEq(a, c);
}


Measured memory_bytes: 3488
#include <stdio.h>          // putchar(), scanf()
#include <stdbool.h>

int
main(int argc, char** argv)
{
	while (true)
	{
		int x, y;
		int m, n;

		scanf("%d %d", &m, &n);
		if (m == 0 && n == 0)
			break;

		for (y = 1; y <= m; ++y)
		{
			bool f = (y & 1) ? true : false;
			for (x = 1; x <= n; ++x)
			{
				if (f)
				{
					putchar('#');
					f = false;
				}
				else
				{
					putchar('.');
					f = true;
				}
			}

			putchar('\n');
		}

		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
#define max(a, b) (a) < (b) ? (b) : (a)
long a[1010];
long DP[100008];
long N;
bool Solve (long x) 
{
    if (!x) return 0;
	long &res = DP[x];
	if (~res) return res;
	long maxx = 0;
	for (int i=0; i < N; i++) {
		if (x >= a[i]) 
		    maxx = max(maxx, Solve(x - a[i]) ^ 1);
	}
	return res = maxx;
}

int main()
{
	long k;
    cin>>N>>k;
    for(int i = 0; i < N; ++i)
        cin>>a[i];
    memset(DP, -1, sizeof(DP));
    if(Solve(k))
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<stdlib.h>
using namespace std;
    
int main(){
    int a,b,c=1,n=0;
    cin>>a>>b;
    if(b==1){
        cout<<0<<endl;
        exit(0);
    }
    for(int i=0;;i++){
        n++;
        c+=a-1;
        if(c>=b){
            break;
        }
    }
    cout<<n<<endl;
}

Measured memory_bytes: 256
{
  const main = (input: string) => {
    const r = reader(input)
    const N = r.n()
    const W = r.ns()

    const sum = W.reduce((a, b) => a + b, 0)
    let p = 0
    let min = sum

    W.forEach(v => {
      p += v
      min = Math.min(min, Math.abs(p - (sum - p)))
    })

    console.log(min)
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')

  main(getInput())
}


Measured memory_bytes: 7372
#include <iostream>
#include <math.h>
#include <vector>
#include <string>
using namespace std;
int main() {
	int N = 0;
	scanf("%d", &N);
	vector<long>v (N+1,0);

	/*
	for (int x = 1; x <= 100; x++) {
		for (int y = 1; y <= 100; y++) {
			for (int z = 1; z <= 100; z++) {
				if ((x * x + y * y + z * z + x * y + x * z + z * y) != 0 && ((x * x + y * y + z * z + x * y + x * z + z * y) < v.size())) {
					v[(x * x + y * y + z * z + x * y + x * z + z * y) - 1]++;
				}
				
			}
			
		}
		
	}*/

	for (int i = 1; i <= 130; i++) {
		for (int w = 1; w <= 130; w++) {
			for (int y = 1; y <= 130; y++) {
				if (((i * i) + (w * w) + (y * y) + (i * w) + (i * y) + (y * w)) <= v.size()) {
					v[((i * i) + (w * w) + (y * y) + (i * w) + (i * y) + (y * w))]++;

				}

			}

		}
	}
	
	for (int i = 1; i <= N; i++) {
		string str = to_string(v[i]);
		const char* l = str.c_str();
		printf(l);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 3708
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var A, B, C, K int
	fmt.Scan(&A,&B,&C,&K)
	var total int
	if (A > 0) && (A <= K) {
		total += A
		K -= A
	} else if (A > 0) && (A > K) {
		total += K
		K = 0
	}
	if B > K{
		K = 0
	} else {
		K -= B
	}
	if K != 0{
		total -= K
	}
	fmt.Println(total)
}

Measured memory_bytes: 1820
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define eps 10e-7

using namespace std;

int main(void){
	while(1){
		int n, w;
		double ans = 0.0;
		vector< int > bar;
		

		cin >> n >> w;
		if( n == 0 && w == 0 ) break;
		for(int i = 0; i <= 100; i++)
			bar.push_back(0);

		//各グラフの高さを取得する
		//同時にグラフが何本あるのかを調べる
		int num = 0;
		for(int i = 0; i < n; i++) {
			int j;
			cin >> j;
			if( j / w > num ) num = j / w;
			bar[j/w] ++;
		}

		//一番高いグラフの高さを取得する
		int max = 0;
		for(int i = 0; i < bar.size(); i++)
			if( bar[i] > max ) max = bar[i];

		//枠線等を除いたインクの量を計算する
		for(int i = 0; i <= num; i++) {
			ans += (double) ( bar[i] * ( num - i ) ) / ( double ) ( max * num );
		}
		ans += 0.01;
		printf("%lf\n", ans);
 	}

    return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

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

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		string s; cin>>s;
		vi lsum(n+1),rsum(n+1);
		rep(i,n) lsum[i+1]=lsum[i]+(s[i]=='W');
		per(i,n) rsum[i]=rsum[i+1]+(s[i]=='E');
		int res=INF;
		rep(i,n) chmin(res,lsum[i]+rsum[i+1]);
		cout<<res<<endl;
	}
}


Measured memory_bytes: 2964
// G++ MACro.cpp -std=c++14
#include <boost/multiprecision/cpp_int.hpp>
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define CIN2(x,y) int x,y;cin>>x>>y;
#define CIN3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define SCIN(x) string x;cin>>x;
#define SCIN2(x,y) string x,y;cin>>x>>y;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i];
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair
int main(){
    
    CIN(n);V a(n);VECCIN(a);
    M map_;
    REP(i,n)FOR(j,a[i]-1,a[i]+2)map_[j]++;
    int max_=0;
    FOREACH(m,map_)max_=max(max_,m.second);
    COUT(max_);

    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#define T true
#define F false

using namespace std;
int num, pth;

bool Complete(vector<bool> const &cmp) {
	int i;
	for (i = 0; i < num; i++)
		if (cmp[i] == F)
			break;
	if (i == num)
		return T;
	return F;
}

int Search(vector<vector<bool>> const &map, vector<bool> &cmp, int now) {
	if (Complete(cmp))
		return 1;
	int i = 0, ans = 0;
	for (; i < num; i++) {
		if (cmp[i] == F && map[now][i] == T) {
			cmp[i] = T;
			ans += Search(map, cmp, i);
			cmp[i] = F;
		}
	}
	return ans;
}

int main(void) {
	int i = 0, a, b;
	cin >> num >> pth;
	vector<vector<bool>> map(num, vector<bool>(num, F));
	vector<bool> cmp(num, F);
	for (; i < pth; i++) {
		scanf("%d%d", &a, &b);
		map[--a][--b] = T;
		map[b][a] = T;
	}
	cmp[0] = T;
	cout << Search(map, cmp, 0) << "\n";
	return 0;
}

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

int main() {
  char s;
  while(1){
    scanf("%c", &s);
    if(islower(s)){
      cout<<(char)toupper(s);
    }else if(isupper(s)){
      cout<<(char)tolower(s);
    }else if(s==' '){
      cout<<' ';
    }
    else if(s=='\n'){
      break;
    }else{
      cout<<s;
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3164
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	char str[10000]={};
	char x[4]={"JOI"},y[4]={"IOI"};
	while(scanf("%s",str)!=EOF){
		int i=0,ans1=0,ans2=0;
		while(str[i]){
			int a=1;
			if(str[i]=='J'){
				for(int j=0;j<3;j++){
					if(str[i+j]!=x[j])
					a=0;
				}
				if(a)
				ans1++;
			}
			if(str[i]=='I'){
				for(int j=0;j<3;j++){
					if(str[i+j]!=y[j])
					a=0;
				}
				if(a)
				ans2++;
			}
			i++;
		}
		cout<<ans1<<endl<<ans2<<endl;
	}
return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
ll r1, r2, c1, c2, ans, arr[2000020];
ll g(ll, ll);
ll f(ll, ll);
ll cal(ll, ll);
int main()
{
	ios::sync_with_stdio(false);
	arr[0] = 1;
	for(ll i = 1; i<=2000010; ++i) arr[i] = arr[i-1]*i%MOD;
    cin>>r1>>c1>>r2>>c2;
	ans = g(r2, c2)-g(r1-1, c2)-g(r2, c1-1)+g(r1-1, c1-1);
	ans = (ans+MOD)%MOD;
	cout<<ans<<"\n";
}

ll g(ll a, ll b)
{
	ll sum = 0;
	for(ll i = 1; i<=a+1; ++i) 
		sum+=f(i, b)%MOD;
	return sum%MOD;
}

ll f(ll a, ll b)
{
	//(a+b)!/a!/b!;
	return arr[a+b]*cal(arr[a], MOD-2)%MOD*cal(arr[b], MOD-2)%MOD;
}

ll cal(ll a, ll b)
{
	if(b==0) return 1;
	if(b%2) return a*cal(a*a%MOD, b/2)%MOD;
	return cal(a*a%MOD, b/2);
}

Measured memory_bytes: 15872
using System;
using System.Linq;
public class Program {
  public static void Main() {
    long N = long.Parse(Console.ReadLine());
    long[] array = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    for (long i = 0; i < N; i++) {
      array[i] -= i+1;
    }
    long b = (long)array.OrderBy(x => x).ToArray()[N/2];
    for (long i = 0; i < N; i++) {
      array[i] = Math.Abs(array[i] - b);
    }
    Console.WriteLine(array.Sum());
  }
}


Measured memory_bytes: 40224
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int n;
  cin >> n;
  map<string, bool> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    m.insert(make_pair(s, true));
  }
  cout << m.size() << endl;
}

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

int a, b, c;

int main(){
	cin >> a >> b;
	c = 0;
	if (b > 1){
		b -= a;
		c++;
		while (b > 0){
			b -= a - 1;
			c++;
		}
	}
	printf("%d\n", c);
}

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

int board[5][5];
int dp[6][4][4][4][4];
int score[4] = {0, 60, 70, 80};
const int inf = 1000000000;


int power(int s,int push) {
  if(s == 0) return 0;
  s--;
  int ps = (s + push) % 4;
  return score[ps];
}

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

  while(n--) {
    for(int i=0; i<5; ++i) {
      for(int j=0; j<5; ++j) {
    cin>>board[i][j];
      }
    }

    for(int i=0; i<6; ++i)
      for(int j=0; j<4; ++j)
    for(int k=0; k<4; ++k)
      for(int l=0; l<4; ++l)
        for(int m=0; m<4; ++m) {
          if(i) dp[i][j][k][l][m] = 0;
          else dp[i][j][k][l][m] = -inf;
        }
    dp[0][0][0][0][0] = 0;

    for(int i=1; i<6; ++i) {
      for(int x1=0; x1<=3; ++x1)
    for(int x2=0; x2<=3; ++x2)
      for(int x3=0; x3<=3; ++x3)
        for(int x4=0; x4<=3; ++x4) {
          int m = 0;
          for(int u1=0; u1<=3; ++u1)
        for(int u2=0; u2<=3; ++u2)
          for(int u3=0; u3<=3; ++u3)
            for(int u4=0; u4<=3; ++u4) {
              int mt = 0;
              mt += power(board[i-1][0], x1+u1);
              mt += power(board[i-1][1], x1+x2+u1+u2);
              mt += power(board[i-1][2], x2+x3+u2+u3);
              mt += power(board[i-1][3], x3+x4+u3+u4);
              mt += power(board[i-1][4], x4+u4);
              m = max(m, dp[i-1][u1][u2][u3][u4]+mt);
            }
          dp[i][x1][x2][x3][x4] = m;
        }
    }

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

Measured memory_bytes: 872
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ppp pair<pii,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define CL(x) memset(x,0,sizeof(x))
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x.size())
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
#define DI(x) (int)(x-'0')
#define LL_MAX (1LL<<60)
#define DB 0
#define DBG(x) if(DB)cout << #x << " : " << x << '\n'
#define PRALL(v) if(DB)for(auto it : v)cout<<v<<' '; NL;
#define NL cout<<'\n';
#define FND(S,x) (S.find(x)!=S.end())
#define bit(x,y) (!!(x&(1<<y)))
typedef long long ll;
typedef long double ld;

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

    int Xi;
    FOR(i,1,5)
    {
        cin>>Xi;
        if(!Xi)cout<<i<<'\n';
    }

    return 0;
}


Measured memory_bytes: 3608
// --------------
// Tejas Pandey  |
// 25 - 07 - 20  |
// ABC M-Solution|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a,b,c;
  int k;
  cin >> a >> b >> c >> k;
  int cnt = 0;
  while(b <= a) cnt++,b *= 2;
  while(c <= b) cnt++,c *= 2;
  if(cnt <= k) cout << "Yes\n";
  else cout << "No\n"; 
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
 map<string ,int> h;
 int n;
 cin>>n;
 string s;
 while(n--){
   cin>>s;
   h[s]++;
 }
 int mx=0;
 for(auto it:h){
   mx = max(it.second,mx);
 }
 for(auto it: h){
   if(it.second==mx)cout<<it.first<<"\n";
 }
 return 0;

}


Measured memory_bytes: 25216
n, k = map(int,input().split())
a = list(input().split())

for i in range(n, 100001):
    flg = True
    s = str(i)
    for j in range(len(s)):
        if s[j] in a:
            flg = False
            break
    if flg:
        break
print(i)

Measured memory_bytes: 9160
N, Y = map(int, input().split())
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)
            exit()
print('-1 -1 -1')

Measured memory_bytes: 2940
# https://atcoder.jp/contests/agc044/submissions/13571248

def main():
    from collections import deque

    N = int(input())
    *p, = (int(x) - 1 for x in input().split())

    H = [min(r, N - 1 - r, c, N - 1 - c) for r in range(N) for c in range(N)]  # 離席コスト
    S = [1] * N * N  # 着席

    ans = 0
    for pi in p:
        hpi = H[pi]  # piの離席コスト
        ans += hpi  # piの離席コストを加算
        S[pi] = 0  # piを空席にする

        # BFSで離席コストを更新
        dq = deque()
        dq.append((pi, hpi))
        while dq:
            x, h = dq.popleft()
            r, c = divmod(x, N)

            nx = x - N
            if r != 0 and H[nx] > h:
                H[nx] = h
                dq.append((nx, h + S[nx]))

            nx = x + N
            if r != N - 1 and H[nx] > h:
                H[nx] = h
                dq.append((nx, h + S[nx]))

            nx = x - 1
            if c != 0 and H[nx] > h:
                H[nx] = h
                dq.append((nx, h + S[nx]))

            nx = x + 1
            if c != N - 1 and H[nx] > h:
                H[nx] = h
                dq.append((nx, h + S[nx]))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 132436
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

ll n, A;

int param(ll x)
{
	ll i, j, k;
	if(x == n) return 1;
	for(i=1;i<64;i++)
	{
		if(i*A >= x) break;
		ll u=x-i*A;
		ll U, V;
		ll pro=1;
		for(j=0;j<i+1;j++)
		{
			ll now=u/(i+1);
			if(j < u%(i+1)) now++;
			if(now >= (n+pro-1)/pro) return 1;
			pro*=now;
			if(pro == 0) break;
		}
	}
	return 0;
}

int main()
{
	ll i, j, k, l;
	cin>>n>>A;
	ll low=1, high=n, mid;
	while(low <= high)
	{
		mid=(low+high)/2;
		if(param(mid)) high=mid-1;
		else low=mid+1;
	}
	cout<<low<<endl;
	return 0;
}
//*/

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define repe(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 100000000

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;
    ll n, q; cin >> n >> q;
    vector<vector<ll> > A(2000,vector<ll>(0));

    ll s, t, u;
    rep(i, q) {
        cin >> s;
        if (s == 0) {
            cin >> t >> u;
            A[t].push_back(u);
        }
        else if (s == 1) {
            cin >> t;
            if (A[t].size() > 0) {
                rep(j, A[t].size() - 1) {
                    cout << A[t][j] << " ";
                }
                cout << A[t][A[t].size() - 1] << endl;
            }
            else {
                cout << endl;
            }
        }
        else if (s == 2) {
            cin >> t;
            A[t].clear();
        }
    }
}


Measured memory_bytes: 8952
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<char> vchar;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<string>> vvstring;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================




	int X;
	cin >> X;

	cout << (X / 500) * 1000 + ((X % 500) / 5) * 5;



}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N, M;
    cin >> N >> M;
    int min_=0;
    int max_=N;

    for(int i=0; i<M; i++){
        int L,R;
        cin >> L >> R;
        min_=max(min_,L);
        max_=min(max_,R);
    }
    cout << max(0,max_-min_+1) << endl;
}

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

int main( void ) {
    int N;
    std::cin >> N;

    std::vector<int> a;
    for( size_t i = 0; i < N; ++i ) {
        int rate;
        std::cin >> rate;
        a.push_back( rate );
    }

    // 色が変わるところを示すテーブル
    // i番目のレート以上、i+1番目のレート以下で、i番の色
    // ただし3200を超えたら、好きな色をつけることができます。
    // 問題の要請では、レートの値は4800点が最大のレートなので、
    // その時も問題なく検索できるように、最後には4801を置いておきます。
    const std::vector<int> color_table = { 1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4801 };

    // 便宜的に色が9色あることにする。
    // ただし最後の人は好きな色を使えるので注意。
    int color_count[ 9 ] = { 0 };

    // 上のテーブルを使って各メンバーを色に振り分けていきます。
    for( size_t i = 0; i < N; ++i ) {
        const int rate = a[i];
        int color = -1;
        for( size_t j = 0; j < color_table.size() - 1; ++j ) {
            const int min = color_table[ j ];
            const int max = color_table[ j + 1 ];

            if( min <= rate && rate < max ) {
                color = j;
                break;
            }
        }
        // 指定の色を持った人を1人増やす
        color_count[ color ] += 1;
    }

    // 決め打ちの色になってる人がいるなら、その個数をみる
    int constant_color_count = 0;
    for( size_t i = 0; i < 8; ++i ) {
        if( color_count [ i ] > 0 ) {
            constant_color_count += 1;
        }
    }

    if( constant_color_count == 0 && color_count[ 8 ] == 0 ) {
        std::cout << 0 << " " << 0 << std::endl;
    } else if ( constant_color_count == 0 && color_count[ 8 ] != 0 ) {
        std::cout << 1 << " " << color_count[ 8 ] << std::endl;
    } else if ( constant_color_count != 0 && color_count[ 8 ] == 0 ) {
        std::cout << constant_color_count << " " << constant_color_count << std::endl;
    } else if ( constant_color_count != 0 && color_count[ 8 ] != 0 ) {
        std::cout << constant_color_count << " " << constant_color_count + color_count[ 8 ] << std::endl;
    }

    return 0;
}

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

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

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 (b<a) { a=b; return 1; } return 0; }

using namespace std;
int x1,x2,x3,x4,y1,y2,y3,y4,hor,ver;
int main(){
    cin >> x1 >> y1 >> x2 >> y2;
    hor=x2-x1;
    ver=y2-y1;
    x3=x2-ver;
    y3=y2+hor;
    x4=x3-hor;
    y4=y3-ver;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[3010][3010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;

    rep(i, s.size()) {
        rep(j, t.size()) {
            if (s[i] == t[j])
                dp[i + 1][j + 1] = dp[i][j] + 1;
            else 
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        }
    }
    string ans;
    int slen = s.size();
    int tlen = t.size();
    while(slen > 0 && tlen > 0 && dp[slen][tlen] > 0) {
        //cout << (dp[slen][tlen] == dp[slen - 1][tlen]) << " " << (dp[slen][tlen] == dp[tlen - 1][tlen]) << " " << ans << endl;
        if (dp[slen][tlen] == dp[slen - 1][tlen]) slen--;
        else if (dp[slen][tlen] == dp[slen][tlen - 1]) tlen--;
        else {
            slen--; tlen--;
            ans = s[slen] + ans;
        } 
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
int main() {
    std::string s;
    std::cin >> s;
    std::string::size_type pos_a = 0;
    std::string::size_type pos_z = s.size()-1;
    while ((pos_a = s.find("A", pos_a)) != std::string::npos) {
        while ((pos_z = s.rfind("Z", pos_z)) != std::string::npos) {
            std::cout << (pos_z - pos_a +1) << std::endl;
            return 0;
        }
    }
}

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

int main()
{
	int n;
	char s[100];
	cin>>n;
	for(int i=0;i<n;i++) cin>>s[i];
	
	int f=0;
	for(int i=0;i<n;i++){
		if(s[i]=='Y') f=1;
	}
	
	cout<<(f? "Four":"Three")<<endl;
	
	return 0;
}


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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  lli n, m; cin >> n >> m;
  if(2 * n >= m) cout << m / 2 << "\n";
  else{
    lli tmp = m - 2 * n;
    cout << n + (tmp / 4) << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define rep1(i,n) for(int i=1;i<=((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef long long ll;
 
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;
 
ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
 
		b>>=1;
	}
	return res;
}
void exgcd(int a,int b,int &x,int &y,int &d)
{
    if (b==0) x=0,y=1,d=a;
    else exgcd(b,a%b,y,x,d),y-=(a/b)*x;
}
int n;
int a[maxn];
int main()
{
    IOS;
    while(cin>>n)
    {
        ll d=0,sum=0;
        rep(i,n)
        {
            cin>>a[i];
            if(a[i]<0) d++;
            a[i]=abs(a[i]);
            sum+=a[i];
        }
        sort(a,a+n);
        if(d%2) cout<<sum-2*a[0]<<"\n";
        else cout<<sum<<"\n";
    }
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int n, i;
    cin >> n >> i;
    cout << n + 1 - i << endl;
    return 0;
}


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


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
int a[200009],b[200009];
bool vis[200009];
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	rep(i,n) cin>>a[i];
	priority_queue<pii> q;
	ll ans = 0;
	rep(i,n){
		int x;cin>>x;b[i] = x;
		if(b[i]==a[i]) vis[i]=1;
		else q.push(mp(x,i));
	}
	while(!q.empty()){
		pii z = q.top();
		q.pop();
		int i = z.snd,j=(i+n-1)%n,k=(i+1)%n;
		if(z.fst-b[j]-b[k]<a[i]){
			cout<<-1;
			return 0;
		}
		int lst = a[i];
		if(!vis[j]) lst = max(lst,b[j]-1);
		if(!vis[k]) lst = max(lst,b[k]-1);
		int d = (z.fst-lst+b[j]+b[k]-1)/(b[j]+b[k]);
		d = max(1,d);
		ans+=d;
		b[i]-=d*(b[j]+b[k]);
		if(b[i]<a[i]){
			cout<<-1;
			return 0;
		}
		else if(b[i]==a[i]) vis[i]=1;
		else q.push(mp(b[i],i));
	}
	cout<<ans;	
	return 0;
}



Measured memory_bytes: 3956
#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a+b<=16 && a>=0 && b>=0){
        if(a<=8 && b<=8){
            printf("Yay!\n");
        }
        else{
            printf(":(\n");
        }

    }
    return 0;
}


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

def solve():
    N = int(input())
    D = list(map(int, input().split()))

    D.sort()
    i = N//2

    if D[i] != D[i-1]:
        # 同じ数になるように分けることが可能
        print(D[i]-D[i-1])
        return
    print(0)
    

if __name__ == "__main__":
    solve()


Measured memory_bytes: 14428
#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  int N, tmp;
  cin >> N;
  vector<pair<pair<string, int>,int>> P(N);
  for( int i=0; i<N; i++ ){
    cin >> P[i].first.first >> tmp;
    P[i].first.second = -tmp;
    P[i].second = i+1;
  }

  sort( P.begin(), P.end() );
  for( int i=0; i<N; i++ )
    //printf( "%s %d %d\n", P[i].first.first.c_str(), -P[i].first.second, P[i].second );
    cout << P[i].second << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x;cin>>x;
  for(long long int a=-1000;a<1000;a++)
  {
  for(long long int b=-1000;b<1000;b++)
  {
    if(
      (a-b)*
      (a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b)
      ==x
    ){
      cout<<a<<" "<<b<<endl;
      return 0;
    }
  }
  }
  return 0;
}



Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
//#define INF 500000000
using namespace std;
const int Max=100;
const long long INF=(1ll<<32);
int V,E;
long long D[Max][Max];
vector<int>G[Max];

void Floyd(){
    for(int k=0;k<V;k++)
        for(int i=0;i<V;i++) {
            if (D[i][k] == INF)continue;
            for (int j = 0; j < V; j++) {
                if(D[k][j]==INF)continue;
                D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
            }
        }
}

int main()
{
    int s,t,d;
    cin>>V>>E;
    for(int i=0;i<V;i++)
        for(int j=0;j<V;j++)
        {
            if(i==j){
                D[i][j]=0;
                continue;
            }
            D[i][j]=INF;
        }

    for(int i=0;i<E;i++)
    {
        cin>>s>>t>>d;
        D[s][t]=d;
    }
    Floyd();
    for(int i=0;i<V;i++)
        if(D[i][i]<0){
            cout<<"NEGATIVE CYCLE"<<endl;
            return 0;
        }
    for(int i=0;i<V;i++)
    {
        for(int j=0;j<V;j++){
            if(j)cout<<' ';
            if(D[i][j]==INF){
                cout<<"INF";
                continue;
            }
            cout<<D[i][j];
        }

        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3192
// 161 D

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

void printVec(vector<ll> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int main() {
  int k;
  cin >> k;
  vector <ll> runrun;

  for(int i = 1; i <= 9; i++) {
    runrun.push_back(i);
  }
  int counter = 0;
  ll push_data;
  
  while (true) {
    if (runrun.size() >= k) {
      cout << runrun[k - 1] << endl;
      return 0;
    }
    ll data = runrun[counter];
    counter = counter + 1;
    // cout << "i = " << counter << ", data = " << data << endl;
    ll data_i;
    data_i = data % 10;
    // cout << "data = " << data << ", data_i = " << data_i << endl;
    ll data_p = data_i - 1;
    if (data_p < 0 || data_p > 9) {
      ;
    } else {
      push_data = data * 10 + data_p;
      runrun.push_back(push_data);
    }

    data_p = data_i + 0;
    if (data_p < 0 || data_p > 9) {
      ;
    } else {
      push_data = data * 10 + data_p;
      runrun.push_back(push_data);
    }

    data_p = data_i + 1;
    if (data_p < 0 || data_p > 9) {
      ;
    } else {
      push_data = data * 10 + data_p;
      runrun.push_back(push_data);
    }

  }
  return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

class Main{
     public static void main(String[] args){

        Scanner as = new Scanner(System.in);
        int x = as.nextInt();
        int i=0;

        while(x!=0){
           i++;
           System.out.println("Case "+i+": "+x);
           x = as.nextInt();
 
 
   }
 }
 
}

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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int h, w, k;
	cin >> h >> w >> k;

	char a[h][w];
	int res[h][w];
	memset(res, 0, sizeof res);
	int it = 1;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			cin >> a[i][j];
			if(a[i][j] == '#')
				res[i][j] = it++;
		}
	}

	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(res[i][j] != 0){
				int color = res[i][j];
				int kx = i - 1;
				while(kx >= 0 && !res[kx][j]) res[kx][j] = color, kx--;
				int lf = j - 1, rg = j + 1;
				while(lf >= 0 && !res[i][lf]){
					int up = i;
					while(up >= 0 && !res[up][lf]) res[up][lf] = color, up--;
					lf--;
				}
				while(rg < w && !res[i][rg]){
					int up = i;
					while(up >= 0 && !res[up][rg]) res[up][rg] = color, up--;
					rg++;
				}
			}
		}
	}

	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(res[i][j] == 0) res[i][j] = res[i - 1][j];
			cout << res[i][j] << " \n"[j == w - 1];
		}
	}


	
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
#define sqr(x) ((x)*(x))
#define pb push_back 
const int N=1000002,M=998244353;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%M)if(y&1)z=1ll*z*x%M;return z;}
void inc(int &x,int y){x+=y;if(x>=M)x-=M;}void dec(int &x,int y){x-=y;if(x<0)x+=M;}
void Max(int &x,int y){if(y>x)x=y;}void Min(int &x,int y){if(y<x)x=y;}
//struct node{int to,ne;}e[];
//void add(int x,int y){e[++tot]=(node){y,h[x]},h[x]=tot;}
double a[100];
int n,i;
signed main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%lf",&a[i]);
	sort(a+1,a+n+1);
	for (i=2;i<=n;i++) a[i]=(a[i-1]+a[i])/2;
	printf("%.9lf",a[n]);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

string s;

map<char, int> cnt;

int main() {
    cin >> s;
    
    int n = s.size();

    for (auto& c : s) {
        cnt[c]++;
    }

    for (auto& kv : cnt) {
        if (kv.SS > (n+2) / 3) {
            printf("NO\n");
            return 0;
        }
    }

    printf("YES\n");
    return 0;
}

Measured memory_bytes: 512
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,t=map(int, input().split())
    costl=[]
    for i in range(n):
        c,tt=map(int, input().split())
        if tt<=t:
            costl.append(c)
    if len(costl)==0:
        print('TLE')
    else:
        print(min(costl))
resolve()

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

int main() {
    ll N; cin >> N;
    string s; cin >> s;
    ll cntr = 0;
    ll cntr2 = 0;
    rep(i, N){
        if(s.at(i)=='R') cntr++;
    }
    rep(i, N){
        if(s.at(i)=='R' && i+1<=cntr) cntr2++;
    }
    cout << cntr - cntr2 << endl;
}

Measured memory_bytes: 3704