akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, t;
    cin >> n >> t;
    double ans = 0;
    for (int i = 0; i < n; ++i) {
        int x, h;
        scanf("%d %d", &x, &h);
        ans = max(ans, (double)t*h/x);
    }
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 3216
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int a[] = new int[m + 2];
        for (int i = 1; i <= m; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        a[0] = -1;
        a[m + 1] = n + 1;
        List<Integer> b = new ArrayList<>();
        for (int i = 1; i <= m + 1; i++) {
            if (a[i] - a[i - 1] == 1) {
                System.out.println(0);
                return;
            }
            b.add(a[i] - a[i - 1] - 1);
        }
        if (m == 0) {
            b.set(0, n + 1);
        }
        long memo[] = new long[n + 2];
        memo[1] = 1;
        memo[2] = 1;
        for (int i = 3; i <= n + 1; i++) {
            memo[i] = memo[i - 1] + memo[i - 2];
            memo[i] %= 1_000_000_007;
        }
        long ans = 1;
        for (int i = 0; i < b.size(); i++) {
            ans *= memo[b.get(i)];
            ans %= 1_000_000_007;
        }
        System.out.print(ans);
    }
}

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

#define ll long long
ll n;
string s;
int main()
{
    scanf("%lld",&n);
    cin >> s;
    if(n%2)
        printf("No");
    else
    {
        for(int i = 0; i < n/2; i++)
        {
            if(s[i] != s[(n/2)+i])
            {
                printf("No");
                return 0;
            }
        }
        printf("Yes");
    }
    return 0;
}


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

const int MAX_N = 3005;
int N;
ll a[MAX_N];
ll dp[MAX_N][MAX_N];

ll go(int le, int ri)
{
	if(le > ri) return 0;
	if(le == ri) return a[le];
	ll& res = dp[le][ri];
	if(res != -1) return res;
	res = max(a[le]+min(go(le+2,ri),go(le+1,ri-1)),
			  a[ri]+min(go(le+1,ri-1),go(le,ri-2)));
	return res;
}

void solve()
{
	memset(dp, -1, sizeof(dp));
	ll ans = go(0, N-1);
	cout << 2*ans-accumulate(a,a+N,0LL) << '\n';
}

int main()
{
	cin >> N;
	for(int i=0;i<N;++i) cin >> a[i];
	solve();
	return 0;
}

