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

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
const int maxn=1005;
//i_am_noob
int n,d,a[maxn],b[maxn];
two_sat noob(maxn);
vector<bool> vec;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> d;
    rep(n) cin >> a[i] >> b[i];
    rep(n) rep2(j,i+1,n){
        if(abs(a[i]-a[j])<d) noob.add_clause(i,false,j,false);
        if(abs(a[i]-b[j])<d) noob.add_clause(i,false,j,true);
        if(abs(b[i]-a[j])<d) noob.add_clause(i,true,j,false);
        if(abs(b[i]-b[j])<d) noob.add_clause(i,true,j,true); 
    }
    if(!noob.satisfiable()){
        print1("No");
        return 0;
    }
    vec=noob.answer();
    print1("Yes");
    rep(n) print1(vec[i]?a[i]:b[i]);
    return 0;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
vector<int> V;

int main(){

	scanf("%d",&N);

	int tmp;
	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		V.push_back(tmp);
	}

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

	if(V[N/2] == V[N/2-1]){

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

	}else{

		printf("%d\n",V[N/2]-V[N/2-1]);
	}

	return 0;
}


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



// Requires lazy_tag
template<typename L>
struct reverse_segment_tree{
	reverse_segment_tree(): reverse_segment_tree(0){}
	reverse_segment_tree(int n): n(n){
		vector<L> v(n);
		for(int i = 0; i < n; ++ i) v[i] = {i, i + 1};
		*this = reverse_segment_tree(v);
	}
	reverse_segment_tree(const vector<L> &v): n((int)v.size()){
		log = __lg(n + 1) + 1;
		size = 1 << log;
		lazy = vector<L>(size << 1);
		copy(v.begin(), v.end(), lazy.begin() + size);
		for(int i = 1; i < size; ++ i){
			int h = log - __lg(i);
			lazy[i] = {(i << h) - size, (i + 1 << h) - size};
		}
	}
	void update(int l, int r, L x){
		if(l >= r) return;
		l += size, r += size;
		for(int i = log; i >= 1; -- i){ // for non-commutative operations
			if(((l >> i) << i) != l) push(l >> i);
			if (((r >> i) << i) != r) push(r - 1 >> i);
		}
		for(; l < r; l >>= 1, r >>= 1){
			if(l & 1) lazy[l ++] = x + lazy[l];
			if(r & 1) lazy[r] = x + lazy[-- r];
		}
	}
	L query(int qp){
		L res{qp, qp + 1};
		for(int p = qp + size; p > 0; p >>= 1) res = lazy[p] + res;
		return res;
	}
	void push(int i){
		lazy[i << 1] = lazy[i] + lazy[i << 1];
		lazy[i << 1 | 1] = lazy[i] + lazy[i << 1 | 1];
		int h = log - __lg(i);
		lazy[i] = {(i << h) - size, (i + 1 << h) - size};
	}
	void push(){
		for(int i = 1; i < n; ++ i) push(i);
	}
	int n, size, log;
	vector<L> lazy;
};

struct L{ // Semigroup (Lazy type) / call L(l, r) for initial lazy type for interval [l, r)
	int val;
	L(){
	}
	L(int val): val(val){
	}
	L(int l, int r): val(-1){
	}
	L operator+(const L &x) const{
		return ~val ? *this : x;
	} // Monoid operator, always applies superset to subset
};

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n, qn;
	cin >> n >> qn;
	int active_v = n - 1, active_h = n - 1;
	vector<L> v(n - 1, {n - 1}), h(n - 1, {n - 1});
	reverse_segment_tree<L> segv(v), segh(h);
	long long cnt = 1LL * (n - 2) * (n - 2);
	for(auto qi = 0; qi < qn; ++ qi){
		int type, p;
		cin >> type >> p, -- p;
		if(type == 2){
			swap(active_v, active_h);
			swap(segv, segh);
		}
		int x = segh.query(p).val;
		segh.update(p, p + 1, {0});
		cnt -= x - 1;
		if(p < active_h){
			segv.update(0, x, {p});
			active_h = p;
		}
		if(type == 2){
			swap(active_v, active_h);
			swap(segv, segh);
		}
	}
	cout << cnt << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 8460
#include <algorithm>
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

std::string S;

