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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int a[MAXN];

int solve(int casi){
	cin>>n;
	ll s = 0;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		s += a[i];
	}
	ll st = 1ll * n * (n + 1) / 2;
	if (s % st != 0)
		return 0;
	s /= st;
	int cnt = 0;
	a[n+1] = a[1];
	for(int i = 1; i <= n; i++){
		ll t = s - (a[i+1] - a[i]);
		if (t % n != 0 || t < 0) return 0;
		cnt += t / n;
	}
	return cnt == s;
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		puts(solve(i) ? "YES" : "NO");
		printans();
	}
	return 0;
}




Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    final int N=sc.nextInt();
    if(N%2==0){
      System.out.println(N/2-1);
    }else{
      System.out.println((N+1)/2-1);
    }
  }
}

Measured memory_bytes: 22740
#include <iostream>
#include <map>
#include <set>
#include <queue>
#define ll long long
using namespace std;

multimap<ll, ll> items; // first = weight, second = value
int n, w;
ll maxVal[100005]; // max value which can be obtained with total weight of i

int main() {
    cin >> n >> w;

    for (int i = 1; i <= n; ++i) {
        ll x, y;
        cin >> x >> y;
        items.emplace(make_pair(x, y));
    }

    ll maxSum = 0;
    set<ll> possible;
    for (pair<ll, ll> item : items) {
        multimap<ll, ll> toAdd;
        toAdd.emplace(make_pair(item.first, item.second));

        auto it = possible.begin();
        while (it != possible.end() && (item.first + *it) <= w) {
            ll weight = *it + item.first;
            ll val = maxVal[*it] + item.second;
            toAdd.emplace(make_pair(weight, val));

            if (val > maxSum)
                maxSum = val;
            ++it;
        }

        for (pair<ll, ll> item : toAdd) {
            possible.emplace(item.first);
            maxVal[item.first] = max(maxVal[item.first], item.second);

            if (maxVal[item.first] > maxSum)
                maxSum = maxVal[item.first];
        }
    }

    cout << maxSum;
    return 0;
}


Measured memory_bytes: 15024
// COPIED

#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

