akhauriyash/Code-Regression huggingface dataset:
import sys
from heapq import heappush, heappop
#input = sys.stdin.readline

def main():
    l,r=map(int,input().split())
    if r-l>=2019:
        print(0)
    else:
        ans=[]
        for i in range(l,r):
            for j in range(i+1,r+1):
                ans.append((i*j)%2019)
        ans.sort()
        print(ans[0])

if __name__ == '__main__':
    main()

Measured memory_bytes: 81420
def chunked(iterable, n):
    return [iterable[x:x + n] for x in range(0, len(iterable), n)]

s=input()
for i in range(1,len(s)):
    a=s[:(-1*i)]
    if len(a)>1:
        li=chunked(a,(len(a)+1)//2)
        
        if li[0]==li[1]:
            print(len(a))
            quit()
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto&& u : a) cin >> u;
  rep(i, n) b[i] = a[i];
  sort(begin(a), end(a));
  int m0 = a[n - 1], m1 = a[n - 2];

  rep(i, n) {
    if (b[i] == m0)
      cout << m1 << endl;
    else
      cout << m0 << endl;
  }
}

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int n;
  cin>>n;
  int ans=n%10;
  if (ans==3) cout<<"bon"<<endl;
  else if(ans==0||ans==1||ans==6||ans==8) cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
  return 0;
}


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

