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

using namespace std;

const int maxn = 2e6 + 10;
const int MOD = 998244353;

int f[maxn], inv[maxn];

int power(int n, int k) {
    int e = 1;
    while (k) {
        if (k & 1) e = 1ll * e * n % MOD;
        n = 1ll * n * n % MOD; k >>= 1;
    }
    return e;
}

int C(int n, int k) {
    return 1ll * f[n] * inv[k] % MOD * inv[n - k] % MOD;
}

int calc(int n, int x, int y) {
    y = min(n, y);
    long long answer = 0;
    for (int i = x % 2; i <= min({n, x, y}); i += 2) {
        int a = (x - i) / 2 + n - 1;
        //cerr << a << " " << x << " " << n - 1 << "\n";
        answer += 1ll * C((x - i) / 2 + n - 1, n - 1) * C(n, i) % MOD;
        answer %= MOD;
    }
    return answer;
}

int main() {
    // initialize factor
    f[0] = 1;
    for (int i = 1; i < maxn; ++i) f[i] = 1ll * f[i - 1] * i % MOD;
    inv[maxn - 1] = power(f[maxn - 1], MOD - 2);
    for (int i = maxn - 2; i >= 0; --i) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;

    // process
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    int n, m;   cin >> n >> m;
    int x = calc(n, 3 * m, m);
    int y = calc(n, m, m);
    int z = calc(n - 1, m, m);
    int answer = (x - 1ll * (y - z) * n % MOD + MOD) % MOD;
    cout << answer << "\n";
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;

int n,m,ar[maxn];
bool vis[maxn];
int ans[maxn];
int main()
{
    char ch[2];
    scanf("%s",ch);
    char c;
    if(ch[0]=='A')c='T';
    if(ch[0]=='T')c='A';
    if(ch[0]=='C')c='G';
    if(ch[0]=='G')c='C';
    printf("%c\n",c);

    return 0;
}


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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<lli, lli> pii;


int main()
{
    map<int, int> evcnt, odcnt;
    evcnt[0] = 0;
    odcnt[0] = 0;
    int n;
    cin >> n;
    int a[n];
    for(auto &x: a) cin >> x;

    for(int i=0; i<n; i+=2){
        evcnt[a[i]]++;
    }
    for(int i=1; i<n; i+=2){
        odcnt[a[i]]++;
    }

    vector<pi> odc, evc;

    for(auto x: evcnt){
        evc.push_back({x.second, x.first});
    }

    for(auto x: odcnt){
        odc.push_back({x.second, x.first});
    }

    sort(odc.begin(), odc.end(), greater<pi>());
    sort(evc.begin(), evc.end(), greater<pi>());

    int x = odc[0].second;
    int y = evc[0].second;
    if(x != y){
        cout << n - (odc[0].first+evc[0].first) << "\n";
        return 0;
    }

    int ca = odc[0].first;
    int cb = evc[0].first;
    if(ca == cb){
        int mx = max(odc[1].first, evc[1].first);
        cout << n - (ca+mx) << "\n";
    }
    else if(ca > cb){
        cout << n - (odc[0].first+evc[1].first) << "\n";
    }
    else{
        cout << n - (odc[1].first+evc[0].first) << "\n";
    }

    return 0;
}


Measured memory_bytes: 6520
#include <stdio.h>

int main(void)
{
  int i, s, d, x;

  while(scanf("%d",&d)!=EOF)
    {
      s=0;

      for(x=0;x<600;x+=d)
        s+=x*x*d;

      printf("%d\n",s);
    }

  return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);
  int V[N], C[N];
  int i;
  for(i=0; i<N; i++)
    scanf("%d", &V[i]);
  for(i=0; i<N; i++)
    scanf("%d", &C[i]);

  int sub[N];
  for(i=0; i<N; i++)
    sub[i] = V[i] - C[i];

  int sum = 0;
  for(i=0; i<N; i++)
    if(sub[i]>0)
      sum += sub[i];

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

  return 0;
}


Measured memory_bytes: 128
// AOJ 1089: Strawberry Cake
// 2017.12.18 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <math.h>

#define N 500
#define D 0.01
#define EPS 1e-8

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } LINE;

PP a[21]; int n;

int dcmp(double x)
{
	if (fabs(x) < EPS) return 0;
	return x < 0 ? -1 : 1;
}

double cross(double ax, double ay, double bx, double by) { return ax*by - ay*bx; }

