akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.function.DoubleToIntFunction;

public class Main {
    public static boolean debug = true;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();

        if(a >= 3200){
            System.out.println(s);
        }else{
            System.out.println("red");
        }


    }
    public static void d(String message){
        if(debug){
            System.out.println(message);
        }
    }
}

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

using namespace std;
using ll = long long;

int main(int argc, char const *argv[]) {
    ll n;
    cin >> n;

    std::vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n / i);
            }
        }
    }

//    sort(ret.begin(), ret.end());

    ll ans = 0;

    for(ll item: ret) {
        if (item == 1) continue;

        ll q = n/(item-1);
        ll r = n%(item-1);

        if (q == r) ans += item-1;
    }


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


Measured memory_bytes: 384
[N,M] = list(map(int,input().split()))
a = []
for i in range(M):
    a.append(int(input()))

aa=[0]*(N+1)
for j in range(M):
    aa[a[j]] = 1

dp = [0]*(N+1)
dp[0]=1
if 1 not in a:
    dp[1]=1
else:
    dp[1]=0

for i in range(2,N+1):
    if aa[i]==0:
        dp[i]=dp[i-1] + dp[i-2]
    else:
        dp[i]=0

print(dp[-1] % 1000000007)

Measured memory_bytes: 501764
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

lli f[MAX];
void fact(int n) {
  for (lli i = 1; i <= n; i++ ) 
    f[i] = f[i-1] * i % MOD;
}

int main(void) {
  lli N, M;
  scanf("%lld %lld", &N, &M);

  f[0] = 1;
  fact(100000);
  lli dif = llabs(N - M);
  if ( dif != 0 && dif != 1 ) {
    printf("0\n");
    return 0;
  }
  if ( dif == 0 ) {
    printf("%lld\n", ((f[N] * f[M]) % MOD) * 2 % MOD);
    return 0;
  }
  printf("%lld\n", f[N] * f[M] % MOD);
  return 0;
}


Measured memory_bytes: 896
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function permutation(a,n)
	ans = Array{Int,1}[copy(a)]
	c = ones(Int,n)
	i = 1
	while i<=n
		if c[i]<i
			if i%2==1
				tmp = a[1]
				a[1] = a[i]
				a[i] = tmp
			else
				tmp = a[c[i]]
				a[c[i]] = a[i]
				a[i] = tmp
			end
			c[i] += 1
			i = 1
			push!(ans,copy(a))
		else
			c[i] = 1
			i += 1
		end
	end
	ans
end

function main()
	n,m = readline() |> split |> parseMap
	g = eye(Int,n)
	for i in 1:m
		a,b = readline() |> split |> parseMap
		g[a,b] = 1
		g[b,a] = 1
	end
	k = 0
	e = [i for i in 2:n]
	c = permutation(e,n-1)

	for i in 1:length(c)
		f = 0
		if g[1,c[i][1]] == 0
			f = 1
		end
		for j in 1:n-2
			if g[c[i][j],c[i][j+1]] == 0
				f = 1
			end
		end
		if f == 0
			k += 1
		end
	end
	println(k)
end

main()

Measured memory_bytes: 114636
#include <bits/stdc++.h>
#define MAX 200005
#define ll long long
#define P 1000000007
using namespace std;

ll qpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n&1) res = res*a%P;
        a = a*a%P;
        n >>= 1;
    }
    return res;
}

int n, k, cnt;
int head[MAX], vet[MAX], Next[MAX];
ll fac[MAX], inv[MAX], d[MAX], ans = 1;

void init(){
    fac[0] = 1;
    for(int i = 1; i < MAX; ++i){
        fac[i] = fac[i-1]*i%P;
    }
    inv[MAX-1] = qpow(fac[MAX-1], P-2);
    for(int i = MAX-2; i >= 0; --i){
        inv[i] = inv[i+1]*(i+1)%P;
    }
}

void add(int x, int y){
    cnt++;
    Next[cnt] = head[x];
    head[x] = cnt;
    vet[cnt] = y;
}

ll A(ll n, ll m){
    if(m<0 || m>n) return 0;
    return fac[n]*inv[n-m]%P;
}

void dfs(int x, int fa){
    if(!fa) ans = ans*A(k-1, d[x])%P;
    else ans = ans*A(k-2, d[x]-1)%P;
    for(int i = head[x]; i; i = Next[i]){
        int v = vet[i];
        if(v == fa) continue;
        dfs(v, x);
    }
}

int main()
{
    init();
    cin >> n >> k;
    int x, y;
    for(int i = 1; i < n; ++i){
        scanf("%d%d", &x, &y);
        add(x, y);
        add(y, x);
        d[x]++, d[y]++;
    }
    ans = k;
    dfs(1, 0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8448
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<cstring>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e6 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 1e9 + 7;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-8;
using namespace std;
int main(){
	ll n;cin >> n;
	string ans;
	while(n){
		n--;
		ans += n % 26 + 'a';
		n /= 26;	
	}
	reverse(ans.begin(),ans.end());
	cout << ans <<"\n";
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int count = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != t[i]) count++;
    }
    cout << count << "\n";
}


