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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    char C;
    cin >> C;
    printf("%c\n", C + 1);

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll mx = 0;
	vector<ll> a(n);
	rep(i,n){
		cin >> a[i];
		chmax(mx, a[i]);
	}
	ll dis = 1e9, ans = -1;
	rep(i,n){
		if(mx == a[i]) continue;
		if(dis > abs(mx/2 - a[i])){
			ans = a[i];
			dis = abs(mx/2 - a[i]);
		}
	}
	cout << mx << " " << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define All(a) a.begin(), a.end()
typedef pair<int, int> P;
long long INF = 1e14;
struct edge{
    int to;
    int cost;
};
vector<int> use;
long long N, M;//Vは頂点、Eは辺の数
void solve(){//priority_queueを用いる
    long long d[N];//各頂点までの距離
    use.resize(N, -1);
    priority_queue<P, vector<P>, greater<P>> que;
    vector<edge> G[N];
    fill(d, d + N, INF);
    for(int i = 0; i < M; i++){
        int a = 0;
        edge es;
        cin >> a >> es.to;
        a--;
        es.to--;
        es.cost = 1;
        edge e = {a, 1};
        G[a].push_back(es);
        G[es.to].push_back(e);
    }
    int s = 0;//スタート地点は最初0
    d[s] = 0;
    que.push(P(0, 0));
    use[0] = 0;
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                use[e.to] = v;
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    for(int i = 0; i < N; i++){
        if(use[i] == -1){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; i++) cout << use[i] + 1 << endl;
}

int main(){
    cin >> N >> M;
    solve();
}

Measured memory_bytes: 13972
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second

int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

signed main(){
	int n;
	cin>>n;
	map<int,int>N;
	int a[n];
	vector<int>v;
	r(i,n){
		cin>>a[i];
		v.push_back(a[i]);
	}
	sort(v.begin(),v.end(),greater<int>());

	if(v[0]==v[1]){
		r(i,n)cout<<v[0]<<endl;
	}
	else{
		r(i,n){
			if(a[i]==v[0])cout<<v[1]<<endl;
			else cout<<v[0]<<endl;
		}
	}
}

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

int main() {
    int N;
    int field = 0;
   
    const int CARDS = 100;
    const int MAX_PLAYERS = 10;
    
    vector<int> Hand(CARDS);
    vector<char> Draw(MAX_PLAYERS);
    
    while (1) {
        field = 0;
        cin >> N;
        if(N == 0) {
            break;
        }
            
        Hand.clear();
        Draw.clear();
                
        vector<int>::iterator HandI = Hand.begin();
        vector<char>::iterator DrawI = Draw.begin();
        
        for(int i = 0; i < CARDS; i++) {
          char card;
          cin >> card;
          Draw.push_back(card);
        }
        
        for (int i = 0; i < N; i++) {
            Hand.push_back(0);
        }
        
        for (DrawI = Draw.begin(); DrawI != Draw.end(); ++DrawI) {
                        
            if (*DrawI == 'S') {
                ++*HandI;
                field += *HandI;
                *HandI = 0;
            }
            else if (*DrawI == 'L') {
                ++*HandI;
                *HandI += field;
                field = 0;
            }
            else {
                ++*HandI;
            }
            
            ++HandI;
            
            
            if(HandI == Hand.end()) {
                HandI = Hand.begin();
            }
        }
        sort (Hand.begin(), Hand.end());
        
        for (HandI = Hand.begin(); HandI != Hand.end(); ++HandI) {
            cout << *HandI << " ";
        }
        
        cout << field <<"\n";
    }
    return 0;
}

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


int main()
{
    int n,m,x;
    int A[105]={0};
    cin>>n>>m>>x;
    for(int i=0;i<m;i++)
    {
        int a;
        cin>>a;
        A[a]=1;
    }
    int ans1=0,ans2=0;
    for(int i=x;i<=n;i++)
    {
        ans1+=A[i];
    }
    for(int i=x;i>=0;i--)
    {
        ans2+=A[i];
    }
    cout<<min(ans1,ans2)<<endl;
}


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

string s;
int p;


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

	for(int i = 0;i<s.length();i++){
		s[i] = ((s[i] - 'A'+p) %26+'A');
	}

	cout<<s;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,ans=-100000000;
  scanf("%d%d",&a,&b);
  if(a+b>ans)ans=a+b;
  if(a-b>ans)ans=a-b;
  if(a*b>ans)ans=a*b;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <ctime>
#include <deque>
using namespace std;

int n, m, k;
int a[110000];
long long dp[110000][310];
int q[110000], h[110000], xx[110000][310];

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	for (int i = 1; i <= k; i++)
		dp[0][i] = -1e18;
	for (int i = 0; i <= k; i++)
		q[i] = h[i] = 1, xx[i][1] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= k; j++) {
			while (q[j] <= h[j] && xx[j][q[j]] < i - m)
				q[j] += 1;
			dp[i][j + 1] = dp[xx[j][q[j]]][j] + 1LL * (j + 1) * a[i];
		}
		for (int j = 0; j <= k; j++) {
			while (q[j] <= h[j] && dp[xx[j][h[j]]][j] <= dp[i][j])
				h[j] -= 1;
			xx[j][++h[j]] = i;
				// q[j] += 1;
		}
	}
	long long ans = -1e18;
	for (int i = 1; i <= n; i++)
		ans = max(ans, dp[i][k]);
	cout << ans << endl;
}