void lineIntersection(PP *p, LINE *a, PP *vs, PP *ve)
{
    double a1, a2;

	a1 = cross(ve->x  - vs->x, ve->y  - vs->y,
			   a->s.x - vs->x, a->s.y - vs->y);
	a2 = cross(ve->x  - vs->x, ve->y  - vs->y,
			   a->e.x - vs->x, a->e.y - vs->y);
	p->x = (a->s.x*a2 - a->e.x*a1) / (a2-a1);
	p->y = (a->s.y*a2 - a->e.y*a1) / (a2-a1);
}

int convex_cut(LINE *u, int n, PP *p, PP *po)
{
	int i, d1, d2, top = 0;

    for (i = 0; i < n; i++) {
        d1 = dcmp(cross(u->e.x - u->s.x, u->e.y - u->s.y,
						p[i].x - u->s.x, p[i].y - u->s.y));
        d2 = dcmp(cross(u->e.x - u->s.x, u->e.y - u->s.y,
				      p[i+1].x - u->s.x, p[i+1].y - u->s.y));
        if (d1 >= 0) po[top++] = p[i];
        if (d1*d2 < 0) lineIntersection(po + top++, u, p+i, p+i+1);
    }
	po[top] = po[0];
#if 0
printf("convex_cut %d\n", top);
for (i = 0; i < top; i++) printf("[%d] (%lf,%lf)\n", i+1, po[i].x, po[i].y);
#endif
	return top;
}

#if 0
double area(int n, PP *p)
{
	int i;
    double s = 0;

    for (i = 1; i < n-1; i++) {
        s += cross(p[i].x-p[0].x, p[i].y-p[0].y, p[i+1].x-p[0].x, p[i+1].y-p[0].y);
    }
    return fabs(s) / 2;
}
#endif

double area(int n, PP *pp)
{
   int i;
   double s;

   for (s = 0, i = 0; i < n; i++) {
      s += (pp[i].x - pp[i+1].x) * (pp[i].y + pp[i+1].y);
   }
   return fabs(s)/2;
}

double calc(double x, double s)
{
	int k;
	PP b[30];

	LINE u;
	u.s.x = u.s.y = 0;
	u.e.x = 128*cos(x), u.e.y = 128*sin(x);
	k = convex_cut(&u, n, a, b);
	return area(k, b) / s;
}

int main()
{
	int i, x, y;
	double s, s1, s2, l, r, m;

	while(scanf("%d", &n) && n > 0) {
		for (i = 0; i < n; i++) {
			scanf("%d%d", &x, &y);
			a[i].x = x, a[i].y = y;
		}
		a[n] = a[0];
		s = area(n, a);

		l = 0, r = D, s1 = calc(0, s);
		for ( ; ; l+=D, r+=D, s1 = s2) {
			s2 = calc(r, s);
			if (s1 <= 0.5 && s2 >= 0.5) {
				i = N; while (i--) {
					m = (l+r)/2;
					if (calc(m, s) <= 0.5) l = m; else r = m;
				}
				break;
			}
		}
		printf("%.15lf %.15lf\n", 128*cos(m), 128*sin(m));
	}
	return 0;
}

Measured memory_bytes: 2128
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
long long MAX(long long a,long long b){
    return a>b?a:b;
}
int main()
{   long long n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    long long k=n/(a+b);
    if(n%(a+b)==0){
        printf("%lld",k*a);
        return 0;
    }else{
        long long d;
        if(n-(k*(a+b))>=a){
            d=a;
        }else{
            d=n-(k*(a+b));
        }
        printf("%lld",k*a+d);
    }
    
    
    return 0;
}


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

int main() {
    int N, X;
    cin >> N >> X;
    int m[1000];
    for(int i = 0; i < N ; i++) {
        cin >> m[i];
    }
    int sum = 0;
    int min = 1001;
    for(int i = 0; i < N; i++) {
        sum += m[i];
        if(min > m[i]) {
            min = m[i];
        }
    }
    X -= sum;
    int result = N + X/min;
    cout << result << endl;
    return 0;
}

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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N % 500 == 0 || A - N % 500 >= 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main() {
  int n;
  cin>>n;  
  vector<int>t(3*n);
  long ans=0;
  rep(i,3*n){
    cin>>t.at(i);
  }
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  rep(i,n){
    ans+=t.at(2*i+1);
  }
    
  cout<<ans<<endl;
  
}

Measured memory_bytes: 1408
a,b,c=map(int,input().split())
k=int(input())

