akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int N = (int)3e5, MOD = (int)1e9 + 7, INF = (int)3e18;

main() {
    ios :: sync_with_stdio(0);
    cin.tie(0);
    double l;
    cin >> l;
    cout << fixed << setprecision(12) << (l / 3) * (l / 3) * (l / 3);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1E9 + 7, N = 100005;
string s;
int n, a[N], dp[N][2];
int solve(int idx, int f)
{
	if (idx == n)
		return 1;
	else if (dp[idx][f] != -1)
		return dp[idx][f];
	int ans = 0, lim = 1;
	if (f)
		lim = a[idx];
	for (int i = 0; i <= lim; ++i)
	{
		int nf = f;
		if (f)
		{
			if (i < lim)
				nf = 0;
		}
		if (i)
			ans = (1LL * ans + (2 * solve(idx + 1, nf)) % MOD) % MOD;
		else
			ans = (1LL * ans + solve(idx + 1, nf)) % MOD;
	}
	return dp[idx][f] = ans;
}
int main(int argc, char const *argv[])
{
	cin >> s;
	n = s.length();
	for (int i = 0; i < n; ++i)
	{
		a[i] = s[i] - '0';
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(0, 1);
	return 0;
}

Measured memory_bytes: 12792
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;i++) 
using namespace std;
typedef long long ll;

ll n, ans = 1e15;
int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        ll j = n / i;
        ans = min(ans, i+j-2 );
    }
    cout << ans;
	return 0;
}


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

int main() {
  int n;
  ll k;
  cin>>n>>k;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  
  vector<int> s;
  vector<int> ord(n+1,-1);
  int cycle; //周期
  int l=0;
  {
    int v = 1; //頂点
    while(ord[v]==-1){ //まだ訪れてないなら 
      ord[v] = s.size(); //何番目
      s.push_back(v); //訪れた頂点
      v=a[v-1];
    }
    cycle=s.size()-ord[v];
    l=ord[v];
  }

  if(k<l) cout<<s[k]<<endl;
  else {
    k-=l;
    k%=cycle;
    cout<<s[l+k]<<endl;
  }
  return 0;
}



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

int main()
{
	int n,i,sum=0;
	cin>>n;
	int a[n+1];
	bool b[105]={0};
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=1;i<=n;i++)
		b[a[i]]=1;
	for(i=1;i<=100;i++)
		if(b[i]==1)
			sum++;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{ s: chars }
    let ans = s.iter().cloned().collect::<String>();
    let ans = ans.replace("A", "1").replace("C", "1").replace("G", "1").replace("T", "1");
    let ans = ans.split(char::is_alphabetic).map(|c| c.len()).max();
    println!("{}", ans.unwrap_or(0));
}


Measured memory_bytes: 2132
#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++)
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;

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

    vector<string> s(n);

    int ac , wa, tle, re;

    ac = 0; wa = 0; tle = 0; re = 0;

    rep (i, n) {
        cin >> s.at(i);
    }

    rep(i, n) {
        if ("AC" == s.at(i)) ac++;
        if ("WA" == s.at(i)) wa++;
        if ("TLE" == s.at(i)) tle++; ;
        if ("RE" == s.at(i)) re++;
    }

    cout << "AC x " << ac << endl;
    
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0; 
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
map<int, int> cnt;
int main() {
  ll n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    for (int j = 2; j <= sqrt(x); j++) {
      while (x % j == 0)
        x /= j, cnt[j]++;
    }
    if (x != 1)
      cnt[x]++;
  }
  ll ans = 1;
  for (pair<int, int> x : cnt)
    ans = ans * (x.ss + 1) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string s;
    cin >> s;
    s[3] = '8';

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
INF = 10**20
N,M = map(int,input().split())
node = [[] for _ in range(N)]
for _ in range(M):
  l,r,d = map(int,input().split())
  node[l-1].append([r-1,d])
  node[r-1].append([l-1,-1*d])

ans = "Yes"
pos = [INF]*N
for i in range(N):
  if pos[i]==INF:
    que = [[i,0]]
    while(que):
      c,cp = que.pop()
      if pos[c]==INF:
        pos[c] = cp
        for n,d in node[c]:
          if pos[n]==INF:
            que.append([n,cp+d])
          elif pos[n] != cp+d:
            ans="No"
            break
        else:
          continue
        break
      elif pos[c] != cp:
        ans="No"
        break
    else:
      continue
    break