Measured memory_bytes: 243456
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main()
{
    int N;
    cin >> N;
    if (N % 2 == 1) { N *= 2; }
    cout << N << endl;
    return 0;
}


Measured memory_bytes: 384
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=B[A[0]-1]

for i in range(1,N):
    ans+=B[A[i]-1]
    if A[i-1]+1==A[i]:
        ans+=C[A[i-1]-1]

print(ans)




Measured memory_bytes: 3064
from statistics import mean
N = int(input())
a=list(map(int,input().split(' ')))

avg=mean(a)

b=[]
for i in range(N):
    b.append(abs(a[i]-avg) )

#print(min(b))
#c=sorted(b)

for i in range(N):
    if b[i]==min(b):
        print(i)
        exit(0)


Measured memory_bytes: 5660
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    A2IN(ll, A, ll, B, N);
    vii T(N);
    REP(i, N)
    {
        T[i] = {B[i], A[i]};
    }
    SORT(T);
    ll t = 0;
    bool ok = true;
    for (auto [b, a] : T)
    {
        t += a;
        ok &= t <= b;
    }
    YES(ok);
}

Measured memory_bytes: 9552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void){
	string s; cin >> s;
	string t = s;
	reverse(all(t));
	rep(i, s.size()){
		if(s[i] == 'b') s[i] = 'd';
		else if(s[i] == 'd') s[i] = 'b';
		else if(s[i] == 'p') s[i] = 'q';
		else if(s[i] == 'q') s[i] = 'p';
	}
	if(s == t) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> arr(m, 0);
    for(auto& val: arr)
        cin >> val;
    sort(arr.begin(), arr.end());
    priority_queue<int> pq;
    for(int i = 1; i < m; i++) {
        pq.push(arr[i]-arr[i-1]);
    }
    int rmv = n-1;
    while (!pq.empty() && rmv > 0) {
        pq.pop();
        rmv --;
    }
    ll ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        // cout << "add " << pq.top() << endl;
        pq.pop();
    }

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




Measured memory_bytes: 1276
#include <stdio.h>

int main(void)
{

    int a, b, c, j;
    int i = 0;

    do {
    scanf("%d %d %d", &a, &b, &c);
    }while (a > b);

    for (j = a; j <= b; j++) {
        if (c % j);
        else
            i++;
    }

    printf("%d\n", i);

    return 0;
}

Measured memory_bytes: 596
use std::io::*;
use std::str::FromStr;

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

fn main(){
    let a: u32 = read();
    let b: u32 = read();

    if a > 9 || b > 9 {
        println!("-1");
        return;
    }

    println!("{}", a * b);
}

Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
s = input()

