akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <limits.h>

using namespace std;

vector<long long> su(200000);

long long binary_search(int le, int ri, long long mid,int st,int ed) {
	if (ri - le == 1) {
		if (ri == ed) {
			return su[le];
		}
		if (su[ri]*2 - mid > mid - su[le]*2) {
			return su[le];
		}
		else {
			return su[ri];
		}
	}
	else {
		int ce = (le + ri) / 2;
		if (su[ce]*2 > mid) {
			return binary_search(le, ce, mid,st,ed);
		}
		else {
			return binary_search(ce, ri, mid,st,ed);
		}
	}
}

long long min(long long x,long long y) {
	if (x > y) {
		return y;
	}
	else {
		return x;
	}
}

long long max(long long x, long long y) {
	if (x > y) {
		return x;
	}
	else {
		return y;
	}
}

long long cal(long long  a, long long b, long long c, long long d) {
	return max(max(a, b), max(c, d)) - min(min(a, b), min(c, d));
}

int main() {
	int n;
	cin >> n;
	vector<int> da(n);
	for (int i = 0;i < n;i++) {
		cin >> da[i];
	}
	su[0] = da[0];
	for (int i = 1;i < n;i++) {
		su[i] = su[i - 1] + da[i];
	}
	long long ans = LLONG_MAX;
	for (int i = 1;i < n - 2;i++) {
		long long  x = binary_search(0, i, su[i] , 0, i),
			y = binary_search(i + 1, n - 1, su[i] + su[n - 1], i + 1, n - 1);
		ans = min(ans, cal(x, su[i] - x, y - su[i], su[n - 1] - y));
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void)
{
  int N, i, sum, most;
  int L[N];
  scanf("%d", &N);
  for(i=0; i<N; i++) {
    scanf("%d", &L[i]);
  }
  sum = 0;
  for(i=0; i<N; i++) {
    sum += L[i];
  }
  most = 0;
  for(i=0; i<N; i++) {
    if(most < L[i]) {
      most = L[i];
    }
  }
  if(most < sum - most) {
    printf("Yes");
  }
  else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
from math import factorial
n,k=map(int,input().split())
inf=10**9+7
def combi(N,r):
    if N==r:
        return 1
    else:
        return factorial(N)//(factorial(N-r)*factorial(r))
for i in range(1,k+1):
    if i>n-k+1:
        print(0)
    else:
        print((combi(n-k+1,i)*combi(k-1,i-1))%inf)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n,m;
	while(cin >> n >> m , n){
		double dp[101][101] = {0};
		double rate[101][101] = {0};
		rep(i,n)rep(j,n)
			cin >> rate[i][j];
		rep(i,n)dp[0][i] = 1.0;
		rep(x,m-1){
			rep(i,n)
				rep(j,n)
					dp[x+1][j] = max(dp[x][i]*rate[i][j],dp[x+1][j]);
		}
		double ans = 0;
		rep(i,n) ans = max(ans,dp[m-1][i]);
		printf("%.2lf\n",ans);
	}
}

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

int main(int argc , char *argv[]){
    int n;
    cin >> n;
    int l[n];
    int r[n];
    for (int i=0;i<n;++i) cin >> l[i] >> r[i];
    int ans=0;
    for(int i=0;i<n;++i){
        ans+=r[i]-l[i]+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    vp bc(m);
    rep(i,m) cin >> bc[i].S >> bc[i].F;
    sort(all(bc),greater<P>());
    int res=0;

    int j=0;
    rep(i,n){
        if(bc[j].F>a[i]){
            a[i]=bc[j].F;
            bc[j].S--;
            if(bc[j].S==0) j++;
        }else break;
    }
    
    rep(i,n) res+=a[i];
    cout<<res<<endl;


}   

Measured memory_bytes: 5520
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 100000000
using namespace std;
int main()
{
 	ll n,ct=0;cin>>n;
 	vector<ll>v(n);
 	rep(i,0,n) cin>>v[i];
 	rep(i,1,n-1)
 	{
 		ll mn=min(v[i-1],v[i+1]),mx=max(v[i-1],v[i+1]);
 		if(v[i]>mn&&v[i]<mx) ct++;
 		
	 }
	cout<<ct;
	
	
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B, C, K; cin >> A >> B >> C >> K;
	int ans = 0;
	ans += min(A, K);
	K -= ans;
	if (K >= 0) {


		K -= B;
		
	}
	if (K >= 0) {
		ans -= min(C, K);
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 305;
const int mod = 1e9 + 7;

int n, a[MAXN], fac[MAXN], inv[MAXN], f[MAXN][MAXN][MAXN];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i <= n; i ++)
		fac[i] = 1LL * fac[i - 1] * i % mod, inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	bool sam = true;
	for (int i = 1; i <= n; i ++)
		inv[i] = 1LL * inv[i - 1] * inv[i] % mod, a[i] = Read(), sam &= a[i] == 2;
	if (sam)
		return printf("%d\n", 1LL * fac[n - 1] * inv[2] % mod), 0;
	f[0][0][0] = 1;
	for (int i = 0; i < n; i ++)
		for (int j = 0; j <= i; j ++)
			for (int k = 0; k <= n; k ++)
				if (f[i][j][k])
				{
					f[i + 1][j][k] = (f[i + 1][j][k] + f[i][j][k]) % mod;
					if (a[i + 1] >= 2)
						f[i + 1][j + 1][k + a[i + 1] - 2] = (1LL * (a[i + 1] - 1) * f[i][j][k] + f[i + 1][j + 1][k + a[i + 1] - 2]) % mod;
				}
	int ans = 0, cur = 1;
	for (int i = 1; i <= n; i ++)
		cur = 1LL * cur * inv[a[i] - 1] % mod;
	for (int i = 3; i < n; i ++)
		for (int j = 1; j <= n; j ++)
			if (f[n][i][j])
				ans = (1LL * j * fac[i - 1] % mod * f[n][i][j] % mod * fac[n - i - 1] % mod * inv[2] % mod * cur + ans) % mod;
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 108800
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    long long int a[100];
    a[0]=2;
    a[1]=1;
    cin>>n;
    for(i=2;i<=n;i++)
        a[i]=a[i-1]+a[i-2];
    printf("%lld",a[n]);
    return 0;


}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr bool chmax(T& m, U x) {
	if(m < x) {
		m = x;
		return true;
	}
	return false;
}

template <typename T, typename U>
constexpr bool chmin(T& m, U x) {
	if(m > x) {
		m = x;
		return true;
	}
	return false;
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	string s, t;
	cin >> s;
	cin >> t;
	int n, m;
	n = s.size();
	m = t.size();
	VI2D dp(n, VI(m, 0));
	vector<vector<pair<int, int>>> prev(
		n, vector<pair<int, int>>(m, make_pair(-1, -1)));
	REP(i, n) {
		REP(j, m) {
			if(s[i] == t[j]) {
				dp[i][j] = ((i > 0 && j > 0) ? dp[i - 1][j - 1] : 0) + 1;
				prev[i][j] = make_pair(i - 1, j - 1);
				continue;
			}

			REP(k, 2) {
				if(i + dy[k] < 0 || j + dx[k] < 0) {
					continue;
				}
				if(chmax(dp[i][j], dp[i + dy[k]][j + dx[k]])) {
					prev[i][j] = make_pair(i + dy[k], j + dx[k]);
				}
			}
		}
	}

	int i = n - 1;
	int j = m - 1;
	string result = "";
	while(i >= 0 && j >= 0) {
		auto p = prev[i][j];
		if(s[i] == t[j]) {
			result = s[i] + move(result);
		}
		i = p.first;
		j = p.second;
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 109048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000;
typedef int64_t ll;
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	int H, W;
	cin >> H >> W;
	H += 2;
	W += 2;
	GraphC vec(H, vector<char>(W));
	for (int i = 1; i < H-1; i++)
	{
		for (int j = 1; j < W-1; j++)
		{
			cin >> vec.at(i).at(j);
		}
	}
	
	rep(i, H) {
		rep(j, W) {
			if (!(vec.at(i).at(j)>= 'a'&& vec.at(i).at(j)<='z' ))
			{
				vec.at(i).at(j) = '#';
			}
			cout << vec.at(i).at(j);
		}
		cout << endl;
	}
}

Measured memory_bytes: 3644
fun main(args: Array<String>) {
    val (n, a, b, c) = readLine()!!.split(" ").map { it.toInt() }
    val l = (1..n).map { readLine()!!.toInt() }
    println(Dfs(n,a,b,c,l).solve())
}

private class Dfs(val N: Int, val A:Int, val B:Int, val C:Int, val lst: List<Int>){
    val INF = 1000000000
    fun solve(): Int{
        return dfs(0, 0, 0, 0)
    }
    fun dfs(cur: Int, a: Int, b: Int, c:Int) : Int{
        if (cur == N){
            return if (listOf(a,b,c).min()!! > 0){
                Math.abs(a - A) + Math.abs(b - B) + Math.abs(c - C) - 30
            }else{
                INF
            }
        }

        val ret0 = dfs(cur + 1, a, b, c)
        val ret1 = dfs(cur + 1, a + lst[cur], b, c) + 10
        val ret2 = dfs(cur + 1, a, b + lst[cur], c) + 10
        val ret3 = dfs(cur + 1, a, b, c + lst[cur]) + 10
        return listOf(ret0, ret1, ret2, ret3).min()!!
    }
}

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

#define llint long long int

using namespace std;

int main(){
    llint N, K;

    cin >> N >> K;

    if(N % K < abs(N % K - K)){
        cout << N % K << endl;
    }else{
        cout << abs(N % K - K) << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            double a = long.Parse(data[0]);
            double b = long.Parse(data[1]);
            if (a == 1 || b == 1) {
                Console.WriteLine(1);
                return;
            }

            double num = a * b / 2;

            Console.WriteLine((long)Math.Ceiling(num));
            return ;

        }
    }
}


Measured memory_bytes: 27380
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  
  val nums = inputs.head.split(" ").map(_.toInt)

  println(solve(nums))

  def solve(nums: Seq[Int]): Int = {
    (1 to 5).foreach { i =>
      if (nums(i - 1) == 0) {
        return i
      }
    }
    return -1
  }
}

Measured memory_bytes: 54784
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


const int MAX = 2000005;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }

}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

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

    ll H, W, A, B; cin >> H >> W >> A >> B;
    COMinit();

    // (1, 1) -> (H, W)
    ll ans=0;
    for(int i=1; B+i<=W; ++i){
        ans+=COM(H-A-1+B+i-1, H-A-1) * COM(A-1+W-B-i, A-1);
        chmod(ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 47104
import java.util.*;

public class Main {
    int GCD(int a,int b){
		if(b>a){int x=a;a=b;b=x;}
		while (a%b!=0){
			int x=a;
			a=b;b=x%b;
		}
		return b;
	}
	public static void main(String[] args){
	    Scanner sc=new Scanner(System.in);
	    System.out.println(new Main().GCD(sc.nextInt(),sc.nextInt()));
	}
}


Measured memory_bytes: 26288
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;

bool isOK(int new_table[10]){
	int trio = 0;

	for(int k=1; k<=7; k++){
		if(new_table[k] > 2){
			trio++;
			new_table[k] -= 3;
		}

		while(new_table[k] > 0 && new_table[k+1] > 0 && new_table[k+2] > 0){
			trio++;
			new_table[k]--;
			new_table[k+1]--;
			new_table[k+2]--;
		}
	}

	for(int k=1; k <= 9; k++){
		if(new_table[k] == 3){
			trio++;
			new_table[k] -= 3;
		}
	}

	if(trio == 4){
		return true;
	}else{
		return false;
	}

}

int main(){

	char buf[14];
	int table[10];
	bool First;

	while(scanf("%s",buf)!=EOF){
		for(int i=1; i < 10; i++)table[i] = 0;

		for(int i=0; buf[i] != '\0';i++)table[buf[i]-'0']++;

		First = true;
		for(int i=1; i <= 9; i++){
			if(table[i] < 4){
				int new_table[10];
				for(int k=1; k <= 9; k++)new_table[k] = table[k];
				new_table[i]++;

				for(int k=1; k <=9; k++){
					if(new_table[k] >= 2){
						int new_table2[10];
						for(int p=1;p<=9;p++)new_table2[p] = new_table[p];
						new_table2[k] -= 2;
						if(isOK(new_table2)){
							if(First){
								printf("%d",i);
								First = false;
							}else{
								printf(" %d",i);
							}
							break;
						}
					}
				}
			}
		}
		if(First){
			printf("0\n");
		}else{
			printf("\n");
		}

	}

	return 0;
}

Measured memory_bytes: 2596
import itertools
from collections import defaultdict

N=raw_input()
k=len(N)

if int(N)<357:
	print 0
	quit()

ans=0

for k in range(3,k+1):
	L=list(itertools.product( (3,5,7) , repeat=k))

	for t  in L:
		C=defaultdict(lambda: 0)
		v=0

		for idx, x in enumerate(t):
			v+=x*(10**idx)
			if x!=0:
				C[x]+=1
	
		if v<=int(N) and len(C)==3:
			ans+=1

print ans



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

int N=0, K=0, score=0;
double a, ans = 0;

int main(){
  cin >> N >> K;
  // 係数の計算をしておく
  a = 1.0 / N;
  rep(n, N){
    // 0.5が何回掛けられるかを保存しておく変数
    double b = 1.0;
    // 現在のスコアを保存する変数
    // 最初にn+1の目が出たという状況
    score = n+1;
    // すぬけ君が勝つのはscoreがKを上回ったとき
    // それまでwhileを回し続ける
    // 各試行に対してコインが表を出し続ける確率を求めるためにbに0,5をかけていく（2で割っていく）
    while (score < K){
      score *= 2;
      b /= 2;
    }
    // n+1の目が出たときの確率を足しあげていく
    ans += a * b;
  }
  // 出力するときには誤差に注意
  // サンプルでは小数点以下12桁まで出力していたのでそれに習う
  printf("%.12f\n", ans);
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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();}

int main(){
    std::ios::sync_with_stdio(false);
    int count = 0, k;
    string s;
    cin >> s >> k;
    set<string> setstr;
    for(int i=0;i<26;++i)
    {
        char c = 'a' + i;
        string tempstr = "";
        for(size_t j=0;j<s.length();++j)
        {
            if(s[j] == c)
            {
                tempstr = "";
                for(size_t p=0;p<k && (p+j) < s.length();++p)
                {
                    tempstr += s[p+j];
                    setstr.insert(tempstr);
                }
            }
        }
        if(setstr.size() >= k) break;
    }

    set<string>::iterator it = setstr.begin();
    for(int i=1;i<k;++i)
    {
        ++it;
    }
    cout << *it << endl;
}


Measured memory_bytes: 384
using System;

namespace ABC026A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);


            if (a==b && a==c)
                Console.WriteLine("1");
            else if (a==b && a!=c || a==c && a!=b || b==c && b!=a)
                Console.WriteLine("2");
            else
                Console.WriteLine("3");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,ko;
    ll x,y,w,z;
    char hoge,fuga;
    cin>>x>>y>>z;
    x-=z;
    y+=z;
    while(x>=y){
        sum++;
        x-=y;
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+5;

int N,K;
void input(){
    cin>>N>>K;
}

int a[MAX], b[MAX], c[MAX];
void solve(){
    if(N%2==1){
        int h=(N+1)/2;
        if(K>h)cout<<-1;
        else{
            rep(i,N){
                if(i<=N/2){
                    a[i]=K+i*2;
                    b[i]=K+N+(N-1)/2-i;
                }
                else{
                    a[i]=K+i*2-N;
                    b[i]=K+2*N+(N-1)/2-i;
                }
                c[i]=K+2*N+i;
            }
            rep(i,N)cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
        }
    }
    else{
        int h=N/2;
        if(K>h)cout<<-1;
        else{
            rep(i,N){
                if(i<=(N/2)-1){
                    a[i]=K+i*2;
                    b[i]=K+N+N/2-1-i;
                }
                else{
                    a[i]=K+i*2-N+1;
                    b[i]=K+2*N+N/2-1-i;
                }
                c[i]=K+2*N+i;
            }
            rep(i,N)cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
        }
    }
}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 3456
#include <vector>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <queue>
#include <climits>
using namespace std;
const int MAXN = 100005;
const int MOD = (int)1e9 + 7;
char s[MAXN];
int dp[MAXN][4];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'A' || s[i] == '?') {
      for (int j = 0; j < 4; ++j) {
	dp[i + 1][j] += dp[i][j];
	dp[i + 1][j] %= MOD;	
	if (j == 0) {
	  dp[i + 1][j + 1] += dp[i][j];
	  dp[i + 1][j + 1] %= MOD;	  
	}
      }
    }
    if (s[i] == 'B' || s[i] == '?') {
      for (int j = 0; j < 4; ++j) {
	dp[i + 1][j] += dp[i][j];
	dp[i + 1][j] %= MOD;	
	if (j == 1) {
	  dp[i + 1][j + 1] += dp[i][j];
	  dp[i + 1][j + 1] %= MOD;	  
	}
      }
    }
    if (s[i] == 'C' || s[i] == '?') {
      for (int j = 0; j < 4; ++j) {
	dp[i + 1][j] += dp[i][j];
	dp[i + 1][j] %= MOD;
	if (j == 2) {
	  dp[i + 1][j + 1] += dp[i][j];
	  dp[i + 1][j + 1] %= MOD;
	}
      }
    }
  }
  printf("%d\n", dp[n][3]);
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}