Measured memory_bytes: 3832
import numpy as np

N, W = map(int, input().split())
inputs = np.array([np.array([int(i) for i in input().split()]) for _ in range(N)])

dp = np.zeros(W+1, dtype=np.int64)
for n in range(1, N+1):
    weight, value = inputs[n-1][0], inputs[n-1][1]
    dp[weight:] = np.maximum(dp[weight:], dp[:-weight] + value)

print(dp[-1])


Measured memory_bytes: 15424
/* Ajay Jadhav */
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve()
{
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int startMin = h1 * 60 + m1;
    int endMin = h2 * 60 + m2;
    cout<<endMin - startMin-k;
}
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    /*
    int a, b , c, d;
    cin >> a >> b >> c >> d ;
    //*/

    char a;
    cin >> a;
    if(a == 'A'){
        a = 'T';
    } else if (a == 'T'){
        a = 'A';
    } else if (a == 'C'){
        a = 'G';
    } else if (a == 'G'){
        a = 'C';
    }

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( b / a < c ){
        cout << b / a << endl;
    } else {
        cout << c << endl;
    }
    //*/
    
    cout << a << endl;

    return 0; 
}


Measured memory_bytes: 3456
import sys

input = sys.stdin.readline

def main():
    s=input()
    hu="Yes"
    for i in range(len(s)):
        if s[i]=="L" and i%2==0:
            hu="No"
            break
        elif s[i]=="R" and i%2!=0:
            hu="No"
            break
    print(hu)

if __name__ == "__main__":
    main()



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

int calc(int day, int act, int arr[][3], int dp[][3]){
    if(dp[day][act]!=-1)
        return dp[day][act];
    int ans;
    if(act==0){
        ans = max(calc(day-1, 1, arr, dp), calc(day-1, 2, arr, dp));
    }
    else if(act==1){
        ans = max(calc(day-1, 0, arr, dp), calc(day-1, 2, arr, dp));
    }
    else
        ans = max(calc(day-1, 1, arr, dp), calc(day-1, 0, arr, dp));

    ans += arr[day][act];
    dp[day][act] = ans;
    return ans;
}

int main(){
    int n,i,j;
    cin>>n;
    int dp[n+1][3], arr[n+1][3];
    for(i=1;i<=n;i++){
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
        dp[i][0] = -1;
        dp[i][1] = -1;
        dp[i][2] = -1;
    }
    dp[1][0] = arr[1][0];
    dp[1][1] = arr[1][1];
    dp[1][2] = arr[1][2];
    cout<<max(calc(n,0,arr,dp), max(calc(n,1,arr,dp), calc(n,2,arr,dp)));
}

Measured memory_bytes: 12032
import Data.List
import Data.Array.IArray

ub = 100000

primes = 2 : f [3] [3,5..]
  where
    f (x:xs) ys = let (ps, qs) = span (< x^2) ys in ps ++ f (xs ++ ps) [z | z<-qs, mod z x /= 0]

primes' = takeWhile (< ub) $! primes

parray = accumArray (\x y -> y) False (1,ub) [(i, True) | i<-primes'] :: Array Int Bool

arr = array (0,ub) ((0,0):(1,0):(2,0):[(n, if parray!n && parray!((n+1)`div`2) then arr!(n-1)+1 else arr!(n-1)) | n<-[3..ub]]) :: Array Int Int


main = do
  n <- readLn :: IO Int
  dat <- getContents >>= return . (map ((map read) . words)) . lines :: IO [[Int]]

  mapM_ print $ map (\(l:r:_) -> arr!r - arr!(l-1)) dat


Measured memory_bytes: 19836
fruits = gets.chomp.split(" ").map(&:to_i)
type = fruits[0]
select = fruits[1]
price = gets.chomp.split(" ").map(&:to_i)

price_sum = 0

for i in 1..select
  price_sum += price.min
  price.delete_at(price.index(price.min))
end

p price_sum

Measured memory_bytes: 14264
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<double, int> P;
vector<P> G[1010];
double x[1010];
double y[1010];
double r[1010];
double dist[1010];
int main() {
	int xs, ys, xt, yt;
	cin >> xs >> ys >> xt >> yt;
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> x[i] >> y[i] >> r[i];
	}
	x[0] = xs;
	y[0] = ys;
	r[0] = 0;
	x[N + 1] = xt;
	y[N + 1] = yt;
	r[N + 1] = 0;
	for (int i = 0; i <= N + 1; i++) {
		for (int j = i + 1; j <= N + 1; j++) {
			double d = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
			double cost = max(d - (r[i] + r[j]), 0.0);
			G[i].emplace_back(cost, j);
			G[j].emplace_back(cost, i);
		}
	}
	priority_queue<P, vector<P>, greater<P>> Q;
	fill(dist, dist + 1010, 1e100);
	dist[0] = 0;
	Q.push(P(0, 0));
	while (!Q.empty()) {
		P p = Q.top(); Q.pop();
		if (dist[p.second] < p.first) continue;
		for (P e : G[p.second]) {
			int to = e.second;
			if (p.first + e.first < dist[to]) {
				dist[to] = p.first + e.first;
				Q.push(P(dist[to], to));
			}
		}
	}
	printf("%.15lf\n", dist[N + 1]);
}