int main()
{
  std::cin >> S;

  if( S.size() == 2 )
    std::cout << S << std::endl;
  else
  {
    std::reverse( all(S) );
    std::cout << S << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,l;
int arr[100009];
vector<int>ans;
int main(){
    cin>>n>>l;
    int sum = 0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    for(int i=0;i<n-1;i++){
        if(arr[i]+arr[i+1]>=l){
            cout<<"Possible"<<endl;
            for(int j=0;j<i;j++){
                cout<<j+1<<" ";
            }
            for(int j=n-1;j>i;j--){
                cout<<j<<endl;
            }
            exit(0);
        }
    }
    for(int i=n-1;i>0;i--){
        if(arr[i]+arr[i-1]>=l){
            cout<<"Possible"<<endl;
            for(int j=n-1;j>=i;j--){
                cout<<j<<" ";
            }
            for(int j=0;j<i;j++){
                cout<<j+1<<endl;
            }
            exit(0);
        }
    }
    cout<<"Impossible"<<endl;
}


Measured memory_bytes: 1152
t = gets.to_s.to_i

t.times do

  n = gets.to_s.to_i
  a = gets.to_s.split.map{|t| t.to_i }
  s = gets.to_s.chomp
  
  f = false
  bases = []
  (0...n).reverse_each do |i|
    bases.each do |base|
      a[i] = [a[i], a[i] ^ base].min
    end
    if a[i] != 0
      if s[i] == '0'
        bases.push a[i]
      else
        f =  true
        break
      end
    end
  end
  
  puts f ? 1 : 0
end

Measured memory_bytes: 14360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

ll d;
vector<ll> c(26);
vector<vector<ll>> s(365, vector<ll>(26));
vector<ll> t(365);

vector<ll> calc() {
  vector<ll> nsc(26);
  vector<ll> score(d);
  vector<ll> last(26, -1);
  rep(i, d) {
    last[t[i]] = i;
    rep(j, 26) {
      if (t[i] == j) nsc[j] += s[i][j];
      else nsc[j] -= c[j]*(i-last[j]);
    }
    ll sum = 0;
    rep(j, 26) sum += nsc[j];
    score[i] = sum;
  }
  return score;
}

int main()
{
  srand((unsigned)time(NULL));

  cin>>d;
  rep(i, 26) cin>>c[i];
  rep(i, d) rep(j, 26) cin>>s[i][j];

  rep(i, d) {
    ll tmp = 0;
    ll ma = -inf;
    rep(j, 26) {
      if (s[i][j] > ma) {
        ma = s[i][j];
        tmp = j;
      } else if (s[i][j] == ma) {
        if (c[j] < c[tmp]) {
          tmp = j;
        }
      }
    }
    t[i] = tmp;
  }
  vector<ll> fsc = calc();

  {
    vector<ll> last(26, -1);
    vector<ll> nsc(26);
    rep(i, d) {
      ll idx = 0;
      ll sum = 0;
      rep(j, 26) {
        nsc[j] -= c[j]*(i-last[j]);
        sum += nsc[j];
      }
      rep(j, 26) {
        ll aa = sum + c[j]*(i-last[j]) + s[i][j];
        ll bb = sum + c[idx]*(i-last[idx]) + s[i][idx];
        if (aa > bb && aa >= fsc[i]) {
          idx = j;
        }
      }
      nsc[idx] += c[idx]*(i-last[idx]) + s[i][idx];
      last[idx] = i;
      t[i] = idx;
    }
  }
  vector<ll> ssc = calc();

  int ti = clock();
  while (clock() - ti < 197 * CLOCKS_PER_SEC / 100) {
    ll nd = rand() % d;
    ll nx = rand() % 26;
    ll px = t[nd];
    t[nd] = nx;
    vector<ll> tsc = calc();
    if (ssc[d-1] < tsc[d-1]) {
      ssc = tsc;
    } else {
      t[nd] = px;
    }
  }

  rep(i, d) cout << t[i]+1 << endl;

  return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll ac = 0;
  ll bc = 0;
  ll res = 0;
  ll count = 0;
  for(int i = 0;i < n;i++){
    string s;
    cin >> s;
    bool now = false;
    if(s[0] == 'B')bc++,now = true;
    if(s[s.size() - 1] == 'A')ac++,now = true;
    if(now)count++;
    for(int j = 0;j < s.size() - 1;j++){
      if(s[j] == 'A' && s[j + 1] == 'B'){
        res++;
        j++;
      }
    }
  }
  if(count == 0)count++;
  res += min(min(ac,bc),count - 1);
  cout << res << endl;
}

Measured memory_bytes: 384
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N, Ma, Mb = sc.nextInt()
    val M = N * 10
    val INF = N * 100 + 1
    val dp = Array.fill[Int](M + 1, M + 1)(INF)
    dp(0)(0) = 0
    for {
      _ <- 0 until N
    } {
      val a, b = sc.nextInt()
      val c = sc.nextInt()
      for {
        i <- (0 to M).reverse
        j <- (0 to M).reverse
      } if (i - a >= 0 && j - b >= 0) dp(i)(j) = min(dp(i - a)(j - b) + c, dp(i)(j))
    }
    val ans = (Iterator.iterate(1)(_ + 1).takeWhile(m => max(Ma, Mb) * m <= M) map { m => dp(Ma * m)(Mb * m) }).min
    println(if (ans == INF) -1 else ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 34744
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	set<string> S;
	string s;
	while (N--) {
		cin >> s;
		S.insert(s);
	}
	cout << S.size() << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 19316
n,m = map(int,input().split())
py = []
p_y = [[] for i in range(n)]
for _ in range(m):
    p,y = map(int,input().split())
    py.append((p,y))
    p_y[p-1].append(y)
ans = {}
for i, tmp in enumerate(p_y):
    cnt = 1
    p_y[i] = tmp.sort()
    for j, jj in enumerate(tmp):

        ans[(i+1, jj)] = str(i+1).zfill(6) + str(j+1).zfill(6)


for i, tmp in enumerate(py):
    print(ans[tmp])


Measured memory_bytes: 45804
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int a, b;
	cin >> a >> b;


	a--;
	b--;

	cout << (b + a - 1) / a << endl;



	return 0;
}

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

int main(){
 bool is_prime[1000000]; //?´???°???????????¨

 is_prime[0] = is_prime[1] = false;

 for(int i=2; i<1000000; i++){
  is_prime[i] = true;
 }

 for(int i=2; i*i<1000000; i++){
  if(is_prime[i]){
   for(int j=i*i; j<1000000; j+=i){
    is_prime[j] = false;
   }
  }
 }

 int n_prime[1000000]; //?´???°????????°?????¨

 int cnt = 0;

 for(int i=0; i<1000000; i++){
  if(is_prime[i]){
   cnt++;
  }
  n_prime[i] = cnt;
 }

 while(true){
  int n;
  cin >> n;

 if(cin.eof()) break;

 cout << n_prime[n] << endl;
 }

 return 0;
}

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

// N <= 50, K <= 100 とdequeのサイズと操作の回数が小さい
// 詰め込んでから、その部分をまた取り出すのは最適ではない
// よって、最初に取り出し作業して、後で詰め込む
// 「K回まで操作を行える」ことから、K回以内であればよい
// 取り出し作業をi(0 <= i <= min(N,K))回行って、
// 詰め込み作業を(K-i)(K - min(N, K) <= K - i <= K)回以内で行う
// 取り出す深度と取り出した総和に関しては、累積和を用いる
// 最後に詰め込む作業については、優先度付きキューで小さいやつから取り出していって、総和から引く

const int MAX_N = 60;
ll V[MAX_N]; // 1-indexed
ll left_acum[MAX_N], right_acum[MAX_N]; // 1-indexed
int N, K;

ll score(int left_pop, int right_pop) {
    ll sm = left_acum[left_pop] + right_acum[(N+1)-right_pop];
    vector<ll> List;
    for(int i = 0; i < left_pop; ++i) List.push_back(V[1+i]);
    for(int i = 0; i < right_pop; ++i) List.push_back(V[N-i]);
    sort(List.begin(), List.end());
    for(int i = 0, i_len = min(K - (left_pop+right_pop), left_pop+right_pop); i < i_len; ++i) {
        if(List[i] < 0) sm -= List[i];
    }
    return sm;
}

int main()
{
    scanf("%d %d", &N, &K);
    for(int i = 1; i <= N; ++i){
        scanf("%lld", &V[i]);
        left_acum[i] = right_acum[i] = V[i];
    }
    for(int i = 1; i <= N; ++i) left_acum[i] += left_acum[i-1];
    for(int i = N; i >= 0; --i) right_acum[i] += right_acum[i+1];
    ll res = 0;
    for(int A = 0, A_len = min(N, K); A <= A_len; ++A){
        for(int B = 0; A + B <= A_len; ++B) {
            res = max(res, score(A, B));
        }
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int dp[maxn][3];		//dp[i][j]±íÊ¾Ñ¡ÁËa[i][j]µÄ×î»¶ÀÖÊý 
int a[maxn][3],n;

int main() {
	cin>>n;
	for(int i = 0;i < n;i++) {
		for(int j = 0;j < 3;j++) cin>>a[i][j];
	}
	
	dp[0][0] = a[0][0];		//µÚ0ÐÐ³õÊ¼»¯ 
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for(int i = 1;i < n;i++) {
		dp[i][0] += max(dp[i-1][1],dp[i-1][2]) + a[i][0];
		dp[i][1] += max(dp[i-1][0],dp[i-1][2]) + a[i][1];
		dp[i][2] += max(dp[i-1][0],dp[i-1][1]) + a[i][2];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int t[100010], x[100010], y[100010];
  t[0] = x[0] = y[0] = 0;
  rep(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];
  
  for(int i = 1; i <= n; ++i){
  	int dt = t[i] - t[i-1]; //総移動距離
  	int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]); //座標上の変化量
  	
  	if(dt < dist){
  		cout << "No" << endl;
  		return 0;
  	}
  	
  	if(dt%2 != dist%2){
  		cout << "No" << endl;
  		return 0;
  	}
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#define ll long int
const int ARR = 1e5+2;
using namespace std;
int main(){
    ll n,m;
    cin >> n >> m;
    ll a[ARR];
    ll sum = 0;
    for(int i = 0 ; i < m ; i++){
        cin >> a[i];
        sum+=a[i];
    }
    if(sum > n) cout << "-1";
    else cout << n - sum;
}

Measured memory_bytes: 3680
from math import factorial as f
mod=10**9+7

def c(n,k):
    if 0<=k<=n:
        return f(n)//f(k)//f(n-k)
    else:
        return 0

N,K=map(int,input().split())

for i in range(1,K+1):
    print(c(N-K+1,i)*c(K-1,i-1)%mod)

Measured memory_bytes: 3444
// Package main provides
//
// File:  a.go
// Author: ymiyamoto
//
// Created on Thu Jan 17 11:39:12 2019
//
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)
	if A+B < 10 {
		fmt.Println(A + B)
	} else {
		fmt.Println("error")
	}
}


Measured memory_bytes: 512
import java.util.*;

class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int K = sc.nextInt();
      int timesCounter=0;
      int maxCounter=0;
      
      for(int i=0; i<A; i++){
        if(timesCounter == K){
          break;
        }
        timesCounter++;
        maxCounter++;
      }
      
      for(int i=0; i<B; i++){
        if(timesCounter == K){
          break;
        }
        timesCounter++;
      }
      
      for(int i=0; i<C; i++){
        if(timesCounter == K){
          break;
        }
        timesCounter++;
        maxCounter--;
      }
      
      System.out.println(maxCounter);
    }
}

Measured memory_bytes: 35600
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  string s;
  ll k,t=0;
  set<string> list;
  cin >> s>>k;
  for(int i=0;i<s.size();i++){
    for(int j=1;i+j<=s.size()&&j<=k;j++){
      list.insert(s.substr(i,j));
    }
  }
  auto tmp=list.begin();
  for(int i=1;i<k;i++){
    tmp++;
  }
  cout << *tmp<<endl;
}


