akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <numeric>
#include <iomanip>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s;
vector<P> p;//fi:pos  se:co

int main(){
	cin >> s;
	int ans = 0;
	int pos = 0;
	int co = 0;
	REP(i, s.size()){
		if (s[i] == 'O'){
			if (co == 0)pos = i;
			co++;
		}
		else if (co > 0){
			if (s[i] != 'O'){
				p.push_back(P(pos, co));
				co = 0;
			}
		}
	}
	if (co > 0)p.push_back(P(pos, co));
	REP(i, p.size()){
		int po = p[i].first;
		int w = p[i].second;
		//cout << po << " " << w << endl;
		bool f = 1;
		if (po - w >= 0){
			string t = s.substr(po - w, w);
			//cout << t << endl;
			REP(j, t.size()){
				if (t[j] != 'J')f = 0;
			}
		}
		else f = 0;
		if (po + w + w - 1 <= s.size() - 1){
			string t = s.substr(po + w, w);
			//cout << t << endl;
			REP(j, t.size()){
				if (t[j] != 'I')f = 0;
			}
		}
		else f = 0;
		if (f)ans = max(ans, w);
	}
	cout << ans << endl;
}

Measured memory_bytes: 11488
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())
    SC = set(tuple(map(int, input().split())) for _ in [0] * M)

    if not M:
        if N == 1:
            print(0)
        else:
            print('1' + '0' * (N - 1))
        return

    num = [-1] * (N + 1)
    for s, c in SC:
        if num[s] < 0:
            num[s] = c
        else:
            print(-1)
            return
    n = ''
    if num[1] < 0:
        num[1] = 1
    for i in num[1:]:
        if i < 0:
            n += '0'
        else:
            n += str(i)
    if n[0] == '0' and len(n) > 1:
        print(-1)
    else:
        print(n)


main()


Measured memory_bytes: 3064
N = int(input())
edges = [[] for _ in range(N)]

for _ in range(N - 1):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edges[to].append(fr)

def calc(s):
    st = [s]
    minDist = [10**18] * N
    minDist[s] = 0
    while st:
        now = st.pop()
        for to in edges[now]:
            if minDist[to] > minDist[now] + 1:
                minDist[to] = minDist[now] + 1
                st.append(to)
    return minDist

A = calc(0)
B = calc(N - 1)

ans = 0
for i in range(N):
    ans += 1 if A[i] <= B[i] else -1
print('Fennec' if ans > 0 else 'Snuke')


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


int main()
{
	//freopen("input16.txt","r",stdin);freopen("output16.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[0]<<c[0];
	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    ll sum = 0;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(),a.end());
    cout << a[0] <<" " << a[n-1] << " " << sum << endl;
}


Measured memory_bytes: 3192
w, h = (int(x) for x in input().split())
ab = []
for _ in range(h):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])

dp = [0] * (w + max(a for a, b in ab))

for j in range(1, w+1):
    dp[j] = min(dp[j-a]+b for a, b in ab)

print(dp[w])

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

bool is_prime(int n) {
    for(int i = 3; i*i <= n; i+=2) {
        if (n % i == 0)
            return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<int> cand = {2};
    // unordered_map<int, int> cnt;
    for(int i = 3; i < 55555; i+= 2) {
        if (is_prime(i)) {
            cand.push_back(i);
            // cout << cand.back() << " ";
            // cnt[i%10] += 1;
            if (i % 10 == 1) {
                cout << i << " ";
                n--;
                if (n <= 0) break;
            }
        }
    }
    /*
    for(auto& p: cnt) {
        cout << p.first << " freq = " <<p.second << endl;
    }*/
    // cout << cand.size() << endl;
    return 0;
}




Measured memory_bytes: 256
import collections

N = int(input())
d = {}
for i in range(N):
    s=input()
    c = "".join(sorted(s))
    if c not in d.keys():
        d[c] = 1
    else:
        d[c]+=1

answer = 0
for k in d.keys():
    if d[k]>1:
        answer += d[k]*(d[k]-1)/2

print(int(answer))

Measured memory_bytes: 18144
r,d,x = map(int,input().split())

x_li = [0 for i in range(11)]
x_li[0] = x

for i in range(10):
    x_li[i+1] = r*x_li[i] -d
    
for i in range(10):
    print(x_li[i+1])
    

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
int ball[10];
int left = 0,right = 0;
bool dfs(int de,int left, int right){//??????????????§???????????????
	if(de == 10)return true;
	if(left < ball[de] ){
		left = ball[de];
		return dfs(de + 1,left,right);
	}
	if(right < ball[de]){
		right = ball[de];
		return dfs(de + 1,left,right);
	}
	return false;
}

int main(){
	int n;
	std::cin >> n;
	while(n--){
		for(int i = 0; i < 10; ++i){
			std::cin >> ball[i];
		}
		left = 0, right = 0;
		if(dfs(0,0,0))std::cout << "YES" << std::endl;
		else std::cout << "NO" << std::endl;
	}
}

Measured memory_bytes: 1152
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//最大公約数
long long gcd(long long a, long long b) {
	if (a < b) std::swap(a, b);
	long long r = a % b;
	while (r) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

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

	ll n;
	cin >> n;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	ll x = 1;
	for (ll i = 0; i < n; i++) {
		if (a[i] == x) x++;
	}
	if (x > 1) cout << n - x + 1 << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

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

snk = 0
arg = 0

for i in range(0, N):
	arg += a[i]

s = 100000000000000

for i in range(0, N - 1):
	snk += a[i]
	arg -= a[i]
	ss = snk - arg
	if ss < 0:
		ss *= -1

	if s > ss:
		s = ss

print(s)


Measured memory_bytes: 24944
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if(max({a, b, c}) == a) a *= 10;
  if(max({a, b, c}) == b) b *= 10;
  if(max({a, b, c}) == c) c *= 10;
  cout << a + b + c << endl;
  return 0;
}
//templete by private_yusuke

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

using namespace std;

void a() {
	int d;
	cin >> d;
	if (d == 25)
		cout << "Christmas" << endl;
	else if (d == 24)
		cout << "Christmas Eve" << endl;
	else if (d == 23)
		cout << "Christmas Eve Eve" << endl;
	else if (d == 22)
		cout << "Christmas Eve Eve Eve" << endl;
}

void b() {
	int n;
	cin >> n;
	int p[10000];
	
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p, p+n);

	int s = 0;
	for (int i = 0; i < n-1; i++) {
		s += p[i];
	}
	s += (p[n-1] / 2);

	cout << s << endl;
}