Measured memory_bytes: 22804
#include<bits/stdc++.h>
using namespace std;
long long a[123456];
int n;
map<long long,long long>Mp;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        Mp[a[i]]++;
    }
    long long Max=1;
    for(int i=0;i<=100010;i++){
            Max=max(Max,Mp[i]);
            if(Mp[i]&&Mp[i+1]&&Mp[i+2]){
               long long ans=Mp[i]+Mp[i+1]+Mp[i+2];
               Max=max(Max,ans);
            }
            if(Mp[i]&&Mp[i+1]){
               long long ans=Mp[i]+Mp[i+1];
               Max=max(Max,ans);
            }
            if(Mp[i]&&Mp[i+2]){
               long long ans=Mp[i]+Mp[i+2];
               Max=max(Max,ans);
            }
    }
    cout<<Max<<endl;
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  vector<int> v(5);
  int k, maxN = 0, minN = INF;
  for (int i = 0; i < 5; i++) {
    cin >> v[i];
    maxN = max(maxN, v[i]);
    minN = min(minN, v[i]);
  }
  cin >> k;
  if (maxN - minN <= k)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
}

Measured memory_bytes: 256
from collections import Counter


def main():
    count_by_kw = Counter()
    n = int(input())
    for i in range(n):
        key = input()
        count_by_kw[key] += 1

    m = int(input())
    for i in range(m):
        key = input()
        count_by_kw[key] -= 1
    print(max(0, count_by_kw.most_common(1)[0][1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int h,w;
int n;
int t[16];
char area[16][20][20];

int sy,sx,gy,gx;

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

int cur[20][20];
int next[20][20];


bool in(int y,int x){
	return 0<=y&&y<h&&0<=x&&x<w;
}

int main(){
	cin>>h>>w;
	rep(i,h)rep(j,w){
		cin>>area[0][i][j];
		char c=area[0][i][j];
		if(c=='S'){sy=i;sx=j;}
		else if(c=='G'){gy=i;gx=j;}
	}
	cin>>n;
	rep(i,n){
		cin>>t[i];
		rep(y,h)rep(x,w)cin>>area[i+1][y][x];
	}
	t[n]=INF;
	int state=0;
	int ans=INF;
	rep(y,h)rep(x,w)cur[y][x]=INF;
	cur[sy][sx]=0;
	rep(i,600){
		if(i+1==t[state]){
			state++;
		}
		char (*grid)[20]=area[state];
		rep(y,h)rep(x,w)next[y][x]=INF;

		rep(y,h)rep(x,w){
			if(cur[y][x]==INF)continue;
			int desty=y,destx=x;
			if(grid[y][x]!='#')next[y][x]=min(next[y][x],cur[y][x]);
			rep(j,4){
				desty=y+dy[j];destx=x+dx[j];
				if(!in(desty,destx))continue;
				if(grid[desty][destx]!='#'){
					next[desty][destx]=min(next[desty][destx],cur[y][x]+1);
					if(desty==gy&&destx==gx)
						ans=min(ans,cur[y][x]+1);
				}
			}
		}

		memcpy(cur,next,sizeof(cur));
	}
	if(ans==INF)ans=-1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1172
n = int(input())
d = list(map(int, input().split()))

if d[0] != 0:
    print(0)
    exit()

d.sort()

if n == 1:
    if d[0] == 0:
        print(1)
    else:
        print(0)
    exit()

if d[0] != 0 or d[1] != 1:
    print(0)
    exit()


mini = d[0]
maxi = d[-1]
num = 1
cnt = 0
lst = [1]
for i in d[1:]:
    if i == num:
        cnt += 1
    elif i == num+1:
        lst.append(cnt)
        num = i
        cnt = 1
    else:
        print(0)
        exit()

lst.append(cnt)

ans = 1
for i in range(1, len(lst)-1):
    ans = (ans * lst[i]**lst[i+1]) % 998244353

print(ans)

Measured memory_bytes: 14396
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>

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

const int MAX = 100;
const int INF = 10000001;

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1, 0);
  ll ans = 0;
  for(int i = 1; i <= N; i++){
    int j = i;
    while(j <= N){
      A[j]++; 
      j += i;
    }
    ans += i * A[i]; 
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n, ret=0;
  cin >> n;
  vector<int>a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int i=0; i<n; i++)for(int j=0; j<n; j++){
    ret = max(ret, abs(a[i]-a[j]));
  }
  cout << ret;
  return 0;
}


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

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
    cin>>n;
    int s=0;
    for(int x=1;x<=n;x++){
        if(x%3!=0&&x%5!=0){
            s+=x;
        }

    }
    cout<<s;








	
return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;cin>>n;
    ll a,ans=0;
    for(ll i=1;i<=n;i++)
    {
        cin>>a;
        if(i&1 && a&1)
            ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <chrono>
#include <random>
#include <iomanip>
#include <ctime>
#include <chrono>
#include <cstdlib>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define au(i, x) for (auto&i : x)
typedef long double ld;
typedef long long ll;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, k;
	cin >> n >> k;
	cout << min(k - n % k, n % k);
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    var list = List[Int]()

    for(in <- StdIn.readLine.split(" ").map(_.toInt)){
      list = in :: list
    }

    var count = 0
    for(i <- list(2) to list(1)){
      if(list.head % i == 0){
        count = count + 1
      }
    }

    println(count)
  }
}

Measured memory_bytes: 44092
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  int x_1, y_1, x_2, y_2;
  cin >> x_1 >> y_1 >> x_2 >> y_2;

  /* input */
  int x_3 = x_2 - (y_2 - y_1);
  int y_3 = y_2 + (x_2 - x_1);
  int x_4 = x_1 - (y_2 - y_1);
  int y_4 = y_1 + (x_2 - x_1);
  cout << x_3 << " " << y_3 << " " << x_4 << " " << y_4 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        long long int n,d,i,c=0,x,y;
        scanf("%lld%lld",&n,&d);
        for(i=0;i<n;i++){
                scanf("%lld%lld",&x,&y);
                if(x*x+y*y<=d*d)c++;
        }
        printf("%lld\n",c);
        return 0;
}