Measured memory_bytes: 70912
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
int main(void) {
	int n, m, x, y;
	scanf("%d %d", &n, &m);
	scanf("%d %d", &x, &y);
	printf("%d\n", (n-x)*(m-y));


	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

const int maxn=1e5+5;
vector<int> G[maxn],order;
int n,a,b,known[maxn],val[maxn],l[maxn],r[maxn],k,used[maxn],known_parity[maxn][2],shit,par[maxn],ans[maxn];

void dfs(int v)
{
	used[v]=1;
	l[v]=-1e9;
	r[v]=1e9;
	for (int i=0;i<G[v].size();i++)
	{
		int to=G[v][i];
		if(used[to]) continue;
		dfs(to);
		par[to] = v;
		if(known_parity[to][0]) known_parity[v][1]=1;
		if(known_parity[to][1]) known_parity[v][0]=1;
		l[v]=max(l[v],l[to]-1);
		r[v]=min(r[v],r[to]+1);
	}
	if(known[v]==1)
	{
		l[v]=max(l[v],val[v]);
		r[v]=min(r[v],val[v]);
		known_parity[v][val[v]%2]=1;
	}
	if(known_parity[v][0] == 1 && known_parity[v][1] == 1) shit=1;
	if(l[v] > r[v]) shit = 1;
	order.pb(v);
}

int solve_val(int v,int par)
{
	if(par == 0) return l[v];
	l[v] = max(l[v],ans[par] - 1);
	r[v] = max(r[v],ans[par] + 1);
	while(l[v] % 2 == ans[par] % 2) ++l[v];
	return l[v];
}

int main(int argc, char const *argv[])
{
	cin>>n;
	for (int i=1;i<=n-1;i++)
	{
		cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	cin>>k;
	for(int i = 1;i <= k; ++i)
	{
		cin>>a>>b;
		known[a] = 1;
		val[a] = b;
	}
	dfs(1);
	if(shit)
	{
		cout<<"No\n";
		return 0;
	}
	reverse(order.begin(),order.end());
	printf("Yes\n");
	for(int i = 0;i < order.size(); ++i)
	{
		int v = order[i];
		ans[v] = solve_val(v,par[v]);
	}
	for (int i=1;i<=n;i++)
	{
		cout<<ans[i];
		if (i!=n) cout<<endl;
	}
	return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,f[ohara],fr[ohara];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

ll mod_pow(ll xx,ll nn,ll mod){
  ll ret=1;
  while(nn>0){
    if(nn&1)ret=ret*xx%mod;
    xx=xx*xx%mod;
    nn>>=1;
  }
  return ret;
}

ll ncr(ll nn,ll r){
  if(nn<r)return 0;
  return f[nn]*fr[r]%MOD*fr[nn-r]%MOD;
}

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

      
     f[0]=1;
     rrep(i,1,2*100000+2){
       f[i]=f[i-1]*i%MOD;
     }
     fr[2*100000+1]=mod_pow(f[2*100000+1],MOD-2,MOD);
     rrrep(i,2*100000,0){
       fr[i]=fr[i+1]*(i+1)%MOD;
     }

     cin>>h>>w>>a>>b;
     rrep(j,b,w){
       ans+=ncr(h-a-1+j,h-a-1)*ncr(a-1+w-j-1,a-1);
       ans%=MOD;
     }
     Cout(ans);

     

       
return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
int main() {
        int N, M;
        cin >> N >> M;
        vector<pair<int, int> > r(M);
        for(auto &x: r) {
                cin >> x.second >> x.first;
        }

        sort(r.begin(),r.end());

        int pos = 0, num = 0;

        for(auto x: r) {
//              cout << x.first << " " << x.second << " " << pos << endl;
                if(pos < x.second) {
                        pos = x.first - 1;
                        num++;
                }
        }

        cout << num << endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>
#include<iomanip>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  double a, b, h, m; cin >> a >> b >> h >> m;
  double pi = 3.141592653589793;
  double x = a*cos(h/6.0*pi + m/30.0/12.0*pi) - b*cos(m/30.0*pi);
  double y = a*sin(h/6.0*pi + m/30.0/12.0*pi) - b*sin(m/30.0*pi);
  double x2 = x * x;
  double y2 = y * y;
  cout << fixed << setprecision(16) << sqrt(x2+y2) << endl;
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 4044
# 2019/09/22

n,m=map(int,input().split())
s=[]
for i in range(m):
    _,*ss=map(lambda x:int(x)-1,input().split())
    
    s.append(ss)
p=list(map(int,input().split()))

res=0
for i in range(2**n):
    flag=True
    for j in range(m):
        cnt=0
        for e in s[j]:
            if i>>e&1:
                cnt+=1

        if cnt%2!=p[j]:
            flag=False
            break
    if flag:res+=1
print(res)

Measured memory_bytes: 3064
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map (fun x -> int x)


let x, t = readIntArray() |> fun x -> (x.[0], x.[1])

max 0 (x - t)
|> printfn "%d"

Measured memory_bytes: 13916
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
typedef long long ll;
using namespace std;

//main
int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  rep(i,N) cin >> V[i];
  rep(i,N) cin >> C[i];
  vector<int> G;
  G.push_back(0);
  rep(i,N) if(V[i]-C[i]>0) G.push_back(V[i]-C[i]);
  cout << accumulate(ALL(G),0) << endl;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

#ユークリッド互除法
def gcd(x,y):
    a = max(x,y)
    b = min(x,y)
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b

L = [A[0]]
R = [A[N-1]]*N
for i in range(N-1):
    L.append(gcd(L[i], A[i+1]))
    R[N-i-2]=gcd(R[N-i-1],A[N-i-2])
can = []
for i in range(N):
    if i == 0:
        can.append(R[1])
    elif i == N-1:
        can.append(L[N-2])
    else:
        can.append(gcd(L[i-1], R[i+1]))

print(max(can))

Measured memory_bytes: 14428
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    for(int i=0; i<N-1; i++) cin >> C[i];

    int ans = 0;
    for(int i=0; i<N; i++)
        ans += B[A[i]-1];

    for(int i=0; i<N-1; i++)
        if(A[i+1] == A[i]+1)
            ans += C[A[i]-1];
    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

ll gcd( ll m, ll n )
{
	if (n == 0) return m;
	else return gcd(n, m%n);
}//gc

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

    ll N, X;
    cin>>N>>X;
    cout<<3*(N - gcd(N, X))<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#include<string>
#define rep(i, n) for(int i=0;i< (int)(n);i++)
using namespace std;

int main(){
  int n, max;
  string input;
  map<string, int> mp;

  max = 0;
  cin >> n;
  rep(i, n){
    cin >> input;
    mp[input]++;
    if(mp[input] > max){
      max = mp[input];
    }
  }

  for(pair<string, int> p : mp){
    if(p.second == max) cout << p.first << endl;
  }
  return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair <int, int>;

#define rep(i, n)     for (int i = 0; i < (int) (n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp)   for (auto &i : mp)

const int INF = 1001001001;

int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  vector <int> a(n);
  vector <int> b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  ll t = 0;
  rep(i, m) t += b[i];
  int j   = m;
  int ans = 0;
  rep(i, n + 1) {
    while (j > 0 && t > k) {
      --j;
      t -= b[j];
    }
    if (t > k) { break; }
    ans = max(ans, i + j);
    if (i == n) { break; }
    t += a[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4828
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007

#define SZ 10005
using namespace std;


int main()
{
    int n;
    cin>>n;
    if(n>=1000) cout<<"ABD";
    else cout<<"ABC";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x[6];
	int ans;
	for(int i=1;i<=5;i++)
	{
		cin>>x[i];
		if(x[i]==0)ans=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

#define N 100000
typedef struct{
char name[10];
int time;
}process;

int isempty(void);
int isfull(void);
void enqueue(process);
process dequeue(void);


int head = 0, tail = 0,q;
process p[N];


int main(){
process x;
int i,n,t = 0;

scanf("%d%d",&n,&q);
for(i = 0; i < n; i++){
scanf("%s%d",x.name,&x.time);
enqueue(x);
}

while(head != tail){
if(p[head].time > q) {
p[head].time = p[head].time-q;
t += q;
enqueue(dequeue());
}

 else if(p[head].time <= q) {
t += p[head].time;
printf("%s %d\n",p[head].name,t);
dequeue();
}
}
return 0;
}


int isempty(){
return head == tail;
}

int isfull(){
return head == (tail + 1)%N;
}

void enqueue(process x){

p[tail] = x;
if(tail + 1 == N-1) tail = 0;
 else tail++;
}

process dequeue(){
process x;


x = p[head];
if(head + 1 == N-1) head = 0;
 else head++;
return x;
}

Measured memory_bytes: 2160
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

const ll MODULO = 998244353L;
ll mod_minus(ll x, ll modval) {
    if (x >= 0) {
        return x % modval;
    } else {
        ll mm = ((-x) % modval);
        if (mm == 0) {
            return 0;
        } else {
            return modval - mm;
        }
    }
}
ll mod(ll x) {
    return mod_minus(x, MODULO);
}

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> dp(200003, 0);
    vector<ll> left(K);
    vector<ll> right(K);
    vector<ll> exist(200003, 0);
    for (ll i = 0; i < K; i++) {
        cin >> left[i] >> right[i];
        for (ll j = left[i]; j <= right[i]; j++) {
            exist[j] = 1;
        }
    }

    for (ll i = 2; i <= N; i++) {
        dp[i] = dp[i - 1] - exist[i - 2] + exist[i - 1];
        for (ll j = 0; j < K; j++) {
            ll l = left[j];
            ll r = right[j];
            if (i - r - 1 >= 1) {
                dp[i] = mod(dp[i] - dp[i - r - 1]);
            }
            if (i - l >= 1) {
                dp[i] = mod(dp[i] + dp[i - l]);
            }
        }
    }
    print(dp[N]);
}


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

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

    vector<bool> existList(1000000000, false);
    bool isDistinct = true;

    for (int i = 0; i < n; ++i)
    {
        int input;
        cin >> input;

        if (existList.at(input))
        {
            isDistinct = false;
            cout << "NO" << endl;
            break;
        }
        else
        {
            existList.at(input) = true;
        }
    }

    if (isDistinct)
    {
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 122368
#include <iostream>

using namespace std;

int main() {
  int n = 0, m = 0, k = 0;
  cin >> n >> m >> k;
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=m; j++) {
      int black = i * (m-j) + j * (n-i);
      if (black == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main(){
	string lefth("qwertasdfgzxcvb");
	string righth("yuiophjklnm");
	bool flag = false; /* ?????????????????? */
	int ans;
	string str;
	while(cin >> str, str != "#"){
		ans = 0;
		int len = str.size();
		if(lefth.find(str[0]) != -1){
			flag = true;
		}
		if(righth.find(str[0]) != -1){
			flag = false;
		}
		for(int i = 1; i < len; ++i){
			if(!flag){
				if(lefth.find(str[i]) != -1){
					flag = true;
					++ans;
				}
			}else{
				if(righth.find(str[i]) != -1){
					flag = false;
					++ans;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3144
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a, b;
    cin >> x >> a >> b;
    if(b - a <= 0){
        cout << "delicious" << "\n";
    }else if(b - a <= x){
        cout << "safe" << "\n";
    }else{
        cout << "dangerous" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 33003;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main(){
int n,k;
cin>>n>>k;
int arr[n];
rep(i,0,n)
cin>>arr[i];
int ans=0;
int x=0;
rep(i,0,n)
{
	
	x+=arr[i];
	if(x<=k)
	ans++;
}

cout<<ans+1;
}

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

int comp(const void *p1,const void *p2);
int smaller_max_bsearch(int array[],int n,int key);

int main(void){
  int point[1001];
  int *array;
  int n,m,i,j,k,max=0;

  while(scanf("%d%d",&n,&m) && n && m){
    for(i=1;i<=n;i++) scanf("%d",&point[i]);
    point[0]=max=0;
    
    array=(int *)calloc((n+1)*(n+1),sizeof(int));
    for(i=0;i<=n;i++){
      for(j=i;j<=n;j++){
	array[i*(n+1)+j]=array[j*(n+1)+i]=point[i]+point[j];
      }
    }
    qsort(array,(n+1)*(n+1),sizeof(int),comp);
    
    for(i=0;i<(n+1)*(n+1);i++){
      if(array[i]>m) break;
      k=array[i]+smaller_max_bsearch(array,(n+1)*(n+1),m-array[i]);
      if(k>max) max=k;
    }
    printf("%d\n",max);
    free(array);
  }
  return 0;
}

int comp(const void *p1,const void *p2){
  int n1,n2;
  n1=*(const int *)p1;
  n2=*(const int *)p2;
  return n1-n2;
}

int smaller_max_bsearch(int array[],int n,int key){
  int h;
  if(n==1) return (array[0]<key)?array[0]:0;
  if(n==2){
    if(array[1]<=key) return array[1];
    else if(array[0]<=key) return array[0];
    else return 0;
  }

  h=n/2;

  if(array[h]==key) return array[h];
  else if(array[h]<key) return smaller_max_bsearch(array+h+1,n-h-1,key);
  else if(array[h-1]<key) return array[h-1];
  else return smaller_max_bsearch(array,h-1,key);
}

Measured memory_bytes: 8560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define vs vector<string>

int main() {
    ll N; cin >> N;
    string S; cin >> S;

    ll count = 0;
    rep(i,N){
        if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C'){
            count ++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3600
fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val map = mutableMapOf<Int,Int>()
    for(i in 1..n){
        val line = readLine()!!.split(" ").map{it.toInt()}
        val a = line[0]
        val b = line[1]
        if(map.contains(b)){
            val x = a + map.get(b)!!
            map.put(b,x)
        }else{
            map.put(b,a)
        }
    }
    var sum = 0
    for(i in map.keys.sorted()){
        if(map.contains(i)){
            sum+=map.get(i)!!
            if(sum>i){
                println("No")
                return
            }
        }
    }
    println("Yes")
}

Measured memory_bytes: 94244
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int R;
	cin >> R;
	if (R < 1200) cout << "ABC" << endl;
	else if(R < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}




Measured memory_bytes: 504
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N, M =  map(int, sys.stdin.readline().split())

print(((N - M) * 100 + 1900 * M) * (2 ** M))

Measured memory_bytes: 64364
from collections import deque

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def bfs(w, h, m):
    cost = [[-1 for _ in range(w + (w - 1))] for _ in range(h + (h - 1))]
    # print(cost)
    que = deque()
    que.append([0, 0])
    cost[0][0] = 2
    while not len(que) == 0:
        p = que.popleft()
        # print((w+(w-2)), (h+(h-2)))
        if p[0] == 2 * h - 2 and p[1] == 2 * w - 2:
            return cost[p[0]][p[1]] // 2
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            # print(nx, ny, 2 * h - 1, 2 * w - 1)
            if nx < 0 or ny < 0 or nx >= 2 * h - 1 or ny >= 2 * w - 1:
                # print(cost[nx][ny])
                continue
            if m[nx][ny] == -1:
                continue
            if not cost[nx][ny] == -1:
                continue
            # print(p[0], p[1], cost)
            cost[nx][ny] = cost[p[0]][p[1]] + 1
            # print(cost[nx][ny], len(que))
            que.append([nx, ny])
        # print(*cost, sep="\n")
        # print("---------------------")
    return 0


if __name__ == "__main__":
    while True:
        W, H = map(int, input().split())
        if W == 0 and H == 0:
            break
        meizu = [[0 for _ in range(W + (W - 1))] for _ in range(H + (H - 1))]
        for i in range(2 * H - 1):
            kabe = list(map(int, input().split()))
            tmp = 0
            if i % 2 == 0:
                for j in range(len(meizu[i])):
                    if j % 2 == 1:
                        if kabe[tmp] == 1:
                            meizu[i][j] = -1
                        tmp += 1
            else:
                for j in range(len(meizu[i])):
                    if j % 2 == 0:
                        if kabe[tmp] == 1:
                            meizu[i][j] = -1
                        tmp += 1
        for i in range(len(meizu)):
            for j in range(len(meizu[i])):
                if i % 2 == 1 and j % 2 == 1:
                    meizu[i][j] = -1
        # print(meizu)
        print(bfs(W, H, meizu))


Measured memory_bytes: 6140
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++) {
			b[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++) {
			c[i] = sc.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(c);
		long ans = 0;
		for(int i = 0 ; i < n ; i++) {
			ans += binary_search(a, b[i]) * (n - binary_search(c, b[i] + 1));
		}
		System.out.println(ans);
	}

	// l, r: 端点を含まないので、探索範囲はl+1~r-1
	// イメージは探索範囲外を指で押さえていって、最終的に右指で押さえているインデックスを返す感じ
	public static long binary_search(int[] array, int target) {
		int l = -1;
		int r = n;
		while(r - l > 1) {
			int mid = (r + l) / 2;
			if(array[mid] < target) {
				l = mid;
			} else {
				r = mid;
			}
		}
		return r;
	}

}


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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 2e18;
const int MOD = 1e9 + 7;
const int MAXN = 3e5 + 5;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	ll ans = 0, tot = 100, x;
	cin >> x;
	while(tot < x) {
		ll t = tot * 0.01;
		tot += t;
		ans++;
	}
	cout << ans;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
map<ll, int> enumpr(ll n) {
	map<ll, int> V;
	for (ll i = 2; i * i <= n; i++) while (n % i == 0) V[i]++, n /= i;
	if (n > 1) V[n]++;
	return V;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














ll N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	auto ep = enumpr(N);

	int ans = 0;
	fore(p, ep) {
		int cnt = p.second;
		rep(i, 1, 1010) {
			if (i <= cnt) {
				ans++;
				cnt -= i;
			}
			else break;
		}
	}
	cout << ans << endl;
}







Measured memory_bytes: 3612
#include<iostream>
#include<string>

using namespace std;

int main(){
  string o, e;
  cin >> o >> e;
  for(int i=0;i<e.length();i++){
    cout << o[i];
    cout << e[i];
  }
  if(o.length()>e.length()){
    cout << o[o.length()-1];
  }
  cout << endl;
}

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

class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //コンソールから入れる際に高速に入れる方法

        String strArr = br.readLine();
        int a = Integer.parseInt(strArr);
        if (a % 2 == 1) {
        	int x = (a/2) + 1;
            System.out.println(x);
        } else {
        	System.out.println(a/2);
        }

    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int main(void) {
	int t,n,s,f,sum,i;
	while (scanf("%d", &t) , t != 0){
		sum = 0;
		scanf ("%d", &n);
		for(i = 1; i <= n; i++){
			scanf("%d%d",&s ,&f);
			sum = sum + f - s;
		}
		if (sum >= t){
			printf("OK\n");
		}
		else{
			printf("%d\n",t - sum);
		}
	}
	return 0;
}
//aoj 0238

Measured memory_bytes: 612
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    return arr

a, b = na()
c = gcd(a, b)
print(len(factorization(c))+1)

Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

#define llong long long

using namespace std;
const int IINF = 2147483647;
const llong LLINF = 9223372036854775807;

vector<bool> SOE(int n) {
  vector<bool> isp(n + 1, true);
  int mp = 1;
  while (mp * mp <= n) {
    for (int i = mp + 1; i <= n + 1; i++) {
      if (i == n + 1) mp = n;  //次の素数がない場合
      if (isp[i]) {
        mp = i;
        break;
      }
    }
    for (int i = mp * 2; i <= n; i += mp) {
      isp[i] = false;
    }
  }
  isp[0]=isp[1]=false;
  return isp;
}

int main(){
  vector<bool>p=SOE(200000);
  vector<int>rp(150000, 0);
  for(int i=3; i<150000; i++){
    if(p[i] && p[(i+1)/2])rp[i]=rp[i-1]+1;
    else rp[i]=rp[i-1];
  }
  int q;
  cin >> q;
  for(int i=0; i<q; i++){
    int l, r;
    cin >> l >> r;
    cout << rp[r]-rp[l-1] << endl;
  }
  return 0;
}

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

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 

vector<vector<int>> v;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    v.assign(n,vector<int>());
    rep(i,n) {
        rep(j,26) {
            v[i].push_back(0);
        }
    }
    string s1,s2,s3;
    cin >> s1;
    cin >> s2;
    cin >> s3;
    rep(i,n) {
        v[i][s1[i]-97]++;
        v[i][s2[i]-97]++;
        v[i][s3[i]-97]++;
    }
    int ch=0;
    rep(i,n) {
        int mx=0;
        rep(j,26) {
            if (v[i][j] > mx) mx = v[i][j];
        }
        if (mx == 2) ch++;
        else if (mx==1) ch+=2;
    }
    cout << ch << '\n';
    return 0;

    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>loe,ano,ple;
set<ll>s;
ll d,n=1,o,ans;
ll iabs(ll x)
{
	return x<0?-x:x;
}
ll dfs(ll use,ll rest)
{
	ll k=ple[(rest%10+10)%10];
	if(use<=0)
	{
		if(rest)
			return 0;
		else
			return 1+(o&1)*9;
	}
	if(abs(rest)/abs(use)>9)
		return 0; 
	if(k)
		return ano[k]*dfs(use/100,(rest-k*use)/10)+ano[k-10]*dfs(use/100,(rest+(10-k)*use)/10);
	else
		return ano[0]*dfs(use/100,rest/10);
}
ll logi(ll use,ll rest)
{
	ll k=ple[(rest%10+10)%10];
	if(use<=0)
	{
		if(rest)
			return 0;
		else
			return 1+(o&1)*9;
	}
	if(abs(rest)/abs(use)>9)
		return 0; 
	if(k)
		return loe[k]*dfs(use/100,(rest-k*use)/10)+loe[k-10]*dfs(use/100,(rest+(10-k)*use)/10);
	else
		return loe[0]*dfs(use/100,rest/10);
}
int main(void)
{
	//freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);
	ll t;
	//scanf("%lld",&t);
	t=1;
	for(ll i=-8; i<9; i++)
		loe[i]=9-iabs(i);
	for(ll i=-9; i<10; i++)
		ano[i]=10-iabs(i);
	for(ll i=0; i<10; i++)
		ple[i*9%10]=i;
	while(t--)
	{
		o=0;
		ans=0;
		n=1;
		scanf("%lld",&d);
		for(ll i=1; i<=18; i++)
		{
			o++;
			ans+=logi(n-1,d);
			n*=10;
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;

struct Restaurant
{
  uint64_t id, point;
  Restaurant(uint64_t id, uint64_t point) : id(id), point(point) {}
  bool operator>(const Restaurant &rhs) const { return point > rhs.point; }
};

int main()
{
  uint64_t N;
  cin >> N;
  
  map<string, set<Restaurant, greater<Restaurant>>> m;
  for (uint64_t n = 0; n < N; ++n) {
    string S;
    uint64_t P;
    cin >> S >> P;
    
    if (m.find(S) == m.end()) {
      m.emplace(S, set<Restaurant, greater<Restaurant>>());
    }
    
    m[S].emplace(n + 1, P);
  }
  
  for (const pair<string, set<Restaurant, greater<Restaurant>>> &p : m) {
    for (const Restaurant &r : p.second) {
      cout << r.id << endl;
    }
  }
  
  return 0;
}

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

struct SegTree{
    int n; vector<ll> dat;
    ll mod;
    //初期化
    SegTree(int _n, ll _mod){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,0);

        mod = _mod;
    }
    //k番目(0-indexed)の値をaに変更
    void update(int k, ll a){
        k+=n-1;
        dat[k]=a;
        //更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=(dat[2*k+1]+dat[2*k+2])%mod;
        }
    }
    //内部的に投げられるクエリ
    ll _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return 0;

        if(a<=l && r<=b) return dat[k];

        ll vl=_query(a,b,2*k+1,l,(l+r)/2);
        ll vr=_query(a,b,2*k+2,(l+r)/2,r);
        return (vl+vr)%mod;
    }
    //[a,b)
    ll query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

using P = pair<string, int>;

int main(){
    int a,b,p;
    while(cin >>a >>b >>p,a){
        int n = b-a+1;
        SegTree st(n+1,p);

        vector<P> v;
        for(int i=1; i<=b-a+1; ++i){
            int val = a+i-1;
            v.pb({to_string(val), i});
        }
        sort(all(v));

        st.update(0,1);
        rep(i,v.size()){
            int idx = v[i].se;
            st.update(idx, st.query(0,idx));
        }

        cout << st.query(1,n+1) << endl;
    }
    return 0;
}



Measured memory_bytes: 11440
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a < c){
        if(b <= c){
            cout << 0 << endl;
        }else if(c < b){
            if(b <= d){
                cout << b-c << endl;
            }else{
                cout << d-c << endl;
            }
        }
    }else{
        if(d < a){
            cout << 0 << endl;
        }else if(d < b){
            cout << d-a << endl;
        }else{
            cout << b-a << endl;
        }
    }
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; ll K; cin >> N >> K;
    vector<ll> A(N),B(N);
    for (int i=0;i<N;++i) cin >> A[i] >> B[i];
    ll ans=0;
    for (int i=0;i<N;++i) if ((A[i]|K)==K) ans+=B[i];
    for (int i=0;i<30;++i) if (K&1<<i){
        ll k=(K^(1<<i))|((1<<i)-1),cnt=0;
        for (int j=0;j<N;++j) if ((A[j]|k)==k) cnt+=B[j];
        ans=max(ans,cnt);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 2 * 100 * 1000 + 10;
const int P = 70;
int pro[MAXN][P];

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

	int N , K;
	cin >> N >> K;
	for (int i = 0 ; i < N ; i++)
	{
		cin >> pro[i][0];
		pro[i][0]--;
	}
	for (int iP = 1 ; iP < P ; iP++)
	{
		for (int i = 0 ; i < N ; i++)
		{
			pro[i][iP] = pro[pro[i][iP - 1]][iP-1];
		}
	}
	int actu = 0;
	int in = 0;
	while (K > 0)
	{
		if (K % 2 == 1)
		{
			actu = pro[actu][in];
		}
		in++;
		K/=2;
	}
	cout<<actu + 1<<endl;
}

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

#define REP(i, n) for(int 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 ALL(v) v.begin(), v.end()

int main() {
  //std::cout << std::fixed << std::setprecision(20);

  int64_t N, R;
  cin >> N >> R;
  if(N >= 10){
    cout << R << endl;
  }else{
    cout << (R + ( 100 * (10-N) )) << endl;
  }

}

Measured memory_bytes: 256
/*
  I_🧡🧡🧡_QMsh
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

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

using namespace std;
using namespace __gnu_pbds; // gp_hash_table<int, int> table;

template <typename T> void smin(T &a, const T &b) { a = (a < b ? a : b); }
template <typename T> void smax(T &a, const T &b) { a = (a > b ? a : b); }

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

const int N = 650;

vector <int> g[N];
vector <int> rg[N];

double dp[N];
const ld EPS = 1e-7;

bool used[N];

int bad = 0;
void dfs(int u)
{
  used[u] = 1;
  for (int v : g[u])
  {
    if (!used[v])
      dfs(v);
    dp[u] += (dp[v] + 1) / g[u].size();
  }
  if (g[u].empty())
    smin(bad, u);
}

/*void dfs2(int u)
{

}
*/
signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;

  for (int i = 0; i < m; i++)
  {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    rg[v].push_back(u);
  }

  double ans = N * N * N;
  bad = n;
  dfs(1);
  smin(ans, dp[1]);

  vector <ld> prob(n + 1);
  vector <bool> vis(n + 1);
  vis[1] = 1;
  prob[1] = 1;
  for (int i = 2; i <= n; i++)
  {
    for (int v : rg[i])
    {
      if (vis[v])
      {
        prob[i] += prob[v] / g[v].size();
        vis[i] = 1;
      }
    }
  }

  for (int i = 1; i <= n; i++)
  {
    if (g[i].size() == 1)
      continue;

    double cur = dp[1];
    for (int v : g[i])
    {
      cur -= prob[i] * (dp[v] + 1) / g[i].size();
      cur += prob[i] * (dp[v] + 1) / (g[i].size() - 1);
    }

    for (int v : g[i])
    {
      double tmp = cur - prob[i] * (dp[v] + 1) / (g[i].size() - 1);

      smin(ans, tmp);
    }
  }
  cout << fixed << setprecision(10) << ans;


  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
#include<utility>
#include<tuple>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<=(n);i++)
#define brep(i,n) for (int i=n-1;i>=0;i--)
#define LL long long int
 
 /* 
 greater<int>() 
 sortの第三因数に入れて降順 
sqrt(double) √を求める 
pair<int,int> x=make_pair(a,b)
x.first
tuple  get<番目>(変数名)

stack<int> s;//いきどまり
s.push(x) //先頭に入れる
s.pop() //先頭を消す
s.top() //先頭にアクセス
s.empty() //中身があれば0,空なら1
s.size() //中身の数

queue <int> q;//一方通行
q.push(x) //先頭に入れる
q.pop() //先頭を消す
q.front() //先頭にアクセス
q.empty() //中身があれば0,空なら1
q.size() //中身の数

 */
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}

int main(){
    int n;
    cin >>n;
    vector<double>a(n);
    double bunbo=1,bunsi=0;
    rep(i,n){
        cin >>a[i];
        bunbo*=a[i];
    }
    double w=1;
    
    rep(i,n){
        bunsi+=bunbo/a[i];
    
    }
    double ans=bunbo/bunsi;
    cout<<ans<<endl;
    return 0;


}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 1000000007
using namespace std;
typedef long long ll;

int main(){
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  bool exist = false;
  rep(i, 0, N)  cin >> A[i];
  rep(i, 0, M)  cin >> B[i];

  for(int ly=0; ly+M<=N; ly++){
    for(int lx=0; lx+M<=N; lx++){
      bool match = true;
      for(int y=0; y<M; y++){
        for(int x=0; x<M; x++){
          if(A[ly+y][lx+x] != B[y][x]){
            match = false;
          }
        }
      }
      if(match)  exist=true;
    }
  }

  if(exist) cout << "Yes" << endl;
  else  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
int main(){
		int a,b;
		char s;
		scanf("%d %c %d",&a,&s,&b);
		if(s=='+')cout << a + b<< endl;
		else cout << a - b << endl;
		return 0;
	}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
#define indexOf(v,x) (find(all(v),x)-v.begin())

class KMP {
	int len;
	int *fail;
	string s;
public:
	KMP(const string &s) :s(s) {
		len = s.size();
		fail = new int[len + 1];
		fail[0] = -1;
		for (int i = 1; i <= len; i++) {
			fail[i] = next(fail[i - 1], s[i - 1]);
		}
	}
	~KMP() { delete[] fail; }
	int next(int t, char c)const {
		if (t == len)t = fail[t];
		while (0 <= t&&s[t] != c)t = fail[t];
		return t + 1;
	}
	bool search(const string &text)const {
		int t = 0;
		for (int i = 0; i<(int)text.size(); i++) {
			t = next(t, text[i]);
			if (t == len)return true;
		}
		return false;
	}
};


int n; 
string a;



string to_s(int n) {
	string s;
	do {
		s += n % 10+'0';
		n /= 10;
	} while (n);
	reverse(all(s));
	return s;
}

bool f(int x) {
	string s(to_s(x));
	int k = 0;
	rep(i,n) {
		if (s[k]-'0'==a[i]) {
			k++;
			if (k == s.size())return false;
		}
		else {
			k = 0;
			if (s[k] - '0' == a[i]) {
				k++;
			}
		}
	}
	return true;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	rep(i, n) {
		int x;
		cin >> x;
		a += x + '0';
	}
	
	rep(i,INF) {
		KMP kmp(to_s(i));
		if (!kmp.search(a)) {
			cout << i << endl;
			break;
		}
	}


	return 0;
}

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

namespace myApp
{
    class Program
    {
        const   int M = 1046527;
        static string[]    H = new string[M];

        static int GetChar(char ch) {
            if (ch == 'A') return 1;
            else if (ch == 'C') return 2;
            else if (ch == 'G') return 3;
            else if (ch == 'T') return 4;
            else return 0;
        }
        static int GetKey(string str) {
            int sum = 0;
            int p = 1;
            char[]  c = str.ToCharArray();
            for (int i = 0; i < c.Length; i++) {
                sum += p * (GetChar(c[i]));
                p *= 5;
            }
            return sum;
        }
        static int H1(int key) {
            return key % M;
        }
        static int H2(int key) {
            return 1 + (key % (M - 1));
        }

        static bool Find(string str) {
            int     key = GetKey(str);
            for (int i = 0; ; i++) {
                int h = (H1(key) + i * H2(key)) % M;
                if (H[h] == str) return true;
                else if (H[h] == null) return false;
            }
        }
        static void Insert(string str) {
            int     key = GetKey(str);
            for (int i = 0; ; i++) {
                int h = (H1(key) + i * H2(key)) % M;
                if (H[h] == str) { return;
                } else if (H[h] == null) {
                    H[h] = str;
                    return;
                }
            }
        }
        static void Main(string[] args)
        {
            var     n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++) {
                // 命令ごとに処理
                var     line = Console.ReadLine().Split(' ');
                if (line[0] == "insert") {
                    Insert(line[1]);
                } else if (line[0] == "find") {
                    if (Find(line[1])) {
                        Console.WriteLine("yes");
                    } else {
                        Console.WriteLine("no");
                    }
                }
            }
        }
    }
}



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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    int n;
    cin >> n;
    n = n % 10;
    if (n == 3) {
        cout << "bon" << endl;
    }    
    else if (n <= 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "hon" << endl;
    }

    return 0;
}

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

int main() {
  int N, A;
  cin >> N >> A;

  if (A < 499) {
    if (N % 500 <= A) {
    cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  
  else if (A >= 499) {
  cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        int b = sc.nextInt();
        if(s.equals("+")){
          System.out.println(a + b);
        }else{
          System.out.println(a - b);
        }
    }
}


Measured memory_bytes: 23764