akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

void factorize(ll n, vector<ll> &factors) {
    for(ll i=2LL;i*i<=n&&n>1LL;++i) {
        while(n % i == 0LL) {
            factors.push_back(i);
            n /= i;
        }
    }
    if(n != 1LL) factors.push_back(n);
}

ll modpow(ll a, ll t) {
    ll ret = 1LL;
    while(t){
        if(t & 1LL){
            ret *= a;
            ret %= MOD;
        }
        a *= a;
        a %= MOD;
        t >>= 1;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n), b_inv(n, 1LL);
    map<ll, ll> lcm_factors;
    for(int i=0;i<n;++i) {
        cin >> a[i];
        vector<ll> factors;
        factorize(a[i], factors);
        map<ll, ll> mp;
        for(ll f: factors) {
            b_inv[i] *= modpow(f, MOD-2);
            b_inv[i] %= MOD;
            ++mp[f];
        }
        for(auto itr=mp.begin(); itr!=mp.end(); ++itr) {
            lcm_factors[itr->first] = max(lcm_factors[itr->first], itr->second);
        }
    }

    ll lcm = 1LL;
    for(auto itr=lcm_factors.begin(); itr!=lcm_factors.end(); ++itr) {
        lcm *= modpow(itr->first, itr->second);
        lcm %= MOD;
    }


    ll ans = 0LL;
    for(int i=0;i<n;++i) {
        ans += (lcm * b_inv[i]) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;

}


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

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

    int f[n][10];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }

    ll p[n][11];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
            cin >> p[i][j];
        }
    }

    ll ans = -10e8-1;
    for (int bit = 0; bit < (1<<10); ++bit) {
        vector<int> S;
        for (int i = 0; i < 10; ++i) {
            if (bit & (1<<i)) {
                S.push_back(i);
            }
        }

        int cou = 0;
        ll now = 0;
        if(S.size() != 0){
            for(int i = 0; i < n; i++){
                cou = 0;
                for(int j = 0; j < S.size(); j++){
                    if(f[i][S[j]] == 1){
                        cou++;
                    }
                }

                now += p[i][cou];
            }

            if(now > ans){
                ans = now;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
n = io.read('*n')
t, v = {}, {}

for i = 1, n do t[i] = io.read('*n') * 2 end
for i = 1, n do v[i] = io.read('*n') end

t[0] = 0
tot = 0
for i = 1, n do
    tot = tot + t[i]
    t[i] = t[i] + t[i - 1]
end

min, max = {}, {}
for i = 0, tot do min[i], max[i] = 0, math.min(i / 2, (tot - i) / 2) end

for i = 1, n do
    for j = t[i - 1], t[i] do max[j] = math.min(max[j], v[i]) end
    for j = 0, t[i - 1] - 1 do
        min[j] = math.max(min[j], v[i] - 0.5 * (t[i - 1] - j))
        max[j] = math.min(max[j], v[i] + 0.5 * (t[i - 1] - j))
    end
    for j = t[i], tot do
        min[j] = math.max(min[j], v[i] - 0.5 * (j - t[i]))
        max[j] = math.min(max[j], v[i] + 0.5 * (j - t[i]))
    end
end

--for i = 0, tot do print(i / 2, min[i], max[i]) end

ans = 0.0
for i = 0, tot - 1 do ans = ans + (max[i] + max[i + 1]) / 2 end
print(ans / 2)


Measured memory_bytes: 2524
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

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

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

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

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

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

int main() {
	ll n;
	cin >> n;
	vl data(n);
	for (int i = 0; i < n; i++) {
		cin >> data[i];
	}
	ll m = 1000;
	ll k = 0;
	ll a = 0;
	ll b = 0;
	for (int i = 0; i < n - 1; i++) {
		if (data[i] < data[i + 1]) {
			a = m / data[i];
			m -= a * data[i];
			k += a;
		}
		if (data[i] > data[i + 1]) {
			b = k * data[i];
			m += b;
			k = 0;
		}
		if (i == n - 2) {
			m += data[i + 1] * k;
		}
	}
	cout << m << endl;
}

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

using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  map<ll, ll> mp;
  priority_queue<int> que;
  rep(i, n) {
    int a;
    cin >> a;
    if (mp[a] == 0) {
      que.push(a);
    }
    mp[a] += 1;
  }
  rep(i, m) {
    ll b, c;
    cin >> b >> c;
    if (mp[c] == 0) {
      que.push(c);
    }
    mp[c] += b;
  }
  ll ans = 0;
  ll cnt = 0;
  while (cnt < n) {
    ll q = que.top();
    que.pop();
    ans += q * mp[q];
    cnt += mp[q];
    if (n < cnt) {
      ans -= q * (cnt - n);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,M;
ll mo=1000000007;
ll from[6060][2];
ll to[6060][2];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,N+1) from[i][i==0]=1;
	FOR(i,M) {
		ZERO(to);
		FOR(x,N+1) {
			if(x+1<=N) {
				//BB
				(to[x+1][0]+=from[x][0])%=mo;
				(to[x+1][1]+=from[x][1])%=mo;
				//BR
				(to[x][0]+=from[x][0])%=mo;
				(to[x][1]+=from[x][1])%=mo;
			}
			if(x) {
				// RB
				(to[x][(x==1)]+=from[x][0])%=mo;
				(to[x][1]+=from[x][1])%=mo;
				// RR
				(to[x-1][(x==1)]+=from[x][0])%=mo;
				(to[x-1][1]+=from[x][1])%=mo;
			}
		}
		swap(from,to);
	}
	
	ll ret=0;
	FOR(i,N+1) ret+=from[i][1];
	cout<<ret%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 512
N,K=map(int,input().split())

def renzoku(K,A):
    s=0
    while K>A:
        A*=2
        s+=1
    return s
        
out=0

for i in range(1,N+1):
    out+=(N*2**renzoku(K,i))**(-1)

print(out)


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

int main() {
	int n;
	cin >> n;
	long long bb=0;
	map<long long,long long> mp;
	for(int i = 0;i<n;i++)
	{
		long long a;
		cin >> a;
		bb += a;
		mp[bb]++;
	}
	long long k=0;
	for(auto itr=mp.begin();itr!=mp.end();itr++)
	{
		long long d;
		d = itr->second;
		if(itr->first == 0)
		{
			k += d * (d + 1) / 2;
		}
		else
		{
			k += (d - 1) * d / 2;
		}
	}
    cout << k << endl;
	return 0;
}


Measured memory_bytes: 12800
S = input()
Sb = S[::-1]
daydreamers = ["maerd", "remaerd", "esare", "resare"]
judge = True

i = 0
while i < len(S) and judge:
    temp = ""
    isThere = False
    for j in range(7):
        temp += Sb[i+j]
        if temp in daydreamers:
            isThere = True
            i = i+j+1
            break
    if not isThere:
        judge = False

print("YES" if judge else "NO")

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

int main()
{
    double l;
    cin >> l;

    l/=3 ;
    cout <<fixed << setprecision(6)<<  l*l*l << endl ;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        boolean ok = false;
        for (int a = 1; a <= 9; a++) {
            if (n % a != 0) {
                continue;
            }
            int b = n / a;
            if (1 <= b && b <= 9) {
                ok = true;
                break;
            }
        }
        if (ok) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 22612
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s)
        .expect("Error");

    let s = s.as_bytes();
    let atgc = "ATGC";
    let atgc = atgc.trim().as_bytes();
    let mut ans = 0;
    let mut cnt = 0;
    for i in s.iter() {
        for j in atgc.iter().enumerate() {
            if *j.1 == *i {
                cnt += 1;
                break;
            }
            if j.0 == 3 {
                cnt = 0;
            }
        }
        ans = max(cnt, ans);
    }
    println!("{}", ans);
}

fn max(x: i32, y: i32) -> i32 {
    if x > y { x } else { y }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i];
  i64 mod = 1e9 + 7;
  i64 AA = 0;
  map<i64, i64> mp;
  rep(i,0,N) {
    mp[A[i]]++;
  }
  rep(i,0,N) {
    rep(j,0,i) {
      if(A[i] < A[j]) {
        AA++;
      }
    } 
  }

  i64 BB = 0;
  i64 added = 0;
  for(auto p: mp) {
    i64 a = p.first;
    i64 cnt = p.second;
    i64 c = added * (K * (K - 1) / 2 % mod) % mod;
    i64 d = cnt * c % mod;
    BB = (BB + d) % mod;
    added += cnt;
  }

  cout << ((AA * K) % mod + BB) % mod << endl;
}


Measured memory_bytes: 384
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line.trim().split_whitespace();
    let a = it.next().unwrap();
    let b = it.next().unwrap();
    let c = it.next().unwrap();
    if a.chars().last() == b.chars().nth(0) && b.chars().last() == c.chars().nth(0) {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int n, d, a;
    vector<P> monster;
    int x, h;
    int i, j;
    int target, targetx, targeth;
    int mid;
    ll count;
    ll ans = 0;
    vector<int> damage(200010, 0);

    cin >> n >> d >> a;

    monster.emplace_back(0, 0);

    rep(i, 1, n + 1)
    {
        cin >> x >> h;
        monster.emplace_back(x, h);
    }

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

    rep(i, 1, n + 1)
    {
        damage[i] += damage[i - 1];

        if (damage[i] < monster[i].second)
        {
            target = i;
        }
        else
        {
            continue;
        }

        targetx = monster[target].first;
        targeth = monster[target].second - damage[target];

        count = (targeth + a - 1) / a;

        ans += count;

        int ok = 0, ng = n + 1;

        while (ng - ok > 1)
        {
            mid = (ok + ng) / 2;

            if (monster[mid].first <= targetx + d * 2)
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        damage[target] += count * a;
        damage[ng] += -count * a;
    }

    cout << ans << endl;
}


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

#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fr freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define mp make_pair
#define F first
#define S second

using namespace std;

const int N = 5e5 + 2;
const int mod = 1e9 + 7;

int a,b;
int main ()
{
	#define int long long
	cin>>a>>b;
	string f="";
	string s="";
	for (int i=0;i<b;i++){
		f+=(a+'0');
	}
	for (int i=0;i<a;i++){
		s+=(b+'0');
	}
	for (int i=0;i<min(f.size(),s.size());i++){
		if (f[i]<s[i]){
			cout<<f;
			return 0;
		}
		else if (f[i]>s[i]){
			cout<<s;
			return 0;
		}
	}
	cout<<f;
}



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

using namespace std;
using ll = long long;

const int INF = 1001001001;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> ans(n, 0);
  x--;
  y--;
  rep(j, n) rep(i, j) {
    int a = abs(i - j);
    int b = abs(x - i) + abs(y - j) + 1;
    int c = abs(x - j) + abs(y - i) + 1;
    int m = min({a, b, c});
    ans[m]++;
  }
  for (int i = 1; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


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

int dp[2][200005];

int main() {
    string s;
    cin >> s;
    dp[0][0] = 0, dp[1][0] = 0;
    dp[0][1] = 1, dp[1][1] = 0;
    for (int i = 2; i <= s.size(); i++) {
        dp[0][i] = dp[1][i - 1] + 1;
        if (s[i - 1] != s[i - 2])
            dp[0][i] = max(dp[0][i], dp[0][i - 1] + 1);
        dp[1][i] = dp[0][i - 2] + 1;
        if (i >= 4 && s[i - 1] == s[i - 3] && s[i - 2] == s[i - 4]) {}
        else
            dp[1][i] = max(dp[1][i], dp[1][i - 2] + 1);
    }
    cout << max(dp[0][s.size()], dp[1][s.size()]);
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d = c - a - b;
  if (d <= 0) {
    cout << "No\n";
    return 0;
  }
  if (4LL * a * b < 1LL * d * d) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#define nmax 100001

using namespace std;
ifstream fin("p.in");
ofstream fout("p.out");

int n;
vector<int>vec;

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
        {
            int x;
            cin>>x;
            vec.push_back(x);
        }
    vector<long long>mem(2*n,1e9);
    mem[n-1]=0;
    for(int i=n-2; i>=0; i--)
        if(i+2<n)
            mem[i]=min(mem[i+1]+abs(vec[i]-vec[i+1]),mem[i+2]+abs(vec[i]-vec[i+2]));
        else mem[i]=mem[i+1]+abs(vec[i]-vec[i+1]);

    cout<<mem[0];
    return 0;
}


Measured memory_bytes: 2300
#include<stdio.h>

int main(){
  int n, i, j, flag, count, A;
  int data[99];
  count = 0;
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%d", &data[i]);
  }

  flag = 1;
  while(flag){
    flag = 0;
    for(j = n-1; j >= 1; j--){
      if (data[j] < data[j-1]){
        A = data[j];
        data[j] = data[j-1];
        data[j-1] = A;
        count++;
        flag = 1;
      }
    }
  }
  printf("%d", data[0]);
  for(i = 1; i < n; i++){
    printf(" %d", data[i]);
  }
  printf("\n%d\n", count);
}

Measured memory_bytes: 1824
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int p=n%10;
    if(p==0||p==1||p==6||p==8) cout<<"pon"<<endl;
    else if(p==2||p==4||p==5||p==7||p==9) cout<<"hon"<<endl;
    else if(p==3) cout<<"bon"<<endl;


    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	vector<int> L(3);
	cin >> L.at(0) >> L.at(1) >> L.at(2);
	sort(L.begin(), L.end());
	cout << L.at(0)*L.at(1) / 2;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>

typedef long double ld;
typedef long long ll;

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  //for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

int main()
{
  ll N;
  std::cin >> N;

  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    ll x;
    std::cin >> x;
    va[x-1] = i+1;
  }

  print(va);
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
const int Maxn = 401, mod = 1e9 + 7;
int N, C, a[ Maxn ], b[ Maxn ], POW[ Maxn ][ Maxn ], F[ Maxn ][ Maxn ];
#define For( i, j, k ) for( int i = j; i <= k; ++i )
int main( )
{
	std::ios::sync_with_stdio( false );
	using std::cin;
	using std::cout;
	cin >> N >> C;
	For( i, 1, N )
		cin >> a[ i ];
	For( i, 1, N ) 
		cin >> b[ i ];
	For( i, 1, 400 )
	{
		POW[ i ][ 0 ] = 1;
		For( j, 1, C )
			POW[ i ][ j ] = 1LL * POW[ i ][ j - 1 ] * i % mod;
	}
	For( i, 1, 400 ) For( j, 0, C )
		POW[ i ][ j ] = ( POW[ i ][ j ] + POW[ i - 1 ][ j ] ) % mod;
	// g[i][j] = 
	// f[i][j]
	F[ 0 ][ 0 ] = 1;
	For( i, 1, N ) For( j, 0, C ) For( k, 0, j )
		F[ i ][ j ] = ( F[ i ][ j ] + 1LL * ( POW[ b[ i ] ][ k ] - POW[ a[ i ] - 1 ][ k ] + mod ) % mod * F[ i - 1 ][ j - k ] % mod ) % mod;
	cout << F[ N ][ C ];
	return 0;
}

Measured memory_bytes: 4916
#include <algorithm>
#include <iostream>
#include <string>

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

	std::string S;
	std::cin >> S;

	int result = 0;
	for(int i = 0; i < N; i++) {
		if(i != 0 && S[i] == 'L' && S[i - 1] == S[i]) {
			result++;
		} else if(i != N - 1 && S[i] == 'R' && S[i] == S[i + 1]) {
			result++;
		}
	}

	result += 2 * K;
	result = std::min(result, N - 1);

	std::cout << result << std::endl;

	return 0;
}


Measured memory_bytes: 512
n = int(input())
l = list(map(int,input().split()))
if not any(l):
  print("Yes")
elif n%3 != 0:
  print("No")
else:
  nx = n//3
  d = dict()
  for x in l:
    if x not in d:
      d[x] = 0
    d[x] += 1
  for x in d:
    if d[x] != nx and d[x] !=2*nx:
      print("No")
      break
  else:
    s = 0
    for x in d:
      if d[x] == nx:
        s ^= x
    if s == 0:
      print("Yes")
    else:
      print("No")


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

using namespace std;

int main()
{
    double a, b, C;

    cin >> a >> b >> C;

    double b_cos = b * cos(C*2*M_PI/360.);
    double b_sin = b * sin(C*2*M_PI/360.);

    double S = a * b_sin / 2;
    double c;
    if(a == b_cos){
        c = b_sin;
    }else{
        c = sqrt((a-b_cos) * (a-b_cos) + b_sin*b_sin);
    }

    printf("%.8f\n", S);
    printf("%.8f\n", (a+b+c));
    printf("%.8f\n", b_sin);
}


Measured memory_bytes: 3664
S = input()
dp = [False] * (len(S) + 1)
dp[0] = True
for i in range(len(S)+1):
    if i >= 5 and dp[i-5] and S[i-5:i] == 'erase':
        dp[i] = True
    if i >= 6 and dp[i-6] and S[i-6:i] == 'eraser':
        dp[i] = True
    if i >= 5 and dp[i-5] and S[i-5:i] == 'dream':
        dp[i] = True
    if i >= 7 and dp[i-7] and S[i-7:i] == 'dreamer':
        dp[i] = True
print('YES' if dp[len(S)] else 'NO')


Measured memory_bytes: 9864
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	long n, k;
	cin >> n >> k;
	long a = n / k;
	long b = 0;
	if (k % 2 == 0)b = a + (n - k * a) / (k / 2);
	cout << a * a*a + b * b*b << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int a, b, q;
vector<ll> s;
vector<ll> t;
vector<ll> x;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> q;
    for (int i = 0; i < a; i++)
    {
        ll temp;
        cin >> temp;
        s.push_back(temp);
    }
    for (int i = 0; i < b; i++)
    {
        ll temp;
        cin >> temp;
        t.push_back(temp);
    }
    for (int i = 0; i < q; i++)
    {
        ll temp;
        cin >> temp;
        x.push_back(temp);
    }
    sort(ALL(s));
    sort(ALL(t));
    ll ans[q];
    for (int i = 0; i < q; i++)
    {
        int scount = lower_bound(ALL(s), x[i]) - s.begin();
        int tcount = lower_bound(ALL(t), x[i]) - t.begin();
        ll s1max = s[scount] - x[i];
        ll s1min = s[scount] - x[i];
        ll s0max = -s[scount - 1] + x[i];
        ll s0min = -s[scount - 1] + x[i];
        ll t1max = t[tcount] - x[i];
        ll t1min = t[tcount] - x[i];
        ll t0max = -t[tcount - 1] + x[i];
        ll t0min = -t[tcount - 1] + x[i];
        if (scount == s.size())
        {
            s1min = 40000000000;
            s1max = 0;
        }
        else if (scount == 0)
        {
            s0max = 0;
            s0min = 40000000000;
        }
        if (tcount == t.size())
        {
            t1min = 40000000000;
            t1max = 0;
        }
        else if (tcount == 0)
        {
            t0max = 0;
            t0min = 40000000000;
        }
        ll plus = max(s1max, t1max);
        ll minus = max(s0max, t0max);
        if (scount == 0 || tcount == 0)
        {
            minus = 40000000000;
        }
        if (scount == s.size() || tcount == t.size())
        {
            plus = 40000000000;
        }
        ll turn1 = 2 * t1min + s0min;
        ll turn2 = t1min + 2 * s0min;
        ll turn3 = 2 * t0min + s1min;
        ll turn4 = t0min + 2 * s1min;
        ans[i] = min(plus, min(minus, min(turn1, min(turn2, min(turn3, turn4)))));
    }
    for (int i = 0; i < q; i++)
    {
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 4596
import java.math.BigDecimal;
import java.util.Scanner;
public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
     int a,b;

            a = sc.nextInt();
            b = sc.nextInt();
        System.out.print(a / b + " " + a % b);
        double c = (double)a / b;
        
            System.out.println(" "+BigDecimal.valueOf(c).toPlainString());



    }
}



Measured memory_bytes: 26696
# /usr/bin/python
# -*- coding: utf-8 -*-
import math
import string


def check(s):
  n = int(s)
  if n>=1 and n<=12:
    return True
  else:
    return False


yymm = str(input())
ym1 = yymm[0:2]
ym2 = yymm[2:4]
if check(ym1) and check(ym2):
  print('AMBIGUOUS')
elif check(ym1) and not check(ym2):
  print('MMYY')
elif not check(ym1) and check(ym2):
  print('YYMM')
else:
  print('NA')


Measured memory_bytes: 38640
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
long long ceil(long long a,long long b){// a以上でｂの倍数の最小値//
    return (a+b-1)/b*b;
}
int main(void){
   long long n;
   int c,k;
   cin>>n>>c>>k;
   vector<int> v(n,0);
   rep(i,n) cin>>v[i];
   sort(v.begin(),v.end());
   int l=0,r=0;
   int sum=0;
   while(l<n){
       int a=0;
       while(a<c && r<n && v[r]<=v[l]+k){
           a++;
           r++;
       }
       l=r;
       sum++;
   }
   cout<<sum<<endl;
   return 0;
}

Measured memory_bytes: 640
#include <iostream>

int main()
{
  int X[102];
  int A[100];

  int N;
  std::cin >> N;
  for (int i = 1; i <= N; ++i)
  {
    std::cin >> X[i];
  }
  X[N + 1] = 2020;

  int M;
  std::cin >> M;
  for (int i = 0; i < M; ++i)
  {
    std::cin >> A[i];
  }

  for (int i = 0; i < M; ++i)
  {
    if (X[A[i] + 1] != X[A[i]] + 1)
    {
      ++X[A[i]];
    }
  }

  for (int i = 1; i <= N; ++i)
  {
    std::cout << X[i] << std::endl;
  }

  return 0;
}



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

using namespace std;
long long x, a=100;
int main()
{
    cin>> x;
    for(int i=1; ;i++){
        a *= 1.01;
        if(a >= x){
            cout<< i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3604
n=int(input())
arr=(list(map(int,input().split())))
dp=[0]*n
dp[0]=0
dp[1]=abs(arr[1]-arr[0])
for i in range(2,n):
     dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]))
print(dp[n-1])

Measured memory_bytes: 13980
#include <stdio.h>

int ans[100];

main() {
    int i,j,k=1;
    ans[0]=105;
    for(i=107;i<200;i+=2) {
        int c=0;
        for(j=1;j*j<=i;j++) {
            if(i%j==0 && j*j!=i) c+=2;
            if(i%j==0 && j*j==i) c++;
        }
        if(c==8) {
            ans[k]=i;
            k++;
        }
    }
    int n;
    scanf("%d", &n);
    for(i=0;i<k;i++) {
        if(ans[i]>n) break;
    }
    printf("%d\n", i);
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h> 
using namespace std;
	typedef long long int lli;
	const int MaxN=200005;
	#define fst first
	#define snd second
	#define mp make_pair
	lli mcd(lli a,lli b){	
		if(a==0)return b;
		return mcd(b%a,a);
	}		
	lli pre[MaxN];
	lli suf[MaxN];
	lli arr[MaxN];
int main(){
	lli N,K,i,j,s=0,p,q,res=1;
	cin>>N;
	for(i=1;i<=N;i++){
		cin>>arr[i];
	}
	pre[1]=arr[1];
	for(i=2;i<=N;i++){
		pre[i]=mcd(pre[i-1],arr[i]);
	}
	suf[N]=arr[N];
	for(i=N-1;i>0;i--){
		suf[i]=mcd(suf[i+1],arr[i]);
	}	
	res=max(res,suf[2]);
	res=max(res,pre[N-1]);
	for(i=2;i<N;i++){
		res=max(res,mcd(pre[i-1],suf[i+1]));
	}	
	cout<<res;
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] K = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(K[0]<=K[1]*2?0:K[0]-K[1]*2);
        }
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 17740
#include<stdio.h>
#include<math.h>

#define N 100000000
#define M 10000

int main(void)
{
  int i,j,k=0,n,l[M],flag=0,fi,temp;
  double cmp;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
    cmp = sqrt(l[i]);
    fi = cmp+1;
    flag = 0;
    for(j=2;j<=fi;j++){
      if(l[i]%j==0 && l[i]!=2){
	flag = 1;
	break;
      }
    }
    if(flag==0)k++;
  }
  printf("%d\n",k);
  return 0;
}

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

