akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
class Program {
    static void Main (string[] args) {
        // 整数の入力
        int N = int.Parse (Console.ReadLine ());
        var s = Console.ReadLine ();
        if (N >= 3200) {
            Console.Write (s);
        } else {
            Console.Write ("red");
        }
        // int[] numbers = new int[N];
        // for (int i = 0; i < N; i++) {
        //     numbers[i] = int.Parse (Console.ReadLine ());
        // }
        // int cnt = 1;
        // int tmp1 = numbers[0]; //見始め
        // int tmp = numbers[1];
        // for (int i = 1; i < N; i++) {
        //     if (numbers[i] < tmp) {
        //         cnt += 1;
        //         if (numbers[i] <= tmp1) {
        //             cnt += 1;
        //             tmp1 = numbers[i];
        //         }
        //         tmp = numbers[i];
        //     } else if (numbers[i] == tmp) {
        //         cnt += 1;
        //     } else {

        //     }
        // }
        // Console.WriteLine (cnt);
        // // int D = int.Parse (Console.ReadLine ());
        // string[] input = Console.ReadLine ().Split (' ');
        // int[] numbers = input
        //     .Select (int.Parse)
        //     .ToArray ();
        // int N = numbers[0];
        // int D = num[1];
        // int X = 2*D+1;
        // int cnt = 1;

        // while(true){
        //     if(cnt*X / N >= 1){
        //         break;
        //     }else{
        //         cnt += 1;
        //     }
        // }
        // スペース区切りの整数の入力
        // string[] input = Console.ReadLine ().Split (' ');

        // int[] numbers = input
        // .Select (int.Parse)
        // .ToArray ();
        // int count = 0;

        // while (true) {
        //     bool ck = cheCk (a, numbers);
        //     if (check) {
        //         numbers = Divide (a, numbers);
        //         count += 1;
        //     } else {
        //         break;
        //     }
        // }
        //出力
        // Console.WriteLine (cnt);
    }

    // public static bool Check (int a, int[] numbers) {
    //     bool check = true;
    //     for (int i = 0; i < a; i++) {
    //         if (numbers[i] % 2 != 0) {
    //             check = false;
    //         }
    //     }
    //     return check;
    // }

    // public static int[] Divide (int a, int[] num){ 
    //     for (int i = 0; i < a; i++) {
    //         numbers[i] /= 2;
    //     }
    //     return numbers;
    // }
}

Measured memory_bytes: 11092
h, w = map(int, input().split())
p = 10**9+7
S = []
for i in range(h):
    S.append(list(input()))
A = [[0 for j in range(w)] for i in range(h)]
flag = True
for i in range(h):
    if S[i][0] == '#':
        flag = False
    if flag:
        A[i][0] = 1
flag = True
for j in range(w):
    if S[0][j] == '#':
        flag = False
    if flag:
        A[0][j] = 1
for i in range(1, h):
    for j in range(1, w):
        if S[i][j] == '#':
            A[i][j] = 0
        else:
            A[i][j] = (A[i-1][j]+A[i][j-1]) % p
print(A[h-1][w-1])


Measured memory_bytes: 52436
# atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7

# main
M1,D1 = map(int,input().split())
M2,D2 = map(int,input().split())

print("1" if D2==1 else "0")

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

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

  vector<int> vec(M * 2);

  for (int i = 0; i < M * 2; i++) {
	cin >> vec.at(i);  
  }
  
  int sum = 0; //出力

  for (int i = 1; i < N + 1; i++) {		//都市の数だけ繰り返す
    
    for (int j = 0; j < M * 2; j++) {	//道 ⋇ 2 = 配列に入れた分繰り返す

      if (i == vec.at(j)) {	//配列の中にi番目の都市があったら足す
          sum++;
      }
    }
  cout << sum << endl;
  sum = 0;
  }
}

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