Measured memory_bytes: 1736
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

ll N, K, a[100100];
ll t[70], s[70];

signed main()
{
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    ll n = 1ll;
    ll mb = 0ll;
    while(K >= n){
        n *= 2ll;
        mb++;
    }
    mb--;
    ll ans = 0ll;
    for(ll b = mb + 1ll; b < 60ll; b++){
        for(int i = 0; i < N; i++){
            if(a[i] & (1ll << b)){
                ans += (1ll << b);
            }
        }
    }
    for(ll i = 0ll; i <= mb; i++){
        for(ll j = 0ll; j < N; j++){
            if(a[j] & (1ll << i)){
                t[i]++;
            }
            else s[i]++;
        }
    }
    ll res = 0ll;
    for(ll i = 0ll; i <= mb; i++){
        ll sum = 0ll;
        if(K & (1ll << i))
        for(ll j = 0ll; j <= mb; j++){
            if(j < i){
                sum += (1ll << j) * max(t[j], s[j]);
            }
            else if(i == j){
                sum += (1ll << j) * t[j];
            }
            else {
                if(K & (1ll << j)){
                    sum += (1ll << j) * s[j];
                }
                else {
                    sum += (1ll << j) * t[j];
                }
            }
        }
        res = max(res, sum);
    }
    ll summ = 0ll;
    for(ll j = 0ll; j <= mb; j++){
        if(K & (1ll << j)){
            summ += (1ll << j) * s[j];
        }
        else {
            summ += (1ll << j) * t[j];
        }
    }
    res = max(res, summ);
    cout << ans + res << endl;


    return 0;
}
/*

*/




Measured memory_bytes: 1024
N = int(input())

res = 0
if 1<= N <= 9:
  res = N
elif N <= 99:
  res = 9
elif N <= 999:
  res = 9 + (N-99)
elif N <= 9999:
  res = 9 + 900
elif N <= 99999:
  res = 9 + 900 + (N-9999)
else:
  res = 9 + 900 + 90000

print(res)


Measured memory_bytes: 2940
#![allow(unused)]

use proconio::input;
use proconio::marker::{Bytes, Chars, Usize1};
use std::cmp::{Reverse, min, max};
use itertools::Itertools;

