akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

#define MOD 1000000007

typedef long long ll;

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<ll> x(n, 0), y(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i] > a[j]) {
        x[i]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (a[i] > a[j]) {
        y[i]++;
      }
    }
  }
  ll ans = 0;
  ll tmp = 0;
  if (k%2 == 0) {
    tmp = ((k/2)*(k + 1))%MOD;
  }
  else {
    tmp = (k*((k + 1)/2))%MOD;
  }
  for (int i = 0; i < n; i++) {
    ans += x[i]*tmp;
    ans -= y[i]*k;
    ans %= MOD;
  }
  if (ans < 0) {
    ans += MOD;
  }
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX = 13;
int C[MAX] = {0};
int A[MAX][MAX] = {0};
int N,M,X,ans;
void solve(int sum[], int n) {
    if(n > N) {
        bool flag = true;
        for(int i=1;i<=M;i++) {
            if(sum[i] < X) flag = false;
        }
        if(flag) {
            if(ans == -1) ans = sum[0];
            else ans = min(ans,sum[0]);
        }
        return ;
    }
    solve(sum,n+1);
    int tmp[MAX] = {0};
    copy(sum,sum+MAX,tmp);
    tmp[0] += C[n];
    for(int i=1;i<=M;i++) {
        tmp[i]+=A[n][i];
    }
    solve(tmp,n+1);
}
int main () {
    ios_base::sync_with_stdio(false);
    cin>>N>>M>>X;
    for(int i=1;i<=N;i++) {
        cin>>C[i];
        for(int j=1;j<=M;j++) {
            cin>>A[i][j];
        }
    }
    ans = -1;
    int sum[MAX] = {0};
    solve(sum,1);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3656
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
K = INT()


for i in range(K):
	if S[i] == "1":
		continue
	else:
		print(S[i])
		break

else:
	print(1)

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

int main() {
    int n, a;
    cin >> n >> a;
    n = n % 500;
    if (n <= a) {
        cout << "Yes" << endl;
        return 0;
    }
    if (a == 0) {
        cout << "No" << endl;
        return 0;
    }
    cout << "No" << endl;

    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    multiset<ll> xs;
    ll x[n];
    rep(i, n)
    {
        cin >> x[i];
        xs.insert(x[i]);
    }
    auto itr_b = xs.begin();
    rep(i, n / 2 - 1) itr_b++;
    auto itr_1 = itr_b;
    itr_b++;
    auto itr_2 = itr_b;
    rep(i, n)
    {
        auto itr = xs.find(x[i]);
        if (*itr > *itr_1)
        {
            cout << *itr_1 << endl;
        }
        else
        {

            cout << *itr_2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 14516
#include<bits/stdc++.h>
using namespace std;
const long long N=2e5+5;
const long long inf=0x3f3f3f3f;
struct pl
{
	long long x;long long y;long long jyz;	
}p1[N];
vector <pl> xxx[N],yyy[N],zzz[N*2],fff[N*2];
long long cntx,cnty,cntz,cntf,n,ans=inf;
string s;
bool cjy(pl a,pl b)
{
	if (a.x>b.x) return 0;
	if (a.x<b.x) return 1;
	return a.y<b.y;
}
signed main()
{
	;;;;;
	cin>>n;
	for (long long i=1;i<=n;i++)
	{
		scanf("%lld%lld",&p1[i].x,&p1[i].y);
		cin>>s;
		if (s=="U") p1[i].jyz=1;
		if (s=="R") p1[i].jyz=2;
		if (s=="D") p1[i].jyz=3;
		if (s=="L") p1[i].jyz=4;
	}
	sort(p1+1,p1+n+1,cjy);
	for (long long i=1;i<=n;i++)
	{
		xxx[p1[i].x].push_back(p1[i]);
		yyy[p1[i].y].push_back(p1[i]);
		fff[p1[i].x+p1[i].y].push_back(p1[i]);
		zzz[p1[i].x-p1[i].y+N-5].push_back(p1[i]);
	}
	for (long long i=0;i<N;i++) if (xxx[i].size()>=2)
	{
		long long tans=inf,ty=-1;
		for (long long j=0;j<xxx[i].size();j++)
		{
			if (xxx[i][j].jyz==1) ty=xxx[i][j].y;
			if (xxx[i][j].jyz==3&&ty!=-1) tans=min(tans,xxx[i][j].y-ty); 
		}
		ans=min(ans,5*tans);
	}
	for (long long i=0;i<N;i++) if (yyy[i].size()>=2)
	{
		long long tans=inf,tx=-1;
		for (long long j=0;j<yyy[i].size();j++)
		{
			if (yyy[i][j].jyz==2) tx=yyy[i][j].x;
			if (yyy[i][j].jyz==4&&tx!=-1) tans=min(tans,yyy[i][j].x-tx); 
		}
		ans=min(ans,5*tans);
	}
	for (long long i=0;i<2*N;i++) if (fff[i].size()>=2)
	{
		long long tans=inf,td=-1,tr=-1;
		for (long long j=0;j<fff[i].size();j++)
		{
			if (fff[i][j].jyz==2) tr=fff[i][j].x;
			if (fff[i][j].jyz==3) td=fff[i][j].x;
			if (fff[i][j].jyz==1&&tr!=-1) tans=min(tans,fff[i][j].x-tr); 
			if (fff[i][j].jyz==4&&td!=-1) tans=min(tans,fff[i][j].x-td); 
		}
		ans=min(ans,10*tans);
	}
	for (long long i=0;i<2*N;i++) if (zzz[i].size()>=2)
	{
		long long tans=inf,tu=-1,tr=-1;
		for (long long j=0;j<zzz[i].size();j++)
		{
			if (zzz[i][j].jyz==2) tr=zzz[i][j].x;
			if (zzz[i][j].jyz==1) tu=zzz[i][j].x;
			if (zzz[i][j].jyz==3&&tr!=-1) tans=min(tans,zzz[i][j].x-tr); 
			if (zzz[i][j].jyz==4&&tu!=-1) tans=min(tans,zzz[i][j].x-tu); 
		}
		ans=min(ans,10*tans);
	}
	if (ans==inf) cout<<"SAFE"<<endl;
	else cout<<ans<<endl;
}

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

sum_monster = 0
add = 0

def trp(l, n):
    return l[:n] + [0]*(n-len(l))
B = trp(B, len(A))

for (mons, hero) in zip(A, B):
  hero_added = hero + add
  if mons >= hero_added:
    sum_monster += hero_added
    add = 0
  else:
    sum_monster += mons
    if (hero_added - mons) >= hero:
      add = hero
    else:
      add = (hero_added - mons)
print(sum_monster)

Measured memory_bytes: 83684
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
# define M_PI           3.14159265358979323846

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

    double R;
    cin >> R;
    cout << 2 * M_PI * R << "\n";

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_trust_a() {
	ll M1, D1, M2, D2;
	ll ans = 0;

	cin >> M1 >> D1 >> M2 >> D2;

	if (M1 < M2) {
		ans = 1;
	}
	else {
		ans = 0;
	}

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

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

	solve_trust_a();

	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0
A0 = []
A1 = []
for _ in range(N):
    s = int(input())
    if s % 10 == 0:
        A0.append(s)
    else:
        A1.append(s)
A1.sort()
if len(A1) != 0:
    if sum(A1) % 10 != 0:
        print(sum(A0) + sum(A1))
    else:
        print(sum(A0) + sum(A1[1:]))
else:
    print(0)

Measured memory_bytes: 3064
import std;

const MOD = 10^^9 + 7;

int fac(int n) {
    int res = 1;
    for (int i = 1; i <= n; i++) {
        res = (res * i) % MOD;
    }
    return res;
}

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

long calc(int n, int k) {
    long[long] memo;
    for (int g = k; g >= 1; g--) {
        long a = modPow(k / g, n, MOD);

        long x = a;
        for (int i = g + g; i <= k; i += g) {
            x = (x - memo[i]) % MOD;
            if (x < 0) x += MOD;
        }
        long y = x * g % MOD;
        memo[g] = x;
    }

    long ans = 0;
    foreach (key, val; memo) {
        auto x = key * val % MOD;
        ans = (ans + x) % MOD;
    }
    return ans;
}

void main() {
    int n, k; scan(n, k);
    writeln(calc(n, k));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 8228
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define Sort(a) sort(a.begin(),a.end())
#define cSort(a,cmp) sort(a.begin(),a.end(),cmp)
#define reSort(a) sort(a.rbegin(), a.rend())
static const ll llMAX = numeric_limits<long long>::max();
static const int intMAX = numeric_limits<int>::max();
static const ll  llMIN = numeric_limits<long long>::min();
static const int intMIN = numeric_limits<int>::min();
static const ll d_5 = 100000;
static const ll d9_7 = 1000000007;
static const ll d_9 = 1000000000;
static const double PI=3.14159265358979323846;

int main(void){
  int n,q;
  cin>>n>>q;
  vl x(n),a(q);
  rep(i,n)cin>>x[i];
  rep(i,q)cin>>a[i];
  //Sort(x);
  rep(i,q){
    ll X=a[i];
    ll r=0;
    ll ans=0;
    ll nowsum=0;
    for(ll l = 0; l < n ; l++){
      while(r < n ){
        //rightを右に動かす処理
        if(nowsum+x[r]<=X/*条件*/){
          nowsum+=x[r];
          r++;
        }else{
          break;
        }
      }
      //この時点では、[l,r]が条件を満たしていない状況
      //何かしらの処理
      ans+=r-l;
      if(l == r){   // leftがrightに追いついたら
        //どうにかする
        r++;
        //lも動かしたら、forのところとダブることに注意
      }else{
      nowsum-=x[l];
        ;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

//<<std::setprecision(30)


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    vector<ll> d(N,0);
    set<ll> se;
    for(ll i=0;i<N;i++){
        cin>>d[i];
        se.insert(d[i]);
    }print(se.size())
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int n; cin>>n;
    string ans;
    while(n > 0){
        int x = (n-1)%26;
        char c = 'a'+x;
        ans += c;
        n = (n-1)/26;
    }
    reverse(all(ans));
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100001
#define MOD 1000000007
typedef long long ll;
 
int par[MAX],rank[MAX];
 
void init(int N){
    for(int i = 0 ; i < N ; i++){
	par[i] = i;
	rank[i] = 0;
    }
}
 
int find(int x){
    if(par[x] == x){
	return x;
    }
    return par[x] = find(par[x]);
}
 
void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]){
	par[x] = y;
    }else{
	par[y] = x;
	if(rank[x] == rank[y]){
	    rank[x]++;
	}
    }
}
 
bool same(int x,int y){
    return (find(x) == find(y));
}
 
ll mod_pow(ll x,ll n){
    if(n == 0) return 1;
    ll res = mod_pow(x*x%MOD,n/2);
    if(n & 1) res = res*x%MOD;
    return res;
}
 
int main(){
    int N,M,a,b;
    while(cin >> N >> M,N){
	init(N);
	for(int i = 0 ; i < M ; i++){
	    cin >> a >> b; a--; b--;
	    unite(a,b);
	}
	ll cnt = 0;
	bool visited[MAX] = {false};
	for(int i = 0 ; i < N ; i++){
	    int x = find(i);
	    if(!visited[x]){
		visited[x] = true;
		cnt++;
	    }
	}
	ll res = mod_pow(2,cnt);
	if(cnt != N) ++res;
	cout << res%MOD << endl;
    }
    return 0;
}

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

int main() {
  int a;
  int b;
  cin >> a;
  cin >> b;
  int x = (a+b) /2;
  if( (a+b)%2 == 0) {
    cout << x << endl;
  } else {
    cout << x+1 << endl;
  }
}


Measured memory_bytes: 3608
n,m=map(int,input().split())
A=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append([a,b])
A.sort()

ans=0
while m>0:
    now=A.pop(0)
    if now[1]>m:
        ans+=now[0]*m
        m=0
    else:
        ans+=now[0]*now[1]
        m-=now[1]
print(ans)

Measured memory_bytes: 20064
#include <iostream>

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

  if (a+b==15)
    std::cout << '+' << std::endl;
  else if (a*b==15)
    std::cout << '*' << std::endl;
  else
    std::cout << 'x' << std::endl;

  return 0;
}


Measured memory_bytes: 256
def pre_c(n, mod):
    f = [0] * (n + 1)
    g = [0] * (n + 1)
    for i in range(n + 1):
        if i == 0:
            f[i] = 1
            g[i] = 1
        else:
            f[i] = (f[i - 1] * i) % mod
            g[i] = pow(f[i], mod - 2, mod)

    return f, g
n, m, k = map(int,input().split())
mod = 998244353
F, G = pre_c(n - 1, mod)
cnt = 0
for i in range(k + 1):
    temp = F[n - 1] * G[i] * G[n - 1 - i] * m * pow(m - 1, n - 1 - i, mod)
    cnt = (cnt + temp) % mod
print(cnt)

Measured memory_bytes: 73540
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// my code goes here
		string s = Console.ReadLine();
		if(s=="AAA"){
			Console.WriteLine("No");
		}else if(s=="BBB"){
			Console.WriteLine("No");
		}else{
			Console.WriteLine("Yes");
		}
	}
}

Measured memory_bytes: 13140
from collections import defaultdict

class UnionFind():

    def __init__(self, n):
        self.par = [i for i in range(n)]

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return
        
        self.par[x] = y
        return


def main():
    N, K, L = map(int, input().split())
    
    uf1 = UnionFind(N)
    uf2 = UnionFind(N)

    # O(K)
    for _ in range(K):
        p, q = map(int, input().split())
        uf1.unite(p-1, q-1)
    
    # O(L)
    for _ in range(L):
        r, s = map(int, input().split())
        uf2.unite(r-1, s-1)

    # O(N) x O(log_N)
    # 理解が少し難しいが、根ペアをキーに加算していく 
    # => 根から見ると、連結している頂点数（自身を含む）を数えている。
    cnts = defaultdict(int)
    for i in range(N):
        pos = (uf1.root(i), uf2.root(i))
        cnts[pos] += 1

    ans = []
    for i in range(N):
        pos = (uf1.root(i), uf2.root(i))
        ans.append(cnts[pos])

    print(*ans)


if __name__ == '__main__':
    main()
    

Measured memory_bytes: 53240
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
#include<iomanip>
using namespace std;

int main() {
  int N,K;
  double cnt=0;
  int tmp=0;
  int f1=0;
  int f2=0;
  double ans =0;

  cin >> N >> K;

  for(int i = 1; i <= N; i++ ){
    tmp = i;
    cnt= 1.0/N;
    while(tmp < K){
      tmp = tmp*2 ;
      cnt = cnt/2.0;
    }
    ans = ans + cnt;
  }

  cout << setprecision(12) << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
  
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  
typedef long long int ll;
  
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =5*100001;
ll power(ll x, ll n) {
  ll res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
  }
  return res;
}

int32_t main()
{
    

  
    IOS
	double a,b,x;
	cin>>a>>b>>x;
	cout<<fixed<<setprecision(10);
	if(x==a*a*b)
	{
		cout<<0.0000000<<endl;
		return 0;
	}
	if(2*x<=(a*a*b))
	{	
		
		cout<<double(90)-((atan((2*x)/(b*b*a)))*180/M_PI)<<endl;
	}
	else
	{
		cout<<double(90)-(atan((a*a*a)/((2*b*a*a)-2*x))*180/M_PI)<<endl;
	}
	
	
}
  
           
         
       


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

using namespace std;

int gcd(int a, int b) {
		if(a < b) swap(a, b);
		if(b) gcd(b, a % b);
		else return a;
}

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

		vector<int> L(N, 0);
		L[0] = A[0];
		for (int i = 1; i < N; i++) {
				L[i] = gcd(L[i-1], A[i]);
		}

		vector<int> R(N, 0);
		R[0] = A[N-1];
		for (int i = 0; i < N - 1; i++) {
				R[i + 1] = gcd(R[i], A[(N - 2) -i]);
		}

		int ans = 0;
		for (int i = 0; i < N; i++) {
				int t;
				if (i == 0) t = R[N-2];
				else if(i == (N-1)) t = L[N-2];
				else t = gcd(L[i - 1], R[(N - 1) - i - 1]);
				if (ans < t) ans = t;
		}

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


Measured memory_bytes: 1408
#include <iostream>

using namespace std;

int main(){
    int N, num = 1, maxh;
    cin >> N;
    int H[N];
    for(int i = 0; i < N; i++) cin >> H[i];
    maxh = H[0];
    for(int i = 1; i < N; i++){
        if(H[i] >= maxh){
            num++;
            maxh = H[i];
        }
    }
    cout << num << endl;
}

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

int main()
{
  int n;
  cin >> n;
  n %= 10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
    cout << "hon" << endl;
  else if (n == 0 || n == 1 || n == 6 || n == 8)
    cout << "pon" << endl;
  else if(n == 3) cout << "bon" << endl;
  return 0;
}


Measured memory_bytes: 3624
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
S = [list(sr()) for _ in range(H)]
S = np.array([[1 if x == '.' else 0 for x in row] for row in S], np.bool)
up = np.zeros((H, W), np.int32)
down = np.zeros((H, W), np.int32)
right = np.zeros((H, W), np.int32)
left = np.zeros((H, W), np.int32)
for i in range(H-1):
    up[i+1] = (1+up[i]) * S[i]
for i in range(H-1, 0, -1):
    down[i-1] = (1+down[i]) * S[i]
for i in range(W-1):
    left[:, i+1] = (1+left[:, i]) * S[:, i]
for i in range(W-1, 0, -1):
    right[:, i-1] = (1+right[:, i]) * S[:, i]

answer = ((up + down + left + right) * S).max() + 1
print(answer)


Measured memory_bytes: 114396
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18;

/*--------------------------------------------------------------------*/
bool isprime(int n){
	if(n<2) return false;
	for(int i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return true;
}
signed main(){
	int n;cin>>n;
	if(isprime(n)){
		cout<<1<<endl;
		return 0;
	}

	map<int,int> mp;
	vector<pii> fact;

	for(int i=2;i*i<=n;i++){
		int cnt=0;
		while(n%i==0){
			cnt++;
			n/=i;
		}
		if(cnt>0){
			fact.pb(make_pair(i,cnt));
		}
	}
	if(n>1) fact.pb(make_pair(n,1));
	
	int ans=0;
	rep(i,fact.size()){
		int k=fact[i].second;
		for(int j=1;k>0;j++){
			if(k>=j){
				k-=j;
				ans++;
			}else{
				break;
			}
		}
	}
	cout<<ans<<endl;


	return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007
#define INV_10 299473306
#define INF 1000000000
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x=c/b + (c%b?1:0);
	int y=a/d + (a%d?1:0);
	cout << (x<=y?"Yes\n":"No\n");
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   int n;
   cin >> n;
   for(int i = 1;i <= n;i++){
       if(i * 108 / 100 == n){
           cout << i << endl;
           return 0;
       }
   }
   cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{int n;
cin>>n;
vector<int>v;
for(int i=0;i<n;i++)
{
    int c;
    cin>>c;
    v.push_back(c);
}
int prev=0;
int curr=abs(v[v.size()-1]-v[v.size()-2]);
if(v.size()<2)
{
    return 0;
}
if(v.size()==2)
{
    cout<<curr<<endl;
}
else{
for(int i=v.size()-3;i>=0;i--)
{int mid=abs(v[i]-v[i+2])+prev;
int end=abs(v[i]-v[i+1])+curr;
prev=curr;
curr=min(mid,end);
}
cout<<curr<<endl;
}
}

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

typedef long long ll;

int H, W;
int A, B;

const ll M = 1e9+7;

ll rev(ll x) {
	ll res = 1, tmp = M-2;
	res = 1;
	while(tmp) {
		if(tmp&1)
			res = (res * x) % M;
		x = (x*x) % M;
		tmp /= 2;
	}
	return res;
}

ll buf[100100];

int main() {
	cin >> H >> W >> A >> B;

	ll a, b;
	a = 1; b = 1;
	for(int i = 0; i < W; i++) {
		buf[i] = (a * rev(b)) % M;
		a = a * (H-A-1 + i+1) % M;
		b = b * (i+1) % M;
	}
	ll res = 0;
	a = 1; b = 1;
	for(int i = 0; i < W-B; i++) {
		res = (res + buf[W-1 -i] * (a * rev(b) % M)) % M;
		a = a * (A-1 + i+1) % M;
		b = b * (i+1) % M;
	}
	cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int N = 100000 + 5;

int main()
{
	char a,b;
	cin >> a >> b;	
	string s1,s2;
	for(int i = 0; i < b-'0'; i++)
		s1 += a;
	for(int i = 0; i < a-'0'; i++)
		s2 += b;
	string str = min(s1,s2);
	cout << str << endl;
    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define SZ(x)  (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;

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 powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 1e3 + 11;
int n;
int a[N][N];
int pos[N];
int cnT[N];
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < n; j++) {
			cin >> a[i][j];
		}
		cnT[i] = 1;
		pos[i] = a[i][1];
		// cout << i << ' ' << pos[i] << ' ' << a[i][1] << endl;
	}
	int cnt = 0;
	int tmp = n * (n - 1) / 2, tot = 0;
	while (cnt < tmp) {
		int pre = cnt;
		++tot;
		set<int>vis;
		vis.clear();
		for (int i = 1; i <= n; i++) {
			// cout << i << ' ' << pos[i] << endl;
			if (i == pos[pos[i]]) {
				if (vis.find(pos[i]) != vis.end() || vis.find(i) != vis.end())continue;
				cnt++;
				vis.insert(i);
				vis.insert(pos[i]);
				// cout << tot << ' ' << i << ' ' << pos[i] << endl;
				pos[pos[i]] = a[pos[i]][++cnT[pos[i]]];
				pos[i] = a[i][++cnT[i]];
			}
		}
		if (cnt == pre) {
			return cout << -1, 0;
		}
	}
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 4224
n = int(raw_input())
aa = map(int, raw_input().split())

div2 = 0
div4 = 0
for a in aa:
    if a % 4 == 0:
        div4 += 1
    elif a % 2 == 0:
        div2 += 1

if 0 < div2:
    div2 -= 1

if n - 1 <= div4*2 + div2:
    print 'Yes'
else:
    print 'No'



Measured memory_bytes: 11296
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++)
	{
		cin >> d[i];
	}

	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			sum += d.at(i) * d.at(j);
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#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;
typedef long long ll;
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;}




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

int n;
cin >> n;
vector<int> x(n),y(n);
rep(i,n) cin >> x[i] >> y[i] ;

long double len = 0;
int fact = 0;

auto dist = [&](int i, int j) { 
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx*dx+dy*dy, 0.5);
};

vector<int> town(n);
rep(i,n) town[i] = i;
do
{
    rep(i,n-1) len += (long double)dist(town[i],town[i+1]);
    fact++;
} while (next_permutation(all(town)));

long double ans = len / fact ;
cout << fixed << setprecision(10) << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
const int N = (int)1e5+10 ;
const int M = (int)1000000007; 

vector<ll>v[N] ;
ll dp[N][2]  ;
ll check(ll s , ll p , bool state){
    if(dp[s][state]!=-1)return dp[s][state] ;
    if(v[s].size()==1 && v[s][0]==p){
        return dp[s][state] = 1 ;
    }
    ll ans = 1 ;
    for(auto e:v[s]){
        if(e==p)continue ;
       if(state) ans = (ans * check(e , s , 1) + ans * check(e , s , 0)  ) %M ;
       else ans = (ans * check(e , s , 1)  )%M ;
    }
    
    return dp[s][state] = ans%M ;
}


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
     
    int n , i  ;
    cin >> n ;
    for(i=0 ; i<n-1 ; i++){
        ll x , y ;
        cin >> x >> y ;
        v[x].pb(y) ;
        v[y].pb(x) ;
    }
    memset(dp , -1 , sizeof(dp)) ;
    ll ans1 = check(1 , 1 , 1)  ;
    ll ans2 = check(1 , 1 , 0)  ;
    
     cout << (ans1+ans2)%M ;

    return 0 ;
}

Measured memory_bytes: 15616
/*
[abc132] A - Fifty-Fifty
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

string S;

bool solve() {
    sort(S.begin(), S.end());

    return (S[0] == S[1] && S[2] == S[3] && S[0] != S[2]);
}

int main() {
    cin >> S;

    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}


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

bool solve(const vector<string> &W)
{
    const int n = W.size();
    // condition 1
    for (int i = 0; i < n - 1; ++i)
    {
        if (W[i].back() != W[i + 1].front())
        {
            return false;
        }
    }
    // condition 2
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            if (W[i] == W[j])
            {
                return false;
            }
        }
    }
    return true;
}

vector<string> input()
{
    int n;
    cin >> n;
    vector<string> W(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> W[i];
    }
    return W;
}

int main(){
    // int n;
    // cin >>n;
    const vector<string> W = input();
    if (solve(W)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

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

int MARCH(vector<string> vec, int cnt){
  int M=0, A=0, R=0, C=0, H=0;
  rep(i,(int)vec.size()){
    if (vec.at(i).at(0) == 'M') M++;
    if (vec.at(i).at(0) == 'A') A++;
    if (vec.at(i).at(0) == 'R') R++;
    if (vec.at(i).at(0) == 'C') C++;
    if (vec.at(i).at(0) == 'H') H++;
  }
  if (M > 0) cnt++;
  if (A > 0) cnt++;
  if (R > 0) cnt++;
  if (C > 0) cnt++;
  if (H > 0) cnt++;
  return cnt;
}

int combination(int n,int k){//組み合わせ
  double ans = 1;
  if (k == 1){
    return n / k;
  }
  ans = (double)n / k * combination(n-1, k-1);
  return ans;
}

int main(){
  int n;
  cin >> n;
  string s = "MARCH";
  vi c(5);
  rep(i,n){
    string t;
    cin >> t;
    rep(j,5){
      if (t.at(0) == s.at(j)){
        c.at(j)++;
      }
    }
  }
  ll ans = 0;
  rep(i,5)REP(j,i+1,5)REP(k,j+1,5){
    ans += 1LL * c.at(i) * c.at(j) * c.at(k);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int n = max(max(a,b),c);
  cout << a + b + c + n*9 << endl;
}


Measured memory_bytes: 256
N = int(input())
c = input()
W = 0
R = c.count("R")
if N == R or R == 0:
  print("0")
else:
  cnt = N
  for i in range(N):
    if c[i] == "W":
      W = W + 1
    else:
      R = R - 1
    m = max(W, R)
    if m < cnt:
      cnt = m
  print(cnt)

Measured memory_bytes: 68308
#include <iostream>
#include <vector>
#include <set>

int main() {
  int n;
  std::cin >> n;
  int len = 1 << n;
  std::multiset<int> st;
  for (int i = 0, in; i < len; ++i) {
    std::cin >> in;
    st.emplace(-in);
  }
  std::vector<int> obtained_data;
  obtained_data.emplace_back(*st.begin());
  st.erase(st.begin());
  bool ans = true;
  for (int i = 1; i <= n; ++i) {
    std::vector<int> new_data;
    for (const auto &cur : obtained_data) {
      auto iter = st.upper_bound(cur);
      if (iter == st.end()) {
        ans = false;
        break;
      }
      new_data.emplace_back(*iter);
      st.erase(iter);
    }
    if (!ans) break;
    for (const auto &cur : new_data) {
      obtained_data.emplace_back(cur);
    }
    // std::sort(obtained_data.begin(), obtained_data.end());
  }
  if (ans) puts("Yes");
  else puts("No");
  return 0;
}



Measured memory_bytes: 13984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	ll A=0,B=0;
	string s;
	cin>>s;
	for(ll i=0;i<n;i++){
		char now=s[i];
		if(now=='a'){
			if(A+B<a+b){
				A++;
				cout << "Yes";
			}
			else{
				cout << "No";
			}
		}
		else if(now=='b'){
			if(A+B<a+b&&B+1<=b){
				B++;
				cout << "Yes";
			}
			else{
				cout << "No";
			}
		}
		else{
			cout <<"No";
		}
		cout << endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 896
import queue
q = queue.Queue()
for i in range(9):
    q.put(i+1)
    
N = int(input())
for _ in range(N):
    x = q.get()
    y = x%10
    if x%10 != 0:
        q.put(10*x + y-1)
    q.put(10*x + y)
    if x%10 != 9:
        q.put(10*x + y+1)
#     print(_, x)
        
print(x)

Measured memory_bytes: 13132
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }

/*****/

void Main()
{
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int res = 0;
	if (n > k)
	{
		res += x * k;
		n -= k;
		
		res += n * y;
	}
	else
	{
		res = x * n;
	}

	cout << res;
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


Measured memory_bytes: 256
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in range(n):
    t = b[i]
    ci = bisect.bisect_right(c,t)
    ai = bisect.bisect_left(a,t)
    ans += ai*(n-ci)
print(ans)


Measured memory_bytes: 29288
#include <cstdio>
#include <cstdint>
#include <cstddef>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

std::string binpad(uintmax_t b, size_t p) {
  std::string res;
  while (b) {
    res += (b & 1) + '0';
    b >>= 1;
  }
  assert(res.length() <= p);
  res += std::string(p-res.length(), '0');
  std::reverse(res.begin(), res.end());
  return res;
}

void print_as_fpn(uintmax_t e, uintmax_t m) {
  std::string exp = binpad(e, 12);
  m ^= 1_ju << 52;
  std::string mant = binpad(m, 52);
  printf("%s%s\n", exp.c_str(), mant.c_str());
}

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  char buf[64];
  scanf("%s", buf);
  std::string s = buf;

  uintmax_t m0 = 1;
  for (auto si: s) {
    m0 <<= 1;
    m0 |= (si-'0');
  }

  uintmax_t m = m0;
  uintmax_t e = 0;
  while (m0 && n) {
    uintmax_t m1 = 1_ju << (64 - __builtin_clzll(m));
    uintmax_t count = (m1 - m + m0 - 1) / m0;
    if (count > n) {
      m += m0 * n;
      break;
    }
    (m += m0 * count) >>= 1;
    ++e;
    m0 >>= 1;
    n -= count;
  }

  print_as_fpn(e, m);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

int SumOfDigits(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int n;
    cin >> n;
    if(n % SumOfDigits(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String s=scan.next();
		int temp=0;
		for(int i=0;i<4;i++) {
		if(s.charAt(i)=='+') {
			temp++;			
		}
		else if(s.charAt(i)=='-'){
			temp--;
		}
	}
	System.out.println(temp);
	}

}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >>H>>W ;
	if(H==1)A=1;
	
	else if(W==1) A=1;
	
	else A=(H*W)/2+(H%2*W%2);
  	cout<<A;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = ~0U>>1;
using namespace std;
int N, X;
int val[105];
int main(){
	scanf("%d%d", &N, &X);
	for(int i = 1; i <= N; ++i) {
		scanf("%d", &val[i]);
		X -= val[i];
	}
	sort(val + 1, val + N + 1);
	cout << N + X / val[1] << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N =2000+10;
const int mod=1e9+7;
#define P pair<int, int>
const double pi=acos(-1.0);
int main()
{
    double a,b,x,ans;
    cin>>a>>b>>x;
    if(x<=a*a*b/2)
    {
        ans=atan(a*b*b/2/x);
        ans=ans*180.0/pi;
    }
    else
    {
        double y=a*a*b-x;
        ans=atan(2*y/a/a/a);
        ans=ans*180.0/pi;
    }
    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 256
n,k,q=map(int,input().split())
a=[]
for i in range(q):
  A=int(input())
  a.append(A)
l=[k]*n
for i in a:
  l[i-1]+=1
for i in range(n):
  if l[i]-q>0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 55896
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << (N / 2) * ((N + 1) / 2) << endl;

    return 0;
}


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

int main(void){
    int N, K, Abuf;
    vector<int> A;
    long long sumA = 0LL;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        A.push_back(Abuf);
        sumA += Abuf;
    }
    long double meanlength = (long double)sumA / (N + K);
    priority_queue<pair<long double, int>> cutA;
    vector<int> pcsA;
    int numpieces = -N;
    for(int i=0; i<N; i++){
        long double cutnumber = floor(A[i]/meanlength);
        cutnumber = (cutnumber < 1.0 ? 1.0 : cutnumber);
        pcsA.push_back((int)cutnumber);
        cutA.push(pair<long double, int>(A[i]/cutnumber, i));
        numpieces += (int)cutnumber;
    }
    if(numpieces < K){
        for(int j=numpieces; j<K; j++){
            pair<long double, int> topA = cutA.top();
            cutA.pop();
            topA.first = topA.first * pcsA[topA.second] / (pcsA[topA.second] + 1);
            pcsA[topA.second]++;
            cutA.push(topA);
        }
    }
    cout << (int)(ceil(cutA.top().first)) << endl;
    return 0;
}

Measured memory_bytes: 13800
#include <iostream>
using namespace std;
int main() {

	int W, H, x, y, r, f=0;

	cin >> W >> H >> x >> y >> r;

	if (x-r<0 || x+r>W) {
		f = 1;
	}
	else if (y-r<0 || y+r>H) {
		f = 1;
	}


	if (f == 1) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}

	return 0;
}

Measured memory_bytes: 1128
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    for(int i = 1; i <= 9; i++){
        if(N%i==0){
            int M = N / i;
            if(1<= M && M<=9){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int main(){
    int n; cin >> n; 
    vector<int> a(n),A(n);
    rep(i,n){
        cin >> a[i];
        A[i] = a[i];
    }
    sort(A.begin(),A.end());
    rep(i,n){
        if(a[i] <= A[n/2-1]) cout << A[n/2] << endl;
        else cout << A[n/2-1] << endl;
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i< int (n); i++)
int main(){
vector<vector<int>> card(3, vector<int>(3));
rep(i,3){
    rep(j,3){
        cin >> card.at(i).at(j);
    }
}
int N;
vector<int> number(N);
cin >> N;
rep(k,N) cin >> number.at(k);
//入力完了
rep(k,N){
    rep(i,3){
        rep(j,3){
            if (card.at(i).at(j)== number.at(k)) 
            {card.at(i).at(j)=101;}
        }
    }
}
if(
    (card.at(0).at(0)==101 && card.at(0).at(1)== 101 && card.at(0).at(2)==101) ||
    (card.at(1).at(0)==101 && card.at(1).at(1)== 101 && card.at(1).at(2)==101) ||
    (card.at(2).at(0)==101 && card.at(2).at(1)== 101 && card.at(2).at(2)==101) ||
    (card.at(0).at(0)==101 && card.at(1).at(0)== 101 && card.at(2).at(0)==101) ||
    (card.at(0).at(1)==101 && card.at(1).at(1)== 101 && card.at(2).at(1)==101) ||
    (card.at(0).at(2)==101 && card.at(1).at(2)== 101 && card.at(2).at(2)==101) ||
    (card.at(0).at(0)==101 && card.at(1).at(1)== 101 && card.at(2).at(2)==101) ||
    (card.at(0).at(2)==101 && card.at(1).at(1)== 101 && card.at(2).at(0)==101)
){
    cout << "Yes" << endl;
}

else cout << "No" << endl;

}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int n,k;
typedef long long ll;
ll s[100004],ss[100004];
int main(){
    cin>>n>>k;
    for (int i=1;i<=n;i++){
    	ll x;
    	cin>>x;
    	s[i]=s[i-1]+x;
    	ss[i]=ss[i-1]+max(0ll,x);
    	//cout<<s[i];
	}
    ll ans=max(0ll,s[n]);
    for (int i=k;i<=n;i++){
    	int j=i-k;
    	ans=max(ans,ss[n]-(ss[i]-ss[j])+max(0ll,s[i]-s[j]));
    }
   	cout<<ans;
}


Measured memory_bytes: 1792
import java.util.*;


/**
 * Created by Seiya on 2016/10/16.
 */

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int ans  = 0;

        int a = scanner.nextInt();
        int b = scanner.nextInt();

        ans = a + b;

        if(ans < 10) {
            System.out.println(ans);
        }else{
            System.out.println("error");
        }
    } // mainMethod


} // MainClass


Measured memory_bytes: 21844
#include <stdio.h>

int main()
{
    int N;
    int i, k=0;
    scanf("%d",&N);
    
    for(i=1;i<=4;i++){
        if(N % 10 == 2) k++;
        N /= 10;
    }

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

    return 0;
}

Measured memory_bytes: 128
def solve():
    S = input()
    if S[0] != 'A':
        return False
    if S[2:-1].count('C') != 1:
        return False
    n = len(list(filter(lambda c:'a' <= c and c <= 'z', S)))
    if n != len(S) - 2:
        return False
    return True

if solve():
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3060
n = int(input())
l = []
cnt = 0
for i in range(n):
    x = int(input())
    l.append(x)


x = sorted(l)
i=1
same=1
while i<n:
    if x[i]==x[i-1]:
        same += 1
    else:
        if same%2 == 1:
            cnt += 1
        same = 1
    i += 1

cnt += same%2
print(cnt)

Measured memory_bytes: 8276