int main() {
  int n, m;

  while(cin>>n>>m, n||m) {
    vector<int> v;
    int cnt=1;
    for(int i=0; i<n; i++) v.push_back(i+1);
    for( vector<int>::iterator it = v.begin(); v.size()>1; cnt++) {
      if(it == v.end()) it = v.begin();
      if(cnt%m==0) it = v.erase( it );
      else it++;
    }
    cout << v[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;
    
   
    long double ans = 0;
    long double now = 1.0;
    while(1){
        if(N*now>=K){
            break;
        }else{
            now*=2.0;
        }
    }
    rep(i,N){
        if((N-i)*now>=K){
            
        }else{
            now*=2;
        }
        ans += 1.0/now;
    }
    cout << fixed << setprecision(15) <<ans/(long double)N << endl;


    return 0;
    

}

Measured memory_bytes: 3780
m, n = map(int, input().split())
a = []
b = []

for i in range(m):
    x = list(map(int, input().split()))
    a.append(x)


for i in range(n):
    y = int(input())
    b.append(y)

    
for i in range(m):
    ans = 0
    for j in range(n):
        ans += a[i][j] * b[j]
    print(ans)

   


Measured memory_bytes: 6008
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main(){
	int i,N,l,m;
	long long x=0,ans=0;
	cin >> N;
	vector <int> a(N),b(N),c(N),d(N),e(N+1);
	vector <long long> f(N+1);
	for(i=0;i<N;i++){
		cin >> a[i];
	}
	for(i=0;i<N;i++){
		cin >> b[i];
	}
	for(i=0;i<N;i++){
		cin >> c[i];
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	
	for(i=0;i<N;i++){
		d[i] = upper_bound(b.begin(),b.end(),a[i])-b.begin();
	}
	for(i=0;i<N;i++){
		e[i] = c.end() - upper_bound(c.begin(),c.end(),b[i]);
		f[0] += e[i];
	}
	for(i=1;i<N;i++){
		f[i] = f[i-1] - e[i-1];
	}
	for(i=0;i<N;i++){
		ans += f[d[i]];
	}
	cout << ans << endl;
}
	
	

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

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    int a,out;
    cin >> a;
    out = a + a*a + a*a*a;
    cout << out;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    reverse(a.begin(), a.end());
    printv(a);
}



Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main(int argc, char **argv)
{
    long long N, Z, W;
    std::cin >> N >> Z >> W;
    std::vector<long long> a(N);

    for(int i = 0; i < N; i++){
        std::cin >> a.at(i);
    }

    if(N == 1){
        std::cout << std::abs(a.at(0) - W) << std::endl;
        return 0;
    }else{
        long long v = std::abs(a.at(N-1) - W);
        long long w = std::abs(a.at(N-2) - a.at(N-1));
        std::cout << std::max(v, w) << std::endl;
        return 0;
    }
    
}


Measured memory_bytes: 256
n_vertex, n_edge = gets.split.map(&:to_i)
#puts "#{n_vertex} #{n_edge}"
edges = n_vertex.times.map { Array.new(n_vertex, -1) }
for i in 0...n_edge do
  u, v, d = gets.split.map(&:to_i)
#  puts "#{u} #{v} #{d}"
  edges[u - 1][v - 1] = d
  edges[v - 1][u - 1] = d
end
#for i in 0...n_vertex do
#  puts edges[i].join(" ")
#end

for i in 1...n_vertex do
  if edges[0][i] > 0
    targ_v = i
    targ_d = edges[0][i]
    break
  end
end
#puts "#{targ_v} #{targ_d}"

t_max = gets.to_i
t_last = (t_max.to_f * 0.95).to_i
#puts "#{t_max} #{t_last}"
count = 0
for t in 0...t_max do
  n_new = gets.to_i
#  puts "#{n_new}"
  for i in 0...n_new do
    new_id, dst = gets.split.map(&:to_i)
#    puts "#{new_id} #{dst}"
  end
  
  if t < t_last
    command = -1
  else
    if count < targ_d
      command = targ_v + 1
      count += 1
    else
      command = -1
    end
  end
  puts command
end


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

int dp[(1<<15)+3];
int a[16][16];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m; int M=1;
	for(int i=0;i<m;i++)
	{
		M=mult(M,2);
		int u,v; cin>>u>>v; u--; v--;
		a[u][v]=1;
	}
	dp[0]=1;
	for(int i=0;i<(1<<n);i++)
	{
		if(dp[i]==0) continue;
		int v=dp[i];
		int superset=i^((1<<n)-1);
		for(int j=superset;;j=((j-1)&superset))
		{
			if(j==0) break;
			if((j&1)^((j>>1)&1)) continue;
			int ways=1; int z=0;
			for(int k=0;k<n;k++)
			{
				if(i&(1<<k))
				{
					int c=0;
					for(int l=0;l<n;l++)
					{
						if(j&(1<<l))
						{
							if(a[k][l])
							{
								c++;
							}
							if(a[l][k])
							{
								z++;
							}
						}
					}
					ways=mult(ways,(1<<c)-1);
				}
			}
			for(int x=0;x<z;x++) ways=mult(ways,2);
			dp[i^j]=add(dp[i^j],mult(v,ways));
		}
	}
	cout<<add(M,MOD-dp[(1<<n)-1])<<'\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a > 0 && c > 0) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int d = sc.nextInt();  // 365
        int[] c = new int[26];
        int[][] s = new int[d][26];

        for (int i = 0; i < 26; i++) {
            c[i] = sc.nextInt();
        }

        for (int i = 0; i < d; i++) {
            for (int j = 0; j < 26; j++) {
                s[i][j] = sc.nextInt();
            }
        }

        PrintWriter pw = new PrintWriter(System.out);
        int[] last_day = new int[26];
        for (int i = 0; i < d; i++) {
            int max_p = Integer.MIN_VALUE;
            int max_i = 0;
            for (int j = 0; j < 26; j++) {
                int tmp = -c[j] * (i+1 - last_day[j]);

                if (max_p <= tmp+s[i][j]) {
                    max_p = tmp+s[i][j];
                    max_i = j;
                }
            }

            last_day[max_i] = i+1;
            pw.println(max_i + 1);
        }

        pw.flush();
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 35796
N=gets.chomp.to_i
arrFood=[]
arrPoint=[]
arrBonus=[]

arrFood=gets.chomp.split.map(&:to_i)
arrPoint=gets.chomp.split.map(&:to_i)
arrBonus=gets.chomp.split.map(&:to_i)

basicSum = arrPoint.inject(:+)


bonusSum = 0
arrFood.each_with_index do |food, i|
  if (arrFood[i + 1].to_i - arrFood[i].to_i) == 1
    bonusSum += arrBonus[arrFood[i].to_i - 1]
  end
end

puts basicSum + bonusSum

Measured memory_bytes: 1788
from operator import itemgetter
n,k = (map(int,input().split()))
a = sorted([list(map(int,input().split())) for i in range(n)])
count = 0
for i in range(len(a)):
         count += a[i][1]
         if count >= k:
                  print(a[i][0])
                  exit()
         


Measured memory_bytes: 28668
import sys

def main():
  input = sys.stdin.readline
  N = int(input())
  ans = 0
  for _ in range(N):
    x, u = map(str, input().split())
    if u == 'JPY':
      ans += float(x)
    else:
      ans += float(x) * 380000
    
  print(ans)


if __name__ == '__main__':
  main()

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

int main(){
    int N;
    cin >> N;
    vector<char>c(N);
    for (int i = 0; i < N; i++)
    {
        cin >> c.at(i);
    }
    int r = -1, w = N;
    for (int i = 0; i < N; i++)
    {
        if (w == N && c.at(i) == 'W')
        {
            w = i;
        }
        if (r == -1 && c.at(N-1-i) == 'R')
        {
            r = N - 1 - i;
        }
    }
    if (r < w)
    {
        cout << 0;
    }
    else
    {
        int rn = 0, wn = 0;
        for (int i = 0; i < r - w + 1; i++)
        {
            if (c.at(w+i) == 'W')
            {
                wn++;
            }
            if (c.at(w+i) == 'R')
            {
                rn++;
            }
        }
        int rna = rn, wna = wn;
        for (int i = 0; i < wn; i++)
        {
            if (c.at(r-i) == 'W')
            {
                wna--;
            }
        }
        for (int i = 0; i < rn; i++)
        {
            if (c.at(w+i) == 'R')
            {
                rna--;
            }
        }
        cout << min(wna, rna);
    }
}

Measured memory_bytes: 3592
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		String t = sc.next();

		// 計算
		String result = "Yes";
		int[] arrayS = new int[26];
		int[] arrayT = new int[26];
		int index = 0;
		for(char c = 'a'; c <= 'z'; c++){
		    for(int i = 0; i < s.length(); i++){
		        if(s.charAt(i) == c) arrayS[index]++;
		        if(t.charAt(i) == c) arrayT[index]++;
		    }
		    index++;
		}
		Arrays.sort(arrayS);
		Arrays.sort(arrayT);
		for(int i = 0; i < 26; i++){
		    if(arrayS[i] != arrayT[i]) result = "No";
		}
		
		// 出力
		System.out.println(result);
		
	}
}