#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        ps: [Usize1; n * n],
    }

    let mut cs = vec![vec![0; n]; n];
    for i in 0..n {
        for j in 0..n {
            cs[i][j] = *[i, j, n - 1 - i, n - 1 - j].iter().min().unwrap();
        }
    }

    let mut exited = vec![vec![false; n]; n];
    let mut ans = 0;
    for p in ps {
        let i = p / n;
        let j = p % n;

        exited[i][j] = true;
        ans += cs[i][j];

        let mut q = vec![(i, j)];
        while let Some((i1, j1)) = q.pop() {
            let neighbors = [
                if i1 == 0     { None } else { Some((i1 - 1, j1)) },
                if i1 == n - 1 { None } else { Some((i1 + 1, j1)) },
                if j1 == 0     { None } else { Some((i1, j1 - 1)) },
                if j1 == n - 1 { None } else { Some((i1, j1 + 1)) },
            ];

            let c = cs[i1][j1] + if exited[i1][j1] { 0 } else { 1 };
            for &(i2, j2) in neighbors.iter().flatten() {
                if cs[i2][j2] > c {
                    cs[i2][j2] = c;
                    q.push((i2, j2));
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 9692
/* code by AbhiTaker  */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n,m,i;
    cin>>n>>m;
    string s;
    cin>>s;
    ll flag=0;

    if(s[n]!='-' || s.size()!=n+m+1)
        flag = 1;

    if(flag)
    {
        cout<<"No\n";
        return 0;
    }

    for(i=0;i<n;i++)
    {
        if((s[i]-'0')<0 || (s[i]-'0')>9)
            flag =1;

    }

    for(i=n+1; i<n+m+1; i++)
      {
        if((s[i]-'0')<0 || (s[i]-'0')>9)
            flag =1;

    }

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


    return 0;
}


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

using namespace std;

#define MOD 998244353

int n, q;
long long m;
int par[100005];
vector<pair<int, int>> v;

int find(int a) {
	return par[a] == a ? a : par[a] = find(par[a]);
}

int main() {
	scanf("%d%lld%d", &n, &m, &q);
	for (int i = 0; i < n; i++)
		par[i] = i;
	while (q--) {
		int ta, tb, tc;
		scanf("%d%d%d", &ta, &tb, &tc);
		if (tc)
			v.emplace_back(ta, tb);
		else {
			ta = find(ta);
			tb = find(tb);
			if (ta != tb)
				par[ta] = tb;
		}
	}
	int cnt = 0;
	for (int i = 0; i < n; i++)
		if (find(i) == i)
			cnt++;
	if (cnt <= 2 && !v.empty()) {
		puts("No");
		return 0;
	}
	for (auto& i : v)
		if (par[i.first] == par[i.second]) {
			puts("No");
			return 0;
		}
	long long mi = v.empty() ? n - 1 : n;
	long long ma = (n - 1) - (cnt - 1) + (long long)cnt * (cnt - 1) / 2;
	puts(mi <= m && m <= ma ? "Yes" : "No");
}


Measured memory_bytes: 1784
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	//var scanner = bufio.NewScanner(os.Stdin)
	//scanner.Split(bufio.ScanLines)
	var K, N int
	fmt.Scan(&K, &N)
	/*
		if scanner.Scan() {
			str := scanner.Text()
			cols := strings.Split(str, " ")
			K, _ = strconv.Atoi(cols[0])
			N, _ = strconv.Atoi(cols[1])
		}
	*/
	_ = K
	A := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}

	var tmp, max int
	max = 0
	for i := 0; i < N; i++ {
		if i == N-1 {
			tmp = A[0] + (K - A[N-1])
		} else {
			tmp = A[i+1] - A[i]
		}
		//fmt.Println(tmp)
		//fmt.Println(tmp)
		if tmp > max {
			max = tmp
		}
	}

	fmt.Fprint(wtr, K-max)
	_ = wtr.Flush()
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        int[] ints = new int[n];
        for (int i = 0; i < ints.length; i++) {
            ints[i] = in.nextInt();
        }
        int q = in.nextInt();
        while (q-- != 0){
            boolean bool = search(ints,0,0,in.nextInt());
            System.out.printf("%s\n",bool?"yes":"no");
        }
    }
    private static int i ;
    private static int n ;
    private static boolean search(int[] ints,int i,int sum,int key){
        if (key == sum)
            return true;
        if (i == n)
            return false;
        if(search(ints,i+1,sum+ints[i],key))
            return true;
        if (search(ints,i+1,sum,key))
            return true;
        return false;
    }
}



Measured memory_bytes: 27056
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){

  int n,a,b,c,num,ma;
  scanf("%d",&n);
  while(n != 0){
    
    for(int i=0;i<n;i++){
      scanf("%d %d %d",&a,&b,&c);
      if(i == 0 || ma<b+c ){
	num = a;
	ma = b+c;
      }
    }

    printf("%d %d\n",num,ma);
    scanf("%d",&n);
  }

  return (0);
}