rl = 0
for i in range(n-1):
    if s[i:i+2]=="RL":
        rl += 1

if k>rl:
    print(n-1)
else:
    res = n - 2*(rl-k)
    if s[0]=="L":
        res -= 1
    if s[n-1]=="R":
        res -= 1

    print(res)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int a, b;
int read()
{
	int x = 0,f = 1;
	char ch= getchar();
	while(ch<'0' || ch>'9')
	{
		if(ch == '-')
			f=-1;
		ch = getchar();
	} 
	while(ch>='0' && ch<='9')
	{
		x = (x<<1) + (x<<3) + ch-'0';
		ch = getchar();
	}
	return x*f;
}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	a = read(), b = read();
	int  re = (a >= 2 * b) ? a - 2 * b : 0;
	printf("%d", re);
	return 0;
} 

Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    else:
        print(a//b)




Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;


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

  int n; cin >> n;

  vector<vector<pair<int, int>>> s;
  rep(i, n) {
    int a; cin >> a;
    vector<pair<int, int>> xy;
    rep(i, a) {
      int x, y; cin >> x >> y; x--;
      xy.emplace_back(x, y);
    }
    s.push_back(xy);
  }

  int ans = 0;
  for (int bit = 0; bit < (1<<n); bit++) {
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if (!((bit >> i) & 1)) continue;
      for (auto& p : s[i]) {
        if (((bit >> p.first) & 1) != p.second) flag = false;
      }
    }
    if (flag) {
      bitset<16> bs(bit);
      chmax(ans, int(bs.count()));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, m, a;
    cin >> n >> m;
    queue<int> q[n];
    
    for(int i=0;i<n;i++){
    	for(int j=0;j<m;j++){
    		cin >> a;
    		q[i].push(a - 1);
    	}
    }

    bool fin[m];
    memset(fin,0,sizeof(fin));

    int ans = n;
    bool maki = true;

    while(maki){
        vector<int> cnt(m, 0);
        for(int i=0;i<n;i++) cnt[q[i].front()]++;
        int num = 0, id = 0;
        for(int i=0;i<m;i++) {
        	if(num < cnt[i]) num = cnt[i], id = i;
        }
        ans = min(ans, num);
        fin[id] = true;
        
        for(int i=0;i<n;i++){
        	while(!q[i].empty() && fin[q[i].front()]) q[i].pop();
        	if(q[i].empty()) maki = false;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

struct segment_tree_max {
    static const int N = 1e6 + 5;
    int t[2 * N + 5];
    void update(int pos, int val) {
        for (t[pos += N] = val; pos > 1; pos >>= 1) {
            t[pos >> 1] = max(t[pos], t[pos ^ 1]);
        }
    }
    int get(int l, int r) {
        int res = 0;
        for (l += N, r += N; l <= r; l >>= 1, r >>= 1) {
            if (l & 1) res = max(res, t[l++]);
            if (!(r & 1)) res = max(res, t[r--]);
        }
        return res;
    }
} tree_max;

struct segment_tree_min {
    static const int N = 1e6 + 5;
    int t[2 * N + 5];
    void update(int pos, int val) {
        for (t[pos += N] = val; pos > 1; pos >>= 1) {
            t[pos >> 1] = min(t[pos], t[pos ^ 1]);
        }
    }
    int get(int l, int r) {
        int res = N;
        for (l += N, r += N; l <= r; l >>= 1, r >>= 1) {
            if (l & 1) res = min(res, t[l++]);
            if (!(r & 1)) res = min(res, t[r--]);
        }
        return res;
    }
} tree_min;

struct Point {
    int x, y, id;
    bool operator<(const Point& ot) const {
        return std::tie(x, y, id) < std::tie(ot.x, ot.y, ot.id);
    }
};

const int N = 2e5 + 10;
Point a[N];
int a_inv[N];
int rig[N], ans[N];
int sc[N];

void solve(int n) {
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        a_inv[a[i].y] = i;
    }
    for (int i = 1; i <= n; i++) {
        tree_min.update(i, a[i].y);
    }
    for (int i = n; i >= 1; i--) {
        tree_max.update(a[i].y, i);
        rig[i] = tree_max.get(a[i].y, n);
    }
    vector<pii> vec;
    for (int i = 1; i <= n; i++) {
        vec.pb({a[i].y, i});
    }
    sort(vec.begin(), vec.end());
    for (auto [val, i] : vec) {
        rig[i] = max(rig[i], rig[a_inv[tree_min.get(1, rig[i])]]);
    }
    for (int i = 1; i <= n; i++) {
        if (i < rig[i]) {
            sc[i + 1]++;
            sc[rig[i] + 1]--;
        }
    }
    for (int i = 1; i <= n; i++) {
        sc[i] += sc[i - 1];
        ans[a[i].id] = rig[i] - i + 1 + sc[i];
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].x >> a[i].y;
        a[i].id = i;
    }
    solve(n);
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << "\n";
    }

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 13392
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>

using namespace std;

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

	string h, m, s;
	char ts[10];
	int tt;
	tt = t / 60 / 60; 
	t = t % (60 * 60);
	sprintf(ts, "%d", tt );
	h.append(ts);
	 
	tt = t / 60;
	t = t % 60;
	sprintf(ts, "%d", tt);
	m.append(ts);

	sprintf(ts, "%d", t);
	s.append(ts);

	cout << h << ":" << m << ":" << s << endl;
return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int n;
  	cin>>n;
  	vector<double>arr(n);
  	for(int i = 0; i < n; i++){
    	cin>>arr[i];
    }
  	double ans = 0;
  	sort(arr.begin(), arr.end());
  	ans = arr[0];
  	for(int i = 1; i < n; i++){
    	ans+=arr[i];
      	ans/=2;
    }
  	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  ll q, h, s, d;
  cin >> q >> h >> s >> d;
  
  ll liters;
  cin >> liters;
  
  if (liters % 2 == 0) {
    cout << min(liters*q*4, min(liters*h*2, min(liters*s, liters/2*d))) << endl;
  } else {
    ll subtotal = min(4*q, min(2*h, s)); // buy 1 liter from 0.25, 0.5, or 1
    liters--;
    cout << subtotal + min(liters*q*4, min(liters*h*2, min(liters*s, liters/2*d))) << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

const R: u64 = 1000000007;

fn pow(n: u64, r: u64) -> u64 {
    let mut ret = 1;
    if r > 0 {
        ret = pow(n, r / 2);
        ret = ret * ret % R;
        if r % 2 == 1 {
            ret = ret * n % R;
        }
    }
    ret
}

fn main() {
    let nk: Vec<u64> = read_vec();
    let n = nk[0];
    let k = nk[1];

    let mut ans = 0;

    if k <= n - 2 {
        let mut a = n;
        let mut b = 1;
        for l in 2..n + 1 {
            a = (a * (n - l + 1)) % R;
            a = (a * pow(l, R - 2)) % R;
            b = (b * (n - l + 1)) % R;
            b = (b * pow(l - 1, R - 2)) % R;
            if l >= n - k {
                ans = (ans + ((a * b) % R)) % R;
            }
        }
    } else {
        ans = 1;
        for i in n + 1..2 * n {
            ans = (ans * i) % R;
        }
        for i in 1..n {
            ans = (ans * pow(i, R - 2)) % R;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
    int i, q, x1, y1, x2, y2, x3, y3, x4, y4;
    scanf("%d", &q);
    for(i=0; i<q; i++){
        scanf("%d%d%d%d%d%d%d%d", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        if((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1)==0)
         printf("2\n");
       else if((y2-y1)* (y4-y3)+(x2-x1)*(x4-x3)==0)
        printf("1\n");
        else
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 2140
n,k = map(int,input().split())

r,s,p = map(int,input().split())

t = input()
l = [[] for i in range(k)]

ans = 0

for i in range(n):
    mod = i%k
    l[mod].append(t[i])
        
for i in range(k):
    h = ""
    for j in l[i]:
        if j == "r" and h != "p":
            ans += p
            h = "p"
        elif j == "s" and h != "r":
            ans += r
            h = "r"
        elif j == "p" and h != "s":
            ans += s
            h = "s"
        else:
            h = ""
print(ans)    

Measured memory_bytes: 13436
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int A; cin >> A;
	ll B, N; cin >> B >> N;
	ll ans = (A * min(N, B - 1)) / B;
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		long ans = 0;
		for(int i = 0; i < n; i++) {
			ans += sc.nextInt();
		}
		System.out.println(ans - n);
    }
}


Measured memory_bytes: 25904
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N;
    cin >> N;

    ll a;
    ll color[9];
    rep(i, 9){
        color[i] = 0;
    }
    rep(i, N){
        cin >> a;
        if(a <= 399){
            color[0]++;
        }else if(a <= 799){
            color[1]++;
        }else if(a <= 1199){
            color[2]++;
        }else if(a <= 1599){
            color[3]++;
        }else if(a <= 1999){
            color[4]++;
        }else if(a <= 2399){
            color[5]++;
        }else if(a <= 2799){
            color[6]++;
        }else if(a <= 3199){
            color[7]++;
        }else{
            color[8]++;
        }
    }

    ll ans = 0;
    rep(i, 8){
        if(color[i] > 0){
            ans++;
        }
    }

    if(ans == 0){
        if(color[8] != 0){
            cout << 1 << " " << color[8] << endl;
        }else{
            cout << "0 0" << endl;
        }
    }else{
        cout << ans << " " << ans + color[8] << endl;
    }

    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define sq(x) ((x) * (x))
int main()
{
    int D, N;
    cin >> N >> D;
    vector<vector<int>> x(N, vector<int>(D));
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < D; ++j)
        {
            cin >> x[i][j];
        }
    }
    int cnt = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            int sum = 0;
            for (int k = 0; k < D; ++k)
            {
                sum += sq((x[i][k] - x[j][k]));
            }
            double calc = sqrt((double)sum);
            if (calc == (int)calc)
                cnt++;
            //            cout << calc << endl;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz              300005
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int main(){
    Fast;
    int a,b,c, i,j, n,m,t, cs=1;

    string s,p ;
    cin>>s>>p;
    int cnt=0;
    for(i=0; i<s.size(); i++){
        cnt+=(s[i]!=p[i]);
    }
    cout<<cnt<<endl;




    return 0;
}



Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

bool vis[maxn];
vector<int>v[maxn];

void dfs(int st){
	vis[st] = 1;
	for(auto i:v[st]){
		if(!vis[i]){
			dfs(i);
		}
	}
}

int32_t main(){
	fastio();
	int n , m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		int a,b,c;
		cin >> a >> b >> c;
		v[a].push_back(b);
		v[b].push_back(a);
	}	

	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(!vis[i]){
			dfs(i);
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 12308
//In The Name Of God
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 4e2 + 5, Mod = 1e9 + 7, P = 727, Lg = 17, TOF = 1900;

vector< pair< int, int > > Adj[N][N];
int Mark[N][N], bl, wh;
char A[N][N];

void Add(int a, int b, int c, int d){
      if(A[a][b] == A[c][d])
            return ;
      Adj[a][b].pb(mp(c, d));
      Adj[c][d].pb(mp(a, b));
}
void Dfs(int i, int j){
      Mark[i][j] = 1;
      if(A[i][j] == '#')
            bl++;
      else
            wh++;
      for(int x = 0; x < (int)Adj[i][j].size(); x++)
            if(!Mark[Adj[i][j][x].F][Adj[i][j][x].S])
                  Dfs(Adj[i][j][x].F, Adj[i][j][x].S);
}
int main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n, m; cin >> n >> m;
      for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                  cin >> A[i][j];
            }
      }
      for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                  if(i > 1)
                        Add(i - 1, j, i, j);
                  if(j > 1)
                        Add(i, j - 1, i, j);
                  if(i < n)
                        Add(i + 1, j, i, j);
                  if(j < m)
                        Add(i, j + 1, i, j);
            }
      }
      long long Ans = 0;
      for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                  if(Mark[i][j])
                        continue;
                  bl = wh = 0;
                  Dfs(i, j);
                  Ans += 1ll * bl * wh;
            }
      }
      cout << Ans;
      return 0;
}



