akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10); x/=10;} reverse(all(res)); return res;}

void solve_A() {
  int n,r;
  cin>>n>>r;
  if(n<10) out(r+100*(10-n));
  else out(r);
}
void solve_B() {
  int n,k,ans=0;
  cin>>n>>k;
  while(n>0){
    n/=k;
    ans++;
  }
  out(ans);
}
void solve_C() {
  int n,ans=INF;
  cin>>n;
  vi x(n);
  rep(i,n) cin>>x[i];
  sort(all(x));
  REP(a,x[0],x[n-1]+1){
    int p=0;
    rep(i,n) p+=(a-x[i])*(a-x[i]);
    chmin(ans,p);
  }
  out(ans);
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int first, second, third, point;

int main(){
  int n;
  string input;
  int out;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    first = second = third = out = point = 0;
    out = 0;
    while(out < 3)
    {
      cin >> input;
      if(input == "OUT")
      {
        out++;
        continue;
      }
      else if(input == "HIT")
      {
        point += third;
        third = second;
        second = first;
        first = 1;
        continue;
      }
      else if(input == "HOMERUN")
      {
        point += first + second + third + 1;
        first = second = third = 0;
        continue;
      }
    }
    cout << point << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
K=int(input())
S=input()
mod=10**9+7
def inv(x):
    return pow(x,mod-2,mod)
N=len(S)
ans=0
tmp1=1
tmp2=1
for i in range(0,K+1):
    ans=ans+(tmp1*tmp2)
    ans%=mod
    tmp1=tmp1*25
    tmp1%=mod
    tmp2=tmp2*(inv(i+1)*(N+K-i))
    tmp2%=mod
    #print(tmp1,tmp2)
print(ans)

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int d[31][31];
int c[501][501];
int col[3][30];

int main() {
    int N, C;
    cin >> N >> C;
    rep(i, C) rep(j, C) cin >> d[i][j];
    rep(i, N) rep(j, N) {
        cin >> c[i][j];
        c[i][j]--;
    }
    rep(i, N) rep(j, N) {
        col[(i+j)%3][c[i][j]] += 1;
    }
    int ans = 1e9;
    rep(c1, C) rep(c2, C) rep(c3, C) {
        if (c1 == c2 or c1 == c3 or c2 == c3) continue;
        int tmp = 0;
        for (int i=0; i<C; ++i) {
            tmp += d[i][c1] * col[0][i] + d[i][c2] * col[1][i] + d[i][c3] * col[2][i];
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
#include <iostream>

int main(){
    std::string o, e;
    std::cin >> o >> e;

    std::string str = "";
    for(int i = 0; i < o.size(); ++i){
        if(i == e.size()){
            str += o.at(i);
        }else{
            str += o.at(i);
            str += e.at(i);
        }
    }

    std::cout << str << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 300005
using namespace std;
int x,y,a,b,c,nx,ny,cnt;
long long ans;
struct node{int cl,val;}p[N];
bool cmp(const node &a,const node &b){return a.val>b.val;}
int main(){
    cin>>x>>y>>a>>b>>c;
    for(int i=1;i<=a;i++)cin>>p[i].val,p[i].cl=1;
    for(int i=a+1;i<=a+b;i++)cin>>p[i].val,p[i].cl=2;
    for(int i=a+b+1;i<=a+b+c;i++)cin>>p[i].val,p[i].cl=3;
    sort(p+1,p+1+a+b+c,cmp);
    for(int i=1;i<=a+b+c;i++){
        if(p[i].cl==1){
            if(nx==x)continue;
            nx++;
        }else if(p[i].cl==2){
            if(ny==y)continue;
            ny++;
        }
        cnt++;
        ans+=p[i].val;
        if(cnt==x+y)break;
    }
    cout<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 5984
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj0025/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/xxxyyyy/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()) {
		int[] a = new int[4], b = new int[4];
		for(int i = 0; i < 4; i++) a[i] = sc.nextInt();
		for(int i = 0; i < 4; i++) b[i] = sc.nextInt();
		int hit = 0, blow = 0;
			for (int i = 0; i < 4; i++) {
				if (a[i] == b[i])
					hit++;
				else {
					for(int j = 0; j < 4; j++) 
						if( i != j && b[i] == a[j] ) blow++;
										}
			}
			System.out.println(hit + " " + blow);
		}
	}

}

Measured memory_bytes: 12000
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let n: usize = read();
  let mut task: Vec<(u64, u64)> = Vec::new();
  for _ in 0..n {
    let t: Vec<u64> = read_vec();
    task.push((t[0], t[1]));
  }

  task.sort_by(|a, b| a.1.cmp(&b.1));

  let mut start = 0;
  let mut now: usize = 0;
  while start < task[n-1].1 && now < n {
    if start + task[now].0 <= task[now].1 {
      start += task[now].0;
      now += 1;
    } else {
      break;
    }
  }
  if now == n {
    println!("Yes");
  } else {
    println!("No");
  }
}


Measured memory_bytes: 9284
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<string, int> ans;
    ans["SAT"] = 1;
    ans["FRI"] = 2;
    ans["THU"] = 3;
    ans["WED"] = 4;
    ans["TUE"] = 5;
    ans["MON"] = 6;
    ans["SUN"] = 7;
    string s;
    cin >> s;
    cout << ans[s] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define n 1000000
int main(){
  
  long long int s;
  cin>>s;
  long long int prev=s;
  long long int ans=-1;
  set<long long int> uns;
  bool flag=0;
  uns.insert(s);
  for(long long int i=2;i<n;i++){
    //cout<<"hello"<<endl;
    if(prev%2==0){
      	//cout<<"hello2"<<endl;
      prev=prev/2;
      if(uns.find(prev)!=uns.end())
      {
        
        ans=i;
        flag=1;
      }
      else
      {
        uns.insert(prev);
      }
    }
    else{
      
       prev=(3*prev)+1 ;
      if(uns.find(prev)!=uns.end())
      {
        ans=i;
        flag=1;
      }
      else
      {
        uns.insert(prev);
      }
      
      
      
    }
    
    if(flag==1)break;
  }
  cout<<ans;
  
  
}


Measured memory_bytes: 256
n = int(input())
li = list(input())

white_position = []
red_potition = []
for i in range(n):
    if li[i] == 'W':
        white_position.append(i)
    else:
        red_potition.append(i)
        
red_potition.sort(reverse=True)

cnt = 0
for s,t in zip(white_position, red_potition):
    if s < t:
        li[s] = 'R'
        li[t] = 'W'
        cnt += 1
        
check = False
for i in range(n):
    if li[i] == 'W':
        check = True
    if check == True and li[i] == 'R':
        cnt += 1

print(cnt)


Measured memory_bytes: 18832
s = list(input())

def ki():
    for i in range(0,len(s),2):
        if s[i] != "R" and s[i] != "U" and s[i] != "D":
            return False
    return True

def gu():
    for i in range(1,len(s),2):
        if s[i] != "L" and s[i] != "U" and s[i] != "D":
            return False
    return True

if ki():
    if gu():
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int cnt = b;
        if (c <= a + b + 1)
            cnt += c;
        else
            cnt += b + a + 1;
        
        System.out.println(cnt);
    }
}


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

int main(){
  ll n;
  cin >> n;
  vector<pair<int, ll>> fs;
  for(ll i=2; i*i<=n; i++){
    int kosuu=0;
    while(n%i==0){
      n /= i;
      kosuu++;
    }
    fs.emplace_back(i, kosuu);
  }
  if(n!=1) fs.emplace_back(n, 1);
  int ans=0;
  for(auto p: fs){
    int i=1;
    while(p.second - i >= 0){
      p.second -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
}


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

//https://atcoder.jp/contests/keyence2020/tasks/keyence2020_d

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = (ll)1e9 + 7;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

ll gcd(ll a, ll b) { while (b) a %= b, swap(a, b); return abs(a); }

ll lcm(ll a, ll b) { return a * inv_mod(gcd(a, b)) * b; }

#define MAX (int)(1e6+10) 
ll prime[MAX];
unordered_map<ll, ll> max_map;

ll power(ll a, ll n)
{
	if (n == 0)
		return 1;
	ll p = power(a, n / 2) % mod;
	p = (p * p) % mod;
	if (n & 1)
		p = (p * a) % mod;
	return p;
}

void sieve()
{
	prime[0] = prime[1] = 1;
	for (int i = 2; i < MAX; i++) {
		if (prime[i] == 0) {
			for (int j = i * 2; j < MAX; j += i) {
				if (prime[j] == 0) {
					prime[j] = i;
				}
			}
			prime[i] = i;
		}
	}
}

ll lcmModuloM(const ll* ar, int n)
{

	for (int i = 0; i < n; i++) {
		ll num = ar[i];
		unordered_map<ll, ll> temp;

		while (num > 1) {

			int factor = prime[num];

			temp[factor]++;

			num /= factor;
		}

		for (auto it : temp) {

			max_map[it.first] = max(max_map[it.first], it.second);
		}
	}

	ll ans = 1;

	for (auto it : max_map) {

		ans = (ans * power(it.first, it.second)) % mod;
	}

	return ans;
}


int main(void)
{
	ll n;
	cin >> n;
	vector<ll> vs(n);
	rep(i, n)cin >> vs[i];
	sieve(); 
	ll t = 1;
	t = lcmModuloM(vs.data(), n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		ll v = t * inv_mod(vs[i]);
		v %= mod;
		sum += v;
		sum %= mod;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define RALL( c ) (c).rbegin(), (c).rend()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

int main()
{
	string buffer;

	while ( getline( cin, buffer ) )
	{
		UREP( i, 0, buffer.length() )
		{
			if ( buffer[i] == ',' )
			{
				buffer[i] = ' ';
			}
		}

		vector<int> l;
		l.PB( 0 );
		istringstream iss( buffer );

		REP( i, 0, 10 )
		{
			int input;
			iss >> input;
			l.PB( l.back() + input );
		}

		int v1, v2, res;
		iss >> v1 >> v2;

		UREP( i, 0, 11 )
		{
			if ( l[i] / (double)v1 < ( l.back() - l[i] ) / (double)v2 )
			{
				res = i;
			}
			else
			{
				res++;
				break;
			}
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1240
from collections import deque

n = int(input())
d = deque()
cmd = ['com', 0]
for i in range(n):
    cmd = input().split()
    if cmd[0] == 'insert':
        d.appendleft(int(cmd[1]))
    elif cmd[0] == 'delete':
        try:
            d.remove(int(cmd[1]))
        except ValueError:
            pass
    elif cmd[0] == 'deleteFirst':
        d.popleft()
    elif cmd[0] == 'deleteLast':
        d.pop()
print(*list(d))

Measured memory_bytes: 48124
#include <iostream>
#include <iomanip>
#include <vector>
#include <complex>
#include <cmath>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}

int lcm(int a,int b){
	return (a/gcd(a,b))*b;
}

int main(){
	int num,ans;
	int tmp[15];
	cin>>num;
	for(int i=0;i<num;i++){
		cin>>tmp[i];
	}
	ans=lcm(tmp[0],tmp[1]);
	for(int j=2;j<num;j++){
		ans=lcm(ans,tmp[j]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1160
# AOJ 2883: Proof of Knowledge
# Python3 2018.7.11 bal4u

def calc(a, b, c, d, i):
    global S
    if S[i] == '[':
        op = S[i+1]
        if S[i+2] == '[': v1, i = calc(a, b, c, d, i+2)
        else:
            if S[i+2] == 'a': v1 = a
            elif S[i+2] == 'b': v1 = b
            elif S[i+2] == 'c': v1 = c
            else: v1 = d
            i += 3

        if S[i] == '[': v2, i = calc(a, b, c, d, i)
        else:
            if S[i] == 'a': v2 = a
            elif S[i] == 'b': v2 = b
            elif S[i] == 'c': v2 = c
            else: v2 = d
            i += 2
        if op == '+': ans = v1 | v2
        elif op == '*': ans = v1 & v2
        else: ans = v1 ^ v2
    else:
        if S[i] == 'a': ans = a
        elif S[i] == 'b': ans = b
        elif S[i] == 'c': ans = c
        else: ans = d
        i += 1
    while i < len(S) and S[i] == ']': i += 1
    return [ans, i]

while True:
    S = input()
    if S == '.': break
    P = input()
    a, b, c, d = map(int, list(P))
    val, cnt = calc(a, b, c, d, 0)[0], 0
    for a in range(0, 10):
        for b in range(0, 10):
            for c in range(0, 10):
                for d in range(0, 10):
                    if calc(a, b, c, d, 0)[0] == val: cnt += 1
    print(val, cnt)



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

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const int MOD = 1'000'000'007;
const double EPS = 0.000'000'001;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

const int N = 3010;
pair<ll, ll> dp[N][N];
ll a[N];
bool vis[N][N];
int n;

pair<ll, ll> solve(int l = 0, int r = n - 1)
{
    if(l == r)
    {
        if(n % 2)
            return {a[l], 0LL};
        else
            return {0LL, a[l]};
    }

    if(!vis[l][r])
    {
        vis[l][r] = true;

        ll x1, y1;
        ll x2, y2;

        tie(x2, y2) = solve(l, r - 1);
        tie(x1, y1) = solve(l + 1, r);

        pair<ll, ll> ans;

        if((r - l + 1) % 2 == n % 2)
        {
            if(x1 + a[l] - y1 > x2 + a[r] - y2)
                ans = {x1 + a[l], y1};
            else
                ans = {x2 + a[r], y2};
        }
        else
        {
            if(x1 - a[l] - y1 < x2 - a[r] - y2)
                ans = {x1, y1 + a[l]};
            else
                ans = {x2, y2 + a[r]};
        }

        dp[l][r] = ans;
    }

    return dp[l][r];
}

int main()
{
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    ios_base::sync_with_stdio(false);
    cout.precision(10);

    cin >> n;

    for(int i = 0; i < n; i++)
        cin >> a[i];

    ll x, y;

    tie(x, y) = solve();

    cout << x - y << endl;

    return 0;
}


Measured memory_bytes: 150016
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


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

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

char step(char a, char b){
  if(a == 'T' && b == 'F') return 'F';
  else return 'T';
}

int main(){
  int N;
  char C;
  cin >> N;
  cin >> C;
  for(int i = 1; i < N; i++){
    char P;
    cin >> P;
    C = step(C, P);
  }
  cout << C << endl;
  return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>

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

    std::vector<std::tuple<int, int, std::string, long long, std::string>> tp(0);

    int v, w;
    long long d;
    std::string t, s;
    for (int i = 0; i < n; i++)
    {
        std::cin >> v >> w >> t >> d >> s;
        auto tuple = std::make_tuple(v, w, t, d, s);
        tp.push_back(tuple);
    }

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

    for (auto &x : tp)
    {
        std::cout
            << std::get<0>(x) << " "
            << std::get<1>(x) << " "
            << std::get<2>(x) << " "
            << std::get<3>(x) << " "
            << std::get<4>(x) << std::endl;
    }
    return 0;
}



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

int main()
{
  int N;
  float sum = 0.0;
  
  cin >> N;
  vector<int> arr(N);
  for (int i= 0; i< N; i++) {
    cin >> arr.at(i);
  }
  for (int i = 0; i < N; i++) {
    sum += 1.0 / arr.at(i);
  }
  sum = 1.0 / sum;
  cout << sum << endl;
  return 0;
}

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

using namespace std;

#define ll long long 


int main(){
	int n;
	string str;
	cin >> n >> str;
	int k = n/2;
	if(n%2==1){
		cout << "No\n";
		return 0;
	}
	for(int i=0;i<k;++i){
		if(str[i]!=str[i+k]){
			
		cout << "No\n";
		return 0;
		}
	}
	cout <<"Yes\n";
} 

Measured memory_bytes: 256
n, x, y = map(int, input().split())

ans = [0] * (n - 1)

dist = 0

for i in range(1, n):
    for j in range(i + 1, n + 1):
        dist = min(j - i, abs(i - x) + abs(j - y) + 1)
        ans[dist - 1] += 1

for i in range(n - 1):
    print(ans[i])

Measured memory_bytes: 3444
#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>;

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


int pre[100005];

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 n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);

    int sum=a[1];
    for(int i=2;i<=n;i++)
    {
        int z=a[i]-2*sum;
        int l=1,r=n;
        int mn=n+1;
        while (l<=r)
        {
            int  mid=l+(r-l)/2;
            if(a[mid]>=z)
            {
                r=mid-1;
                mn=min(mn,mid);
            }
            else
            {
                l=mid+1;
            }            
        }
        if(z>0)
        {
            pre[1]++;
            mn=max(mn,i);
            pre[mn]--;            
        }
        sum+=a[i];
    }
    int ans=0;
    if(a[1]*2>=a[2]&& pre[1]==0)
        ans++;
    for(int i=2;i<=n;i++)
    {
        pre[i]+=pre[i-1];
        if(pre[i]==0)
        {
            ans++;
        }
    }
    cout<<ans;

} 
    
 


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){
	
}

void solve(int casi){
	char s[100];
	scanf("%d%s%d", &n, s, &m);
	if (s[0] == '+')
		cout<<n+m<<endl;
	else
		cout<<n-m<<endl;
}

void printans(){

}


int main(){
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}




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

int n, X;
int x[200000];


long long f(int m) {
	if (m <= 0)return 1LL << 60;
	long long ret = 1LL * X * (n + m);

	long long a;
	int rem;
	if (n%m == 0) {
		a = n / m;
		rem = m;
	}
	else {
		a = n / m + 1;
		rem = n % m;
	}

	rep(i, n) {
		ret += (a + 1)*(a + 1)*x[i];
		if(a>1)ret -= a*a*x[i];

		if (--rem == 0) {
			a--;
			rem = m;
		}
	}
	for (int i = n-1; i >= n - m;i--) {
		ret += x[i];
	}

	return ret;
}

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

	cin >> n >> X;
	rep(i, n)cin >> x[i];

	int left = 0, right = n;
	while (right-left > 2) {
		int mid1 = (left * 2 + right) / 3;
		int mid2 = (left + right * 2) / 3;
		if (f(mid1) < f(mid2)) {
			right = mid2;
		}
		else {
			left = mid1;
		}
	}
	long long a1 = f(right - 1), a2 = f(right);
	cout << min(a1, a2) << endl;


	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;
using pii = pair<int,int>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define M 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define FIND(x,y) find(all(x),y)!=x.end()
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 (b<a) { a=b; return true; } return false; }

struct uf {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rcount;

    uf(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

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

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


int main(){
	int n;cin>>n;
	vector<pii> x(n);
	rep(i,n)cin>>x[i].s>>x[i].f;
	sort(all(x));
	bool flag=true;
	int c=0;
	rep(i,n){
		c+=x[i].s;
		if(c>x[i].f)flag=false;
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 1792
import java.util.Scanner

fun a(sc: Scanner): String {
    if (sc.nextInt() + sc.nextInt() + sc.nextInt() < 22) {
        return "win"
    }
    return "bust"
}

fun b(sc: Scanner): String {
    val s = sc.next()
    val sr = s.reversed()
    val l = s.length
    var ans = 0
    s.forEachIndexed { index, c ->
        if (index * 2 >= l) {
            return ans.toString()
        }
        if (c != sr[index]) ans++
    }
    return "0"
}

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    println(
//        a(sc)
        b(sc)
    )
}

Measured memory_bytes: 31404
S = input()
for i, s in enumerate(S):
  if i < len(S) - 1 and s == S[i + 1]:
    print(i + 1, i + 2)
    break
  if i < len(S) - 2 and s == S[i + 2]:
    print(i + 1, i + 3)
    break
else:
  print('-1 -1')

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

# 最小公倍数 lcm (least common maltiple)
# lcm(a,b) = a * b / gcd(a,b)

from fractions import gcd
from functools import reduce

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

def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

lcm = lcm_list(A)
#print(lcm)

# 分子
numerator = lcm

# 分母
denominator = 0
for i in range(N):
  denominator += lcm // A[i]

ans = numerator / denominator
print(ans)

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

#define int long long
#define endl "\n"

using namespace std;

int32_t main()
{
    int n;
    cin >> n;
    
	string s,t;
	cin >> s >> t;
	
	for(int i=0;i<n;i++)
	    cout << s[i] << t[i];
	cout << endl;
}

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


using namespace std;


using ull = unsigned long long;


int main()
{
    ull N;
    cin >> N;
    vector<ull> t;
    for (ull i = 0; i < 5; i++) {
        ull tmp;
        cin >> tmp;
        t.push_back(tmp);
    }

    ull neck = *min_element(t.begin(), t.end());

    if (N % neck == 0) {
        cout << N / neck + 4 << endl;
    } else {
        cout << N / neck + 5 << endl;
    }
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_v

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%lld%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int M_MAX = 1e9;

int N, M;

//------------------------------------------------------------------------------
const int V_MAX = N_MAX;

int V;
vector<int> G[V_MAX];

void add_edge(int from, int to) {
  G[from].push_back(to);
  G[to].push_back(from);
}

//------------------------------------------------------------------------------
#define LF(i)   (n - 1 + i)
#define PA(k)   ((k - 1) / 2)
#define LC(k)   (k * 2 + 1)
#define RC(k)   (k * 2 + 2)
#define M(l,r)  ((l + r) / 2)

template<typename T> class SegTree {
public:
  int n;
  int sz;
  T def;
  vector<T> dat;

  void init(int _n, T _def) {
    n = 1; while (n < _n) n <<= 1;
    sz = n * 2 - 1;
    def = _def;
    dat.resize(sz, def);
  }

  void update(int i, T x) {
    int k = LF(i);
    dat[k] = x;
    while (k > 0) {
      k = PA(k);
      dat[k] = dat[LC(k)] * dat[RC(k)] % M;
    }
  }

  T query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return def;
    if (a <= l && r <= b) return dat[k];
    T vl = query(a, b, LC(k), l, M(l, r));
    T vr = query(a, b, RC(k), M(l, r), r);
    return vl * vr % M;
  }

  T query(int a, int b) {
    if (a >= b) return def;
    return query(a, b, 0, 0, n);
  }

  T except(int i) {
    return query(0, i) * query(i + 1, n) % M;
  }

  void dump() {
    REP(i, sz) printf("%d%c", dat[i], i + 1 == sz ? '\n' : ' ');
  }
};

//------------------------------------------------------------------------------
SegTree<ll> dp[V_MAX];
int pi[V_MAX];

void dfs(int p, int v) {
  dp[v].init(G[v].size(), 1);
  REP(i, G[v].size()) {
    int u = G[v][i];
    if (u == p) {
      pi[v] = i;
      continue;
    }
    dfs(v, u);
    dp[v].update(i, (dp[u].dat[0] + 1) % M);
  }
}

void dfs2(int p, int v, int vi) {
  if (p >= 0) dp[v].update(pi[v], (dp[p].except(vi) + 1) % M);
  REP(i, G[v].size()) {
    int u = G[v][i];
    if (u == p) continue;
    dfs2(v, u, i);
  }
}

void solve() {
  dfs(-1, 0);
  dfs2(-1, 0, -1);
  REP(v, V) printf("%lld\n", dp[v].dat[0]);
}

void input() {
  scanf("%d%d", &N, &M);
  V = N;
  REP(i, N - 1) {
    int x, y;
    scanf("%d%d", &x, &y);
    add_edge(x - 1, y - 1);
  }
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 24576
import java.util.Scanner;

/**
 * Main
 */
public class Main {
  public static void main(String[] args) {
    (new Main()).run();
  }

  public void run() {
    Scanner sc = new Scanner(System.in);
    int[][] mx = new int[3][3];
    boolean[][] isOpened = new boolean[3][3];
    for (int j = 0; j < 3; j++) {
      for (int i = 0; i < 3; i++) {
        mx[i][j] = sc.nextInt();
      }
    }
    int n = sc.nextInt();
    for (int i = 0; i < n; i++) {
      int b = sc.nextInt();
      check(mx, b, isOpened);
    }
    System.out.println(isBingo(isOpened) ? "Yes" : "No");
  }

  public void check(int[][] mx, int tryNumber, boolean[][] isOpened) {
    for (int j = 0; j < 3; j++) {
      for (int i = 0; i < 3; i++) {
        if (mx[i][j] == tryNumber) {
          isOpened[i][j] = true;
          return;
        }
      }
    }
    return;
  }

  public boolean isBingo(boolean[][] isOpened) {
    // 縦方向
    for (int i = 0; i < 3; i++) {
      if (isOpened[i][0] && isOpened[i][1] && isOpened[i][2]) {
        return true;
      }
    }
    // 横方向
    for (int j = 0; j < 3; j++) {
      if (isOpened[0][j] && isOpened[1][j] && isOpened[2][j]) {
        return true;
      }
    }
    // 対角線
    if (isOpened[0][0] && isOpened[1][1] && isOpened[2][2]) {
      return true;
    }
    if (isOpened[2][0] && isOpened[1][1] && isOpened[0][2]) {
      return true;
    }
    return false;
  }
}

Measured memory_bytes: 23252
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

N, W = map(int, input().split())
v, w = [0 for _ in range(N + 1)], [0 for _ in range(N + 1)]
for i in range(1, N + 1):
    v[i], w[i] = map(int, input().split())

dp = [[0 for _ in range(W + 10)] for _ in range(N + 10)]

for i in range(w[1], W + 1):
    dp[1][i] = v[1]
for i in range(2, N + 1):
    for l in range(1, W + 1):
        if l - w[i] >= 0:
            dp[i][l] = max(dp[i - 1][l], dp[i - 1][l - w[i]] + v[i])
        else:
            dp[i][l] = dp[i - 1][l]
print(dp[N][W])



Measured memory_bytes: 27548
#include <stdio.h>
#include <limits.h>

int n;
int mins[262143];

void update(int arrIndex, int val) {
  mins[arrIndex] = val;

  while (arrIndex > 1) {
    arrIndex /= 2;
    mins[arrIndex] = min(mins[arrIndex * 2], mins[arrIndex * 2 + 1]);
  }
}

int min(int n1, int n2) {
  return n1 < n2 ? n1 : n2;
}

int find(int node, int l, int r, int i, int j) {
  if (r < i || l > j)
    return INT_MAX;
  else if (l >= i && r <= j)
    return mins[node];
  else {
    int lValue = find(2*node, l, (l + r) / 2, i, j);
    int rValue = find((2*node)+1, (l + r) / 2 + 1, r, i, j);

    return lValue < rValue ? lValue : rValue;
  }
}

int main() {
  int q, i, j, query, counter, cur, powerOf2[18], lengthOfBottomRow;

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

  for (i = 0; i < 19; i++) {
    cur = 2;

    for (j = 0; j < i; j++)
      cur *= 2;

    powerOf2[i] = cur;

    if (i) {
      if (powerOf2[i-1] <= 2 * n && powerOf2[i] >= 2 * n) {
        lengthOfBottomRow = powerOf2[i-1];
        break;
      }
    }
  }

  for (counter = 1; counter < lengthOfBottomRow * 2; counter++)
    mins[counter] = INT_MAX;

  for (counter = 0; counter < q; counter++) {
    scanf("%d %d %d", &query, &i, &j);

    if (query)
      printf("%d\n", find(1, lengthOfBottomRow, (lengthOfBottomRow * 2) - 1, i + lengthOfBottomRow, j + lengthOfBottomRow));
    else {
      update(i + lengthOfBottomRow, j);
    }
  }
}



Measured memory_bytes: 2864
def abc_3() :
	H, W = map(int, input().split())
	print (min(div_3(H, W), div_3(W, H), div_s(H, W), div_s(W, H)))

def div_3(H, W) :
	w = W //3
	if w == 0 :
		return 10000000000
	if W % 3 == 0 :
		return 0
	else :
		return H

def div_s(H, W) :
	min_diff = 10000000000
	for w in range(1, W) :
		s1 = w * H
		s2 = (W - w) * (H // 2)
		s3 = W * H - s2 - s1
		diff = max(s1, s2, s3) - min(s1, s2, s3)
		if diff < min_diff :
			min_diff = diff
	return min_diff

#for i in range(5) :
#	abc_3()
#	print ('input:', end = '')
#	if input() == 'q' :
#		break

abc_3()

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

int main(){
  int n;
  cin>>n;
  vector<int>d(n);
  vector<int>freq(200,0);
  rep(i,n){
    cin>>d[i];
    freq[d[i]]++;
  }
  int cnt=0;
  rep(i,200)
    if(freq[i]>=1)cnt++;
  cout<<cnt<<endl;
  return 0;
  
}

Measured memory_bytes: 3628
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    int x,y;
    void solve()
    {
        cin>>x>>y;
        if(x==1|| y==1)
        {
            cout<<1<<endl;
        }
        else
        if((x*y)%2)
            cout<<(x*y+1)/2<<endl;
        else
            cout<<(x*y)/2<<endl;
 
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
      {
        
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        
        // cin>>t;while(t--)
        solve();
        
      return 0;
      }

Measured memory_bytes: 256
// JOI 2011-2012 予選6
#include<iostream>
#include<string>
#include<vector>
#include<cstring>

// 多倍長整数
std::vector<int> A, B;
int M;
// memo[現在i桁目][Mで割った余り][直前の数字][直前が増加・減少(0: 増, 1: 減, 2: 上から0が連続][自由に選べるか]
int memo[501][500][10][3][2];

// メモ化再帰
// (vで表される数)以下のZig-Zag数の個数を10000で割った余りを返す
int rec( const std::vector<int>& v, int n, int mod, int prv, int ud, bool ok )
{
	if( n == v.size() )
		return !mod;

	if( memo[n][mod][prv][ud][ok] >= 0 )
		return memo[n][mod][prv][ud][ok];

	int ret = 0;
	
	for( int i = 0; i <= ( ok ? 9 : v[n] ); ++i )
	{
		if( !ud && prv <= i )
			continue;
		if( ud == 1 && prv >= i )
			continue;
		if( ud == 2 && prv && prv == i )
			continue;

		int nud;
		if( ud == 2 )
		{
			if( !prv )
				nud = 2;
			else if( prv > i )
				nud = 1;
			else
				nud = 0;
		}
		else
			nud = !ud;

		ret += rec( v, n + 1, ( mod * 10 + i ) % M, i, nud, ok | i != v[n] );
	}

	return memo[n][mod][prv][ud][ok] = ret % 10000;
}

int main()
{
	std::string s, t;
	std::cin >> s >> t >> M;
	for( int i = 0; i != s.size(); ++i )
		A.push_back( s[i] - '0' );
	for( int i = 0; i != t.size(); ++i )
		B.push_back( t[i] - '0' );

	// A - 1をする
	// c: carry
	int c = 1;
	for( int i = A.size() - 1; i >= 0; --i )
	{
		A[i] -= c;
		c = 0;

		if( A[i] < 0 )
		{
			c = 1;
			A[i] += 10;
		}
	}

	memset( memo, -1, sizeof( memo ) );
	int a = rec( A, 0, 0, 0, 2, 0 );
	memset( memo, -1, sizeof( memo ) );
	int b = rec( B, 0, 0, 0, 2, 0 );

	// 10000で割った余りなので、f( B ) < f( A - 1 )の可能性あり
	std::cout << ( 10000 + b - a ) % 10000 << std::endl;

	return 0;
}

Measured memory_bytes: 60012
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        StringBuilder s = new StringBuilder(in.next()).reverse();

        int p = 0;
        int pp = -1;
        long t = 0;
        int b = 0;
        while ((p = s.indexOf("B", pp)) > -1) {
            t += p - b;
            b++;
            pp = p + 1;
        }
        out.println(t);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}


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

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

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		BitSet isPrime = createIsPrimeBit(0,1000000);
		int[] cnt = new int[1000000];
		for (int i=2; i<1000000; i++) {
			if (isPrime.get(i)) cnt[i] = cnt[i-1] + 1;
			else cnt[i] = cnt[i-1];
		}
		while (in.hasNext()) {
			int n = in.nextInt();
			out.println(cnt[n]);
			out.flush();
		}
	}

	public static BitSet createIsPrimeBit(int offset, int n) {
		if (n < 2) return null;
		BitSet res = new BitSet();
		res.set(2,n,true);
		for (int i=2; i*i<n; i=res.nextSetBit(i+1)) {
			if (i < offset) res.set(i,false);
			for (int j=i+i; j<n; j+=i) res.set(j,false);
		}
		return res;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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

int main() {
  int N, M;
  cin >> N >> M;
  long long A[N];
  pair<int, long long> BC[M];
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) cin >> BC[i].first >> BC[i].second;

  sort(A, A + N);
  sort(BC, BC + M,
       [](pair<int, long long> bc1, pair<int, long long> bc2) -> int {
         return bc1.second > bc2.second;
       });

  int ai = 0;
  for (int i = 0; i < M; i++) {
    if (A[ai] >= BC[i].second) break;

    for (int j = 0; j < BC[i].first; j++) {
      if (A[ai] >= BC[i].second) break;

      A[ai] = BC[i].second;
      ai++;
      if (ai == N) break;
    }
    if (ai == N) break;
  }

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
N, x = map(int,input().split())
a = list(map(int,input().split()))
b = []
ans = 0
for i in range(N-1):
    if a[i]+a[i+1] > x:
        tmp = a[i]+a[i+1] - x
        if a[i+1] >= tmp:
            a[i+1] -= tmp
            ans += tmp
        else:
            a[i] -= tmp - a[i+1]
            a[i+1] = 0
            ans += tmp
print(ans)

Measured memory_bytes: 14540
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdio>
using namespace std;

typedef pair<int,int> pii;

int main()
{
  int n,h,m,s;
  for(;;){
    cin>>n;
    if(!n) break;
    vector<pii> time;
    for(int i=0;i<n;i++){
      scanf("%d:%d:%d", &h, &m, &s);
      time.push_back(pii(h*10000+m*100+s,1));
      scanf("%d:%d:%d", &h, &m, &s);
      time.push_back(pii(h*10000+m*100+s,-1));
    }
    sort(time.begin(),time.end());
    int ans=0,res=0;
    for(int i=0;i<time.size();i++){
      res+=time[i].second;
      ans=max(ans,res);
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 1496
import java.util.*;
import java.math.*;
import java.io.*;


public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]) {
        int m = sc.nextInt();
        int d = sc.nextInt();
        int ans = 0;
        for(int i = 1; i <= m; i++) {
            for(int j = 1; j <= d; j++) {
                int d_10 = j / 10;
                int d_1 = j % 10;
                if(d_1 > 1 && d_10 > 1 && d_10 * d_1 == i) ans++;
            }
        }

        System.out.println(ans);


    } 
}

Measured memory_bytes: 21844
def solver():
	a = input().rstrip('\n').split('/')
	if int(a[0]) > 2019:
		print('TBD')
	elif int(a[0]) < 2019:
		print('Heisei')
	else:
		if int(a[1]) > 4:
			print('TBD')
		elif int(a[1]) < 4:
			print('Heisei')
		else:
			if int(a[2]) > 30:
				print('TBD')
			elif int(a[2]) < 30:
				print('Heisei')
			else:
				print('Heisei')

solver()

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)

	var ans int
	if w < 2 || h < 2 {
		ans = 1
	} else {
		ans = int(math.Ceil(float64(h*w) / 2.0))
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
n, m = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

import bisect
d = make_divisors(m)
idx = bisect.bisect_left(d, n)
print(m // d[idx])


Measured memory_bytes: 3060
s = str(input())
t = str(input())

ans = ''
dec = ''
cando = False

def match(enc, key):
  result = True
  for e, k in zip(enc, key):
    if e == '?':
      continue
    else:
      if e != k:
        result = False
        break
  return result

if len(s) < len(t):
  cando = False
else:
  for i in range(len(s)-len(t), -1, -1):
    if match(s[i:i+len(t)], t):
      dec = t
      if i > 0: dec = s[:i] + dec
      if i + len(t) < len(s): dec = dec + s[i+len(t):]
      cando = True
      break
  if cando:
    ans = dec.replace('?', 'a')

if cando: print(ans)
else: print('UNRESTORABLE')

Measured memory_bytes: 3064