#define MAX 100000
int n, m;
int p[MAX], y[MAX];
vector<int> yd[MAX+1];
int main()
{
  scanf("%d%d", &n,&m);
  rep(i,m)scanf("%d%d", &p[i],&y[i]),yd[p[i]].push_back(y[i]);
  rep(i,n)sort(yd[i+1].begin(),yd[i+1].end());
  rep(i,m) {
    int val = int(lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) - yd[p[i]].begin()) + 1;
    ll ans = ll(p[i]) * 1000000 + val;
    printf("%012lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
#define pi 3.14159265359
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, t, p;
    cin >> n >> x >> t;
    cout << (ll)ceil((double)n/x)*t;


    return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;

int main(){
	ios_base::sync_with_stdio (false);
	cout << fixed;
	cout.precision(10);
	if(fopen("joke.in", "r")){
		freopen ("joke.in","r",stdin);
		freopen ("joke.out","w",stdout);
	}

	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h + 2, vector<char>(w + 2, '#'));

	for(int i = 1; i <= h; ++i){
		for(int j = 1; j <= w; ++j){
			cin >> a[i][j];
		}
	}

	vector<vector<int>> dp(h + 2, vector<int>(w + 2, 0));
	dp[1][1] = 1;
	for(int i = 1; i <= h; ++i){
		for(int j = 1; j <= w; ++j){
			if(a[i][j] == '#') continue;
			if(a[i + 1][j] == '.')
				dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
			if(a[i][j + 1] == '.')
				dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MOD;
		}
	}

	cout << dp[h][w];
    return 0;
}


Measured memory_bytes: 5248
n, m = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
a.sort()
pm = s = 0
m_minus_1 = m - 1
for item in a:
    pm += item[1]
    if pm > m_minus_1:
        print(s + item[0] * (m - pm + item[1]))
        break
    else:
        s += item[0] * item[1]


Measured memory_bytes: 27760
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  double w, h, x, y;
  cin >> w >> h >> x >> y;

  double ans = w * h /2;
  int multi = (2*x == w && 2*y == h) ? 1: 0;

  printf("%.12lf %d\n", ans, multi);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define MAX_V 1000

using namespace std;
vector<int> G[MAX_V];
int m,V,color[MAX_V],sum1,sum2,c[1000],d[1000],num=0;
bool dp[1000][1000],mp[1000][1000];
bool dfs(int v, int c){
	color[v]= c;
	if(c==1){
		sum1++;
	}else{
		sum2++;
	}
	for(int i=0;i<G[v].size();i++){
		if(color[G[v][i]]==c) return false;
		if(color[G[v][i]]==0 && !dfs(G[v][i],-c)) return false;
	}
	return true;
}

bool dfs2(int i, int col) {
    if (color[i] == col) return true;
    if (color[i] != 0) return false;
    bool ok = true;
    color[i] = col;
	if(col==1){
		sum1++;
	}else{
		sum2++;
	}
    for (int u : G[i])
        ok &= dfs2(u, 3 - col);
    return ok;
}

int main(){
	cin >> V >> m;
	int i,j;
	for(i=1;i<=V;i++){
		for(j=1;j<=V;j++){
			mp[i][j] = true;
		}
	}
	for(i=0;i<m;i++){
		int a,b;
		cin >> a >> b;
		mp[a][b] = false;
		mp[b][a] = false;
	}
	
	for(i=1;i<=V;i++){
		for(j=1;j<=V;j++){
			if(mp[i][j] && i!=j){
				G[i].push_back(j);
			}
		}
	}
	
	for(i=1;i<=V;i++){
		color[i] = 0;
	}
	
	for(i=1;i<=V;i++){
		sum1 = 0; sum2 = 0;
		if(color[i]==0){
			if(!dfs2(i,1)){
				cout << -1 << endl;
				return 0;
			}
			c[num] = sum1;
			d[num] = sum2;
			num++;
		}
	}

	for(i=0;i<710;i++){
		for(j=0;j<710;j++){
			dp[i][j] = false;
		}
	}
	dp[0][0] = true;
	for(i=0;i<num;i++){
		for(j=0;j<1000;j++){
			if(dp[i][j]){
				dp[i+1][j+c[i]] = true;
				dp[i+1][j+d[i]] = true;
			}
		}
	}
	
	for(i=V/2;i>=0;i--){
		if(dp[num][i]){
			cout << V*(V-1)/2 - i*(V-i) << endl;
			return 0;
		}
	}
}
	

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


/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/



using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef float f;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define Unique(n)   (n).erase(unique(all(n)), (n).end())
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}
bool preced (int x , int y)
{
	return x > y;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n  , ans = 0 , cnt;
    cin >> n;
    ll x[n];
    loop(n)
    	cin >> x[i];
    sort (x , x + n , preced);
    cnt = n - 2;
    ans += x[0];
    for (int i = 1; i < n ; i++)
    {
    	ans += min((ll)2 , cnt) * x[i];
    	cnt -= min((ll)2 , cnt);
    }
    cout << ans;
	return 0;
}


Measured memory_bytes: 5200
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

int W,H;
P2 p[200010];
int s , t;
LL ans;