Measured memory_bytes: 26388
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int sum = 1;
		String[] s = new String[n];
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		java.util.Arrays.sort(s);
		
		for(int i= 1; i < n; i++) {
			if(!s[i].equals(s[i-1])) {
				sum++;
			}
		}
		System.out.println(sum);
	}
	
}


Measured memory_bytes: 62068
#include <bits/stdc++.h>
#define PII pair<int,int>
using namespace std;
const int MAXN = 100000;
const int INF = 1e9 + 5;

struct DSU {
	int pa[MAXN+5];
	int find_root(int x) {
		return pa[x] == x ? x : pa[x] = find_root(pa[x]);
	}
	void merge(int x, int y) {
		x = find_root(x);
		y = find_root(y);
		if (x == y) return;
		pa[y] = x;
	}
} dsu;

int pa[MAXN+5], first[MAXN+5];
vector<pair<char, int>> qs;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N, Q;
	while (cin >> N >> Q) {
		if (N == 0 && Q == 0) break;
		for (int i = 1; i <= N; i++) {
			first[i] = 1e9;
		}
		
		dsu.pa[1] = pa[1] = 1;
		for (int i = 2; i <= N; i++) {
			cin >> pa[i];
			dsu.pa[i] = pa[i];
		}
		
		qs.resize(Q);
		for (int i = 0; i < Q; i++) {
			int v;
			char c;
			cin >> c >> v;
			qs[i] = {c, v};
			if (c == 'M') {
				dsu.pa[v] = v;
				first[v] = min(first[v], i);
			}
		}
		
		long long ans = 0;
		for (int q = Q - 1; q >= 0; q--) {
			char c = qs[q].first;
			int v = qs[q].second;
			if (c == 'Q') {
				ans += dsu.find_root(v);
			}
			else if (q == first[v]) {
				dsu.merge(pa[v], v);
			}
		}
		
		cout << ans << "\n";
	}
	
	/**** Note MAXN ****/
}



Measured memory_bytes: 4948
// @author: Arthur Sun

#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

#define all(x) begin(x), end(x)
#define fillc(p, t, v) fill_n((t*) p, sizeof(p) / sizeof(t), v)
#define pb push_back
#define inc(a, b, c) for(auto a(b); a <= (c); a++)
#define dec(a, b, c) for(auto a(b); a >= (c); a--)

#define MAX_N (304)

int N;
int cnt[5];

double cache[MAX_N][MAX_N][MAX_N];