print(ans)
      
      
    


Measured memory_bytes: 116512
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

// template <class T>
// bool contain(const std::string& s, const T& v) {
//   return s.find(v) != std::string::npos;
// }

int main(){
    string s, t;
    cin >> s >> t;
    int slen = s.size(), tlen = t.size();

    int res = 0;

    rep(i, slen-tlen+1){
        int tmp=0;
        rep(j, tlen){
            if(s[i+j]==t[j]){
                tmp++;
            }
        }
        res = max(tmp, res);
    }

    // rep2(i, 1, tlen+1){
    //     rep(j, i){
    //         string x = t.substr(j, tlen - i + 1);
    //         rep(k, slen-x.size()+1){
    //             int tmp=0;
    //             rep(l, tlen){
    //                 if(s[k+l]==t[l]){
    //                     tmp++;
    //                 }
    //             }
    //             res = max(tmp)
    //         }
    //     }
    // }

    // rep2(i, 1, tlen+1){
    //     rep(j, i){
    //         string x = t.substr(j, tlen-i+1);
    //         int seq=0;
    //         rep2(k, j, slen-(i-j-1)){
    //             if(x[seq]==s[k]){
    //                 seq++;
    //             }else{
    //                 seq=0;
    //             }
    //             if(seq==x.size()){
    //                 cout << tlen - seq << endl;
    //                 return 0;
    //             }
    //         }
    //     }
    // }

    cout << tlen - res << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,s.length()){
        if(s[i]=='2')ans++;
    }
    cout<<ans<<endl;
}

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

ll f(ll x,ll y){
  ll sumx=0,sumy=0;
  while(x>0){
    x/=10;
    sumx++;
  }
  while(y>0){
    y/=10;
    sumy++;
  }
  return (max(sumx,sumy));
}

