akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll mx = -1001001001001001000;
    mx = max(a * c, mx);
    mx = max(mx, a * d);
    mx = max(mx, b * c);
    mx = max(mx, b * d);
    //mx = max(mx, 0);
    cout << mx << endl;
    return 0;
}

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

using namespace std;

const int N = 82;
const int Q = 2*(N+2)*2*N;
const int Z = Q/2;
int dp[N][N][Q];
int a[N][N];
int b[N][N];

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(15);
    cout << fixed;
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> b[i][j];
        }
    }

    dp[0][0][Z+a[0][0]-b[0][0]] = 1;
    dp[0][0][Z+b[0][0]-a[0][0]] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int k = 0; k < Q; k++) {
                if (dp[i][j][k]) {
                    if (i < n-1) {
                        int ni = i+1;
                        int nj = j;
                        dp[ni][nj][k+a[ni][nj]-b[ni][nj]] = 1;
                        dp[ni][nj][k-a[ni][nj]+b[ni][nj]] = 1;
                    }
                    if (j < m-1) {
                        int ni = i;
                        int nj = j+1;
                        dp[ni][nj][k+a[ni][nj]-b[ni][nj]] = 1;
                        dp[ni][nj][k-a[ni][nj]+b[ni][nj]] = 1;
                    }
                }
            }
        }
    }

    for (int d = 0; ; d++) {
        if (dp[n-1][m-1][Z+d] || dp[n-1][m-1][Z-d]) {
            cout << d << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 705024
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()
    a.sort(reverse=True)
    upper = 10**9 + 1
    under = 0

    while upper - under > 1:
        middle = (upper + under) // 2

        tk = k
        flg = True
        for ai in a:
            if ai <= middle:
                break

            ta = ai
            tk -= int(ta // middle)
            if tk < 0:
                flg = False
                break

        if flg:
            upper = middle
        else:
            under = middle

    if k == 0:
        print(max(a))
    else:
        print(math.ceil((upper + under) / 2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 33128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<b) rep(i,b) cout<<a;
    if(b<=a) rep(i,a) cout<<b;
}

Measured memory_bytes: 3492
n = gets.to_i
a = gets.split.map(&:to_i)
if n == 2
  puts (a[0] - a[1]).abs
  exit
end
total = a.sum
y = a[0]
z = (total - y).abs
(1..n - 2).each do |i|
  y += a[i]
  b = total - y
  z = [(y - b).abs, z].min
end
puts z

Measured memory_bytes: 27316
#include <stdio.h>
#include <string.h>
int main(void){
    int x,y,a,count,count2;
    count = count2 = 0;
    scanf("%d %d\n",&x, &y);
    x = x - y;
    count2 = x + 1;
    
    printf("%d",count2);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x <= 3) {
			System.out.println(1);
			return;
		}
		outside: for(int i = x; ; i--) {
			for(int j = 2; j * j <= i; j++) {
				for(int k = 2; Math.pow(j, k) <= i; k++) {
					if(Math.pow(j, k) == i) {
						System.out.println(i);
						break outside;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 22356
v[50],p,n,k,X;main(s){for(;n=atoi(gets(v));printf("%d\n",s)){for(p=s=0;p<n;v[++p]=strlen(gets(v+n)));for(;n;)for(n=0,p=++s,k=3956;k/=4;n+=X)for(X=k%4+4;X>0;X-=v[p++]);}}

Measured memory_bytes: 532
import java.util.Scanner;

public class Main {
    /** 最初の借金 */
    public static final double FIRST_DEBT = 100000.0;
    /** 利率 */
    public static final double INTEREST_RATE = 0.05;
    public static final double CEIL_BASE = 1000.0;

    public static void main(String args[]) {
        System.out.println(
            calcDebt(FIRST_DEBT, new Scanner(System.in).nextInt())
        );

    }

    private static int calcDebt(double firstDebt, int nWeeks) {
        double debt = firstDebt;
        for(int i = 0; i< nWeeks; i++) {
            debt = Math.ceil(debt * (1 + INTEREST_RATE) / CEIL_BASE) * CEIL_BASE;
        }
        return (int)debt;
    }
} 

Measured memory_bytes: 17168
def inpl(): return [int(i) for i in input().split()]
def next(v):
    for i in edge[v]:
        if visited[i]:
            continue
        visited[i] = True
        return i
    return -1

from collections import defaultdict
edge = defaultdict(lambda: [])
N, M = inpl()
visited = [False for _ in range(N+1)]
visited[1] = True
for _ in range(M):
    A,B = inpl()
    edge[A].append(B)
    edge[B].append(A)
v = 1
nv = 1
path = [1]
while nv >= 0:
    nv = next(v)
    path.append(nv)
    v = nv
path.pop()
path = list(reversed(path))
v = 1
nv = 1
while nv >= 0:
    nv = next(v)
    path.append(nv)
    v = nv
path.pop()
print(len(path))
print(*path)

Measured memory_bytes: 31344
X = list(input())

for i in range(2**3):
    W = ["+"]*3
    for j in range(3):
        if (i >> j) & 1:
            W[j] = "-"
    formula = ""
    for k,l in zip(X,W+[""]):
        formula += k+l
    if eval(formula) == 7:
        print(formula+"=7")
        break


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

using namespace std;
const int mod=1e9+7;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int maxn=1e3+100;

ll a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    ll sum1=0,sum2=0;
    for(int i=0;i<n;i++){
        sum1+=a[i]*a[i];
        sum2+=2*a[i];
    }
    ll mine=inf;
    for(int i=1;i<=100;i++){
        mine=min(mine,sum1-sum2*i+n*i*i);
    }
    cout<<mine<<endl;
    return 0;
}
/*

ll qpow(ll x,ll y){
    ll sum=1;
    while(y){
        if(y&1)
            sum=sum*x%mod;
        y/=2;
        x=x*x%mod;
    }
    return sum;
}
ll C(ll n,ll m){
    ll low=min(m,n-m);
    ll H=1,L=1;
    for(int i=n-low+1;i<=n;i++)
        H=H*i%mod;
    for(int i=1;i<=low;i++)
        L=L*i%mod;
    return H*qpow(L,mod-2)%mod;
}
*/



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

int main() {
    int n, q; cin >> n >> q;
    queue< pair<string, int> > que;
    for (int i = 0; i < n; ++i) {
        string s; int t;
        cin >> s >> t;
        que.push(make_pair(s, t));
    }
    int sum = 0;
    while (que.size()) {
        pair<string, int> s = que.front(); que.pop();
        sum += min(q, s.second);
        s.second -= q;
        if (s.second > 0) que.push(s);
        else cout << s.first << ' ' << sum << endl;
    }
}

Measured memory_bytes: 6324
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
const int MX = 200005;
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------

void Main(){
  int n,k;
  cin>>n>>k;
  map<int,int>m;
  rep(i,n){
    int a;
    cin>>a;
    m[a]++;
  }
  PQ(int)  q;
  for(auto i:m){
    q.push(i.second);
  }
  int ans = 0;
  while(q.size()>k){
    ans += q.top(); q.pop();
  }
  cout<<ans<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 10744
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n;
	cin >> n;
  	vector<int> v;
	while(n!=0){
		//cout << n << endl;
		if(n%(-2)==0) v.push_back(0);
		else v.push_back(1);
		if(n<0){
			n *= -1;
			n += n%2;
			n /= 2;
		}else{
			n /= (-2);
		}
		if(n==1){
			v.push_back(1);
			break;
		}
		if(n==-1){
			v.push_back(1);
			v.push_back(1);
			break;
		}
	}
	reverse(v.begin(),v.end());
	if((int)v.size()==0) v.push_back(0);
	for(auto u : v){
		cout << u;
	}
	cout << endl;
	return 0;
}


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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  string s;
  cin >> s;
  int cnt = 0,ans = 0;
  rep(i,s.size()){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      cnt++;
    }else{
      ans = max(ans,cnt);
      cnt = 0;
    }
  }
  ans = max(ans,cnt);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  long long n; cin >> n;
  if (n % 2 == 0) {
    long long ans = 0, m1 = 10;
    while (m1 <= n) {
      ans += n / m1;
      m1 *= 5;
    }
    cout << ans << '\n';
  } else {
    cout << "0\n";
  }
  return 0;
}


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

namespace DPL_1_A_Coin_Changing_Problem
{
	class Program
	{
		static void Main ( string[] args )
		{
			//input
			int[] input = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			int price = input[0];

			int[] coinArray = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

			//process
			int[] priceArray = Enumerable.Repeat (int.MaxValue, price + 1).ToArray ();
			priceArray[0] = 0;

			foreach (var coin in coinArray)
			{
				for (int index = 0; index + coin <= price; index++)
				{
					priceArray[index + coin] = Math.Min (priceArray[index + coin], priceArray[index] + 1);
				}
			}

			Console.WriteLine (priceArray[price]);
		}
	}
}



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

int main() {
    int N, x[8], y[8], p[8];
    cin >> N;
    rep(i, N) {
        cin >> x[i] >> y[i];
        p[i] = i;
    }

    double ans = 0;
    do {
        rep(i, N-1) {
            double dx = x[p[i]] - x[p[i+1]];
            double dy = y[p[i]] - y[p[i+1]];
            ans += hypot(dx, dy);
        }
    } while (next_permutation(p, p + N));

    rep(i, N) ans /= i + 1;
    printf("%.9f\n", ans);
}

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

using namespace std;

typedef long long ll;
#define PI 3.14159265







int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int> > g(n + 1);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<bool> visited(n + 1);
    vector<int> sign(n + 1);
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int v = q.front();
        visited[v] = true;
        q.pop();
        for(int i = 0; i < g[v].size(); i++){
            if(!visited[g[v][i]]){
                visited[g[v][i]] = true;
                sign[g[v][i]] = v;
                q.push(g[v][i]);
            }
        }
    }
    bool yap = true;
    for(int i = 1; i <= n; i++){
        yap = visited[i];
    }
    if(yap){
        cout << "Yes" << endl;
        for(int i = 2; i <= n; i++){
            cout << sign[i] << endl;
        }
    }else{
        cout << "No" << endl;
    }


    return 0;

}


Measured memory_bytes: 10312
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char str[4]={0};
    scanf("%s", str);

    if(str[0]==str[2]) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>

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


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

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

    return 0;
}


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

bool is_prime[100006];

int main()
{
    int n;
    cin>>n;
    
    vector<int> v;
    vector<int> :: iterator it;
    
    for(int i=2;i*i<100006;i++)
    {
        if(!is_prime[i])
        {
            for(int j=2*i;j<100006;j+=i)
            {
                is_prime[j]=true;
            }
        }
    }
    
    for(int i=2;i<100005;i++)
    {
        if(!is_prime[i])
        {
            v.push_back(i);
        }
    }
    
    it = upper_bound(v.begin(),v.end(),n);
    
    if(!is_prime[n])
    {
        cout<<n<<endl;
    }
    
    else
    {
        cout<<*it<<endl;

    }
    
    return 0;
}

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

int main(void){
    int H,W,cnt=0;
    cin>>H>>W;
    vector<string> C(H);
    vector<string> ans;

    for(int i=0;i<H;i++){
        cin>>C[i];
        for(int j=0;j<2;j++)
            ans.push_back(C[i]);
    }

    for(int i=0;i<H*2;i++)
        cout<<ans[i]<<endl;  


    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>

#define arrayLength(array) (size_t)((sizeof array) / (sizeof array[0]))

int main() {
  int n = 0, m = 0, x = 0, y = 0, z = 0;

  char s[3][255];
  char t;

  //   scanf(" %d %d %d %d", &n, &m, &x, &y);
  for (int i = 0; i < 4; i++) {
    scanf("%1s", &t);
    switch (t) {
    case '-':
      n -= 1;
      break;
    case '+':
      n += 1;
      break;
    }
  }
  printf("%d", n);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string s;
long long a,b,c,n;
bool ch;
int main()
{
 cin.tie();
 cout.tie();
 ios::sync_with_stdio(false);
 cin>>n;
for(long long i=1;i<=n;i++)
{
   if(i%3!=0&&i%5!=0)
   a+=i;
}
cout<<a;
}


Measured memory_bytes: 3632
function main(input) {
  input=input.trim();
  const n = parseInt(input.split("\n")[0], 10);
  const arrA = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
  var sum=0;
  for(var i=0; i<arrA.length; i++){
    sum+=1/arrA[i];
  }
  console.log(1/sum);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 16010;
bool dp[N],nx[N];
vector<int> v[2];

const int P = 8000;


bool solve(int pos, int id)
{
    // dbg(pos);
    // dbg(v[id]);
    fill(dp,dp+N,false);
    dp[P] = true;
    rep(i,v[id].size())
    {
        fill(nx,nx+N,false);

        int w = v[id][i];
        rep(j,N)if(dp[j])
        {
            int nj = j+w;
            if(nj<N) nx[nj]=true;

            nj = j-w;
            if(nj>=0) nx[nj]=true;
        }

        rep(j,N) dp[j]=nx[j];
    }

    return dp[pos+P];
}

int main()
{
    string s;
    int x,y;
    cin >>s >>x >>y;

    int n = s.size();
    int idx = 0;
    while(idx<n && s[idx]=='F')
    {
        --x;
        ++idx;
    }

    s = s.substr(idx);
    s += 'T';
    n = s.size();

    int st = 1;
    int dir = 1;
    while(st<n)
    {
        idx = st;
        while(idx<n && s[idx]=='F') ++idx;
        v[dir].pb(idx-st);
        // dbg(st);
        // dbg(idx);
        st = idx+1;
        dir = !dir;
    }

    string ans = "No";
    if(solve(x,0) && solve(y,1)) ans = "Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define method(name,res,...) function<res (__VA_ARGS__) > name = [&](__VA_ARGS__) -> res
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

pii func(int n) {
  vector<pii> line(n);
  line[0] = pii(0,0);
  int mx[]={0,1,0,-1};
  int my[]={1,0,-1,0};
  rep(i,1,n){
    int k = in();
    int d = in();
    line[i].first = line[k].first + mx[d];
    line[i].second = line[k].second + my[d];
  }
  int l,r,u,d;
  l = r = line[0].first;
  u = d = line[0].second;
  foreach(i,line){
    chmin(l,i.first);
    chmax(r, i.first);
    chmin(d, i.second);
    chmax(u, i.second);
  }
  return pii(u-d+1,r-l+1);
}

int main(){
  int n;
  while(n=in()){
    pii ans = func(n);
    cout << ans.first << " " << ans.second << endl;
  }
  return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s, t;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s >> t;
    int n = (int)s.size();
    map<char, char> r, rd;
    bool ans = true;
    rep(i, 0, n) {
        r[s[i]] = t[i];
        rd[t[i]] = s[i];
    }
    rep(i, 0, n) {
        if (r[s[i]] != t[i]) ans = false;
        if (rd[t[i]] != s[i]) ans = false;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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


int main(){


    int n, l, i, a;

    int s = 0;


    cin >> n >> l;


    for( i = 1 ; i <= n ; i = i + 1 ){

         s += l + i - 1;

         }

    
    if( l + n - 1 <= 0 ) a = s - ( l + n - 1 );

    else if( 0 <= l ) a = s - l;

    else a = s;


    cout << a << endl;

    
    return 0;


    }


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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int num[3];
	int many[4];
	fn(many, 4, 0);
	while(scanf("%d%d%d", &num[0], &num[1], &num[2]) != EOF){
		if(num[0] + num[1] > num[2] && num[1] + num[2] > num[0] && num[2] + num[0] > num[1]){
			many[0]++;
			sort(num, num + 3);
			int check = num[0] * num[0] + num[1] * num[1] - num[2] * num[2];
			if(check > 0) many[2]++;
			else if(check == 0) many[1]++;
			else if(check < 0) many[3]++;
		}else break;
	}
	for(int i = 0; i < 4; i++){
		cout << many[i];
		if(i != 3) cout << " ";
		else cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int n,k;
    cin>>n>>k;
    int b=0;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    REP(i,k){
    b+=a[i];
    }
    cout<<b;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=4e5+9;
	int head[N],nex[N],to[N],w[N],cnt;
	inline void add(int u,int v,int c){
		nex[++cnt]=head[u];
		head[u]=cnt,to[cnt]=v,w[cnt]=c;
	}

	int n,m,vis[N],tot,num[4],PC,cntm;
	inline void dfs(int u,int col){
		vis[u]=col,num[col]++,tot++;
		for(int i=head[u];i;i=nex[i]){
			if(!vis[to[i]]){
				dfs(to[i],(col+w[i]+2)%3+1);
			}else if(vis[to[i]]!=(col+w[i]+2)%3+1) PC=1;
			cntm+=w[i]==1;
		}
	}
	int main(){
		n=read<int>(),m=read<int>();
		for(int i=1;i<=m;i++){
			int u=read<int>(),v=read<int>();
			add(u,v,1),add(v,u,-1);
		}

		long long ans=0;
		for(int i=1;i<=n;i++) if(!vis[i]){
			num[3]=num[1]=num[2]=tot=cntm=PC=0,dfs(i,1);
			if(PC) ans+=1LL*tot*tot;
			else if(!num[3] || !num[1] || !num[2]) ans+=cntm;
			else ans+=1LL*num[3]*num[1]+1LL*num[3]*num[2]+1LL*num[1]*num[2];
		}
		printf("%lld\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen("black.in","r",stdin);
	freopen("black.out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 13080
import sys
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    a =list(map(int,input().split()))
    L.append(a[0])
    R.append(a[1])
LL = L[0]
RR = R[0]
for i in range(1,M):
    if L[i] > RR or LL > R[i]:
        print(0)
        sys.exit()
    else:
        LL = max(LL, L[i])
        RR = min(RR, R[i])
print(RR - LL + 1)


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

int main() {
	
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(all(a), greater<int>());
	int ans = 0;
	
	for(int i = 1; i <= 2; i++){
		while(a[i] < a[0] - 1){
			a[i] += 2;
			ans++;
		}
	}
	if(a[0] == a[1] && a[1] == a[2]){
		
	}else if(a[1] == a[2]){
		ans++;
	}else{
		ans += 2;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
  string S, T;
  cin >> S >> T;

  bool success = false;

  int len = S.size();
  for (int i = 0; i < len;i++){
    char lastChar = S[len - 1];

    for (int j = len - 1; j >= 1; j--){
      S[j] = S[j - 1];
    }
    S[0] = lastChar;

    if(S==T){
      success = true;
      break;
    }
  }

  if(success){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int n;
    cin >> n;

    unordered_map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (mp[a] != 0) {
            cout << "NO" << endl;
            return 0;
        }
        ++mp[a];
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 8520
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int dx = x2 - x1;
    int dy = y2 - y1;
    
    cout << x2 - dy <<" "<<  y2 + dx << " ";
    cout << x2 - dy - dx << " "<< y2 + dx - dy;
    rn 0;
}


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

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const vector<int> dr = {0, 0, 1, -1};
const vector<int> dc = {1, -1, 0, 0};

void test_case() {
    int h, w;
    cin >> h >> w;
    vector<string> S(h + 1);
    for (int i = 1; i <= h; ++i) {
        cin >> S[i];
        S[i] = " " + S[i];
    }
    auto get = [&](int r, int c) {
        vector<vector<int>> dist(h + 1, vector<int>(w + 1, INT_MAX));
        vector<vector<int>> seen(h + 1, vector<int>(w + 1));
        queue<pair<int, int>> q;
        q.push({r, c});
        seen[r][c] = true;
        int d = 0;
        int mx = 0;
        while (!q.empty()) {
            int sz = q.size();
            for (int i = 0; i < sz; ++i) {
                int row = q.front().first;
                int col = q.front().second;
                q.pop();
                dist[row][col] = d;
                mx = d;
                for (int dir = 0; dir < 4; ++dir) {
                    int _row = row + dr[dir];
                    int _col = col + dc[dir];
                    if (_row >= 1 && _row <= h && _col >= 1 && _col <= w && S[_row][_col] == '.' && !seen[_row][_col]) {
                        seen[_row][_col] = true;
                        q.push({_row, _col});
                    }
                }
            }
            ++d;
        }
        return mx;
    };
    int ans = 0;
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            if (S[i][j] == '.') {
                ans = max(ans, get(i, j));
            }
        }
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    test_case();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
int N, K;
char S[50];
scanf("%d", &N);
scanf("%d", &K);
scanf("%s", S);
switch (S[K-1]) {
  case 'A':
  S[K-1] = 'a'; break;
  case 'B':
  S[K-1] = 'b'; break;
  case 'C':
  S[K-1] = 'c'; break;
}
printf("%s", S);
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int yakusu;
    int count = 0;

    for(int i = 1; i <= n; i++){
        yakusu = 0;
        for(int j = 1; j <= i; j++){
            if(i%2 != 0 && i%j == 0){
                yakusu++;
            }
        }
        if(yakusu == 8){
            count++;
        }
    }
    cout << count << endl;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::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...);
    }
#else
    #define debug(...)
#endif

#define MAX 300005
#define ff first
#define ss second
#define FOR(i, x, y) for(int i = x; i < y; i++)
#define ROF(i, x, y) for(int i = x; i >= y; i--)
#define sf scanf

struct Node{
    int ff, ss;
    bool operator<(const Node &a)const{
        if(ff != a.ff) return ff<a.ff;
        return ss<a.ss;
    }
};
set<Node> Q;

inline void insertToSet(int val, int cnt){
    if(Q.empty() or ((*Q.begin()).ff > val)) Q.insert({val, cnt});//, debug("inserting", val, cnt);
    else {
        auto now = (*Q.begin());
        Q.erase(Q.begin());
        Q.insert({val, now.ss + cnt});
        // debug("inserting", val, now.ss + cnt);
    }
}

inline void addToSet(int add){
    // debug("adding", add);
    while(add){
        auto now = (*Q.begin());
        Q.erase(Q.begin());
        // debug("now", add, now.ff, now.ss);
        if(now.ss <= add){
            insertToSet(now.ff+1, now.ss);
            add -= now.ss;
        }
        else{
            insertToSet(now.ff + 1, add);
            insertToSet(now.ff, now.ss - add);
            add = 0;
        }
    }
}

int ar[MAX];
int f[MAX];
int ff[MAX];
int ans[MAX];

int main(){
    #ifdef VAMP
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    memset(ans, -1, sizeof(ans));
    int n; sf("%d", &n);
    FOR(i, 0, n){
        sf("%d", &ar[i]);
        ++f[ar[i]];
    }
    sort(f+1, f+n+1);
    FOR(i, 1, n+1){
        ++ff[f[i]];
    }
    FOR(i, 0, n+1){
        if(ff[i]){
            // debug(i, ff[i]);
            Q.insert({i, ff[i]});
        }
    }
    ROF(i, n, 1){
        if(Q.empty()) continue;
        auto now = (*Q.begin());
        Q.erase(Q.begin());
        ans[i-1] = now.ff;
        // debug(i, ar[i-1]);
        if(i == 1) break;
        if(now.ss - 1 > 0) Q.insert({now.ff, now.ss - 1});
        if(now.ff) addToSet(now.ff);
    }
    FOR(i, 0, n) printf("%d\n", ans[i]);

    return 0;
}

Measured memory_bytes: 4736
a = list(input())
b = list(input())


for j in range(len(a)+1-len(b)) :
    Same = True
    ans = j
    i = 0
    while i < len(b) :
        if b[i] == a[j] :
            i += 1
            j += 1
        else :
            Same = False
            break
    if Same == True :
        print(ans)


Measured memory_bytes: 5572
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}





void test_case()
{
    
    int k, x;
    cin>>k>>x;

    if(k*500 >= x) {
        yes;
    } else {
        no;
    }
    
    
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n, x; cin >> n >> x;
    vector<int> A(n);
    REP(i, n) cin >> A[i];
    int acc = whole(accumulate, A, 0);
    x -= acc;
    whole(sort, A);
    x /= A[0];
    cout << x + n << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

typedef long long ll;
ll M = 998244353;
ll n, m, k, s, fac[N] = {1, 1}, fiv[N] = {1, 1}, inv[N] = {1, 1}, sq[N] = {1};
ll f(ll p, ll q) {
	ll t, r1, r2;
	t = p + q - 1;
	r1 = (sq[p - 1] * m) % M;
	r2 = ((fac[t] * fiv[t - q] % M) * fiv[q]) % M;
	return (r1 * r2) % M;
}

int main()
{
	ll i;
	cin >> n >> m >> k;
	sq[1] = m - 1;
	for(i=2; i<=n; i++) {
		fac[i] = fac[i-1] * i % M;
		inv[i] = inv[M%i] * (M-M/i) % M;
		fiv[i] = fiv[i-1] * inv[i] % M;
		sq[i] = sq[i - 1] * (m - 1) % M;
	}
	for (i = 0; i <= k; i++) {
		s = (s + f(n - i, i)) % M;
	}
	cout << s << endl;
    return 0;
}


Measured memory_bytes: 9848
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define v vector
typedef  long long int ll;
#define f first
#define s second
#define MOD 1000000007
#define inf 1e18
//typedef pair<int,int> pi;

int main(){
	int i,n;
	string s;
	getline(cin,s);
	n=s.length();
	
	int pos=n-1;ll ans=0;
	for(i=n-1;i>=0;i--){
	   if(s[i]=='B')
	   	ans+=pos-i,pos--;

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

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
long long int sum,n,q,tt;
long long int a[100006],biaoji,s[100006];
int main()
{
    while(scanf("%lld",&n)==1)
    {
        biaoji=0;sum=1;
        memset(a,0,sizeof(a));
        memset(s,0,sizeof(s));
        for(int i=1;i<=n;i++)
        {
            scanf("%lld",&a[i]);
        }
        sort(a+1,a+n+1);
        tt=-5225512;
        s[1]=1;
        for(int i=2;i<=n;i++)
        {
            if(a[i]==a[i-1])
            {
                s[i]=s[i-1]+1;
            }
            else
                s[i]=1;
        }
        for(int i=n-1;i>=1;i--)
        {
            if(a[i]==a[i+1])
            {
                s[i]=s[i+1];
            }
        }
        q=0;
        for(int i=n;i>=1;i--)
        {
            if(s[i]>=4&&sum==1)
            {
                sum=a[i]*a[i];
                biaoji=1;
                break;
            }
            if(s[i]>=2&&tt!=a[i])
            {
                sum=sum*a[i];
                tt=a[i];
                ++q;
                if(q>=2)
                {
                    biaoji=1;
                    break;
                }
            }
            continue;
        }
        if(biaoji==1)printf("%lld\n",sum);
        if(biaoji==0)printf("0\n");
    }
}


Measured memory_bytes: 1792
import math

a,b,h,m = map(float,input().split())
if 6*m>30*h+m*0.5:
  angle = (6*m) - (30*h+m*0.5)
else:
  angle = (30*h+m*0.5) - (6*m)

if angle>180:
  angle = 360-angle

c = math.sqrt((a**2) + (b**2) - (2*a*b*math.cos(math.radians(angle))))
  
print(c)

Measured memory_bytes: 9296
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

int main(){
    ll d;
    cin >> d;
    vector<pll> c;
    rep(i,26){
        ll t;
        cin >> t;
        c.push_back(make_pair(t,i+1));
    }
    vector<vector<pll>> s(d);
    rep(i,d){
        rep(j,26){
            ll v;
            cin >> v;
            s[i].push_back(make_pair(v,j+1));
        }
        sort(s[i].rbegin(),s[i].rend());
    }
    vector<ll> ans,used(26);
    ll tot=d;
    ll cnt=0;
    sort(c.rbegin(),c.rend());
    rep(i,d){
        //cout << ans[i] << endl;
    }
    vector<ll> per(26);
    rep(i,26){
        per[i]=i+1;
    }
    do{
        rep(i,26){
            ans.push_back(per[i]);
            cnt++;
            if(cnt==d) break;
        }
        if(cnt==d) break;
    }while(next_permutation(per.begin(),per.end()));
    vector<ll> num(5);
    rep(i,5){
        num[i]=c[i].se;
    }
    rep(i,d){
        cout << num[i%5] << endl;
    }
    return 0;
} 


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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B >= C) {
		cout << B + C << endl;
	}
	else if (A + B < C) {
		cout << A + 2 * B + 1 << endl; 
	}
}

Measured memory_bytes: 3604
fun sle(a: Int, b: Int): String = when {
  a < b -> "a < b"
  a > b -> "a > b"
  else -> "a == b"
}

fun main(args: Array<String>) {
  val (a,b) = readLine()!!.split(' ').map(String::toInt)

  println(sle(a,b))
}



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

string cutter(const string t){
  long long l = t.size();
  if(l >= 5 && t.substr(l-5) == "dream" || t.substr(l-5) == "erase")
    return t.substr(0, l-5);
  else if (l >= 6 && t.substr(l-6) == "eraser")
    return t.substr(0, l-6);
  else if (l >= 7 && t.substr(l-7) == "dreamer")
    return t.substr(0, l-7);
  
  return t;
}

int main(){
  string s;
  cin >> s;
  
  while(s != "" && s != cutter(s))
    s = cutter(s);
  
  cout << (s == "" ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
#include<cstdio>
using namespace std;

main(){
  int n,s;
  while(true){
    scanf("%d%d",&n,&s);
    if (n==0)break;
    int r[101]={0};
    for(int i=0;i<n;i++){
      int tmp;scanf("%d",&tmp);r[tmp]++;
    }
    int ans = 0;
    for(int i=0;i<101;i++){
      if (i+i > s && r[i])ans += (r[i]*(r[i]-1))/2;
      for(int j=i+1;j<101;j++){
	if (i+j > s && r[i] && r[j])ans += r[i]*r[j];
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    int k=a[n]/2,m=k+1,ans;
    for(int i=1;i<n;i++)
    {
        int t=min(a[i],a[n]-a[i]);
        if(k-t<m)
            m=k-t,ans=a[i];
    }
    printf("%d %d\n",a[n],ans);
}


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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, ans = 1;
	string s;
	
	cin>>N;
	
	cin>>s;
	
	for(int i = 0; i < 2*N; i++){
		if(s[i] == 'B'){
			if(i%2) s[i] = 'R';
			else s[i] = 'L';
		} else {
			if(i%2) s[i] = 'L';
			else s[i] = 'R';
		}
	}
	// cout<<s<<endl;
	
	if(count(s.begin(), s.end(), 'L') != N){
		cout<<0<<endl;
		return 0;
	}
	
	for(int i = 0, con = 0; i < 2*N; i++){
		if(s[i] == 'R'){
			ans *= con;
			ans %= MOD;
			con--;
		} else {
			con++;
		}
	}

	for(int i = 1; i <= N; i++){
		ans *= i;
		ans %= MOD;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

void solve() {
  int n, h, w; cin >> n >> h >> w;
  int ans = 0;
  while(n--) {
    int a, b; cin >> a >> b;
    ans += a >= h && b >= w;
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 998244353
//#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
char s[2010];
ll dp[4010][4010];
int main(){
	scanf("%s",s);
	n=strlen(s);
	
	dp[0][0]=1;
	int c=0;
	rep(i,1,2*n+1){
		if(i-1<n)c+=s[i-1]-48;
		rep(j,0,2*i+1)if(j<=c&&i-j<=2*min(i,n)-c){
			if(j)dp[i][j]=(dp[i-1][j]+dp[i-1][j-1])%MOD;
			else dp[i][j]=dp[i-1][j];
//			printf("%d %d %d\n",i,j,dp[i][j]);
		}
	}
	printf("%lld",dp[2*n][c]);
}

Measured memory_bytes: 123392
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

int N;
struct Info{
	bool operator<(const struct Info &arg) const{

		return B < arg.B;
	}
	ll A,B;
};
Info info[SIZE];


int main(){

	scanf("%d",&N);
	for(int i = 0; i < N; i++){

		scanf("%lld %lld",&info[i].A,&info[i].B);
	}
	sort(info,info+N);

	ll current = 0;
	for(int i = 0; i < N; i++){
		current += info[i].A;
		if(current > info[i].B){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 3328
#include  <bits/stdc++.h>
using namespace std;
//vector<int> vec(N,0);
int main() {
  int N,ans=0;
  cin >> N;
  vector<int> vec(N,0);
  
  for(int i=0;i<N;i++){
   cin >> vec.at(i)  ;
  }
  
  sort(vec.begin(),vec.end());
  vec.at(N-1) = vec.at(N-1)/2;
  
  for(int i=0;i<N;i++){
    ans+=vec.at(i);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())

count = [[0] * (N+1) for _ in range(N+1)]

for i in range(M):
    l, r = map(int, input().split())

    count[l][r] += 1

# 2次元累積和
for i in range(1, N+1):
    for j in range(1, N+1):
        count[i][j] += count[i][j-1]
for i in range(1, N+1):
    for j in range(1, N+1):
        count[i][j] += count[i-1][j]


for i in range(Q):
    l, r = map(int, input().split())
    print(count[r][r]+count[l-1][l-1]-count[l-1][r]-count[r][l-1])


Measured memory_bytes: 13400