akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
    
    return 0;
}

Measured memory_bytes: 3636
N = int(input())
S = input()
alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans = ''
for s in S:
    i = alphabet.index(s)
    if i+N >25:
        ans += alphabet[i+N-26]
    else:
        ans += alphabet[i+N]
print(ans)

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

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
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); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  vec h(N);
  for (int i = 0; i < N; i++) cin >> h[i];

  int max = 0, ans = 0;
  for (int i = 0; i < N; i++) {
    if (max <= h[i]) {
      ans++;
    }
    if (max < h[i]) {
      max = h[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

set<int> make_prime_set(int lim){//10^7:4.938 10^6:0.265sec 10^5:0.015sec lim > 2
	set<int> ps;
	bool pflag;
	int num;
	ps.insert(2);
	for(num = 3; num < lim; num++){
		pflag = true;
		for(int p : ps){
			if(p * p > num) break;
			if(num % p == 0){
				pflag = false;
				break;
			}
		}
		if(pflag == true) ps.insert(num);
	}
	
	return ps;
}

int main(){
	set<int> prime = make_prime_set(1e5+1);
	int q;
	cin >> q;
	vector<int> sum(1e5, 0);
	rep2(i, 1, 1e5){
		if(i % 2 == 0)continue;
		int add = 0;
		if(prime.count(i) == 1 && prime.count((i+1)/2) == 1) add++;
		sum.at(i) = add;
		if(i > 1) sum.at(i) += sum.at(i-2);
	}
	rep(i, q){
		int l, r;
		cin >> l >> r;
		int ans = sum.at(r);
		if(l != 1){
			ans -= sum.at(l-2);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1536
import itertools

N,M = map(int, input().split())
all_lst = []
for i in range(M):
  lst = list(map(int, input().split()))
  all_lst.append(lst[1:])

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

l = [0, 1]
on_off = list(itertools.product(l, repeat=N))
ans = 0
for idx,i in enumerate(on_off):
  ans_lst = []
  for j in range(M):
    sum = 0
    for k in all_lst[j]:
      sum += i[k-1]
    ans_lst.append(sum % 2)
  if(ans_lst == lst_p):
    ans += 1
print(ans)
    
  

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>

int stack[100], sp;
int start[100], end[100];
int ti;

void dfs(int , int **);
void visit(int , int **, int *);
int pop();
void push(int);

int main(){

  int i, j;
  int n, u , k;
  int **a;

  scanf("%d", &n);

  a = (int **)malloc(sizeof(int *) * n);

  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);

    a[i] = (int *)malloc(sizeof(int) * k + 1);
    a[i][k] = -1;

    for(j = 0; j < k; j++){
      scanf("%d", &a[i][j]);
    }

  }

  dfs(n, a);

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


  return 0;
}

void dfs(int n, int **a){

  int i;
  int color[100];

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

  for(i = 0; i < n; i++){
    if(color[i] == 0) visit(i, a, color);
  }

}

void visit(int u, int **a, int *c){

  int i;
  int v;

  c[u] = 1;
  start[u] = ++ti;

  for(i = 0; a[u][i] != -1; i++){
    v = a[u][i] - 1;
    if(c[v] == 0) visit(v, a, c); 

  }  

  c[u] = 2;
  end[u] = ++ti;

}

int pop(){

  sp--;

  return stack[sp];
}


void push(int d){

  stack[sp] = d;

  sp++;

}

Measured memory_bytes: 1032
#include <stdio.h>
int min(int x, int y){
  if(x > y) return y;
  else return x;
}
int main(){
  int N, X;
  scanf("%d %d", &N, &X);
  int m[N];
  int M = 100000;
  for(int i = 0; i < N; i++){
    scanf("%d", m + i);
    M = min(M, m[i]);
    X -= m[i];
  }
  printf("%d\n", N + X / M);
}
  

Measured memory_bytes: 128
#include <complex>
#include <vector>
#include <set>
#include <cstdio>
using namespace std;
 
const double EPS = 1e-12;
typedef complex<long double> P;

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
 
long long pow_binary_mod(long long x,long long y,long long M){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=z*x%M;
		x=x*x%M;
	}
	return z;
}
 
int main(){
	int M=998244353;
	int N,x,y;
	scanf("%d",&N);
	vector<P>v(N);
	int r=pow_binary_mod(2,N,M);
	set<L>se;
	for(int i=0;i<N;i++)scanf("%d%d",&x,&y),v[i]={(double)x,(double)y};
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		L l(v[i],v[j]);
		int n=0;
		for(int k=0;k<N;k++)if(k!=i&&k!=j&&intersectSP(l,v[k]))n++;
		r=(r-pow_binary_mod(2,n,M))%M;
	}
	printf("%d\n",((r-N-1)%M+M)%M);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int cnt=0;
    int K, S;
    cin >> K >> S;
    for(int z=0; z<=K; z++){
        for(int y=0; y<=K; y++){
            int x = S-z-y;
            if(x>=0 && K>= x){
                cnt++;
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

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

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

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    deque<char> S;
    string s;
    cin >> s;
    rep(i,s.length()){
        S.push_back(s[i]);
    }
    int Q;
    cin >> Q;
    int T;
    int F;
    char C;
    int revflag = -1;
    rep(i, Q){
        cin >> T;
        if(T==1){
            revflag *= -1;
        }
        else if(T==2){
            cin >> F >> C;
            if(F==1){
                if(revflag==1) S.push_back(C);
                else S.push_front(C);
            }
            else if(F==2){
                if(revflag==1) S.push_front(C);
                else S.push_back(C);
            }
        }
    }
    if(revflag==1) reverse(S.begin(), S.end());
    rep(i, S.size()){
        cout << S[i];
    }
    cout << endl;
}



Measured memory_bytes: 896
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();
        switch (A) {
        case 5:
            if (B == 5 && C == 7 || B == 7 && C == 5) {
                System.out.println("YES");
                return;
            }
            System.out.println("NO");
            return;
        case 7:
            if (B == 5 && C == 5) {
                System.out.println("YES");
                return;
            }
            System.out.println("NO");
            return;
        default:
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 20564
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N;

signed main()
{
	cin >> N;
	int min_b = INT_MAX;
	int sum = 0;
	REP(i, N)
	{
		int a, b;
		cin >> a >> b;
		if (a > b)
		{
			min_b = MIN(min_b, b);
		}
		sum += a;
	}
	if (min_b == INT_MAX)
	{
		cout << 0 << endl;
		return 0;
	}

	cout << (sum - min_b) << endl;
}







Measured memory_bytes: 256
n,a,b,c,d=map(int,input().split())
s=["."]+list(input())
k=0
for i in range(a,c):
    if s[i]==s[i+1]=="#":
        k=1
for i in range(b,d):
    if s[i]==s[i+1]=="#":
        k=1
if d<c:
    for i in range(b,d+1):
        if s[i]==s[i-1]==s[i+1]==".":
            break
    else:
        k=1

if k==0:
    print("Yes")
else:
    print("No")

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

using namespace std;

void ans(int n)
{
    if(n==25)return;
    cout<<" Eve";
    ans(n+1);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int x,sum,mx=0;
    while(n--)
    {
        cin>>x;
        mx=max(x,mx);
        sum+=x;
    }
    sum-=mx;
    sum+=(mx/2);
    cout<<sum;
}


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

typedef pair<int, int> p;

int main(void)
{
    int N;
    cin >> N;
    vector<p> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i].first;
        A[i].second = i+1;
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N; i++) {
        cout << A[i].second << " ";
    }
    cout << endl;
    return 0;
}



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

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string S;
    ll K;
    cin >> S >> K;
    bool zutto_1 = true;
    char moshi_not_zutto_1;
    for (auto && i: irange(0LL, K)){
        if (S.at(i) != '1'){
            zutto_1 = false;
            moshi_not_zutto_1 = S.at(i);
            break;
        }
    }
    if (zutto_1){
        cout << '1' << endl;
    } else {
        cout << moshi_not_zutto_1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C;
  cin>>A>>B>>C;
  int a=A%B;
  set<int> st;
  for(int i=1;i<=B;i++){
    st.insert((a)%B);
    a+=(A%B);
    a%=B;
  }
  auto it = st.find(C);
  if(it!=st.end()){
    cout<<"YES";
    return 0;
  }
  cout<<"NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
const long long MOD = (long long)1e9+7;
using namespace std;
typedef long long ll;

ll A[100001], B[100001], V[100001];

int main() {
    ll N;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
        if(N % 2 == 0) {
            V[i] = (i + 2) / 2 * 2 - 1;
        }else {
            V[i] = (i + 1) / 2 * 2;
        }
    }
    memcpy(B, A, sizeof(A));
    sort(B, B + N);
    for(int i = 0; i < N; i++)
    {
        if(B[i] != V[i]) {
            cout << 0 << endl;
            return 0;
        }
    }
    
    ll ans = 1;
    for(int i = 0; i < N / 2; i++)
    {
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
}


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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100

int N, A, B;
int P[MAX];

int main() {
	cin >> N >> A >> B;
	for( int i = 0; i < N; i++ ) {
		cin >> P[i];
	}

	sort( P, P + N );
	int acnt = lower_bound( P, P + N, A + 1 ) - P;
	int bcnt = upper_bound( P, P + N, B ) - lower_bound( P, P + N, A + 1 );
	int ccnt = P + N - upper_bound( P, P + N, B );
	int ans = 0;
	while( acnt > 0 && bcnt > 0 && ccnt > 0 ) {
		acnt--;
		bcnt--;
		ccnt--;
		ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000010];
int main(){
	int n,k;
	cin>>k>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int maxn=a[0]+k-a[n-1];
	for(int i=1;i<n;i++){
		maxn=max(a[i]-a[i-1],maxn);
	}
	cout<<k-maxn<<endl;
}

Measured memory_bytes: 1024
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(n):
    a += [a[i]+A[i]]
for i in range(m):
    b += [b[i]+B[i]]

ans, i = 0, m
for j in range(n+1):
    if a[j] > k:
        break
    while b[i] > k-a[j]:
        i -= 1
    ans = max(ans, i+j)
print(ans)
    


Measured memory_bytes: 47412
#include <bits/stdc++.h>
#define inf (int)1e9
using namespace std;

int n, m, s, t;
vector<vector<int>> edge;
vector<int> ds, dt;
queue<int> qu;
map<int, long long> mps, mpt;

long long solve();

int main() {
  cin >> n >> m >> s >> t;
  --s, --t;
  edge.resize(n);
  for(int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    edge[--x].push_back(--y);
    edge[y].push_back(x);
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  ds.assign(n, inf);
  dt.assign(n, inf);
  ds[s] = 0;
  dt[t] = 0;
  qu.push(s);
  while(!qu.empty()) {
    int now = qu.front();
    qu.pop();
    for(int i = 0; i < edge[now].size(); ++i)
      if(ds[edge[now][i]] == inf) {
        ds[edge[now][i]] = ds[now] + 1;
        qu.push(edge[now][i]);
      }
  }
  qu.push(t);
  while(!qu.empty()) {
    int now = qu.front();
    qu.pop();
    for(int i = 0; i < edge[now].size(); ++i)
      if(dt[edge[now][i]] == inf) {
        dt[edge[now][i]] = dt[now] + 1;
        qu.push(edge[now][i]);
      }
  }
  for(int i = 0; i < n; ++i) {
    ++mps[ds[i]];
    ++mpt[dt[i]];
  }
  long long ans = 0, target = ds[t] - 2;
  for(auto nmp : mps) {
    long long nowds = nmp.first, nowdt;
    nowdt = target - nowds;
    ans += nmp.second * mpt[nowdt];
  }
  return ans;
}


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

using namespace std;

typedef long long ll;

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<ll> towns;
    towns.push_back(1);
    vector<bool> visited(n + 1);
    visited[1] = true;
    while (1) {
        ll cur = towns[(int)towns.size() - 1];
        ll next = a[cur];
        towns.push_back(next);
        if (visited[next]) {
            break;
        } else {
            visited[next] = true;
        }
    }
    ll size = towns.size();
    ll l = towns[size - 1];
    ll startidx;
    for (int i = 0; i < size; ++i) {
        if (towns[i] == l) {
            startidx = i;
            break;
        }
    }
    startidx++;
    if (startidx > k) {
        cout << towns[k];
    } else {
        cout << towns[startidx + (k - startidx) % (size - startidx)];
    }
    return 0;
}


Measured memory_bytes: 6960
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int n, m; cin >> n >> m;

    int ans;
    if (n >= 1 && m >= 1) ans = (n-1)*n/2 + (m-1)*m/2;
    else if (n >= 1) ans = (n-1)*n/2;
    else if (m >= 1) ans = (m-1)*m/2;
    else ans = 0;
    out(ans);


    return 0;
}






Measured memory_bytes: 256
S = input()
ans = 0
s = ""
for bit in range(2**(len(S)-1)):
    s = "".join(list(map(lambda i,x: x+"+" if ((bit>>i) & 1 and (i<len(S)-1)) else x, range(len(S)), S)))
    ans += eval(s)
print(ans)

Measured memory_bytes: 3060
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    long long A,B,C,K;cin >> A >> B >> C >> K;
    long long ans = 0;
    if(A >= K) {
        cout << K << endl;
        return 0;
    }
    if(A < K && B+A >= K){
        cout << A << endl;
        return 0;
    }
    cout << A - (K-A-B) << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const int INF=(1<<30);

int dp[401][401];

int main(){
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;

  REP(i,401)REP(j,401) dp[i][j] = INF;
  dp[0][0]=0;
  vector<tuple<int,int,int>> med(N);

  REP(i,N){
    int a,b,c;
    cin >> a >> b >> c;
    med[i] = make_tuple(a,b,c);
  }

  REP(k,N){
    int a,b,c;
    a = get<0>(med[k]);
    b = get<1>(med[k]);
    c = get<2>(med[k]);
    for(int i=10*N; i >=0; i--){
      for(int j=10*N; j>=0; j--){
        if(dp[i][j]==INF)continue;
        dp[i+a][j+b] = min(dp[i+a][j+b], dp[i][j] + c);
      }
    }

  }


  // REP(i,10*N+1)REP(j,10*N+1){
  //    if(dp[i][j]==INF)continue;
  //    printf("%d %d: %d\n",i,j,dp[i][j]);
  //  }

  int ans=INF;

  REP(i,N*10+1)REP(j,N*10+1){
    if(i+j==0)continue;
    if(dp[i][j]==INF)continue;
    if(i*Mb==j*Ma){
      // printf("%d %d\n",i,j);
      ans=min(dp[i][j],ans);
    }
  }
  if(ans==INF)ans=-1;
  cout << ans << endl;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
ll N,K,count;
cin >> N >> K;
count=0;
for(ll i=K;i<N+2;i++)
count += (N-i+1)*i+1;
cout << count % 1000000007 << endl;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define rEP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9+7;

int a, b, c, N,A,B,sum,ans;
string s;
int F[110][11];
int P[110][11];
int cnt[110];
int main() {
    cin>>N;
    ans=-inf;
    REP(i,0,N){
        REP(j,0,10){
            cin>>F[i][j];
        }
    }
    REP(i,0,N){
        REP(j,0,11){
            cin>>P[i][j];
        }
    }
    REP(mask,1,1<<10){
        sum=0;
        REP(i,0,N) cnt[i]=0;
        REP(i,0,10){
            if(mask&(1<<i)){
                REP(j,0,N){
                    if(F[j][i]) {
                        cnt[j]++;

                    }
                }
            }
        }
        REP(i,0,N){
            sum+=P[i][cnt[i]];
        }

        ans=max(ans,sum);
    }
    p(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, counter;
  cin >> A >> B;
  counter = 0;
  while(A<=B){
  	int t, a1, a2, a3, a4, a5;
  	t = A;
  	a1 = t%10;
  	t /= 10;
  	a2 = t%10;
  	t /= 10;
  	a3 = t%10;
  	t /= 10;
  	a4 = t%10;
  	t /= 10;
  	a5 = t%10;
  	t /= 10;
    if((a1==a5)&&(a2==a4)){
      counter++;
    }
    A++;
  }
  cout << counter << endl;
  
}

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

int is_palindrome(string s, int n)
{
    int i;
    
    i = -1;
    while (++i < n / 2)
        if (s.at(i) != s.at(s.size() - 1 - i))
            return (0);
    return (1);
}

int main(void)
{
    string s;
    cin >> s;
    char t[s.size() / 2 + 1];
    int i;
    
    i = -1;
    while (++i < s.size() / 2)
        t[i] = s.at((s.size() + 1) / 2 + i);
    t[i] = 0;
    if (is_palindrome(s, s.size()) && is_palindrome(s, s.size() / 2) && is_palindrome(t, s.size() / 2))
        cout  << "Yes";
    else
        cout << "No";
    return (0);
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  long long a[100000], b[100000];
  for (int i = 0; i < n; ++i)
  {
    scanf("%lld %lld", a + i, b + i);
  }
  long long ans = 0;
  for (int i = n - 1; i >= 0; --i)
  {
    long long r = (a[i] + ans) % b[i];
    if (r == 0) continue;
    ans += b[i] - r;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1664
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
main ()

Measured memory_bytes: 21572
let rev_iter (f : int -> unit) (a : int array) =
  let rec doit i =
    if i >= 0 then (f a.(i); doit (i - 1))
  in
  doit (Array.length a - 1)

let counting_sort a b k =
  let c = Array.make (k + 1) 0 in
  Array.iter (fun e -> c.(e) <- c.(e) + 1) a;
  Array.iteri (fun i _ -> if i <> 0 then c.(i) <- c.(i) + c.(i - 1)) c;
  rev_iter (fun e -> b.(c.(e) - 1) <- e; c.(e) <- c.(e) - 1) a

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun e -> e)) in
  let b = Array.make n 0 in
  counting_sort a b 10000;
  Array.iteri (fun i e -> if i <> 0 then print_string " "; print_int e) b;
  print_newline ()

Measured memory_bytes: 36264
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

if In.str() == "ABC":
    Out.str("ARC")
else:
    Out.str("ABC")


        
######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 85888
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int countDays(int year, int month, int day)
{
    int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int cnt = day;

    if (month == 1)
    {
        return cnt;
    }

    for (int i = 0; i < month - 1; i++)
    {
        cnt += days[i];
    }

    if (month >= 3 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
    {
        cnt++;
    }

    return cnt;
}

int main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    cout << pow(n, 3) << endl;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "keyofscience" ].parse.expand.solve == "YES" );
	assert( [ "mpyszsbznf" ].parse.expand.solve == "NO" );
	assert( [ "ashlfyha" ].parse.expand.solve == "NO" );
	assert( [ "keyence" ].parse.expand.solve == "YES" );

	assert( [ "keyencex" ].parse.expand.solve == "YES" );				// 追加ケース
	assert( [ "xkeyencex" ].parse.expand.solve == "NO" );				// 追加ケース
	assert( [ "keyxxxenxxxence" ].parse.expand.solve == "YES" );		// 追加ケース
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	return match( s, "keyence", 0, false ) ? "YES" : "NO";
}

bool match( string s, string k, long dc, bool ma )
{
	// 削除対象の部分文字列が2個以上になったら失敗
	if( 1 < dc ) return false;
	
	// マッチングが完了
	if( s.length <= 0 && k.length <= 0 ) return true;
	
	// マッチングの途中で入力文字列が足りなくなったら失敗
	if( s.length < k.length ) return false;
	
	// マッチングの途中で入力文字列が余ったら、余った分は削除対象扱い
	if( k.length <= 0 ) return ( dc <= 0 );
	
	// 先頭の文字をマッチング
	if( s[ 0 ] == k[ 0 ] )
	{
		auto m1 = match( s[ 1 .. $ ], k[ 1 .. $ ], dc,       false );		// マッチしたパターン
		auto m2 = match( s[ 1 .. $ ], k[ 0 .. $ ], dc + !ma, true );		// マッチを無視するパターン
		return ( m1 || m2 );
	}
	else
	{
		auto m2 = match( s[ 1 .. $ ], k[ 0 .. $ ], dc + !ma, true );		// マッチしなかったパターン
		return m2;
	}
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a = ni()
b = ni()
c = ni()
d = ni()

if a > b:
    x = b
else:
    x = a

if c > d:
    y = d
else:
    y = c

print(x+y)


Measured memory_bytes: 3316
N, M = map(int,input().split())
v = []
for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    v.append((x,str(y)))

for i in range(10**N):
    fl = True
    s = str(i)
    # N桁になるまで待ってもらう
    if len(s) != N:
        continue
    for a,b in v:
        if s[a] != b:
            fl = False
    if fl:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3188
# input
n = int(input())
s = input()

# preparation
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
max = 0
count = 0

# main
for i in range(len(s)):
  count = 0
  a = (s[i:n])
  b = (s[0:i])
  for j in range(len(ascii_lowercase)):
    if (a.count(ascii_lowercase[j]) > 0 and b.count(ascii_lowercase[j]) > 0):
      count += 1
  if (max < count):
    max = count
print (max)

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>box(n);
 
for(int i=0;i<n;i++){
  cin>>box.at(i);
}
  
sort (box.begin(),box.end());
reverse (box.begin(),box.end());
  
int sum=0;
for(int i=0;i<n;i++){
  sum=sum+box.at(i);
}

if(box.at(m-1)<(double)sum/(4*m))cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}

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


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		string s;
		cin >> s;
		if(cin.fail()) break;
		if(s[0]!='R' && s[0]!='S') break;

		int ans=0;
		int c=0;
		for(int i=0;i<3;i++)
		{
			if(s[i]=='R')
			{
				c++;
			}
			else
			{
				c=0;
			}
			max_u(ans, c);
		}

		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3644
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define exists(x,m) m.find(x) != m.end()
#define umap unordered_map
#define uset unordered_set
#define pq priority_queue

const ll MOD = 1e9 + 7;

template<typename T>
pair<vector<T>, vector<bool>> prime_sieve(T lim) {
	vector<T> primes = vector<T>();
	vector<bool> composite = vector<bool>(lim+1);
	for (T num = 2; num <= lim; num++) {
		if (!composite[num]) primes.pb(num);
		for (int i = 0; i < isize(primes) and num * primes[i] <= lim; i++) {
			composite[num * primes[i]] = true;
			if (num % primes[i] == 0) break;
		}
	}
	return {primes, composite};
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n; cin >> n;
	vi A = vi();
	int maxx = 0;
	rep(i, n) {
		int x; cin >> x;
		A.pb(x);
		maxx = max(maxx, x);
	}	
	auto [primes, composite] = prime_sieve((int)min(1e3+100, ceil(sqrt(maxx)) + 100));
	vi prime_freq = vi(maxx+1, 0);
	for (const int& a : A) {
		int b = a;
		for (int i = 0; primes[i]*primes[i] <= b; i++) {
			if (b % primes[i] == 0) prime_freq[primes[i]]++;
			while(b % primes[i] == 0) b /= primes[i];
		}
		if (b != 1) prime_freq[b]++;
	}
	int max_freq = 0;
	rep(i, isize(prime_freq)){
		max_freq = max(max_freq, prime_freq[i]);
	}
	if (max_freq <= 1) {
		cout << "pairwise coprime";
	} else {
		cout << (max_freq < n ? "setwise coprime" : "not coprime");
	}
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

    for (int i = s.size() - 1; i >= 0; i--)
    {
        string t = s.substr(0, i);
        int n = t.size();
        if (n & 1)
            continue;

        if (t.substr(0, n / 2) == t.substr(n / 2))
        {
            cout << i << '\n';
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
use std::cmp::*;
use std::collections::BinaryHeap;

fn readln() -> Vec<String> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().split_whitespace().map(|s| s.to_owned()).collect()
}

fn main() {
    const INF: i32 = 1010101010;

    let input: Vec<i32> = readln().iter().map(|s| s.parse().unwrap()).collect();
    let n = input[0];
    let m = input[1];
    let s: Vec<char> = readln()[0].chars().collect();

    let mut steps = vec![INF; (n + 1) as usize];
    let pq = &mut BinaryHeap::<(i32, i32)>::new();
    pq.push((0, n));
    for i in 0..(n + 1) {
        let i = n - i;
        let mut step = INF;
        if s[i as usize] == '0' {
            while let Some(&(val, lim)) = pq.peek() {
                if lim <= i {
                    step = -val + 1;
                    break;
                }
                pq.pop();
            }
        }
        steps[i as usize] = step;
        if step != INF {
            pq.push((-step, i - m));
        }
    }

    if steps[0] == INF {
        println!("-1");
        return;
    }

    let mut pos = 0;
    let mut ans = vec![];
    while pos < n {
        let mut x = pos + 1;
        while steps[pos as usize] != steps[x as usize] + 1 {
            x += 1
        }
        ans.push((x - pos).to_string());
        pos = x;
    }
    println!("{}", ans.join(" "));
}


Measured memory_bytes: 10620
#include <stdio.h>
int main(){
    int n,a,i;
    int max=-1000000;
    int min=1000000;
    long long sum=0;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&a);
        
        if(max<a) max=a;
        if(min>a) min=a;
        
        sum+=a;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
    
}


Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main()
{
	int a[5];
	for (size_t i = 0; i < 5; i++)
	{
		cin >> a[i];
	}

	int m[5];
	for (size_t i = 0; i < 5; i++)
	{
		m[i] = 10 - (a[i] % 10);
		m[i] %= 10;
	}

	sort(m, m + 5);

	int ans = 0;
	for (size_t i = 0; i < 5; i++)
	{
		ans += a[i];
		ans += m[i];
	}
	ans -= m[4];

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


Measured memory_bytes: 256
#include <stdio.h>
	#include <iostream>
	#include <vector>
	#include <algorithm>
	using namespace std;
	typedef long long ll;
	typedef std::vector<ll> lls;
	#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
	#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

	void cinv(lls& llVec, ll n) {
		ll val;
		llVec.reserve((size_t)(n));
		for (ll i = 0; i < n; i++) {
			cin >> val;
			llVec.push_back(val);
		}
	}


	int main()
	{
		ll N;
		lls v;

		cin >> N;
		cinv(v, N);
		
		//ソート
		std::sort(v.begin(), v.end(),
			[](ll& a, ll& b) {return a < b; }
		);

		double temp;
		temp = (double)v[0];
		for (int i = 1; i < v.size(); i++) {
			temp = (temp + v[i])/2.0;
		}

		cout << temp << '\n';

		return 0;
	}



Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
char ch[100100];
int main(){
	int n;
	scanf("%d",&n);
	
	scanf("%s",ch+1);
	int len=strlen(ch+1);
	for(int i=1;i<=len;i++){
		int now=(ch[i]-'A');
		printf("%c",((now+n)%26+'A'));
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)


void solve(long long N){
  cout<<(((N-1)*N)>>1)<<endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n,f[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  vector<int>v;
  v.pb(1);
  for(int i=9;i<=n;i*=9)v.pb(i);
  for(int i=6;i<=n;i*=6)v.pb(i);
  for(int i=1;i<=n;i++){
    f[i]=1e9;
    for(auto k:v){
      if(k<=i){
        f[i]=min(f[i],f[i-k]+1);
      }
    }
  }
  cout<<f[n]<<endl;
  return 0;
}

Measured memory_bytes: 4036
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    int N = sc.nextInt();
	    int K = sc.nextInt();
	    int X = sc.nextInt();
	    int Y = sc.nextInt();
	    
	    if(N < K) {
	    	System.out.println(N*X);
	    }else {
	    	System.out.println(K*X + (N-K)*Y);
	    }
	}
	
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>  
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long  ll;
int main(){
  int n,k;
  cin>>n>>k;
  vector<vector<int>> vec(n);
  
  for(int i=0; i<k; i++){
    int d;
    cin>>d;
    vector<int> v(d);
    for(int j=0; j<d; j++){
      cin>>v.at(j);
      vec.at(v.at(j)-1).push_back(i);
    }
    
  }
  int count=0;
  for(int  i=0; i<n;i++){
    if(vec.at(i).size()==0)count++;
   
  }
  cout<<count;
}

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

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif     
	long long x;
	cin >> x;
	long long ans = 0;
	long long cur = 100;
	while(cur < x){
		++ans;
		cur += cur/100;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順

signed main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c<=21){
    cout << "win" << endl;
  }
  else{
    cout << "bust" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	M := N - K
	for i := 1; i <= K; i++ {
		if i > M+1 {
			fmt.Println(0)
			continue
		}
		v := ModCombination(M+1, i) * ModCombination(K-1, i-1) % Mod
		fmt.Println(v)
	}
}

const Mod = int(1e9) + 7

func ModInverse(n int) int { return ModPow(n, Mod-2) }
func ModDiv(a, b int) int  { return a * ModInverse(b) }
func ModPow(a, b int) int {
	x := 1
	for b > 0 {
		if b&1 == 1 {
			x = x * a % Mod
		}
		a = a * a % Mod
		b >>= 1
	}
	return x
}
func ModFactorial(n int) int      { return fac[n] }
func ModPermutation(n, r int) int { return fac[n] * finv[n-r] % Mod }
func ModCombination(n, k int) int { return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod }

var fac, finv, inv []int

func init() {
	const MAX = 2001
	fac, finv, inv = make([]int, MAX+1), make([]int, MAX+1), make([]int, MAX+1)
	fac[0], fac[1], finv[0], finv[1], inv[1] = 1, 1, 1, 1, 1
	for i := 2; i <= MAX; i++ {
		fac[i] = fac[i-1] * i % Mod
		inv[i] = Mod - inv[Mod%i]*(Mod/i)%Mod
		finv[i] = finv[i-1] * inv[i] % Mod
	}
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main()
{
    string s;
    cin >> s;
    for (int bp = 0; bp < 8; bp++) {
        int sum = s[0] - '0';
        for (int i = 0; i < 3; i++) {
            if (bp & (1 << i)) {
                sum += s[i + 1] - '0';
            } else {
                sum -= s[i + 1] - '0';
            }
        }
        if (sum == 7) {
            cout << s[0];
            for (int i = 0; i < 3; i++) {
                if (bp & (1 << i)) {
                    cout << "+" << s[i + 1];
                } else {
                    cout << "-" << s[i + 1];
                }
            }            
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
    int a,b;
    while(1){
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        if(a < b) {
            cout << a << " " << b << endl;
        }else{
            cout << b << " " << a << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3108