int main()
{
	b();
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

#define MOD 1000000007ll

//
li dp[111][4][4][4];
li n;


// NG
/*
AGC* => 012*
GAC* => 102*
ACG* => 021*
*AGC => *012
*GAC => *102
*ACG => *021
A*GC => 0*12
AG*C => 01*2
*/

int main() {
	cin >> n;
	if (n == 3) {
		cout << 4 * 4 * 4 - 3 << endl;
		return 0;
	}
	rep(i1, 4) {
		rep(i2, 4) {
			rep(i3, 4) {
				dp[3][i1][i2][i3] = 1;
				if ((i1 == 2 && i2 == 1 && i3 == 0) ||
				        (i1 == 2 && i2 == 0 && i3 == 1) ||
				        (i1 == 1 && i2 == 2 && i3 == 0) ) {
					dp[3][i1][i2][i3] = 0;
				}
			}
		}
	}

	repp(i, 4, n + 1) {
		rep(i1, 4) {
			rep(i2, 4) {
				rep(i3, 4) {
					rep(now, 4) {
						if ((i1 == 2 && i2 == 1 && i3 == 0) ||
						        (i1 == 2 && i2 == 0 && i3 == 1) ||
						        (i1 == 1 && i2 == 2 && i3 == 0) ) {
							continue;
						}
						if ((now == 2 && i1 == 1 && i2 == 0) ||
						        (now == 2 && i1 == 0 && i2 == 1) ||
						        (now == 1 && i1 == 2 && i2 == 0) ) {
							continue;
						}
						if ((now == 2 && i1 == 1 && i3 == 0) ||
						        (now == 2 && i2 == 1 && i3 == 0)) {
							continue;
						}
						dp[i][now][i1][i2] = (dp[i][now][i1][i2] + dp[i - 1][i1][i2][i3]) % MOD;
					}
				}
			}
		}
	}
	li res = 0;

	rep(i1, 4) {
		rep(i2, 4) {
			rep(i3, 4) {
				res += dp[n][i1][i2][i3];
			}
		}
	}
	cout << res % MOD << endl;

	return 0;
}


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

int main()
{
    int N;
    std::string S;
    std::string T;
    std::cin >> N;
    std::cin >> S >> T;

    std::string ans;
    for (int i = 0; i < N; i++)
    {
        ans.push_back(S[i]);
        ans.push_back(T[i]);
    }

    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100100;
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}

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



int main(){
    ll N;
    cin >> N;
    ll ans = INF;
    for(int i = 1; i <= sqrt(N); i++){
        if(N % i == 0){
            if(ans > ((i - 1) + (N / i - 1))) ans = (i - 1) + (N / i - 1);
        }
    }
    cout << ans << endl;
}

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


const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) {
			x -= mod;
		}
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) {
			x -= mod;
		}
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

ll nck(int n, int k){
    if(k == 0)return 1;
    mint res = 1;
    rep(i, k)res *= (n - i);
    rep(i, k)res /= (i + 1);
    return res.x;
}

