akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc122/tasks/abc122_d

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <regex>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }
map<string, ll> mp;
static regex re(".*(A(.?GC|G.?C|CG)|GAC)");
// 文字列長、今までの文字列
ll rec(int n, string s) {
    bool result = regex_match(s, re);
    if (result) {
        return 0;
    }
    if (n == 0) {
        // cout << s << endl;
        return 1;
    }
    ll ret = 0;
    //末尾から3桁の文字列 + ":" + 残り文字数
    int pos = max(0, (int)s.length() - 3);
    string ends = s.substr(pos) + ":" + to_string(n);
    if (mp.count(ends) == 0) {
        ret = rec(n - 1, s + "A") + rec(n - 1, s + "G") + rec(n - 1, s + "C") +
              rec(n - 1, s + "T");
        ret = ret % MOD;
        mp[ends] = ret;
    } else {
        ret = mp[ends];
    }
    return ret;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;

    cout << rec(n, "") << endl;

    return 0;
}


Measured memory_bytes: 1024
# ABC082 B - Two Anagrams
S = input()
T = input()

LS = [s for s in S]
LT = [t for t in T]

LS.sort()
LT.sort(reverse=True)
SS = ''
TT = ''

for ls in LS:
    SS += ls
for lt in LT:
    TT += lt
ans = []

ans.append(SS)
ans.append(TT)

ans.sort()

if SS == TT:
    print('No')
    exit()

print('Yes' if ans[1] == TT else 'No')



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
  

int task = 1;
const int mxN = 2e5 + 1;
const ll mod=1000000007;

const ll modi = 998244353; 



void solve(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(ceil(c*1.0/b)>ceil(a*1.0/d)){
    cout << "No" << endl;return;
  }
  cout << "Yes" << endl;

}
 
 
int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output1.txt","w",stdout);
    #endif
    // int t;cin >> t;while(t--)
        // cout << "Case #" << task << ": " ;
        solve();
        // task++;
    // }

}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int sum=0;
		
		for(int i=0; i<n; i++){
			if(i<k){
				sum+=x;
			}
			else{
				sum+=y;
			}
		}
		System.out.println(sum);

	}

}


Measured memory_bytes: 9684
#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 int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;  
typedef unsigned long long ull;         
typedef vector < pii > vpii;                                   	
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;
 
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

 
const int inf = 1e9, maxn = 1e5 + 48, mod = 998244353, N = 2e5 + 12;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 300;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const ldb eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;

                                                     
int n, b[N], p2[N], p5[N], ans, m;
map < pii, int > cnt;
char s[20];

int toInt () {
	int ans = 0;
	for (int i = 0; i < m; ++i) {
		if (s[i] == '.')
			continue;
		ans *= 10;
		ans += s[i] - '0';
	}

	return ans;
}

main () {
	scanf("%lld", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("\n%s", s);
		m = strlen(s);
		for (int j = 0; j < m; ++j) 
			if (s[j] == '.') {
				p2[i] = -(m - 1 - j);
				p5[i] = -(m - 1 - j);
			}
		

		b[i] = toInt();

		while (!(b[i] % 2)) {
			++p2[i];
			b[i] /= 2;
		}

		while (!(b[i] % 5)){
			++p5[i];
			b[i] /= 5;
		}

		for (int x = -25; x <= 25; ++x)
			for (int y = -15; y <= 15; ++y)
				if (x + p2[i] >= 0 && y + p5[i] >= 0 && cnt.count(mp(x, y))) 
					ans += cnt[mp(x, y)];
				
					
		++cnt[mp(p2[i], p5[i])];
	}
	cout << ans;
}



Measured memory_bytes: 8356
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

ll invmod(ll a, ll p)
{ // a^-1 mod p
    ll b = p, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= p;
    if (u < 0)
        u += p;
    return u;
}
ll cmb(ll n, ll k)
{
    ll tmp = 1;
    REP(i, k)
    {
        tmp = tmp * n;
        n--;
        tmp %= MOD;
        tmp = tmp * invmod(k - i, MOD) % MOD;
    }
    return tmp;
}