int tot[2005][2005];
int find(int x1,int y1,int x2,int y2)
{
    int z=tot[x2][y2]-tot[x1-1][y2]-tot[x2][y1-1]+tot[x1-1][y1-1];
    return z;
}

int n,m;
int pre1[2005][2005],pre2[2005][2005];
int find_row(int x1,int y1,int x2,int y2)
{
    int z=pre1[x2][y2]-pre1[x2][y1]-pre1[x1-1][y2]+pre1[x1-1][y1];
    return z;
}

int find_col(int x1,int y1,int x2,int y2)
{
    int z=pre2[x2][y2]-pre2[x2][y1-1]-pre2[x1][y2]+pre2[x1][y1-1];
    return z;
}

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int q;
    cin>>n>>m>>q;
    string a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]="#"+a[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            tot[i][j]=tot[i][j-1]+a[i][j]-'0';
        }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            tot[i][j]+=tot[i-1][j];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(j>1)
            {
                if(a[i][j-1]-'0'+a[i][j]-'0'==2)
                {
                    pre1[i][j]=pre1[i][j-1]+1;
                }
                else
                    pre1[i][j]=pre1[i][j-1];
            }
            if(i>1)
            {
                if(a[i-1][j]-'0'+a[i][j]-'0'==2)
                {
                    pre2[i][j]=pre2[i-1][j]+1;
                }
                else
                    pre2[i][j]=pre2[i-1][j];
            }
        }
    }

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            pre1[i][j]+=pre1[i-1][j];
            pre2[i][j]+=pre2[i][j-1];
        }
    }

    int x1,y1,x2,y2;
    
    while (q--)
    {
        cin>>x1>>y1>>x2>>y2;
        int val=find(x1,y1,x2,y2)-find_row(x1,y1,x2,y2)-find_col(x1,y1,x2,y2);
        cout<<val<<'\n';
    }
    

} 
    