token=0
for i in range(k+1):
    c_c=c*(2**i)
    for j in range(k-i+1):
        b_c=b*(2**j)
        if a<b_c and b_c < c_c:
            token=1

if token : print("Yes")
else : print("No")

Measured memory_bytes: 9192
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############

A,B = inputIL()

if A==B:
  print("Draw")
elif A==1:
  print("Alice")
elif B==1:
  print("Bob")
elif A>B:
  print("Alice")
else:
  print("Bob")

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

int main(){
    string A;
    cin >> A;
    if (A.at(0) != A.at(1) && A.at(1) !=A.at(2) && A.at(0) != A.at(2)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
    int n;
  cin >> n;
  
  rr(i, n)
    cout << "ACL";
  cout << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}   

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

int main()
{
    string Sentence;

    string Alphabet = "abcdefghijklmnopqrstuvwxyz";
    string CapAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    getline(cin,Sentence);

    int SentenceLength = Sentence.length();

    for(int x = 0; x < SentenceLength; x++)
    {
        for(int y = 0; y < 26; y++)
        {
            if(Sentence[x] == Alphabet[y])
            {
                Sentence[x] = CapAlphabet[y];
            }
        }
    }

    cout << Sentence << endl;




}

Measured memory_bytes: 2996
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    
    ll n,k;
    string s;
    cin>>n>>k>>s;
    ll ans=0;
    rep(i,n-1){
        if(s[i]!=s[i+1]) ans++;
    }
    ans=n-1-ans;
    cout<<min(n-1,ans+k*2)<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
    int a,b,c,d,e,i,j;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    for(i=0;;i++){
        if(b<1&&c<1){
            printf("%d\n",a);
            break;
        }
        a--;
        b=b-d;
        c=c-e;
    }
return 0;
}

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