Measured memory_bytes: 2732
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
#include<cassert>
const int S=4000039;
const int M=998244353;
bool c[2011][10011];
bool f[2011][10011];
char g[10011];
int h[10011];
char s[2011][10011];
int len[2011];
int ex[10011];
int max;
int slcp[10011];
int lcp[10011];
int cmp(int i,int j,int min,int &ans)
{
	int l1=lcp[j+1];
	if(l1<min-j)
	{
		ans=j+l1;
		if(l1==len[i])return 0;
		if(s[i][l1+1]<g[j+l1+1])return -1;
		return 1;
	}
	if(j+len[i]==min)return 0;
	int l2=slcp[min-j+1];
	ans=min+l2;
	if(min+l2==j+len[i])return 0;
	if(s[i][l2+1]>s[i][min-j+l2+1])return -1;
	return 1;
}
int main()
{
	int n=io::F(),k=io::F();
	ex[0]=1;
	for(register int i=1;i<=k;++i)ex[i]=(ex[i-1]*(long long)S)%M;
	for(register int i=1;i<=n;++i)scanf("%s",s[i]+1),len[i]=strlen(s[i]+1);
	c[n+1][0]=1;
	for(register int i=n;i;--i)
		for(register int j=0;j<=k;++j)
		{
			c[i][j]=c[i+1][j];
			if(j>=len[i])c[i][j]|=c[i+1][j-len[i]];
		}
	f[0][0]=1;
	for(register int i=1;i<=n;++i)
	{
		int min=-1;
		slcp[1]=len[i];
		int la=0;
		for(register int j=2;j<=len[i];++j)
		{
			if(j<la+slcp[la])
			{
				int t=j-la+1;
				if(t+slcp[t]-1<slcp[la])slcp[j]=slcp[t];
					else for(slcp[j]=la+slcp[la]-j,la=j;s[i][j+slcp[j]]==s[i][1+slcp[j]];++slcp[j]);
			}
			else
			{
				for(slcp[j]=0;s[i][j+slcp[j]]==s[i][1+slcp[j]];++slcp[j]);
				la=j;
			}
		}
		la=0;
		for(register int j=1;j<=max;++j)
		{
			if(j<la+lcp[la])
			{
				int t=j-la+1;
				if(t+slcp[t]-1<lcp[la])lcp[j]=slcp[t];
					else for(lcp[j]=la+lcp[la]-j,la=j;1+lcp[j]<=len[i]&&j+lcp[j]<=max&&s[i][1+lcp[j]]==g[j+lcp[j]];++lcp[j]);
			}
			else
			{
				for(lcp[j]=0;1+lcp[j]<=len[i]&&j+lcp[j]<=max&&s[i][1+lcp[j]]==g[j+lcp[j]];++lcp[j]);
				la=j;
			}
		}
		int ml=max;
		for(register int j=max;j>=0;--j)
			if(j+len[i]<=k&&c[i+1][k-j-len[i]]&&f[i-1][j])
				if(min==-1)
				{
					int l1=lcp[j+1];
					if(j==max||j+l1==dmin(max,j+len[i])||s[i][l1+1]<g[j+l1+1])min=j,ml=j+l1;
				}
				else
				{
					int L;
					int tmp=cmp(i,j,min,L);
					if(tmp==-1)
					{
						min=j;
						ml=L;
					}
				}
		if(min!=-1)
		{
			for(register int j=1;j<=len[i];++j)g[min+j]=s[i][j];
			max=min+len[i];
			for(register int j=max;j>=0;--j)
				if(j+len[i]<=k&&c[i+1][k-j-len[i]]&&f[i-1][j])
				{
					int L;
					int tmp=cmp(i,j,min,L);
					if(tmp==0)f[i][j+len[i]]=1;
				}
		}
		for(register int j=0;j<=ml;++j)f[i][j]|=f[i-1][j];
		g[max+1]=0;
	}
	assert(strlen(g+1)==k);
	puts(g+1);
	return 0;
}




Measured memory_bytes: 58240
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
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; }
static const lint MOD = (lint)1e9+7;

int main()
{
    int A, B;
    cin >> A >> B;
    if (A > B)
    {
        swap(A, B);
    }

    if (A == 2 and B == 3)
    {
        cout << 1 << endl;
    }
    else if (A == 1 and B == 3)
    {
        cout << 2 << endl;
    }
    else if (A == 1 and B == 2)
    {
        cout << 3 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
	int s=0,f=0;
	for(int i=0;i<3;i++) {
		int t;
		cin >> t;
		if(t==5) 
			f++;
		else
			s++;
	}
	if(f==2&&s==1)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	
    return 0;
}

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

int main() {
    int N; cin >> N;
    vector< vector<int> > G(N);
    vector< pair<int, int> > v;
    int a, b;
    for (int i = 1; i < N; i++) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        v.push_back(make_pair(a, b));
    }
    int K = 0;
    map< pair<int, int>, int> I;
    vector<int> color(N);
    vector<int> check(N); check[0] = 1;
    queue<int> q;
    q.push(0);
    int tmp;
    while(!q.empty()) {
        tmp = q.front(); q.pop();
        if (K < G[tmp].size()) K = G[tmp].size();
        int cur = 1;
        for (int u:G[tmp]){
            if (check[u]) continue;
            if (cur == color[tmp]) cur++;
            color[u] = I[make_pair(u, tmp)] = I[make_pair(tmp, u)] = cur++;
            check[u]++;
            q.push(u);
        }
    }
    cout << K << endl;
    for (auto p:v) cout << I[p] << endl;

}

Measured memory_bytes: 20084
def roop_punch(list,num):
    while 1:
        list.sort()
        list=[i for i in list if i>0]
        #print(list)
        min_hp=min(list)
        min_index=list.index(min(list))
        for x in range(len(list)):
            if x==0:
                continue
            if list[x]/min_hp>0:
                list[x]=list[x]%min_hp
            else:
                list[x]-min_hp
        if min(list)==max(list):
            break

    return min(list)


# スペース区切りの整数の入力
a =int(input())
# 文字列の入力
input_list = list(map(int, input().split()))
#print(like_list)
s=roop_punch(input_list,a)
# 出力
print(s)


Measured memory_bytes: 14252
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}
    
void run(){
    int n;
    cin>>n;
    map<string,int> m;
    rep(i,n){
        string s;
        cin>>s;
        m[s]++;
    }
    int a=0;
    for(auto e:m){
        a=max(a,e.se);
    }
    for(auto e:m){
        if(a==e.se)cout<<e.fi<<endl;
    }
}

Measured memory_bytes: 23808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			String str[] = br.readLine().split(" ");
			int r = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			int C = Integer.parseInt(str[2]);
			int R = Integer.parseInt(str[3]);

			if (r == 0 && w == 0 && C == 0 && R == 0)
				break;

			double c = (double) r / w;
			int x = 0;

			while (c < C) {
				x++;
				c = (double) (r + x * R) / w;
			}
			System.out.println(x);
		}
	}
}


