akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public 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 d = sc.nextInt();
        
        int start = a > c ? a : c;
        int end = b < d ? b : d;
        int ans = end > start ? end - start : 0;
        
    
		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int n;
bool table[5001][5001];
int hx[3000],hy[3000];

int main() {
	while (1) {
		cin >> n;
		if (n == 0)break;
		for (int i = 0; i <= 5000; i++)for (int j = 0; j <= 5000; j++)table[i][j] = false;
		for (int i = 0; i < n; i++) {
			cin >> hx[i] >> hy[i];
			table[hx[i]][hy[i]] = true;
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				int ax, ay, bx, by;
				ax = hx[i] - abs(hy[j] - hy[i]);
				ay = hy[i] - abs(hx[j] - hx[i]);
				bx = hx[j] - abs(hy[j] - hy[i]);
				by = hy[j] - abs(hx[j] - hx[i]);

				if (ax < 0 || ax > 5000 ||
					bx < 0 || bx > 5000 ||
					ay < 0 || ay > 5000 ||
					by < 0 || by > 5000)
					continue;

				if (table[ax][ay] && table[bx][by]) {
					int tmp = ((hy[j] - hy[i]) + (hx[j] - hx[i])) * ((hy[j] - hy[i]) + (hx[j] - hx[i]));
					tmp -= ((hy[j] - hy[i]) * (hx[j] - hx[i])) * 2;
					ans = max(ans, tmp);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
    int n;
    std::cin>>n;
    std::string s;
    char t='!';
    std::string s2="";
    if(n!=1)std::cin>>s;
    else std::cin>>t;
    if(t!='!'){
        std::cout<<"()"<<std::endl;
        return 0;
    }
    int c=0;
    for (int i = 0; i < n; ++i) {
        if(s[i]=='(')++c;
        else --c;
        if(c<0){
            s2.push_back('(');
            c=0;
        }
    }
    c=0;
    for (int i = n-1; i >= 0; --i) {
        if(s[i]==')')++c;
        else --c;
        if(c<0){
            s.push_back(')');
            c=0;
        }
    }

    std::cout<<s2+s<<std::endl;
    return 0;
}

Measured memory_bytes: 256
import math
import sys
sys.setrecursionlimit(10**5)
x, y = map(int, input().split())
mod = 10**9+7

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if (x + y) % 3 != 0:
    print(0)
    sys.exit()

if y > 2 * x or y < x / 2:
    print(0)
    sys.exit()

cnt = (x + y) // 3
# p = cnt // 2
p = (2 * x - y) // 3
#print(cnt, p)

# Calclate cntCp
comb = Combination(1000000)
ans = comb(cnt, p)

print(ans)



Measured memory_bytes: 125256
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){ int sz = a.size();
for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

int main(void){
    
    ll n,x;
    cin >> n >> x;
    vl a(n),b(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    ll ans = 1e18;

   for (int k = 0; k < n; k++) {
       ll cur = 0;
       for (int i = 0; i < n; i++) {
           if (k == 0) { b[i] = a[i]; }
           else { chmin(b[i] , a[(i - k + n) % n]); }
           cur += b[i];
        }
        chmin(ans,cur + (ll)k * x);
   }

   cout << ans << '\n'; 
}

Measured memory_bytes: 256
n=int(input())
matrix=[]
for i in range(n):
    matrix.append([0]*n)
for i in range(n):
    listi=list(map(int,input().split()))
    for j in range(listi[1]):
        matrix[i][listi[j+2]-1]=1

for i in range(n):
    for j in range(n-1):
        print(matrix[i][j],end=" ")
    print(matrix[i][n-1])



Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
int main(){
  int Q;
  cin >> Q;
  long long c = 0;
  multiset<int> st1;
  long long sum1 = 0;
  multiset<int> st2;
  long long sum2 = 0;
  for (int i = 0; i < Q; i++){
    int t;
    cin >> t;
    if (t == 1){
      int a, b;
      cin >> a >> b;
      c += b;
      if (st1.size() == st2.size()){
        st1.insert(a);
        sum1 += a;
      } else {
        st2.insert(a);
        sum2 += a;
      }
      if (!st1.empty() && !st2.empty()){
        int x = *prev(st1.end());
        int y = *(st2.begin());
        if (x > y){
          st1.erase(st1.find(x));
          sum1 -= x;
          st2.erase(st2.find(y));
          sum2 -= y;
          st1.insert(y);
          sum1 += y;
          st2.insert(x);
          sum2 += x;
        }
      }
    }
    if (t == 2){
      int x = *prev(st1.end());
      long long ans = (x * st1.size() - sum1) + (sum2 - x * st2.size()) + c;
      cout << x << ' ' << ans << endl;
    }
  }
}

Measured memory_bytes: 12996
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

ll n, r;
int main() {
    while(cin>>n>>r, n!=0 && r!=0){
        ll card[51];
        REP(i, 0, n) card[i]=n-i;

        REP(i, 0, r){
            ll p, c;
            cin>>p>>c;

            ll tmp[51];
            ll idx=0;
            REP(j, 0, c){
                tmp[j]=card[p-1+j];
            }
            REP(j, 0, p-1){
                tmp[j+c]=card[j];
            }
            REP(j, p-1+c, n){
                tmp[j]=card[j];
            }

            REP(j, 0, n){
                card[j]=tmp[j];
            }
        }
        cout<<card[0]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3040
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N = 3;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(begin(A), end(A));

  ll ans = A[0] + A[1];

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


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	vector<vector<int>> dp(n + 1, vector<int>(n + 1));
	int ans = 0;
	for (int i = 0; i < n; ++i)
	for (int j = i + 1; j < n; ++j)
		ans = max(ans, dp[i + 1][j + 1] = s[i] != s[j] ? 0 : min(j - i, dp[i][j] + 1));
	cout << ans << '\n';
}

Measured memory_bytes: 101152
#include<stdio.h>

void input(int *n,char s[])
{
  scanf("%s",s);
  int i;
  for(i=0;s[i]!='\0';i++){
  }
  *n=i;
}

int main(void)
{
  int n;
  char s[100001];
  input(&n,s);
  
  int i,j,tmp,num[2]={0,0};
  for(i=0;i<=1;i++){
    tmp=i;
    for(j=0;j<n;j++){
      if(s[j] != tmp+'0'){
        num[i]++;
      }
      tmp=!(tmp);
    }
  }
  
  printf("%d\n",num[0]<num[1]?num[0]:num[1]);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define all(x)              (x).begin(), (x).end()
#define inf                 1e18

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//	ifstream cin("input.txt");
//	ofstream cout("output.txt");
	int n;
	cin >> n;
	vector <ll> v(n);
	int tf = 1;
	for (auto &i : v) {
		cin >> i;
		if (!(i & 1)) {
			tf &= ((i % 3 == 0) || (i % 5 == 0));
		}
	}
	cout << ((tf) ? "APPROVED" : "DENIED");
}


Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O25")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1
)X";
stringstream iss{text};
#endif

class CountOrder
{
	ll N{0};
	vector<ll> p, q;
	void inp( ) {
		iss >> N; p.resize(N); q.resize(N);
		rep(n, N) { iss >> p[n]; }
		rep(n, N) { iss >> q[n]; }
		//for_each(begin(p), end(p), [](auto x) { cout << x << "\n"; });
	}
	void change( ) {
		long long sa{0};
		if (p > q) swap(p, q);
		do {
			if (p == q) break;
			++sa;
		} while (next_permutation(begin(p), end(p)));
		p(sa);
	}
public:
	void procedures( ) {
		inp( );
		change( );
	}
};
//https://atcoder.jp/contests/abc145/tasks/abc145_c
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	cout << fixed << setprecision(15);
	class CountOrder a; a.procedures( );
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
char t;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b)
    {
        cout<<"YES"<<endl;
        return 0;
    }
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(a[K-1])

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

    int a = (abcd / 1000) % 10;
    int b = (abcd / 100) % 10;
    int c = (abcd / 10) % 10;
    int d = abcd % 10;

    for (int i = 0; i < 8; i++) {
        int r = a
                + ((i & 0b100) > 0 ? 1 : -1) * b
                + ((i & 0b010) > 0 ? 1 : -1) * c
                + ((i & 0b001) > 0 ? 1 : -1) * d;
        if (r == 7) {
            cout << a
                    << ((i & 0b100) > 0 ? "+" : "-") << b
                    << ((i & 0b010) > 0 ? "+" : "-") << c
                    << ((i & 0b001) > 0 ? "+" : "-") << d
                    << "=7" << endl;
            break;
        }
    }
}


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    vector<priority_queue<int>> hoge(n);
    int a, b, c;
    for (int i = 0; i < q; i++){
        cin >> a;
        if(a == 0){
            cin >> b >> c;
            hoge[b].push(c);
            continue;
        }

        if(a == 1){
            cin >> b;
            if(hoge[b].empty()) continue;
            cout << hoge[b].top() << endl;
            continue;
        }

        if(a == 2){
            cin >> b;
            if(hoge[b].empty()) continue;
            hoge[b].pop();
            continue;
        }
    }
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, M;
    cin >> N >> M;

    priority_queue<pair<int, int>> pq;
    for (int i = 0, v; i < N; i++) {
        cin >> v;
        pq.push({ v, 1 });
    }
    for (int i = 0, b, c; i < M; i++) {
        cin >> b >> c;
        pq.push({ c, b });
    }

    ll ans = 0;
    while (N) {
        auto best = pq.top();
        pq.pop();

        int take = min(N, best.second);
        ans += best.first * 1ll * take;
        N -= take;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	long long a,b;
	cin>>a>>b;
	if(fabs(a-b)>2018){
		cout<<0<<endl;
		return 0;
	}
	ll mi=10000;
	for(ll i=a;i<=b;i++){
		for(ll j=i+1;j<=b;j++){
			if(i*j%2019<mi){
				mi=i*j%2019;
			}
		}
	}
	cout<<mi<<endl;
	return 0;
}

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

using namespace std;

typedef long long lint;
int par[18][100010], dep[100010];
lint pdist[18][100010];
vector<pair<int,int>> g[100010];
void dfs(int v, int p, int d){
	par[0][v] = p;
	pdist[0][v] = d;
	dep[v] = dep[p] + 1;
	for (int i=1; i<18; ++i){
		par[i][v] = par[i-1][par[i-1][v]];
		pdist[i][v] = pdist[i-1][v] + pdist[i-1][par[i-1][v]];
	}
	for (auto it : g[v]){
		if (it.first == p) continue;
		dfs(it.first, v, it.second);
	}
}
lint dist(int a, int b){
	if (dep[a] > dep[b]) swap(a, b);
	lint dif = dep[b] - dep[a];
	lint ret = 0;
	for (int i=17; i>=0; --i){
		if (dif >= (1 << i)){
			dif -= (1 << i);
			ret += pdist[i][b];
			b = par[i][b];
		}
	}
	if (a == b) return ret;
	for (int i=17; i>=0; --i){
		if (par[i][a] != par[i][b]){
			ret += pdist[i][a] + pdist[i][b];
			a = par[i][a];
			b = par[i][b];
		}
	}
	ret += pdist[0][a] + pdist[0][b];
	return ret;
}

int main(){
	cin.sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for (int qq=0; qq<n-1; ++qq){
		int v, u, d; cin >> v >> u >> d;
		g[v].push_back({u, d});
		g[u].push_back({v, d});
	}
	dfs(1, 1, 0);
	int nq, k;
	cin >> nq >> k;
	for (int qq=0; qq<nq; ++qq){
		int a, b; cin >> a >> b;
		cout << dist(a, k) + dist(k, b) << '\n';
	}
	return 0;
}

Measured memory_bytes: 33408
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define INF 0x3f3f3f3f3f3f3f3f
#define LL long long
#define MX 55
struct Node
{
    LL x, y;
    bool operator < (const Node &b)const{
        return x<b.x;
    }
}pt[MX];

int k, n;

int main()
{
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++)
        scanf("%lld%lld",&pt[i].x, &pt[i].y);
    sort(pt+1,pt+1+n);
    LL area = INF;
    for (int i=1;i<=n;i++)
    {
        for (int j=i+1;j<=n;j++)
        {
            LL miny = min(pt[i].y, pt[j].y);
            LL maxy = max(pt[i].y, pt[j].y);
            for (int q=1;q<=n;q++)
            {
                if (pt[q].y>maxy||pt[q].y<miny) continue;
                int tot = 0;
                for (int z=q;z<=n;z++)
                {
                    if (pt[z].y>maxy||pt[z].y<miny) continue;
                    tot++;
                    if (tot>=k)
                        area = min(area, (maxy-miny)*(pt[z].x-pt[q].x));
                }
            }
        }
    }
    printf("%lld\n",area);
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
INF = float("inf")
V = [INF] * (1<<N)
V[0] = 0
for i in range(M):
  v,_ = map(int, input().split())
  b = 0
  s = list(map(int, input().split()))
  for a in s:
    b |= (1<<(a-1))
  V[b] = min(V[b], v) #宝箱の集合bを開けるための最小コスト

vbs = [] #（最小コスト、宝箱の集合b）のリスト、ただしコストINFのものを除く
for b,v in enumerate(V):
  if v == INF:
    continue
  vbs.append((v,b))

for v,b in vbs:
  for c in range(1<<N):
    if V[c] == INF:
      continue
    V[b|c] = min(V[b|c], V[b]+V[c])

print(V[-1] if V[-1] < INF else -1)

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

// function to count the divisors
int countDivisors(int n)
{
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            // If divisors are equal,
            // count only one
            if (n / i == i)
                cnt++;

            else // Otherwise count both
                cnt = cnt + 2;
        }
    }
    return cnt;
}