using namespace std;

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

    for (int i = 0; i < S.size() - 1; ++i) {
        if (S.substr(i, 2) == "AC") {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
A = gets.chomp.to_i
B = gets.chomp.to_i
C = gets.chomp.to_i
X = gets.chomp.to_i

count = 0

for a in 0..A
  for b in 0..B
    c = (X - 500*a - 100*b) / 50
    if c >= 0 && c <= C
      count += 1
    end
  end
end

p count


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
using namespace std;
using uint = unsigned int;

int main() {

	uint X;
	cin >> X;
	
	vector<bool> dp(X+1, false);
	dp[0] = true;

	uint price[6] = {100, 101, 102, 103, 104, 105};
	
	for(uint i=0; i<=X; i++) {
		for(uint p=0; p<6; p++) {
			if(price[p] <= i && dp[i-price[p]]) {
				dp[i] = true;
				break;
			}	
		}
	}
	
	if(dp.back()) {
		cout << 1;
	} else {
		cout << 0;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll a,b,c,k;
  cin>>a>>b>>c>>k;

  rep(i,k){
    if(max(max(a,b),c)==a)a*=2;
    if(max(max(a,b),c)==b)b*=2;
    if(max(max(a,b),c)==c)c*=2;
  }

  cout<<a+b+c<<endl;
  return 0;
}


Measured memory_bytes: 3568
import java.util.*

fun main(args: Array<String>) = abc160d()

fun abc160d() {
    val (n, x, y) = readLine()!!.split(' ').map { it.toInt() }

    val graph = Array(n) {
        Vertex(
            it, (mutableSetOf<Int>() + (if (it != 0) setOf(it - 1) else setOf())
                    + if (it != n - 1) setOf(it + 1) else setOf()).toMutableSet()
        )
    }
    graph[x - 1].neighbor.add(y - 1)
    graph[y - 1].neighbor.add(x - 1)
    val count = IntArray(n)

    fun bfs(fromIndex: Int) {
        val queue = ArrayDeque(listOf(fromIndex to 0))
        val visited = mutableSetOf<Int>()

        while (queue.isNotEmpty()) {
            val (index, dist) = queue.poll()
            if (!visited.add(index)) continue

            count[dist]++
            graph[index].neighbor.filterNot { visited.contains(it) }
                .map { it to dist + 1 }.let { queue.addAll(it) }
        }
    }

    for (i in 0 until n) bfs(i)

    val answer = count.drop(1).map { it / 2 }.joinToString(System.lineSeparator())

    println(answer)
}

private data class Vertex(val index: Int, val neighbor: MutableSet<Int> = mutableSetOf())


Measured memory_bytes: 123708
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    for(int i=0; i<s.size(); i++){
        for(int j=i+1; j<s.size(); j++){
            if(s.at(i)==s.at(j)){
                cout << "no" << endl;
                return 0;
            }
        }
    }

    cout << "yes" << endl;


    return 0;
}


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

int N, A[20], x[20][20], y[20][20];

int counter(int x) {
	return x == 0 ? 0 : counter(x >> 1) + (x & 1);
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		for (int j = 1; j <= A[i]; j++) {
			cin >> x[i][j] >> y[i][j];
		}
	}

	int ans = 0;
	for (int bit = 1; bit < (1 << N); bit++) {
		bool ok = true;
		for (int i = 1; i <= N; i++) {
			if (!(bit & (1 << i - 1)))continue;
			for (int j = 1; j <= A[i]; j++) {
				if ((bit >> (x[i][j] - 1) & 1) ^ y[i][j])ok = false;
			}
		}
		if (ok)if (ans < counter(bit))ans = counter(bit);
	}
	cout << ans << endl;

	return 0;
}

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

#define INF 100010001
int main()
{
	int i,j;
	int N, M, X;
	int *C;
	int **A;
	long *sum;
	int nall;
	int s;
	long ans, cost;
	int ok;
	
	scanf("%d %d %d", &N, &M, &X);
	C = (int *)malloc(sizeof(int)*N);
	sum  = (long *)malloc(sizeof(long)*M);
	A = (int **)malloc(sizeof(int*)*N);
	for (i =0; i< N; i++) {
		A[i] = (int *)malloc(sizeof(int)*M);
	}
	for (i =0; i < N; i++) {
		scanf(" %d", &C[i]);
		for (j = 0; j < M; j++) {
			scanf(" %d", &A[i][j]);
		}
	}

	nall = 1 << N;
	ans = INF;
	/* 全探索 */
	for (s = 0; s < nall; s++) {
		cost = 0;
		ok = 1;
		for (j = 0; j < M; j++) {
			sum[j] = 0;
		}
		/* このセットでの合計金額costと スキルup sum[j] */
		for (i = 0; i < N; i++) {
			/* このセットがこの本iを含む時*/
			if (s>>i&1) {
				cost += C[i];
				for (j = 0; j < M; j++) {
					sum[j] += A[i][j];
				}
			}
		}
		for (j = 0; j < M; j++) {
			if (sum[j] < X) {
				ok = 0;
				break;
			}
		}
		if (ok) {
			ans = (ans > cost)?cost:ans;
		}
	}
	if (ans == INF) {
		printf("-1\n");
	} else {
		printf("%ld\n", ans);
	}

	free(C);
	for (i = 0; i < N; i++) {
		free(A[i]);
	}
	free(A);

	return EXIT_SUCCESS;
}


Measured memory_bytes: 1708
def cal():
    s = input()
    num, ans = len(s)-1, 0
    for i in range(2**num):
        count0, count1 = 0, 0
        for j in range(num):
            count1 += 1
            if (i>>j)&1:
                ans += int(s[count0:count1])
                count0 = count1
        ans += int(s[count0:count1+1])
    print(ans)
cal()



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    char b;
    cin >> b;

    if (b == 'A') {
        cout << 'T' << endl;
    } else if (b == 'T') {
        cout << 'A' << endl;
    } else if (b == 'G') {
        cout << 'C' << endl;
    } else if (b == 'C') {
        cout << 'G' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#一日ごとにSunny・Cloudy・rainy
#今日の天気S。明日の天気予想

#S＝Sunny.Cloudy.Rainy

S=input('')
print()

if S =="Sunny":
    print('Cloudy')
elif S =="Cloudy":
    print('Rainy')
elif S =="Rainy":
    print('Sunny')


Measured memory_bytes: 8872
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


def main():
    N,K = map(int, input().split())
    mod = 10**9+7
    fac = [1]*(N+1)
    rev = [1]*(N+1)
    
    for i in range(1,N+1):
        fac[i] = i*fac[i-1]%mod
        rev[i] = pow(fac[i], mod-2, mod)
    
    comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%mod
    for i in range(1, K+1):
        if i >N-K+1:
            print(0)
            continue
        print(comb(N-K+1, i)*comb(K-1, i-1)%mod)


if __name__ == "__main__":
    main()


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 2e5 + 10;

int n, k;
int ar[N];
ll t;

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

    cin >> n >> k;
    for (int i=0;i<n;i++){
        cin >> ar[i];
    }
    if (k>=n){
        cout << 0 << el;
        return 0;
    }

    sort(ar, ar + n, greater<int>());
    for (int i=k;i<n;i++){
        t+=(ll)ar[i];
    }
    cout << t << el;

    return 0;
}

Measured memory_bytes: 1024
n =int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    ans += min(a[i], b[i])
    ans += min(a[i+1], b[i] - min(a[i],b[i]))
    a[i+1] -= min(a[i+1], b[i] - min(a[i],b[i]))

print(ans)

Measured memory_bytes: 18624
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <string>
typedef long long ll;
using namespace std;
const int maxn=1e6+5;
int vis[maxn];
int main()
{
    ll n;
    while(~scanf("%lld",&n))
    {
        ll ans=0;
        memset(vis,0,sizeof(vis));
        vis[n]++;
        while(1)
        {
            if(n%2) n=3*n+1;
            else n/=2;
            if(vis[n])
            {
                ans++;
                break;
            }
            else
            {
                vis[n]++;
                ans++;
            }
        }
        printf("%lld\n",ans+1);
    }
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 nn, ll;
	cin >> nn >> ll;
	int64 sum = 0;
	for(int64 ii = 0;ii < nn;ii++)
	{
		int64 tmp = ll + ii;
		sum += tmp;
	}
	if(ll + nn - 1 < 0)
	{
		sum -= (ll + nn - 1);
	}
	else if(ll > 0)
	{
		sum -= ll;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3500
# -*- coding: utf-8 -*-

def main():
    import itertools
    nums = [int(c) for c in input()]
    ops = itertools.product(["+","-"], repeat=3)
    for op in ops:
        s = "{}{}{}{}{}{}{}".format(nums[0], op[0],
                                    nums[1], op[1],
                                    nums[2], op[2],
                                    nums[3])
        if eval(s) == 7:
            print(s + "=7")
            exit()


if __name__ == '__main__':
    main()


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

int maximumChars(string& str)
{
    int n = str.length();

    int ct=0,res=0;

    for(int i=0;i<n;++i)
    {
    	if(str[i]=='R')
    	{
    	ct++;
    	res=max(res,ct);
        }
    	else
    	{
    		ct=0;
		}
	}
	return res;
}

// Driver code
int main()
{
    string str;
    cin>>str;
    cout << maximumChars(str);
    return 0;
}

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

int a[100],b[100], c[100], d[100], ans[100], mini[100];
int main(void){
 int n, m; cin >> n >> m;
 for(int i=0;i<n;i++) cin >> a[i] >> b[i];
 for(int i=0;i<m;i++) cin >> c[i] >> d[i];
 for(int i=0;i<n;i++){
  mini[i] = INT_MAX;
 for(int j=0;j<m;j++){
  if (abs(a[i]-c[j])+abs(b[i]-d[j])<mini[i]) {ans[i] = j+1; mini[i] = abs(a[i]-c[j])+abs(b[i]-d[j]);}
  }
  cout << ans[i] << endl;
 }
 return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int num1=Integer.parseInt(S.substring(0,2));
        int num2=Integer.parseInt(S.substring(2));

        if(1<=num1 && num1<=12  && 1<=num2 && num2<=12){
            System.out.println("AMBIGUOUS");
        }else if(1<=num1 && num1<=12 ){
            System.out.println("MMYY");
        }else if(1<=num2 && num2<=12 ){
            System.out.println("YYMM");
        }else{
            System.out.println("NA");
        }


    }
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int n, ans;

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		int cnt = 0, t = i;
		for (; t; t /= 10) ++cnt;
		if (cnt & 1) ++ans;
	}
	write(ans);
	putchar('\n');
	return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var ws = Extend(n, "", 'a');

        Console.WriteLine(string.Join(Environment.NewLine, ws));
    }

    static IEnumerable<string> Extend(int n, string prefix, char unused)
    {
        if (--n < 0)
        {
            return new [] { prefix };
        }

        var xs = E.Empty<string>();
        for (int i = 0; i < unused - 'a'; ++i)
        {
            xs = E.Concat(xs, Extend(n, prefix + (char)('a' + i), unused));
        }
        xs = E.Concat(xs, Extend(n, prefix + unused, ++unused));

        return xs;
    }
}