Measured memory_bytes: 24408
n = int(input())

# c = N - a*b
cnt = 0
for a in range(1, n, 1):
    for b in range(1, n, 1):
        if n <= a*b:
            break
        else:
            if a != b:
                cnt += 2
            else:
                cnt += 1
                break

print(cnt)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector <int> vi;
const int MOD = 1e9 + 7;

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    int k = a;
    while(a < 1e8){
        if(a % b == c % b){
            cout << "YES";
            return;
        }
        a += k;
    }
    cout << "NO";
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    int y = (int)(S[0] - '0') * 1000 + (S[1] - '0') * 100 + (S[2] - '0') * 10 + (S[3] - '0');
    int m = (int)(S[5] - '0') * 10 +  (S[6] - '0');
    int d = (int)(S[8] - '0') * 10 +  (S[9] - '0');
    //cout << y << m << d << endl;
    cout << (m < 4 || (m == 4 && d <= 30) ? "Heisei" : "TBD") << endl;
    return 0;
}

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

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

        double rad = (double)C * (M_PI / 180.);
        double x = b * cos(rad);
        double h = b * sin(rad);
        double S = a * h * 0.5;
        double aa = a - x;
        double d = sqrt((aa * aa) + (h * h));
        printf("%.8lf\n", S);
        printf("%.8lf\n", a + b + d);
        printf("%.8lf\n", h);
}



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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    double n;
    double minv = INT_MAX, maxv = 0;
    while (cin >> n)
    {
        if (maxv < n)
            maxv = n;
        if (minv > n)
            minv = n;
    }

    printf("%.3f", maxv - minv);
    return 0;
}


Measured memory_bytes: 3160
import collections
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

counter = collections.Counter()

for i in s:
    counter[i] += 1

for j in t:
    counter[j] -= 1

ans = max(counter.values())

print(ans if ans >=0 else 0)


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
#include<map>
#define pai 3.1415926535
using namespace std;
typedef pair<int, pair<int, int> >PP;
typedef long long ll;
typedef pair<int, int>P;
typedef vector<int>vec;
int inf=-1;
ll mod = pow(10, 9) + 7;
 
double rad2deg(double rad){
    return rad/pai*180;
}

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    double y=2.0*x/(a*a)-b;
    double ans;
    if(y<=0){
        y=2*x/a/b;
        ans=90-rad2deg(atan(y/b));

    }
    else{
        ans=90-rad2deg(atan(a/(b-y)));
    }
    cout<<setprecision(12)<<ans<<endl;
    return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

