akhauriyash/Code-Regression huggingface dataset:
/*author : Yashvardhan
Sunday, May 03, 2020
6:01 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin >> n;

	vi arr(n + 1);
	map<int,int> mapi;
	for(int i = 1; i <= n; i++){
		cin >> arr[i];
		mapi[(i - arr[i])]++;
	}

	int ans = 0;
	for(int i = 1; i <= n; i++){
		mapi[(i - arr[i])]--;
		ans += mapi[(arr[i] + i)];
	}

	cout << ans << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 27516
package main

import (
	"fmt"
	"strconv"
)

func main() {
	result := make([]int, 0, 200)

	for {
		var a, b int
		scanCount, _ := fmt.Scanf("%d %d", &a, &b)
		if scanCount == 2 {
			result = append(result, a+b)
		} else {
			break
		}
	}

	for _, v := range result {
		length := len(strconv.Itoa(v))

		fmt.Println(length)
	}
}



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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vi l(n);
    rep(i, n) cin >> l[i];
    VSORT(l);
    ll cnt = 0;
    rep(i, n) for (int j=i+1; j<n; ++j) {
        cnt += distance(l.begin(), lower_bound(all(l), l[i]+l[j])) - (j+1);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int N,M,X;cin>>N>>M>>X;
    vector<int>A[N];
    int C[N];
    REP(i,N){
        cin>>C[i];
        REP(j,M){
            int a;cin>>a;
            A[i].pb(a);
        }
    }
    int ans=INF;
    for(int i=0;i<(1<<N);i++){
        vector<int>sum(M,0);
        bitset<12>s(i);
        int money=0;
        REP(j,12){
            if(s.test(j)){
                money+=C[j];
                REP(k,M){
                    sum[k]+=A[j][k];
                }
            }
        }
        bool ok=true;
        REP(j,M){
            if(sum[j]<X)ok=false;
        }
        if(ok)chmin(ans,money);
    }
    cout<<(ans==INF?-1:ans)<<endl;
}

Measured memory_bytes: 3636
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline);
n = Number(line.shift());
adj = {};
for (i in line) {
  ary = line[i].split(' ');
  j = ary.shift();
  ary.shift();
  adj[j] = ary;
}

node = new Array(n + 1);
node[0] = null;
node[1] = 0;
for (i = 2; i <= n; i++) node[i] = -1;

d = 1;
do {
  cnt = 0;
  for (i = 1; i <= n; i++) {
    if (node[i] !== d - 1) continue;
    for (j in adj[i]) {
      k = adj[i][j];
      if (node[k] === -1) {
        node[k] = d;
        cnt++;
      }
    }
  }
  d++;
} while (cnt !== 0);

for (i = 1; i <= n; i++)
  console.log("%d %d", i, node[i]);

Measured memory_bytes: 15460
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int D, Q, x[131072], ls, rs, es, a, b; vector<int> seg[262144];
int query(int k, int l, int r) {
	if (r <= ls || rs <= l) return 0;
	if (ls <= l && r <= rs) return lower_bound(seg[k].begin(), seg[k].end(), b) - lower_bound(seg[k].begin(), seg[k].end(), a);
	int lc = query(2 * k, l, (l + r) / 2);
	int rc = query(2 * k + 1, (l + r) / 2, r);
	return lc + rc;
}
int main() {
	scanf("%d", &D);
	for (int i = 0; i < D; i++) {
		scanf("%d", &x[i]);
		int t = i + 131072;
		while (t > 0) {
			seg[t].push_back(x[i]);
			t >>= 1;
		}
	}
	for (int i = 1; i < 262144; i++) {
		if (seg[i].size() > 1) {
			sort(seg[i].begin(), seg[i].end());
		}
	}
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d%d%d", &ls, &rs, &es); ls--;
		a = min(x[ls], x[rs - 1]) - es;
		b = max(x[ls], x[rs - 1]) + es + 1;
		printf("%d\n", rs - ls - query(1, 0, 131072));
	}
	return 0;
}

Measured memory_bytes: 21228
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)
    var m, n = scanner.nextInt

    if(m < n) {
      val t = m
      m = n
      n = t
    }

    while(true) {
      if(n == 0) {
        println(m)
        System.exit(0)
      }
      val t = n
      n = m % n
      m = t
    }
  }
}



Measured memory_bytes: 45112
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
i=0
j=0
#N=int(input())
#N, W=input().split()
S=input()
#T=input()
#S_list=list(S)
#h_list=  list(map(int, input().split(" ")))
#M=int(input())
#drink_list = [list(map(int, input().split(" ")))for i in range(M)]
#print(T_list[1])
#N=int(N)
#W=int(W)
#不本意だが内包表記で二次元の空のリストを作成する

#dp=[['' for i in range(2)] for j in range(N)]
#K=int(K)
#S_list=[]
sentence_list=[]
#total=0
#mojiretu=""
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
#for i in range(K):
# ID_list.append(i+1)
#print(ID_list)
#for i in range(H)
#この下の行が二次元リストの読み込
#intを消して記号を読み込めるようにしたしかしこれでは文字列から読み込んでいるのと同じ
#weight_value_list =  [list(input())for i in range(N)]#一文字づつばらして入れてしまう
#s = [input() for i in range(N)]
#複数行に複数の入力値を取得し、出力する
#sentence_list =  (list(input())for i in range(N))
#for i in range(H):
#  ppixel_list=list(input())
#
#print(pixel_list)
#high_pixel_list =[['' for i in range(W)]for j in range(2*H)]
#print(high_pixel_list)
#print(pixel_list[0][1])#行　列の順番にかっこが並んでいる
#print(a_list)
first_term=0
second_term=0
#整数二次元配列を読み込む時のやり方
#a_b_c_list =  [list(map(int, input().split(" ")))for i in range(N)]

#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
#print(S)
#sentence_list=sorted(S)
p=-10000
sentence_list=list(S)
#print(sentence_list)
#スペースでいれつつ値を取得
if len(S) <4 or len(S) > 10:
    print("WA")
    sys.exit()

if sentence_list[0]=="A":# and sentence_list[2]=="C":
    #print(1231234)
    #del sentence_list[0]
    pass
else:
    print("WA")
    sys.exit()

for j in range(len(sentence_list)-3):
    #print(len(S))
    #print(sentence_list[j+2])
    #if j+4==len(sentence_list):
        #print("WA")

        #sys.exit()
    if sentence_list[j+2]=="C":
        #del sentence_list[j+2]
        p=j+2
        break

#print(sentence_list)
if p> 0:
    del sentence_list[p]
if p< 0:
    print("WA")
    sys.exit()
del sentence_list[0]
#print(sentence_list)

S="".join(sentence_list)

if S.islower()==True:
    print("AC")
    sys.exit()
#print(123)
print("WA")


#x, y = [0]*N, [0]*N#N個の空のリストを作成
#l = list(range(N))#範囲がNのリストを作成する

#for i in range(N):
#  x[i], y[i] = map(int, input().split())
#分けて入力する形式を設定することで可読性が高く仕上がっている
#素晴らしいことだ


distance = 0
#comb = list(itertools.permutations(l))
#prmutation:英語の意味としては順列である
'''p[, r]で
長さrのタプル列、重複なしのあらゆる並びを表す
今回はリストlの重複なしの並び替え順序を新たなリストに収納している
並び方を計算しリストに収納しているイメージ
l[0,1,2]
l[0,2,1]これにもリスト番号が0,1,2と割り振られている
これが全通り入っている
これ作った人はすごい
自分も早く理解したい
'''
#for i in range(0, len(comb)):#i番目のパターンの時を考える。
#  for j in range(0, N-1):#lのリスト番号を読み込み
#    distance += math.sqrt((x[comb[i][j]]-x[comb[i][j+1]])**2 + (y[comb[i][j]]-y[comb[i][j+1]])**2)
'''
各経路の距離を足していき全距離分を経路数
で割れば平均距離が出るので各経路ごとの距離は
不必要と判断されている。
'''
#print(distance/len(comb))
i=0
j=0
#1を選んだとき0,2を選ぶってのがどう実装すべきかわからんかった
#だからここで学ぶ
#2019/1/4参考サイトに見当たらず 　仕方がないのでその場しのぎ
#for i in range(N):
for j in range(3):
        pass
      # dp[i+1][j]=max(dp[i][j]+a_b_c_list[i],dp[i][j],dp[i][j])
#リストを一周するようにすればいいのか


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)

//cerrはコメントアウトしなくても通る

int main(){
    int n;
    cin >> n;
    double ans;
    int m=(n+1)/2;
    double a=m,b=n;
    ans=a/b;
    printf("%.10f\n",ans);
    return 0;
}

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

int main() {
    int n;
    cin >> n;

    int r[n];

    for (int i = 0; i < n; i++) {
        cin >> r[i];
    }


    int min = std::min(r[0], r[1]);
    int max = r[1] - r[0];

    for (int i = 2; i < n; i++) {
        max = std::max(max, r[i] - min);
        min = std::min(min, r[i]);
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 3888
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'a')+1)
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
const double pi=acos(-1);
const int maxn=1000005;;
//const ll Mod=1000000007;
const ll Mod=998244353;
using namespace std;


int n,cnt[maxn],sum[maxn],tmp=2,ans;
char a[maxn];
int main()
{
    sync;
    cin>>n;
    cin>>a;
    for(int i=0;i<n;i++)
    {
        a[i]-='1';
        if(a[i]==1)
            tmp=1;
    }
    for(int i=1;i<n;i++)
    {
        sum[i]=sum[i-1]+(cnt[i]=(i&1?0:cnt[i>>1]+1));
    }
    for(int i=0;i<n;i++)
    {
        if(sum[n-1]==sum[i]+sum[n-i-1])
            (ans+=a[i]/tmp)&=1;
    }
    cout<<ans*tmp<<endl;
    return 0;
}


Measured memory_bytes: 9088
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int n;
string s;
void solve(bool fs, bool ls){
    bool ps, ps2, pw, pw2;
    ps2 = ls; pw2 = !ls;
    ps = fs; pw = !fs;
    for(int i=1;i<n;i++){
        bool ns = (ps && s[i] == 'o' && ps2) || (ps && s[i] == 'x' && pw2) || (pw && s[i] == 'o' && pw2) || (pw && s[i] == 'x' && ps2),
             nw = (ps && s[i] == 'o' && pw2) || (ps && s[i] == 'x' && ps2) || (pw && s[i] == 'o' && ps2) || (pw && s[i] == 'x' && pw2);
        ps2 = ps;
        pw2 = pw;
        ps = ns;
        pw = nw;
    }
    bool ok = (ls && ps) || (!ls && pw);
    prints(ok);
    vector<int> pss(n + 1), pws(n + 1);
    pss[0] = ls; pws[0] = !ls;
    pss[1] = fs; pws[1] = !fs;
    for(int i=2;i<=n;i++){
        pss[i] = (pss[i-1] && s[i-2] == 'o' && pss[i-2]) || (pss[i-1] && s[i-2] == 'x' && pws[i-2]) || (pws[i-1] && s[i-2] == 'o' && pws[i-2]) || (pws[i-1] && s[i-2] == 'x' && pss[i-2]);
        pws[i] = (pss[i-1] && s[i-2] == 'o' && pws[i-2]) || (pss[i-1] && s[i-2] == 'x' && pss[i-2]) || (pws[i-1] && s[i-2] == 'o' && pss[i-2]) || (pws[i-1] && s[i-2] == 'x' && pws[i-2]);
    }
    pss[1] &= (pss[n] && s[n-1] == 'o' && pss[n-1]) || (pss[n] && s[n-1] == 'x' && pws[n-1]) || (pws[n] && s[n-1] == 'o' && pws[n-1]) || (pws[n] && s[n-1] == 'x' && pss[n-1]);
    pws[1] &= (pss[n] && s[n-1] == 'o' && pws[n-1]) || (pss[n] && s[n-1] == 'x' && pss[n-1]) || (pws[n] && s[n-1] == 'o' && pss[n-1]) || (pws[n] && s[n-1] == 'x' && pws[n-1]);
    // bool ok2 = (ls && pss[n]) || (!ls && pws[n]);
    bool ok2 = ((ls && pss[n]) || (!ls && pws[n])) && ((fs && pss[1]) || (!fs && pws[1]));
    prints(ok2);
    prints(pss, pws);
    if(!ok2){ return; }
    for(int i=1;i<=n;i++){
        cout << (pss[i] ? 'S' : 'W');
    }
    cout << '\n';
    exit(0);
}

int main(){
    cin >> n;
    cin >> s;
    solve(false, false);
    solve(false, true);
    solve(true, false);
    solve(true, true);
    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 1344
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int w,n,c,x,y;
	cin>>w>>n;
	int a[w+1]={0};
	for(int i=0;i<=w;i++)a[i]=i;
	for(int i=0;i<n;i++)
	{
		scanf("%d,%d",&x,&y);
		c=a[x],a[x]=a[y],a[y]=c;
	}
	for(int i=1;i<=w;i++)
	{
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);


void solve(long long N, std::vector<std::string> s){
    ll ans=0;
    ll cnt[3]={0,0,0};
    for (auto &&ss : s)
    {
        if(ss[0]=='B'&&ss[ss.size()-1]=='A')cnt[2]++;
        else if(ss[0]=='B')cnt[1]++;
        else if(ss[ss.size()-1]=='A')cnt[0]++;
        for(long long i = 0; i < ss.size()-1; i++){
            dump(i);
            dump(ss.substr(i,2));
            if(ss.substr(i,2)=="AB")
                ans++;
        }
    }
    dump(ans);
    if(cnt[2]>0){
    if(cnt[0]>0){
        ans+=cnt[2];
    }
    else if(cnt[1]>0){
        ans+=cnt[2];
    }else{
        ans+=cnt[2]-1;
    }
    }
    ans+=min(cnt[0],cnt[1]);
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> s(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
    }
    solve(N, std::move(s));
    return 0;
}


Measured memory_bytes: 768
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		sc.close();

		char[] s = S.toCharArray();

		boolean flg = true;

		for(int i=0;i<S.length()-1;i++) {
			if(s[i]==s[i+1]) {
				flg = false;
			}
		}
		if(flg) {
			System.out.println("Good");
		} else {
			System.out.println("Bad");
		}
	}
}

Measured memory_bytes: 21588
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;

const double pi = 3.1415926535897932384626433832795;
int main(){
    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double r1 = m * 6, r2 = (h * 60 + m) / 2;
    long double cr = cos(abs(r1 - r2) * pi / 180);
    long double res = pow(a * a + b * b - 2 * a * b * cr, 0.5);
    cout << fixed << setprecision(15) << res << endl;
}




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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int n, k;
    cin >> n >> k;

    vector<int> a(n);

    rep(i, n){
        cin >> a[i];
    }

    rep(i, n - k){
        if(a[i] < a[i + k]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		 FastReader s = new FastReader();
		 
		 
		 int n = s.nextInt();
		 int a = s.nextInt();
		 int b = s.nextInt();
		 
		 if(b-a >= n-1)
			 System.out.println("OK");
		 else
		 {
			 if(a%n==0 || ((a/n)+1)*n > a && ((a/n)+1)*n <= b)
				 System.out.println("OK");
			 else System.out.println("NG");
		 }
		 
	}
	
	static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
	}

}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin >> N;
	VVL a(N, VL(N));
	FOR(i, 0, N) {
		FOR(j, 0, N) {
			cin >> a[i][j];
		}
	}

	bool ok = 1;
	VVL use(N, VL(N, 1));
	FOR(k, 0, N) {
		FOR(i, 0, N) {
			FOR(j, 0, N) {
				ok &= (a[i][j] <= a[i][k] + a[k][j]);
				if (i != j && j != k && i != k && (a[i][j] == a[i][k] + a[k][j])) {
					use[i][j] = 0;
				}
			}
		}
	}


	LL ans = 0;
	FOR(i, 0, N) {
		FOR(j, i, N) {
			if (use[i][j])ans += a[i][j];
		}
	}
	cout << (ok ? ans : -1) << endl;

	return 0;
}


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

int P[100005];

class DisjointSet {
    public:
        vector<int> rank, p;
    
    DisjointSet() {}
    DisjointSet(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; i++) makeSet(i);
    }

    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }

    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
        if (rank[x] > rank[y]) {
            p[y] = x;
        } else {
            p[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
    }

    int findSet(int x) {
        if (x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main() {
    int N, M, x, y;
    scanf("%d %d", &N, &M);

    DisjointSet ds = DisjointSet(N+1);

    for (int i = 1; i <= N; i++) scanf("%d", &P[i]);

    for (int i = 1; i <= M; i++) {
        scanf("%d %d", &x, &y);
        ds.unite(x, y);
    }

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (P[i] == i) ans++;
        else if (ds.same(i, P[i])) ans++;
    }
    
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            int a = in.nextInt();
            if (x < a)
                out.println(0);
            else
                out.println(10);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

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

int main() {
    string s1,s2;
    cin >> s1 >> s2;

    int dp[1010][1010];
    rep(i,0,s1.size()+1) dp[i][0] = i;
    rep(j,0,s2.size()+1) dp[0][j] = j;

    rep(i,0,s1.size()) {
        rep(j,0,s2.size()) {
            dp[i+1][j+1] = min( min(dp[i][j+1], dp[i+1][j]) + 1, 
                dp[i][j] + (s1[i]==s2[j] ? 0 : 1));
        }
    }

    cout << dp[s1.size()][s2.size()] << endl;
    return 0;
}

Measured memory_bytes: 5140
n,a,b = map(int,input().split())
ans=0
for i in range(n):
    i+=1
    s=list(str(i))
    s1=''.join(s)
    for j in range(len(s)):
        s[j]=int(s[j])
    if(a <= sum(s) and sum(s) <= b):
        ans+=int(s1)
print(ans)

Measured memory_bytes: 3064
# coding: utf-8

n = int(input().rstrip())

monster_list = list(map(int, input().rstrip().split(" ")))
yusya = list(map(int, input().rstrip().split(" ")))

kill_count = list(range(n))

for i in range(n):
    tmp = min(yusya[i], monster_list[i])
    if yusya[i] > tmp:
        tmp2 = min(yusya[i] - tmp, monster_list[i+1])
        monster_list[i+1] -= tmp2
        tmp += tmp2
    kill_count[i] = tmp

ans = sum(kill_count)
print(ans)


Measured memory_bytes: 18624
#include<bits/stdc++.h>
typedef long long i64;
const int P=998244353,M=1000100;
i64 fac[M+7],fiv[M+7];
i64 pw(i64 a,i64 n){
	i64 v=1;
	for(;n;n>>=1,a=a*a%P)if(n&1)v=v*a%P;
	return v;
}
i64 C(int x,int y){return fac[x+y]*fiv[x]%P*fiv[y]%P;}
int n,m;
int main(){
	for(int i=fac[0]=1;i<=M;++i)fac[i]=i*fac[i-1]%P;
	fiv[M]=pw(fac[M],P-2);
	for(int i=M;i;--i)fiv[i-1]=i*fiv[i]%P;
	scanf("%d%d",&n,&m);
	if(n>m)std::swap(n,m);
	i64 s=0;
	for(int i=1;i<=n;++i)s=(s+C(i,i)*C(n-i,m-i))%P;
	s=(m+s*(P+1)/2%P*pw(C(n,m),P-2))%P;
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1,0); }
	V<V<pin>> qab(2);
  int sz=ab.size();
  qab[0].reserve(sz);
  qab[1].reserve(sz);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2,x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2,(x.second + 1) / 2)); }
	}
  vel c(2);
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
          c[i]^=(qc+1);
		}
	}
	rep(i, 2) {
		if (!c[1 - i]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for(pin &v:ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	long long inf = 2e17;
	int n; scanf("%lld", &n);
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; scanf("%lld", &a); scanf("%lld", &b);
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}


Measured memory_bytes: 11136
import sys
N, M, Q = map(int, input().split())
abcd = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]
ans = 0
done = set()
todo = [(i,) for i in range(1, M + 1)]
while todo:
    A = todo.pop()
    done.add(A)
    if len(A) == N:
        total = 0
        for a, b, c, d in abcd:
            if A[b-1] - A[a-1] == c:
                total += d
        ans = max(ans, total)
        continue
    for i in range(A[-1], M + 1):
        nA = A + (i,)
        if not nA in done:
            todo.append(nA)
print(ans)

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

using namespace std;

int main() {
    long long a, b, k;
    cin >> a >> b >> k;
    if (a <= k) {
        k -= a;
        a = 0;
    } else {
        a -= k;
        k = 0;
    }
    if (k) {
        if (b > k) {
            b -= k;
        } else {
            b = 0;
        }
    }
    cout << a << " " << b << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

int main(){
  int n;
	while(true){
		cin>>n;
		if(!n)break;
		map<int,int> star;
		for(int i=0;i<n;i++){
			int k;
			cin>>k;
			if(star.find(k) == star.end()){
				star[k] = 1;
			}
			else{
				star[k]++;
			}
		}
		map<int,int>::iterator it = star.begin();
		while(it != star.end()){
			if((*it).second*2>n){
				cout<<(*it).first<<endl;
				break;
			}
			it++;
		}
		if(it == star.end())
			cout<<"NO COLOR"<<endl;
	}
  return 0;
}

Measured memory_bytes: 1936
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		char[] c = stdIn.next().toCharArray();
		for(int i = 0; i < c.length; ++i)
		{
			if(c[i] <= 'C')
			{
				c[i] += -3 + 26;
			}
			else
			{
				c[i] -= 3;
			}
			System.out.print(c[i]);
		}
		System.out.println("");
	}
}

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

int main()
{
    int S, h, m, s;
	cin >> S;

	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;

	cout << h << ":" << m << ":" << s << endl;


	return 0;
}

Measured memory_bytes: 1168
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i—)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << “ “ << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << “ \n”[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[200010];
    cin >> N;
	rep(i,0,N) cin >> A[i];
	rep(i,0,N-1){
		if(A[i+1] - A[i] >= 2){
			print(-1);
			return 0;
		}
	}
	if(A[0] != 0){
		print(-1);
		return 0;
	}
	A[N] = -INF;
	ll ans = 0;
	rep(i,0,N){
		if(A[i+1] - A[i] <= 0){
			ans += A[i];
		}
	}
	print(ans);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 1002
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

vector<int> b[11], v[11];
int dp[2000];
int main(){
	int n, k, t1, t2;
	scanf("%d%d", &n, &k);
	rep(i,n){
		scanf("%d%d", &t1, &t2);
		b[t2].pb(t1);
	}
	rrep(i,10){
		sort(b[i].begin(), b[i].end(), greater<int>());
		v[i].pb(0);
	}
	rrep(i,10)rep(j,b[i].size())v[i].pb(v[i][j]+b[i][j]+j*2);
	rrep(i,10){
		t1 = v[i].size();
		drep(j,k){
			for(int h = 0;h < min(j+1, t1);h++){
				dp[j] = max(dp[j], dp[j-h]+v[i][h]);
			}
		}
	}
	printf("%d\n", dp[k]);
	return 0;
}

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

int keta(int a) {
	int ans = 0;
	while (1) {
		ans += a % 10;
		a /= 10;
		if (a == 0) break;
	}
	return ans;
}


int main()
{

	int N;
	cin >> N;
	int A = 0;
	int B = 0;
	cin >> A >> B;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (keta(i) >= A && keta(i) <= B) ans += i;
	}
	cout << ans << endl;
}



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

int main() {
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    V p(a),q(b),r(c);
    rep(i,a)cin>>p[i];
    rep(i,b)cin>>q[i];
    rep(i,c)cin>>r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    priority_queue<ll,V,greater<ll>> X,Y;
    rep(i,x)X.push(p[i]);
    rep(i,y)Y.push(q[i]);
    rep(i,c){
        if(X.top()<Y.top()){
            if(X.top()<r[i]){
                X.pop();
                X.push(r[i]);
            }
        }else{
            if(Y.top()<r[i]){
                Y.pop();
                Y.push(r[i]);
            }
        }
    }
    ll ans=0;
    while(X.size())ans+=X.top(),X.pop();
    while(Y.size())ans+=Y.top(),Y.pop();
    cout<<ans<<endl;
}


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

typedef long long ll;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define dump(x) cerr<<#x<<"="<<x<<endl

typedef pair<int,int> P;

int N;
int ans=0;
int A[212345];
int B[212345];
int A2[212345];
int main(){
    cin>>N;
    string s;
    cin>>s;
    int i=0;
    int ans1=0,ans2=0;

    N=s.size();
    // .....######
    while(s[i]=='.'){
        i++;
    }
    //dump(i);
    for(int j=i;j<N;j++){
        if(s[j]=='#'){
            ans1++;
        }else{
            ans2++;
        }
    }
    ans=min(ans1,ans2);



    //途中まで ... の位置をきめる

    for(i=0;i<N;i++){
        if(s[i]=='.'){
            A[i]=1;
        }else{
            B[i]=1;
        }
    }
    for(i=N-1;i>=0;i--){
        if(s[i]=='.'){
            A2[i]=1;
        }
    }
    for(i=1;i<N;i++){
        A[i]+=A[i-1];
        B[i]+=B[i-1];
    }
    for(i=N-2;i>=0;i--){
        A2[i]+=A2[i+1];
    }
    
    i=0;ans1=0;ans2=0;
    for(i=0;i<N;i++){
        ans1=0;

        ans1+=B[i];
        ans1+=(A2[i]-1);
        dump(ans1);
        ans=min(ans,ans1);
    }

    // #########
    i=0;ans1=0;ans2=0;
    for(i=0;i<N;i++){
        if(s[i]=='.')ans1++;
    }
    ans=min(ans,ans1);

    // .........
    i=0;ans1=0;ans2=0;
    for(i=0;i<N;i++){
        if(s[i]=='#')ans1++;
    }
    ans=min(ans,ans1);



    cout<<ans<<endl;

}

Measured memory_bytes: 2948
import sys
import heapq
sys.setrecursionlimit(2*10**5)
N=int(input())
a=[-1]+[int(input())-1 for i in range(1,N)]
G=[[] for i in range(N)]
for i in range(1,N):
    G[a[i]].append(i)
def dp(i):
    if len(G[i])==0:
        return 0
    q=[]
    for j in G[i]:
        heapq.heappush(q,-dp(j))
    k=1
    res=0
    while(q):
        x=-heapq.heappop(q)
        res=max(res,x+k)
        k+=1
    return res
print(dp(0))

Measured memory_bytes: 116664
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e9;
const long long MOD = 1e9+7;
signed main(){
    int k; cin >> k;
    string s; cin >> s;
    if(s.size()>k) {rep(i,k) cout<<s[i]; cout<<"..."<<endl;}
    else rep(i,s.size()) cout<<s[i];
}

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

int main(){
	int n, m, l;
	long long A[100][100];
	long long B[100][100];
	long long C[100][100] = {0};
	
	cin >> n >> m >> l;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < l; j++){
			cin >> B[i][j];
		}
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			for(int k = 0; k < m; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			cout << C[i][j];
			if(j != l-1) cout << ' ';
		}
		cout << endl;
	}
	
	return 0;
}

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

int main() {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n), y(m);
  for (int i=0; i<n; i++){
    cin >> x[i];
  }
  sort(x.begin(), x.end());
  reverse(x.begin(), x.end());
  int xmax = x[0];
  
  for (int i=0; i<m; i++){
    cin >> y[i];
  }
  sort(y.begin(), y.end());
  int ymin = y[0];
  
  if (xmax < ymin && X < xmax && ymin < Y){
    cout << "No War" << endl;
  }
  else cout << "War" << endl;
  
  return 0;
}

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

int main() {
  int S, W;
  cin >> S >> W;
  if(W >= S) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}  

Measured memory_bytes: 3624
def actual(n, X, U):
    # 変換: 1[BTC] == 380000.0[円]
    amount_yen = 0

    for x, u in zip(X, U):
        if u == 'JPY':
            amount_yen += x
        if u == 'BTC':
            amount_yen += x * 380000.0

    return amount_yen

n = int(input())
X = []
U = []

for _ in range(n):
  x, u = input().split()
  X.append(float(x))
  U.append(u)
  
print(actual(n, X, U))  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long int
#define F(i,n) for(long long int i=0;i<n;i++)
#define REF(i,a,b) for(int i=a;i<=b;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ln "\n"
#define milli 1000000
#define M 1000000007
#define fastio ios::sync_with_stdio(0);cin.tie(0);

const ll N=1e7+1;
int p[N];

bool prime(ll n)
{
    if(n<2)return false;
    for(ll x=2;x*x<=n;x++)
    {
        if(n%x==0)
            return false;
    }
    return true;
}

ll largestDigit(ll n)
{
    ll largest=0;
    while(n)
    {
        ll r=n%10;
        largest=max(r,largest);
        n=n/10;
    }
    return largest;
}

ll smallestDigit(ll n)
{
    ll smallest=10;
    while(n)
    {
        ll r=n%10;
        smallest=min(r,smallest);
        n=n/10;
    }
    return smallest;
}

int numOfFactors(ll n)
{
    int ans=1;
    while(n > 1){
            int prime = p[n],cnt = 1;
            while(n % prime == 0)cnt++, n/=prime;
            ans*=cnt;
        }
    return ans;
}




int main()
{
   for(int i=2;i<N;i++)
    {
        if(p[i])
            continue;
        for(int j=i;j<N;j+=i)
            p[j]=i;
    }
    fast;
    fastio;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll arr[4];
    arr[0]=a*c;
    arr[1]=a*d;
    arr[2]=b*c;
    arr[3]=b*d;
    cout<<*max_element(arr,arr+4)<<ln;
    return 0;
}


Measured memory_bytes: 42632
(defun f (k)
  (+ (loop :for a :from 4 :downto 1 :sum(mod (floor k (expt 10 a)) 10)) (mod k 10)))
(let ((n (read))
      (a (read))
      (b (read)))
  (princ (reduce #'+ (remove-if-not (lambda (q) (<= a (f q) b)) (loop :for x :from 1 :upto n :collect x)))))

Measured memory_bytes: 26468
N = gets.chomp.to_i
points_hash  = {}
N.times do |i|
    point = gets.chomp.split(' ')
    if points_hash[point[0]] == nil
        points_hash[point[0]] = Hash[point[1].to_i, i]
    else
        points_hash[point[0]][point[1].to_i] = i
    end
end
sities = points_hash.keys.sort
sities.each do |sity|
    points_hash[sity].keys.sort.reverse.each do |point|
        p points_hash[sity][point]+1
    end
end


Measured memory_bytes: 1788
s = input()
t = s.replace('x', '')

if t != t[::-1] :
    print(-1)
    
else :
    sp = []
    cnt = 0
    for i in s :
        if i != 'x' :
            sp.append(cnt)
            cnt = 0
        else :
            cnt += 1
    
    sp.append(cnt)
    
    ret = 0
    n = len(sp)
    for i in range(n // 2) :
        ret += abs(sp[i] - sp[n-1-i])
        
    print(ret)

Measured memory_bytes: 45808
import java.math.*

fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    
    var t = 0
    var x = 0
    var y = 0
    
    for (i in 1..n) {
        val (ti, xi, yi) = readInputLine().split(" ").map { it.toInt() }
        
        val distance = Math.abs(xi - x) + Math.abs(yi - y)

        if (ti - t < distance) {
            println("No")
            return
        }
        
        if ((ti - t - distance) % 2 != 0) {
            println("No")
            return
        }
        
        t = ti
        x = xi
        y = yi
    }
    
    println("Yes")
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 51564
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,k;
vi a;

bool f(int x){
	ll t=0;
	for(int i=0;i<n;i++) t+=(a[i]-1)/x;
	return t<=k;
}

int main(){
	cin>>n>>k;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	int l=0,r=inf;
	while(r-l>1){
		int m=(l+r)/2;
		if(f(m)) r=m;
		else l=m;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define N 50
ull v[N+1];
map<ull, int> occ;
ull C[N+1][N+1];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(int n = 0; n <= N; n++) {
        for(int k = 0; k <= n; k++) {
            C[n][k] = n == k ? 1 : C[n-1][k-1] + C[n-1][k];
        }
    }
    int n, a, b;
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
        occ[v[i]]++;
    }
    sort(v, v + n);
    reverse(v, v + n);
    long double max_mean = 0;
    for(int k = a; k <= b; k++) {
        ull s = 0;
        for(int i = 0; i < k; i++) {
            s += v[i];
        }
        max_mean = max(max_mean, (long double) s / k);
    }
    cout << fixed << setprecision(6) << max_mean << endl;
    ull count = 0;
    for(int k = a; k <= b; k++) {
        ull s = 0;
        for(int i = 0; i < k; i++) {
            s += v[i];
        }
        if((long double) s / k == max_mean) {
            int choose = 0;
            for(int i = 0; i < k; i++) {
                choose += v[i] == v[k - 1];
            }
            count += C[occ[v[k - 1]]][choose];
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> H >> W >> K;
    vector<vector<char>> a(H, vector<char>(W));
    int hoge = 0;
    REP(h, H)
    REP(w, W) {
        cin >> a[h][w];
    }
    REP(hb, (1 << H))
    REP(wb, (1 << W)) {
        int cnt = 0;
        REP(h, H)
        REP(w, W) {
            if (((hb >> h) & 1) && ((wb >> w) & 1) && a[h][w] == '#') {
                cnt++;
            }
        }
        if (cnt == K)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
s = input()
n = len(s)
if n%2 == 0:
    im1 = '01'*(n//2)
    im2 = '10'*(n//2)
else:
    im1 = '01'*(n//2) + '0'
    im2 = '10'*(n//2) + '1'
cnt1 = 0
cnt2 = 0
for i in range(n):
    if s[i] != im1[i]:
        cnt1 += 1
    if s[i] != im2[i]:
        cnt2 += 1
print(min(cnt1,cnt2))

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1){
    c-=b;
    if(c<1){
      cout<<"Yes"<<endl;
      break;
    }else{
      a-=d;
      if(a<1){
        cout<<"No"<<endl;
        break;
      }
    }
  }
}

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


bool checkHarshad(long long int n)
{

   long long int sum = 0;
    for (long long int temp = n; temp > 0; temp /= 10)
        sum += temp % 10;


    return (n % sum == 0);
}


int main()
{
    long long int n;
    cin>>n;
    checkHarshad(n) ? cout << "Yes\n" : cout << "No\n";


    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int maxn = 1e5 + 7;
const int inf = 2e9 + 7;
const ll infl = 1e18 + 7;
const long double eps = 1e-9;
const ll mod = 1e9 + 7;

vector<int> g[maxn];

ll dp[maxn][2];
bool used[maxn];

void dfs(int v, int p) {
	used[v] = true;
	int go = 0;
	for (int to : g[v]) {
		if (p != to) {
			go++;
			dfs(to, v);
		}
	}
	dp[v][0] = dp[v][1] = 1;
	for (int to : g[v]) {
		if (p != to) {
			dp[v][0] = (dp[v][0] * ((dp[to][0] + dp[to][1]) % mod)) % mod;
			dp[v][1] = (dp[v][1] * dp[to][0]) % mod;
		}
	}
}

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // _DEBUG

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	ll ans = 1;
	for (int i = 1; i <= n; i++) {
		if (!used[i]) {
			dfs(i, -1);
			ans = (ans * ((dp[i][0] + dp[i][1]) % mod)) % mod;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 14336