int main()
{
    int s;
    cin >> s;
    if(s<3){
        cout << 0 << endl;
        return 0;
    }
    ll ans=0;
    int count=s/3;
    while(count>=1){
        ans+=cmb(count-1+s-count*3,count-1);
        ans%=MOD;
        count--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=1000005;
int nxt;
bool is_end[N];
int child[N][26];

int main() {
	int n;
	cin>>n;
	vector<string>v;
	nxt=1;
	vector<vector<int>>paths;
	paths.resize(n);
	for(int i=0; i<n; i++){
		string s;
		cin>>s;
		v.pb(s);
	
		int node=0;
		reverse(s.begin(), s.end());
		for(char ch:s){
			
			paths[i].pb(node);
			if(child[node][ch-'a']==0){
			
				child[node][ch-'a']=nxt;
				nxt++;
			}
			node=child[node][ch-'a'];
		}
		is_end[node]=1;
	}
	
	int ans=0;
	for(int i=0; i<n; i++){
		string s=v[i];
		set<int>suf;
		for(int j=s.size()-1; j>=0; j--){
			suf.insert(s[s.size()-j-1]-'a');
			int node=paths[i][j];
			
			for(auto ch:suf){
				ans+=is_end[child[node][ch]];
				
			}
		}
	}
	cout<<ans-n;
	return 0;
}

Measured memory_bytes: 112316
N, K, C = map(int, input().split())
S = input()
left = []
right = []
i, j = 0, N-1
while len(left) <= K-1:
    if S[i] == "o":
        left.append(i)
        i += C+1
    else:
        i += 1
while len(right) <= K-1:
    if S[j] == "o":
        right.append(j)
        j -= C+1
    else:
        j -= 1
right.sort()
for n in range(K):
    if left[n] == right[n]:
        print(left[n] + 1)


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

class Radix
{
private:
  const char *s;
  int a[128];

public:
  Radix(const char *s = "-abcdefghijklmnopqrstuvwxyz") : s(s)
  {
    int i;
    for (i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q)
  {
    int i;
    if (!p)
      return "-";
    char t[64] = {};
    bool first = false;
    for (i = 62; p; --i)
    {
      ll num = first ? (p % q) - 1 : p % q;
      t[i] = s[num];
      if (num == -1)
        t[i] = 'z';
      first = true;
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string &t, int p, int q)
  {
    return to(to(t, p), q);
  }
  long long to(const std::string &t, int p)
  {
    int i;
    long long sm = a[(int)t[0]];
    for (i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

int main()
{
  ll n;
  cin >> n;
  vector<ll> as(n);
  rep(i, n) cin >> as[i];
  ll q;
  cin >> q;
  vector<ll> bs(q);
  vector<ll> cs(q);

  rep(i, q) cin >> bs[i] >> cs[i];

  map<ll, ll> m;
  rep(i, n)
  {
    ll a = as[i];
    if (m.count(a))
    {
      m[a]++;
    }
    else
    {
      m[a] = 1;
    }
  }

  ll sum = 0;
  rep(i, n)
  {
    sum += as[i];
  }

  vector<ll> ans(q);
  rep(i, q)
  {

    ll dif = cs[i] - bs[i];
    ll cnt = m[bs[i]];

    sum += dif * cnt;
    ans[i] = sum;

    ll moveCnt = m[bs[i]];
    m[bs[i]] = 0;
    m[cs[i]] += moveCnt;
  }

  rep(i, q)
  {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 12236
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int mod=1000000007;
		String s=in.next();
		int[][] dp=new int[n][n];
		int[] sum=new int[n];
		dp[0][0]=1;
		for (int i=1;i<n;++i) if (s.charAt(i-1)=='<') {
			for (int j=0;j<=i;++j) {
				sum[j]=dp[i-1][j];
				if (j>0) sum[j]+=sum[j-1];
				if (sum[j]>=mod) sum[j]-=mod;
			}
			for (int j=1;j<=i;++j) dp[i][j]=sum[j-1];
		} else {
			for (int j=i;j>=0;--j) {
				sum[j]=dp[i-1][j];
				if (j+1<n) sum[j]+=sum[j+1];
				if (sum[j]>=mod) sum[j]-=mod;
			}
			for (int j=0;j<=i;++j) dp[i][j]=sum[j];
		}
		int res=0;
		for (int i=0;i<n;++i) {
			res+=dp[n-1][i];
			if (res>=mod) res-=mod;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 81988
n = gets.to_i
commands = []
n.times {commands << gets.chomp.split}
list = []

commands.each do |co|
  case co[0]
  when "insert"
    list.unshift(co[1])
  when "delete"
    i = list.index(co[1])
    list.delete_at(i) if i
  when "deleteFirst"
    list.shift
  when "deleteLast"
    list.pop
  end
end
puts list.join(" ")



Measured memory_bytes: 310916
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k, a, b;
	scanf("%d %d %d", &k, &a, &b);
	for(int i=a; i<=b; i++){
		if(i%k==0){
			printf("OK");
			return 0;
		}
	}
	printf("NG");
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for(ll i = 0; i < (n); i++)
#define fori(i, b, e) for(ll i = (b); i < (e); i++)
#define forr(i, b, e) for(ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll r;
    cin >> r;
    cout << (3 * r * r) << endl;
    return 0;
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int D, N;
    cin >> D >> N;
    int ans= pow(100, D) * N;
    if (N == 100)
        ans += pow(100, D);
    cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String w = scan.nextLine();
		char[] c = w.toCharArray();
		int[] count =new int[c.length];
		String show =null;
		for(int i=0;i<c.length;i++) {
			for (int m=0;m<c.length;m++) {
				if(c[i]==c[m]) {
					count[i]++;
				}
			}

		}
		for(int i=0;i<c.length;i++) {
			if(count[i]%2!=0) {
				show ="No";
				break;
			}else {
				show="Yes";
			}
		}
		//System.out.println(count[0]);
		System.out.println(show);

	}

}


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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a < c) {
    cout << (c < b ? "Yes" : "No") << endl;
  } else {
    cout << (b < c ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i, r, z, n, m, l;
    long x[101][101] = {}, y[101][101] = {}, c[101][101] = {};

    scanf("%d %d %d", &n, &m, &l);
    for( i = 0; i < n; i++ ){
        for( r = 0; r < m; r++ ){
            scanf("%d", &x[i][r]);
        }
    }
    for( i = 0; i < m; i++ ){
        for( r = 0; r < l; r++ ){
            scanf("%d", &y[i][r]);
        }
    }
    for( i = 0; i < n; i++ ){
        for( r = 0; r < l; r++ ){
            for( z = 0; z < m; z++ ){
                c[i][r] += x[i][z] * y[z][r];
            }
            if( r == l - 1 ){
                printf("%ld", c[i][r]);
            }else{
            printf("%ld ", c[i][r]);
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 852
z['   '],i;
main(j){
	for(;++i<2e3;)
		for(j=z[i>>5]&1<<i?1e7:-2*i*~i;j<5e6;j+=i-~i)z[j>>5]|=1<<j;
	for(;~scanf("%d",&i);)
		for(j=-~i/2;i;)
			z[--j>>5]&1<<j|
			z[j-1>>5]&1<<j-1|
			z[j-3>>5]&1<<j-3|
			z[j-4>>5]&1<<j-4||printf("%d\n",j*2+1,i=0);
}

Measured memory_bytes: 1016
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int size=s1.size()*3,len=s1.size();
    string s=s1+s1+s1;
    int flag;
    if(s1==s2) flag=1;
    else flag=0;
    for(int i=0;i<size;++i)
    {
    	string temp=s.substr(i,len);
    	if(temp==s2){
    		flag=1;break;
		}
	}
    printf("%s\n",flag?"Yes":"No");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int n, m;
	cin >> n >> m;

	int l, r, lmax = 0, rmin = n;
	rep(i, 0, m) {
		cin >> l >> r;
		lmax = max(l, lmax);
		rmin = min(r, rmin);
	}

	int ans = rmin - lmax + 1;
	if (ans < 0) ans = 0;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
n = gets.to_i
b = gets.split.map(&:to_i)

min = 0

-100.step(100){ |i|
	sum = 0
	
	n.times do |e|
		sum += ( b[e] - i ) ** 2
	end
	if i == -100
		min = sum
	elsif sum < min
		min = sum
	end
}

if b.uniq.count == 1
	puts 0
else
	puts min
end

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

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

    int N;
    int64 A, B, C;
    cin >> N >> A >> B >> C;

    int64 num[3] = {A, B, C};

    vector<string> s(N);
    for (int i = 0; i < N; i++) {
        cin >> s[i];
    }

    vector<string> answers(N, " ");

    auto operate = [&](int i, int add, int sub) {
        answers[i][0] = 'A' + add;
        num[add]++;
        num[sub]--;
    };

    for (int i = 0; i < N; i++) {
        int x = s[i][0] - 'A',
            y = s[i][1] - 'A';
        if (num[x] == 1 && num[y] == 1) {
            if (i + 1 >= N) {
                operate(i, x, y);
                continue;
            }

            int nx = s[i + 1][0] - 'A',
                ny = s[i + 1][1] - 'A';
            if (x == nx || x == ny) {
                operate(i, x, y);
            } else {
                operate(i, y, x);
            }
        } else if (num[x] <= num[y]) {
            operate(i, x, y);
        } else {
            operate(i, y, x);
        }
        if (num[x] < 0 || num[y] < 0) {
            cout << "No" << endl;
            return 0;
        }
        // cerr << "> " << num[0] << " " << num[1] << " " << num[2] << endl;
    }
    cout << "Yes" << endl;
    for (const auto& ans : answers) {
        cout << ans << endl;
    }

    return 0;
}



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

typedef long long ll;

int main()
{
    int a, b, k;
    cin >> a >> b >> k;

    vector<int> ans;
    for(int i = 1; i <= max(a, b); i++)
    {
        if ((a % i == 0 ) && (b % i == 0)){
            ans.push_back(i);            
        }
    }
    
    sort(ans.begin(), ans.end(), greater<int>());
    cout << ans[k - 1] << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline
MOD = 10**9+7
# @njit
def solve(n,stairs):
  # ～段目と対応
  dp = [1] + [0] * (n+1)
  dp[1] = stairs[1]
  for i in range(n):
    dp[i+2] = (dp[i] + dp[i+1]) * stairs[i+2]
    dp[i+2] %= MOD

  return dp[n]



def main():
  N,M = map(int,input().split())
  stairs = [1]*(N+10)
  for i in range(M):
    stairs[int(input())] = 0
  print(solve(N,stairs))
  return

if __name__ == '__main__':
  main()


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

int main() {
  int N,K,integer=1;
  cin>>N>>K;
  
  for(int i=0;i<N;i++){
 
    if(2*integer<=(K+integer)){
      integer*=2;
      continue;
    }
    
    else if(2*integer>(K+integer)){
      integer+=K;
      continue;
    }
    
  }
  
 cout<<integer<<endl;
  
}


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

int k, n, a, b;
ll t[1 << 17], d[1 << 17];
vector<ll>v;

int main(){
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max((a + b) - n, 0) << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}


void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}


string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}


string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int top, s[1000];
int pop(){
    top--;
    return s[top+1];
}
void push(int a){
    s[++top]=a;
}
int main(){
    int a,b;
    char c[3];
    top=0;
    while(cin>>c){
        if(c[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(c[0]=='-'){
            a=pop();
            b=pop();
            push(b-a);
        }
        else if(c[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else{
            push(atoi(c));
        }
    }
    cout<<pop()<<endl;
    return 0;
    
}


Measured memory_bytes: 3108
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b float64
	fmt.Scan(&a, &b)

	for i := float64(1); i <= 11000; i++ {
		x := math.Floor(i * 0.08)
		y := math.Floor(i * 0.1)
		if x == a && y == b {
			fmt.Println(i)
			return
		}
	}

	fmt.Println(-1)
}


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

using namespace std;

vector<string> path;
int dp[1004][1004];
int mod = 1e9 + 7;
int main(){
	int w, h;
	string a;
	cin>>w>>h;
	for(int x=0;x<w;x++){
		cin>>a;
		path.push_back(a);
	}
	dp[0][0] = 1;
	for(int x= 0;x<w;x++){
		for(int i=0;i<h;i++){
			if(x == 0 && i == 0) continue;
			dp[x][i] = 0;
			if(path[x][i] == '.'){
				if(x-1 >=0) dp[x][i] = dp[x-1][i];
				if(i-1 >= 0 && dp[x][i-1]){
						dp[x][i] += dp[x][i-1]%mod;
						dp[x][i]%=mod;
				}
			}
		}
	}
	cout<<dp[w-1][h-1];
	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;

int main(){
    int a,b;
    cin>>a>>b;
    if(a!=2 && b!=2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}
 
   

Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

import bisect
n = inn()
a = inl()
done = [False]*n
ofs = [0]*n
cnt = 0
a.sort()
for i in range(n-1,0,-1):
    if done[i]:
        continue
    for j in range(32):
        if 2**j>a[i]:
            break
    x = 2**j-a[i]
    j = bisect.bisect_left(a,x)
    if j>=i:
        continue
    k = j+ofs[j]
    if k<i and a[k]==x:
        done[k] = done[i] = True
        ofs[j] += 1
        cnt += 1
print(cnt)


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] AB = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = AB[0];
            int B = AB[1];
            int ans = 0;
            if (A <= B * 2)
            {
                ans = 0;
            }
            else
            {
                ans = A - B * 2;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int A, B;
    cin >> A >> B;
    int res = max(A + B, A - B);
    res = max(res, A * B);
    cout << res << endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

int divisors(int n)
{
    vi d(n, 0);
    int N = n;
    for(int i = 2; i * i <= N; i++)
    {
        while(n % i == 0)
        {
            d[i]++;
            n /= i;
        }
    }
    int res = 1;
    for(int i = 2; i * i <= N; i++)
    {
        res *= (d[i] + 1);
    }
    return res;
}

void solve()
{
    int N; cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i += 2)
    {
        if(divisors(i) == 8) ans++;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int main(){
    long long n, m;
    std::cin >> n >> m;
    std::vector<long long> div;
    long long p = 1;
    while(m >= p * p && (p*n) <= m){
        if(!(m % p)){
            div.push_back(p);
            if(n <= p) div.push_back(m/p);
        }
        p++;
    }
    std::sort(div.begin(), div.end(), std::greater<long long>());
    std::cout << div[0] << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */
int main() {
    int m, D;
    cin >> m >> D;
    int d = 22;
    int count = 0;
    rep1(i, m) {
        for(int d = 22;d <= D;d++) {
            if(d%10 <= 1) continue;
            if((d%10) * (d/10) == i) count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3516
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 1e6 + 10;

int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    ll n, m;cin >> n >> m;

    n = max(1ll, n), m = max(1ll, m);
    cout << ((n) * (n - 1)) / 2 + (m * (m - 1)) / 2;
    return 0;
}
/*!
    Be careful who you share your weaknesses with.
    Some people can't wait for the opportunity to use them against you!!
*/
//! N.N


Measured memory_bytes: 256
X, N = map(int, input().split())
h = list(map(int, input().split()))
ans = []
for i in range(0, N+1):
    if X+i not in h:
        ans.append(X+i)
    if X-i not in h:
        ans.append(X-i)
    if ans != []:
        break
print(min(ans))

Measured memory_bytes: 9160
#include<iostream>
#include<vector>
#define ll long long int

ll mod = 1e9 +7;

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> arr(1001, vector<int>(1001));
    vector<vector<ll>> dp(1001, vector<ll>(1001));
    char ch = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> ch;
            if(ch=='.') arr[i][j]=1;
            else arr[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(!arr[i][j]) dp[i][j]=0;
            else if(i==1 && j==1) dp[i][j]=1;
            else if(i-1>0 && j-1>0){
                dp[i][j] = ( dp[i-1][j] + dp[i][j-1] )%mod; 
            }
            else if(i-1>0){
                dp[i][j] = dp[i-1][j];
            }
            else{
                dp[i][j] = dp[i][j-1];
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 14780
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[210000] = {};
long long int col[210000] = {};

int main(){
	int N;
	cin >> N;
	DP[0] = 1;
	for(int i = 1; i <= N; i++){
		int C;
		cin >> C;
		DP[i] = DP[i - 1];
		if(col[C] != 0 && col[C] != i - 1){
			DP[i] += DP[col[C]];
		}
		DP[i] %= MOD;
		col[C] = i;
	}
	cout << DP[N] << endl;
	return 0;
}

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

using namespace std;

int main(){
  vector<int> vec(3);
  cin >> vec[0] >> vec[1] >> vec[2];
  
  sort(vec.begin(),vec.end());
  
  string res = "";
  res += (char)(vec[2]+'0');
  res += (char)(vec[1]+'0');
  
  int r = stoi(res);
  
  r += vec[0];
  
  cout << r << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int INF = 1 << 30;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int c[N];
    int a[N][M];

    for(int i = 0; i < N; i++) {
        cin >> c[i];
        for(int j = 0; j < M; j++) cin >> a[i][j];
    }

    int ans = INF;
    for(int bit = 0; bit < (1 << N); bit++) {
        int sum = 0;
        vector<int> b(M, 0); //理解度

        for(int i = 0; i < N; i++) {
            if(bit & (1 << i)) {
                sum += c[i];
                for(int j = 0; j < M; j++) {
                    b[j] += a[i][j];
                }
            }
        }

        bool check = true;
        for(int j = 0; j < M; j++) {
            if(b[j] < X) check = false;
        }

        if(check) {
            ans = min(ans, sum);
        }
    }

    if(ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
#include<stdio.h>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
int main()
{

    int t,n,i,r,l,arra[1000];
    string s;
    cin>>t;

        n=t/500;
        r=t%500;
        l=r/5;
        cout<<n*1000+l*5<<endl;
    return 0;
}



Measured memory_bytes: 256
//21171_somesh || asomesh999

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;

template<typename T>
void debug(T arr) {
	for(auto it : arr) {
		cout << it << ' ';
	}
	cout << '\n';
}

int main()
{
	io
	#ifdef CODE
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	int n;
	cin >> n;
	string s;
	cin >> s;
	vl ar, br, cr;
	fr(i, 0, n) {
		if (s[i] == 'R') {
			ar.push_back(i);
		} else if (s[i] == 'G') {
			br.push_back(i);
		} else {
			cr.push_back(i);
		}
	}	
	auto get = [&] (char ch) {
		if (ch == 'R') return 0;
		else if (ch == 'G') return 1;
		else return 2;
 	};
 	// debug(ar);
 	// debug(br);
 	// debug(cr);
 	ll sum = 0;
	fr(i, 0, n) {
		fr(j, i + 1, n) {
			if (s[i] != s[j]) {
				int a = get(s[i]) ^ get(s[j]);
				ll pos = 0;
				if (a == 1) {
					auto it = lower_bound(cr.begin(), cr.end(), j + 1);
					if (it != cr.end()) {
						pos = cr.size() - (it - cr.begin());
					}
					it = lower_bound(cr.begin(), cr.end(), j + j - i);
					if (it != cr.end() && *it == j + j - i) {
						pos--;
					}
				} else if (a == 3) {
					auto it = lower_bound(ar.begin(), ar.end(), j + 1);
					if (it != ar.end()) {
						pos = ar.size() - (it - ar.begin());
					}
					it = lower_bound(ar.begin(), ar.end(), j + j - i);
					if (it != ar.end() && *it == j + j - i) {
						pos--;
					}
				} else {
					auto it = lower_bound(br.begin(), br.end(), j + 1);
					if (it != br.end()) {
						pos = br.size() - (it - br.begin());
					}
					it = lower_bound(br.begin(), br.end(), j + j - i);
					if (it != br.end() && *it == j + j - i) {
						pos--;
					}
				}
				sum += pos;
			}
		}
	}
	cout << sum;

	#ifdef CODE
		cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

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

int64_t a[100010];
int64_t d[100010][2];

int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    d[1][0]=a[0];
    d[1][1]=-a[0];
    for(int i=2;i<n;++i){
        d[i][0]=d[i][1]=-1e18;
        for(int j=0;j<2;++j){
            d[i][0]=max(a[i-1]*(-2*j+1)+d[i-1][j],d[i][0]);
            d[i][1]=max(a[i-1]*(2*j-1)+d[i-1][j],d[i][1]);
        }
    }
    cout<<max(d[n-1][0]+a[n-1],d[n-1][1]-a[n-1])<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N,K;
    cin >> N >> K;

    ll R,S,P;
    cin >> R >> S >> P;

    string t;
    cin >> t;

    map<char,char> win;
    win['r'] = 'p';
    win['s'] = 'r';
    win['p'] = 's';

    map<char,ll> point;
    point['r'] = R;
    point['s'] = S;
    point['p'] = P;



    vector<vector<char>> ans;

    ans.resize(K);
    rep(i,N){
        ans[i%K].PB(win[t[i]]);
    }


    ll ans_point = 0;

    rep(j,K){//j=0,1,,2,...,K-1
        vector<pair<ll,char>> renzoku;
        ll ct = 1;
        if(!sz(ans[j])) continue;
        if(sz(ans[j]) == 1){
            renzoku.PB(MP(1,ans[j][0]));
        }else{
            rep(i,sz(ans[j])-1){
                if(ans[j][i] == ans[j][i+1]){
                    ct++;
                }else{
                    renzoku.PB(MP(ct,ans[j][i]));
                    ct = 1;
                }
            }
            renzoku.PB(MP(ct,ans[j][sz(ans[j])-1]));
        }

        rep(i,sz(renzoku)){
            //cout << point[renzoku[i].second] << ' ' << renzoku[i].first << endl;
            ans_point += point[renzoku[i].second] * ((renzoku[i].first + 1)/2);
        }
    }

    cout << ans_point << endl;

}


Measured memory_bytes: 5200
// OURL: https://atcoder.jp/contests/abc166/tasks/abc166_e
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));  }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v);  }

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", ";  } first = false; res += to_string(x);  } res += "}"; return res;  }

string to_string(string s) { return '"' + s + '"';  }
string to_string(const char* s) { return to_string((string) s);  }
string to_string(bool b) { return (b ? "true" : "false");  }
string to_string(vector<bool>::reference b) { return to_string(bool(b));  }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";  }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res; }

void debug_out() { cerr << endl;  }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...);  }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

  ll n;
  cin >> n;
  auto as = make_v<ll>(n+1);
  auto diff = make_v<int>(n+1);
  // map<ll, ll> diff2;
  for (ll i = 1; i <= n; ++i) {
    cin >> as[i];
    if (i+1 - as[i] >= 0) {
      diff[i+1 - as[i]]++;
    }
  }
  ll ans = 0;
  debug(diff);
  for (ll i = 1; i <= n; ++i) {
    if (as[i] + i+1 <= n) ans += diff[as[i] + i+1];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5584
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int N,M;
	cin>>N>>M;
	cout<<(((N-M)*100)+(M*1900))*pow(2,M)<<endl;
}
	

Measured memory_bytes: 256
function main(arg) {
	arg = arg.trim().split('\n');
  	var v = arg[1].split(' ').map(str => parseInt(str, 10)).sort((a,b) => a-b),
        n = arg[0], out = 0;
  	out = (v[0]+v[1])/2;
  	for (var i = 2; i < n; i++) {
    	out = (out + v[i])/2
    }
	console.log(out);
}

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

Measured memory_bytes: 7500
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>

int main(){

    size_t n, k;
    std::cin >> n >> k;

    std::vector<size_t> h(n);

    for(auto&& e : h){
        std::cin >> e;
    }

    std::sort(h.begin(), h.end());

    if(n <= k){
        std::cout << 0 << std::endl;
    }else{
        std::cout << std::accumulate(h.begin(), h.end() - k, 0ul) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
  char s[200000];
  cin >> s;
  char cs[20000];
  int k = 0,same = 0;
  for(int i = 0;s[i] != '\0';i++)
  {
    if(s[i] == s[i+1])
    {
        if(same)
        {
            k++;
            i++;
            same = 0;
        }
        else
        {
            k++;
            same = 1;
        }
    }
    else
    {
        if(same)
        {
            if(s[i+1] == '\0')break;
            i++;
            k++;
            same = 0;
        }
        else
        {
            k++;
        }
    }
  }
  cout << k << endl;
  return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll N,K;
double f(ll x){
	double ret=1;
	while(x<K){x<<=1;ret/=2;}
	return ret;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	scanf("%lld %lld",&N,&K);
	double ans=(double)max(N+1-K,0ll)/N;
	FOR(i,1,min(K,N+1)){
//		printf("%.12f\n",ans);
		ans+=1.0/N*f(i);
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int a[100][100];
  int n, i, j, k, u, v;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      a[i][j]=0;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d %d", &u, &k);//u...頂点の番号 k...いくつ頂点が隣接してるか

    u--; //a[i][j]のi=u-1
    for(j=0; j<k; j++){
      scanf("%d", &v);
      a[u][v-1]=1;    
    }
  }

  //print
  for(i=0; i<n; i++){
    for(j=0; j<n-1; j++){
      printf("%d ", a[i][j]);
    }
    printf("%d",a[i][n-1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2148
fun main (args:Array<String>){
    val numLen = readLine()!!.toInt()
    val numList = readLine()!!.split(" ").map(String::toInt).toMutableList()

    if(numList == numList.sorted()){
        print("YES")
        return
    }
    for(i in 0..numLen-2){
        for(j in 1..numLen-1){
            numList.swap(i, j)
            if(numList == numList.sorted()){
                print("YES")
                return
            }
            else numList.swap(i, j)
        }
    }
    print("NO")
}

private fun MutableList<Int>.swap(index1: Int, index2: Int) {
    val tmp = this[index1]
    this[index1] = this[index2]
    this[index2] = tmp
}


Measured memory_bytes: 42392
N, M = map(int, input().split())
p = [0]*M
S = [0]*M
for i in range(M):
    l = input().split()
    p[i] = int(l[0])
    S[i] = l[1]
# print(N, M, p, S)
ans = {(x + 1): [0, 0] for x in range(N)}
# print(ans)
for i in range(M):
    a = p[i]
    b = S[i]
    if b == 'AC':
        ans[a][0] += 1
    else:
        if ans[a][0] == 0:
            ans[a][1] += 1
# print(ans)
ac = 0
wa = 0
for i in range(1, N + 1):
    if ans[i][0] > 0:
        ac += 1
        wa += ans[i][1]

print(ac, wa)


Measured memory_bytes: 72016
S=str(input())

a='SUN'
b='MON'
c='TUE'
d='WED'
e='THU'
f='FRI'
g='SAT'

if S==a:
    print(7)

elif S==b:
    print(6)

elif S==c:
    print(5)

elif S==d:
    print(4)

elif S==e:
    print(3)

elif S==f:
    print(2)

elif S==g:
    print(1)

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

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);
            int[] b = in.nextIntArray(n);
            long sum = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] > b[i]) {
                    sum += a[i] - b[i];
                } else {
                    sum -= (b[i] - a[i]) / 2;
                }
            }
            out.println(sum > 0 ? "No" : "Yes");
        }

    }

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

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

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

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

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 26064
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
ll dp[100001];
int main(){
    ll n,w,a,b;
    cin>>n>>w;
    while(n--){
        cin>>a>>b;
        for(int i=w;i>a;i--){
            if(dp[i-a]) dp[i]=max(dp[i],dp[i-a]+b);
        }
        dp[a]=max(dp[a],b);
    }
    ll ans=0;
    for(int i=0;i<=w;i++) ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [m, d] = li()
    seki = 0
    for mi in range(1, m + 1):
        for di in range(1, d + 1):
            d10 = di // 10
            d1 = di % 10
            if mi == d1 * d10 and d1 >= 2 and d10 >= 2:
                seki = seki + 1
                # print(mi, di)
    print(seki)


Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i = (s); i < (e); i++)
#define FOE(i,s,e) for(int i = (s); i <= (e); i++)
#define FOD(i,s,e) for(int i = (s); i >= (e); i--)
#define ll long long
#define pb push_back
#define mp make_pair

int n, m, x, y, z, k, w;

int a, b, t;

int main ()
{
	a = b = t = 0;
	scanf("%d", &n);
	FOR(i, 0, n)
	{	
		scanf("%d %d %d", &z, &x, &y);
		k = abs(a - x) + abs(b - y);
		
		if (t + k > z) { printf("No\n"); return 0; }
		if (k % 2 != (z - t) % 2) { printf("No\n"); return 0; }
		
		a = x;
		b = y;
		t = z;
	}
	
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String base;
		String comparison;
		
		try {
			base = br.readLine();
			comparison = br.readLine();
			
			Inversions(base, comparison, br);
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}

	public static void Inversions(String base, String comparison,  BufferedReader br){ 
		StringBuilder sb = new StringBuilder();
		int length = base.length() - comparison.length();
		String 	container;
		int ans_num = 0;
		int[] ans = new int[1000000];
		
		for(int i = 0; i <= length ; i ++ ) {
			container = base.substring( i, i + comparison.length() );
			if( container.equals(comparison) ) {
				ans[ans_num] = i;
				ans_num ++;
			}
		}
		
		for(int i = 0; i <ans_num; i++){
            //System.out.println(start + i);
            sb.append(ans[i] + "\n");
        }
         
        System.out.print(sb);
		
	}
}


Measured memory_bytes: 28408