vector<int> g[100'000];
int visited[100'000];
vector<int> tsorted;

bool dfs(int u) {
    if(visited[u] == 1) return false;
    if(visited[u] == 0) {
        bool result = true;
        for(auto && v : g[u]) result = dfs(v) && result;
        if(!result) return false;
        visited[u] = 2;
        tsorted.push_back(u);
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n + m - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
    }
    for(int i = 0; i < n; ++i){
        dfs(i);
    }
    reverse(begin(tsorted), end(tsorted));
    vector<int> parent(n, -1);
    for(int i = 0; i < n; ++i){
        for(auto && j : g[tsorted[i]]){
            parent[j] = tsorted[i];
        }
    }
    for(int i = 0; i < n; ++i){
        cout << parent[i] + 1 << "\n";
    }
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'W') x.at(i) = 1;
    else y.at(i) = 1;
  }
  
  // x.at(i): 右端からi番目までのうち左向きの人
  // y.at(i): 左端からi番目までのうち右向きの人
  for (int i = 1; i < n; i++) x.at(i) += x.at(i - 1);
  for (int i = n - 2; i >= 0; i--) y.at(i) += y.at(i + 1);
  
  int ans = min(y.front(), x.back()); // 両端がリーダーのとき
  for (int i = 1; i < n - 1; i++) {
    ans = min(ans, x.at(i - 1) + y.at(i + 1));
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    vector<string> w(n);
    rep(i, n) cin >> w[i];
    
    unordered_set<string> us;
    rep(i, n) {
        if (us.count(w[i]) >= 1) {
            put("No");
            return 0;
        }
        if (i >= 1 && w[i-1][w[i-1].size() - 1] != w[i][0]) {
            put("No");
            return 0;
        }
        us.emplace(w[i]);
    }
            put("Yes");

    return 0;
}

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

int main()
{
    const int NumOfKindOfContestType = 26;  // タイプ1～26

    int D; cin >> D;    // 本番ではD = 365

    vector<int> c(NumOfKindOfContestType);
    rep(i, NumOfKindOfContestType) cin >> c[i];

    vector<vector<int>> s(D, vector<int>(NumOfKindOfContestType));
    rep(i, D)rep(j, NumOfKindOfContestType) cin >> s[i][j];

    vector<int> t(D);
    //rep(i, D) cout << t[i] << endl;
    rep(i, D)
    {
        cin >> t[i];
        t[i]--;
    }

    vector<int> last(26, -1);
    ll v = 0;
    rep(d, D)
    {
        v += s[d][t[d]]; // コンテスト開催による満足度の増加
        last[t[d]] = d;  // 指定タイプのコンテストを開催した最後の日

        // 特定のタイプのコンテストが開催されないと、日々、満足度が下がる
        rep(i, NumOfKindOfContestType) v -= c[i] * (d - last[i]);

        cout << v << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define MAX 50 

void get(ll a, ll arr[], ll n) 
{ 
    // array to store the orginal 
    // elements 
    ll elements[n + 1]; 
  
    // first element a i.e elements[0]=a 
    elements[0] = a; 
  
    for (int i = 0; i < n; i++) { 

        elements[i + 1] = arr[i] ^ elements[i]; 
    } 
  
    // Printing the original array elements 
    for (int i = 0; i < n + 1; i++) 
        cout << elements[i] << " "; 
}

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

   
    ll n;
    cin>>n;
    ll a[n];
    ll z=n-1;
    ll x=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        x^=a[i];
    }
    ll l=x;
    vector<ll>v;
    //v.push_back(x);
    ll j=1;
    ll i=0;
    ll k=n-1;
    while(z--){
        
        x^=a[i];
        x^=a[k%n];
        i++;
        k++;
        v.push_back(x);
    }
    v.push_back(l);
    
    for(int i=0;i<n;i++)
    cout<<v[i]<<" ";
    

    return 0;
}


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

int main()
{
	int  W;
	int  H;
	int  x;
	int  y;
	int  r;

	cin >> W>>H>>x>>y>>r;
	if (x+r>W||y+r>H ||x-r<0||y-r<0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}



Measured memory_bytes: 3100
s, t = input(), input()
ls, lt = [ [s[0], {0}] ], [ [t[0], {0}] ]

for i in range(len(s)-1):
  if s[i] != s[i+1]:
    b = True
    for j in range(len(ls)):
      if s[i+1] in ls[j][0]:
        ls[j][1].add(i+1)
        b = False
    if b:
      ls.append( [s[i+1], {i+1}] )
      
for i in range(len(t)-1):
  if t[i] != t[i+1]:
    b = True
    for j in range(len(lt)):
      if t[i+1] in lt[j][0]:
        lt[j][1].add(i+1)
        b = False
    if b:
      lt.append( [t[i+1], {i+1}] )

if len(ls) != len(lt):
  print("No")
else:
  for i in range(len(ls)):
    if ls[i][1] != lt[i][1]:
      print("No")
      exit()
  print("Yes")

Measured memory_bytes: 34768
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e9;
int num[1010];
int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k%2) cout<<(b-a)<<endl;
    else cout<<(a-b)<<endl;
    return 0;
}

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

double r;
double teisuu = 3.141592653589;
double mennseki,ennsyuu;

int main() {
  cin >> r;
  mennseki = r*r*teisuu;
  ennsyuu = 2*r*teisuu;
  cout << fixed << mennseki << " ";
  cout << fixed << ennsyuu << endl;
}

Measured memory_bytes: 3196
#include <iostream>
#include <queue>
#define INF 1000000000
using namespace std;

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

int main(){
	int n;
	vector<edge> es[100];
	priority_queue<P,vector<P>,greater<P> > que;
	int d[100];
	cin >> n;
	for(int i = 0;i < n;i++){
		int now,m;
		cin >> now >> m;
		for(int j = 0;j < m;j++){
			int a,b;
			cin >> a >> b;
			es[now].push_back({a,b});
		}
		d[i] = INF;
	}
	d[0] = 0;
	que.push(make_pair(0,0));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0;i < es[v].size();i++){
			edge e = es[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(make_pair(d[e.to],e.to));
			}
		}
	}
	for(int i = 0;i < n;i++) cout << i << " " << d[i] << endl;
	return 0;
}

Measured memory_bytes: 3124
n = int(input())

x = list(map(int,input().split()))
x.sort()

con = 0

for p in range(n):
    for q in range(p+1,n):
        for r in range(q+1,n):
            if x[p] != x[q] and x[q] != x[r] and x[r] < (x[p] + x[q]):
                con += 1
                
print(con);


Measured memory_bytes: 9124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int ans = 5000 * 2 * 100000 + 1;
        int maxZ = 2 * Math.max(x, y);
        for (int i_z = 0; i_z <= maxZ; i_z++) {
            int i_x = Math.max(0, x - i_z / 2);
            int i_y = Math.max(0, y - i_z / 2);
            ans = Math.min(ans, a * i_x + b * i_y + c * i_z);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
A=list(input())
from collections import deque
A=deque(A)
cnt=0
while len(A)>1:
   if A[0]==A[-1]:
      A.pop()
      A.popleft()
   elif (A[0]!="x" and A[-1]=="x" ):
      cnt+=1
      A.pop()
   elif (A[0]=="x" and A[-1]!="x" ):
      cnt+=1
      A.popleft()
   else:
      print(-1)
      exit()
print(cnt)

Measured memory_bytes: 10640
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long a=2,b=1,t;
    n--;
    while(n--){
        a=a+b;
        t=b;
        b=a;
        a=t;
    }
    cout<<b;
    return 0;
}


Measured memory_bytes: 256