Measured memory_bytes: 101428
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);i++)

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N, M;

int main() {
    cin >> N >> M;
    if (N == M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <cstdio>


int main() {
    int n, rez = 0, maxx = 0;

    scanf("%d", &n);
    char ch = fgetc(stdin);
    for (int i = 1; i <= n; i++) {
        char ch = fgetc(stdin);
        if (ch == 'I') {
            rez++;
        }
        else {
            rez--;
        }
        if (rez >= maxx)
            maxx = rez;
    }
    printf("%d", maxx);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  long long x, y, z;
  std::vector<long long > sum[8];
  int signx[8]={1, -1, 1, -1, 1, -1, 1, -1};
  int signy[8]={1, 1, -1 , -1, 1, 1, -1, -1};
  int signz[8]={1, 1, 1, 1, -1, -1, -1, -1};
  for (int i=0; i<N; i++){
    scanf("%lld", &x);
    scanf("%lld", &y);
    scanf("%lld", &z);
    for (int j=0; j<8; j++){
      sum[j].push_back(signx[j]*x+signy[j]*y+signz[j]*z);
    }
  }
  for (int j=0; j<8; j++){
    std::sort(sum[j].begin(), sum[j].end(), std::greater<long long>());
  }
    
  long long ans = -1;
  for (int i=0; i<8; i++){
    long long temp=0;
    for (int j=0; j<M; j++){
      temp+=sum[i][j];
    }
    ans = std::max(ans, temp);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

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

  vector<int>s(20);
  auto add = [&](int i){
    bool ok=true;
    rep(j,20){
      if(s[j]+(a[i]>>j&1)>1)ok=false;
    }
    if(ok){
      rep(j,20){
        s[j]+=(a[i]>>j&1);
      }
    }
    return ok;
  };
  auto remove = [&](int i){
    rep(j,20){
      s[j]-=(a[i]>>j&1);
    }
  };

  auto two_p = [&]() {
    long long rec = 0;
    int r = 0;
    for (int l = 0; l < n; l++) {
      while (r < n && add(r)) {
        r++;
      }
      rec += r - l;
      if (r == l) r++;
      else remove(l);
    }
    return rec;
  };

  cout<<two_p()<<endl;

  return(0);
}


Measured memory_bytes: 1024
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True

S = input()
first = is_kaibun(S)
S_s = S[0:len(S) // 2]
second = is_kaibun(S_s)
S_t = S[len(S) // 2 + 1:len(S)]
third = is_kaibun(S_t)
if first and second and third:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <string.h>
#include <cmath>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define max3(A,B,C) max((A),max((B),(C)))

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;

const int INF = 0x3f3f3f3f;
const long long int INFL = 0x3f3f3f3f3f3f3f3f;
const double pi = atan(1.0)*4.0;
const int N = 15;

int pd[1 << N][N];

int main(void) {
   int n, m, adj[N][N], a, b, c;

   scanf("%d %d", &n, &m);

   for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
         adj[i][j] = INF;
      }
   }

   for(int i = 0; i < m; i++) {
      scanf("%d %d %d", &a, &b, &c);
      adj[a][b] = c;
   }

   for(int i = 0; i < 1 << n; i++) {
      for(int j = 0; j < n; j++) {
         pd[i][j] = INF;
      }
   }
   pd[1][0] = 0;

   for(int i = 0; i < 1 << n; i++) {
      for(int j = 0; j < n; j++) {
         if(i & (1 << j)) {
            for(int k = 0; k < n; k++) {
               if(i & (1 << k)) {
                  pd[i][j] = min(pd[i][j], pd[i^(1 << j)][k] + adj[k][j]);
               }
            }
         }
      }
   }

   int ans = INF;
   for(int i = 0; i < n; i++) ans = min(ans, pd[(1 << n)-1][i] + adj[i][0]);
   printf("%d\n", ans == INF ? -1 : ans);

   return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    string t[] = {"P", "W", "G", "Y"};
    int cnt[4] = {0};
    int ans = 0;
    
    rep(i, n) {
        rep(ii, 4) {
            if (s[i] == t[ii]) {
                cnt[ii]++;
            }
        }
    }
    
    rep(i, 4) {
        if (cnt[i]) {
            ans++;
        }
    }
    
    cout << ((ans == 4) ? "Four" : "Three") << endl;
    return 0;
}

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

#define REP(i, x) for (int i = 0, i##_len = (int)(x); i < i##_len; i++)
#define REP1(i, x) for (int i = 1, i##_len = (int)(x); i <= i##_len; i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREP1(i, x) for (int i = ((int)(x)); i > 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 + 9;
using ll = long long;
using i_i = pair<int, int>;
using l_l = pair<ll, ll>;
using d_d = pair<double, double>;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    int N, W;
    cin >> N >> W;
    vint w(N + 1), v(N + 1);
    REP1(i, N) {
        cin >> w[i] >> v[i];
    }
    vvll dp(N + 1, vll(W + 1));
    //配る
    REP1(i, N) {
        REP(j, W + 1) {
            chmax(dp[i][j], dp[i - 1][j]);
            if (j + w[i] <= W)
                chmax(dp[i][j + w[i]], dp[i - 1][j] + v[i]);
        }
    }
    cout << dp[N][W];
}

Measured memory_bytes: 80256
let rec sum lst = match lst with
  | [] -> 0.
  | head :: tail -> head +. sum tail
let () =
  let n = Scanf.scanf "%d\n" (fun x -> x) in
  let lst = Array.to_list
      (Array.init n (fun _ -> Scanf.scanf "%f %s\n" (fun x u -> if u = "JPY" then x else x *. 380000.))) in
  Printf.printf "%f\n" (sum lst)


Measured memory_bytes: 384
S = input()
odd_ = []
even_ = []
for i in range(len(S)):
  if i % 2 == 0:
    odd_.append(int(S[i]))
  else:
    even_.append(int(S[i]))
print(
  min(
  odd_.count(0)+even_.count(1),
  even_.count(0)+odd_.count(1)
  )
)

Measured memory_bytes: 4052
import sys
from collections import Counter

s = input()
f = 10 * int(s[0]) + int(s[1])
l = 10 * int(s[2]) + int(s[3])
f_flg = 0
l_flg = 0

if 1 <= f <= 12:
    f_flg = 1

if 1 <= l <= 12:
    l_flg = 1

#print(f_flg, l_flg)
if f_flg == l_flg == 1:
    print('AMBIGUOUS')
elif f_flg == 0 and l_flg == 1:
    print('YYMM')
elif f_flg == 1 and l_flg == 0:
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 3316
// 問題文
// 正整数
// A
// ,
// B
//  が与えられます。
//
// A
//  が
// B
//  の約数なら
// A
// +
// B
//  を、そうでなければ
// B
// −
// A
//  を出力してください。

package main

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

var sc = bufio.NewScanner(os.Stdin)

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	var str string
	if sc.Scan() {
		str = sc.Text()
	}

	aaa := strings.Split(str, " ")

	a, _ := strconv.Atoi(aaa[0])
	b, _ := strconv.Atoi(aaa[1])

	if b%a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)

	}

}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader s = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    private static int[] rai(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        return arr;
    }

    private static int[][] rai(int n, int m) {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextInt();
            }
        }
        return arr;
    }

    private static long[] ral(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextLong();
        }
        return arr;
    }

    private static long[][] ral(int n, int m) {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextLong();
            }
        }
        return arr;
    }

    private static int ri() {
        return s.nextInt();
    }

    private static long rl() {
        return s.nextLong();
    }

    private static String rs() {
        return s.next();
    }
    static int gcd(int a,int b)
    {
        if(b==0)
        {
            return a;
        }
        return gcd(b,a%b);
    }

    public static void main(String[] args) {
        StringBuilder ans = new StringBuilder();
//        int t = ri();
        int t=1;
        while (t-- > 0) {
            int n=ri();
            int[] arr=rai(n);
            int count=0;
            for(int i=0;i<n;i++)
            {
                if(arr[i]%2==1 && i%2==0)
                {
                    count++;
                }
            }
            ans.append(count).append("\n");
        }
        out.print(ans.toString());
        out.flush();

    }

}