/* Driver program to test above function */
int main()
{
    int n;
		int s=0;
		cin >> n;
    for (int c=1;c<n;c++){
			s=s+countDivisors(n-c);
		}
		cout << s;
    return 0;
}


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

typedef long long ll;

int partition(vector<int> &v,int p,int r){
    int x=v[r];
    int i=p-1;
    for(int j=p;j<r;j++){
        if(v[j]<=x){
            i++;
            swap(v[i],v[j]);
        }
    }
    swap(v[i+1],v[r]);
    return i+1;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int itr = partition(a,0,n-1);
    for(int i=0;i<n;i++){
        cout << (i==itr?"[":"") << a[i] << (i==itr?"]":"") << (i!=n-1?" ":"\n");
    }
}



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

const int N = 1001;
int n;
int a[N];
int d[10];
int main() {
	//freopen("in.txt", "r", stdin);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	int cntColor=0;
	for (int i = 1; i <= n; i++) {
		if (1 <= a[i] and a[i] <= 399 and d[1]==false) {
			d[1] = true;
			cntColor++;
		}
		else if (400 <= a[i] and a[i] <= 799 and d[2]==false) {
			d[2] = true;
			cntColor++;
		}
		else if (800 <= a[i] and a[i] <= 1199 and d[3] == false) {
			d[3] = true;
			cntColor++;
		}
		else if (1200 <= a[i] and a[i] <= 1599 and d[4] == false) {
			d[4] = true;
			cntColor++;
		}
		else if (1600 <= a[i] and a[i] <= 1999 and d[5] == false) {
			d[5] = true;
			cntColor++;
		}
		else if (2000 <= a[i] and a[i] <= 2399 and d[6] == false) {
			d[6] = true;
			cntColor++;
		}
		else if (2400 <= a[i] and a[i] <= 2799 and d[7] == false) {
			d[7] = true;
			cntColor++;
		}
		else if (2800 <= a[i] and a[i] <= 3199 and d[8] == false) {
			d[8] = true;
			cntColor++;
		}
		if (a[i] >= 3200) {
			d[9]++;
		}
	}
	if(cntColor ==0)
		printf("%d %d", 1, d[9] );
	else
		printf("%d %d", cntColor, cntColor+d[9]);
	return 0;
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if(k <= a) cout << k << endl;
  else if(k <= a + b) cout << a << endl;
  else cout << a - (k - a - b) << endl;
  return 0;
}


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