int main(){
	scanf("%d%d" , &W , &H);
	repp(i,0,W){
		int x;
		scanf("%d" , &x);
		p[i] = MP(x , i);
	}
	repp(i,0,H){
		int x;
		scanf("%d" , &x);
		p[W + i] = MP(x , W + i);
	}
	sort(p , p + W + H);
	repp(i,0,W+H){
		if(p[i].Snd < W){
			ans += (LL)p[i].Fst * (H - t + 1);
			++s;
		} else {
			ans += (LL)p[i].Fst * (W - s + 1);
			++t;
		}
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 1664
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N, P;
    private int[] A;

    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        N = int.Parse(line[0]);
        P = int.Parse(line[1]);
        A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }

    public void Solve()
    {
        Scan();
        long[,] arr = new long[5001, N + 1];
        arr[0, 0] = 1;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j <= 5000; j++)
            {
                if (arr[j, i] > 0)
                {
                    arr[j, i + 1] += arr[j, i];
                    arr[j + A[i], i + 1] += arr[j, i];
                }
            }
        }
        long ans = 0;
        for(int i = 0; i <= 5000; i++)
        {
            if (i % 2 == P)
            {
                ans += arr[i, N];
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 14176
#include <stdio.h>

int main(void)
{
        int n,k,x,y;
        scanf("%d%d%d%d",&n,&k,&x,&y);

        if(n<=k)printf("%d\n",n*x);
        else printf("%d\n",k*x+(n-k)*y);
        return 0;
}


Measured memory_bytes: 1728
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def std_in():
    return sys.stdin.readline().strip()


def main():
    x = int(std_in())
    if 400 <= x <= 599:
        print(8)
    elif 600 <= x <= 799:
        print(7)
    elif 800 <= x <= 999:
        print(6)
    elif 1000 <= x <= 1199:
        print(5)
    elif 1200 <= x <= 1399:
        print(4)
    elif 1400 <= x <= 1599:
        print(3)
    elif 1600 <= x <= 1799:
        print(2)
    elif 1800 <= x <= 1999:
        print(1)
    else:
        pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
s = input()

sg = 0
sp = 0
ans = 0

for i in range(len(s)):
    if sp+1 <= sg and s[i] == 'g':
        sp += 1
        ans += 1
    elif sp+1 > sg and s[i] == 'p':
        sg += 1
        ans -= 1
    elif sp+1 <= sg and s[i] == 'p':
        sp += 1
    else:
        sg += 1
print(ans)

Measured memory_bytes: 3316
n=int(input())
da=list(map(int,input().split()))
ma=da[0]
ju=True
for i in range(n):
    if ma-da[i]>0:
        ju=False
        break
    else:
        ma=max(ma,da[i]-1)
if ju:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int t=N%10;
  if(t==3)cout<<"bon"<<endl;
  else if(t==0 || t==1 || t==6 || t==8)cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
  return 0;
}

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

using namespace std;


void solve() {
    string s; cin >> s;
    string x = s.substr(0, 2);
    string y = s.substr(2, 2);
    bool u = "01" <= x && x <= "12";
    bool v = "01" <= y && y <= "12";
    if (u && v) {
        cout << "AMBIGUOUS";
    }else if (u) {
        cout << "MMYY";
    }else if (v) {
        cout << "YYMM";
    }else {
        cout << "NA";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
# INPUT
d, g = map(int, input().split())
questions = [list(map(int, input().split())) for i in range(d)]

# PROCESS
ans_num = 1000000000
for i in range(2**d):
  bit = format(i,'0'+str(d)+'b')
  score = 0
  ans = 0
  for j in range(d):
    if bit[j] == '1':
      score += questions[j][1] + 100*questions[j][0]*(j+1)
      ans += questions[j][0]
  if score >= g:
    if ans < ans_num:
      ans_num = ans
  else:
    for j in range(d-1, -1, -1):
      if bit[j] == '0':
        p, c = questions[j]
        for k in range(p):
          score += 100 * (j + 1)
          ans += 1
          if score >= g:
            break
        else:
          continue
        break
    if score >= g and ans < ans_num:
        ans_num = ans


# OUTPUT
print(ans_num)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n, k;
    cin >> n >> k;

    int ans = 1;
    rep (i, n)
    {
        if (ans > k) ans += k;
        else ans *= 2;
    }

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



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int r = in.nextInt();
            int g = in.nextInt();
            int b = in.nextInt();
            out.println((g * 10 + b) % 4 == 0 ? "YES" : "NO");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	long double ans=(a*b)/2.0;
	cout<<fixed<<setprecision(10)<<ans<<" ";
	if(2*c==a&&2*d==b)
	{
		cout<<"1";
	}
	else
	{
		cout<<"0";
	}
}

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

using namespace std;

const double EPS = 1e-9;
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

struct Point{
  double x,y;
  Point(double x = 0, double y = 0): x(x),y(y){};
  bool operator < (const Point& p) const{
    if(x != p.x) return x < p.x;
    return y < p.y;
  }
  Point operator + (Point p) {return Point(x+p.x,y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  double own_dot(){return x*x+y*y;};
};

double dot(Point a, Point b){
  return a.x*b.x+a.y*b.y;
}

double cross(Point a, Point b){
  return a.x*b.y-a.y*b.x; 
}

int ccw(Point p0, Point p1, Point p2){
  Point a = p1-p0;
  Point b = p2-p0;
  if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
  if(cross(a,b) < -EPS) return CLOCKWISE;
  if(dot(a,b) < -EPS) return ONLINE_BACK;
  if(a.own_dot() < b.own_dot()) return ONLINE_FRONT;
  return ON_SEGMENT;
}

vector<Point> andrewScan(vector<Point> s){
  vector<Point> u,l;
  
  if(s.size() < 3) return s;

  sort(s.begin(),s.end());
  
  u.push_back(s[0]);
  u.push_back(s[1]);
  l.push_back(s[s.size()-1]);
  l.push_back(s[s.size()-2]);
  
  for(int i = 2; i < s.size(); i++){
    for(int n = u.size(); n>=2 && ccw(u[n-2],u[n-1],s[i])!=CLOCKWISE;n--)
      u.pop_back();
    u.push_back(s[i]);
  }

  for(int i = s.size()-3; i >= 0; i--){
    for(int n = l.size(); n>=2 && ccw(l[n-2],l[n-1],s[i])!=CLOCKWISE;n--)
      l.pop_back();
    l.push_back(s[i]);
  }

  reverse(l.begin(),l.end());
  
  for(int i = u.size()-2; i >= 1; i--) l.push_back(u[i]);
  return l;
}

int main(){
  int n;
  while(cin >> n && n){
    vector<Point> V(n);
    for(int i = 0; i < n; i++) scanf("%lf,%lf",&V[i].x,&V[i].y);
    cout << n-andrewScan(V).size() << endl;
  }
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int X = 1;
  for (int i = 0; i < N; i++) {
    if (X < K) X *= 2;
    else X += K;
  }
  cout << X << endl;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;


void solve()
{
    string s; cin >> s;
    int p = 0;
    int win = 0;
    REP(i, s.length())
    {
        if(i % 2 == 0)
        {
            if(s[i] == 'p') win--;
        }
        else
        {
           if(s[i] == 'g') win++; 
        }
    }
    cout << win << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 10000
#define NIL -1
struct Node { int p,l,r; };
struct Node T[MAX];
int n;
void preParse(int u)
{
    if(u==NIL) return ;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}
void inParse(int u)
{
    if( u == NIL ) return ;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}
void postParse(int u)
{
    if( u == NIL ) return ;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}
int main()
{
    int i,v,l,r,root;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        T[i].p=NIL;
    }
    for(i=0;i<n;i++)
    {
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL) T[l].p=v;
        if(r!=NIL) T[r].p=v;
    }
    for(i=0;i<n;i++) if ( T[i].p == NIL ) root=i;
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
    return 0;
}

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

int main()
{
    int n,s=0,p;
    cin>>n;
    int a[n+1],b[55],c[55];
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    for(int i=1;i<=n-1;i++) cin>>c[i];
    p=a[1];
    s+=b[a[1]];
    for(int i=2;i<=n;i++)
    {
        s+=b[a[i]];
        if(p+1==a[i]) s+=c[p];
        p=a[i];
    }
    cout<<s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; ll w; cin >> n >> w;
    vector<vector<int> > ob(4);
    ll a,b; cin >> a >> b;
    a--;
    ob[0].push_back(b);
    rep(i,n-1){
        ll o; int v; cin >> o >> v;
        ob[o-a-1].push_back(v);
    }
    rep(i,4){
        sort(all(ob[i]));
        reverse(all(ob[i]));
    }

    int ans=0;

    rep(i,ob[0].size()+1){
        rep(j,ob[1].size()+1){
            rep(z,ob[2].size()+1){
                rep(k,ob[3].size()+1){
                    int tmp=0;
                    rep(ii,i) tmp+=ob[0][ii];
                    rep(jj,j) tmp+=ob[1][jj];
                    rep(zz,z) tmp+=ob[2][zz];
                    rep(kk,k) tmp+=ob[3][kk];
                    ll tmpw=(ll)(i*(a+1))+(ll)(j*(a+2))+(ll)(z*(a+3))+(ll)(k*(a+4));
                    if(tmpw<=w) ans=max(ans,tmp);
                }
            }
        }
    }

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



Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;

	int m;

	cin >> n;
	int d[n];
	map<int, int>m1, m2;
	zip(i, 0, n)
	{
		cin >> d[i];
		m1[d[i]]++;
	}
	cin >> m;
	int t[m];
	zip(i, 0, m)
	{
		cin >> t[i];
		m2[t[i]]++;
	}
	zip(i, 0, m)
	{
		if (m2[t[i]] > m1[t[i]])
		{
			cout << "NO" << en;
			return 0;
		}
	}
	cout << "YES" << en;


	return 0;
}



Measured memory_bytes: 31756
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string s[N];
  map<string, long long> cnt;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
    cnt[s[i]]++;
  }
  long long ans = 0;
  for (auto p : cnt) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 14624
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n, p;
	cin >> n;
	int c = 1;
	int m = 0;
	cin >> p;
	m = p;
	for (int i = 1; i < n; i++) {
		cin >> p;
		if (p < m)	m = p;
		if (p <= m)	c++;
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n;
	float sum=0;
	cin>>n;
	float a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++)
	{
		sum+=(1/a[i]);
	}
	cout<<1/sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

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

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  LL N, Q;
  cin >> N >> Q;


  string s;
  cin >> s;

  vector<LL> v(s.size(), 0);

  FOR(i, 1, s.size())
  {
    if(s[i-1]=='A'&&s[i]=='C'){
      v[i] = v[i - 1] + 1;
    }else{
      v[i] = v[i - 1];
    }
  }

  REP(i,Q){
    LL l, r;
    cin >> l >> r;
    l--;
    r--;
    LL hoge = v[r] - v[l];
    cout << hoge << endl;
  }
}


Measured memory_bytes: 1872
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(c-b==b-a) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
    ll n,m;
    cin>>n>>m;
    vp in(n);
    rep(i,n)cin>>in[i].first>>in[i].second;
    sort(all(in));
    ll out=inf;
    rep(i,n-1)loop(j,i+1,n){
        vi t;
        loop(k,i,j+1)t.pb(in[k].second);
        sort(all(t));
        if((int)t.size()-m+1>=0)rep(k,(int)t.size()-m+1)out=min(out,(in[j].first-in[i].first)*(t[k+m-1]-t[k]));
    }
    cout<<out<<endl;
}




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

int main(void){
  while(1){
    int stone[50];
    for(int k = 0 ; k < 50 ; k++){stone[k] = 0;}

    int bowl;
    int n, p;  // n：候補者人数，p：小石の総数
    cin >> n;
    cin >> p;

    if(n == 0 && p == 0){return 0;}

    bowl = p;

    bool flg = true;
    int ans;

    for(int i = 0 ; flg ; i = (i+1) % n){

      if(bowl == 0){
        bowl = bowl + stone[i];
        stone[i] = 0;
      }else{
        stone[i]++;
        bowl--;
        if(bowl == 0 && stone[i] == p){ans = i; flg = false;}
      }
    }

    for(int i = 0 ; i < 1000000 ; i++){
        for(int j = 0 ; j < 1000000 ; j++){
            int k = i + j;
        }    
    }


    cout << ans << endl;
  }
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){cin>>a[i];}
  map<int,int> amap;

  for(int i=0;i<n;i++)
  {
    if(amap.find(a[i])!=amap.end())
    {
      amap[a[i]]+=1;
    }
    else{
      amap[a[i]]=1;
    }
  }
  int res=0;
  for(auto itr=amap.begin();itr!=amap.end();itr++)
  {
    int p,q;
    p=itr->first;
    q=itr->second;
    if(p<=q){res+=q-p;}
    else{res+=q;}
  }
  cout<<res;





  return 0;

}

