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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int diff(int n) {
  return (10 - n % 10) == 10 ? 0 : (10 - n % 10);
}

int main() {
  vector<int> v;
  load(v, 5);

  // 一番最後にする物(=待ち時間がもっとも長いもの)を選ぶ
  int index = -1, ma = 0;
  for (int i = 0; i < 5; ++i) {
    int dif = diff(v[i]);
    if (ma < dif) {
      index = i;
      ma = dif;
    }
  }

  int sum = 0;
  for (int i = 0; i < 5; ++i) {
    if (i == index) {
      sum += v[i];
    } else {
      sum += v[i] + diff(v[i]);
    }
  }
  p(sum);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(){
    int l,r;
    cin >> l >> r;
    int min = 2019;

    int check=0;

    for(int i=l;i<r;i++){
        for(int j=i+1;j<=r;j++){

            int tmpi=i%2019;
            int tmpj=j%2019;
            if(tmpj==0 || tmpi==0){
                check=1;
                min=0;
                break;
            }

            int tmp=tmpi*tmpj % 2019;
            if(tmp<min) min=tmp;
        }
        if(check) break;
    }

    cout << min << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 998244353
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

vvl G(10005);
vl ans(10005);
bool visit[10005];
vl c(10005,INF);

void dfs(ll u){
    visit[u] = true;
    ans[u] = c.back();
    c.pop_back();
    for(auto v : G[u]){
        if(visit[v]) continue;
        dfs(v);
    }
}

int main(){
    ll n; cin >> n;
    rep(i,n-1){
        ll a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    c.resize(n,0);
    rep(i,n) cin >> c[i];
    sort(all(c));
    ll sum = 0;
    rep(i,n-1){
        sum += c[i];
    }
    dfs(0);
    cout << sum << endl;
    rep(i,n) cout << ans[i] << " ";
}


Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int R = sc.nextInt();
        int d = sc.nextInt();
        int counter = 0;
        for(int i = L;i < R+1;i++){
            if(i % d == 0){
                counter++;
            }
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 35476
#line 1 "template.cpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 768
#include <iostream>
#include <utility>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    const pair<ll, ll> dp = make_pair(a - b, a - c);
    map<pair<ll, ll>, ll> m;
    const pair<ll, ll> p0 = make_pair(0, 0);
    m[dp] = 0;
    queue<pair<ll, ll>> q;
    q.push(dp);
    while(!q.empty() && m.count(p0) == 0){
        const auto p = q.front();
        q.pop();

        pair<ll, ll> p2 = make_pair(p.first, p.second + 1);
        if(m.count(p2) == 0){
            m[p2] = m[p] + 1;
            q.push(p2);
        }

        p2 = make_pair(p.first - 1, p.second - 1);
        if(m.count(p2) == 0){
            m[p2] = m[p] + 1;
            q.push(p2);
        }

        p2 = make_pair(p.first + 1, p.second);
        if(m.count(p2) == 0){
            m[p2] = m[p] + 1;
            q.push(p2);
        }

        p2 = make_pair(p.first + 2, p.second + 2);
        if(m.count(p2) == 0){
            m[p2] = m[p] + 1;
            q.push(p2);
        }

        p2 = make_pair(p.first - 2, p.second);
        if(m.count(p2) == 0){
            m[p2] = m[p] + 1;
            q.push(p2);
        }

        p2 = make_pair(p.first, p.second - 2);
        if(m.count(p2) == 0){
            m[p2] = m[p] + 1;
            q.push(p2);
        }
    }
    cout << m[p0] << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

vector <string> v;
void rec(string s, int n, int curr, set <char> ss)
{
	if(curr == n) {
		v.pb(s);
		return;
	}
	
	for(auto x : ss)
	rec(s + x, n, curr + 1, ss);
	
	for(int i = 1; i < 26; i++) {
		char c = char(i + 97);
		char p = char(i - 1 + 97);
		
		size_t poss = s.find(p);
		if(poss != string::npos) {
			ss.insert(c);
			rec(s + c, n, curr + 1, ss);
		}
		else break;
	}
}
int main()
{
	boost;
	int n;
	cin >> n;
	set <char> ss;
	ss.insert('a');
	
	rec("a", n, 1, ss);
	sort(all(v));
	v.resize(unique(all(v)) - v.begin());
	for(auto x : v)
	cout << x << '\n';
}


Measured memory_bytes: 101860
N, M = map(int, input().split())
S = [0]*M
C = [0]*M
num = [-1]*N

for i in range(M):
    s, c = map(int, input().split())
    if num[s-1] == -1:
        num[s-1] = c
    elif num[s-1] == c:
        continue
    else:
        print(-1)
        break
else:
    if num[0] == 0:
        if N == 1:
            print(0)
        else:
            print(-1)
    else:
        for i in range(N):
            if num[i] == -1:
                if i == 0 and N != 1:
                    num[i] = 1
                    continue
                num[i] = 0
        print(''.join(map(str, num)))

Measured memory_bytes: 38384
# Aiで貪欲する
# kが何度も登場するっていう罠？

n, m = map(int, input().split())
h = dict()
for _ in range(n):
    k, v = map(int, input().split())
    if k in h:
        h[k] += v
    else:
        h[k] = v
h = sorted(h.items(), key=lambda x: x[0])


ans = 0
for k, v in h:
    while v > 0:
        if m <= 0:
            print(ans)
            exit()
        else:
            v -= 1
            ans += k
            m -= 1
print(ans)


Measured memory_bytes: 24144
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(void)
{
  int D,T,S;
  cin >> D >> T >> S;
  // cout << S << endl;
  string ans;
  if (D > T * S) ans = "No";
  else ans = "Yes";

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


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

const long double e = 0.0000001;

long double f(long double x1,long double y1,long double x2,long double y2,long double X){
    return (y1*(x2-X)+y2*(X-x1))/(x2-x1);
}

int main(){
    while(1){
        int m;
        long double x[102],y[102];
        scanf("%d",&m);
        if(m == 0)break;
        for(int i = 0 ; i < m ; i ++){
            scanf("%Lf%Lf",&x[i],&y[i]);
        }
        x[m] = x[0];
        y[m] = y[0];
        
        int ret = 0;
        for(long double _X = -2000.0 ; _X < 2000.0 ; _X += 1.0){
            vector<long double> Y[2];
            long double X[2] = { _X+e , _X+1.0-e };
            for(int i = 0 ; i < m ; i ++){
                for(int j = 0 ; j < 2 ; j ++){
                    if((x[i]-X[j])*(x[i+1]-X[j]) < 0){
                        Y[j].push_back(2500.0+f(x[i],y[i],x[i+1],y[i+1],X[j]));
                    }
                }
            }
            sort(Y[0].begin(),Y[0].end());
            sort(Y[1].begin(),Y[1].end());
            int a[5002] = {};
            for(int i = 0 ; i < Y[0].size() ; i += 2){
                long double l = min(Y[0][i],Y[1][i]), r = max(Y[0][i+1],Y[1][i+1]);
                if((int)(l+e*e) <= (int)(r+1.0-e*e)){
                    a[(int)(l+e*e)] ++;
                    a[(int)(r+1.0-e*e)] --;
                }
            }
            for(int i = 1 ; i < 5002 ; i ++){
                a[i] += a[i-1];
                if(a[i] > 0){
                    ret ++;
                }
            }
        }
        cout << ret << endl;
    }
}

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

using namespace std;

int n, a, b;

int main()
{
	cin >> n;
	if(n == 1) cout << "Hello World" << endl;
	else if(n == 2)
	{
		cin >> a >> b;
		cout << a+b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define DEBUG 0

/**
 * File    : F2.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-6-2 00:47:04
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <bitset>
using namespace std;

typedef long long ll;

bitset<2010> dp_L[2010];
bitset<2010> dp_R[2010];
bitset<2010> W[2010];

int main()
{
  int N;
  cin >> N;
  for (auto i = 1; i < N; i++)
  {
    string S;
    cin >> S;
    for (auto j = 0; j < i; j++)
    {
      if (S[j] == '0')
      {
        W[j][i] = 1;
      }
      else
      {
        W[i][j] = 1;
      }
    }
  }
  for (auto i = 0; i < N; i++)
  {
    dp_L[i][i] = 1;
    dp_R[i][i] = 1;
  }
  for (auto n = 1; n < N; n++)
  {
    for (auto a = 0; a + n < N; a++)
    {
      int b = a + n;
      if ((dp_R[a + 1] & dp_L[b] & W[a]).any())
      {
        dp_L[b][a] = 1;
      }
      if ((dp_R[a] & dp_L[b - 1] & W[b]).any())
      {
        dp_R[a][b] = 1;
      }
    }
  }
  int ans = (dp_R[0] & dp_L[N - 1]).count();
  cout << ans << endl;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    int h,n;
    cin >> h >> n;

    vector<ll> a;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    ll total = accumulate(ALL(a),0);
    if(total >= h){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4272
time = 0
def count(s):
    if s== []:
        return
    global time 
    isend = True
    div = s.index(min(s))
    minuted = s[div]
    time += minuted
    for i in range(len(s)):
        s[i] -= minuted
        if s[i] != 0:
            isend = False
    else:
        nextlistf = []
        nextlistl = []
        for i in range(div):
            nextlistf.append(s[i])
        for i in range(1, len(s) - div):
            nextlistl.append(s[i + div])
        count(nextlistf)
        count(nextlistl)


n = int(input())
s = list(map(int, input().split()))
count(s)
print(time)


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

int main() {
    int arr[3];
    for (int i = 0; i < 3; i++) {
        cin >> arr[i];
    }

    sort(begin(arr), end(arr));
    cout << arr[0] << " " << arr[1] << " " << arr[2] << endl;

    return 0;
}



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

typedef pair<string, string> P;

int n;
int m;
int f;
string temp[10];
map<string, map<string, int> > ma;
set<P> se;
set<string> word;

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

  cin >> n >> f;
  for(int i = 0;i < n;++i){
    cin >> m;
    for(int j = 0;j < m;++j){
      cin >> temp[j];
      word.insert(temp[j]);
      if(j != 0){
	for(int k = 0;k < j;++k){
	  ++ma[temp[k]][temp[j]];
	  ++ma[temp[j]][temp[k]];
	  if(ma[temp[k]][temp[j]] >= f){
	    if(temp[k] < temp[j]){
	      P p;
	      p.first = temp[k];
	      p.second = temp[j];
	      se.insert(p);
	    }else{
	      P p;
	      p.first = temp[j];
	      p.second = temp[k];
	      se.insert(p);
	    }
	  }
	}
      }
    }
  }

  /*
  cout << "start debug------------------------------------------------" << endl;
  for(set<string>::iterator itr1 = word.begin();itr1 != word.end();itr1++){
    for(set<string>::iterator itr2 = ++itr1;itr2 != word.end();itr2++){
      cout << *itr1 << ' ' << *itr2 << ' ' << ma[*itr1][*itr2] << endl;
    }
  }
  cout << "end debug--------------------------------------------------" << endl;
  */

  cout << se.size() << endl;
  for(set<P>::iterator itr = se.begin();itr != se.end();itr++){
    cout << itr -> first << ' ' << itr -> second << endl;
  }

  return 0;
}



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

int main (){
  int n,i,*A,B[10001]={},*C,j;
  scanf("%d",&n);
  A=(int *)malloc(sizeof(int)*(n+1));
  C=(int *)malloc(sizeof(int)*(n+1));
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    B[A[i]]++;
  }
  for(i=1;i<10001;i++){
    B[i]+=B[i-1];
  }
  for(i=n;i>=0;i--){
    C[B[A[i]]]=A[i];
    B[A[i]]--;    
  }
  for(i=1;i<=n;i++){
    if(i-1) printf(" ");
    printf("%d",C[i]);
  }
  printf("\n");
  free(A);
  free(C);
  return 0;
}
  
  
  



Measured memory_bytes: 17076
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int X, Y;
	cin >> X >> Y;
	cout << X + (Y / 2) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
import itertools
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a, b, c = MII()
    if (a*b*c)%2==0:
        print(0)
    else:
        print(min(a*b,a*c,b*c))

if __name__ == '__main__':
    main()

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


using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;
#define fin "\n"
void chmin(LL &a,LL b){a=min(a,b);}
LL f(LL a,LL b){return (a+b-1)/b;}
int main(){
    LL A,B,N;
    cin>>A>>B>>N;
    LL res=1e15;
    for(LL i=1;i<=1000000;i++)
        if(B%i==0){
            {
                LL m=i;
                LL b=B/m;
                if(B/m<=N)
                    for(LL a=1;a<=N;a++)
                        chmin(res,abs(a*m-A));
                    
                
            }
            {
                LL m=B/i;
                LL b=B/m;
                if(B/m<=N)
                    for(LL a=1;a<=N;a++)
                        chmin(res,abs(a*m-A));
                    
            }
        }
    cout<<res<<fin;

    return 0;
}

Measured memory_bytes: 3208
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

#define ll long long
#define ull unsigned long long

int main()
{
    int n;
    std::cin >> n;
    int a;
    std::vector<int> vec(n + 1);
    for (int i = 1; i < n + 1; ++i) { vec[i] = 0; }
    for (int i = 1; i < n; ++i)
    {
        std::cin >> a;
        vec[a]++;
    }
    for (int i = 1; i < n + 1; ++i) { std::cout << vec[i] << std::endl; }

    return 0;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
//#define int long long
using namespace std;

signed main() {
	string s;
	cin >> s;
	int a = stoi(s.substr(0, 2));
	int b = stoi(s.substr(2, 2));
	if (1 <= a && a <= 12) {
		if (1 <= b && b <= 12) cout << "AMBIGUOUS" << endl;
		else cout << "MMYY" << endl;
	}
	else {
		if (1 <= b && b <= 12)cout << "YYMM" << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <vector>
#include <cmath>
using namespace std;

const int MAX = 85;
const int LIM = 6500;

int n, m;
int A[MAX][MAX], B[MAX][MAX];
bool am[MAX][MAX][LIM];
vector <int> S[MAX][MAX];

void faSeturi() {
    am[1][1][(int)abs(A[1][1] - B[1][1])] = 1;
    S[1][1].push_back(abs(A[1][1] - B[1][1]));

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i == 1 && j == 1)
                continue;
            for (auto x: S[i][j - 1]) {
                int bag = abs(x + (A[i][j] - B[i][j]));
                if (bag < LIM && !am[i][j][bag])
                    S[i][j].push_back(bag),
                    am[i][j][bag] = 1;
                bag = abs(x - (A[i][j] - B[i][j]));
                if (bag < LIM && !am[i][j][bag])
                    S[i][j].push_back(bag),
                    am[i][j][bag] = 1;
            }
            for (auto x: S[i - 1][j]) {
                int bag = abs(x + (A[i][j] - B[i][j]));
                if (bag < LIM && !am[i][j][bag])
                    S[i][j].push_back(bag),
                    am[i][j][bag] = 1;
                bag = abs(x - (A[i][j] - B[i][j]));
                if (bag < LIM && !am[i][j][bag])
                    S[i][j].push_back(bag),
                    am[i][j][bag] = 1;
            }
            
        }
    }
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            scanf("%d", &A[i][j]);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            scanf("%d", &B[i][j]);

    faSeturi();

    int ans = S[n][m].back();
    for (auto x: S[n][m])
        ans = min(ans, x);

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 141312
//
//  main.c
//  Surrounding Area
//
//  Created by x15071xx on 2016/06/22.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//

#include <stdio.h>

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

void paint (char field[51][51],int x,int y,char S,int h,int w) {
    int i;
    if (S == 'W') {
        for (i=0; i<4; i++) {
            if (y+dy[i] >= 0 && y+dy[i] < h && x+dx[i] >= 0 && x+dx[i] < w && field[y+dy[i]][x+dx[i]] == '.') {
                field[y+dy[i]][x+dx[i]] = 'w';
                paint(field, x+dx[i], y+dy[i], 'W', h, w);
            }
        }
    } else if (S=='B'){
        for (i=0; i<4; i++) {
            if (y+dy[i] >= 0 && y+dy[i] < h && x+dx[i] >= 0 && x+dx[i] < w ) {
                if (field[y+dy[i]][x+dx[i]] == 'w') {
                    field[y+dy[i]][x+dx[i]] = 'x';
                    paint(field, x+dx[i], y+dy[i], 'B', h, w);
                } else if (field[y+dy[i]][x+dx[i]] == '.'){
                    field[y+dy[i]][x+dx[i]] = 'b';
                    paint(field, x+dx[i], y+dy[i], 'B', h, w);
                }
                
                
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    int i,j,k;
    while (1) {
        char field[51][51];
        int w,h,b;
        int count_w=0,count_b=0;
        for (i=0; i<50; i++) {
            for (j=0; j<50; j++) {
                field[i][j] = 0;
            }
        }
        
        scanf("%d %d",&w,&h);
        
        if (w==0&&h==0) {
            break;
        }
        for (i=0; i<h; i++) {
            scanf("%s",field[i]);
        }
        
        for (i=0; i<h; i++) {
            for (j=0; j<w; j++) {
                if (field[i][j] == 'W') {
                    paint(field, j, i, 'W', h, w);
                }
            }
        }
        
        
        for (i=0; i<h; i++) {
            for (j=0; j<w; j++) {
                
                if (field[i][j] == 'B') {
                    paint(field, j, i, 'B', h, w);
                }
            }
        }

        
        
        for (i=0; i<h; i++) {
            for (j=0; j<w; j++) {
                if (field[i][j] == 'w') {
                    count_w++;
                } else if (field[i][j] == 'b') {
                    count_b++;
                }
            }
        }
        
        
        printf("%d %d\n",count_b,count_w);
        
        
        
        
    }
    
    return 0;
}

Measured memory_bytes: 676
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a, b;
    cin >> a >> b;
    string A, B, ans;
    for (int i = 0; i < b - '0'; i++)
    {
        A.push_back(a);
    }
    for (int i = 0; i < a - '0'; i++)
    {
        B.push_back(b);
    }
    if (A[0] == B[0])
    {
        for (int i = 0; i < min(A.size(), B.size()); i++)
        {
            if (A[i] == B[i])
            {
                if (i == min(A.size(), B.size()) - 1)
                {
                    ans = A;
                }
            }
            if (A[i] > B[i])
            {
                ans = B;
            }
            if (A[i] < B[i])
            {
                ans = A;
            }
        }
    }
    if (A[0] < B[0])
    {
        ans = A;
    }
    if (A[0] > B[0])
    {
        ans = B;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int cnt = 0;
  rep(i, n) if(p[i] != i + 1) cnt++;
  if(cnt == 2 || cnt == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> blueCard(n);
  for (int i = 0; i < n; i++)
    cin >> blueCard[i];
  
  int m;
  cin >> m;
  vector<string> redCard(m);
  for (int i = 0; i < m; i++)
    cin >> redCard[i];
  
  //Card一覧作成終了
  string word;
  int best = 0;
  
  for (int i = 0; i < n; i++) {
    word = blueCard[i];
    int point = 0;
    
    for (int i = 0; i < n; i++) {
      if (word == blueCard[i])
        point++;
    }
    for (int i = 0; i < m; i++) {
      if (word == redCard[i])
        point--;
    }
    
    if (best < point)
      best = point;
  }

  cout << best << endl;
}



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

int main(){
	int N=5, x[N+1], i, ans;
	for(i=1; i<=N; i++){
		cin >> x[i];
	}
	for(i=1; i<=N; i++){
		if(x[i]==0)	ans=i;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
a = list()
a.insert(0,int(input()))
cnta = 0
cntb = 0
while a[cnta] != 0:
	cnta += 1
	a.insert(cnta,int(input()))
for i in a:
	cntb += 1
	if i != 0:
		print("Case "+ str(cntb) + ": " + str(i))
	else:
		break


Measured memory_bytes: 5896
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  if(n % 2 == 1){
    cout << "No\n";
    return 0;
  }else{
    for(int i = 0; i < n; i+=2){
      if(s[i] == 'h' && s[i + 1] == 'i'){
        continue;
      }else{
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 256
nTmp  = input().rstrip().split(' ')
nH = int(nTmp[0])
nW = int(nTmp[1])
nD = int(nTmp[2])

nS = nH * nW
Ans = 0

nDataH = [0 for i in range(nS + 1)]
nDataW = [0 for i in range(nS + 1)]

for i in range(nH):
    sTmp = input().rstrip().split(' ')
    
    for i2 in range(nW):
        nNum = int (sTmp[i2])
        nDataH[nNum] = i
        nDataW[nNum] = i2

nQ = int(input())

nDis = [0 for i in range(nS + 1)]

for i in range(nS + 1):
    nDis[i] = 0
    if i <= nD:
        continue
    
    nTmpDis = nDataH[i] - nDataH[i - nD] 
    if nTmpDis < 0:
        nTmpDis *= -1
    nDis[i] += nTmpDis
    nTmpDis = nDataW[i] - nDataW[i - nD] 
    if nTmpDis < 0:
        nTmpDis *= -1
    nDis[i] += nTmpDis
    nDis[i] += nDis[i - nD]

for i in range(nQ):
    sTmp = input().rstrip().split(' ')
    nL = int(sTmp[0])
    nR = int(sTmp[1])
    Ans = nDis[nR] - nDis[nL]
    print(Ans)


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

int main(){
  string a,b; cin >> a >> b;
  if(a==b){
    cout << "EQUAL" << endl;  
  } else if(a.size()==b.size()){
    for(int i=0; i<a.size(); i++){
      if(a[i]==b[i]) continue;
      else {
        cout << ( a[i]>b[i] ? "GREATER" : "LESS" ) << endl;
        break;
      }
    }
  } else {
    cout << ( a.size()>b.size() ? "GREATER" : "LESS" ) << endl;  
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int a[4];
int main()
{
    int i,j;
    for(i=1; i<=3; i++)
        scanf("%d",&a[i]);
        sort(a+1,a+4);
    printf("%d\n",a[1]+a[2]);
}


Measured memory_bytes: 128
#include <cstdio>
int H, W, bs, res, ret; char c, s[1009][1009], t[5][5], r[] = "JOI";
bool check(int x, int y) { return 0 <= x && x < H - 1 && 0 <= y && y < W - 1 && s[x][y] == t[0][0] && s[x][y + 1] == t[0][1] && s[x + 1][y] == t[1][0] && s[x + 1][y + 1] == t[1][1]; }
int main() {
	scanf("%d%d", &H, &W);
	for(int i = 0; i < H; i++) scanf("%s", s[i]);
	scanf("%s%s", t[0], t[1]);
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			bs += check(i, j); c = s[i][j];
			for(int k = 0; k < 3; k++) {
				res = -check(i - 1, j - 1) - check(i - 1, j) - check(i, j - 1) - check(i, j);
				s[i][j] = r[k];
				res += check(i - 1, j - 1) + check(i - 1, j) + check(i, j - 1) + check(i, j);
				ret = ret > res ? ret : res;
				s[i][j] = c;
			}
		}
	}
	printf("%d\n", ret + bs);
	return 0;
}


Measured memory_bytes: 3716
S = input()

ans = [0 for _ in range(len(S))]

cnt = 0
index = 0
for i in range(len(S)-1):
    if S[i] == "R":
        if S[i+1] == "R":
            cnt += 1
        else:
            if cnt%2 == 0:
                ans[i] += cnt//2 + 1
                ans[i+1] += cnt//2 + 1
            else:
                ans[i] += cnt//2 + 1 
                ans[i+1] += cnt//2 + 2
            cnt = 0
            index = i
    else:
        if S[i+1] == "L":
            if index != i-1:
                cnt += 1
        else:
            if index != i-1:
                cnt += 1
                if cnt%2 == 0:
                    ans[index] += cnt//2
                    ans[index+1] += cnt//2 
                else:
                    ans[index] += cnt//2+1
                    ans[index+1] += cnt//2
            cnt = 0

i += 1
if S[i-1] == S[i]:
    cnt += 1
    if cnt%2 == 0:
        ans[index] += cnt//2
        ans[index+1] += cnt//2 
    else:
        ans[index] += cnt//2+1
        ans[index+1] += cnt//2
        
print(*ans)

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

using namespace std;

int main(){
 double x1,y1,x2,y2,x3,y3;
  cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  double a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  double b=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
  double c=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));

  double s=abs((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))/2.0;
  double r=2*s/(a+b+c);
  
  cout << setprecision(15) << r*max({a,b,c})/(2*r+max({a,b,c})) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int c[50], v[50];

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

    long result=0;

    for(int i=0; i<n; i++){
        if( v[i] > c[i] ) result+=v[i]-c[i];
    }

    cout << result << endl;;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    ll N;
    cin >> N;
    vector<ll> vec(N), num(100010, 0);
    REP(i, N) {
        cin >> vec[i];
        num[vec[i]]++;
    }
    sort(vec.begin(), vec.end());
    
    // calculation
    if (N == 1) {
        cout << 1 << "\n";
    } else if (N == 2) {
        if ((vec[1] - vec[0]) <= 2) {
            // 1, 3 -> 2, 2  o
            // 1, 4 -> 2, 3  x
            cout << 2 << "\n";
        } else {
            cout << 1 << "\n";
        }
    } else {
        ll now_renzoku, max_renzoku = 1;
        for (ll i = 0; i <= 100000; ++i) {
            if (i == 0) {
                now_renzoku = num[i] + num[i+1];
            } else if (i == 100000){
                now_renzoku = num[i-1] + num[i];
            } else {
                now_renzoku = num[i-1] + num[i] + num[i+1];
            }
            max_renzoku = max(max_renzoku, now_renzoku);
        }
        
        cout << max_renzoku << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 1792
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A+...+B problem
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  if (a > b || (n == 1 && a != b)) {
    puts("0");
    return 0;
  }

  ll minsum = (ll)(n - 1) * a + b;
  ll maxsum = (ll)(n - 1) * b + a;
  ll d = maxsum - minsum + 1;
  printf("%lld\n", d);
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int acnt = 0;
  int uncnt = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "A") acnt++;
    if (s == "Un") uncnt++;
    if (acnt < uncnt) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (acnt == uncnt) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}



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

typedef long long LL;

LL A,B,C,D;
map<LL,LL> memo;

LL solve(LL N){
    if(N==0)
        return 0;
    if(N==1)
        return D;
        
    if(memo.count(N))
        return memo[N];
        
    LL l2=(N/2)*2;
    LL r2=((N+1)/2)*2;
    LL l3=(N/3)*3;
    LL r3=((N+2)/3)*3;
    LL l5=(N/5)*5;
    LL r5=((N+4)/5)*5;
    
    LL res=1e18;
    
    if(N<res/D)
        res=N*D;
        
    res=min(res,llabs(l2-N)*D+A+solve(l2/2));
    res=min(res,llabs(r2-N)*D+A+solve(r2/2));
    
    res=min(res,llabs(l3-N)*D+B+solve(l3/3));
    res=min(res,llabs(r3-N)*D+B+solve(r3/3));
    
    res=min(res,llabs(l5-N)*D+C+solve(l5/5));
    res=min(res,llabs(r5-N)*D+C+solve(r5/5));
    
    memo[N]=res;
    
    return res;
}

int main(){
    int T;
    cin>>T;
    
    while(T--){
        memo.clear();
        LL N;
        
        cin>>N;
        cin>>A>>B>>C>>D;
        cout<<solve(N)<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 4500
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))

 # 要素n が全てTrueの配列
good = [True] * n
for im in range(m):
    a,b = list(map(int,input().split()))
    if h[a-1] > h[b-1]:
        good[b-1] = False
    elif h[b-1] > h[a-1]:
        good[a-1] = False
    else:
        good[a-1] = False
        good[b-1] = False

#count(x) リスト中のxの数を返す
print(good.count(True))

Measured memory_bytes: 20108
from collections import Counter
def snum(x):
    return ord(x)-ord('a')

class Bit:
    def __init__(self, n,ls):
        self.size=n
        self.tree=[[0]*26 for _ in range(n+1)]
        self.ls=['']*(n+1)

    def sum(self, i, j):
        i-=1
        res=[0]*26
        for k in range(26):
            i2=i
            j2=j
            while j2>0:
                res[k] += self.tree[j2][k]
                j2 -= j2&-j2
            while i2>0:
                res[k] -= self.tree[i2][k]
                i2 -= i2&-i2
        return 26-res.count(0)
    
    def add(self, i, x):
        self.ls[i] = x
        while i <= self.size:
            self.tree[i][snum(x)]+=1
            i += i & -i

    def change(self, i, x):
        original = self.ls[i]
        self.ls[i]=x
        while i <= self.size:
            self.tree[i][snum(original)] -= 1
            self.tree[i][snum(x)] += 1
            i += i & -i
        

n = int(input())
s = list(input())
bit=Bit(n,s)

for i in range(n):
    bit.add(i+1, s[i])

q = int(input())
for _ in range(q):
    query, a, b = input().split()
    if query=='1':
        bit.change(int(a),b)
    else:
        print(bit.sum(int(a), int(b)))


Measured memory_bytes: 210076
#include<stdio.h>
#include<string.h>

#define M 2000000
#define L 14

char H[M][L];

int getChar( char ch )
{
	if( ch == 'A') {
		return 1;
	} else if( ch == 'C') {
		return 2;
	} else if( ch == 'G') {
		return 3;
	} else if( ch == 'T') {
		return 4;
	} else {
		return 0;
	}
}

long long getKey( char str[] )
{
	long long sum = 0, p = 1, i;
	for ( i=0; i<strlen(str); i++ ) {
		sum += p*( getChar( str[i] ) );
		p *= 5;
	}
	return sum;
}

int find( char str[] )
{
	int i;
	int hashkey, tmp = getKey( str );
	for( i=0; i<M; i++ ) {
		hashkey = ( tmp+ i*tmp )%M;
		if( '\0' == H[ hashkey ][0] ) {
			return 0;
		} else {
		    if( 0 == strcmp( H[ hashkey ], str ) ) {
		    	return 1;
		    }
		}
	}
	return 0;
}

void insert( char str[] )
{
	int i;
	int hashkey, tmp = getKey( str );
	for( i=0; i<M; i++ ) {
		hashkey = ( tmp+ i*tmp )%M;
		if( '\0' == H[ hashkey ][0] ) {
			strcpy( H[ hashkey ], str );
			break;
		}
	}
    return;
}


int main() 
{

	int i, n;
	char str[L], com[9];
	
	for ( i=0; i<M; i++ ) {
		H[i][0] = '\0';
	}
	scanf( "%d", &n );
	for ( i=0; i<n; i++ ) {
		scanf( "%s %s", com, str );
		if ( com[0] == 'i' ){
			insert( str );
		} else {
			if( find( str ) ){
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}

    return 0;
}

Measured memory_bytes: 27952
N=int(input())
for n in range(N):
    gx,gy =map(int,input().split())
    T=[[0 for i in range(16)] for j in range(16)]
    left=[[0 for i in range(16)] for j in range(16)]
    upper=[[0 for i in range(16)] for j in range(16)]
    p=int(input())
    
    for i in range(p):
        x1,y1,x2,y2=map(int,input().split())
        if x1==x2:
            upper[x1][max(y1,y2)]=1
        if y1==y2:
            left[max(x1,x2)][y1]=1
    
    for i in range(16):
        for j in range(16):
            if i==0 and j==0:
                T[i][j]=1
            elif i==0 and j>=1 and upper[i][j]==0:
                T[i][j]=T[i][j-1]
            elif i>=1 and j==0 and left[i][j]==0:
                T[i][j]=T[i-1][j]
            else:
                if left[i][j]==1 and upper[i][j]==1:
                    T[i][j]=0
                if left[i][j]==0 and upper[i][j]==1:
                    T[i][j]=T[i-1][j]
                if left[i][j]==1 and upper[i][j]==0:
                    T[i][j]=T[i][j-1]
                if left[i][j]==0 and upper[i][j]==0:
                    T[i][j]=T[i-1][j]+T[i][j-1]
    if T[gx][gy]==0:
        print("Miserable Hokusai!") 
    else:
        print(T[gx][gy])


Measured memory_bytes: 5632
/* attention to typo and overflow */
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;
const int INF=-1+(1<<30)+(1<<30);
void io(){ cin.tie(0);ios::sync_with_stdio(false);} //attention to use of endl
/*printf("%.9Lf\n",cf);*/
const int MOD=1000000007;

template <class T>
class RMQ{
	private:
	vector<T> data;
	int n;
	const T UNDEF;

	T _query(int a, int b, int k, int l, int r){
		if (r <= a || b <= l) return UNDEF;
		if (a <= l && r <= b) return data[k];
		else{
			T left = _query(a, b, 2 * k + 1, l, (l + r) / 2);
			T right = _query(a, b, 2 * k + 2, (l + r) / 2, r);
			return min(left, right);
        }
    }
	public:
	RMQ(int n, T UNDEF) : UNDEF(UNDEF){
		this->n = 1;
		while (this->n < n) this->n *= 2;
		data = vector<T>(this->n * 2, UNDEF);
	}

    void update(int k, T a){
        k += n - 1;
        data[k] = a;
        while (k > 0){
            k = (k - 1) / 2;
            data[k] = min(data[2 * k + 1], data[2 * k + 2]);
        }
    }

    // [a, b)
    T query(int a, int b) { return _query(a, b, 0, 0, n); }

    void update_min(int k, T a){
        if (a < query(k, k + 1)) update(k, a);
    }
};


int main(){
	io();
	int n,q;
	cin>>n>>q;
	RMQ <int> rq(n,INF);
	for(int i=0;i<q;i++){
		bool type;
		int x,y;
		cin>>type>>x>>y;
		if(type){
			cout<<rq.query(x,y+1)<<endl;
		}else{
			rq.update(x,y);
		}
	}


	return 0;
}

Measured memory_bytes: 3116
///apigs property
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
using namespace std;
typedef long long ll;
ll q, dp[555555], a[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
ll mem(ll idx){
    if(idx == n)return 0;
    if(idx > n)return 1e16;
    ll &r = dp[idx];
    if(r != -1)return r;
    r = 1e15;
    for(ll i = idx + 1 ; i <= idx + k ; i++){
        r = min(r , mem(i) + abs(a[i] - a[idx]));
    }
    return r;
}
int main() {
    memset(dp , -1 , sizeof dp);
    fast , cin >> n >> k;
    for(ll i = 1 ; i <= n ; i++)cin >> a[i];
    cout << mem(1);
}


Measured memory_bytes: 26484
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/


int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       double a,b,x;
       cin>>a>>b>>x;
       double h=2*x/(a*a) - b;
       if(h>=0){
          double ans=(b-h)/a;
          double a=atan(ans) * 180.0/pie;
          printf("%0.12f\n",a);
       }else{
          double y=a - (2*x)/(a*b);
          double ans=b/(a-y);
          double a=atan(ans) * 180.0/pie;
          printf("%0.12f\n",a);
       }
    }
}












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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> red_possible(N,0);
    red_possible[0]=1;
    vector<int> balls(N,1);

    for(int i=0; i<M; i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        balls[x]--;
        balls[y]++;

        if (red_possible[x]==1){
            red_possible[y]=1;
        }
        if (balls[x]==0){
            red_possible[x]=0;
        }
    }
    for(int i=0; i<N-1; i++){
        red_possible[i+1]+=red_possible[i];
    }
    cout << red_possible[N-1] << '\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end()
#define int long long
#define double long double

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


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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

long fact(int n){
	if(n==1){
		return 1;
	}else{
		return n*fact(n-1)%MOD;
	}
}

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


	long N, M;
	cin>>N>>M;

	if(abs(N-M) > 1){
		cout<<0<<endl;
	}else if(N-M == 0){
		long a=fact(N);
		long b=fact(M);
		cout<<(a*b*2)%MOD<<endl;
	}else{
		long a=fact(N);
		long b=fact(M);
		cout<<(a*b)%MOD<<endl;
	}

	return 0;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] nd = sc.intarr;
            int n = nd[0];
            int d = nd[1];

            if(n % (d * 2 + 1) == 0)
            {
                wr.wri(n / (d * 2 + 1));
            }
            else
            {
                wr.wri(n / (d * 2 + 1) + 1);
            }

        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{

    ll n,i,j,k,l,a,b;
    cin>>n>>a>>b;
   ll ans=n/(a+b);
   ans*=a;
   k=n%(a+b);
   ans+=min(a,k);
   cout<<ans<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  sort(A.begin(), A.end());
  int n = A.at(N - 1);
  int left = -1, right = N;
  while (right - left > 1) {
    int mid = (left + right) / 2;
    if (A.at(mid) * 2 <= n) left = mid;
    else right = mid;
  }
  
  if (n - A.at(left) * 2 > A.at(right) * 2 - n) cout << n << " " << A.at(right) << endl;
  else cout << n << " " << A.at(left) << endl;
}

Measured memory_bytes: 640
from collections import deque
K=int(input())
que=deque([1,2,3,4,5,6,7,8,9])
for i in range(K):
    a=que.popleft()
    if not a%10==0:
        que.append(a*10+a%10-1)
    que.append(a*10+a%10)
    if not a%10==9:
        que.append(a*10+a%10+1)
print(a)


Measured memory_bytes: 11908
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let () = Scanf.sscanf (read_line ()) "%f %f" (
        fun h w -> 
                if h = 1.0 || w = 1.0 then
                        1
                else
                        let hb = floor (h /. 2.0) in
                        let hl = h -. hb in
                        let wb = floor (w /. 2.0) in
                        let wl = w -. wb in
                                int_of_float (hb *. wb +. hl *. wl)
) |> Printf.printf "%d\n"


Measured memory_bytes: 1024