int main(){
  ll n;cin>>n;
  ll q = sqrt(n),sum = 1e8;
  for(ll i = 1;i<=q;i++){
    if (n%i==0){
      ll a = i,b = n/i;
      sum = min(sum,f(a,b));
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt(), w= in.nextInt();
		boolean[] ff = new boolean[h];
		String[] a = new String[h]; in.nextLine();
		for(int i = 0; i < h; i++ ){
			a[i] = in.nextLine();
		}
		for(int i = 0; i < h; i++){
			ff[i] = false;
			for(int k = 0; k < w; k++) {
				if(a[i].charAt(0) == '#' || a[i].charAt(0) != a[i].charAt(k)) {
					ff[i] = true;
					break;
				}
			}
		}
		for(int i = 0; i < w; i++) {
			boolean f = true;
			for(int k = 0; k < h; k++) {
				if(a[0].charAt(i) == '#' || a[0].charAt(i) != a[k].charAt(i)) {
					f = false;
				}
			}
			// System.out.println(f);
			if(f) {
				for(int k = 0; k < h; k++) {
					// System.out.println(i);
					a[k] = a[k].substring(0, i) + a[k].substring(i + 1);
				}
				w--;
				i--;
			}
		}
		// System.out.println(w);
		for(int i = 0; i < h; i++){
			if(ff[i]) {	
				System.out.println(a[i]);
			}
		}
	}
}
	


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

int main()
{
    int N, K, x, sum;
    sum = 0;
    cin >> N >> K;
  
    for (int i = 0; i < N; i++)
    {
        cin >> x;
        if ((x * x) <= ((x - K) * (x - K)))
        {
            sum += 2 * x;
        }
        else if (x - K > 0)
        {
            sum += 2 * (x - K);
        }
        else
        {
            sum += 2 * (K - x);
        }
    }
    cout << sum << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
	cin >> n;
	vector<int> w(n + 1);
	rep (i, n) cin >> w[i];
	rep (i, n) w[i + 1] += w[i];
	int res = Inf;
	rep (i, n) {
	  int diff = abs(w[i] - (w[n] - w[i]));
	  res = min(res, diff);
	}
	cout << res << endl;
	
    return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 1e5 + 1000;
int n, m, a[N], b[N], vis[N], Size[N];
int fa[N];
stack<long long> ans;

int find(int x){
  	return fa[x] == x? x : fa[x] = find(fa[x]);
}

long long num(){
    for (int i = 1; i <= n; i++) vis[i] = 0;
  	long long res = 0;
  	for (int i = 1; i <= n; i++){
        int o = find(i);
        if (!vis[o]){
            long long t = Size[o];
            res += (t*(t-1))/2;
            vis[o] = 1;
        }
    }
  	return res;
}

int main(){
  	//cin >> n >> m;
  	scanf("%d%d", &n, &m);
  	for (int i = 1; i <= n; i++) fa[i] = i, Size[i] = 1;
  	for (int i = 1; i <= m; i++){
      	//cin >> a[i] >> b[i];
      	scanf("%d%d", &a[i], &b[i]);
    }
    long long sum = 1LL*n*(n-1)/2, res = 0;
    ans.push(sum);
  	for (int i = m - 1; i >= 1; i--){
      //long long t = num();
      //ans.push(sum - t);
      int o = find(a[i+1]);
      int p = find(b[i+1]);
      if (o != p){
            if (Size[o] > Size[p]) swap(o, p);
            fa[o] = p;
            res += 1LL * Size[p] * Size[o];
            Size[p] += Size[o];
      }
      ans.push(sum - res);
    }
  	while (ans.size() > 0){
      //cout << ans.top() << endl;
      printf("%lld\n", ans.top());
      ans.pop();
    }
  	return 0;
}



Measured memory_bytes: 3484
N = int(input())
A, B = map(int, input().split())
Ps = list(map(int, input().split()))
n1 = 0
n2 = 0
n3 = 0
for P in Ps:
  if P <= A:
    n1 += 1
  if A+1 <= P <= B:
    n2 += 1
  if P >= B+1:
    n3 += 1
r = min(n1, n2, n3)
print(r)


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

typedef long long ll;

using namespace std;

int main(){
 int N,Y; cin >> N >> Y;
  
  for(int x = 0; x <= N; x++){
    for(int y = 0; y <= N; y++){
      int z = N-x-y; if( z < 0){ continue;}
      
      if( 10000*x + 5000*y + 1000*z == Y){ cout << x << " " << y << " " << z << endl;
                                          return 0;}
    }
  }
  
  cout << "-1 -1 -1" << endl; return 0;}

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


int f(int X) {
	int sum[N + 1] = {};
	rep(i, N) {
		if (a[i] < X) sum[i + 1] = -1;
		else sum[i + 1] = 1;
	}
	rep(i, N + 1) {
		sum[i + 1] += sum[i];
	}
	int cnt[200020] = {};
	rep(i, N) {
		//cout << sum[i + 1] << " ";
		cnt[sum[i + 1] + 100010]++;
	}
	//cout << endl;
	int tmp = 0;
	rep(i, 100010) {
		tmp += cnt[i + 100010];
	}
	int ret = tmp;
	rep(i, N){
		//REP(j, -3, 3) {
		//	cout << j << " " << cnt[j + 100010] << endl;
		//}
		//cout << endl;
		if (sum[i] < sum[i + 1]) tmp -= cnt[sum[i] + 100010];
		else tmp += cnt[sum[i + 1] + 100010];
		tmp--; cnt[sum[i + 1] + 100010]--;
		ret += tmp;
		//cout << "*" << tmp << endl;
	}
	//cout << tmp << endl;
	return ret;
}


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> N;
	rep(i, N) cin >> a[i];
	if (N == 1) {
		cout << a[0] << endl;
		return 0;
	}
	int ok = 0;
	int ng = 20000000001;
	while (ng - ok > 1) {
		int mid = (ok + ng) / 2;
		//cout << mid << " " << f(mid) << endl;
		int num = N * (N + 1) / 2;
		if (f(mid) >= (num + 1) / 2 ) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;




    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int A,B,C,K;
    int res[3];
    int mul[3]={1,0,-1};
    rep(i,0,3)cin>>res[i];
    cin>>K;
    ll sum=0;
    int p=0;
    rep(i,0,3){
        if(K>0&&res[i]>0){
            sum+=mul[i]*min(K,res[i]);
            K-=res[i];
        }
    }
    cout<<sum<<endl;
    return 0;
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string a,b;
    cin >> a >> b;

    int tmp = stoi(a+b);
    bool flag = false;
    rep(i,317)
    {
	    if (tmp == i*i)
	    {
		    flag = true;
		    break;
	    }
    }
    if (flag)
    {
	    cout << "Yes" << endl;
    }
    else
    {
	    cout << "No" << endl;
    }
    



//    cout << a + b << endl;
    
}


Measured memory_bytes: 256
while True:
    shuffle = []
    card = []
    card = list(str(input()))
    if card[0] == '-':
        break
    m = int(input())

    for i in range(m):
        shuffle.append(int(input()))

    for i in shuffle: 
        for j in range(i):
            card.append(card.pop(0))

    print(''.join(map(str, card)))



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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

// フェルマーの小定理を使った計算
class Felmat
{
  ll M;
  vector<ll> fac;  // n! (mod M)
  vector<ll> ifac; // k!^{M-2} (mod M)

public:
  Felmat(ll max_nk, ll m)
  {
    M = m;
    fac.reserve(max_nk + 1);
    ifac.reserve(max_nk + 1);
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < max_nk; i++) {
      fac[i + 1] = fac[i] * (i + 1) % M;              // n! (mod M)
      ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M)
    }
  }
  ll mpow(ll x, ll n)
  { // x^n (mod M)
    ll ans = 1;
    while (n != 0) {
      if (n & 1)
        ans = ans * x % M;
      x = x * x % M;
      n = n >> 1;
    }
    return ans;
  }
  ll minv(ll a)
  { // 1/a (mod M)
    ll b = M, u = 1, v = 0;
    while (b) {
      ll tmp = a / b;
      a -= tmp * b;
      swap(a, b);
      u -= tmp * v;
      swap(u, v);
    }
    u %= M;
    if (u < 0)
      u += M;
    return u;
  }
  ll mfac(ll x)
  { // n! (mod M)
    int i;
    return fac[x];
  }
  ll comb(ll n, ll k)
  { // nCk (mod M)
    if (n == 0 && k == 0)
      return 1;
    if (n < k || n < 0)
      return 0;
    ll tmp = ifac[n - k] * ifac[k] % M;
    return tmp * fac[n] % M;
  }
  ll perm(ll n, ll k)
  { // nPk (mod M)
    if (n < k)
      return 0;
    ll tmp = ifac[n - k] % M;
    return tmp * fac[n] % M;
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  
  Felmat fm(2005, MOD);

  int N, K;
  cin >> N >> K;
  for (int i = 1; i <= K; i++) {
    ll a = fm.comb(K - 1, i - 1);
    ll b = fm.comb(N - K + 1, i);
    // ll b = fm.comb(N - K + i, i);
    dump(a, b);
    cout << a * b % MOD << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	x := make(map[int]struct{})
	f := true
	for _, v := range a {
		y := PrimeFactors(v)
		for k, _ := range y {
			if _, ok := x[k]; ok {
				f = false
			} else {
				x[k] = struct{}{}
			}
		}
	}
	if f {
		fmt.Println("pairwise coprime")
	} else {
		b := a[0]
		for _, v := range a {
			b = gcd(v, b)
		}
		if b == 1 {
			fmt.Println("setwise coprime")
		} else {
			fmt.Println("not coprime")
		}
	}
}
func PrimeFactors(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2]++
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i]++
			n = n / i
		}
	}
	if n > 2 {
		pfs[n]++
	}
	return pfs
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 22440
#include<stdio.h>
int time[24][60];
int main(void)
{
    int i,j,h,m,f;
    for(i=0; i<2; ++i) {
        scanf("%d",&j);
            for(;j>0;--j) {
                scanf("%d %d",&h,&m);
                time[h][m]=1;
                }
            }
            f=1;
            for(i=0;i<24;i++)
                for(j=0;j<60;j++)
                    if(time[i][j]){
                        if(!f)printf(" ");
                        else f=0;
                        printf("%d:%02d",i,j);
                        }
                    printf("\n");
                    return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;

int main()
{
    fastio;
    ll n,a,b;
    cin>>n>>a>>b;

    int x=abs(a-b)-1;

    if(x&1)cout<<"Alice"<<nl;
    else cout<<"Borys"<<nl;

    bdyptb;
}

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

int h, w, k;
vector<string> s;

bool judge(int i, int j)
{
  int c = 0;
  rep(p, h-1)
  {
    if (s[p][j] == '1')
    {
      c++;
      if (c > k)
        return false;
    }
    if (i>>p&1)
      c = 0;
  }
  return true;
}

int main()
{
  cin >> h >> w >> k;
  s.resize(h);
  rep(i, h)
    cin >> s[i];
  vector<vector<int>> csum(h, vector<int>(w + 1, 0));
  rep(i, h)
    rep(j, w)
      if (s[i][j] == '1')
        csum[i][j+1] = csum[i][j] + 1;
      else
        csum[i][j+1] = csum[i][j];
  int ans = 100000000;
  rep(i, 1<<h-1)
  {
    int tmp = __builtin_popcount(i);
    int l = 0;
    for (int x=1; x<=w; x++)
    {
      if (!judge(i, x - 1))
        break;
      int vsum = 0;
      rep(y, h)
      {
        vsum += csum[y][x] - csum[y][l];
        if (vsum > k)
        {
          tmp++;
          l = x - 1;
          break;
        }
        if (i>>y&1)
          vsum = 0;
      }
      if (x == w)
        ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int P;
	int Q;
	int R;
	cin >> P >> Q >> R;

	int ans;
	ans = P + Q;
	if (ans > Q + R) {
		ans = Q + R;
	}
	if (ans > R + P) {
		ans = R + P;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;
 
int main(){
	long long int n, y;
	cin >> n >> y;
	int a1 = -1, a2 = -1, a3 = -1;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n - i; j++){
			if(1000 * i + 5000 * j + 10000 * (n - i - j) == y){
				a1 = i;
				a2 = j;
				a3 = n - i - j;
			}
		}
	}
	cout << a3 << " " << a2 << " " << a1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    
    int dp(int n, int left, vector<int> &a, vector<int> &b, vector<vector<int> > &minmp)
    {
      if (minmp[n][left] != -1) return minmp[n][left];
      if (left <= 0) return 0;

      int ret = b[n] + dp(n, max(left-a[n], 0), a, b, minmp);
      if (n > 0) ret = min(ret, dp(n-1, left, a, b, minmp));
      
      minmp[n][left] = ret;
      
      return ret;
    }

    int main()
    {
      int h, n; cin >> h >> n;
      vector<int> a(n), b(n);
      for (int i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
      
      vector<vector<int> > minmp(n, vector<int>(h+1, -1));      
      cout << dp(n-1, h, a, b, minmp) << endl;
    }

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

public class Hello
{
    public static void Main()
    {
        hoge();
        //System.Console.ReadLine();
    }

     public static void hoge()
    {
        var vars = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var n = vars[0];
        var k = vars[1];

        var p = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); ;

        p = p.OrderBy(x => x).ToArray();

        long ans = 0;
        for(int i = 0; i < k; i++)
        {
            ans += p[i];
        }
        Console.WriteLine(ans);

    }
}

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

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

    int n;
    cin>>n;

    vector<double> a(n);

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

    sort(a.begin(),a.end());

    double ans=0;

    for(int i=1;i<n;i++)
    {
        a[i]=(a[i-1]+a[i])/2.0;
        ans=a[i];
    }

    printf("%.5lf", ans);

    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  int zeros=0,ones=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0'){zeros++;}
    else{ones++;}
  }
  cout<<2*min(ones,zeros)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    int v[n], c[n];
    repi(i, n, 0)
    {
        cin >> v[i];
    }
    repi(i, n, 0)
    {
        cin >> c[i];
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        int x = 0, y = 0;
        repi(i, n, 0)
        {
            if (bit & (1 << i))
            {
                x += v[i];
                y += c[i];
            }
        }
        ans = max(ans, x - y);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;


int StepsData[31] = { 0,1,2,4 };



int main(void) {
	int n, years;

	for (int i = 4; i < 31; i++) {
		StepsData[i] = StepsData[i - 3] + StepsData[i - 2] + StepsData[i - 1];
	}

	while (cin >> n, n) {
		years = StepsData[n] / 3650;

		if (StepsData[n] % 3650 != 0) {
			years++;
		}
	
		cout << years << endl;		
	}

	return 0;
}


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

using namespace std;

void solve(){
    int n;
    cin>>n;
    if(n%1000==0)cout<<0;
    else{
        int a=n/1000;
        cout<<(a+1)*1000-n;
    }
}

int main()
{
    int n;
    cin>>n;
    if(n%1000==0)cout<<0;
    else{
        int a=n/1000;
        cout<<(a+1)*1000-n;
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
int main() {
	string s, ans;
	cin >> s;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == '0') ans += "0";
		else if (s[i] == '1') ans += "1";
		else if (s[i] == 'B'&&ans.length() != 0) ans.erase(--ans.end());
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	ll n,k;
	cin >> n >> k;
	vector<ll> x(n);
	for(ll i=0;i<n;i++)cin >> x[i];
	ll ans = LLONG_MAX;

	for(int i = 0;i<n-k+1;i++)
	{
		if(x[i]*x[i+k-1]<0)
		{
			ans = min(ans,x[i+k-1]-x[i]+min(abs(x[i]),abs(x[i+k-1])));
		}
		else
		{

			ans = min(ans,max(abs(x[i+k-1]),abs(x[i])));
		}
	}
	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

using ll = long long int;
using vi = vector<int>;
#define f(n) for(int i = 0; i < n; i++)
#define fj(n) for(int j = 0; j < n; j++)
#define fk(n) for(int k = 0; k < n; k++)
#define ci(n) cin >> n;
#define ic(n) int n; cin >> n;
#define lc(n) int n; cin >> n;
#define all(a) a.begin(), a.end()
#define pri(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define sc(a, n) int a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define scl(a, n) ll a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define pb push_back
#define eb emplace_back
#define int long long
const int inf = 2e9;

vector<int> get(vector<int> &a)
{
    int n = a.size();
    int line[n + 1] = {0};
    f(n)
    {
        line[max(0ll, i - a[i])]++;
        line[min(n, i + a[i] + 1)]--;
    }
    vector<int> res(n);
    int bal = 0;
    f(n) bal += line[i], res[i] = bal;
    return res;
}
bool check(vector<int> &a)
{
    bool res = true;
    int n = a.size();
    f(n) if(a[i] < a.size()) res = false;
    return res;
}
void solve(int ci)
{
    ic(n) ic(k)
    vector<int> a(n);
    f(n) cin >> a[i];
    for(int i = 0; i < k && !check(a); i++) a = get(a);
    pri(a, n)
}

signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    //cin >> t;
    f(t) solve(i + 1);
}


Measured memory_bytes: 7900
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

Q = iin()
lr = [iln() for _ in range(Q)]
max_num = 10**5
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

primes = sieves_of_e(max_num)

c = [0 for _ in range(max_num+2)]
for i in range(max_num+1):
    c[i+1] = c[i]
    if i % 2 == 1 and primes[i] and primes[(i+1)//2]: c[i+1] += 1

for i in range(Q):
    left = lr[i][0]
    right = lr[i][1]+1
    print(c[right]-c[left])





Measured memory_bytes: 31868
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n;
    cin >> n;
    map<p, ll> I{};
    vector<p> vp;
    for(ll i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        vp.push_back(p(a, b));
    }
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < n; j++){
            if(i==j) continue;
            ll a = vp[i].first-vp[j].first;
            ll b = vp[i].second-vp[j].second;
            I[p(a, b)]++;
        }
    }
    ll ans = 0;
    ll MAX = 0;
    for(auto x : I)
        MAX = max(MAX, x.second);
    //cout << MAX << endl;
    cout << n-MAX << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
  int a, b, c, x;
  
  scanf("%d%d%d", &a, &b, &c);
  
  x=a; a=b; b=x;
  x=a; a=c; c=x;
  
  printf("%d %d %d\n", a, b, c);
  
  return 0;
}
  

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

namespace AtCoder{
  
class Program{
  
  static void Main(){
    
    int N = int.Parse(Console.ReadLine());
    var workList = new List<Work>();
    
    for (int i = 0; i < N; i++){
      string[] input = Console.ReadLine().Split(' ');
      int A = int.Parse(input[0]);
      int B = int.Parse(input[1]);
      var elem = new Work(A, B);
      workList.Add(elem);
    }
    workList.Sort();
    
    int time = 0;
    string ans = "Yes";
    for (int i = 0; i < N; i++){
      if ((time += workList[i].A) > workList[i].B){
        ans = "No";
        break;
      }
    }
    
    Console.WriteLine(ans);
  }
}

public class Work : IComparable{
  public int A {get; set;}
  public int B {get; set;}
  
  public Work(int timeA, int timeB){
    this.A = timeA;
    this.B = timeB;
  }
  
  public int CompareTo(object obj){
    Work wobj = (Work)obj;
    return this.B - wobj.B;
  }
  
}
  
}

Measured memory_bytes: 27556
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

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

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

n=int(input())
L=deque([i for i in range(1,10)])
if n<=9:
    ans = L[n-1]
else:
    cnt = 9
    for i in range(1,n):
        c=L.popleft()
        
        if c%10!=0:
            L.append(c*10+(c%10)-1)
            cnt+=1
            if cnt>=n:
                break
        L.append(c*10+(c%10))
        cnt+=1
        if cnt>=n:
            break
        
        if c%10!=9:
            L.append(c*10+(c%10)+1)
            cnt+=1
            if cnt>=n:
                break
    ans = L[-1]
print(ans)


Measured memory_bytes: 74904
#学習用
#
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    # curはN本の竹のうち何本を確認したか。
    if cur == N:
        # 全ての竹を確認した後の場合
        return abs(a - A) + abs(b - B) + abs(c - C) if min(a,b,c) > 0 else INF
    # cur本目の竹を使用しない場合
    ret0 = dfs(cur + 1, a, b, c)
    # cur本目の竹をAに使用する場合
    ret1 = dfs(cur + 1, a + l[cur], b, c) + (10 if a > 0 else 0)
    # cur本目の竹をBに使用する場合
    ret2 = dfs(cur + 1, a, b + l[cur], c) + (10 if b > 0 else 0)
    # cur本目の竹をCに使用する場合
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + (10 if c > 0 else 0)
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

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

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

type SortSlice []int

func (s SortSlice) Len() int {
        return len(s)
}

func (s SortSlice) Swap(i, j int) {
        s[i], s[j] = s[j], s[i]
}

func (s SortSlice) Less(i, j int) bool {
        return s[i] < s[j]
}

func reverseString(str string) string {
        buf := []rune(str)
        for i, j := 0, len(buf)-1; i < j; i, j = i+1, j-1 {
                buf[i], buf[j] = buf[j], buf[i]
        }
        return string(buf)
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
        line := nextLine()
        N := parseInt(line)

        line = nextLine()
        spl := strSprit(line)
        D := parseInt(spl[0])
        X := parseInt(spl[1])

        a := make([]int, 100)

        for i := 0; i < N; i++ {
                line = nextLine()
                a[i] = parseInt(line)
        }

        sum := X

        for i := 1; i <= D; i++ {
                for j := 0; j < N; j++ {
                        if i%a[j] == 1 || a[j] == 1 {
                                sum++
                        }
                }
        }

        fmt.Println(sum)
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> xi = new ArrayList<>();
        List<Integer> yi = new ArrayList<>();
        double D1 = 0;
        double D2 = 0;
        double D3 = 0;
        double D4 = 0;
        int k = 0;
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            xi.add(x);
        }
        for (int i = 0; i < n; i++) {
            int y = sc.nextInt();
            yi.add(y);
        }
        for (int i = 0; i < n; i++) {
            k = Math.abs(xi.get(i) - yi.get(i));
            D1 += k;
            D2 += Math.pow(k,2);
            D3 += Math.pow(k,3);
            if(D4 < k)
                D4 = k;
        }
        System.out.println(D1);
         System.out.println(Math.sqrt(D2));
          System.out.println(Math.cbrt(D3));
           System.out.println(D4);
    }
}

Measured memory_bytes: 26528
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 999999999
const int mod = 1000000007;
ll cnt = 0;

int main(){
  int n,m;
  cin >> n >> m;
  int a[m];
  ll all=0;
  rep(i,m){
      cin>> a[i];
      all+=a[i];
  }
  if(n-all < 0){
      cout << -1 << endl;
      return 0;
  }else cout << n-all << endl;

}

Measured memory_bytes: 3676
while True:
    mylist = []
    n = input()
    n = int(n)
    if n ==0:
        break
    for i in range(0,n):
        mylist.append(int(input()))
    mylistz = sorted(mylist)
    del mylistz[0]
    del mylistz[n-2]
    print(int(sum(mylistz))//(n-2))




Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX = 100000;

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a), q(b), r(c);
	for (int i = 0; i < a; i++) cin >> p[i];
	for (int i = 0; i < b; i++) cin >> q[i];
	for (int i = 0; i < c; i++) cin >> r[i];
	sort(p.begin(), p.end(), greater<int>());
	sort(q.begin(), q.end(), greater<int>());
	p.resize(x);
	q.resize(y);
	p.reserve(3 * MAX);
	p.insert(p.end(), q.begin(), q.end());
	p.insert(p.end(), r.begin(), r.end());
	sort(p.begin(), p.end(), greater<int>());
	long long ans = 0;
	for (int i = 0; i < x+y; i++) {
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2168
n,k = map(int, input().split())
AR = n + 1
mod = 10**9+7
ans = 0

def calc_ans(AR,i):
	max = AR*(AR-1)/2 - (AR-i)*(AR-i-1)/2
	min = i*(i-1)/2
	return max - min +1

for i in range(k, AR+1):
	ans += calc_ans(AR,i)

print(int(ans % mod))

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

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

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

int main(void){
    ll N,M; cin >> N >> M;
    VI A(N), B(M); REP(i,N) cin >> A[i]; REP(i,M) cin >> B[i];
    SORT(A); SORT(B);
    VI sa(A), sb(B);
    sa.erase(unique(ALL(sa)), sa.end()); sb.erase(unique(ALL(sb)), sb.end());
    if(sa.size() < N || sb.size() < M){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    RFOR(i,N*M+1,1){
        ll it1 = LB(A,i), it2 = LB(B,i);
        if(it1<N && A[it1]==i && it2<M && B[it2]==i) continue;
        else if(it1<N && A[it1]==i) ans *= M-it2;
        else if(it2<M && B[it2]==i) ans *= N-it1;
        else ans *= (M-it2)*(N-it1) - (N*M-i);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

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

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

  
  vector<pair<int, int>> P;
  rep(i,n){
    int a;
    cin >> a;
    P.push_back(make_pair(a,i+1));
  }
  sort(P.begin(), P.end());

  rep(i,n)printf("%d ",P[i].second);
  cout << endl;
  return 0;
}

Measured memory_bytes: 1780
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

const int MAX = 2000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long nHm(int n, int m)
{
    return fac[n] * (finv[n - m] * finv[m] % MOD) % MOD;
}

int main()
{
    COMinit();

    lint n, k;

    scanf("%lld", &n);
    scanf("%lld", &k);

    for (int i = 0; i < k; ++i)
    {
        if (n - k + 1 < i + 1)
        {
            printf("%d\n", 0);
        }
        else
        {
            lint b = nHm(k - 1, i + 1 - 1);
            lint r = nHm(n - k + 1, i + 1);
            printf("%lld\n", b * r % MOD);
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX(x,y) x>y?x:y

int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main(){
	long N,*arr,*save;
	scanf("%ld",&N);
	arr=malloc(sizeof(long)*N);
	save=malloc(sizeof(long)*N);
	for(long i=0;i<N;i++){
		scanf("%ld",&arr[i]);
		save[i]=arr[i];
	}
	qsort(arr,N,sizeof(long),cmpfunc);
	for(long i=0;i<N;i++)
	{
		if(save[i]<=arr[N/2-1])	printf("%ld\n",arr[N/2]);
		else printf("%ld\n",arr[N/2-1]);
	}	
	free(arr);
	free(save);
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S;
int from[4];
int to[4];

ll hoge(string S) {
	vector<int> V;
	V.push_back(0);
	FORR(c,S) {
		if(c=='0') V.push_back(0);
		else V.back()++;
	}
	
	ZERO(from);
	for(int i=1;i<V.size();i++) {
		
		// 0-none 1-left 2-right 3-keep
		if(V[i]==1) {
			to[0]=max({from[0],from[1]+V[i-1]-1,from[2]+1,from[3]+V[i-1]});
			to[1]=max({from[0],from[1]+V[i-1]-1,from[3]+V[i-1]});
			to[2]=max({from[0],from[1],         from[2],from[3]});
		}
		else {
			to[0]=max({from[0],from[1]+V[i-1]-1,from[2]+V[i]});
			to[1]=max({from[0],from[1]+V[i-1]-1,from[3]+V[i-1]});
			to[2]=max({from[0],from[1]+V[i-1]-1,from[2]+V[i]-1,from[3]+V[i-1]});
		}
		to[3]=max({from[0],from[1],from[2],from[3]});
		
		
		swap(from,to);
	}
	int ret=max({from[0],from[1],from[2],from[3]});
	//cout<<S<<" "<<ret<<endl;
	return ret;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S;
	N+=2;
	S+="00";
	ll ret=0;
	FOR(i,N) {
		if(S[i]=='0') continue;
		for(j=i+1;j<N;j++) {
			if(S[j]=='0' && S[j+1]=='0') {
				ret+=hoge(S.substr(i,j-i));
				i=j+1;
				break;
			}
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1308
n,t=map(int,input().split())
ct=[list(map(int,input().split())) for _ in range(n)]


ct=sorted(ct, key=lambda x:(x[0], x[1]))

for i in range(n):
    if ct[i][1]<=t:
        print(ct[i][0])
        break
else:
    print("TLE")

Measured memory_bytes: 3064