akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = input()

E_lst = []
cnt = 0
for i in range(N):
    if S[i] == 'E':
        cnt += 1
    E_lst.append(cnt)
min = N + 1
for i in range(N):
    nw = 0 #i番目の人の左側にいるWの人数
    if i > 0:
        nw = i - E_lst[i - 1]
    ne = E_lst[N - 1] - E_lst[i]
    if nw + ne < min:
        min = nw + ne
print(min)


Measured memory_bytes: 15520
#include <iostream>

using namespace std;

int main()
{
    int k,s,cont = 0;
    cin >> k >> s;
    for(int i = 0;i<=k;i++){
        for(int j = 0;j<=k;j++){
            int x = s - i -j;
            if(x >= 0 && x <= k){
                cont++;
            }
        }
    }
    cout << cont;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
 string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>s;
for (int i = 0; i < s.size(); ++i)
{
 if(s[i]=='o')
  c++;
}
//c(c);
if(c>=8 or c+ (15-s.size())>=8)
c("YES");
else c("NO");

}

signed main(){
 
      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define bit(n) (1LL<<(n))
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
struct baseN{
    int base;
    int len;
    string val; //reversed
    string digit = "0123456789ABCDEF";
    bool end = false;
    baseN(int b,int l) :base(b), len(l){
        val = string(len,'0');
    }
    baseN operator++(int){
        bool flag = true;
        for(int i=0; i < len; i++){
            if(val[i]!=digit[base-1]){
                val[i]=digit[pos(val[i])+1];
                flag = false;
                break;
            } else {
                val[i]='0';
            }
        }
        if(flag) end = true;
        return *this;
    }
    int operator[](int i){
        return pos(val[i]);
    }
    int pos(char s){
        if(s-'0'<10) return s-'0';
        else return s-'A'+10;
    }
};
#pragma endregion library
int n;    
vector<tuple<ll,ll,ll>> m;
vll ans;
const int MX = 16;
ll dpx[1<<16][16],dpy[1<<16][16];
void solve(string &i){
    int xbit = 0, ybit = 0;
    int cnt = 0;
    rep(j,n){
        if(i[j]=='1') cnt++,ybit+=bit(j);
        if(i[j]=='2') cnt++,xbit+=bit(j);
    }
    ll cost = 0;
    rep(j,n){
        cost += min(dpx[xbit][j],dpy[ybit][j]);
    }
    ans[cnt] = min(ans[cnt], cost);
}
void dfs(string s){
    if((int)s.length()==n){
        solve(s);
        return;
    }
    dfs(s+'0');
    dfs(s+'1');
    dfs(s+'2');
}
int main(){
    cin >> n;
    rep(i,n){
        ll x,y,p; cin >> x >> y >> p;
        m.emplace_back(x,y,p);
    }
    ans.assign(n+1,LINF);
    rep(i,bit(n)){
        set<ll> xax = {0ll}, yax = {0ll};
        rep(j,n){
            if(bit(j)&i) yax.emplace(get<0>(m[j])),xax.emplace(get<1>(m[j]));
        }
        rep(j,n){
            ll x,y,p;
            tie(x,y,p) = m[j];
            ll now = LINF;
            auto it2 = yax.lower_bound(x);
            if(it2!=yax.end()) now = min(now, (*it2-x)*p);
            if(it2!=yax.begin()) now = min(now, (x-*(--it2))*p);
            dpy[i][j] = now;
            now = LINF;
            auto it = xax.lower_bound(y);
            if(it!=xax.end()) now = min(now, (*it-y)*p);
            if(it!=xax.begin()) now = min(now, (y-*(--it))*p);
            dpx[i][j] = now;
        }
    }
    dfs("");
    rep(i,n+1){
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 11812
package main

import "fmt"

func main() {
	var A, B, C, D, E, F int
	fmt.Scan(&A, &B, &C, &D, &E, &F)
	best := -1.0
	var ans_m int
	var ans_s int
	for a := 0; a <= F; a += A * 100 {
		for b := 0; b <= F; b += B * 100 {
			for c := 0; c <= F; c += C {
				for d := 0; d <= F; d += D {
					M := a + b + c + d
					W := a + b
					S := c + d
					if M > F {
						continue
					}
					if (E * W / 100) < S {
						continue
					}
					x := float64(S) / float64(M)
					if x > best {
						best = x
						ans_m = M
						ans_s = S
					}
				}
			}
		}
	}
	fmt.Println(ans_m, ans_s)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n=scan.nextLong();
		int k=scan.nextInt();
		scan.close();
		int cnt=1;
		while(true) {
			if(Math.pow(k,cnt) > n) {
				break;
			}else cnt++;
		}

		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define MOD 1000000007

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

const int INF=1e9;
const double eps=0.0000000001;

int main(){
  int n,v=0;
  cin >> n;
  int a[1000000];
  FOR(i,n){
    cin >> a[i];
    if(a[i]%2==1){
      v++;
    }
  }
  if(v%2==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

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

    long long x = min(b - 1, n);
    long long f_x = floor(a * x / b) - a * floor(x / b);
    cout << f_x << endl;
}


Measured memory_bytes: 3616
var
  n,m,x,y,i,q,total:longint;
  b,p,d,v,tot,que,first,next,ans,c:array[0..200010]of longint;

procedure add(x,y:longint);
begin
    inc(total);
    next[total]:=first[x];
    first[x]:=total;
    b[total]:=y;
end;

procedure bfs(k:longint);
var
  head,tail:longint;
  s:longint;
begin
    head:=1;
    tail:=1;
    que[1]:=k;
    while head<=tail do begin
        s:=first[que[head]];
        if ans[que[head]]=0 then ans[que[head]]:=c[i];
        if tot[head]>p[que[head]] then begin
            p[que[head]]:=tot[head];
            if tot[head]>0 then begin
                while s<>-1 do begin
                    inc(tail);
                    tot[tail]:=tot[head]-1;
                    que[tail]:=b[s];
                    s:=next[s];
                end;
            end;
        end;
        inc(head);
    end;
end;

begin
    read(n,m);
    for i:=1 to n*2 do first[i]:=-1;
    for i:=1 to m do begin
        read(x,y);
        add(x,y);
        add(y,x);
    end;
    read(q);
    for i:=1 to q do read(v[i],d[i],c[i]);
    for i:=q downto 1 do begin
        if p[v[i]]>d[i] then continue;
        if (ans[v[i]]<>0)and(d[i]=0) then continue;
        tot[1]:=d[i];
        bfs(v[i]);
    end;
    for i:=1 to n do writeln(ans[i]);
end.

Measured memory_bytes: 7168
import sys

stdin = sys.stdin

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


s = ns()
s1 = int(s[:2])
s2 = int(s[2:])

if s1 == 0 and s2 > 12:
    ans = "NA"
elif s1 > 12 and s2 == 0:
    ans = "NA"
elif s1 == 0 and s2 == 0:
    ans = "NA"
elif s1 == 0:
    ans = "YYMM"
elif s2 == 0:
    ans = "MMYY"
elif s1 > 12 and s2 > 12:
    ans = "NA"
elif s1 > 12:
    ans = "YYMM"
elif s2 > 12:
    ans = "MMYY"
else:
    ans = "AMBIGUOUS"

print(ans)


Measured memory_bytes: 3064
def examA():
    L, R, D = LI()
    ans = R//D - (L-1)//D
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    ans = 0
    for i,a in enumerate(A):
        if i%2==0:
            if a%2==1:
                ans += 1
    print(ans)
    return

def examC():
    N = I()
    ans = [0]*N
    for x in range(1,101):
        for y in range(1,101):
            for z in range(1,101):
                cur = x**2 + y**2 + z**2 + x*y + y*z + x*z
                if cur<N+1:
                    ans[cur-1] += 1

    for v in ans:
        print(v)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(2*10**6)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 79608
#include<bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define pb push_back
#define pii pair<int64_t,int64_t>
#define mp make_pair
#define whole(v) begin(v),end(v)
#define print(c,n) for(int64_t i=0;i<n;i++) cout << c[i] << " ";
#define MOD 1000000007
void solve(){
	string s;
	cin >> s;
	int freq[26];
	memset(freq,0,sizeof(freq));
	for(int i=0;i<s.size();i++){
		freq[s[i]-'A']++;
	}
	int c1=0,b=1;
	for(auto i : freq){
		if(i==0) continue;
		else if(i==2) c1++;
		else {
			b=0;break;
		}
	}
	//cout << c1 << " " << b ;
	if(b && c1==2) cout << "Yes";
	else cout << "No";
}
int main(){
	
	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define maxn 300005
#define mod 1000000007
#define inf 1000000007
namespace lib
{
	using namespace std;
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
		public:
			inline void gc(char & _c) {_c=getchar();}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				_x=0;
				while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
				while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
				_f&&(_x=-_x,_f=0);
				return *this; 
			}
			inline void pc(char _c) {putchar(_c);}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				_T _k;
				if(_x==0) {pc('0'),pc(' ');return *this;}
				if(_x<0) pc('-'),_x=-_x;
				while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
				while(_head>0) pc(_num[_head]),--_head;
				pc(' ');
				return *this; 
			}
			#define endl pc('\n')
		fastio() {_f=0,_head=0,_ch=' ';}
	}io;
}using namespace lib;

ll cnt[65],ans;
signed main()
{
//	freopen("ttin.in","r",stdin);
//	freopen("ttout.out","w",stdout);
//	ios::sync_with_stdio(false);
//	cin.tie(0),cout.tie(0);
	ll n,a;
	io-n;
	for(rgi i=1;i<=n;++i)
	{
		io-a;
		for(rgi j=0;j<61;++j)
			cnt[j]+=a&1,a>>=1;
	}
	ll t=1;
	for(rgi i=0;i<61;++i)
	{
		(ans+=((cnt[i]*(n-cnt[i])%mod)*t)%mod)%=mod;
		(t<<=1)%=mod;
	}
	io+ans;
	return 0;
}

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

int64_t kurikaeshi_2jou(int64_t a, int64_t num);

int main(){

    int64_t H;
    cin >> H;

    int64_t num = 1;
    int64_t count = 0;

    while (H>1){
        H /= 2;
        count++;
        num *= 2;
    }

    int64_t sum = 0;
    for (int64_t i=0; i<count; i++){
        sum += kurikaeshi_2jou(2, i);
    }

    num = kurikaeshi_2jou(2, count);

    int64_t ans;
    ans = sum + num;

    cout << ans << endl;

    return 0;
}

int64_t kurikaeshi_2jou(int64_t a, int64_t num){

    if (num == 0){
        return 1;
    }
    if (num == 1){
        return a*kurikaeshi_2jou(a, num-1);
    }
    else if (num%2 != 0){
        return a*kurikaeshi_2jou(a, num-1);
    }
    else{
        return kurikaeshi_2jou(a, num/2)*kurikaeshi_2jou(a, num/2);
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int c[3][3];

int main(){
  REP(i,3){
    REP(j,3){
      cin>>c[i][j];
    }
  }

  REP(i,3){
    FOR_IN(j,1,3){
      c[i][j] -= c[i][0];
    }
  }
  
  FOR_IN(i,1,3){
    FOR_IN(j,0,3){
      c[i][j] -= c[0][j];
    }
  }

  int f=true;

  FOR_IN(i,1,3){
    FOR_IN(j,1,3){
      f = f && c[i][j] == 0;
    }
  }

  if(f)
    cout<<"Yes\n";
  else
    cout<<"No\n";

  return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

int main(void){
    string s;
    cin >> s;
    string sc = "";
    rep(i, 5){
        sc+="hi";
        if(s == sc){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
n = int(input())

if 100 <= n and n <= 111:
    print(111)
if 112 <= n and n <= 222:
    print(222)
if 223 <= n and n <= 333:
    print(333)
if 334 <= n and n <= 444:
    print(444)
if 445 <= n and n <= 555:
    print(555)
if 556 <= n and n <= 666:
    print(666)
if 667 <= n and n <= 777:
    print(777)
if 778 <= n and n <= 888:
    print(888)
if 889 <= n and n <= 999:
    print(999)


Measured memory_bytes: 63980
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int prime(ll a){
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){
    if(a%i==0){return 0;}
  }
  return 1;
}
int main(){
  ll N,ans=0;;
  cin>>N;
  bool checker=false,oneprime=false;
  ll n=N,memo=0,count=0,sqrtN=sqrt(N);
  vector<ll> vec(sqrtN);
  for(ll i=1;i*i<=n;i++){
    ll rock=N;
    while(N%i==0 && N>1 && prime(i)==1){
      N/=i;
      checker=true;
      vec.at(i-1)++;
      if(rock==n && N==1){oneprime=true;}
    }
    if(vec.at(i-1)>0){
      ll j=1;
        while(vec.at(i-1)>=j){
          vec.at(i-1)-=j;
          if(vec.at(i-1)>=j+1){j++;}
        }
        ans+=j;
    }
    if(n%i==0 && prime(n/i)==1 && N%(n/i)==0){
      while(N%(n/i)==0 && N>1){
        N/=(n/i);
        checker=true;
        count++;
        memo=n/i;
      }
      if(count>0){
        ll j=1;
          while(count>=j){
            count-=j;
            if(count>=j+1){j++;}
          }
          ans+=j;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11184
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k;
    string s;
    cin>>s;
    for(i=0;i<s.length();i++)
    {
        if(s[i]=='?')
        {
                s[i]='D';
        }
    }
    cout<<s<<endl;
}



Measured memory_bytes: 3752
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a,b,ans;
int main()
{
	scanf("%d%d",&a,&b);
	if(a<0&&b<0)
	{
		if(a<b)ans=b-a;
		else ans=a-b+2;
	}
	else	if(a<0&&b>0)
	{
		ans=b-a;
		if(-a>b)ans=min(ans,-a-b+1);
		else	ans=min(ans,b+a+1);
	}
	else	if(a>0&&b<0)
	{
		ans=a-b;
		if(a>-b)ans=min(ans,b+a+1);
		else	ans=min(ans,-a-b+1);
	}
	else	if(a>0&&b>0)
	{
		if(a<b)ans=b-a;
		else ans=a-b+2;
	}
	else
	{
		if(a==0)
		{
			if(b<0)ans=a-b+1;
			else ans=b;
		}
		else
		{
			if(a<0)ans=-a;
			else ans=a+1;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
a = [input() for i in range(2)]
 
N = int(a[0])
data = a[1].split(' ')
 
data = [int(i) for i in data]
 
result = []
a = 0
for i in range(N):
    a = a ^ data[i]
    
if a == 0:
    print('Yes')
    exit()
    
print('No')

Measured memory_bytes: 14996
#include <iostream>
#include <set>
#include <list>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std; 

int
main(int argc, char const *argv[])
{
    int64_t n;
    cin >> n;
    vector<int64_t> a(n);
    int64_t count_minus = 0;
    int64_t min;
    int64_t sum = 0;
    int64_t res;

    for (int64_t i = 0; i < n; ++i) {
	if (i == 0) min = a[i];

	cin >> a[i];
	if (a[i] < 0) {
	    ++count_minus;
	}

	int64_t b;
	b = a[i];
	if (a[i] < 0) b = -b;

	sum += b;
	if (i == 0) {
	    min = b;
	} else {
	    if (min > b) min = b;
	}
    }

    // cerr << "sum is " << sum << ", min is " << min << endl;;
    if ((count_minus % 2) == 1) {
	res = sum - min * 2;
    } else {
	res = sum;
    }

    cout << res << endl;
    return 0;
}


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

int main()
{
    int n , m , l;
    long long a[103][103] , b[103][103] , c[103][103];
    
    cin >> n >> m >> l;

    for(int i = 0;i <n ; i++)
    {
        for(int j = 0; j < m;j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 0 ; i <m;i++)
    {
        for(int j=0;j<l ;j++)
        {
            cin >> b[i][j];
        }
    }
    for(int i = 0 ; i<n;i++)
    {
        for(int j = 0 ; j <l;j++)
        {
            c[i][j] = 0;
            for(int k = 0 ; k < m;k++)
            {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    for(int i = 0 ; i < n;i++)
    {
        for(int j = 0 ; j< l;j++)
        {
            if(j) cout << " ";
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3336
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
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; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  double x, h;
  while (cin >> x >> h, x) {
    cout << prec(8) << x * x + x * hypot(h, x / 2) * 2 << endl;
  }
}

Measured memory_bytes: 3284
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

using namespace std;

typedef long long lint;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int ret = 2018;
    int L, R;
    cin >> L >> R;
    for (int i = L;i < R && i < L + 2019;i++)
        for (int j = R;j > i && j > R - 2019;j--)
            ret = min(ret, ((i % 2019) * (j % 2019)) % 2019);

    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define Tsetso ios_base::sync_with_stdio(0) ; cin.tie(0) ;
using namespace std;
const ll N = 2e5+50, inf = 1e3+5, mod = 1e9+7, NN = 1e5+10;
ll a[N];
int main()
{
    Tsetso
    map < int , int > mp ;
    int n , m ;
    cin >> n >> m ;
    ll ans = 0 ;
    mp[0] = 1 ;
    for ( int i = 1 ; i <= n ; i++)
    {
        cin >> a[i] ;
        a[i] += a[i-1];
        a[i] %= m ;
        ans += mp[a[i]] ;
        mp[a[i]]++ ;
    }
    cout << ans ;
}


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

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

using ll = long long;
using namespace std;

constexpr int INF = 2147483647; // 2 * 1e9
constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

int clc(int b, int n){
	int c = b;
	while(n / c) c *= b;
	c /= b;
	if(c == 1) return n;
	return n / c + clc(b, n % c);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int ma = INF;
	for(int i = 0; i <= n / 9; ++i){
		int nn = n - 9 * i;
		int k = 0;
		k += clc(9, i);
		k += clc(6, nn / 6);
		nn %= 6;
		k += nn;
		ma = min(ma, k);
	}
	cout << ma << "\n";
	return 0;
}


Measured memory_bytes: 256
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;

#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n;
        cin>>n;
        cout<<(n-1)*(n)/2;
    }
    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  string S;
  cin >> S;
  vi R_idx(S.size(), 0), L_idx(S.size(), 0);
  for (int i = 1; i < S.size(); i++) {
    if (S[i - 1] == 'L') {
      R_idx[i] = R_idx[i - 1] + 1;
    } else {
      R_idx[i] = 1;
    }
  }
  for (int i = S.size() - 2; i >= 0; i--) {
    if (S[i + 1] == 'R') {
      L_idx[i] = L_idx[i + 1] + 1;
    } else {
      L_idx[i] = 1;
    }
  }
  vi ans(S.size(), 0);
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'L') {
      ans[i - R_idx[i] + (R_idx[i] % 2)]++;
    } else {
      ans[i + L_idx[i] - (L_idx[i] % 2)]++;
    }
  }
  for (int i = 0; i < S.size(); i++) {
    cout << ans[i] << ' ';
  }
  cout << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1872
H, W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))

B = [[-1] * W for _ in range(H)]

now = 0
for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            B[i][j] = now+1
            A[now] -= 1
            if A[now] == 0:
                now += 1
    else:
        for j in range(W)[::-1]:
            B[i][j] = now+1
            A[now] -= 1
            if A[now] == 0:
                now += 1

for line in B:
    print(*line)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e5+100))
#define ARRS ((ll)(1e6+100))
#define ARS ((ll)(1e3+100))
#define HS ((ll)(233))
#define MOD ((ll)(998244353))
#define EP ((double)(1e-9))
#define PI ((double)3.141592653)
#define LG 21
using namespace std;


int main(){
	ll n,l,r;
	vector<pair<ll,ll> > v;
	multiset<ll> st;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>l>>r;
		v.pb({l,r});
	}
	v.pb({0,0});
	sort(v.begin(),v.end());
	n++;
	ll j=0;
	ll pas=0;
	l=0;
	r=n;
	for(int x=-MX; x<=MX; x++){
		while(j<n&&v[j].fr<=x)
			st.insert(v[j].sc),r--,j++;
		while(st.size()&&*st.begin()<=x)l++,st.erase(st.begin());
		pas+=2*min(l,r);
	}
	cout<<pas;
	
}


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

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(string S) {
    bool f = true;
    f &= S[0] == 'A';
    int c = 0;

    for (int i = 2; i < S.size() - 1; i++) {
        c += S[i] == 'C';
    }
    for (int i = 1; i < S.size(); i++) {
        if (S[i] == 'C') continue;
        if (S[i] >= 'a' && S[i] <= 'z') {

        } else f = 0;
    }
    f &= c == 1;
    cout << (f ? "AC" : "WA") << endl;


}


void main_(istream &cin) {
    string S;
    cin >> S;
    solve(S);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
import numpy as np

def python_list_add(in1, in2):
    wrk = np.array(in1) + np.array(in2)
    return wrk.tolist()

N,M,X = map(int,input().split())
book = [list(map(int,input().split())) for _ in range(N)]

ans = float('inf')
for i in range(1,2**N):
    bits = []
    bit = bin(i)[2:].zfill(N)
    check = [0] * M
    cost = 0
    for j in range(N):
        if bit[j] == '1':
            bits.append(j)
    for j in bits:
        check = python_list_add(check,book[j][1:])
        cost += book[j][0]
    if min(check) >= X and ans > cost:
        ans = cost
print(ans if ans != float('inf') else -1)

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

typedef long long ll;

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

int main(){
  ll a;
  cin >> a;
  vector<ll> v(a, 0);
  for(ll i = 0; i < a; i++) cin >> v[i];
  sort(all(v));

  for(ll i = 0; i < a-1; i++){
    if(v[i] == v[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

vector<pair<int, int> > h;

// 1文字固定することを考える。固定したら片方の依存関係を除去する。
// i < j
// j - i = a[i] + a[j]
// a[i] + i = j - a[j] 

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,int> mp;
    ll ans = 0;
    rep(i,n) {
        int sa = i - a[i];
        ans += mp[sa];
        // 予め記録しておく
        int wa = a[i] + i;
        mp[wa]++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n; cin >> n;
  int sum = 0, tmp = 0;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    sum += a; 
    tmp = max(tmp, a);
  }
  sum -= tmp/2;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
#define int long long
using ll = long long;
const ll mod = LLONG_MAX;

int a[2123];
signed main(){
  int N,Z,W;
  cin>>N>>Z>>W;
  rep(i,N)cin>>a[i];

  if(N>1)cout<<max(abs(a[N-1]-W),abs(a[N-2]-a[N-1]))<<endl;
  else cout<<abs(a[N-1]-W)<<endl;
}


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

int main(){
  int i,array[51],array2[51],sum[51]={},c=0,a,b;
  cin>>a>>b;
  for(i=0;i<b;i++){
    cin>>array[i]>>array2[i];
    sum[array[i]-1]++;
    sum[array2[i]-1]++;
  }
  for(i=0;i<a;i++){
    cout<<sum[i]<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(void){
    int N,W;
    int v[101],w[101],valueDP[101][10001];
 
    cin>>N>>W;
    for(int i=1; i<=N; i++) cin>>v[i]>>w[i];
 
    for(int i=0; i<=W; i++) valueDP[0][i]=0;
    for(int i=1; i<=N; i++) valueDP[i][0]=0;
 
    for(int i=1; i<=N;i++){
        for(int j=1; j<=W;j++){
            if(j>=w[i]){
                if(valueDP[i-1][j]<=(valueDP[i-1][j-w[i]]+v[i])){
                    valueDP[i][j]=(valueDP[i-1][j-w[i]]+v[i]);
                }else{
                    valueDP[i][j]=valueDP[i-1][j];
                }
            }else{
                valueDP[i][j]=valueDP[i-1][j];
            }
        }
    }
    
    cout<<valueDP[N][W]<<endl;
    
    return 0;
}


Measured memory_bytes: 6968
using System;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var S = Console.ReadLine();

            var result1 = 0;
            var result2 = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if ((i % 2 == 0 ? '0' : '1') != S[i])
                {
                    result1++;
                }
                if (((i + 1) % 2 == 0 ? '0' : '1') != S[i])
                {
                    result2++;
                }
            }
            Console.WriteLine(Math.Min(result1, result2));
        }
    }
}

Measured memory_bytes: 13116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef pair<int, int> pr;
typedef priority_queue<int> p_int_max;
typedef priority_queue<int, vector<int>, greater<int>> p_int_min;

string s;
int q, ti, fi;
bool rev = false;
deque<char> d;
char ci;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> s >> q;
    rep(i, s.size()) d.push_back(s[i]);
    rep(i, q)
    {
        cin >> ti;
        if (ti == 1)
            rev = !rev;
        else
        {
            cin >> fi >> ci;
            bool loc = (fi - 1) ^ rev;
            // if (loc == false)
            //     cout << fi - 1 << " " << rev << " FRONT\n";
            // else
            //     cout << fi - 1 << " " << rev << " BACK\n";
            if (loc == false)
                d.push_front(ci);
            else
                d.push_back(ci);
        }
    }
    if (rev)
    {
        for (int i = d.size() - 1; i >= 0; i--)
            cout << d[i];
    }
    else
    {
        for (int i = 0; i < d.size(); i++)
            cout << d[i];
    }
    cout << "\n";
}


Measured memory_bytes: 976
import kotlin.math.abs

fun main(args: Array<String>) {
    val n = readInt()
    val a = readIntList().toMutableList()

    val aa = mutableListOf(0)
    var before = 0
    var sum = 0L
    a.forEach {
        aa.add(it)

        sum += abs(it - before)
        before = it
    }
    sum += abs(a[n - 1])

    val str = StringBuilder()
    for (i in 1..n) {
        var ans = sum - abs(aa[i] - aa[i - 1])
        if (i < n) {
            ans -= abs(aa[i] - aa[i + 1])
            ans += abs(aa[i - 1] - aa[i + 1])
        } else {
            ans -= abs(aa[i])
            ans += abs(aa[i - 1])
        }
        str.append("$ans\n")
    }
    println(str.toString())
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 59892
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = inx(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

/*

https://atcoder.jp/contests/abc121/tasks/abc121_d

	ll A, B, ans, cnt1, cnt2, cnt;
	cin >> A >> B;
	ans = 0;
	vl v(50);
	v[0] = 1;
	rep(i, 50) v[i + 1] = v[i] * 2;
	rep2(i, 1, 50){
		cnt1 = min(v[i] / 2, v[i] - (A % v[i]));
		cnt2 = max((ll)0, -1 + (B % v[i]));
		cnt = cnt1 + cnt2;
		print2(cnt1, cnt2);
		if(cnt % 2) ans += v[i];
	}
	print(ans);
	
*/

vl v(100);
vl p(100);

ll rev(ll level, ll x){
	
	if(x <= 0) return 0;
	if(level == 0) return 1;
	if(x == 1) return 0;
	if(x <= 1 + v[level - 1]) return rev(level - 1, x - 1);
	if(x == v[level - 1] + 2) return 1 + p[level - 1]; 
	if(x <= 2 * v[level - 1] + 2) return 1 + rev(level - 1, x - 2 - v[level - 1]) + p[level - 1]; 
	return 1 + 2 * p[level - 1];
	
}

void solve(){
	
	ll N, X, ans;
	cin >> N >> X;
	v[0] = 1;
	rep2(i, 1, 60) v[i] = 3 + 2 * v[i - 1];
	p[0] = 1;
	rep2(i, 1, 60) p[i] = 1 + 2 * p[i - 1];
	ans = rev(N, X);
	print(ans);	
	
}	

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
    
	return 0;
	
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define stkl stack<ll>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
using namespace std;

void solve(){
	int n;
	cin>>n;
	map<string,int> m;
	m["AC"]=0;
	m["WA"]=0;
	m["TLE"]=0;
	m["RE"]=0;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		m[s]++;
	}

	cout<<"AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
}

int main(){
    IOS;
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ss = Console.ReadLine().Split();
            var p = new int[N];
            for (int i = 0; i < N; i++)
            {
                p[i] = int.Parse(ss[i]);
            }

            var pAsk = new int[p.Length];
            pAsk = p.OrderBy(s => s).ToArray();

            var diffNum = 0;
            for (int i = 0; i < N; i++)
            {
                if (p[i] != pAsk[i])
                    diffNum++;
            }

            if (diffNum == 0 || diffNum == 2)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }

        static bool JudgeAsk(int n, int[] p)
        {
            for (int i = 0; i < n - 1; i++)
            {
                if (p[i] > p[i + 1])
                {
                    return false;
                }
            }

            return true;
        }
    }
}

Measured memory_bytes: 13268
#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() {
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N + 1, 0);
    rep(i, N) cin >> a[i + 1];

    rep(i, N) a[i + 1] += a[i];

    vector<vector<ll>> v(41);
    int cnt = 0;
    for (int l = 0; l < N; ++l) {
        for (int r = l + 1; r < N + 1; ++r) {
            v[40].push_back(a[r] - a[l]);
            ++cnt;
        }
    }

    ll ans = 0;

    int min_bit = 40;
    for (int i = 39; i >= 0; --i) {
        rep(j, v[min_bit].size()) {
            if (v[min_bit][j] & (1LL << i)) {
                v[i].push_back(v[min_bit][j]);
            }
        }

        if (v[i].size() >= K) {
            ans |= (1LL << i);
            min_bit = i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 14164
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String
    }
    if s <= "2019/04/30".to_string() {
        println!("Heisei");
    } else {
        println!("TBD");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << w+1 << ": "  


int main()
{
    int n;
    lli d;
    cin >> n >> d;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        lli x,y;
        cin >> x >> y;
        if(x*x+y*y<=d*d)
            ans+=1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3548
#include <iostream>
int gcc(int x,int y);
int main(){
  int x,y;
  std::cin>>x>>y;
  if(x<y){
    int tmp=x;
    x=y;
    y=tmp;
  }
  while(true){
    int r=x%y;
    if(r==0) break;
    x = y;
    y = r;
  }
  std::cout<<y<<"\n";
  return 0;
}


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

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

  string res = "Good";
  for(int i=0 ; i < 3 ; ++i ){
    if(S[i]==S[i+1]) res ="Bad";
  }
  
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int gcd(int x, int y){
	if (x < y){
		int temp = x;
		x = y;
		y = temp;
	}
	if (x % y) return gcd(y, x%y);
	return y;
}


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	int ans = a[0];
	for (int i = 1; i < n; i++){
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
 	return 0;
 }

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

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

  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  list<ll> ans_list;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      ans_list.push_front(a[i]);
    } else {
      ans_list.push_back(a[i]);
    }
  }

  if (n % 2 == 0) {
    auto itr = ans_list.rbegin();
    while (itr != ans_list.rend()) {
      printf("%ld ", *itr++);
    }
  } else {
    auto itr = ans_list.begin();
    while (itr != ans_list.end()) {
      printf("%ld ", *itr++);
    }
  }
  printf("\n");
}


Measured memory_bytes: 11140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

int a[200005],b[200005];

int main()
{
	ios::sync_with_stdio(false);
	int n,l,r,k,w;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i]>>b[i];
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if(n%2==0)
	{
		k=n/2;
		w=b[k]+b[k+1]-a[k]-a[k+1]+1;
		if(w<0) w=0;
		cout<<w;
	}
	else
	{
		k=(n+1)/2;
		w=b[k]-a[k]+1;
		if(w<0) w=0;
		cout<<w;
	}
	return 0;
}




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

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

  int count = 0;
  int ans = 0;
  rep(i,3) {
    if (s[i] == 'R') count++;
    else count = 0;
    ans = max(ans,count);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3588
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define SIZE(a) (int)((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}


signed main()
{
  int N, M; cin >> N >> M;

  cout << (1900*M + 100*(N-M)) * (1<<M) << endl;

  return 0;
}


Measured memory_bytes: 256
n,p=map(int,input().split())
a=list(map(int,input().split()))
d={0:0,1:0}
for i in range(n):
  d[a[i]%2]+=1
q=2**d[0]
ans=0
m=d[1]
f=[1]
for i in range(1,m+1):
  f+=[f[-1]*i]
for i in range(m+1):
  if i%2!=p:continue
  ans+=q*f[m]//f[i]//f[m-i]
print(ans)

Measured memory_bytes: 61924
#include <stdio.h>          // printf(), fprintf(), scanf()
#include <stdlib.h>         // exit()
#include <stdbool.h>

#define SZ_FIELD 100
#define QUE_SIZE 10000
#define MAX_M 10000

typedef struct que_tbl
{
	int x;
	int y;
} que_t;

int N, M;
char field[SZ_FIELD][SZ_FIELD + 1];
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = { 0,-1, 0, 1};
que_t queue[QUE_SIZE];
int mx[MAX_M];
int my[MAX_M];
int que_in;
int que_out;
int ix;

void
cleanup(int ecode)
{
	exit(ecode);
}

int
que_empty()
{
	return que_in == que_out;
}

void
que_push(int x, int y)
{
	queue[que_in].x = x;
	queue[que_in].y = y;
	que_in = (que_in + 1) % QUE_SIZE;

	if (que_in == que_out)
	{
		fprintf(stderr, "Queue overflow. size:%d\n", QUE_SIZE);
		cleanup(1);
	}
}

void
que_pop()
{
	if (que_out == que_in)
	{
		fprintf(stderr, "Queue underflow\n");
		cleanup(1);
	}

	que_out = (que_out + 1) % QUE_SIZE;
}

void
que_front(que_t *que)
{
	que->x = queue[que_out].x;
	que->y = queue[que_out].y;
}

void
dfs(int x, int y)
{
	field[y][x] = '.';
	for (int i = 0; i < 4; ++i)
	{
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx && nx < N && 0 <= ny && ny < M && field[ny][nx] == '#')
			dfs(nx, ny);
	}
}

bool
bfs()
{
	que_t que;

	ix = 0;
	while (!que_empty())
	{
		que_front(&que); que_pop();
		int x = que.x, y = que.y;
		if (x == 0 || x == N - 1 || y == 0 || y == M - 1)
			return true;

		for (int i = 0; i < 4; ++i)
		{
			int nx = x + dx[i], ny = y + dy[i];
			if (0 <= nx && nx < N && 0 <= ny && ny < M)
			{
				if (field[ny][nx] == '.')
				{
					field[ny][nx] = ' ';
					que_push(nx, ny);
				}
				else if (field[ny][nx] == '#')
				{
					mx[ix] = nx, my[ix] = ny;
					ix++;
				}
			}
		}
	}

	return false;
}

int
solve()
{
	int cx, cy;

	for (cy = 0; cy < M; ++cy)
	{
		for (cx = 0; cx < N; ++cx)
		{
			if (field[cy][cx] == '&')
				break;
		}

		if (cx < N)
			break;
	}

	que_in = 0;
	que_out = 0;

	field[cy][cx] = ' ';
	que_push(cx, cy);

	int count = 0;
	while (!bfs())
	{
		que_in = 0;
		que_out = 0;
		for (int i = 0; i < ix; ++i)
		{
			dfs(mx[i], my[i]);
			que_push(mx[i], my[i]);
		}

		count++;
	}

	return count;
}

int
main(int argc, char **argv)
{
	while (true)
	{
		scanf("%d%d", &N, &M);
		if (N == 0 && M == 0)
			break;

		for (int i = 0; i < M; ++i)
			scanf("%s", &field[i][0]);

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

	return 0;
}


Measured memory_bytes: 1840
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  int num = 0;

  int n; cin >> n;
  vector<int> v(n);

  for (int i = 0; i < n; ++i) cin >> v[i];

  num = 0;
  for (int i = 0; i < n; ++i) {
    bool flag = true;
    for (int j = 0; j < i; ++j) {
      if (v[j] > v[i]) flag = false;
      if (!flag) break;
    }
    if (flag) ++num;
  }
  
  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------


int main()
{
	int x, y;

	cin >> x >> y;

	cout << x + y * 0.5 << endl;

	return 0;
}



Measured memory_bytes: 256