int main(){
  int n,m,b,bb;
  cin >> n >> m;
  vector<int>p(m);
  vector<vector<int>>a(m);
  for(int i=0;i<m;i++){
    cin >> b;
    for(int j=0;j<b;j++){
      cin >> bb;
      a.at(i).push_back(bb-1);
    }
  }
  for(int i=0;i<m;i++)
    cin >> p.at(i);
  bool ok=false;
  int ans=0;
  for(int i=0,l=(1<<n);i<l;i++){
    bitset<10>ptn=i;
    ok=true;
    for(int j=0;j<m;j++){
      int c=0;
      for(int k=0;k<a.at(j).size();k++)
        if(ptn.test(a.at(j).at(k))) c++;
      if(c%2!=p.at(j))
        ok=false;
    }
    if(ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		Map<Integer,Integer> index = new TreeMap<>();
		for(int i=0;i<N;i++) {
			int a = sc.nextInt();
			if(index.containsKey(a)) {
				int v = index.get(a);
				v++;
				index.put(a, v);
			}else {
				index.put(a, 1);
			}
		}

		List<Integer> key = new ArrayList<>(index.keySet());
		long ans = 0;
		for(int i=0;i<key.size();i++) {
			int k = key.get(i);
			int a = index.get(k);
			if(a < k) {
				ans += a;
			}else if(a > k){
				ans += a-k;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 62724
//
// Created by kuroneko on 2019-09-07.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    int a; cin >> a;
    string s; cin >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}


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

int main() {
    int N;
    std::cin >> N;
    std::vector<int> X(N);
    for (int i = 0; i < N; ++i) std::cin >> X[i];
    
    std::vector<std::pair<int, int>> Y(N);
    for (int i = 0; i < N; ++i) Y[i] = std::make_pair(X[i], i);
    sort(Y.begin(), Y.end());
    std::vector<int> Z(N);
    for (int i = 0; i < N; ++i) Z[Y[i].second] = i;
    
    for (int i = 0; i < N; ++i) {
        if (Z[i] < N / 2) std::cout << Y[N / 2].first << std::endl;
        else std::cout << Y[N / 2 - 1].first << std::endl;
    }
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
vector <string> v;
vector<int> x;
string s;
string ans = "Left";
int main(){
  int a,b,c,d;

  cin >> a>>b>>c>>d;

  if((a+b)<(c+d))ans = "Right";
  else if((a+b)  == (c+d))ans = "Balanced";

  cout << ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	print(a*b / 2);




	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

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

    string str;

    cin >> str;

    vector<vector<int>> vec(26);

    for(int i = 0; i < str.size(); i++){
        char c = str[i];
        int t = (int)(c - 'a');
        vec[t].push_back(i+1);
    }

    bool frag = true;
    int l,r;

    for(int i = 0; i < 26 && frag ; i++){
        for(int j = 1; j < vec[i].size() && frag; j++){
            if(vec[i][j] - vec[i][j-1] <= 2){
                l = vec[i][j-1];
                r = vec[i][j];
                frag = false;
            }
        }
    }

    if(frag){
        cout << "-1 -1\n";
    }else{
        cout << l << " ";
        cout << r << "\n";
    }

    
    return 0;
}

Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,N;
  cin >> K >> N;
  int A[N+1];
  for(int i=0;i<N;i++)cin >> A[i];
  int max_length=0;
  A[N]=A[0]+K;
  for(int i=0;i<N;i++){
    max_length=max(max_length,A[i+1]-A[i]);
  }
  cout << K-max_length << endl;
}


Measured memory_bytes: 1024
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}


int main(){
    init();

    string s;
    cin>>s;
    ll ans=0;
    for(int i=0;i<(1<<((int)s.size()-1));i++){
        ll num=0;
        ll a=(s[0]-'0');
        for(int j=0;j<(int)s.size()-1;j++){
            if((i>>j)&1){
                //+の処理
                num+=a;
                a=(s[j+1]-'0');
            }else{
                a*=10;
                a+=(s[j+1]-'0');
            }
        }
        num+=a;
        ans+=num;
    }
    cout<<ans<<endl;
}

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

int main()
{
	char n[3] = {0};
	int i = 0;
	scanf("%s",n);
	for(i = 0; i < 3; i++) {
		if(n[i] == '1') {
			n[i] = '9';
		} else if (n[i] == '9' ) {
			n[i] = '1';
		} else {
			//
		}
	}
	printf("%s\n",n);
	return 0;
}



Measured memory_bytes: 128
#template
def inputlist(): return [int(j) for j in input().split()]
#template

def pow_k(a,n,mod):
    if n == 0:
        return 1
    if n % 2 ==0:
        return pow_k(a*a % mod,n//2,mod)
    else:
        return a * pow_k(a,n-1,mod) % mod
def modinv(a, mod):
    return pow(a, mod-2, mod)
def combination_list(n, mod):
    lst = [1]
    for i in range(1, k+1):
        lst.append(lst[-1] * (n+1-i) % mod * modinv(i, mod) % mod)
    return lst
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res
def chofuku_cmb(n, r, mod=10**9+7):
    return combination(n+r-1, r, mod)

S = int(input())
mod = 10**9+7
if S < 3:
    print(0)
    exit()
N = S // 3
d = S % 3
ans = 0
for i in range(N):
    if i != 0:
        d += 3
    tmp = chofuku_cmb(N-i,d,mod)
    ans += tmp
    ans %= mod
ans %= mod
print(ans)

Measured memory_bytes: 73272
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
int main()
{
     string s;
     while(getline(cin,s)){
         for(int i=0;i<s.size();i++){
               if('a'<=s[i] && s[i]<='z')
                      s[i]=s[i]-'a'+'A';
         }
         cout<<s<<endl;
    }
}

Measured memory_bytes: 1172
N=int(input())
btoa=0
enda=0
startb=0
ab=0
for i in range(N):
	buf=input()
	if buf[0]=="B" and buf[-1]=="A":
		btoa+=1
	elif buf[-1]=="A":
		enda+=1
	elif buf[0]=="B":
		startb+=1
	ab+=buf.count("AB")
if btoa>=1:
	res=ab+btoa-1
	if enda!=0 or startb!=0:
		enda+=1
		startb+=1
		print(res+min(enda,startb))
	else:
		print(res)
else:
	print(ab+min(enda,startb))

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

namespace AtCoder.Abc
{
    class A_170_FiveVariables
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            for (int i = 0; i < inputLongArray.Length; i++)
            {
                if (inputLongArray[i] == 0)
                {
                    Console.WriteLine(i + 1);
                    break;
                }
            }
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28208
#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;
int main(){
  int n;
  while( cin >> n,n ){
    int ansm = 1000000000;
    int ansM = 0;
    for(int i = 0 ; i < n ; i++){
      int sum = 0;
      for(int j = 0 ; j < 5 ; j++){
	int a;
	cin >> a;
	sum+=a;
      }
      if(ansm > sum)ansm = sum;
      if(ansM < sum)ansM = sum;
    }
    cout << ansM << ' ' << ansm << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <cctype>

using namespace std;

typedef string::const_iterator state;

int expression(state &begin);
int number(state &begin);

int number(state &begin){
	int ans=0;
	while(1){
		if(isdigit(*begin)){
			ans *=10;
			ans += *begin -'0';
			begin++;
		}else{
			break;
		}
	}
	return ans;
}

int expression(state &begin){
	begin++;
	int ans = 0;
	if(isdigit(*begin)){
		ans = (number(begin)+1)/2;
	}else{
		vector<int> v;
		while(1){
			if(*begin==']')break;
			v.push_back(expression(begin));
		}
		sort(v.begin(),v.end());
		for(int i=0;i<=v.size()/2;i++){
			ans += v[i];
		}
	}
	begin++;
	return ans;
}

int main(){
	int n;
	string s;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s;
		state k = s.begin();
		cout << expression(k) << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
function *main() {
  const N = +(yield);
  
  let sum = 0;
  for (let k = 1; k <= N; k++)
    sum += Math.floor(k * Math.floor(1+N/k) * Math.floor(N/k) / 2);
  
  console.log(sum);
}
const iter = main();
iter.next();
require("readline").createInterface({input: process.stdin}).on("line", line => iter.next(line));


Measured memory_bytes: 33804
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long x = sc.nextLong();
		
		long a = (Math.floorDiv(x, 11))* 2;
		long b = x % 11;
		
		if(b > 6) {
			a += 2;
		}
		else if(b > 0 && b <= 6) {
			a++;
		}
		
		System.out.println(a);
	}

}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int N;
int p[100005];

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

	cin >> N;

	for (int i = 1;i <= N;i++){
		cin >> p[i];
	}

	int ans = 0;
	bool flag = false;

	for (int i = 1;i <= N;i++){
		if(p[i] == i){
			if(flag){flag = false; continue;}
			flag = true;
			ans++;
		}else{
			flag = false;
		}
	}

	cout << ans << endl;

	return 0;

}


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

int main() {
  int n;
  cin >> n;
  int h[n];
  int i, j, k;
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }

  int num[n] = {};


  int count = 0;
  for (i = 0; i < n; i++) {
    int temp = h[i];
    for (j = 0; j < temp; j++) {
      count++;
      for (k = i; k < n; k++) {
        if (h[k] == 0) {
          break;
        }

        h[k]--;
      }

      //count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = in.nextInt();
        int[] A = new int[N];
        for (int n = 0; n < N; n++)
            A[n] = in.nextInt();

        long sum = 0;
        int max = 0;
        for (int i : A) {
            if (max <= i) {
                max = i;
            } else {
                sum += max - i;
            }
        }
        out.println(sum);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}


Measured memory_bytes: 62344
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    lint mod = 1e9 + 7;
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<lint>> dp(2, vector<lint>(n + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        // 0->0
        if (s[i] == '1') {
            dp[0][i + 1] += (dp[0][i] * 2) % mod;
            dp[0][i + 1] %= mod;
        } else {
            dp[0][i + 1] += dp[0][i];
            dp[0][i + 1] %= mod;
        }
        // 0->1
        if (s[i] == '1') {
            dp[1][i + 1] += dp[0][i];
            dp[1][i + 1] %= mod;
        }
        // 1->1
        dp[1][i + 1] += dp[1][i] * 3;
        dp[1][i + 1] %= mod;
    }
    cout << (dp[0][n] + dp[1][n]) % mod << endl;
}

Measured memory_bytes: 2816
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC112D
int compare_int(const void *a, const void *b) { //sort
  return *(int*) a-*(int*) b;
}
int main(void) {
  int n, m, k=0, i, memo[1000];
  scanf(" %d %d", &n, &m);
  for(i=sqrt(m); i>=1; i--) if(m%i==0) memo[k++ ]=i, memo[k++ ]=m/i;
  qsort(memo, k, sizeof(int), compare_int); //sort
  while(memo[--k]>=n);
  printf("%d", m/memo[k+1]);
  return 0;
}

Measured memory_bytes: 128