double dp(int k1, int k2, int k3) {
    if(k1 < 0 or k2 < 0 or k3 < 0) return 0.0;
    if(k1 == 0 and k2 == 0 and k3 == 0) return 0.0;
    auto& ans = cache[k1][k2][k3];
    if(ans >= 0.0)
        return ans;
    ans = 0.0;
    ans += k1 / (double) N * (1.0 + dp(k1 - 1, k2, k3));
    ans += k2 / (double) N * (1.0 + dp(k1 + 1, k2 - 1, k3));
    ans += k3 / (double) N * (1.0 + dp(k1, k2 + 1, k3 - 1));
    ans += (N - k1 - k2 - k3) / (double) N;
    ans /= 1.0 - (N - k1 - k2 - k3) / (double) N;
    return ans;
}

int main() {
    srand(time(nullptr));
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    inc(i, 0, N - 1) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    fillc(cache, double, -1.0);
    cout << fixed << setprecision(15);
    cout << dp(cnt[1], cnt[2], cnt[3]) << '\n';
    return 0;
}



Measured memory_bytes: 223280
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,a,b,k;
  cin>>a>>b>>k;
  if(a>=k)
  {
      cout<<a-k<<" "<<b<<endl;
  }
  else if(a+b>=k)
  {
      cout<<0<<" "<<b-(k-a)<<endl;
  }
 else
    cout<<0<<" "<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int main(){
	unsigned long long H,W;
	scanf("%lld %lld",&H,&W);
	if(H == 1 || W == 1) printf("%d",1);
	else{
		if(H%2 == 0){
			printf("%lld",(H/2)*W);
		}
		else{
			if(W%2==0){
				printf("%lld",(H/2)*W+W/2);
			}else{
				printf("%lld",(H/2)*W+W/2+1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
A = []
for i in range(h):
    if i%2 == 1:
        A.extend(reversed(list(map(int, input().split()))))
    else:
        A.extend(list(map(int, input().split())))
ans = []

def calcPos(i):
    if i//w % 2 == 0:
        return i//w + 1, i%w + 1
    else:
        return i//w + 1, w - i%w

for i in range(h*w-1):
    if A[i] % 2 == 1:
        A[i] -= 1
        A[i+1] += 1
        x,y = calcPos(i)
        x_,y_ = calcPos(i+1)
        ans.append("%d %d %d %d" % (x,y,x_,y_))
print(len(ans))
print(*ans, sep='\n')

Measured memory_bytes: 17832
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20191021
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int count = 0;
            
            for (int i = 1; i <= n; i++)
            {


                if (i / 10 == 0)
                {
                    count++;
                }

                else if(i / 100 == 0)
                {

                }

                else if (i / 1000 == 0)
                {
                    count++;
                }

                else if (i / 10000 == 0)
                {

                }

                else if (i / 100000 == 0)
                {
                    count++;
                }

                else if (i / 1000000 == 0)
                {

                }

                else if (i / 10000000 == 0)
                {
                    count++;
                }

            }

            Console.WriteLine(count);

        }
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int l[N];
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  sort (l, l + N);
  reverse (l, l + N);
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(void){
    int n;
    cin>>n;
    int* row=(int*)malloc(sizeof(int)*n);
    int u,k;
    int v;
    for(int j=0;j<n;j++){
        for(int i=0;i<n;i++){
            row[i]=0;
        }
        cin>>u>>k;
        for(int i=0;i<k;i++){
            cin>>v;
            row[v-1]=1;
        }
        for(int i=0;i<n-1;i++){
            cout<<row[i]<<" ";
        }
        cout<<row[n-1]<<endl;
    }
    return 0;
}



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

int main() {
    int r,g,b;
    cin >> r>>g>>b;
 
  if ((10*g+b)%4 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

}

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

using namespace std;
const int N = 2e5+1;

int ans[N];
pair <int, int> a[N];
int main(){
    int n; cin >> n;
    for (int i = 0; i < n; ++ i){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a, a+n);
    for (int i = 0; i < n; ++ i){
        int m = n/2-1;
        if (i <= m) ++ m;
        ans[a[i].second] = a[m].first;
    }
    for (int i = 0; i < n; ++ i)
        cout << ans[i] << endl;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define ve vector

int main() {
    int n,l; cin>>n>>l;
    ve<string> a(n);
    for(string& i:a) cin>>i;
    sort(a.begin(),a.end());
    for(string i:a) cout<<i;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll ans = n-1;
    for(ll i = 1; i * i <= n; i++) {
        if(n%i==0) ans = min(ans, i + n/i - 2);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int s[]={1,2,4,8,16,32,64};
  for(int i=6;i>=0;--i){
    if(s[i]<=n){
      cout<<s[i]<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
	typedef long long int lli;
	const int MaxN=200005;
	#define fst first
	#define snd second
	const lli mod=1e9+7;
	lli gauss(lli N){
		return N*(N+1)/2;
	}
int main(){
	lli N,K,i,p,inf,sup,tot=0;
	cin>>N>>K;
	for(K=K;K<=N+1;K++){
		inf=gauss(K-1);
		sup=gauss(N)-gauss(N-K);
		//cout<<inf<<" "<<sup<<" "<<N<<" "<<K<<"\n";
		tot+=sup-inf+1;
		tot=tot%mod;
	}
	cout<<tot;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int,int> > vp;
#define pb push_back
#define mp make_pair
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin>>n>>k;
	ll ans = 0;
	for(int i=1;i<=n;i++){
		ll x = k - i%k;
		ll y = k - x%k;
		if(!x)x += k;
		if(!y)y += k;
		if(x == y){
			ll val1 = 0;
			ll low = 0, high = 1e6;
			while(low < high){
				ll mid = (low + high)/2;
				if(x + mid*k > n)high = mid;
				else low = mid + 1;
			}
			val1 = low;
			if(val1 < 0)continue;
			low = 0, high = 1e6;
			while(low < high){
				ll mid = (low + high)/2;
				if(y + mid*k > n)high = mid;
				else low = mid + 1;
			}
			ll val2 = low;
			if(val2 < 0)continue;
			ans += 1LL*(val1)*(val2);
		}
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[100005],dp[2][100005];
int main(){
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	dp[0][0]=a[0],dp[1][0]=-a[0];
	for(int i=1;i<n;i++){
		dp[0][i]=max(dp[0][i-1]+a[i],dp[1][i-1]-a[i]);
		if(i!=n-1)dp[1][i]=max(dp[0][i-1]-a[i],dp[1][i-1]+a[i]);
	}
	cout << max(dp[0][n-1],dp[1][n-1]);
	return 0;
}

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

namespace AtCoderCs
{
    class Program
    {
        static void Main()
        {

            var K = int.Parse(Console.ReadLine());
            var Result = 0;
            for (int i = K; 0 < i; i--)
            {

                for (int j = i; 0 < j; j--)
                {

                    for (int k = j; 0 < k; k--)
                    {

                        bool[] Boolean = new bool[2] { i == j, j == k };

                        Result += Gcd(i, Gcd(j, k)) * (Boolean[0] && Boolean[1] ? 1 : (Boolean[0] || Boolean[1] ? 3 : 6));

                    }

                }

            }

            Console.WriteLine(Result);

            int Gcd(int a, int b)
                => a > b ? PrivateGcd(a, b) : PrivateGcd(b, a);

            int PrivateGcd(int a, int b)
                => b == 0 ? a : PrivateGcd(b, a % b);

        }


    }
}


Measured memory_bytes: 46016
import math

def main():
    buf = input()
    N = int(buf)
    buf = input()
    buflist = buf.split()
    A = list(map(int, buflist))
    remaining = list(sorted(set(A)))
    while len(remaining) > 1:
        smallest = remaining[0]
        for i in range(1, len(remaining)):
            remaining[i] %= smallest
        new_remaining = []
        for i in remaining:
            if i > 0:
                new_remaining.append(i)
        remaining = list(sorted(set(new_remaining)))
    print(remaining[0])

if __name__ == '__main__':
    main()


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

int main(void) {
    int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    cout << x2 - y2 + y1 << " " << y2 + x2 - x1 << " " << x1 - y2 + y1 << " " << y1 + x2 - x1 << endl;
    return 0;
}

Measured memory_bytes: 256
function main(input){
    var input = input.split('\n');
    var num = parseInt(input[0]);
    var playlist = Array(num);
    var log = Array(num);
    var flag = 0;
    var time = 0;

    for(i=1;i<=num;i++){
        playlist[i] = input[i].split(' ');
        if(flag==1){
            time=time+parseInt(playlist[i][1]);
        }
        if(playlist[i][0] == input[num+1]){
            flag=1;
        }
    }

    console.log(time);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

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

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long LL;

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

//=function prototype========================================================//

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

//=variables=================================================================//
char X, Y;
//===========================================================================//
int main(void)
{
  // Scan begin.
  scanf("%c %c", &X, &Y);
  // Scan done.

  // Code begin.
  if (X == Y) {
    printf("=\n");
  }
  else if (X > Y) {
    printf(">\n");
  }
  else {
    printf("<\n");
  }
  // Code done.

  // return begin.
  return 0;
  // return done.
}

//=functions=================================================================//

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

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

int main(){
    long long N;
    cin >> N;
    long long i, n, n_sub, num = 0;
    long long counta_seki;
    long long counta[11];
    long long p[11] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};
    for(n = 1; n <= N; n += 2){
        n_sub = n;
        counta_seki = 1;
        for(i = 0; i < 11; i++){
            counta[i] = 0;
            while(n_sub % p[i] == 0){
                n_sub /= p[i];
                counta[i]++;
            }
            counta_seki *= (1 + counta[i]);
        }
    if(counta_seki == 8){
        num++;
    }
    }
    cout << num << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
dis1 = []
dis2 = []
num = 0
ans = 0
tmp = 0

for i in range(N):
    num = A[i] - B[i]
    if num > 0:
        dis1.append(num)
    elif num < 0:
        dis2.append(num)

if sum(A) < sum(B):
    ans = -1
elif len(dis2) == 0:
    ans = 0
else:
    dis1.sort(reverse = True)
    num = sum(dis2)
    ans += len(dis2)
    for i in range(len(dis1)):
        num += dis1[i]
        ans += 1
        if num >= 0:
            break

print(ans)

Measured memory_bytes: 18356
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __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...);
}
string s,t;
int dp[N][2];
int solve(int pos,int f){
	if(pos==t.size()){
		if(!f)return 0;
		else
			return 1e18;
	}
	if(dp[pos][f]!=-1)return dp[pos][f];
	int d = t[pos]-'0';
	int x = 1e18;
	if(!f){
		x = min(x,d+solve(pos+1,0));
		if(d<9)x=min(x,d+1+solve(pos+1,1));
	}
	else{
		x= min(x,10-d+solve(pos+1,0));
		x= min(x,10-d-1+solve(pos+1,1));
	}
	return dp[pos][f]=x;
}
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		cin>>s;
		t = "0";
		t+=s;
		memset(dp,-1,sizeof(dp));
		cout<<solve(0,0);
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 96156
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    string s;
    cin >> s;
    if(s[0]=='9'||s[1]=='9')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
        int result=0;
        for(int i=0;i<2;i++) {
			result += Math.max(A,B);
            if(result == A) A--;
            else B--;
		}
    	System.out.println(result);
	}
}

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

int main() {
  int N, Q; cin >> N >> Q;
  vector<ll> a(N); for (int i = 0; i < N; ++i) cin >> a[i];
  vector<ll> x(Q); for (int i = 0; i < Q; ++i) cin >> x[i];

  vector<deque<int>> deq(Q);
  vector<ll> ans(Q, 0);
  vector<ll> sum(Q, 0);
  for (auto&& val : a) {
    for (int i = 0; i < Q; ++i) {
      deq[i].push_back(val);
      sum[i] += val;
      while (sum[i] > x[i]) {
        ll b = deq[i].front(); deq[i].pop_front();
        sum[i] -= b;
      }
      ans[i] += deq[i].size();
    }
  }
  for (auto&& val : ans) cout << val << endl;
  return 0;
}



Measured memory_bytes: 113204
#include<iostream>
#include<map>
#include<vector>
using namespace std;
string s[10];
int h,w;
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};
main()
{
	while(cin>>h>>w,h)
	{
		for(int i=0;i<h;i++)cin>>s[i];
		map<string,int>M;
		string ans="0";
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)
		{
			for(int r=0;r<8;r++)
			{
				string now=s[i].substr(j,1);
				int x=i+dx[r],y=j+dy[r];
				x=(x+h)%h;y=(y+w)%w;
				while(x!=i||y!=j)
				{
					now+=s[x][y];
					if(M[now]++==1)
					{
						if(now.size()>ans.size())ans=now;
						else if(ans.size()==now.size()&&ans>now)ans=now;
					}
					x+=dx[r],y+=dy[r];
					x=(x+h)%h;y=(y+w)%w;
				}
			}
		}
		cout<<ans<<endl;
	}
}



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

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

  int sum = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;

    if (x * 2 < (K - x) * 2) {
      sum += x * 2;
    }
    else {
      sum += (K - x) * 2;
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
import math

s = input()
li = [0 for _ in range(len(s))]

rCnt = 0
for i in range(len(s)):
    if s[i] == "R":
        rCnt += 1
    else:
        li[i] += rCnt // 2
        li[i - 1] += math.ceil(rCnt / 2)
        rCnt = 0
lCnt = 0
for i in reversed(range(len(s))):
    if s[i] == "L":
        lCnt += 1
    else:
        li[i] += lCnt // 2
        li[i + 1] += math.ceil(lCnt / 2)
        lCnt = 0

print(*li)

Measured memory_bytes: 10856
#include <bits/stdc++.h>
using namespace std;
using pll=pair<long long,long long>;

int N;long long base=998244353LL;

long long topow(int x) {
  if (x==0) return 1;
  else {
    if (x%2==0) return topow(x/2)*topow(x/2)%base;
    else return 2*topow(x-1)%base;
  }
}

long long operator*(pll x,pll y) {
  long long xx=((topow(x.first)-1)%base)*((topow(y.second)-1)%base)%base;
  long long yy=((topow(x.second)-1)%base)*((topow(y.first)-1)%base)%base;
  long long zz=topow(N-1)%base;
  long long ww=(((topow(x.first)-1)%base)*((topow(y.second)-1)%base)%base)*(((topow(x.second)-1)%base)*((topow(y.first)-1)%base)%base)%base;
  return (xx*topow(N-1-x.first-y.second)%base+yy*topow(N-1-x.second-y.first)%base+zz-ww)%base;
}

int main() {
  cin >> N;
  vector<pll> A(N);map<long long,int> M1,M2;
  for (int i=0;i<N;i++) {
    cin >> A[i].first >> A[i].second;
  }
  vector<pll> B=A;
  sort(A.begin(),A.end());
  for (int i=0;i<N;i++) {
    M1[A[i].first]=i;
  }
  for (int i=0;i<N;i++) {
    A[i].first=B[i].second;
    A[i].second=B[i].first;
  }
  sort(A.begin(),A.end());
  for (int i=0;i<N;i++) {
    M2[A[i].first]=i;
  }
  for (int i=0;i<N;i++) {
    B[i].first=M1[B[i].first];
    B[i].second=M2[B[i].second];
  }
  sort(B.begin(),B.end());
  vector<int> X(N,0);
  for (int i=0;i<N;i++) {
    int j=B[i].second;long long low=0LL;
    while (j>0) {
      int lsb=(j & -1*j);
      low+=X[j-1];
      j-=lsb;
    }
    long long high=i-low;A[i]=make_pair(low,high);
    int k=B[i].second+1;
    while (k<=N) {
      int lsb=(k & -1*k);
      X[k-1]++;
      k+=lsb;
    }
  }
  vector<pll> C(N);vector<int> Y(N,0);
  for (int i=N-1;i>=0;i--) {
    int j=B[i].second;long long low=0LL;
    while (j>0) {
      int lsb=(j & -1*j);
      low+=Y[j-1];
      j-=lsb;
    }
    long long high=N-1-i-low;C[i]=make_pair(low,high);
    int k=B[i].second+1;
    while (k<=N) {
      int lsb=(k & -1*k);
      Y[k-1]++;
      k+=lsb;
    }
  }
  long long ans=0LL;
  for (int i=0;i<N;i++) {
    ans+=A[i]*C[i];
    ans%=base;
  }
  cout << ans << endl;
}

Measured memory_bytes: 39100
#include<bits/stdc++.h>
using namespace std;
int N, K;
int x[101010], y[101010]; char c[101010];
int S[2020][2020];
// [x1, x2) [y1, y2)
int Sum(int x1, int x2, int y1, int y2)
{
  --x1; --y1; --x2; --y2;
  return S[x2][y2] - S[x1][y2] - S[x2][y1] + S[x1][y1];
}
void Sinit()
{
  for(int i=1; i<=2*K; ++i)
    for(int j=1; j<=2*K; ++j)
      S[i][j] += S[i-1][j] + S[i][j-1] - S[i-1][j-1];
}
int main()
{
  scanf("%d%d", &N, &K);
  for(int i=0; i<N; ++i)
  {
    scanf("%d%d %c", x+i, y+i, c+i);
    x[i] %= 2*K; y[i] %= 2*K;
    if(c[i] == 'W') S[x[i]+1][y[i]+1]++;
    else S[x[i]+1][y[i]+1]--;
  }
  Sinit();
  
  /*
  for(int i=1; i<=2*K; ++i, puts(""))
    for(int j=1; j<=2*K; ++j)
      printf("%d ", S[i][j]);
  */
  
  int ans = -99999999;
  for(int v1=1; v1<=K+1; ++v1)
    for(int v2=1; v2<=K+1; ++v2)
    {
      // [1, v1) [v1, v1+K) [v1+K, 2K+1)
      // [1, v2) [v2, v2+K) [v2+K, 2K+1)
      int vv =   Sum(1, v1, 1, v2) 
              +  Sum(1, v1, v2+K, 2*K+1)
              +  Sum(v1, v1+K, v2, v2+K)
              +  Sum(v1+K, 2*K+1, 1, v2)
              +  Sum(v1+K, 2*K+1, v2+K, 2*K+1);
      ans = max(ans, max(vv, S[2*K][2*K] - vv));
    }
  //printf("%d %d %d\n", ans, S[2*K][2*K], N);
  printf("%d\n",  (ans*2 - S[2*K][2*K] + N)/ 2 );
  return 0;
  
  
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

vll nums(MAXN);
vector<vector<ll>> dp(MAXN, vector<ll>(MAXN, LINF));

ll res(ll l, ll r) {
    if (l > r) {
        return 0;
    }
    if (l == r) {
        return 0;
    }
    if (dp[l][r] < LINF) {
        return dp[l][r];
    }
    for (int k = l; k < r; ++k) {
        dp[l][r] = min(dp[l][r], res(l, k) + res(k + 1, r) + nums[r] - nums[l - 1]);
    }
    return dp[l][r];
}

int main() {
    ll N;
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> nums[i];
        nums[i] += nums[i - 1];
    }
    cout << res(1, N) << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

const i32 mod = 1000000007;

#define ADD(x, a) do{(x) += (a); if ((x) >= mod) (x) -= mod;} while (0)
#define SUB(x, a) do{(x) += mod - (a); if ((x) >= mod) (x) -= mod;} while (0)

i32 inv (i32 a) {
  i32 t = 1;
  while (a > 1) {
    t = (i64) t * (mod - mod / a) % mod;
    a = mod % a;
  }
  return t;
}

i32 mod_pow (i32 r, i32 n) {
  i32 t = 1;
  i32 s = r;
  while (n > 0) {
    if (n & 1) t = (i64) t * s % mod;
    s = (i64) s * s % mod;
    n >>= 1;
  }
  return t;
}

i32 *fact = NULL;
i32 *iFact = NULL;
void init_fact (const i32 n) {
  fact = (i32 *) calloc (n + 1, sizeof (i32));
  fact[0] = 1;
  for (i32 i = 1; i <= n; ++i) {
    fact[i] = (i64) i * fact[i - 1] % mod;
  }
  iFact = (i32 *) calloc (n + 1, sizeof (i32));
  iFact[n] = inv (fact[n]);
  for (i32 i = n - 1; i >= 0; --i) {
    iFact[i] = (i64) (i + 1) * iFact[i + 1] % mod;
  }
}

i32 perm (i32 n, i32 k) {
  if (!(0 <=k && k <= n)) return 0;
  return (i64) fact[n] * iFact[n - k] % mod;
}

i32 comb (i32 n, i32 k) {
  if (!(0 <= k && k <= n)) return 0;
  return (i64) fact[n] * iFact[k] % mod * iFact[n - k] % mod;
}

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

void run (void) {
  i32 n, a, b, c;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32 "%" SCNi32, &n, &a, &b, &c);
  i32 p = (i64) a * inv (a + b) % mod;
  i32 q = (1 + mod - p) % mod;
  init_fact (2 * n);
  i64 ans = 0;
  for (i32 i = 0; i < n; ++i) {
    i64 prob = (i64) comb (n + i - 1, i) * mod_pow (p, n - 1) % mod * mod_pow (q, i) % mod * p % mod;
    ans = (ans + (i64) prob * (n + i)) % mod;
  }
  for (i32 i = 0; i < n; ++i) {
    i64 prob = (i64) comb (n + i - 1, i) * mod_pow (q, n - 1) % mod * mod_pow (p, i) % mod * q % mod;
    ans = (ans + (i64) prob * (n + i)) % mod;
  }
  ans = ans * 100 % mod * inv (100 - c) % mod;
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


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

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

    vector<int> a(n, 0);

    rep2(i, 1, n)
    {
        int t;
        cin >> t;
        a.at(t - 1)++;
    }

    rep(i, n)
    {
        cout << a.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 4060
from collections import defaultdict

N = int(input())
C = defaultdict(int)
for x in range(1, 10**2+1):
    for y in range(1, 10**2+1):
        for z in range(1, 10**2+1):
            n = x**2 + y**2 + z**2 + x*y + y*z + z*x
            C[n] += 1

for i in range(N):
    print(C[i+1])

Measured memory_bytes: 72396
class Dice:
    
    def __init__(self, nums):
        self.nums = list(nums)
        
    @property
    def top(self):
        return self.nums[0]
        
    def _shift(self, *pairs):
        for pair in pairs:
            num = self.nums[pair[0]]
            self.nums[pair[0]] = self.nums[pair[1]]
            self.nums[pair[1]] = num
            
    def go(self, opes:str):
        for ope in opes:
            if ope == "N":
                self.go_north()
            elif ope == "E":
                self.go_east()
            elif ope == "W":
                self.go_west()
            else:
                self.go_south()
        
    def go_north(self):
        self._shift((0, 1), (1, 5), (5, 4))
        
    def go_east(self):
        self._shift((0, 3), (3, 5), (5, 2))
        
    def go_west(self):
        self._shift((0, 2), (2, 5), (5, 3))
        
    def go_south(self):
        self._shift((0, 4), (4, 5), (5, 1))
        

dice = Dice(map(int, input().split()))
dice.go(input())
print(dice.top)


Measured memory_bytes: 5604
from sys import stdin
H,W = [int(x) for x in stdin.readline().rstrip().split()]
data = [["."]*(W+2)]
for _ in range(H):
    data.append(["."] + list(input()) + ["."])
data.append(["."]*(W+2))

ans_flag = True
for h in range(1,H+1):
    for w in range(1,W+1):
        flag = True
        if data[h][w] == "#":
            flag = False
            if data[h+1][w] == "#":
                flag = True
            if data[h-1][w] == "#":
                flag = True
            if data[h][w+1] == "#":
                flag = True
            if data[h][w-1] == "#":
                flag = True
        #print(flag,h,w)
        if flag == False:
            ans_flag = False
if ans_flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a%3==0||b%3==0||(a+b)%3==0)
        printf("Possible\n");
    else
        printf("Impossible\n");
    return 0;
}


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

int main (){
	int n,k,ans=0;
	cin >> n>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin>>h.at(i);
    }
    for(int i=0;i<n;i++){
        if(h.at(i)>=k){
            ans+=1;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a  >> b;
  for(int i=1;;i++){
    int a1=i*0.08;
    int b1=i*0.1;
    if(a1==a && b1==b){
      cout << i << endl;
      break;
    }
    if(a1>a && b1>b){
      cout << -1  << endl;
      break;
    }
  }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

const int MX = 1101010;

const int mod = 1000000007;
class mint {
  long long x;
  public:
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const {
    return mint(-x);
  }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const  mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint& a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint& a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint& a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint& a) const {
    mint res(*this);
    return res/=a;
  }

  friend ostream& operator<<(ostream& os, const mint& m){
    os << m.x;
    return os;
  }
};

struct Sieve{
  int n;
  vector<int> f,primes;
  Sieve(int n=1):n(n),f(n+1){
    f[0] = f[1] = -1;
    for(int i = 2; i <= n;++i){
      if(f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for(int j = i*i;j <= n;j += i){
        if(!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x){return f[x] == x;}
  vector<int> factorList(int x){
    vector<int> res;
    while(x != 1){
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x){
    vector<int> fl = factorList(x);
    if(fl.size() == 0) return {};
    vector<P> res(1,P(fl[0],0));
    for(int p:fl){
      if(res.back().first == p){
        res.back().second++;
      }
      else{
        res.emplace_back(p,1);
      }
    }
    return res;
  }
};

signed main(){
  Sieve sieve(MX);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  map<int,int> mp;
  rep(i,n){
    auto f = sieve.factor(a[i]);
    for(auto p:f){
      mp[p.first] = max(mp[p.first],p.second);
    }
  }
  mint lcm = 1;
  for(auto p:mp){
    rep(i,p.second){
      lcm *= p.first;
    }
  }
  mint ans;
  rep(i,n){
    mint b = lcm/a[i];
    ans += b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 10228