Measured memory_bytes: 25348
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using ll = long long;

using namespace std;

void print2(ll a , ll b){cout << a << " : " << b << endl;}
void print3(ll a , ll b , ll c){cout << a << " : " << b << " : " << c << endl;}

const ll mod = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	
	map<int,int> mp;
	for(int i = n; i >= 2; i--){
		int x = i;
		for(int j = 2; j*j <= x; j++){
			if(x%j == 0){
				while(x%j == 0){
					x /= j;
					mp[j]++;
				}
			}
		}
		if(x > 1)mp[x]++;	
	}
	ll ans = 1;
	for(auto p : mp){
		ans *= (p.second + 1);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}
 


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;

int n;

void call(int n){
	int i = 1;
CHECK_NUM:
	int x = i;
	if (x % 3 == 0){
		cout << " " << i;
		goto END_CHECK_NUM;
	}
INCLUDE3:
	if (x % 10 == 3){
		cout << " " << i;
		goto END_CHECK_NUM;
	}
	x /= 10;
	if (x) goto INCLUDE3;
END_CHECK_NUM:
	if (++i <= n) goto CHECK_NUM;

	cout << endl;
}

int main(){

	cin >> n;

	call(n);

	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int main(void)
{
  int A,B,C,N=IN(),Q,num[100000]={0};
  static long long sum=0;
  while(N--){A=IN();num[A-1]++;sum+=A;}
  Q=IN();
  while(Q--)
  {
    B=IN()-1;C=IN()-1;
    sum+=1ll*num[B]*(C-B);
    num[C]+=num[B];num[B]=0;
    printf("%lld\n",sum);
  }
}

Measured memory_bytes: 1984
//odds in oddness
#include <bits/stdc++.h>
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pi pair<int,int> 
#define mod 1000000007
#include<stdio.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	vector< pair< int ,int > > v(n);
	for(i=0;i<n;i++)
	{
		cin>>v[i].f;
		v[i].s=i+1;
	}
	sort(v.begin(),v.end());
	for(i=0;i<n;i++)
	{
		cout<<v[i].s<<" ";
	}
}