Measured memory_bytes: 24960
def counter(n):
    count = 0
    while n % 2 == 0:
        n /= 2
        count += 1
    return count

N = int(input())
A = (int(x) for x in input().split())#ここでAには入力された数がリストとして格納される
y = min(map(counter,A))
print(y)


Measured memory_bytes: 2940
using System;

namespace TEST
{
    class Program
    {
        private static void Main(string[] arg)
        {
            int x = int.Parse(Console.ReadLine());
            string[] y = Console.ReadLine().Split();
            ulong z = 1;
            for (int i = 0; i < x; i++)
            {
                if (ulong.Parse(y[i]) == 0)
                {
                    Console.WriteLine(0);
                    return;
                }
            }
            for (int i = 0; i < x; i++)
            {
                try
                {
                    checked
                    {
                        z *= ulong.Parse(y[i]);
                    }
                }
                catch(OverflowException ex)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            if (z > (ulong)Math.Pow(10, 18))
            {
                Console.WriteLine(-1);
                return;
            }
            Console.WriteLine(z);
            return;

        }

    }
}

Measured memory_bytes: 40892
ds = []
for i in range(5):
    ds.append(int(input()))
k = int(input())

cnt = 0
for i in range(5):
    for j in range(i + 1, 5):
        if abs(ds[i] - ds[j]) > k:
            cnt += 1
if cnt > 0:
    print(':(')
else:
    print("Yay!")


Measured memory_bytes: 3064
import sys
N = int(input())

if N == 1:
    print(1)
    sys.exit(0)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


P = prime_factorize(N)

ans = len(str(N))

for i in range(2 ** (len(P) - 1)):
    a = 1
    b = 1
    for j in range(len(P)):
        if (i >> j) & 1 == 1:
            a *= P[j]
        else:
            b *= P[j]