Measured memory_bytes: 5120
#include<iostream>
//#include<cstring>
//#include<cmath>
//#include<cstdio>
//#include<algorithm>
using namespace std;

int x,y,z; 

int main(){
	cin>>x>>y>>z;
	cout<<(x-z)/(y+z)<<endl;
	return 0;
} 

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

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

  cout << min(n*a,b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<climits>
using namespace std;
 
 
int main(){
	int n, a, b, c, d;

	cin >> n >> a >> b >> c >> d;

	int ans = INT_MAX / 4;
	a--; b--; c--; d--;

	for(int i = 1; i <= n;i++){
		int dx,dy;
		int tmp;

		dy = abs(a / i - b / i);
		dx = abs(a % i - b % i);
		tmp = dy + dx;
		dy = abs(c / i - d / i);
		dx = abs(c % i - d % i);
		tmp += dy + dx;
		ans = min(tmp, ans);
	}

	cout << ans << endl;
}

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

int main() {
  ll n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

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

  vector<int> c(n, 2);
  for (int i = 1; i < n; i += 2) c[i] *= -1;
  c[0] /= abs(c[0]), c[n - 1] /= abs(c[n - 1]);
  sort(c.begin(), c.end());
  ll ans1 = 0;
  rep(i, n) ans1 += a[i] * c[i];

  vector<int> d(n, -2);
  for (int i = 1; i < n; i += 2) d[i] *= -1;
  d[0] /= abs(d[0]), d[n - 1] /= abs(d[n - 1]);
  sort(d.begin(), d.end());
  ll ans2 = 0;
  rep(i, n) ans2 += a[i] * d[i];

  cout << max(ans1, ans2) << endl;
  return 0;
}


Measured memory_bytes: 4556
# B - Iron Bar Cutting
from bisect import bisect
from itertools import accumulate


def main():
    N, *A = map(int, open(0).read().split())
    cumsum = tuple(accumulate(A))
    idx = bisect(cumsum, cumsum[-1] // 2)
    print(min(cumsum[idx] * 2 - cumsum[-1], cumsum[-1] - cumsum[idx - 1] * 2))


if __name__ == "__main__":
    main()


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


int main(){
	int n, cn=0;
	string s, x, y;
    vector<int> c;

    cin >> n;
    cin >> s;
    for(int i=1;i<n;i++){
        vector<char> p, q;
        c.push_back(0);
        x = s.substr(0, i);
        y = s.substr(i, n - i);

        for(int j=0;j<(int)x.size();j++){
            p.push_back(x[j]);
        }
        for(int j=0;j<(int)y.size();j++){
            q.push_back(y[j]);
        }
        sort(p.begin(), p.end());
        sort(q.begin(), q.end());
        auto r = unique(p.begin(), p.end());
        auto s = unique(q.begin(), q.end());
        p.erase(r, p.end());
        q.erase(s, q.end());

        for(int j=0;j<(int)p.size();j++){
            for(int k=0;k<(int)q.size();k++){
                if(p[j] == q[k]) c[cn]++;
            }
        }
        cn++;
    }
    sort(c.begin(), c.end());
    cout << c[cn-1] << endl;
	
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    if S[0] == S[1] == S[2]:
        print(NO)
    else:
        print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n, a, b, c, d = map(int, raw_input().split())
if a > b: a, b = b, a
for i in xrange(n - 1):
    mn = -d * i + c * (n - 1 - i)
    mx = -c * i + d * (n - 1 - i)
    if mn <= b - a <= mx:
        print "YES"
        exit()
print "NO" 


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

int minCostDP(int *arr, int n, int k){
    int *dp=new int[n+1];
    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=n;i++){
        int kk=k;
        if(k>=i) kk=i-1;
        int minC=INT_MAX;
        for(int j=1;j<=kk;j++){
            minC=min(minC,abs(arr[i]-arr[i-j]) + dp[i-j]); 
        }
        dp[i]=minC;
    }
    return dp[n];
}

int main(){
	int n,k;
  	cin>>n>>k;
  	int *arr=new int[n+1];
    for(int i=1;i<=n;i++){
    	int h;
      	cin>>h;
      	arr[i]=h;
    }
    
    int *dp=new int[n+1];
    memset(dp,-1,sizeof(dp[0])*(n+1));
    
    cout<< minCostDP(arr,n,k)<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <cstring>
#include <string>
#include <bitset>
#include <stdlib.h>
#include <time.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second > b.second;}};
int lb(int x){return  x & -x;}

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9+7;
const int maxn = 105;

int main()
{
	char t[2];
	scanf("%s",t);
	if(t[0] >= 'A' && t[0] <= 'Z')
	{
		printf("A\n");
	}
	else
	printf("a\n");

}

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

using namespace std;

int main() {
    int K, N;
    cin >> K >> N;
    
    vector<int> vec(N);
    vector<int> dist(N);
    for(int n=0; n<N; n++) {
        cin >> vec[n];
    }
    
    sort(vec.begin(), vec.end());

    vector<int> sd(N+1, 0);
    for(int n=1; n<N; n++) {
        dist[n-1] = vec[n]-vec[n-1];
        sd[n] = dist[n-1]+sd[n-1];
    }
    dist[N-1] = vec[0]+K-vec[N-1];
    sd[N] = dist[N-1]+sd[N-1];
    
    int ans=1e6+1;
    for(int n=0; n<N; n++) {
        ans = min(ans, sd[n]-sd[0] + sd[N]-sd[n+1]);
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
	ll n;
	cin>>n;
	cout<<(ll)n*(n-1)/2<<endl;
}


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

#include <boost/range/irange.hpp>
using boost::irange;

int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i : irange(0, n)) {
    cin >> arr[i];
  }
  int cnt = 0;
  while (all_of(arr.begin(), arr.end(), [](auto value){return value % 2 == 0;})) {
    ++cnt;
    for (auto &value : arr) {
      value /= 2;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			double x = sc.nextDouble();
			double h = sc.nextDouble();
			if(x == 0 && h == 0)break;
			double t = Math.sqrt(x * x / 4+ h * h);
			double s = x * x + 2 * x * t;
			System.out.println(s);
		}
		sc.close();
	}
}


Measured memory_bytes: 27716
#include <stdio.h>
int main() {
    short int a, b, c, k;
    scanf("%hi%hi%hi%hi", &a, &b, &c, &k);
    while (k && a >= b) {
        k--;
        b <<= 1;
    }
    while (k && b >= c) {
        k--;
        c <<= 1;
    }
    printf(a < b && b < c ? "Yes" : "No");
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
ll inf=1000000000000000,mod=1000000007;

int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
       
     ll arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
     ll k;
     cin>>k;
     cout<<arr[k-1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long ans = 0;
  if (N % 2 == 0) {
    N = N / 2;
    while (N / 5 != 0) {
      N /= 5;
      ans = ans + N; 
    }
  cout << ans << endl;
  }
  else {
    cout << 0 <<endl;
  }
}

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    vector<set<int>> g(n);
    set<int> cand;
    rep(i, m)
    {
        g[a[i]].insert(b[i]);
        g[b[i]].insert(a[i]);
        cand.insert(a[i]);
        cand.insert(b[i]);
    }

    vector<int> indx(n);
    rep(i, n)
    {
        indx[i] = 0;
    }

    int ans = -1;
    rep(x, n)
    {
        if (indx[x] != 0)
        {
            continue;
        }
        int temp = 1;
        indx[x] = 1;

        deque<int> q;
        q.push_back(x);

        while (!q.empty())
        {
            int t = q.front();
            q.pop_front();

            for (auto y : g[t])
            {
                if (indx[y])
                {
                    continue;
                }
                else
                {
                    q.push_back(y);
                    temp++;
                    indx[y] = 1;
                }
            }
        }
        ans = max(ans, temp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 45988
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  string s;
  cin>>s;
  string a="YAKI";
  if(s.size()<4||a!=s.substr(0,4)) cout<<"No\n";
  else cout<<"Yes\n";
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int cnt0 = 0;
  int ans = 0;
  while (cnt0 < n) {
    cnt0 = 0;
    rep(i, n) {
      if (h[i] == 0) {
        ++cnt0;
        if (i+1 < n) if (h[i+1] > 0) ++ans; 
      }
      else {
        --h[i];
        if (i == 0) ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int main() {
    // source
    string s;
    cin >> s;
    int a, b;
    int temp = stoi(s);
    a = temp / 100;
    b = temp % 100;

    bool first, second;
    first = a != 0 && a <= 12;
    second = b != 0 && b <= 12;

    if (first && second) {
        cout << "AMBIGUOUS" << endl;
    } else if (!first && second) {
        cout << "YYMM" << endl;
    } else if (first && !second) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;


int tx[] = {-1,0,1,0};
int ty[] = {0,1,0,-1};

int path[501][501];


int main(){
	int N,M;
	while(~scanf("%d %d",&N,&M)){
		if(N==M && M==0) break;
		memset(path,0,sizeof(path));
		for(int i=0;i<M;i++){
			int a,b;
			scanf("%d %d",&a,&b);
			path[a][b] = path[b][a] = 1;
		}

		priority_queue<P,vector<P>,greater<P> > que;
		que.push(P(0,1));
		map<int,int> visited;
		visited[1] = 1;

		int res=0;
		while(!que.empty()){
			int cost = que.top().first;
			int now = que.top().second;

			if(cost >= 2) break;

			que.pop();
			for(int i=2;i<=N;i++){
				if(path[now][i]==1 && visited.find(i) == visited.end()){
					visited[i] = 1;
					res++;
					que.push(P(cost+1,i));
				}
			}

		}

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

Measured memory_bytes: 0