int main(void){
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    if (a<b && b<c){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    cout << endl;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    vec<int> C(N-1),S(N-1),F(N-1);
    rep(i,N-1) cin >> C[i] >> S[i] >> F[i];
    
    rep(i,N-1){
        int nows = S[i] + C[i];
        for(int j=i+1;j<N-1;++j){
            if(nows >= S[j]) nows = nows+ (F[j] - ((nows-S[j])%F[j]))%F[j] + C[j];
            else nows = S[j] + C[j];
        }
        cout << nows << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,a[101],key,j;
    cin>>n;
    for(int i=0;i<n;i++)
        cin >>a[i];
    for(int i=0;i<n;i++){
        cout <<a[i];
        if(i<n-1) cout <<" ";
    }
    cout << endl;
    for(int i=1;i<n;i++)
    {
        
         key=a[i];
         j=i-1;
         while(j>=0 && a[j]>key){
             a[j+1]=a[j];
             j--;
         }
         a[j+1]=key;
         for(int k=0;k<n;k++)  {
                    cout << a[k];
                    if(k<n-1) cout <<" ";}
         cout <<endl;
    }   
    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
// #define fore(i,a) for(auto &i:a)
// #define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// 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 main()
{
  int K;
  cin>>K;
  string S;
  cin>>S;
  
  if(S.size()<=K){
    cout<<S<<endl;
  }
  else{
    cout<<S.substr(0,K)<<"..."<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int s[100][100] = { 0 };
int dp[100][100] = { 0 };

int sum(int x1, int y1, int x2, int y2) {
	int sum;
	sum = dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1];
	return sum;
}

int main(void) {
	int n,max=0,a=0;
	int i,j,k,l;
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++)
			scanf("%d",&s[i][j]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++)
			dp[i][j] = s[i][j];
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) 
			dp[i][j] += dp[i][j - 1];
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < n ; j++) 
			dp[i][j] += dp[i - 1][j];
	}

	a = sum(0, 0, 0, 0);
	max = a;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			for (k = i; k < n; k++) {
				for (l = j; l < n; l++) {
					a = sum(i,j,k,l);
					if (max < a)
						max = a;
				}
			}
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 676
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    int h,n;
    cin >> h >> n;
    vector <pair<int,int>> ar(n);
    for(int i = 0; i < n; ++i){
        cin >> ar[i].first >> ar[i].second;
    }
    sort(all(ar));
    vector <ll> dp(h + 1,(ll)2e18);
    dp[0] = 0;
    for(int i = 1; i <= h; ++i){
        for(int j= 0; j < n; ++j){
                dp[i] = min(dp[i], dp[max(0,i - ar[j].first)] + ar[j].second);
        }
    }
    //for(auto i : dp)
        //cout << i << " ";
    //cout << '\n';
    cout << dp[h] << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
char s[510000];
int main(){
    int k=0;
    while(cin>>s[k]){
       if(s[k]=='i')break;
        k++;
    }
    if(k%2!=0){
        printf("No");
        return 0;
	}
    for(int i=0;i<k/2;i++){
        if(s[i]=='b'&&s[k-i-1]!='d'){
            printf("No");
            return 0;
        }
        if(s[i]=='d'&&s[k-i-1]!='b'){
            printf("No");
            return 0;
        }
        if(s[i]=='q'&&s[k-i-1]!='p'){
            printf("No");
            return 0;
        }
        if(s[i]=='p'&&s[k-i-1]!='q'){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N;
	cin >> N;
	VL a(N);
	int c2 = 0, c4 = 0;
	REP(i, N) {
		cin >> a[i];
		if (a[i] % 2LL == 0)c2++;
		if (a[i] % 4LL == 0)c4++;
	}
	string S = "No";
	if ((N - (c2 - c4) + 1)/2 <= c4) S = "Yes";
	if (N / 2 <= c4) S = "Yes";
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}
  struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};
int main(){
 ll n;
 cin>>n;
 
 vcl a(n);
 vcl b(n);
 vcl c(n+1);
 ll ans=0;
 rep(i,n){cin>>a[i]>>b[i];
if(a[i]==b[i]) ans++;
else ans = 0;
c[i+1] = max(c[i],ans);
 }

if(c[n]>=3) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}




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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    vector<int> v(3);
    REP(i, 3) {
        cin >> v[i];
    }
    swap(v[0], v[1]);
    swap(v[0], v[2]);
    REP(i, 3) {
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		String S = input.next();
		for (int i = 0; i < S.length(); i+=2) {
			System.out.print(S.substring(i,i+1));
		}
	}
}

Measured memory_bytes: 31332
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long int ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int mod = 1e9+7;
const int inf = 1e9+9;
const ll MOD = 1e9+696969;
const long long INF = 1e18+3;
#define maxn 300100
string s;
bool jest[1500];
int ile = 26, n;
int newbegin[maxn], dp[maxn], wynLen;

inline bool tryMatch(int i, int skad, int lit)
{
	while (skad < n && s[skad] != lit + 'a') ++skad;
	if (skad == n) return 1;
	int bedzie = dp[skad + 1] + 1;
	if (bedzie + i <= wynLen) return 1;
	return 0;
}

int main()
{
	boost;
	cin >> s;
	n = s.length();
	string ret = "";
	for (int i=n-1; i>=0; --i)
	{
		dp[i] = dp[i + 1];
		if (!jest[s[i] - 'a']) --ile;
		jest[s[i] - 'a'] = 1;
		if (ile == 0)
		{
			dp[i]++;
			FOR(j, 0, 25) jest[j] = 0;
			ile = 26;
		}
	}
	
	wynLen = dp[0] + 1;
	//optymalna dlugosc wyniku to "wynLen"
	newbegin[0] = 0;
	
	string overallRet = "";
	for (int i=0; i<wynLen; ++i)
	{
		for (int j=0; j<26; ++j) 
			if (tryMatch(i + 1, newbegin[i], j))
			{
				int sz = newbegin[i];
				while (sz < n && s[sz] != j + 'a') ++sz;
				newbegin[i + 1] = sz + 1;
				overallRet += (char)(j + 'a');
				break;
			}
	}
	
	cout << overallRet;
}


Measured memory_bytes: 1428
<?php

        
    $list = explode(" ", trim(fgets(STDIN)));

   

    if(($list[0]== $list[1] && $list[2]== $list[1]) 
    ||  ($list[0]!= $list[1] && $list[2]!= $list[1] && $list[2]!= $list[0] )){
        echo "No\n";
    }else{
        echo "Yes\n";
    }


Measured memory_bytes: 4604
#include <stdio.h>

int main() {

	int i, j = 0, n, min[100], max[100], sum[100] = {0};
	int point[1000], ans[100];

	while (1) {
		scanf("%d", &n);

		if (n == 0)
			break;

		for (i = 0; i < n; i++) {
			scanf("%d", &point[i]);
		}

		min[j] = point[0];
		max[j] = point[0];

		for (i = 0; i < n; i++) {
			if (max[j] < point[i]) {
				max[j] = point[i];
			}
			if (min[j] > point[i]) {
				min[j] = point[i];
			}
			sum[j] += point[i];
		}
		ans[j] = (sum[j] - min[j] - max[j])/(n-2);
		j++;
	}

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

	return 0;
}

Measured memory_bytes: 604
stdin.ReadLine()
|> fun x -> x.Split(' ')
|> Array.map int
|> fun x -> (x.[0], x.[1] / 1000)
|> fun (n, y) ->
  [0..n]
  |> Seq.tryFind (fun a ->
    (y - n - 9 * a) % 4 = 0 &&
       (y - n - 9 * a) >= 0 &&
       n - a - (y - n - 9 * a) / 4 >= 0
  )
  |> fun a ->
    match a with
    | Some a ->
      (y - n - 9 * a) / 4
      |> fun b -> sprintf "%d %d %d" a b (n - a - b)
    | None -> "-1 -1 -1"
|> printfn "%s"


Measured memory_bytes: 14288
#include <stdio.h>
int main() {
	int a, b, c, k, ans = 0;
	scanf("%d%d%d%d", &a, &b, &c, &k);
	if (a >= k) {
		ans = k;
	} else if (a + b >= k) {
		ans = a;
	} else {
		ans = a - (k - a - b);
	}
	printf("%d\n", ans);
	return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vpii        vector< pii >
#define vi          vector<ll>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll)x.size()
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

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


void Main()
{
	string S, T;
	cin >> S >> T;
	ll diff = 0;
	rep(i, 0, S.size()) {
		if (S[i] != T[i]) diff++;
	}
	cout << diff << endl;
}


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

	Main();
	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  string S; cin >> S;
  ll count = 0;
  for (char c : S) {
    if (c == 'o') {
      count += 1;
    }
  }
  cout << (count+(15-S.length()) >= 8 ? "YES" : "NO") << endl;
  return 0;
}


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

int main() {


	int a, b;	cin >> a >> b;
	for (ll i = 1; i <= 10000000; i++) {

		if ((i * 8) / 100 == a && (i * 10 / 100) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;


	return 0;
}

Measured memory_bytes: 256
// in the name of Allah

#include<bits/stdc++.h>
#define ll long long
#define int long long
#define F first
#define S second
#define MP make_pair
#define pii pair<int, int>
#define p push_back

using namespace std;

const ll mx=2e5+5;

ll n, x, dp[mx];
map<ll, ll>c;
int an(int a, int b){
	if(a==1){
		if(b>=1) return 1;
		else return 0;
	}
	if(b==a/2+1){
		return(1+an(a/2-1, a/2-1));
	}
	if(b<a/2+1){
		return(an(a/2-1, b-1));
	}
	if(b>a/2+1){
		return(c[a/2-1]+1+an(a/2-1, b-(a/2+1)));
	}	
}
int32_t main(){
	ios::sync_with_stdio(false);
	cin>>n>>x;
	dp[0]=1;
	c[1]=1;
	for(int i=1;i<=n;i++){
		dp[i]=dp[i-1]*2+3;
		c[dp[i]]=c[dp[i-1]]*2+1;
		//cout<<dp[i]<<" "<<c[dp[i]]<<endl;
	}	
//	cout<<an(5, 5)<<endl;
	cout<<an(dp[n], x)<<endl;
	//cout<<dp[n]<<endl;
	return 0;
}

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

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

using namespace std;

int n;

int main(){
	cin >> n;
	
	rep(i, n){
		int k, x;
		cin >> k >> x;
		if(k % 2 == 0){
			x = 127 - x;
		}
		cout << x + (k - 1) * 127 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define endl "\n"
#define count_ones __builtin_popcountl
#define piii pair<int,pair<int,int>>
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
inline void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
/* -------------------------------------- */
/* -------------------------------------- */
int main() {
	boost();
	ll n;cin>>n; ll a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int count, maxcount=0;
	for(int i=0;i<n-1;i++){
		count=0;
//		cout<<a[i]<<" ";
		while(a[i]>=a[i+1]){
			i++;count++;
		}
		maxcount=max(maxcount,count);
	}	
	cout<<maxcount;
}

Measured memory_bytes: 1024
from itertools import combinations

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ret = float('inf')
for ce in combinations(range(N), (N + 1) // 2) :
  e, o = [], []
  for i in range(N) :
    if i in ce :
      if i % 2 == 0 :
        e.append([A[i], i])
      else :
        e.append([B[i], i])
    else :
      if i % 2 == 0 :
        o.append([B[i], i])
      else :
        o.append([A[i], i])
  
  e.sort()
  o.sort()
  s = []
  for i in range(N // 2) :
    s.append(e[i])
    s.append(o[i])
  if N % 2 != 0 :
    s.append(e[N // 2])
  
  for i in range(1, N) :
    if s[i][0] < s[i-1][0] :
      break
    
  else :
    tmp = 0
    for i in range(N) :
      for j in range(i) :
        if s[j][1] > s[i][1] :
          tmp += 1
    ret = min(ret, tmp)
    
if ret == float('inf') :
  print(-1)
else :
  print(ret)

Measured memory_bytes: 48284
import os
import sys
from collections import deque

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

que = deque()
for i in range(N):
    if i % 2 == 0:
        que.append(A[i])
    else:
        que.appendleft(A[i])
if N % 2:
    que.reverse()
print(*que)


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

int main() {
    int n;
    cin >> n;
    vi c(n-1), s(n-1), f(n-1), t(n, 0);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
    int ct, wt;
    rep(i, n) {
        if (i == (n-1)) {
            cout << 0 << endl;
            continue;
        }
        ct = 0;
        for (int ii = i; ii < (n-1); ii++) {
            wt = max(s[ii] - ct, 0);
            wt = max(wt, (ct % f[ii]) ? (f[ii] - (ct % f[ii])) : 0);
            ct += wt + c[ii];
        }
        cout << ct << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	int N, x; cin >> N >> x;
	vector<int> a(N); rep(i, 0, N)cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	rep(i, 0, N) {
		if (x >= a[i]) {
			ans++;
			x -= a[i];
		}
		else break;
	}
	if (x > 0 && ans == N)ans--;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <string>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;

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

int main()
{
  vector<ll> divisor;
  ll N,sum=0;
  cin >> N;
  for(ll i=sqrt(N);i>=1;i--){
    if(N%i == 0){
      divisor.push_back(i);
      divisor.push_back(N/i);
    }
  }
  sort(divisor.begin(), divisor.end());
  for(int i=1;i<divisor.size();i++){
    if(divisor[i] == 1) continue;
    if(N/divisor[i] == N/(divisor[i]-1)) sum += divisor[i]-1;
  }
  cout << sum;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};

const int N=2e5+5,OO=1e18;
int a[N],b[N];
int p[N],s[N];
int32_t main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    {
        vector<pii> v;//{start,lad}
        for(int i=1;i<=n;++i){
            p[i]=p[i-1]+1;
            b[i]=a[i]*-2;
            if(v.empty()){
                v.pb(1,OO);
            }else{
                int l=b[i-1],c=b[i];
                if(l>c){
                    while(l>c){
                        l*=4;
                        int sz=i-v.back().f;
                        p[i]+=2*sz;
                        v.back().s--;
                        if(!v.back().s)v.pop_back();
                    }
                }else{
                    int pot=0;
                    while(c*4>=l)pot++,c*=4;
                    if(pot)v.pb(i,pot);
                }
            }
        }
    }
    {
        vector<pii> v;//{start,lad}
        for(int i=n;i>=1;--i){
            s[i]=s[i+1];
            if(v.empty()){
                v.pb(n,OO);
            }else{
                int l=a[i+1],c=a[i];
                if(l<c){
                    while(l<c){
                        l*=4;
                        int sz=v.back().f-i;
                        s[i]+=2*sz;
                        v.back().s--;
                        if(!v.back().s)v.pop_back();
                    }
                }else{
                    int pot=0;
                    while(c*4<=l)pot++,c*=4;
                    if(pot)v.pb(i,pot);
                }
            }
        }
    }
    int ans=OO;
    for(int i=0;i<=n;++i)upn(ans,p[i]+s[i+1]);
    cout<<ans<<'\n';


    return 0;
}


Measured memory_bytes: 9832
import sys
from operator import itemgetter

input = sys.stdin.readline


def main():
    N = int(input())
    LR = [None] * N
    for i in range(N):
        X, L = map(int, input().split())
        LR[i] = (X - L, X + L)

    LR.sort(key=itemgetter(0))
    ans = N
    cur_R = LR[0][1]
    for L, R in LR[1:]:
        if L < cur_R:
            ans -= 1
            cur_R = min(cur_R, R)
        else:
            cur_R = R

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24072
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	h, _ := nextInt(), nextInt()
	c := make([]string, h)
	for i := range c {
		c[i] = next()
	}
	for i := 0; i < h; i++ {
		puts(c[i])
		puts(c[i])
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
from math import *
s=str(input())
arr=[]
for i in range(len(s)):
    arr.append(int(s[i]))
n=int(input())
val=n
i=0
ans=1
flag=0
while(flag==0):
    ans=ans*arr[i]
    if(s[i]=='1'):
        if(val==1):
            flag=1
            break
        else:
            val-=1
    else:
        if(log(val,ans)<=pow(10,15)*5):
            flag=1
            break
    i+=1
print(arr[i])

Measured memory_bytes: 3064
class Combination:
    def __init__(self, mod, max_num):
        self.mod = mod
        self.fac = [0] * max_num
        self.finv = [0] * max_num
        self.inv = [0] * max_num

        self.fac[0], self.fac[1] = 1, 1
        self.finv[0], self.finv[1] = 1, 1
        self.inv[1] = 1

        for i in range(2, max_num):
            self.fac[i] = self.fac[i-1] * i % mod
            self.inv[i] = mod - self.inv[mod % i] * (mod // i) % mod
            self.finv[i] = self.finv[i - 1] * self.inv[i] % mod

    def calc(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n] * (
            self.finv[k] * self.finv[n - k] % self.mod) % self.mod


x, y = map(int, input().split())

if (2 * x - y) % 3 != 0:
    print(0)
    exit()

n = (2 * x - y) // 3
m = (2 * y - x) // 3

com = Combination(1000000007, 1000000)

print(com.calc(n+m, n))


Measured memory_bytes: 62192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  sort(all(a));
  double ans = a[0];
  rep3(i, 1, n) ans = (ans + a[i]) / 2.0;
  cout << ans << endl;
}


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

int main(){
  int ja,jb,sa,sb,ra,rb,ea,eb,s,t;
  cin >> ja >> sa >> ra >> ea;
  cin >> jb >> sb >> rb >> eb;

  s=ja+sa+ra+ea;
  t=jb+sb+rb+eb;

  if (s>t) {
    cout << s << endl;
  } else {
    cout << t << endl;
  }

  return 0;
}

Measured memory_bytes: 3076
h,n = map(int, input().split( ))
m = []
mxa = 0
for _ in range(n):
    ai,bi = map(int, input().split( ))
    m.append((ai,bi))
    mxa = max(mxa,ai)
inf = 10**10
dp = [inf for _ in range(h+1+mxa)]
dp[0] = 0
for i in range(h+mxa):
    for j in range(n):
        if i+m[j][0]<=h+mxa:
            dp[i+m[j][0]] = min(dp[i+m[j][0]],dp[i]+m[j][1])
print(min(dp[h:]))


Measured memory_bytes: 41836
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
m = 0

for i in range(n):
  if a[i] >= b[i]:
    m += b[i]
  else:
    b[i] -= a[i]
    if a[i+1] < b[i]:
      m += a[i+1]+a[i]
      a[i+1]=0
    else:
      a[i+1] -= b[i]
      m += b[i] + a[i]
      
print(m)

Measured memory_bytes: 19244
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  long long n,x;
  cin>>n;
  vector<long long>v;
  for(long long i=0; i<n; i++)
  {
    cin>>x;
    v.push_back(x);
  }
  long long h=0;
  for(long long i=1; i<n; i++)
  {
    if(v[i-1]>v[i])
    {
      h=h+v[i-1]-v[i];
      v[i]=v[i-1];
    }
  }
  cout<<h;
  return(0);
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<LL> t(n),v(n);
  for(int i=0;i<n;i++){
    cin >> t[i];
  }
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  vector<LL> ji(n+1);
  ji[0]=ji[n]=0;
  for(int i=1;i<=n;i++){
    ji[i]=ji[i-1]+t[i-1];
  }
  vector<LL> tv(ji[n]+1,0),hi(ji[n]+1,0),mi(ji[n]+2,0);
  LL now=1;
  for(int i=1;i<=ji[n];i++){
    tv[i]=v[now-1];
    if(i==ji[now]){
      now++;
      // tv[i]=min(tv[i],v[now-1]);
    }
  }
  tv[0]=0;
  // for(int i=0;i<=ji[n];i++) cout << tv[i] << " ";
  // cout <<endl;
  hi[0]=0;
  mi[ji[n]+1]=0;
  for(int i=1;i<=ji[n];i++){
    hi[i]=min(hi[i-1]+1,tv[i]);
  }
  for(int i=ji[n]-1;i>=0;i--){
    mi[i]=min(mi[i+1]+1,tv[i+1]);
  }
  vector<LL> ansv(ji[n]+1,0);
  for(int i=0;i<=ji[n];i++){
    ansv[i]+=min(hi[i],mi[i]);
  }
  // for(int i=0;i<=ji[n];i++) cout << ansv[i] << " ";
  // cout <<endl;
  LD ans=0;
  for(int i=1;i<=ji[n];i++){
    if(ansv[i]!=ansv[i-1]) ans+=((LD)ansv[i]+ansv[i-1])/2;
    else if(ansv[i]<tv[i]) ans+=(LD)ansv[i]+0.25;
    else ans+=ansv[i];
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 896
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-17 09:52:29
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=610,mod=1000000007;
int n,f[N][N][N],a[N],s[N],m,_n,p[N],sp[N];
int solve(int i,int a,int b)
{
	if(i>n) return a==0&&b==0;
	if(a<0||b<0) return 0;
	int v=n/2-m-(i-1-sp[i-1]-(sp[i-1]-b)-a)/2;
	if(v<0) return 0;
	if(f[i][a][b]) return f[i][a][b]==-1?0:f[i][a][b];
	int &ans=f[i][a][b];
	if(p[i]) ans=(solve(i+1,a,b+1)+solve(i+1,a-1,b))%mod;
	else ans=(solve(i+1,a+1,b)+solve(i+1,a,b-1)*1ll*b+solve(i+1,a-1,b)*1ll*v)%mod;
	if(ans==0) ans--;
	return f[i][a][b]==-1?0:f[i][a][b];
}
int main()
{
	n=read(); _n=n;
	fr(i,1,n)
	{
		int x=read(),y=read();
		if(x!=-1&&y!=-1){ s[x]++; s[y]++; _n--; }
		else if(x!=-1) a[++m]=x;
		else if(y!=-1) a[++m]=y;
	}
	fr(i,1,n+n) s[i]+=s[i-1];
	n=_n*2;
	fr(i,1,m) p[n-(a[i]-s[a[i]])+1]=1;
//	fr(i,1,n) printf("%d%c",p[i],i==n?'\n':' ');
	fr(i,1,n) sp[i]=sp[i-1]+p[i];
	printf("%d\n",solve(1,0,0));
	return 0;
}

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

int main(){
	int x,a,b; cin>>x>>a>>b;
	int xa=abs(a-x);
	int xb=abs(b-x);
	cout<<(xa<xb?"A":"B")<<endl;
}

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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[200200];

int sum(int b) {
	int res = 0;
	rep(i,n) res += abs(a[i]-b);
	return res;
}

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> a[i];
		a[i] -= i+1;
	}
	int l = -inf, r = inf;
	rep(t,1000) {
		int m1 = l + (r-l)/3, m2 = l + 2*(r-l)/3;
		int lb = sum(m1), rb = sum(m2);
		if (lb>=rb) l = m1;
		else r = m2;
	}
	int res = linf;
	repst(i,l,r) chmin(res,sum(i));
	cout << res << ln;
}

Measured memory_bytes: 1792
// B - Count ABC

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

int main()
{
    int N;
    string S;
    string target = "ABC";

    cin >> N;
    cin >> S;

    int ans = 0;
    for (int i=0; i<N; i++) {
        bool is_substr = true;
        for (int j=0; j<target.size(); j++) {
            if (j >= N) {
                is_substr = false;
                break;
            }

            if (S[i + j] != target[j]) {
                is_substr = false;
                break;
            }
        }
        if (is_substr) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n;
	while ( cin >> n ) {
		int count;
		if (n>36) count = 0;
		else if (n<=9) count = ((n+1)*(n+2)*(n+3))/6;
		else if (n<=18) count = ((n+1)*(n+2)*(n+3))/6 - 4*((n-9)*(n-8)*(n-7))/6;
		else if (n<=27) count = ((37-n)*(38-n)*(39-n))/6 - 4*((27-n)*(28-n)*(29-n))/6;
		else count = ((37-n)*(38-n)*(39-n))/6;
		
		cout << count << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
    map<string, int> d;
    int N; cin >> N;
    string s;
    rep(i, N) {
        cin >> s;
        if (d.count(s)) d.at(s)++;
        else d[s] = 1;
    }
    int n_max = 0;
    for (auto p : d) n_max = max(n_max, p.second);
    for (auto p : d) if (p.second == n_max) cout << p.first << endl;
}


Measured memory_bytes: 27008
#include <bits/stdc++.h>
#define int long long int
using namespace std;
bool DP[100001] = {0};

signed main() {
    int n,k,t;
    cin>>n>>k;
    set<int> p;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        p.insert(t);
    }
    for(int i=0;i<=k;i++)
    {

        for(auto i1 = p.begin(); i1!=p.end();i1++)
        {
            
            //cout<<i-*i1<<endl;
            if(i-*i1>=0)
            {
                DP[i] = DP[i] || !DP[i-*i1];
            }
        }

    }

    //cout<<DP[4]<<endl;
    if(DP[k]==true)
    cout<<"First";
    else
    cout<<"Second";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<pll> v(n),a(n);
	rep(i,n)cin>>v[i].fs>>v[i].sc;
	rep(i,n){
		a[i].fs=v[i].fs+v[i].sc;
		a[i].sc=v[i].fs-v[i].sc;
	}
	sort(all(a));
	ll mx=-LINF;
	ll ans=0;
	rep(i,n){
		if(mx>a[i].sc)continue;
		ans++;
		mx=a[i].fs;
	}
	puta(ans);

}


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

int n, c, d[210][210], v[210];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++) {
        getchar();
        for(int j = 0; j < n; j++) d[i][j] = getchar() - '0';
    }
    int ans = -1;
    for(int i = 0; i < n; i++) {
        queue<int> q;
        q.push(i);
        memset(v, 0, sizeof(v));
        v[i] = 1;
        int f = 0, tans = 0;
        while(!q.empty()) {
            int a = q.front();q.pop();
            tans = max(tans, v[a]);
            for(int j = 0; j < n; j++) {
                if(d[a][j]) {
                    if(!v[j]) v[j] = v[a] + 1, q.push(j);
                    else if(abs(v[a] - v[j]) != 1) f = 1;
                }
            }
        }
        if(!f) ans = max(ans, tans);
    }
    cout << ans;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  vector<long> dp(n);
  
  for (int i=0; i<n; i++)
    cin >> h.at(i);
  
  dp.at(0) = 0;
  
  for (int i=1; i<=n-1; i++) {
    dp.at(i) = 1000000000;
    for (int j=1; j<=k; j++) {
      long tmp = dp.at(i-j) + abs(h.at(i) - h.at(i-j));
      if (tmp < dp.at(i)) dp.at(i) = tmp;
      if (j>=i) break;
    }
  }
  
  cout << dp.at(n-1) << endl;
}
     

Measured memory_bytes: 1408
use std::collections::BTreeSet;
use std::cmp;

fn main(){
    let mut sc = Scanner::new();
    while let Ok(n) = sc.wrapped() {
        let x : i64 = sc.next();
        let mut a = vec![0i64; n];
        for e in a.iter_mut() { *e = sc.next(); }
        let mut ans = a.iter().fold(0, |x, y| x + y);
        a.resize(n*2, 0);
        for i in 0..n { a[i+n] = a[i]; }

        for mg in 1..n {
            let mut s:BTreeSet<(i64, usize)> = (n-mg..n).map(|i| (a[i], i)).collect();
            // for t in s.iter() {
            //     println!("{} {}", t.0, t.1);
            // }
            let mut cand = x*mg as i64;
            for j in n..n+n {
                let min = *s.iter().nth(0).unwrap();
                cand += cmp::min(min.0 as i64, a[j]);
                assert!(s.remove(&(a[j-mg], j-mg)));
                assert!(s.insert((a[j], j)));
            }
            // println!("cand: {}", cand);
            if ans > cand {
                ans = cand;
            }
        }
        println!("{}", ans);
    }
}

// Scanner

#[allow(dead_code)]
struct Scanner {
    token_buffer : Vec<String>,
    index : usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner{
        Scanner { token_buffer: vec![], index: 0 }
    }

    fn wrapped<T>(& mut self) -> Result<T,&str> where T: std::str::FromStr {
        let s = try!(self.fetch_token());
        let t = try!(s.parse::<T>().map_err(|_| "Parse error"));
        Ok(t)
    }
    fn next<T>(& mut self) -> T where T: std::str::FromStr {
        self.wrapped::<T>().unwrap()
    }

    fn fetch_token(&mut self) -> Result<&String,&str> {
        while self.index >= self.token_buffer.len() {
            let mut st = String::new();
            while st.trim() == "" {
                match std::io::stdin().read_line(&mut st) {
                    Ok(l) if l > 0 => continue,
                    Ok(_)  => return Err("End of file"),
                    Err(_) => return Err("Failed to read line"),
                }
            }
            self.token_buffer = st.split_whitespace()
                .map(|x| x.to_string())
                .collect();
            self.index = 0;
        }

        self.index += 1;
        Ok(&self.token_buffer[self.index - 1])
    }
}


Measured memory_bytes: 636
#include <stdio.h>
#define N_MAX 100
#define S_MAX 100+1

int main(void)
{
     int n, m, t1, t2, s1[N_MAX], s2[N_MAX], i;
     int x1, x2;
     
     while(1){
	  scanf("%d %d",&n,&m);
	  if(n+m==0) return 0;

	  t1 = t2 = 0;
	  x1 = x2 = S_MAX;
	  
	  for(i=0; i<n; i++) scanf("%d",s1+i), t1+=s1[i];
	  for(i=0; i<m; i++) scanf("%d",s2+i), t2+=s2[i];
	  
	  while(n--)
	       for(i=0; i<m; i++)
		    if(t1 - 2*s1[n] + 2*s2[i] == t2)
			 if(s1[n] + s2[i] < x1 + x2)
			      x1=s1[n], x2=s2[i];

	  if(x1 != S_MAX) printf("%d %d\n",x1,x2);
	  else puts("-1");
     }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;


int main() {
    int a,b;
    cin >> a >> b;
    for(int i = 1;i<4;i++) {
        if(i != a&&i != b) cout << i;
    }
}

Measured memory_bytes: 768
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    foreach(s;stdin.byLine())
    {
        string t;
        for(int i=0; i<s.length; ++i)
            if(s[i]!='@') t~=s[i];
            else t~=s[i+2].repeat().take(s[i+1]-'0').array(),i+=2;
        writeln(t);
    }
}

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


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

    sort(a.begin(),a.end(),greater<int>());
    int  cnta = 0, cntb =0;
    rep(i,n) {
      if(i%2==1) cnta+=a[i];
      else cntb+=a[i];
    }
    cout << cntb-cnta <<endl;

   }

Measured memory_bytes: 256
# AOJ 0032 Plastic Board
# Python3 2018.6.15 bal4u

rect = loz = 0
while True:
	try:
		a, b, c = list(map(int, input().split(',')))
	except EOFError:
		break
		
	if a*a + b*b == c*c:
		rect += 1
	elif a == b and a + b > c and b + c > a:
		loz += 1
print(rect, loz, sep='\n')


Measured memory_bytes: 5604
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<int,int> P;
P p[111];
int main(void)
{
  while(1){
    int n,m;
    cin >> n >> m;
    if(!n && !m)break;
    for(int i = 0; i < m; i++){
      p[i] = P(0,i+1);
    }
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
	int a;
	cin >> a;
	p[j].first-=a;
      }
    }
    sort(p,p+m);
    for(int i = 0; i < m; i++){
      cout << p[i].second;
      if(i == m - 1)cout << endl;
      else cout << " ";
    }
  }
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, a, b; cin>>n>>a>>b;
    int ans=0;
    for(int i=1; i<=n; i++){
        int m=i, sum=0;
        while(m>0){
            sum+=(m%10);
            m/=10;
        }
        if(a<=sum && sum<=b) ans+=i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256