    ans = min(ans, max(len(str(a)), len(str(b))))

print(ans)


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

int main(){
        long long n, p, q, s = 0;
        cin >> n >> p >> q;
        vector<long long> c(n);
        vector<long long> v;
        for(long long i = 0; i < n; i++){
                cin >> c[i];
                s += c[i];
                v.push_back(p * i + c[i]);
        }
        long long ans = s;
        sort(v.begin(), v.end());
        for(long long i = 0; i < n - 1; i++) v[i + 1] += v[i];
        for(long long i = 0; i < n; i++) ans = max(ans, s + (i + 1) * p * q + p * i * (i + 1) - v[i]);
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 11008
#include <cstdio>

int main()
{
    int a, w =0, e = 0;
    int sum = __INT_MAX__;
    char arr[300050];
    int brr[300050];
    int crr[300050];
    scanf("%d", &a);
    scanf("%s", arr);
    for (int i=0; i<a; i++) {
        if (arr[i]=='W') {
            w++;
        }
        brr[i]=w;
    }
    for (int i=a; i>=0; i--) {
        if (arr[i]=='E') {
            e++;
        }
        crr[i]=e;
    }
    for (int i=0; i<a; i++) {
        if (sum > brr[i]+crr[i]) {
            sum = brr[i]+crr[i];
        }
    }
    printf("%d", sum-1);
}


Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int a, b, c, d, e, f;cin>>a>>b>>c>>d>>e>>f;
  vector<int> water, sugar;
  int na=0;
  while(na*a*100<=f){
    int nb=0;
    while(na*a*100+nb*b*100<=f){
      int num=na*a*100+nb*b*100;
      if(num!=0)water.push_back(num);
      nb++;
    }
    na++;
  }
  sort(water.begin(), water.end());
  water.erase(unique(water.begin(), water.end()), water.end());
  // for(int x: water)cout<<x<<" ";
  // cout<<endl;
  int nc=0;
  while(nc*c<=f*e/(100+e)){
    int nd=0;
    while(nc*c+nd*d<=f*e/(100+e)){
      int num=nc*c+nd*d;
      if(num!=0)sugar.push_back(num);
      nd++;
    }
    nc++;
  }
  sort(sugar.begin(), sugar.end());
  sugar.erase(unique(sugar.begin(), sugar.end()), sugar.end());
  // for(int x: sugar)cout<<x<<" ";
  // cout<<endl;
  int a1=a*100, a2=0;
  double conc=-1;
  for(int i=0;i<(int)water.size();i++){
    for(int j=0;j<(int)sugar.size();j++){
      int w=water[i], s=sugar[j];
      if(w+s<=f && w*e/100>=s && conc<(100*s)/double(w+s)){
        a1 = w+s;a2=s;
        conc=(100*s)/double(w+s);
      }
    }
  }
  cout<<a1<<" "<<a2<<endl;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0,v=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 25224
#!/usr/bin/env python3

n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

h = [t-i*0.006 for i in h]


diff = 10**6
index = 0
for i, j in enumerate(h):
    if diff > abs(j-a):
        diff = abs(j-a)
        index = i+1
print(index)


Measured memory_bytes: 9216
#[allow(dead_code)]
fn main() {
    let t = i::s();
    for c in t {
        print!("{}", if c == '?' { 'D' } else { c });
    }
    println!();
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }
    pub fn u() -> usize {
        read()
    }
    pub fn u2() -> (usize, usize) {
        (read(), read())
    }
    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }
    pub fn u4() -> (usize, usize, usize, usize) {
        (read(), read(), read(), read())
    }
    pub fn u5() -> (usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read())
    }
    pub fn u6() -> (usize, usize, usize, usize, usize, usize) {
        (read(), read(), read(), read(), read(), read())
    }
    pub fn f() -> f64 {
        read()
    }
    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }
    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }
    pub fn iv3(n: usize) -> Vec<(i64, i64, i64)> {
        (0..n).map(|_| iv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }
    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }
    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }
    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }
    pub fn uv4(n: usize) -> Vec<(usize, usize, usize, usize)> {
        (0..n)
            .map(|_| uv(4))
            .map(|a| (a[0], a[1], a[2], a[3]))
            .collect()
    }
    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }
    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 3132