Measured memory_bytes: 1536
#include <queue>
#include<set>
#include<vector>
#include<list>
#include<deque>
#include<map>
#include <stack>
#include<algorithm>
#include<iterator>
#include<iostream>
#include<string>

using namespace std;

int main() {
    queue<int> v[1005];
    int n,q;
    cin>>n>>q;
    int a,b,c;
    while(q--){
        cin>>a;
        if(a==0){
            cin>>b>>c;
            v[b].push(c);
        }
        else if(a==1){
            cin>>b;
            if(!v[b].empty()) cout<<v[b].front()<<endl;
        }
        else{
            cin>>b;
            if(!v[b].empty()) v[b].pop();
        }
    }
    return 0;
}




Measured memory_bytes: 4248
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

#include<bits/stdc++.h>
using namespace std;
#define ll long long int

#define pb push_back
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
string temp=" ";
ll dp[3010][3010];
string s,tt,ans="";
ll ii,jj;
//vector<ll> dp(100000100,110);
ll LCS(ll i, ll j)
{

    if(i>ii || j>jj)
    {
        return 0;
    }
   else
    {
        //cout<<i<<" "<<j<<endl;
        if(dp[i][j]!=-1)
        {
            //cout<<"Hello"<<i<<" "<<j<<endl;
            return dp[i][j];
        }
        else
        {

            if(s[i]==tt[j])
            {

                dp[i][j] = 1+LCS(i+1,j+1);
                return dp[i][j];
            }
            else
            {
                dp[i][j] = max(LCS(i+1,j),LCS(i,j+1));
                return dp[i][j];
            }

        }
    }

}