Measured memory_bytes: 47208
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


main()
{
  int N, Q;

  while( cin >> N >> Q, !(N == 0 && Q == 0) ) {
    
    int cnt[101] = {0};
    Rep(i, N) {
      int M;
      cin >> M;
      
      Rep(j, M) {
	int a;
	cin >> a;
	cnt[a]++;
      }
    }
    
    int ma = 0, id = 0;
    Rep(i, 101) {
      if( cnt[i] > ma && cnt[i] >= Q ) { ma = cnt[i]; id = i; }
    }

    cout << id << endl;
  }
  
}
  

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>

int main()
{
    std::string S;

    std::cin >> S;
    int max_len = 0;

    int cur_len = 0;
    for (auto s : S) {
        if (s == 'A' || s == 'C' || s == 'G' || s == 'T') {
            ++cur_len;
            max_len = std::max(max_len, cur_len);
        } else {
            cur_len = 0;
        }
    }

    std::cout << max_len << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		rep(i,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};

template<class T=ll>struct BellmanFord:Graph<T>{
	using Graph<T>::Graph;
	BellmanFord(int N=1):Graph<T>::Graph(N){}
	const T mval=numeric_limits<T>::max()/2;
	vector<T>dist(ll s){
		vector<T> ret(this->n,mval);
		ret[s]=0;
		rep(i,2*this->n){
			rep(f,this->n)for(auto&e:this->edge[f]){
				ll t; T c; tie(t,c)=e;
				if(ret[f]!=mval && chmin(ret[t],ret[f]+c) && i+1>=this->n){
					ret[t]=-mval;
				}
			}
		}
		return ret;
	}
	T dist(ll s,ll t){return dist(s)[t];}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int v,e,r;
	ll s,t,d;
	cin>>v>>e>>r;
	BellmanFord<> g(v);
	rep(i,e){
		cin>>s>>t>>d;
		g.add(s,t,d,true);
	}
	vl ans=g.dist(r);
	bool ng=false;
	rep(i,v)ng|=(ans[i]==-g.mval);
	if(ng)cout<<"NEGATIVE CYCLE"<<endl;
	else{
		rep(i,v)cout<<(ans[i]==g.mval?"INF":to_string(ans[i]))<<"\n";
	}

}


Measured memory_bytes: 3324
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	int count = 0;
	sort(A.begin(), A.end());
	for (int i = 0; i < N-1; i++) {
		if (A.at(i) == A.at(i + 1)) {
			cout << "NO" << endl;
			count++;
			break;
		}
	}
	if (count == 0) {
		cout << "YES" << endl;
	}
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;

  int ans = 0;

  if(a>b){
      ans += a;
      a--;
  }
  else{
      ans += b;
      b--;
  }

  if(a>b){
      ans += a;
      a--;
  }
  else{
      ans += b;
      b--;
  }

  cout << ans << endl;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}