#include <stdio.h>
int N, X, Y, W, H, Q, C, A, B;
int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d%d%d%d%d", &X, &Y, &W, &H, &Q); C = 0;
		for (int i = 0; i < Q; i++) {
			scanf("%d%d", &A, &B);
			if (X <= A && A <= X + W && Y <= B && B <= Y + H) {
				C++;
			}
		}
		printf("%d\n", C);
	}
	return 0;
}

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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  int A[Q];
  vector<int>count(N);
  rep(i, Q){
    cin >> A[i];
    count[A[i]-1]++;
  }
  rep(i,N){
    if(count[i] >= Q-K+1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  string S;
  cin>>S;
  int N=S.length();
  int ans=0;
  for(int i=0;i<N;i++){
    int tmp=0;
    for(int j=i;j<N;j++){
      if(S[j]=='A' || S[j]=='T' || S[j]=='G' || S[j]=='C'){
        tmp++;
      }else{
        break;
      }
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[2][300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;
queue<ll> ql;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}


bool itta[300000];

int main() {
	
	cin >> S;

	SS += 'A' + (S[0] - 'a');

	cin >> S;

	SS += 'A' + (S[0] - 'a');

	cin >> S;

	SS += 'A' + (S[0] - 'a');


	cout << SS << endl;

	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;



}


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

using namespace std;

int swap_count = 0; // number of swaps

void insertion_sort(vector<int> &sort_vec, int n, int interval) {
  for (int i = interval; i < n; ++i) {
    int pivot = sort_vec[i];
    int j = i - interval;
    while (j >= 0 && sort_vec[j] > pivot) { //
      sort_vec[j + interval] = sort_vec[j]; // perform swap
      j = j - interval; // drop by interval
      swap_count++;
    }
    sort_vec[j + interval] = pivot; // put pivot in proper place
  }
}

int main() {
  int n; //number of entries
  cin >> n;

  vector<int> sort_vec;
  //initialize unsorted vector
  for (int i = 0; i < n; ++i) {
    int entry;
    cin >> entry;
    sort_vec.push_back(entry);
  }
  
  vector<int> intervals;
  //initialize array according to formula k_next = 3*k_prev + 1 (Knuth)
  int next = 1;
  while (true) {
    intervals.push_back(next);
    next = next * 3 + 1;
    if (next >= n) break;
  }

  int intervals_size = intervals.size();
  //shell sort
  for (int i = intervals_size - 1; i >= 0; --i) {
    insertion_sort(sort_vec, n, intervals[i]);
  }

  //print results
  cout << intervals_size << endl; // number of intervals
  for (int i = intervals_size - 1; i >= 0; --i) {
    cout << intervals[i];
    if (i <= n - 1) cout << " ";
  }
  cout << endl;
  cout << swap_count << endl; // number of swaps
  for (int i = 0; i < n; ++i) { // sorted vector
    cout << sort_vec[i] << endl;
  }
  
}
    
  
  
  
  
  

Measured memory_bytes: 7256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n,m,x;
  cin >> n >> m >> x;
  
  int hi = 0;
  int mi = 0;
  
  vector<int> p(n);
  rep(i,m) {
  cin >> p[i];
    if(p[i]<x)hi++;
    if(p[i]>x)mi++;  
  }
  
  cout << min(hi,mi) << endl;
  
}

Measured memory_bytes: 256
import math

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

h = x[0]
w = x[1]

if (h == 1 or w == 1):
    count = 1
else:
    count = math.ceil(h/2) * math.ceil(w/2) + math.floor(h/2) * math.floor(w/2)

'''
for i in range(h):
    if i % 2 == 0:
        count += math.ceil(w/2)
    else:
        count += math.floor(w/2)
'''

print(count)



Measured memory_bytes: 62116
from itertools import accumulate
N = int(input())
As = list(map(int, input().split()))

accR = reversed(list(accumulate(reversed(As))))
num = 1
MAX = 10 ** 13
ans = 0
for a, limit in zip(As, accR):
    tmp = min(num, limit)
    if a > tmp:
        print(-1)
        exit()
    ans += tmp
    num = (tmp - a) * 2
    if num >= MAX:
        num = MAX
print(ans)


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

const int nmax=400010;
bool ok[nmax];
int mov[nmax][26],num[nmax],nxt=1;

string s[100010];
int cnt[100010][26][26];
int offset[100010];

int main(void){
	int n,q;
	cin >> n;
	clr(mov,-1);

	rep(i,n){
		cin >> s[i];		
		int cur=0;
		for(auto &c:s[i]){
			if(mov[cur][c-'a']==-1) mov[cur][c-'a']=nxt++;
			cur=mov[cur][c-'a'];
		}
		ok[cur]=true,num[cur]++;
	}

	rrep(i,nxt)rep(j,26) if(mov[i][j]!=-1) num[i]+=num[mov[i][j]];
	
	rep(i,n){
		int cur=0;
		for(auto &c:s[i]){
			rep(j,26) cnt[i][c-'a'][j]+=num[mov[cur][j]];
			offset[i]+=ok[cur];
			cur=mov[cur][c-'a'];
		}
	}

	cin >> q;
	 

	rep(loop,q){
		int tar;
		cin >> tar;
		tar--;
		string order;
		cin >> order;

		int ans=offset[tar]+1;
		rep(j,26){
			rep(k,26){
				int cur=order[k]-'a';
				if(cur==j) break;
				ans+=cnt[tar][j][cur];
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 312444