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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int D = 0;
		int kaisu = 0;
		for(int i = 0; i < N; i++) {
			D += sc.nextInt();
			if (D <= X) {
				kaisu += 1;
			}
			else {
				break;
			}
		}
		System.out.println(kaisu + 1);
	}
}

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

using namespace std;

int main()
{
  string S;
  cin >> S;
  bool a = false, b = false, c = false, d = false;
  for(char& cc : S) {
    if(cc == 'N') a = true;
    else if(cc == 'S') b = true;
    else if(cc == 'W') c = true;
    else d = true;
  }
  if((a ^ b) + (c ^ d) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
def recursion(n,m,curList,res):
    if len(curList) == n:
        res.append(curList.copy())
        return

    for i in range(1,m+1):
        if len(curList) > 0 and i < curList[-1]:
            continue
        curList.append(i)
        recursion(n,m,curList,res)
        curList.remove(curList[-1])

def makeSequenceList(n,m):
    res = []
    recursion(n,m,[],res)
    return res

n,m,q = map(int,input().split())
quadList = []
for i in range(q):
    quad = [int(ch) for ch in input().split()]
    quadList.append(quad)
seqList = makeSequenceList(n,m)
ans = -1
for seq in seqList:
    sum = 0
    for quad in quadList:
        if seq[quad[1]-1] - seq[quad[0]-1] == quad[2]:
            sum += quad[3]
    ans = max(sum,ans)
print(ans)


Measured memory_bytes: 85228
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
const int mod = 1e9 + 7;

int main(){
    bool IsPrime[1001];
    fill(IsPrime,IsPrime+1001,true);
    for(int i=2;i<1001;i++){
        if(IsPrime[i]){
            int j=i;
            while(j+i<1001){
                j+=i;
                IsPrime[j]=false;
            }
        }
    }
    int N;
    cin>>N;
    int used[1001]={};
    for(int i=2;i<1001;i++){
        if(IsPrime[i]){
            int j=1;
            while(j*i <= N){
                j*=i;
                used[i]+=N/j;
            }
        }
    }
    int64_t res=1;
    for(int i=2;i<=N;i++){
        if(IsPrime[i]){
            res = res*(used[i]+1)%mod;
        }
    }
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int k, p;
        cin >> k >> p;

        int v = k % p;
        if (v == 0) {
            cout << p << endl;
        } else {
            cout << v << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
    int n,k;
    string s;
    cin >> n >> s >> k;
    char s1 = s[k-1];
    for (int i = 0; i < n; ++i) {
        if (s[i] != s1) s[i] = '*';
    } 
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 768
#include <atcoder/mincostflow>

#include <cstdio>
#include <vector>
#include <string>

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	
	std::vector<std::vector<int>> A(N, std::vector<int>(N));
	for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) scanf("%d", &A[i][j]);
	
	using ll = long long;
	atcoder::mcf_graph<int, ll> g(2 * N + 2);
	int source = 2 * N, sink = 2 * N + 1;
	
	// row [0, n), column [n, 2n)
	ll bias = 1'000'000'000;
	for (int i = 0; i < N; ++i) {
		g.add_edge(source, i, K, 0);
		g.add_edge(i + N, sink, K, 0);
	}
	
	for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
		g.add_edge(i, j + N, 1, bias - A[i][j]);
	}
	
	g.add_edge(source, sink, N * K, bias);
	
	auto ans = g.flow(source, sink, N * K);
	printf("%lld\n", bias * ans.first - ans.second);
	std::vector<std::string> anss(N, std::string(N, '.'));
	for (auto && e : g.edges()) {
		if (e.from == source || e.to == sink || e.flow == 0) continue;
		anss[e.from][e.to - N] = 'X';
	}
	for (int i = 0; i < N; ++i) printf("%s\n", anss[i].c_str());
	return 0;
}

Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

int gcd(int a, int b) {
	return b != 0 ? gcd(b, a%b) : a;
}
lli gcd(lli a, lli b) {
	return b != 0 ? gcd(b, a%b) : a;
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
lli lcm(lli a, lli b) {
	return a * b / gcd(a, b);
}

#define N_MAX 1000
#define MOD 1000000007

void solv()
{
	char C; scanf("%c", &C);
	printf("%c", C + 1);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}


Measured memory_bytes: 128
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

long long n,ans;
int main(){
  cin>>n;
  for(int i=1;i<=sqrt(n);++i){
    if(n%i==0&&n/i-1>i){ans+=n/i-1;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
big = 1
mod = 10 ** 9 + 7
for i in range(1,n):
  big *= i
  big %= mod
def inv(x):
  y = 1
  while x != 1:
    y *= mod // x + 1
    y %= mod
    x -= mod % x
  return y
tribe = [1 for _ in range(n)]
we = [1 for _ in range(n)]
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
seen = [0 for _ in range(n)]
pre = [0 for _ in range(n)]
seen[0] = 1
rank = []
now = [0]
while now:
  rank.append(now)
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if seen[y] == 0:
        seen[y] = 1
        now.append(y)
        pre[y] = x
#print(seen)
#print(pre)
#print(rank)
pre[0] = 10**6
rank.reverse()
for z in rank:
  if z == [0]:
    continue
  for w in z:
    tribe[pre[w]] += tribe[w]
    we[pre[w]] *= tribe[w] * we[w]
    we[pre[w]] %= mod
#print(tribe)
#print(we)
rank.reverse()
for z in rank:
  if z == [0]:
    continue
  for w in z:
    tmp = we[pre[w]]
    tmp *= inv(we[w]*tribe[w]%mod)
    tmp *= n - tribe[w]
    we[w] *= tmp
    we[w] %= mod
#print(we)
for i in range(n):
  print(big*inv(we[i])%mod)

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

int main(){
  	int N, M, ans=0;
  	cin >> N >> M;
  	if(N>=2){
    	ans+=N*(N-1)/2;
    }
  	if(M>=2){
    	ans+=M*(M-1)/2;
    }
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

ll mod_pow(ll x, ll n, ll modp){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % modp;
        x = x * x % modp;
        n >>= 1;
    }
    return res;
}

int main(void){
    int n, k;
    cin >> n >> k;
    vector<ll> m(k+1);

    for(int x=k; x>=1; x--){
        m[x] = mod_pow(floor(k/x), n, mod);
        int i = 2;
        while(i * x <= k){
            m[x] -= m[i * x];
            m[x] %= mod;
            i++;
        }
    }

    ll ans = 0;
    for(int i=1; i<=k; i++){
        ans += ll(i * m[i]) % mod;
        ans = ans % mod;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll N, Q;
string S;

// map<int, set<ll>> mp;
vector<set<int>> mp(26);

int main() {
    // set<ll> v = {2, 4, 5, 7};
    // auto it = v.lower_bound(5);
    // cout << *it << endl;
    // v.erase(it);
    // rep(i, v.size()) {
    //     cout << v[i] << " ";
    // }
    // return 0;

    cin >> N >> S >> Q;

    rep(i, S.size()) {
        mp[S[i] - 'a'].insert(i);
    }

    // cout << (upper_bound(v.begin(), v.end(), 5) - v.begin()) - (lower_bound(v.begin(), v.end(), 4) - v.begin()) << endl;
    // for (auto m : mp) {
    //     cout << m.first << endl;
    //     cout << "  ";
    //     for (auto s : m.second) {
    //         cout << s << " ";
    //     }
    //     cout << endl;
    // }

    rep(k, Q) {
        ll t;
        cin >> t;
        if (t == 1) {
            ll i;
            char c;
            cin >> i >> c;
            i--;

            // // idx 消す
            // for (int j = 0; j < 26; j++) {
            //     set<ll> target = mp[j];
            //     // auto idx = find(target.begin(), target.end(), i);
            //     if (target.count(i)) {
            //         // cout << "erase" << endl;
            //         // cout << *idx << endl;
            //         target.erase(i);
            //         mp[j] = target;
            //         break;
            //     }
            // }
            // i文字めを消す
            mp[S[i] - 'a'].erase(i);
            S[i] = c;

            // idx 挿入
            mp[c - 'a'].insert(i);
        } else {
            ll l, r;
            cin >> l >> r;
            l--; r--;
            ll ans = 0;
            for (int j = 0; j < 26; j++) {
                auto it = mp[j].lower_bound(l);
                if (it != mp[j].end() && *it <= r) {
                    ans++;
                };
                // ll tmp = (upper_bound(v.begin(), v.end(), r) - v.begin()) - (lower_bound(v.begin(), v.end(), l) - v.begin());
                // if (tmp > 0) {
                //    ans++;
                // }
            } 
            cout << ans << endl;
        }
    }

    // for (auto m : mp) {
    //     cout << m.first << endl;
    //     cout << "  ";
    //     for (auto s : m.second) {
    //         cout << s << " ";
    //     }
    //     cout << endl;
    // }
}

Measured memory_bytes: 27208
#include <stdio.h>
#include <algorithm>
#include <functional>
using namespace std;
int arr[110];
bool f(int a, int b){
return a>b ;}
int main(){
    int i;
    for(i=1;i<=9;i++){
        scanf("%d",&arr[i]);
    }
    if(arr[1]+arr[5]==arr[2]+arr[4]&&arr[1]+arr[9]==arr[3]+arr[7]&&arr[9]+arr[5]==arr[6]+arr[8]){
        printf("Yes");
    }
else printf("No");
}


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



int main() {
    int n;
    cin >> n;
    
    int cnt = 0, mn = 1001001001;
    ll sum = 0;
    rep(i,n) {
        int a;
        cin >> a;
        sum += abs(a);
        mn = min(abs(a),mn);
        if(a < 0) {
            cnt++;
        }
    }
    
    if(cnt % 2 == 1)
        sum -= mn * 2;
    
    cout << sum << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
 
typedef long long LL;
typedef pair<int, int> PII;

const int MAX = 1 << 20;

LL a[MAX];
char C[MAX];
int I[MAX], J[MAX], K[MAX];
int sz = 0;

void print(char c, int i, int j, int k)
{
	if(c == '+')
		a[k] = a[i] + a[j];
	else
		a[k] = a[i] < a[j];
	C[sz] = c;
	I[sz] = i - 1;
	J[sz] = j - 1;
	K[sz] = k - 1;
	sz++;
}

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//cin >> a[1] >> a[2];
	print('<', 3, 1, 3);
	print('<', 4, 2, 4);
	print('+', 3, 4, 3);
	print('<', 6, 7, 4);
	print('<', 4, 3, 3);
	print('+', 3, 1, 1);
	print('+', 3, 2, 2);
	print('+', 3, 8, 8);
	print('+', 3, 8, 8);
	int posBegin[2] = {10, 1000};
	int posBin[2] = {2000, 2050};
	const int len = 30;
	FOR(it, 0, 2)
	{
		int posA = 1 + it;
		int posSum = 4 + it;
		FOR(i, 0, 30)
		{
			int beg = posBegin[it] + i * len;
			print('+', 3, beg, beg);
			FOR(j, beg + 1, beg + len)
				print('+', j - 1, j - 1, j);
			FOR(j, beg, beg + len)
			{
				print('+', j, posSum, j);
				print('<', j, posA, j);
			}
			FOR(j, beg, beg + len - 1)
				print('<', j + 1, j, j);
			FOR(j, 0, len)
				print('+', beg + j, posBin[it] + j, posBin[it] + j);
			RFOR(j, beg + len - 1, beg)
			{
				print('+', j + 1, j, j);
				print('+', j + 1, j, j);
			}
			print('+', posSum, beg, posSum);
			FOR(j, beg, beg + len)
				print('<', 6, j, j);
			RFOR(j, beg + len - 1, beg)
				print('+', j, j + 1, j);
		}
	}
	const int posMult = 2100;
	const int buf = 2200;
	FOR(i, 0, 60)
	{
		FOR(j, max(0, i - 29), min(30, i + 1))
		{
			print('<', 6, posBin[0] + j, buf);
			print('+', posBin[1] + i - j, buf, buf);
			print('<', 3, buf, buf);
			print('+', posMult + i, buf, posMult + i);
		}
	}
	RFOR(i, 59, 0)
	{
		FOR(j, 0, 2)
			print('+', posMult + i + 1, posMult + i, posMult + i);
	}
	print('<', 6, 7, 3);
	print('+', posMult, 3, 3);
	cerr << a[3] << "\n";
	cout << sz << "\n";
	FOR(i, 0, sz)
		cout << C[i] << " " << I[i] << " " << J[i] << " " << K[i] << "\n";
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

template <typename T, typename U>
vector<U> make_vector(T&& n, U&& val) {
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
decltype(auto) make_vector(T&& n, Args&&... args) {
  return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...));
}

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

void solve() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  repic(i, l, r) {
    if (i % d == 0) ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;


int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = 0;
  if(a == 0) {
    cout << 0;
    return 0;
  }
  ans += ((n/(a+b))*a);
  if(n%(a+b) <= a) {
    ans+= n%(a+b);
  } else{
    ans+= a;
  }
  cout << ans;
}


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

const int N = 1e5;

bool uda[N+5];
int cnt[N+5];
int n,m;

int main(){
	scanf("%d%d",&n,&m);
	int ac = 0;
	int pen = 0;
	for(int i=1;i<=m;i++){
		int x;
		string s;
		cin >> x >> s;
		if(s[0] == 'A'){
			if(uda[x]) continue;
			uda[x] = 1;
			ac++;
			pen+=cnt[x];
		} else {
			cnt[x]++;
		}
	}
	printf("%d %d\n",ac,pen);
	return 0;
}


Measured memory_bytes: 768
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N = int(input())

ans = [N]*(N+1)
ans[0] = 0

for i in range(1,N+1):
    c6 = 1
    while c6 <= i:
        ans[i] = min(ans[i], ans[i-c6]+1)
        c6 *= 6
    c9 = 1
    while c9 <= i:
        ans[i] = min(ans[i], ans[i-c9]+1)
        c9 *= 9

print(ans[N])

Measured memory_bytes: 15020
#include <iostream>
#include <vector>
#include <algorithm>
 
int main(){
    std::vector<int> a(4);
     
    while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){
        int hit = 0, blow = 0;
         
        for(int i = 0; i < 4; ++i){
            int b;
            std::cin >> b;
             
            auto it = std::find(a.begin(), a.end(), b);
            if(it == a.begin() + i){
				++hit;
			}
            else if(it != a.end()){
				++blow;
			}
        }
        std::cout << hit << " " << blow << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 2980
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

const int N = 30;
int g[N];
int n;
int ans;
void dfs(int now, int cover, int cost) {
  if (ans<=cost) return;
  if (cover == (1<<n)-1) {ans=cost; return;}
  if (now == n) return;
  dfs(now+1, cover|g[now], cost+1);
  dfs(now+1, cover, cost);
}

int main() {
  int m;
  while(cin >> n >> m, n ||m) {
    REP(i, n) g[i] = 1<<i;
    REP(i, m) {
      int x, y;
      cin >> x >> y;
      g[x] |= 1<<y;
      g[y] |= 1<<x;
    }
    ans = n;
    dfs(0,0,0);
    cout << ans << endl;
  }
}

Measured memory_bytes: 868
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		//(pink and white and green) or (pink and white and green and yellow) 
		int n = scanner.nextInt();
		boolean existsY = false;
		for (int i = 0; i < n; i++) {
			if(scanner.next().equals("Y")) {
				existsY = true;
				break;
			}
		}
		if (existsY) {
			System.out.println("Four");
		}else {
			System.out.println("Three");
		}
		scanner.close();

	}

}


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

using namespace std;

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

Measured memory_bytes: 3620
N=int(input())
S = input()
w = [0]*(N+1)
b = [0]*(N+1)
for i, s in enumerate(S):
    if s=='.':
        w[i+1] = w[i]+1
        b[i+1] = b[i]
    elif s=='#':
        b[i+1] = b[i]+1
        w[i+1] = w[i]
ans = 10**20
for i in range(N+1):
    ans = min(ans, b[i]+w[N]-w[i])
print(ans)

Measured memory_bytes: 12840
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,sum=0;
    cin>>n>>m;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    sum+=vec.at(i);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    for(int i=1;i<=m;i++){
        if(vec.at(i-1)<(double)sum/(double)(4*m)){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int max = 0;

		int count = 0;
		for (int i = 0; i < N; i++) {
			int H = sc.nextInt();
			if (max <= H) {
				count++;
				max = H;
			}
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 25172
require 'set'

N = gets.to_i
S = gets.chomp

# i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
def calc_next
    res = Array.new(N+1) { Array.new(10) { N } }
    (0..(N-1)).to_a.reverse_each do |i|
        (0..9).each do |j|
            res[i][j] = res[i+1][j]
        end
        res[i][S[i].to_i] = i
    end
    res
end

nexts = calc_next

dp = Array.new(N+1) { Array.new(4) {0} }
dp[0][0] = 1
(0..(N-1)).each do |i|
    (0..9).each do |j|
        next if nexts[i][j] >= N
        dp[nexts[i][j] + 1][1] +=  dp[i][0]
        dp[nexts[i][j] + 1][2] +=  dp[i][1]
        dp[nexts[i][j] + 1][3] +=  dp[i][2]
    end
end

puts dp.inject(0) {|sum, n| sum + n[3] }


Measured memory_bytes: 9272
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int global_max = -1;
    int local_max = 0;
    for(char x:s){
        if(x=='R'){
            local_max++;
        }
        else{
            local_max = 0;
        }
        global_max = max(local_max,global_max);
    }
    cout<<global_max;
}


Measured memory_bytes: 3548
a, b, c, d = map(int,input().split())
#ls = list(map(int,input().split()))
#r = int(input())
#s = input()

if abs(a - b) <= d and abs(b - c) <= d:
  print("Yes")
elif abs(a - c) <= d:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import Control.Monad
import Data.List
import Data.Function

main :: IO ()
main = do
  l1 <- getLine
  let [n, m, x] = map read $ words l1 :: [Int]
  ln <- replicateM n getLine
  let ca = map (map read . words) ln :: [[Int]]
      asum = foldl (zipWith (+)) (repeat 0) $ map tail ca
      achieved = all (>=x) asum
  print $ if achieved then f n m x ca
    else -1

f n m x ca = head $ minimumBy (compare `on` head) pass
  where
    patterns = subsequences [0..n-1]
    calc = map (foldl (\acc i -> zipWith (+) acc $ ca !! i) (replicate (m + 1) 0)) patterns
    pass = filter (all (>=x) . tail) calc

Measured memory_bytes: 5028
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,m;cin>>n>>m;
  vector<int> ans(n,-1);
  bool ok = true;
  rep(t,m){
    int s,c;cin>>s>>c;
    if(ans[s-1] != -1 && ans[s-1] != c){
      ok = false;
    }
    ans[s-1] = c;
  }
  if(ans[0] == 0 && n != 1){
    ok = false;
  }
  if(!ok){
    cout<<-1<<endl;
    return 0;
  }
  rep(t,n){
    if(ans[t] == -1){
      if(t == 0 && n == 1){
        ans[t] = 0;
      }else if(t == 0 && n != 1){
        ans[t] = 1;
      }else{
        ans[t] = 0;
      }
    }
  }
  rep(t,n){
    cout<<ans[t];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()
else:
    P = list(map(int,input().split()))
L = [i for i in range(0,102) if i not in P]

if X in L:
    ANS = X
else:
    L.append(X)
    L = sorted(L)
    n = L.index(X)
    l = len(L) - 1


    if (0 < n < l):
        if (L[n+1]-L[n] < L[n] - L[n-1]):
            ANS = L[n+1]
        else:
            ANS = L[n - 1]
    elif (n == l):
        ANS = L[l - 1]

print(ANS)

Measured memory_bytes: 9228
n = int(input())
l = [int(x) for x in input().split()]
l.append(100000) #100000はダミー
#print(n, l, len(l))
z = []
z.append(l[0]) # z[0]のみl[0]と決まる
for i in range(len(l)-1):
    #print(i)
    z.append(min(l[i],l[i+1]))

print(sum(z))


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(),a.end());
  double ans=(a[0]+a[1])/2.0;
  
  rep(i,n-2){
    ans = (ans+a[i+2])/2.0;
  }
  
  cout << ans << endl;

  return(0);
}

Measured memory_bytes: 3672
# B - Ordinary Number

N = int(input())
data = list(map(int, input().split()))
ans = 0
for i in range(N-2):
    if (data[i+1] > data[i] and data[i+1] < data[i+2]) or (data[i+1] < data[i] and data[i+1] > data[i+2]):
        ans += 1

print(ans)


Measured memory_bytes: 38384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] s = new boolean[200010];
        boolean[] t = new boolean[200010];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a == 1) {
                s[b] = true;
            }
            if (b == n) {
                t[a] = true;
            }
        }
        boolean ans = false;
        for (int i = 0; i < n; i++) {
            if (s[i] && t[i]) {
                ans = true;
                break;
            }
        }
        if (ans) {
            System.out.println("POSSIBLE");
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 93464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>


using namespace std;
typedef long long ll;

int main(){
  long double a,b,x;
  cin >> a >> b >> x;
  float y = x*1.0/a;
  long double ans = 0;
  if(y<a*b/2.0){
    ans = atan(2.0*x/(a*b*b));
  }else{
    ans = atan(a/(2.0*(-x*1.0/(a*a)+b)));
  }
  ans = 90 - ans/M_PI*180.0;
  printf("%Lf12\n",ans);
}


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

//const int MAX_LEN = 200002;

int main()
{
int n, p;
cin >> n;
while (n >= 1000)
{
  n = n % 1000;
}
if (n == 0)
  cout << 0 << endl;
else {
  int ans = 1000 - n;
  cout << ans << endl;
}

return 0;
}

Measured memory_bytes: 3632
n = int(input())
mlist = []
plist = [2]
for i in range(3,10000):
    count = 0
    for k in plist:
        if (i%k != 0):
            count += 1
        else:
            break
    if (count == len(plist)):
        plist.append(i)
def check(m):
    for p in plist:
        if (m <= p):
            return True
        if m%p == 0:
            return False     ##한번이라도 False가 return되면 False가 되기에 prime인지 아닌지 check가능
    return True

count = 0
for i in range(n):
    m = int(input())
    if check(m):
        count += 1
        
print(count)  


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

int main(){
    int D,N;
    cin >>D>>N;
    if(N!=100){    
    long long count=N;
    for(int i=0;i<D;++i){
        count*=100;
    }
    cout <<count <<endl;
    }
    else{
    long long count=101;
    for(int i=0;i<D;++i){
        count*=100;
    }
    cout <<count <<endl;
    }

}

Measured memory_bytes: 3552
#include <stdio.h>

void Sort_big(char* c, char *c_s);
void Sort_small(char* c, char *c_s);
int Hikaku(char *s_s,char *t_s);

int main(void){
	char s[100] = {0};
	char t[100] = {0};
	char s_s[100] = {0};
	char t_s[100] = {0};

	scanf("%s%s",&s,&t);

	Sort_small(&s[0], &s_s[0]);
	Sort_big(&t[0], &t_s[0]);

//	printf("s' : %s\nt' : %s\n",s_s,t_s);
//	printf("s' < t' = ");

	if(Hikaku(s_s,t_s) == 0)	printf("Yes");
	else	printf("No");
	return 0;
}


//	大きい順にソート
void Sort_big(char *c , char *c_s){
	int i,j;
	char max_c = 0;
	int max_i = 0;

	for(j = 0; j < 100; j++){
		for(i = 0; i < 100; i++){
			if(max_c < c[i]){
				max_c = c[i];
				max_i = i;
			}
	}
	if(max_c == 0)	break;
		c_s[j] = max_c;
		c[max_i] = 0;
		max_c = 0;
	}

}

//	小さい順にソート
void Sort_small(char *c , char *c_s){
	int i,j;
	char max_c = 0;
	char bf_c_s[100];
	int max_i = 0;

	for(j = 0; j < 100; j++){
		for(i = 0; i < 100; i++){
			if(max_c < c[i]){
				max_c = c[i];
				max_i = i;
			}
	}
	if(max_c == 0)	break;
		bf_c_s[j] = max_c;
		c[max_i] = 0;
		max_c = 0;
	}

	for(i = 0; j >= 0; i++){
		j--;
		c_s[i] = bf_c_s[j];
	}
	

}


//	s' < t' なら0返す s'> t'なら1返す
int Hikaku(char *s_s,char *t_s){
	int i;
	for(i = 0; i < 100; i++){
		if(t_s[i] != s_s[i]) break;
		if(i == 99) return 1;
	}
	for(i = 0; i < 100; i++){
		if(s_s[i] != EOF && t_s[i] == EOF)	return 0;
		if(t_s[i] < s_s[i])	return 1;
		if(t_s[i] > s_s[i]) return 0;
	}

	return -1;
}

Measured memory_bytes: 128
n = int(input())
li = []
for i in range(n):
    li.append(int(input()))
li.sort()
flag1 = False
flag2 = False
flag3 = False
if sum(li)%10 != 0:
    flag2 = True

for i in range(n):
    if (sum(li) - li[i])%10 != 0 and flag2 == False:
        flag1 = True
        break
    else:
        flag3 =True
    
if flag1:
    print (sum(li) - li[i])
elif flag2:   
    print(sum(li))
elif flag3:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int numr,numw,ans;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<=s.size()-1;i++)
	{
		if(s[i]=='R')
			numr++;
		else
			numw++;
	}
	string ss="";
	for(int i=1;i<=numr;i++)
		ss+='R';
	for(int i=1;i<=numw;i++)
		ss+='W';
	for(int i=0;i<=ss.size()-1;i++)
	{
		if(ss[i]=='R'&&s[i]=='W')
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}




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

int main(void){
   int N,A,B;
   int a=0,b=0,c=0;
   int max;

    cin>>N>>A>>B;

    int P[N];

    for(int i=0;i<N;i++)
        cin>>P[i];

    for(int i=0;i<N;i++){
        if(P[i]>=1&&P[i]<=A){
            a+=1;
        }else if(P[i]>A&&P[i]<=B){
            b+=1;
        }else if(P[i]>B&&P[i]<=20){
            c+=1;
        }
    }

    if(a>=b)
        max=b;
    else
        max=a;


    if(max>=c)
        max=c;

    cout<<max<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[100];
	int n;
	scanf("%d %s", &n, s);

	int i = 0, x = 0, max = 0;
	for(i = 0; i < n; i++) {
		if(s[i] == 'I') {
			x++;
			if(max < x) {
				max = x;
			}
		}
		else {
			x--;
		}
	}

	printf("%d", max);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sqr(x) (x) * (x)
#define cube(x) (z) * (z) * (x)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}
string ans;
signed main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  ans = "";
  rep(i, ty - sy) {
    ans += 'U';
  }
  rep(i, tx - sx) {
    ans += "R";
  }
  rep(i, ty - sy) {
    ans += 'D';
  }
  rep(i, tx - sx + 1) {
    ans += "L";
  }
  rep(i, ty - sy + 1) {
    ans += 'U';
  }
  rep(i, tx - sx + 1) {
    ans += "R";
  }
  ans += "D";
  ans += "R";
  rep(i, ty - sy + 1) {
    ans += 'D';
  }
  rep(i, tx - sx + 1) {
    ans += "L";
  }
  cout << ans + "U" << endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<double> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dp[i + 1][j] += dp[i][j] * (1 - P[i]);
      dp[i + 1][j + 1] += dp[i][j] * P[i];
    }
  }
  double res = 0;
  for (int i = (N + 1) / 2; i < N + 1; i++) {
    res += dp[N][i];
  }
  cout << fixed << setprecision(10) << res << '\n';
  return 0;
}


Measured memory_bytes: 70784
package main

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

func main() {
	A := readint()
	B := readint()
	m := map[int]bool{
		1: false,
		2: false,
		3: false,
	}
	m[A] = true
	m[B] = true
	for k, v := range m {
		if !v {
			fmt.Println(k)
			return
		}
	}
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


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

int h,w;
char grid[105][105];
int dx[]={0,1},dy[]={1,0};
const int INF=1000000010;

int main(){
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++)scanf("%s",grid[i]);
	int dist[h][w];
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)dist[i][j]=INF;
	dist[0][0]=0;
	queue<int> q;
	q.push(0);
	while(!q.empty()){
		int x=q.front()/w,y=q.front()%w;q.pop();
		for(int i=0;i<2;i++){
			int nx=x+dx[i],ny=y+dy[i];
			if(0<=nx&&nx<h&&0<=ny&&ny<w){
				if(grid[nx][ny]!=grid[x][y]&&dist[nx][ny]>dist[x][y]+1){
					dist[nx][ny]=dist[x][y]+1;
					q.push(nx*w+ny);
				}else if(grid[nx][ny]==grid[x][y]&&dist[nx][ny]>dist[x][y]){
					dist[nx][ny]=dist[x][y];
					q.push(nx*w+ny);
				}
			}
		}
	}
	if(grid[0][0]=='#'||grid[h-1][w-1]=='#'){
		printf("%d",dist[h-1][w-1]/2+1);
	}else{
		printf("%d",dist[h-1][w-1]/2);
	}
}


Measured memory_bytes: 256
N=int(input())
A = [int(x) for x in input().split()]

ans=1
if 0 in A:
    ans = 0
else:
    A.sort(reverse=True)
    for a in A:
        if a > 10**18:
            ans = -1
            break
        else:
            ans *= a
            if ans > 10**18:
                ans = -1
                break
print(ans)

                


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

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

const int MAXV = 100010;

bool used[MAXV];
vector<int> g[MAXV];
vector<int> rg[MAXV];
vector<int> out;
int rk[MAXV];

int n, m;

void dfs(int u){
    used[u] = true;
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i];
        if(!used[v]) dfs(v);
    }
    out.push_back(u);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for(int i=0;i<n+m-1;i++){
        int a, b; cin >> a >> b;
        g[a].push_back(b);
        rg[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        if(!used[i]) dfs(i);
    }
    reverse(out.rbegin(), out.rend());
    for(int i=0;i<out.size();i++) rk[out[i]] = i;
    // for(int i=1;i<=3;i++) cout << rk[i] << endl;
    vector<int> ans(n+1);
    for(int i=1;i<=n;i++){
        int par = -1;
        int rkmax = -1;
        for(int j=0;j<rg[i].size();j++){
            int v = rg[i][j];
            if(rk[v] < rk[i]){
                if(rk[v] > rkmax){
                    par = v;
                    rkmax = rk[v];
                }
            }
        }
        ans[i] = par;
    }
    ans[out[0]] = 0;
    for(int i=1;i<=n;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 15356
#include<stdio.h>
int main(){
  int n,i;
  int data[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }
  for(i=n-1;i>=0;i--){
    printf("%d",data[i]);
    if(i!=0)printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2756
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(10);
    double ang = 360.0/12.0;
    double angm = 360.0/60.0;
    // double dif=0;
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    h=h*ang + (m/60)*ang;
    m*=angm;
    double angr = min(max(h,m)-min(h,m),min(h,m)+360-max(h,m));
    // double angr = dif;
    // cout<<angr<<endl;
    double ans = sqrt(pow(a,2)+pow(b,2)-2*a*b*cos((angr*pi)/180));
    cout<<ans<<"\n";
    return 0;   
}

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

using namespace std;

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

    int a, b, q;
    cin >> a >> b >> q;
    vector<long long> s(a), t(b);

    for (int i = 0; i < a; i++)
        cin >> s[i];
    for (int i = 0; i < b; i++)
        cin >> t[i];

    while (q--) {
        long long x, ans = 2e18;
        int sr, tr, sl, tl;
        cin >> x;
        sr = lower_bound(s.begin(), s.end(), x + 1) - s.begin();
        tr = lower_bound(t.begin(), t.end(), x + 1) - t.begin();
        sl = lower_bound(s.begin(), s.end(), x) - s.begin() - 1;
        tl = lower_bound(t.begin(), t.end(), x) - t.begin() - 1;

        if (sr < a && tr < b)
            ans = min(ans, max(s[sr], t[tr]) - x);

        if (sl >= 0 && tl >= 0)
            ans = min(ans, x - min(s[sl], t[tl]));

        if (sl >= 0 && tr < b)
            ans = min(ans, min(x - s[sl], t[tr] - x) + (t[tr] - s[sl]));

        if (sr < a && tl >= 0)
            ans = min(ans, min(x - t[tl], s[sr] - x) + (s[sr] - t[tl]));

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

Measured memory_bytes: 2944
import sys

s = input()
t = input()
check = []
check.append(t[len(t)-1]+t[0:len(t)-1])
for i in range(1, len(t)+1):
    check.append(check[i-1][len(t)-1]+check[i-1][0:len(t)-1])
    if s == check[i-1]:
        print('Yes')
        sys.exit()
print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))
 
typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int r;
  cin>>r;
  
  cout<<2*r*M_PI;

  return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <vector>
#include <map>

int main(){
   int N;
   std::cin >> N;
   int A;
   std::map<int,int> length;
   for(int i=0; i<N; ++i){
      std::cin >> A;
      length[A]++;
   }
   long long x = 0;
   long long y = 0;
   for(auto itr=length.begin(); itr!=length.end(); ++itr){
      if(itr->second>3){
	 long long tmp = itr->first;
	 if(tmp>x){
	    x = tmp;
	    y = tmp;
	 }else if(tmp>y) y=tmp;
      }else if(itr->second>1){
	 long long tmp = itr->first;
	 if(tmp>x){
	    y = x;
	    x = tmp;
	 }else if(tmp>y) y=tmp;
      }
   }
   std::cout << x*y << std::endl;
   return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <string>
#define rep(i,N) for(int i=0;i<(N);i++)
using namespace std;

int main(){
	long long N,i=0;
	cin>>N;
	vector<long long> p;

	while(N!=0){
		N=N-1;
		p.push_back(N % 26);
		N = N / 26;
		i++;
	}
	string res = "";
	for(int i = p.size() -1 ; i >= 0 ; i-- )res += (char)('a' +p[i]);
	cout<<res<<endl;
}

Measured memory_bytes: 3608
N = int(input())
S = input()

count = 0
maxcount = 0
for i in range(N):
    if S[i] == ")":
        count += 1
        maxcount = max(count, maxcount)
    else:
        count -= 1

if maxcount > 0:
    S = "(" * maxcount + S

count = 0
maxcount = 0

for i in range(len(S)):
    if S[i] == "(":
        count += 1
    else:
        count -= 1

if count > 0:
    S += ")" * count

print(S)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
#define is_uruu main
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
    
int is_uruu() {
	long long N,M;
	cin >> N >> M;
	if(N==1 && M==1){
		cout << 1 << endl;
		return 0;
	}
	if(N==1){
		cout << M-2 << endl;
		return 0;
	}
	if(M==1){
		cout << N-2 << endl;
		return 0;
	}
	if(N==2 || M==2){
		cout << 0 << endl;
		return 0;
	}
	cout << (N-2)*(M-2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;

int vis[55],len_s,len_h;
char s[55],h[55];
string k[55];

bool slove(int pos){
	int head = 1;
	for(int i = pos;i <= len_s;i++){
		if(s[i] == h[head] || s[i] == '?') vis[i] = head;
		else return false;
		head++;
		if(head == len_h + 1) return true;
	}
}

int main(){
	cin >> s + 1;
	cin >> h + 1;
	len_s = strlen(s + 1);
	len_h = strlen(h + 1);
	if(len_h > len_s){
		cout << "UNRESTORABLE" << endl;
	}
	else{
		int ans = 0;
		for(int i = 1;i <= len_s - len_h + 1;i++){
			memset(vis,0,sizeof(vis));
			if(slove(i)){
				ans++;
				for(int j = 1;j <= len_s;j++){
					if(s[j] == '?' && vis[j] == 0) k[ans] += 'a';
					else if(vis[j] != 0) k[ans] += h[vis[j]];
					else k[ans] += s[j];
				}
			}
		}
		if(ans == 0) cout << "UNRESTORABLE";
		else{
			sort(k + 1,k + ans + 1);
			cout << k[1] << endl;
		}
	}
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadLine().ToCharArray();
            WriteLine((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3]) ? "Yes" : "No");
        }
    }
}



Measured memory_bytes: 13140
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction

n = int(input())
xors = list(map(int, stdin.readline().split()))
nums = []
a1 = 0
for i in xors[1:]:
    a1^= i
nums.append(a1)
for i in xors[1:]:
    nums.append(xors[0]^a1^i)

print(*nums)




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

int main(){
    int sx, sy, tx, ty, dx, dy;
    cin >> sx >> sy >> tx >> ty;
    dx = tx - sx;
    dy = ty - sy;
    string w, wb = "";
    rep(i, dx) {
        w += 'R';
        wb += 'L';
    }
    rep(i, dy) {
        w += 'U';
        wb += 'D';
    }
    string ans = w + wb + "DR" + w + "UL" + "UL" + wb + "DR";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var sort = line.OrderBy(x => x).ToArray();
        int miss = 0;
        bool isYes = true;
        for(int i=0;i<N;i++){
            if(line[i]!=sort[i]){
                miss++;
            }
            if(miss>2){
                isYes = false;
                break;
            }
        }
        if(isYes){
            Console.WriteLine("YES");
        }else{
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
    int k;
    string s;
int main()
{
    cin>>k>>s;
    if(s.size()<=k)
        cout<<s<<endl;
    else
    {
        for(int i=0;i<k;i++)
        cout<<s[i];
        cout<<"..."<<endl;
    }
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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 div_game(ll x){
    unordered_map<ll, ll> m;
    
    if(!(x&1)){
        while(!(x&1) && x!=1){
            m[2]++;
            x >>= 1;
        }
    }

    for(ll i=3; i*i<=x; i+=2){
        // pr(i);
        if(x%i==0){
            while(x%i==0 && x!=1){
                m[i]++;
                x /= i;
            }
        }
    }

    if(x!=1) m[x]++;

    ll ans=0;

    vector<ll> v(101, 0);
    rep(i, 100) v[i+1] = v[i] + i + 1;

    for(auto e: m){
        int t = upper_bound(ALL(v), e.second) - v.begin() - 1;
        ans += t;
    } 

    return ans;
}

int main()
{
    ll x; cin >> x;
    pr(div_game(x));
    return 0;}

Measured memory_bytes: 3648