int main() {
int N;
cin>>N;
bool ok = true;
for(int i=0;i<N;i++) {
    int x;
    cin>>x;
    if(x%2==0) {
        if(x%3!=0 and x%5!=0) ok = false;
    }
}
cout<<(ok ? "APPROVED" : "DENIED")<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  string s;
  cin >> s;
  int w;
  cin >> w;
  for(int i=0; i < s.length(); i+=w){
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
    ll i,j;
    ll l,r;
    cin>>l>>r;
    vector<ll> v(2019,0);
    if(r-l>2025) cout<<0<<endl;
    
    else {
      ll ans=20000;
      for(i=l;i<=r;i++){
        v[i%2019]++;
      }
      for(i=0;i<2019;i++){
        for(j=0;j<2019;j++){
          if(i!=j) {
            if(v[i]>0&&v[j]>0) ans=min(ans,(i*j)%2019);
          }
          else {
            if(v[i]>1) ans=ans=min(ans,(i*j)%2019);
          }
        }
      }
      cout<<ans<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcnt(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 1000005

int n, k, a[maxn];

int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> k;
	int Max = 0;
	int ret = 0;
	For(i, 1, n){
		cin >> a[i];
		ret = gcd(ret, a[i]);
		Max = max(Max, a[i]);
	}

	if(k <= Max && k % ret == 0){
		cout << "POSSIBLE" << endl;
	} else cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int f(int a, int n)
{
	if (n < 0 || a < 0)
		return 0;
	int d[1003][10];
	int i, j;
	for (i = 0; i <= n; i++)
		for (j = 0; j < 10; j++)
			d[i][j] = 0;
	d[0][a] = 1;
	for (i = 0; i < n; i++)
	{
		d[i + 1][0] += d[i][0];
		d[i + 1][1] += d[i][0];
		for (j = 1; j < 9; j++)
		{
			d[i + 1][j - 1] += d[i][j];
			d[i + 1][j] += d[i][j];
			d[i + 1][j + 1] += d[i][j];
		}
		d[i + 1][8] += d[i][9];
		d[i + 1][9] += d[i][9];
	}
	int res = 0;
	for (i = 0; i < 10; i++)
		res += d[n][i];
	return res;
}
int main()
{
	int k;
	scanf("%d", &k);
	int n, a;
	a = 1;
	n = 0;
	while (f(a, n) < k)
	{
		k -= f(a, n);
		a++;
		if (a == 10)
		{
			a = 1;
			n++;
		}
	}
	printf("%d", a);
	int b = a;
	n--;
	while (n >= 0)
	{
		a = b - 1;
		b--;
		while (f(a, n) < k)
		{
			k -= f(a, n);
			a++;
			b = a;
		}
		printf("%d", a);
		n--;
	}
	printf("\n");
	return 0;
}

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

tmp=0
if sum(A)>=sum(B):
    D=[A[i]-B[i] for i in range(N)]
    D.sort(reverse=True)
    t_ind = [i for i, d in enumerate(D) if d<0]
    if len(t_ind)!=0:
        t_sum=sum([D[t] for t in t_ind])
        for i in range(len(D)-len(t_ind)):
            tmp+=D[i]
            if tmp>=-t_sum:
                print((i+1)+len(t_ind))
                break
    else:
        print(0)
else:
    print(-1)

Measured memory_bytes: 18524
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define int long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1e15
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back

using namespace std;


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




int32_t main()
{
	std::ios::sync_with_stdio(false);

#ifndef ONLINE_JUDGE
	freopen("inputf.txt", "r", stdin);
	freopen("outputf.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	string s;
	cin >> s;
	int l = 0, r = n - 1;

	int cnt = 0;
	while (l < r)
	{
		if (s[r] == 'R' && s[l] == 'W')
		{
			cnt++;
			l++;
			r--;
		}
		else if (s[l] == 'R')
		{
			l++;
		}
		else
			r--;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3776
def main():
    n = int(input())
    s = [input() for i in range(n)]

    AB = 0
    B_ = 0
    _A = 0
    B_A = 0
    for ss in s:
        for i in range(len(ss)-1):
            if ss[i:i+2] == 'AB':
                AB += 1
        if ss[0] == 'B':
            if ss[-1] == 'A':
                B_A += 1
            else:
                B_ += 1
        elif ss[-1] == 'A':
            _A += 1
    if B_A > 0:
        if _A > 0 and B_ > 0:
            print(AB + (B_A - 1) + 2 + min(_A - 1, B_ - 1))
        elif _A == 0 and B_ == 0:
            print(AB + (B_A - 1))
        else:
            print(AB + (B_A - 1) + 1)
    else:
        print(AB + min(_A, B_))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include<iostream>
using namespace std;
int main() {
	int M, D, D1, D10;
	int count = 0;
	cin >> M >> D;
	D1 = D % 10;
	D10 = (D - D1) / 10;
    
	for (int m = 1; m <= M; m++) {
		for (int d10 = 2; d10 <D10; d10++) {
			for (int d1 = 2; d1 <= 9; d1++) {
				if (m == d10 * d1)count++;
			}
		}
		if (D1 > 1) {
			for (int d1 = 2; d1 <= D1; d1++) {
				if (m == D10 * d1)count++;
//				if (m == D10 * d1)printf("%d月%d%d日\n", m, D10, d1);
			}
		}
	}

	printf("%d", count);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long s,c,a;
  cin >> s >> c;
  if(c >= s*2) {
    a += s;
    c -= s*2;
    c /= 4;
    a += c;
  } else {
    c /= 2;
    a += c;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
from heapq import heapify, heappush, heappop

N = int(input())
v = list(map(int,input().split(" ")))
heapify(v)

while len(v) != 1:
    tmp_a = heappop(v)
    tmp_b = heappop(v)
    heappush(v,(tmp_a+tmp_b)/2)

print(v[0])



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
	ll n,k;
	cin >> n >> k;
  ll ans= 0;
  
  // 200000 200001
  // (200001)*(2*200000-200001+1)/2
  // 200001*200000


  for (ll i = k; i < n+2; i++)
  {
    // cout << temp << endl;
    ll largest = (i)*(2*n-i+1)/2;
    // cout << largest << endl;
    ll smallest = (i)*(i-1)/2;
    ans+=largest-smallest+1;
  }
  cout << ans%1000000007;
}

Measured memory_bytes: 3596
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210000;

int n,c,k,ans;
int a[maxn];
int q[maxn],head,tail;

int main()
{
	scanf("%d%d%d",&n,&c,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1); head=1,tail=0;
	for(int i=1;i<=n;i++)
	{
		if(head<=tail&&tail-head+1>=c) ans++,head=tail+1;
		if(head<=tail&&a[i]-q[head]>k) ans++,head=tail+1;
		q[++tail]=a[i];
	}
	if(head<=tail) ans++;
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 1024
while True:
    n = int(input())
    if n == 0:
        break
    
    L =[]
    for _ in range(n):
        id, h, w = [int(x) for x in input().split()]
        bmi = abs(w * 10000 / h**2 -22.0)
        L.append([bmi,id])
    L.sort()
    print(L[0][1])


Measured memory_bytes: 5748
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


n = int(input())
a = list(map(int, input().split()))
box = [0 for _ in range(n)]
sum_box = [0 for _ in range(n)]
for i in range(n)[::-1]:
    if a[i] == 1 and sum_box[i] % 2 == 0:
        for k in make_divisors(i+1):
            sum_box[k-1] += 1
        box[i] = 1
    elif a[i] == 1 and sum_box[i] % 2 != 0:
        box[i] = 0
    elif a[i] != 1 and sum_box[i] % 2 != 0:
        for k in make_divisors(i+1):
            sum_box[k-1] += 1
        box[i] = 1
    elif a[i] != 1 and sum_box[i] % 2 == 0:
        box[i] = 0
ans = []
for i, b in enumerate(box):
    if b == 1:
        ans.append(str(i+1))
if not ans:
    print(0)
else:
    s = ' '.join(ans)
    print(len(ans))
    print(s)


Measured memory_bytes: 75240
s = input()

hi = True
for i in range(len(s)):
  if i % 2 == 0 and s[i] != "h":
    hi = False
    break
  elif i % 2 == 1 and s[i] != "i":
    hi = False
    break
    
if len(s) % 2 != 0:
  hi = False
  
if hi:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



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; }


using Graph = vector<vector<int>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n


double culc(double a,double b, double x){
    return floor(a*x/b) - a*floor(x/b);
}

void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    double a,b;
    int n;
    cin >> a >> b >> n;
    
    int ans = -1;
    int limit =((b>n)?n:b);
    for (int i = ((limit-10000<0)?1:limit-10000); i <= limit; i++) {
        //cout << culc(a, b, i) << endl;
        ans = ((culc(a, b, i)>ans)?culc(a, b, i):ans);
    }
    
    cout << ans << endl;
    
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 3772
s = str(input())
flag = 0
C_count = 0
flag_2 = 0
mode = 0
a = 0
b = 0
c = 0
k = ["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"]
if s[0] == "A":
  a += 1
for i in s[2:-1]:
  if i == "C":
    C_count += 1
if C_count == 1:
  b += 1

l = s[1:]
l = l.replace("C","")
if l.islower() == True:
  c += 1
if a == 1 and b == 1 and c == 1:
  print("AC")
else:
  print("WA")

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def abc079_d():
    inp = iter(map(int, read().split()))
    H, W = next(inp), next(inp)
    adj_mtx = [[next(inp) for _ in range(10)] for _ in range(10)]
    grid = [[next(inp) for _ in range(W)] for _ in range(H)]

    def floyd_warshall(W):
        ''' ワーシャルフロイド法、全頂点間の最短距離 '''
        n = len(W)  # 頂点の数
        # DPで全頂点間の最短距離を求める
        for k in range(n):
            for u in range(n):
                for v in range(n):
                    W[u][v] = min(W[u][v], W[u][k] + W[k][v])
        return W

    min_dist = floyd_warshall(adj_mtx)

    # グリッドの数字が-1と1以外はコスト発生するため足していく
    ans = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == -1 or grid[i][j] == 1:
                continue
            ans += min_dist[grid[i][j]][1]
    print(ans)

abc079_d()

Measured memory_bytes: 5260
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int64_t n; cin >> n;
	cout << (n * (n - 1) / 2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a > b){
		if(c > d){
			cout << b+d << endl;
		}
		else{
			cout << b+c << endl;
		}
	}
	else if(a < b){
		if(c > d){
			cout << a+d << endl;
		}
		else{
			cout << a+c << endl;
		}
	}
	else if(a == b){
		if(c > d){
			cout << a+d << endl;
		}
		else{
			cout << a+c << endl;
		}
	}
}

Measured memory_bytes: 256