int main(){

    int n;
    cin >> n;

    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    int i=0;
    int count;
    while(i<n-1){
        if(a[i] == a[i+1]){
            count ++;
            i+=2;
        }else{
            i++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        String t = sc.next();
        int n = s.length();
        int m = t.length();
        int max = 0;
        for(int i=0; i<n-m+1; i++){
            int cnt = 0;
            for(int j=0; j<m; j++){
                if(s.charAt(i+j)==t.charAt(j)){
                    cnt++;
                }
            }
            max = Math.max(cnt, max);
        }
        
        System.out.println(m-max);
    }
}


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

int main() {
  long n, x;
  cin >> n >> x;

  vector<long long> a(n+1);
  a.at(0) = 0ll;
  long long t;
  for(int i = 0; i < n; ++i){cin >> t; a.at(i+1) = a.at(i) + t;}

  long long ans = 1ll << 62;
  long long tans = 0ll;
  long long b;
  long long coef;
  for(long k = 1; k <= n; ++k) {
    tans = 0ll;
    b = 1ll*(n+k)*x;
    for(long i = 0; i < (n+(k-1))/k; ++i){
      coef = i?2ll*i+3ll:5ll;
      tans += coef * (a.at(n - i * k) - a.at(max(n - (i + 1) * k, 0l)));
      if (tans<0) tans = 1ll << 62;
    }
    ans = min(ans, tans+b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String expression = in.nextLine();
        compute(expression);
    }

    private static void compute(String expression) {
        Scanner in = new Scanner(expression);
        Stack<Integer> stack = new Stack<>();
        while (in.hasNext()) {
            String next = in.next();
            switch (next) {
                case "+": {
                    int first = stack.pop();
                    int second = stack.pop();
                    int sum = second + first;
                    stack.push(sum);
                    break;
                }
                case "-": {
                    int first = stack.pop();
                    int second = stack.pop();
                    int diff = second - first;
                    stack.push(diff);
                    break;
                }
                case "*": {
                    int first = stack.pop();
                    int second = stack.pop();
                    int product = second * first;
                    stack.push(product);
                    break;
                }
                default:
                    stack.push(Integer.parseInt(next));
                    break;
            }
        }
        System.out.println(stack.pop());
    }
}



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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
   int n,m; scanf("%d%d",&n,&m);
   printf(n==m?"Yes\n":"No\n");
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
 
using namespace std;
 
typedef long long int ll;
typedef long int li;
 
int main(void){
    ll n;
    ll od=0;
    ll ev=0;
    cin >> n;
    ll a[n+1];
    for(ll i=1;i<n+1;i++)cin >> a[i];
    for(ll i=1;i<n+1;i++){
        if(a[i]%2==0)ev++;
        if(a[i]%2==1)od++;
    }
    if(od==n){cout << "first" << endl;}
    else if(ev==n){cout << "second" << endl;}
    else if(od%2==1&&ev%2==1){cout << "first" << endl;}
    else if(od%2==0&&ev%2==1){cout << "first" << endl;}
    else if(od%2==1&&ev%2==0){cout << "first" << endl;}
    else if(od%2==0&&ev%2==0){cout << "first" << endl;}
    return 0;
}

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


Measured memory_bytes: 2044
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll q;
  cin >> q;
  priority_queue<ll> lo;
  priority_queue<ll, vl, greater<ll>> hi;
  ll offset = 0;
  ll cur = 0;
  ll m1, m2, p1, p2;
  rep(i, q) {
    ll t;
    cin >> t;
    if (t == 1) {
      ll a, b;
      cin >> a >> b;
      offset += b;
      lo.push(a);
      hi.push(lo.top());
      lo.pop();
      if (lo.size() < hi.size()) {
        lo.push(hi.top());
        hi.pop();
      }
      p1 = m1, p2 = m2;
      if (lo.size() > hi.size()) {
        m1 = m2 = lo.top();
      } else {
        m1 = lo.top();
        m2 = hi.top();
      }
      if (i > 0) {
        if (a < p1) {
          cur += p1 - a;
        } else if (p2 < a) {
          cur += a - p2;
        }
      }
    } else {
      cout << m1 << " " << cur + offset << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;

struct CHT{
	using D = ll;
	typedef pair<D,D> P;
	vector<P> deq;
	int s,sd,t;
	void init(int N){
		deq.resize(N);
		s=0,sd=0,t=0;
	}
	void add(D a,D b){		//add ax+b     a:(広義)単調減少!!!
		b=-b;
		P p(a,b);
		while(s+1<t&&check(deq[t-2],deq[t-1],p)) t--;
		sd++;
		deq[t++]=p;
	}
	D incr_query(D x){		//x:単調増加の時,これを繰り返し呼ぶ(間にaddが挟まるのはOK)
		x=-x;
		while(s+1<t&&f(deq[s],x)>=f(deq[s+1],x)) s++;
		return -f(deq[s],x);
	}
	D decr_query(D x){		//x:単調減少の時,これを繰り返し呼ぶ(間にaddが挟まるのはOK)
		x=-x;
		if(sd>=t) sd=t-1;
//		while(sd+1<t&&f(deq[sd],x)>=f(deq[sd+1],x)) sd++;
		while(sd>0&&f(deq[sd],x)>f(deq[sd-1],x)) sd--;
		return -f(deq[sd],x);
	}
	D query(D x){
		x=-x;
		int lb=s-1,ub=t-1;
		while(ub-lb>1){
			int m=(lb+ub)/2;
			if(isright(deq[m],deq[m+1],x)) lb=m;
			else ub=m;
		}
		return -f(deq[ub],x);
	}

	bool isright(P& a,P& b,D x){
		return f(a,x)>=f(b,x);
	}
	bool check(P& a,P& b,P& c){
		return (b.fs-a.fs)*(c.sc-b.sc)>=(b.sc-a.sc)*(c.fs-b.fs);
	}
	D f(P &p,int x){
		return p.fs*x+p.sc;
	}
}cht;

ll inf=1e18;
const int MN=300000;
int N;
ll T[MN];

ll le[MN+1],ri[MN+1];

ll notuse[MN];
ll use[MN];

void calc(int L,int R){
	if(L==R) return;
	int m=(L+R)/2;
	
	//L<=j<=m<=p<i<=R
	cht.init(m-L+1);
	for(ll j=L;j<=m;j++) cht.add(-j,le[j]+(j*j-j)/2);
	ll mx=-inf;
	for(ll i=R;i>=m+1;i--){
		ll val=cht.incr_query(i)+(i*i+i)/2+ri[N-i];
		chmax(mx,val);
		chmax(use[i-1],mx);
	}

	//L<=j<=p<m<i<=R
	cht.init(R-m);
	for(ll i=m+1;i<=R;i++) cht.add(-i,ri[N-i]+(i*i+i)/2);
	mx=-inf;
	for(ll j=L;j<m;j++){
		ll val=cht.decr_query(j)+(j*j-j)/2+le[j];
		chmax(mx,val);
		chmax(use[j],mx);
	}

	calc(L,m);
	calc(m+1,R);
}
int main(){
	cin>>N;
	rep(i,N) cin>>T[i];

	cht.init(N);
	le[0]=0;
	for(ll i=0;i<N;i++){
		cht.add(-i,le[i]+(i*i-i)/2);
		le[i+1]=max(le[i]+T[i],cht.decr_query(i+1)+(i+1)*(i+2)/2);
	}
	cht.init(N);
	ri[0]=0;
	for(ll i=0;i<N;i++){
		cht.add(-i,ri[i]+(i*i-i)/2);
		ri[i+1]=max(ri[i]+T[N-1-i],cht.decr_query(i+1)+(i+1)*(i+2)/2);
	}
	
	rep(i,N) notuse[i]=le[i]+T[i]+ri[N-1-i];

	ll sum=0;
	rep(i,N) sum+=T[i];

	calc(0,N);

//	rep(i,N) printf("use[%d]=%lld\n",i,use[i]);
//	rep(i,N) printf("notuse[%d]=%lld\n",i,notuse[i]);
	

	int M;
	cin>>M;
	rep(i,M){
		int p;
		ll x;
		cin>>p>>x;
		p--;
		ll ans=max(use[p],notuse[p]-T[p]+x);
		cout<<ans-(sum-T[p]+x)<<endl;
	}
}


Measured memory_bytes: 18944
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		Set<Integer> ts = new TreeSet<>();
		for (int i = a; i <= a + k - 1 && i <= b; i++) {
			ts.add(i);
		}
		for (int i = Math.max(a, b - k + 1); i <= b; i++) {
			ts.add(i);
		}

		for (int e : ts) {
			pr.println(e);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 25172
N=int(input())
A=list(map(int,input().split()))

A=[A[i]-i-1 for i in range(0,N)]

A.sort()

if N%2==1:
    s=0
    for i in range(0,N):
        s=s+abs(A[i]-A[(N-1)//2])
    print(s)
else:
    s=0
    for i in range(0,N):
        s=s+abs(A[i]-A[N//2])
    print(s)


Measured memory_bytes: 25748
n, k = map(int, input().split( ))
mod = 10**9+7

def chs(s,t,mod):
    nume =  1
    for i in range(s-t+1,s+1):
        nume *= i
        nume %= mod
    deno = 1
    for i in range(1,t+1):
        deno *= i
        deno %= mod
    deno = pow(deno,mod-2,mod)
    
    return (nume*deno%mod)

ans = chs(n+k-1,n,mod)
print(ans)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void precomp()
{
}

void solve()
{
    int n, m, k;
    cin>>n>>m>>k;
    readv(a,n);
    readv(b,m);

    for(int i=1;i<n;i++)
    {
        a[i] = a[i-1] + a[i];
    }
    for(int i=1;i<m;i++)
    {
        b[i] = b[i-1] + b[i];
    }

    a.insert(a.begin(), 0);
    b.insert(b.begin(), 0);
    int ans = 0;

    for(int i=0;i<=n;i++)
    {
        int left = k - a[i];
        if(left>=0)
        {
            int other = upper_bound(all(b),  left) - b.begin() - 1;
            ans = max(ans, i + other);
        }
    }
    cout<<ans<<endl;

}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen("INPUT.txt", "r", stdin);
        freopen("OUTPUT.txt", "w", stdout);
    }
#endif
    auto clk = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------
    precomp();
    int t = 1;
    // cin>>t;

    for (int test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;
    // cerr << fixed << setprecision(6) << "Time: " << ((long double)clk) / CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 7916
n,m = map(int,input().split())
ks_list = [list(map(int,input().split())) for _ in range(m)]
p_list = list(map(int,input().split()))

count = 0
for i in range(2**n):
    on = 0
    for j in range(m):
        cnt = 0
        for s in ks_list[j][1:]:
            if (i >> s-1)&1 == 1:
                cnt += 1
        if cnt%2 == p_list[j]:
            on += 1
    if on == m:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    ll n, d;
    cin >> n >> d;
    int cnt = 0;
    REP(i, n){
        ll x, y;
        cin >> x >> y;
        if(x*x+y*y<=d*d)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  float ave_f = (float)(a + b) / 2;
  int ave_i = (int)ave_f;
  int i = ((ave_f - ave_i) != 0) ? 1 : 0;
  ave_i += i;
  cout << ave_i << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>

using namespace std;

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


#define all(v) v.begin(),v.end()
#define INF 1<<30
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;

typedef long long ll;
struct node{
	int x;
	vi vch;
	string st;
};

int f(string tst){
	//cout << "tst : " << tst << endl;
	string jst;
	vi vn;
	int ans = 0;
	if(tst[1] != '['){
		int tmp=0;
		rep(j,tst.size()-2){
			tmp *= 10;
			tmp += char(tst[j+1])-'0';
		}
		return tmp/2+1;
	}
	jst = tst.substr(1,tst.size()-2);
	// jst = tst;
	int kc = 0;
	int sp = 0;
	rep(i,jst.size()){
		if(jst[i]=='['){
			if(kc==0){
				sp = i;
			}
			kc++;
		}
		if(jst[i]==']'){
			kc--;
			if(kc==0){
				int x;
				string buf = jst.substr(sp,i-sp+1); 
				//cout <<"buf : "<< buf << endl;
				x = f(buf);
				vn.pb(x);
			}
		}
	}
	sort(all(vn));
	vi vk;
	rep(i,vn.size()/2+1){
		//vk.pb(vn[i]/2+1);
		vk.pb(vn[i]);
	}
	int su = 0;
	//cout << "v : ";
	rep(i,vk.size()) su += vk[i];
	// rep(i,vk.size()){
	// 	cout << vk[i] << ",";
	// }
	// cout << endl;

	return su;
}


int main(){
	int n;
	cin >> n;
	rep(i,n){
		string str;
		cin >> str;
		int ans = f(str);
		// rep(j,str.size()){
		// 	switch(str[j]){
		// 		case '[':
		// 		break;
		// 		case ']':
		// 		break;
		// 		default:
		// 			int tmp=0;
		// 			while(str[j]!=']'){
		// 				tmp *= 10;
		// 				tmp += char(str[j])-'0';
		// 				j++;
		// 			}
		// 			cout << tmp << endl;
		// 		break;
		// 	}
		// }
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3224
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define NOT_ZERO 1
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long ll;

int main()
{
    int N, W;
    int w, v;
    int i, j;

    scanf("%d %d",&N, &W);

    ll *val = (ll*)calloc(W+1, sizeof(ll));

    for(i=0; i<N; i++) {
        scanf("%d %d",&w, &v);
        for(j=W; j>=w; j--) {
            val[j] = MAX(val[j], val[j-w] + v);
        }
    }

    printf("%lld",val[W]);

    return 0;
}


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

int main() {
  long long kazu;
  cin >>kazu;
  long long kotae=kazu-1;
  for(long long i=2;i<=sqrt(kazu);i++){
    long long a=kazu/i;
    long long amari=kazu%i;
    if(amari==0)kotae=min(kotae,i+a-2);
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int a;
    cin >> a;
    if(a < 1000)cout << "ABC" << endl;
    else cout << "ABD" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll a,b;
  char ch;
  cin>>a>>ch>>b;
  if(ch=='+') cout<<a+b<<endl;
  if(ch=='-') cout<<a-b<<endl;
  if(ch=='*') cout<<a*b<<endl;
  if(ch=='/') cout<<a/b<<endl;
  return 0;
}
	

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int main() {
    int N, K;
    while (~scanf("%d %d", &N, &K)) {
          LL ans = 0, pre_ans = 0;
          for (int b = K + 1; b <= N; b++) {
              ans += (LL)(N / b) * (b - K);
              int tmp = N % b;
              if (tmp && tmp >= K) {
                  ans += (tmp - K + 1);
                  if (K == 0) ans--;
              }
              // printf("b = %d cnt = %lld\n", b, ans - pre_ans);
              // printf("fst = %lld\n", (LL)(N / b) * (b - K));
              pre_ans = ans;
          }
          printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <string.h>

int main(void)
{
	char s[101];
	char sbuf[101];
	char p[101];
	
	
	int i,j,k;
	int slen;
	
	scanf("%s",s);
	slen = strlen(s);
	scanf("%s",p);
	
	for(i = 0;i < slen;i++){
		for(j = 0;j < slen;j++){
			sbuf[j] = s[(i+j)%slen];
		}
		sbuf[slen] = '\0';
		if(strstr(sbuf,p) != '\0'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 524
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = a * n;
		if (x < b) {
			System.out.println(x);
		} else {
			System.out.println(b);
		}
	}
}


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

using namespace std;

int a[21], num, m, q;

bool dfs (int n, int sum)
{
    bool ret;
    if (n==num && sum!=m) return false;
    if (sum==m) return true;
    if (sum>m) return false;
    if (sum<m)
    {
        for (int i=n+1; i<=num; i++)
        {
            ret=dfs(i,sum+a[i]);
            if (ret) return true;
        }
        return false;
    }
}

int main()
{
    cin>>num;
    for (int i=1; i<=num; i++) cin>>a[i];
    sort(a,a+num);
    cin>>q;
    bool ret[q];
    for (int i=0; i<q; i++)
    {
        cin>>m;
        ret[i]=dfs(0,0);
    }
    for (int i=0; i<q; i++) cout<<(ret[i] ? "yes\n" : "no\n");
    return 0;
}



Measured memory_bytes: 3092
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
unordered_set<string> st;

signed main(){
	cin >> N;
	rep(i, N){
		string S;
		cin >> S;
		st.insert(S);
	}
	cout << st.size() << endl;
}

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

using namespace std;

int main() {
	string S = "";
	cin >> S;
	
	int cnt = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'o') {
			cnt++;
		}
	}
	cout << 700 + (100 * cnt) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		int d = a / b;
		int r = a % b;
		double f = (double) a / (double)b;
		System.out.printf("%d %d %.10f\n", d, r, f);
	}
}



Measured memory_bytes: 26436
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
 //for study & upsolving. other coder's source code 
const LL mod = 1000000007;
LL N, K;
std::vector<LL>a(N);
std::vector<std::vector<LL>>memo;
 
// dp(i, j) = dp(i - 1, j) + dp(i - 1, j - 1) + ... + dp(i - 1, j - a[i])
// dp(i, j) = dp(i - 1, j) + dp(i, j - 1) - dp(i - 1, j - a[i] - 1)
LL dp(LL i, LL j)
{
	if (j == 0) return 1;
	if (j < 0) return 0;
	if (i == -1) return 0;
	if (memo[i][j] != -1) return memo[i][j];
	return memo[i][j] = ((dp(i - 1, j) + dp(i, j - 1)) % mod - dp(i - 1, j - a[i] - 1) + mod) % mod;
}
 
int main()
{
	in >> N >> K;
	a.resize(N);
	rep(i, N) in >> a[i];
 
	memo.resize(N);
	rep(i, memo.size()) memo[i].resize(K + 1, -1);
	out << dp(N - 1, K) << std::endl;
}

Measured memory_bytes: 84864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=2e5+5;
int cnt[N];

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int r;cin>>r;
    double pi=acos(-1.0);
    cout<<setprecision(10)<<fixed<<pi*r*2;
}


Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    string s[200]={};
    for(int i=0;i<a;i++){
        cin>>s[i];
    }
    sort(s,s+200);
    reverse(s,s+200);
    for(int i=0;i<a;i++){
        cout<<s[a-i-1];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> B(N - 1);
    for (int i: irange(0, N - 1)) cin >> B[i];

    vector<int> A(N);
    for (int i: irange(0, N)) {
        if (i == 0) {
            A[i] = B[i];
        } else if (i == N - 1) {
            A[i] = B[i - 1];
        } else {
            A[i] = min(B[i - 1], B[i]);
        }
    }
    cout << accumulate(A.begin(), A.end(), 0) << endl;
    return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {
ll n,k;
cin>>n>>k;

if(n<k && k<=n*2-1)
	cout<<abs(n-k)<<endl;
else if(n<k && k>n*2-1)
	cout<<n<<endl;
if(n>=k)
{
ll ans=min(n%k,abs(n%k-k));
	cout<<ans<<endl;
}

return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    int res = 0, n;
    string s;
    cin >> n >> s;
    for (int p = n; p > 0; --p) {
        vector<int> a(n, 0);
        a[0]  = p;
        int i = 1, j = 0;
        while (i < n) {
            while (i + j < p && s[j + n - p] == s[i + j + n - p]) ++j;
            a[i] = j;
            if (!j) {
                ++i;
                continue;
            }
            int k = 1;
            while (i + k < n && k + a[k] < j) a[i + k] = a[k], ++k;
            i += k;
            j -= k;
        }
        for (int q = 0; q < p; ++q) {
            if (q >= a[q]) res = max(res, a[q]);
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int ans;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=s[i+1])
		ans++;
	}
	cout<<ans-1<<endl;
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


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

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  using P = pair<Int, Int>;
  vector<P> vp;
  for(Int i=0;i<m;i++){
    Int b,c;
    cin>>b>>c;
    vp.emplace_back(c,b);
  }
  
  sort(a.begin(),a.end());
  sort(vp.begin(),vp.end());
  
  Int ans=0;
  for(Int i=0;i<n;i++){
    if(vp.empty()||vp.back().first<=a[i]){
      ans+=a[i];
      continue;
    }
    ans+=vp.back().first;
    vp.back().second--;
    if(vp.back().second==0) vp.pop_back();
  }  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3188