int main() {
    int n;
    ll m;
    cin >> n >> m;
    map<ll, int> mp;
    ll x = m;
    for(int i = 2; i <= sqrt(m) + 1; i++){
        while(x % i == 0){
            x /= i;
            mp[i]++;
        }
    }
    if(x > 1)mp[x]++;

    ll ans = 1;
    for(auto i = mp.begin(); i != mp.end(); i++){
        int k = i->second;
        ans *= nck(n+k-1, k);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
counter=Counter(A)
sum_res=sum(A)
for i in range(Q):
  b,c=map(int,input().split())
  sum_res-=counter[b]*b
  sum_res+=counter[b]*c
  counter[c]+=counter[b]
  counter[b]=0
  print(sum_res)

Measured memory_bytes: 24120
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

/*
...  #......#####. #####
*/

int ans = 1000000000;
int x[200005];

int main(void) {
    int n;
    string s;
    cin >> n >> s;

    int w = 0, b = 0;
    rep(i, 0, n) if (s[i]=='.') w++;

    ans = min(ans, w);
    rep(i, 0, n) {
        if (s[i]=='.') w--;
        else b++;
        ans = min(ans, w+b);
    }
    
    cout << ans << endl;

	return 0;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c =='u' || c =='e' || c == 'o')
    cout << "vowel" << endl;
  else 
    cout << "consonant" << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

ll d[13][13];
ll Money[13];

int main(){
    ll N,M,X; cin>>N>>M>>X;
    rep(i,N){
        cin>>Money[i];
        rep(j,M) cin>>d[i][j];
    }

    ll ans=INF;
    ll K=(1<<N);
    rep(i,K){
        vec kari(M,0);
        rep(j,N) if(i & 1<<j) {
            rep(k,M) kari[k]+=d[j][k];
        }
        bool able=true;
        rep(k,M) if(kari[k]<X) able=false;
        if(able){
            ll X=0;
            rep(j,N) if(i & 1<<j) X+=Money[j];
            ans=min(X,ans);
        }

    }
    if(ans<INF) cout<<ans<<endl;
    else cout<<-1<<endl;

}

Measured memory_bytes: 3632
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import Data.Char


main :: IO ()
main = readLn >>= print . solve

solve :: Int -> Int
solve n = length [ 1 | x <- [1..(n `div` 2)], x /= n - x]

Measured memory_bytes: 508
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    string S; cin >> S;
    
    for (int i=2; i<S.size(); i++)
    {
        if (i%2==1) continue;
        if (S.substr(0,(S.size()-i)/2) == S.substr((S.size()-i)/2, (S.size()-i)/2)) 
        {
            cout << (S.size() - i) << endl;
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,pw[22],ansn,ansm,fs;
pair<pair<int,int>,int> res[222];
int main()
{
	scanf("%d",&n);
	m=1;
	pw[0]=1;
	for (int i=1;i<=20;i++) pw[i]=pw[i-1]*3;
	while(pw[m]<=n) m++;
	m--;ansn=m+2;
	for (int i=0;i<m;i++)
	{
		res[++ansm]=make_pair(make_pair(i,i+1),0);
		res[++ansm]=make_pair(make_pair(i,i+1),pw[i]);
		res[++ansm]=make_pair(make_pair(i,i+1),2*pw[i]);
	}
	fs=n;
	for (int i=0;i<=m;i++)
	{
		int x=fs%3;
		fs/=3;
		if (!x) continue;
		if (x==1)
		{
			res[++ansm]=make_pair(make_pair(i,ansn-1),n-pw[i]);
			n-=pw[i];
		}
		else
		{
			res[++ansm]=make_pair(make_pair(i,ansn-1),n-2*pw[i]);
			res[++ansm]=make_pair(make_pair(i,ansn-1),n-pw[i]);
			n-=pw[i]*2;
		}
	}
	printf("%d %d\n",ansn,ansm);
	for (int i=1;i<=ansm;i++) printf("%d %d %d\n",res[i].first.first+1,res[i].first.second+1,res[i].second);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const int size = 100010;
int cum[size];

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int N; cin >> N;
    REP(_, N) {
        int a, b; cin >> a; cin >> b;
        cum[a] += 1;
        cum[b+1] += -1;
    }
    REP(i, size-1) {
        cum[i+1] += cum[i];
    }
    REP(i, 8) {
    }
    RREP(i, size) {
        if (cum[i]+1 >= i) {
            cout << i-1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 3940
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }





int main() {
    ll l, n;
    cin >> l >> n;
    vector<ll> x1(n), x2(n);
    REP(i, n){
        cin >> x1[i];
    }
    REP(i, n){
        x2[i] = l - x1[n - 1 - i];
    }
    vector<ll> r1(n + 1), r2(n + 1);
    REP(i, n){
        r1[i + 1] = r1[i] + x1[i];
        r2[i + 1] = r2[i] + x2[i];
    }
    ll ans = max(x1[n - 1], x2[n - 1]);
    REP(i, n - 1){
        ll res1, res2;
        if((n - i) % 2 == 0){
            res1 = 2 * (r1[i + (n - i) / 2] - r1[i]) + 2 * r2[(n - i - 1) / 2] + x2[(n - i - 1) / 2];
            res2 = 2 * (r2[i + (n - i) / 2] - r2[i]) + 2 * r1[(n - i - 1) / 2] + x1[(n - i - 1) / 2];
        }
        else{
            res1 = 2 * (r1[i + (n - i) / 2] - r1[i]) + x1[i + (n - i) / 2] + 2 * r2[(n - i) / 2];
            res2 = 2 * (r2[i + (n - i) / 2] - r2[i]) + x2[i + (n - i) / 2] + 2 * r1[(n - i) / 2];
        }
        ans = max({ans, res1, res2});
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int d = sc.nextInt();
			int t = sc.nextInt();
			int s = sc.nextInt();
			if (d > t * s) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}
	}
}

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


def solve(N: int, K: int, D: "List[int]"):
    while any([str(i) in str(N) for i in D]):
        N += 1

    print(N)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>
int main(){
   int a,b;
   int d,r;
   double f;

   scanf("%d %d",&a,&b);

   d=a/b;
   r=a%b;
   f=(double)a/b;

   printf("%d %d %lf\n",d,r,f);

   return 0;
}

Measured memory_bytes: 636
import java.io.*;
import java.util.*;
 
public class Main {
    static final long MOD = 1000000007L;
    static final int INF = 50000000;
    static final int NINF = -50000000;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        int H = sc.ni();
        int W = sc.ni();
        int K = sc.ni();
        int[][] grid = new int[H][W];
        for (int i = 0; i < H; i++) {
        	String s = sc.next();
        	for (int j = 0; j < W; j++) {
        		if (s.charAt(j)=='#')
        			grid[i][j] = 1;
        	}
        }
        int ans = 0;
        for (int i = 0; i < (1<<H); i++) {
        	for (int j = 0; j < (1<<W); j++) {
        		int black = 0;
        		for (int a = 0; a < H; a++) {
        			for (int b = 0; b < W; b++) {
        				if ((i&(1<<a))==0 && (j&(1<<b))==0)
        					black += grid[a][b];
        			}
        		}
        		if (black==K)
        			ans++;
        	}
        }
        pw.println(ans);
        
        pw.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  ll N;
  scanf("%lld", &N);

  vector<ll> nums(15);
  for (ll i = 0; i < nums.size(); i++) {
    nums[i] = -1;
  }
  nums[0] = 0;

  ll ans = 0;
  for (;;) {
    for (ll j = 0; j < nums.size(); j++) {
      if (nums[j] == -1) {
        nums[j] = 3;
      } else {
        nums[j] += 2;
      }
      if (nums[j] <= 7) {
        break;
      }
    }
    // adjust
    for (int i = nums.size() - 2; i >= 0; i--) {
      if (nums[i] > 7) {
        nums[i] = 3;
      }
    }
    ll n = 0;
    ll b = 1;

    bool found3 = false;
    bool found5 = false;
    bool found7 = false;
    for (ll k = 0; k < nums.size(); k++) {
      if (nums[k] < 0) {
        break;
      }
      if (nums[k] == 3) found3 = true;
      if (nums[k] == 5) found5 = true;
      if (nums[k] == 7) found7 = true;

      n += nums[k] * b;
      b *= 10LL;
    }
    if (n > N) {
      break;
    }
    if (found3 && found5 && found7) {
      ans++;
    }
    // print
    // for (ll k = nums.size() - 1; k >= 0; k--) {
    //   if (nums[k] >= 0) {
    //     cout << nums[k];
    //   }
    // }
    // cout << endl;
    // cout << n << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    ll cnt[4]; memset(cnt, 0, sizeof(cnt));
    
    string s[4] = {"AC", "WA", "TLE", "RE"};
    zep(i, 0, n){
    	string t; cin >> t;
    	zep(j, 0, 4){
    		if(t == s[j])cnt[j]++;
    	}
    }
    
    zep(j, 0, 4){
    	cout << s[j] << " x " << cnt[j] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3648
/* long long or int */
/* xx 396*/

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

typedef long long ll;

ll l,r;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin>>l>>r;
	if(r-l+1>=2019){
		cout<<0<<endl;
		return 0;
	}
	ll ans=2019;
	for(ll i=l;i<r;i++){
		for(ll j=i+1;j<=r;j++){
			ll sum=i*j;
			ans=min(sum%2019,ans);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
No matter how long a night, dawn will always break.

Simular saying ... The darkest hour is just before the dawn.
 ***************************************   ************************8   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
 
 
 
 
 
int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 

 int f(int a,int b,int l,int r){
 	if(l>r)return 0;
 	if(l/b==r/b){
 		return (a*r)/b-a*(r/b);
 	}
 	int mid=l+(r-l)/2;
 	return max(f(a,b,l,mid),f(a,b,mid+1,r));
 }
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int i,j,x,k,a,b;
  	cin>>a>>b>>x;
  	if(b<x){
  		cout<<(a*(b-1))/b<<endl;
  		return 0;
  	}
  	cout<<f(a,b,1,x);

   
   
   
    return 0;
}

Measured memory_bytes: 3612
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let mut vec: Vec<i32> = (0..3).map(|_| read()).collect();
    vec.sort();
    vec.reverse();

    let a: String = vec[0].to_string();
    let b: String = vec[1].to_string();
    let c: i32 = vec[2];

    let ab: String = format!("{}{}", a, b);
    let ab_i: i32 = ab.parse().unwrap();

    println!("{}", ab_i+c);
}

fn calc_distance(x: i32, y: i32, target_x: i32, target_y: i32) -> i32 {
    let diff_x = (target_x - x).abs();
    let diff_y = (target_y - y).abs();

    return diff_x + diff_y;
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

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

int main() {
  int A, B, C, D, P;

  cin >> A >> B >> C >>	D >> P;

  if(P < C) {
    if((A * P) < B)
      cout << (A * P) << endl;
    else
      cout << B << endl;
  }
  else {
    if((A * P) < (B + ((P - C) * D)))
      cout << (A * P) << endl;
    else
      cout << (B + ((P - C) * D)) << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
#define int long long
#define ll long long 
#define F first
#define sqr(x) ((x) * (x))
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;

const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int N = (int)2e6+ 222;
const ll INF = (ll)1e18;
const int p = 997, p1 = 991;
const double eps = (double)1e-6;


string s;
int n, P[5111], h[5111], P1[5111], h1[5111];

void calc () {
   	P[0] = 1;       
   	P1[0] = 1;
	for (int i = 1; i <= sz(s); ++i) {
		P[i] = P[i - 1] * p;
		P1[i] = P1[i - 1] * p1;
		P1[i] %= MOD1;
		P[i] %= MOD;
		h1[i] = h1[i - 1] * p1 + (s[i - 1] - 'a' + 1);
		h1[i] %= MOD1;
		h[i] = h[i - 1] * p + (s[i - 1] - 'a' + 1);
		h[i] %= MOD;
	}
}
int get (int l, int r) {
	int x = (h[r] - ((h[l - 1] * P[r - l + 1]) % MOD)) % MOD + MOD;
	return x % MOD;
}
int get1 (int l, int r) {
	int x = (h1[r] - ((h1[l - 1] * P1[r - l + 1]) % MOD1)) % MOD1 + MOD1;
	return x % MOD1;
}

void solve () {                                           
	cin >> n;
	cin >> s;
	calc();
	int mx = 0;  
	int l = 0, r = sz(s);
	while (r - l > 1) {
		bool ok = 0;
	 	int len = (r + l) / 2;
	 	for (int i = 1; i + len - 1 <= n; ++i) {
	 		for (int j = i + len - 1 + 1; j + len - 1 <= n; ++j) {
	 			if (get(i, i + len - 1) == get(j, j + len - 1) &&get1(i, i + len - 1) == get1(j, j + len - 1) ) {
	 				ok = 1; 
   					break;
	 			}
	 		}
	 		if (ok) break;
	 	}
	 	if (ok) l = len;
	 	else r = len;
	}
	cout << l;


}

signed main () {
    #ifdef Maga
        freopen("input", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);                                              
    int t = 1;
    while (t --) {
    	solve ();
    }
    return 0;
}





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

int main(){
  int n,i,ans=0;
  cin >> n;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
    ans += ((i+1)*a.at(i))%2;
  }
  
  cout << ans << endl;
}

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

int main(){
  int N;
  cin>>N;
  int ans=0;
  int out,pout;
  pout=1;
  for(int i=3;i<=N+2;i+=2){
    out=0;
    for(int j=3;j*j<=i&&out==0;j+=2){
      if(i%j==0)out++;
    }
    if(out==0&&pout==0)ans++;
    pout=out;
  }
  cout<<ans*2<<endl;
}



Measured memory_bytes: 3136
N,L=map(int,input().split())
a=[]
for i in range(N):
    a.append(L+i)
if a[-1]>0 and L<=0:
    print(sum(a))
if a[-1]>0 and L >0:
    print(sum(a[1:]))
if a[-1]<=0:
    print(sum(a[:-1]))

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

int main(){
  int x = 0;
  cin >> x;
  if (x <= 599)
    cout << 8 << endl;
  else if (x <= 799)
    cout << 7 << endl;
  else if (x <= 999)
    cout << 6 << endl;
  else if (x <= 1199)
    cout << 5 << endl;
  else if (x <= 1399)
    cout << 4 << endl;
  else if (x <= 1599)
    cout << 3 << endl;
  else if (x <= 1799)
    cout << 2 << endl;
  else if (x <= 1999)
    cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3192
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
using namespace std;

#define MAX 2000000000
#define SIZE 100000
struct card{char suit;int num;};

card L[SIZE/2+2],R[SIZE/2+2];

int merge(card a[],int l,int m,int r)
{
	int n1=m-l;
	int n2=r-m;
	for(int i=0;i<n1;i++)
	{
		L[i]=a[l+i];
	}
	L[n1].num=MAX;
	for(int i=0;i<n2;i++)
	{
		R[i]=a[m+i];
	}
	R[n2].num=MAX;
	int i=0,j=0;
	for(int k=l;k<r;k++)
	{
		if(L[i].num<=R[j].num)
		{
			a[k]=L[i++];
		}
		else
		{
			a[k]=R[j++];
		}
	}
}

int mergeS(card a[],int l,int r)
{
	if(l+1<r)
	{
		int m=(l+r)/2;
		mergeS(a,l,m);
		mergeS(a,m,r);
		merge(a,l,m,r);
	}
}

int part(card a[],int p,int r)
{
	int x=a[r].num;
	int i=p-1;
	for(int j=p;j<r;j++)
	{
		if(a[j].num<=x)
		{
			i++;
			swap(a[i],a[j]);
		}
	}
	swap(a[i+1],a[r]);	
	return i+1;
}

int quickS(card a[],int p,int r)
{
	if(p<r)
	{
		int q=part(a,p,r);
		quickS(a,p,q-1);
		quickS(a,q+1,r);
	}
}

int main()
{
	int n;cin>>n;card a[SIZE];card b[SIZE];
	for(int i=0;i<n;cin>>a[i].suit>>a[i].num,i++);
	for(int i=0;i<n;b[i]=a[i],i++);
	quickS(a,0,n-1);
	mergeS(b,0,n);
	int err=0;
	for(int i=0;i<n;i++)
	{
		if(a[i].suit!=b[i].suit)err=1;
	}
	if(err==0)cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;
	for(int i=0;i<n;cout<<a[i].suit<<" "<<a[i].num<<endl,i++);
	return 0;
}

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

int main() {
int n;
cin>>n;
if(n<=111) cout<<111<<endl;
else if(n<=222) cout<<222<<endl;
else if(n<=333) cout<<333<<endl;
else if(n<=444) cout<<444<<endl;
else if(n<=555) cout<<555<<endl;
else if(n<=666) cout<<666<<endl;
else if(n<=777) cout<<777<<endl;
else if(n<=888) cout<<888<<endl;
else if(n<=999) cout<<999<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main ()
{
	int n, i;
	scanf("%d", &n);
	int res=n ;
	for(i=0; i<=n; i++){
		int cnt=0, t=i;
		
		while (t>0){ cnt+=t%6, t/=6; }
		t=n-i;
		while (t>0){ cnt+=t%9, t/=9; }
		if(res>cnt) res=cnt;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		TreeMap<Integer,Integer> treeMap = new TreeMap<Integer,Integer>();
		Scanner scan = new Scanner(System.in);
		int max = 0;

		while(scan.hasNext()) {
			int count = 1;
			Integer input = scan.nextInt();

			if(treeMap.containsKey(input)) {
				count += treeMap.get(input);
			}

			if(max < count) {
				max = count;
			}
			treeMap.put(input, count);
		}

		for(int key : treeMap.keySet()) {
			if(max == treeMap.get(key)) {
				System.out.println(key);
			}
		}
		scan.close();

	}

}



Measured memory_bytes: 26284
#include <iostream>

using namespace std;

typedef long long ll;

const ll DIV = 1e9 + 7;

ll power(ll x, ll n){
    ll res = 1;
    if (n>0) {
        res = power(x, n/2);
        res *= res;
        res %= DIV;
        if (n%2) res *= x;
        res %= DIV;
    }
    return res;
}

int main(int argc, char const *argv[])
{
    ll m, n;
    cin >> m >> n;

    ll ans = power(m, n);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3112
class BinaryIndexedTree():  #1-indexed
    def __init__(self, n):
        self.n = n
        self.tree = [0 for _ in range(n + 1)]

    def sum(self, index):
        res = 0
        while index:
            res += self.tree[index]
            index -= index & -index
        return res

    def add(self, index, x):
        while index <= self.n:
            self.tree[index] += x
            index += index & -index

    def bisect_left(self, x):
        if x <= 0: return 0
        res, tmp = 0, 2**((self.n).bit_length() - 1)
        while tmp:
            if res + tmp <= self.n and self.tree[res + tmp] < x:
                x -= self.tree[res + tmp]
                res += tmp
            tmp >>= 1
        return res + 1


INF = 10**18

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

res = INF

for i in range(2**N):
    front = []
    back = []
    for j in range(N):
        if (i >> j) & 1:
            front.append((A[j], j))
        else:
            back.append((B[j], j))
    odd = []
    even = []
    for x, j in front:
        if j % 2 == 0:
            odd.append((x, j))
        else:
            even.append((x, j))
    for x, j in back:
        if j % 2 != 0:
            odd.append((x, j))
        else:
            even.append((x, j))
    if len(even) != N // 2:
        continue
    odd.sort()
    even.sort()
    seq = []
    for j in range(N):
        if j % 2 == 0:
            seq.append(odd[j // 2])
        else:
            seq.append(even[j // 2])
    for j in range(N - 1):
        if seq[j][0] > seq[j + 1][0]:
            break
    else:
        bit = BinaryIndexedTree(N)
        count = 0
        for j in range(N):
            bit.add(seq[j][1] + 1, 1)
            count += j + 1 - bit.sum(seq[j][1] + 1)
        res = min(res, count)

print(res if res != INF else -1)

Measured memory_bytes: 58972
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,k,q;
vi a;

int main(){
	cin>>n>>k>>q;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vp b(n);
	for(int i=0;i<n;i++) b[i]={a[i],i};
	sort(b.begin(),b.end());
	int res=inf;
	for(int i=0;i<n;i++){
		int x=b[i].first,t=-1,K=q;
		map<int,int> m;
		vi c;
		for(int j=0;j<n;j++) if(a[j]<x){
			m[j]=j-t-1;
			c.push_back(j);
			t=j;
		}
		c.push_back(n);
		m[n]=n-t-1;
		for(int j=i;j<n;j++){
			int y=b[j].first,I=b[j].second;
			int it=*lower_bound(c.begin(),c.end(),I);
			if(m[it]>=k){
				m[it]--;
				K--;
			}
			if(!K){
				res=min(res,y-x);
				break;
			}
		}
	}
	cout<<res<<endl;
}

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

long long n;
long long a[(1<<20)], f[(1<<20)];

vector < long long > prs;

pair < long long, long long > vals[(1<<20)];
map < long long, long long > cnt;
map < long long, pair < long long , long long > > mem;

pair< long long, long long > gg ( long long x ) {

    //if ( mem.count( x ) ) { return mem[x]; }

    long long a = 1, b = 1;

    for ( int i = 0 ; i < prs.size() && prs[i]*prs[i] <= x ; i ++ ) {

        if ( x%prs[i] == 0 ) {
            int cnt = 0;
            for ( ; x%prs[i] == 0 ; cnt ++ ) {
                x /= prs[i];
            }
            cnt %= 3;
            for ( int c = 0 ; c < cnt ; c ++ ) { a *= prs[i]; }
            cnt = (3-cnt)%3;

            for ( int c = 0 ; c < cnt ; c ++ ) {
                if ( b != -1 ) {
                    b *= prs[i];
                    if ( b >  (10000000000LL) ) { b = -1; }
                }
            }

        }
    }

    if ( x != 1 ) {
        a *= x;
        if ( x > 1000000 ) { b = -1; }
        if ( b != -1 ) {
            b *= x;
            if ( b > (10000000000LL) ) { b = -1; }
        }
        if ( b != -1 ) {
            b *= x;
            if ( b > (10000000000LL) ) { b = -1; }
        }
    }

    mem[x] = make_pair( a, b );
    return make_pair( a, b );
}

int main () {

    for( long long i = 2 ; i*i < (10000000000LL) ; i ++ ) {
        if ( f[i] == 0 ) {
            prs.push_back( i );
            for ( long long j = 1;  i*i*j*j < (10000000000LL) ; j ++ ) {
                f[i*j] = 1;
            }
        }
    }


    cin >> n;
    for ( long long i = 0 ; i < n ; i ++ ) {
        cin >> a[i];
    }
    sort( a, a+n );
    for ( int i = 0 ; i < n ; i ++ ) {
        if ( i == 0 || a[i] != a[i-1] ) { vals[i] = gg( a[i] ); }
        else {
            vals[i] = vals[i-1];
        }
     //   cout << vals[i].first << " " << vals[i].second << "\n";
        cnt[ vals[i].first ] ++;
    }
    sort ( vals, vals+n );

    long long ans = 0;
    for ( long long i = 0 ; i < n ; ) {
        long long j = i;
        for ( ; j < n && vals[i].first == vals[j].first ; j ++ ) {}

        long long ccnt = j-i, revcnt = cnt[ vals[i].second ];

        if ( vals[i].first == 1 ) { ans ++; }
        else {
            if ( ccnt > revcnt ) {
                ans += ccnt;
            }else if ( ccnt < revcnt ) {
                //ans += revcnt;
            }else {
                if ( vals[i].first < vals[i].second ) {
                    ans += ccnt;
                }
            }

        }

        i = j;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 16896
#include <iostream>
#include <bitset>
using namespace std;
int main(void){
    int n,b[32],x=0,c=0;
    cin>>n;
    fill(b, b+32, 0);
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        x^=a;
        int t=(a^(a-1));
        for(int j=31;j>=0;j--){
            if(((t>>j)&1)==1){
                b[j]++;
                break;
            }
        }
    }
    for(int i=31;i>=0;i--){
        if(((x>>i)&1)==1){
            if(b[i]>0){
                x^=(1<<(i+1))-1;
                c++;
            }else{
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    cout << c << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define lowbit(x) x&(-x)
using namespace std;
 
typedef long long ll;
 
const int maxn=15;
 
int p[maxn],a[maxn][maxn];

int res[15];
int vis[15];
int n,m,x;
//int ans=1e9;
//
//void dfs( int x )
//{
//	if( x==n+1 )
//	{
//		int sum=0;
//		memset(res,0,sizeof(res));
//		for( int i=1;i<=n;i++ )
//		{
//			if( vis[i]==0 ) continue;
//			sum+=p[i]; 
//			for( int j=1;j<=m;j++ )
//			{
//				res[i]+=a[i][j];
//			}
//		}
//		int flag=1;
//    	for( int j=1;j<=m;j++ )
//    	{
//    		if( res[j]<x )  flag=0;
//    	}
//    	if( flag ) ans=min(ans,sum);
//    	return;
//	}
//	vis[x]=1;
//	dfs(x+1);
//	vis[x]=0;
//	dfs(x+1);
//}


int main()
{
    
    cin>>n>>m>>x;
    for( int i=1;i<=n;i++ )
    {
    	cin>>p[i];
    	for( int j=1;j<=m;j++ ) cin>>a[i][j];
    }
    
   // dfs(1);
    
    int ans=1e9;
    for( int i=0;i<(1<<n);i++ )
    {
    	int tmp=i,sum=0;
    	memset(res,0,sizeof(res));
    	for( int j=0;j<n;j++ )
    	{
    		if( tmp>>j & 1 )
    		{
    			sum+=p[j+1];
    			for( int k=1;k<=m;k++ ) res[k]+=a[j+1][k];
    		}
    	}
    	int flag=1;
    	for( int j=1;j<=m;j++ )
    	{
    		if( res[j]<x )  flag=0;
    	}
    	if( flag ) ans=min(ans,sum);
    }
    if( ans!=(int)1e9 ) cout<<ans<<endl;
    else puts("-1");
}

Measured memory_bytes: 3632
using System;
class pg
 {
  static void Main(string[] args)
  {
    int a = int.Parse(Console.ReadLine());
    if(a<3200)
    {
      Console.WriteLine("red");
    }
    else
    {
      string s = Console.ReadLine();
      Console.WriteLine(s);
    }
  }
}

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

const double EPS = 1e-10;
const int INF = 100000000;
const ll MOD = 1000000007;

int n, x[3];
map<vector<int>, ll> dp[41];
map<vector<int>, ll>::iterator it;

P valid(vector<int> vec) {
    int now = 0, cnt = 0;
    rep(j,vec.size()) {
        now += vec[j];
        if (now == x[cnt]) {
            if (cnt == 2) {
                return P(INF, INF);
            }
            cnt++;
            now = 0;
        } else if (now > x[cnt]) {
            return P(-1, -1);
        }
    }
    return P(cnt, now);
}

int main() {
    cin >> n;
    rep(i,3) cin >> x[i];
    dp[0][vector<int>()] = 1;
    for (int i = 1; i <= n; i++) {
        for (it = dp[i-1].begin(); it != dp[i-1].end(); it++) {
            vector<int> tmp = (*it).first;
            ll val = (*it).second;
            
            for (int j = 1; j <= 7; j++) {
                tmp.push_back(j);
                for (int k = 0; k <= tmp.size(); k++) {
                    vector<int> ttmp = vector<int>(tmp.begin()+k, tmp.end());
                    P q = valid(ttmp);
                    if (q == P(INF, INF)) {
                        break;
                    } else if (q != P(-1, -1)) {
                        dp[i][ttmp] = (dp[i][ttmp]+val)%MOD;
                        break;
                    }
                }
                tmp.pop_back();
            }
            dp[i][vector<int>()] = (dp[i][vector<int>()]+3*val)%MOD;
        }
    }
    ll ans = 1;
    rep(i,n) ans = ans * 10 % MOD;
    for (it = dp[n].begin(); it != dp[n].end(); it++) {
        ans = (ans-(*it).second+MOD)%MOD;
    }
    cout << ans << endl;
}
































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

typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;

    int ans;
    if ((b-1)%(a-1)==0){
        ans = (b-1)/(a-1);
    }
    else{
        ans = (b-1)/(a-1) + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256