Measured memory_bytes: 1664
package main
 
import (
  "fmt"
)
 
func main() {
  var a, b, x int
  fmt.Scanf("%d %d %d", &a, &b, &x)
  
  ans := "YES"
  if x < a {
    ans = "NO"
  }
  if x > a + b {
    ans = "NO"
  }
 
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1832
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

 
Node root;
 
Node treeSearch(Node u, int k){ 
  while(u != NIL && k != u->key){
    if(k < (u->key)) u = u->left;
    else u = u->right;
  }
  return u;
 } 

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if((z->key) < (x->key)) x = x->left;
    else x = x->right;
  }
  z->parent = y;
 
  if(y == NIL) root = z;
  else if((z->key) < (y->key)) y->left = z;
  else y->right = z;
 
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
}


int main(){
  int n, i, x;
  char command[20];
  scanf("%d", &n);
   
  for ( i = 0; i < n; i++ ){
    scanf("%s", command);
    if ( command[0] == 'f' ){ 
      scanf("%d", &x); 
      Node t = treeSearch(root, x); 
      if ( t != NIL ) printf("yes\n"); 
      else printf("no\n"); 
    }  
    else if ( command[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( command[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }
  return 0;
}

Measured memory_bytes: 19364
def prime(N):
  factor_li = []
  for i in range(1, int(N**(1/2)//1)+1):
    if N%i == 0:
      factor_li.append(i)
      factor_li.append(N//i)
  return sorted(set(factor_li))

def run():
  n = int(input())
  a_li = sorted(map(int, input().split()))
  factor_li = prime(a_li[0])
  for factor in factor_li:
    for a in a_li[1:]:
      if a%factor != 0:
        break
    else:
      print(factor)
  
if __name__ == '__main__':
  run()


Measured memory_bytes: 5624
#include<iostream>
#include<vector>
#include<cstdlib>

using namespace std;

pair<int,int> min(int a, int b)
{
    if(a <= b)
        return make_pair(a,1);
    if(b < a)
        return make_pair(b,2);

}

int main()
{
    int n;
    cin >> n;
   vector<int> h;
    for(int  i = 0 ; i < n ; i++ )
    {
      	int l;
        cin >> l;
      	h.push_back(l);
    }

    vector<int> dp;
    dp.push_back(0);

    for(int i = 1 ; i < n ; i++)
    {
        pair<int,int> current;
      int sum;
      if(i==1)
      {
        current = make_pair(abs(h[i] - h[i-1]),1);
       	sum = current.first;
      }
      else
      {
        current = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2]);
       
          sum = current.first;
      }
        dp.push_back(sum);
    }

/*
    for(int i = 0 ; i < n ; i++)
    {
        cout << dp[i].first << "," << dp[i].second <<endl;
    }

    int  cost = 0;
    cost += dp[n-1].first;
    int x = dp[n-1].second;n-=1;
 //cout<<"c"<<cost<<"n"<<x;
    while((n - x) >= 1)
    {
        n = n - x ;
        cost += dp[n].first;
        x = dp[n].second;
  //      cout<<"c"<<cost<<"n"<<x;
    }*/
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1400
t = gets.to_i
t.times{
    n = gets.to_i
    arr =  gets.chomp.split.map(&:to_i)
    maxes = [0, 0]
    prev = arr[0]
    arr[1..-1].each{|x|
        if x - prev >= 0
            maxes[0] = x - prev if maxes[0] < x - prev
        else
            maxes[1] = x - prev if maxes[1] > x - prev
        end
        prev = x
    }
    puts "#{maxes[0]} #{-maxes[1]}"
}


Measured memory_bytes: 6932
#include <stdio.h>
int main()
{
    int a,b,c,d,i=0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(a>0&&c>0)
    {
        if(i%2==0)
        c-=b;
        else
        a-=d;
        i++;
    }
    if(c<=0)
    printf("Yes");
    else
    printf("No");
}


Measured memory_bytes: 1736
import java.io.*;
import java.math.BigInteger;
import java.util.*;

 
public class Main{
	/*
	 * use Integer for sorting
	 * avoid object comparison
	 * NEVER APPEND A STRING -> APPEND char by char
	 * Always use TreeSet instead of HashSet
	 * 
	 */
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final long MAX = (long) 1e8;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static long[] fac;
    public static int N = 400000+200;
    public static int x = 0;
    public static boolean[] visited;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		edges = new ArrayList[n+1];
		for(int i=0;i<=n;++i) edges[i] = new ArrayList<>();
		for(int i=1;i<n;++i) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			edges[u].add(v);
			edges[v].add(u);
		}
		
		int[] tak = new int[n+1]; tak[0] = -1;
		int[] aok = new int[n+1]; aok[0] = -1;
		dfs(t,0,tak);
		dfs(a,0,aok);
		long ans = 0;
		for(int i=1;i<=n;++i) {
			if(tak[i] < aok[i]) {
				ans = Math.max(ans,aok[i]);
			}
		}
		out.print(ans-1);
		out.close();
	}
	private static void dfs(int v, int parent, int[] level) {
		level[v] = level[parent] + 1;
		for(int child : edges[v]) {
			if(child != parent) dfs(child,v,level);
		}
	}
	
	
	
}

Measured memory_bytes: 62748
#include<iostream>
#include<string>

using namespace std;

int ans[30] = {};

int main()
{
	string x;
	int y;
	while (cin >> x)
	{
		for (int i = 0; i < x.length(); i++)
		{
			if ('a' <= x[i] && x[i] <= 'z')
			{
				y = x[i] - 'a';
				ans[y]++;
			}
			else if ('A' <= x[i] && x[i] <= 'Z')
			{
				y = x[i] - 'A';
				ans[y]++;
			}
		}
	}
		for (int i = 0; i < 26; i++)
		{
			cout << char(i + 'a') << " : " << ans[i] << endl;
		}
	return 0;
}

Measured memory_bytes: 3172
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def get_num_draw(n, x):
    res = 0
    while n > 0:
        res += n % x
        n = n // x
    return res


def main():
    N = NI()
    ans = 10**10
    for i in range(0, N+1, 6):
        ans = min(get_num_draw(N-i, 9) + get_num_draw(i//6, 6), ans)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9368
#include <stdio.h>

int main(void) {
    char S[10], T[10]={0};
    scanf("%s", &S);

    switch (S[0])
    {
        case 'A':
            T[0] = 'T';
            break;
        case 'T':
            T[0] = 'A';
            break;
        case 'C':
            T[0] = 'G';
            break;
        case 'G':
            T[0] = 'C';
            break;
        default:
            break;
    }

    printf("%s\n", T);
    return 0;
}

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

signed main(void)
{
	int n, ans;
	cin >> n;
	map<int, int> m;
	for(int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		m[a]++;
	}
	ans = 0;
	for(auto p : m)
	{
		auto v = p.second;
		if (v % 2 != 0)
			ans += 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+10;
struct node {
	int l,r;
	int operator<(const node &a) {
		return r-l<a.r-a.l;
	}
}a[maxn];
int c[maxn],n,m;
void add(int x,int v) {
	for(int i=x;i<=n;i+=i&-i)c[i]+=v;
}
int qry(int x) {
	int sum=0;
	for(int i=x;i;i-=i&-i)sum+=c[i];
	return sum;
}
int main() {
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++)
		scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+m+1);
	for(int i=1,j=1;i<=n;i++) {
		while(j<=m&&a[j].r-a[j].l+1<i) {
			add(a[j].l,1);
			add(a[j].r+1,-1);
			j++;
		}
		int ans=m-j+1;
		for(int j=i;j<=n;j+=i)ans+=qry(j);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 6524
<?php
fscanf(STDIN, "%d%d", $H, $W);
for($i = 0; $i < $H; $i++){
  fscanf(STDIN, "%s", $s);
  $map[$i] = $s."#";
}
$map[$H] = str_repeat("#", $W);
for($i = 0; $i < $H; $i++){
  $h = 0;
  for($j = 0; $j <= $W; $j++){
    if($map[$i][$j] === "."){
      $h++;
    }else{
      $q = &$p[$i];
      for($k = 0; $k < $h; $k++){
        $q[$j - 1 - $k] = $h;
      }
      $h = 0;
    }
  }
}
$max = 0;
for($i = 0; $i < $W; $i++){
  $h = 0;
  for($j = 0; $j <= $H; $j++){
    if($map[$j][$i] === "."){
      $h++;
    }else{
      for($k = 0; $k < $h; $k++){
        $pp = $p[$j - 1 - $k][$i] + $h;
        if($max < $pp)$max = $pp;
      }
      $h = 0;
    }
  }
}
echo $max - 1;

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

int main(){
    int x, y;
    cin >> x >> y;
    string ans = "No";
    for(int i = 0; i <= x; i++){
        if(2*i + (x-i)*4 == y) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

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

  int n, m, k;
  cin >> n >> m >> k;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int m1 = 0; m1 < (1 << n); m1++) {
    for (int m2 = 0; m2 < (1 << m); m2++) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (m1 & (1 << i)) {
            continue;
          }
          if (m2 & (1 << j)) {
            continue; 
          }
          if (a[i][j] == '#') {
            cnt++;
          }
        }
      }
      if (cnt == k) {
        ans++;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
map<int, int> sum;
int n, a[200001], ans;
signed main()
{
    std::ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        if (a[i] < i)
        {
            ++sum[i - a[i]];
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        if (a[i] < i)
        {
            --sum[i - a[i]];
        }
        ans += sum[i + a[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18980
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

import numpy as np

H,W=two_int()



output = []
for i in range(H):
    row = list(one_str())

    temp = list(set(row))
    if temp[0]=="." and len(temp)==1:
        continue
    
    output.append(row)

output = np.asarray(output).T



fin=[]
for row in output:
    temp = list(set(row))
    if temp[0]=="." and len(temp)==1:
        continue
    
    fin.append(row)
output = np.asarray(fin).T


for row in output:
    print("".join(row))

Measured memory_bytes: 12368
//
//  main.cpp
//  AT
//
//  Created by 黄道煜 on 2018/8/12.
//  Copyright © 2018年 黄道煜. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int n, cnt, bit[100000];

int main()
{
    scanf("%d", &n);
    if(n==0) {printf("0\n"); return 0;}
    while(n)
    {
        if(n%2) bit[++cnt]=1, n-=1;
        else bit[++cnt]=0;
        n/=-2;
    }
    for(int i=cnt; i>=1; i--) printf("%d", bit[i]);
}


Measured memory_bytes: 384
#coding:utf-8
include Math

x,y = 0.0,0.0
dir = 0.0 

step,angle = 0,0
while !STDIN.eof? do
	str = gets.chomp.split(',').map(&:to_i)
	break if str==[0,0]
	step,angle = str[0], str[1]
	
	
	#進行方向の決定
	rad = dir.to_f*Math::PI/180.0
	x += sin(rad)*step
	y += cos(rad)*step

	dir += angle
	
end

puts x = x.to_i
puts y = y.to_i

Measured memory_bytes: 6172
#include <stdio.h>

int main(void) {
  int i, j, k, n, m, now;
  while( 1 ) {
    now = 0;
    scanf("%d%d", &n, &m);
    if(!n && !m) break;
    int a[n];
    for(i = 0; i < n; ++i) scanf("%d", &a[i]);
    for(i = 1; i <= m; ++i) {
      int f;
      scanf("%d", &f);
      now += f;
      now += a[now];
      now = now > 0 ? now : 0;
      if(now >= n - 1) break;
    }
    printf("%d\n", i);
    for(; i < m; ++i) scanf("%d", &n);
  }
  return 0;
}


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

typedef long long LL;

const int N=200000,INF=(1<<30)-1;

int n,a[N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
	scanf("%d",&a[i]);
}

LL mn[N+9];

LL Divide_ans(int l,int r){
  if (l==r) return a[l];
  int mid=l+r>>1;
  LL res=Divide_ans(l,mid)+Divide_ans(mid+1,r);
  mn[mid]=INF;mn[r+1]=0;
  for (int i=mid+1;i<=r;++i) mn[i]=min(mn[i-1],(LL)a[i]);
  for (int i=r;i>mid;--i) mn[i]+=mn[i+1];
  int now=a[mid];
  for (int i=mid,j=mid+1;i>=l;--i){
	now=min(now,a[i]);
	for (;j<=r&&now<=a[j];++j);
	res+=(LL)now*(j-mid-1)+mn[j];
  }
  return res;
}

void outo(){
  printf("%lld\n",Divide_ans(1,n));
}

int main(){
  into();
  outo();
  return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include<vector>
#include<math.h>
#include<string>

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

int main(){
	int N, D;
	int range;
	int count, r;
	scanf("%d%d", &N, &D);
	
	range = D * 2 + 1;
	r = N % range;
	if (r == 0) {
		count = N / range;
	}else{
		count = (N - r) / range;
		count++;
	}
	printf("%d", count);
}

Measured memory_bytes: 128
// Vicfred
// https://atcoder.jp/contests/abc155/tasks/abc155_b
// simulation
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.map!(to!int).array;

    foreach(item; a) {
        if(item%2 == 0 && item%3 != 0 && item%5 != 0) {
            writeln("DENIED");
            return;
        }
    }
    writeln("APPROVED");
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[MAX][MAX];
int main()
{
  int n,i,j;
  int k,c,u,v;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      M[u][v]=c;
    }
  }

  int minv=0;
  int d[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
	if(d[v]>d[u]+M[u][v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i] == INFTY ? -1 : d[i]);
  }
  
  return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

#define INF 1000000007

int main()
{
	int n,m,x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n,vector<int>(m));
	for(int i=0;i<n;i++)
	{
		cin >> c[i];
		for(int j=0;j<m;j++)
			cin >> a[i][j];
	}

	int ans=INF;

	for(int i=0;i<(1<<n);i++)
	{
		vector<int> und(m,0);
		int money=0;
		for(int j=0;j<n;j++)
		{
			if(i&(1<<j))
			{
				money+=c[j];
				for(int k=0;k<m;k++)
					und[k]+=a[j][k];
			}
		}
		bool can=true;
		for(int j=0;j<m;j++)
			if(und[j]<x)
				can=false;
		if(can)
		if(ans>money)
			ans=money;
	}

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





}


Measured memory_bytes: 3196
YM = False
MY = False

S = input()
S1 = int(S[:2])
S2 = int(S[2:])
if 0 < S1 < 13:
    MY = True
if 0 < S2 < 13:
    YM = True

if YM and MY:
    print('AMBIGUOUS')
elif YM:
    print('YYMM')
elif MY:
    print('MMYY')
else:
    print('NA')    

Measured memory_bytes: 38384
#include <stdio.h>

int main(void){
  int a,b,r;
  int x,y;

  while( 1 ){
    if( scanf("%d %d ",&x,&y)!=2 )
      break;
    if( b>a ){
      r=b;b=a;a=r;
    }

    a=x;b=y;

    r=1;
    while( r!=0 ){
      r=a%b;
      a=b;
      b=r;
    }

    b=x/a*y;
    printf("%d %d\n",a,b);
  }
  return 0;
}

Measured memory_bytes: 0
import numpy as np
import sys

def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    N = int(input())
    A = np.empty((N, 2))
    for i in range(N):
        A[i,:] = InputToInt()
    A = A[np.argsort(A[:, 0])]
    A = A[np.argsort(A[:, 1])]
    T = 0
    for i in range(N):
        T+=A[i, 0]
        if T > A[i, 1]:
            print('No')
            sys.exit()
    print('Yes')
    


Measured memory_bytes: 20284
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();

    char[] inArray = line.toCharArray();
    char tmp = inArray[0];
    String rtval = "Good";

    for(int i = 1; i < 4; i++) {
      if(tmp == inArray[i]){
        rtval = "Bad";
        break;
      }
      tmp = inArray[i];
    }

    System.out.println(rtval);
    sc.close();
  }
}

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

using namespace std;

int main()
{
	long long x,y;
	cin>>x>>y;
	
	if(y==1||x==y)
	{
		cout<<"-1";
		return 0;
	}
	else{
		if(y<x&&x%y==0)
		{
			cout<<"-1";
		}
		else
		{
			int temp = y/x;
			temp++;
			cout<<x;
		}
		
	}
	
	
	return 0;
}

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

int main() {
	int N; 
	cin >> N;
	int dp[N+1][3];
	for (int i = 0; i <= N; ++i)for (int j = 0; j < 3; ++j)dp[i][j] = 0;
	for (int i = 1; i<=N; ++i)
	{
		cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
		dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] += max(dp[i - 1][0], dp[i - 1][1]);
	}
	int ans=max({ dp[N][0],dp[N][1],dp[N][2] });
	cout << ans;
}

Measured memory_bytes: 1408
tmp=input().split()
W=int(tmp[0])
H=int(tmp[1])
x=int(tmp[2])
y=int(tmp[3])
r=int(tmp[4])
Flag=True
if x-r<0 or x+r>W or y-r<0 or y+r>H:
    Flag=False
if Flag:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5596
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

bool iro[10];
int main(void){
  int n,t;
  int i;

  int res=0,tmp=0;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>t;
    if(t<400) iro[0]=true;
    else if(t<800) iro[1]=true;
    else if(t<1200) iro[2]=true;
    else if(t<1600) iro[3]=true;
    else if(t<2000) iro[4]=true;
    else if(t<2400) iro[5]=true;
    else if(t<2800) iro[6]=true;
    else if(t<3200) iro[7]=true;
    else tmp++;
  }

  for(i=0;i<8;i++){
    if(iro[i]==true) res++;
  }
  if(res==0) cout<<1;
  else cout<<res;
  cout<<" "<<res+tmp<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

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

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
A, B, C, K = map(int, stdin.readline().rstrip().split())
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]

if K <= A:
    print(K)
elif K <= A +B:
    print(A)
else:
    print(A- (K-A-B))


Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define EPS 1e-8
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
    return os << "(" << P.fi << "," << P.se << ")";
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
    os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
template <typename T>
T power_mod(T base, int exp, int mod = MOD) {
    T res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
template <typename T>
T power(T base, int exp) {
    T res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, MOD - 2);
}

/******************************** template ********************************/
#define N 100010
int n;
int a[N];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
    }
    sort(a, a + n);
    int diff = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (i % 2 == (n - 1) % 2) {
            diff += a[i];
        } else {
            diff -= a[i];
        }
    }
    cout << diff;

    return 0;
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	if(n%2==0){
		int a1=a[n/2]+a[(n/2)+1];
		int b1=b[n/2]+b[(n/2)+1];
		cout<<b1-a1+1<<endl;
	}
	else{
		int a1=a[(n+1)/2];
		int b1=b[(n+1)/2];
		cout<<b1-a1+1<<endl;
	}
	return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    ll L;
    cin >> L;
    vector<ll> A(L);
    REP(i, L) cin >> A[i];

    vector<ll> dp0(L + 1);
    vector<ll> dp1(L + 1);
    vector<ll> dp2(L + 1);
    vector<ll> dp3(L + 1);
    vector<ll> dp4(L + 1);
    dp0[0] = 0;
    dp1[0] = 0;
    dp2[0] = 0;
    dp3[0] = 0;
    dp4[0] = 0;
    REP(i, L) {
        dp0[i + 1] = dp0[i] + A[i];
        if (A[i] == 0) {
            dp1[i + 1] = min(dp0[i + 1], dp1[i] + 2);
            dp2[i + 1] = min(dp1[i + 1], dp2[i] + 1);
            dp3[i + 1] = min(dp2[i + 1], dp3[i] + 2);
        } else if (A[i] % 2 == 0) {
            dp1[i + 1] = min(dp0[i + 1], dp1[i]);
            dp2[i + 1] = min(dp1[i + 1], dp2[i] + 1);
            dp3[i + 1] = min(dp2[i + 1], dp3[i]);
        } else {
            dp1[i + 1] = min(dp0[i + 1], dp1[i] + 1);
            dp2[i + 1] = min(dp1[i + 1], dp2[i]);
            dp3[i + 1] = min(dp2[i + 1], dp3[i] + 1);
        }
        dp4[i + 1] = min(dp3[i + 1], dp4[i] + A[i]);
        /*
        printf("dp0[%d] = %lld\n", i + 1,  dp0[i + 1]);
        printf("dp1[%d] = %lld\n", i + 1,  dp1[i + 1]);
        printf("dp2[%d] = %lld\n", i + 1,  dp2[i + 1]);
        printf("dp3[%d] = %lld\n", i + 1,  dp3[i + 1]);
        printf("dp4[%d] = %lld\n", i + 1,  dp4[i + 1]);
        */
    }
    cout << dp4[L] << endl;
    return 0;
}

Measured memory_bytes: 9600
N=int(input())

li=list(map(int,input().split()))

li.sort()
if N%2==0:
  print(2*sum(li[int(-N/2):-1])+li[-1])
else:
  print(2*sum(li[-(N//2):-1])+li[-1]+li[-(N//2)-1])

Measured memory_bytes: 94212
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

lli N, M;
priority_queue<lli, vector<lli>, greater<lli>> D, T;
lli in, d, t;
bool flag = true;

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

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> in;
		D.push(in);
	}
	cin >> M;
	for(int i = 0; i < M; i++){
		cin >> in;
		T.push(in);
	}
	while(T.size() > 0 && flag){
		d = D.top();
		t = T.top();
		dbug(d)dbug(t)dbugln;
		if(d == t){
			D.pop();T.pop();
		}else if(d > t){
			flag = false;
		}else{
			D.pop();
		}
		if(D.size() == 0 && T.size()>0) flag = false;
	}

	if(flag) cout << "YES";
	else cout << "NO";

	return 0;
}


Measured memory_bytes: 4848