int main( )
{
    fio;

	cin>>s>>tt;
	 ii=s.size()-1;
	 jj=tt.size()-1;
	 memset(dp,-1,sizeof(dp));

//	ll jj;
    //cout<<v.size()<<endl;
    LCS(0,0);
    //ll maxi = 0;
    ll i=0,j=0;
    while(i<=ii && j<=jj)
    {
        if(s[i]==tt[j])
        {
            ans+=s[i];
            i++;
            j++;
        }
        else
        {
            if(dp[i][j] == dp[i+1][j])
            {
                i++;
            }
            else
            {
                j++;
            }
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    //cout<<endl;

    return 0;
}




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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

  array<bool, 102> vis{};
  int x, n; cin >> x >> n;
  while (n--) {
    int p; cin >> p;
    vis[p] = true;
  }

  pair<int, int> ans{static_cast<int>(1e9), -1};
  for (int i = 0; i < sz(vis); ++i) {
    if (vis[i]) {
      continue ;
    }

    asMn(ans, {abs(x - i), i});
  }

  cout << ans.second << '\n';

  return 0;
}

Measured memory_bytes: 3668
#include <iostream>

using namespace std;

typedef long long ll;

int main(){
    ll A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    if(A1 + A2 + A3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}


Measured memory_bytes: 256
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
A.reverse()
B.sort()
B.reverse()
C.sort()
C.reverse()

anslist = []

for i in range(X):
	for j in range(Y):
		for k in range(Z):
			if (i+1)*(j+1)*(k+1) <= K:
				anslist.append(A[i] + B[j] + C[k])
			else:
				break

anslist.sort()
anslist.reverse()
for hoge in range(K):
	print (anslist[hoge])

Measured memory_bytes: 8708
#include<iostream>
#include<fstream>
#include<algorithm>

using namespace std;
int n,h,d=-100;
char a[110];
int main()
{
     cin>>n;
     for(int i=1;i<=n;i++)
     {
     	cin>>a[i];
     	if(a[i]=='I')h++;
     	if(h>d)d=h;
     	if(a[i]=='D')h--;
     	if(h>d)d=h;
     }
     if(h>d)d=h;
     cout<<d<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

vector<int> alp_cnt(string &x) {
    vector<int> ans(26);
    for (int i = 0; i < x.size(); i++) {
        int a = x[i] - 'a';
        ans[a]++;
    }
    return ans;
}

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

    string s, t;
    cin >> s >> t;
    map<char, char> sm, tm;
    auto no = []() {
        print("No");
        exit(0);
    };
    REP(i, s.size()) {
        char a = s[i];
        char b = t[i];
        if (sm.count(a) && sm[a] != b)
            no();
        if (tm.count(b) && tm[b] != a)
            no();
        sm[a] = b;
        tm[b] = a;
    }
    print("Yes");

    return 0;
}

Measured memory_bytes: 916