akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

S = list(sys.stdin.readline().rstrip())
ans = 'Yes'

for i in range(len(S)):
    if((i+1)%2 == 1):
        if(S[i] == 'L'):
            ans = 'No'
    elif((i+1)%2 == 0):
        if(S[i] == 'R'):
            ans = 'No'

print(ans)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    ll a[n];
    priority_queue<int>q;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        q.push(a[i]);
    }
    for(int i=0;i<m;i++)
    {
        ll x=q.top();
        q.pop();
        x/=2;
        q.push(x);
    }
    ll sum=0;
    while(q.size())
    {
        sum+=q.top();
        q.pop();
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 4532
#include <iostream>
using namespace std;
int n, M=1e9+7; string s;
int main() {
    cin >> n >> s;
    for(int i = 0; i < n*2; i+=2) s[i] = (s[i]=='B' ? 'W' : 'B');

    long A=1, L=0, R=0;
    for(int i=0; i < n*2; ++i) {
        if(s[i]=='W') L++;
        else A = A*(L - R++)%M;
    }
    if(L!=R || s[0]=='B' || s[n*2-1]=='W') { cout << 0; return 0; }

    for(; n>1; A = A*n%M, --n);
    cout << A;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N, K; cin >> N >> K;
    K = min(K, 100);
    vector<int> A(N + 1, 0); FOR(i, 1, N + 1) cin >> A[i];
    REP(i, K) {
        vector<int> tmp(N + 1, 0);
        FOR(i, 1, N + 1) {
            int d = A[i];
            int b = (i - d < 0) ? 0 : i - d;
            tmp[b]++;
            if (i + d + 1 <= N) {
                int e = i + d + 1;
                tmp[e]--;
            }
        }
        A[0] = tmp[0];
        FOR(i, 1, N + 1) {
            A[i] = A[i - 1] + tmp[i];
        }
    }
    FOR(i, 1, N + 1) {
        cout << A[i] << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 5008
K, Q = map(int, input().split())
D = list(map(int, input().split()))
query = []
for i in range(Q):
    query.append(tuple(map(int, input().split())))


for n, x, m in query:
    Dmod = [d % m for d in D]
    equal = (n - 1) // K * sum(d == 0 for d in Dmod) + sum(d == 0 for d in Dmod[:((n - 1) % K)])

    a0 = x
    an = x + sum(Dmod) * ((n - 1) // K) + sum(Dmod[:((n - 1) % K)])
    small = an // m - a0 // m

    ans = (n - 1) - equal - small
    print(ans)


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

int main(){

  string s;
  cin>>s;
  int n;
  n=int(s.size());
  
  int answer=753;
  
  for (int i=0;i<=n-3;i++){
    int tmp;
    int a,b,c;
    a=int(s.at(i)-'0');
    b=int(s.at(i+1)-'0');
    c=int(s.at(i+2)-'0');
    tmp=100*a+10*b+c;
    
    answer=min(answer,abs(753-tmp));
  }
  
  cout<<answer<<endl;
    
  
}
  













Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
	long long N;
	cin>>N;
	map<long long,long long> A; 
	long long x;
	long long i;
	map<long long,long long>::iterator mit;
	for (i=0;i<N;i++){
		cin>>x;
		mit=A.find(x);
		if (mit!=A.end()){
			(*mit).second++;
		}else{
			A.insert(map<long long,long long>::value_type(x,1));
		}
	}
	long long y=0;
	long long num2=0;
	for (mit=A.begin();mit!=A.end();mit++){
		x=(*mit).second;
		if (x%2==0){
			(*mit).second = 2;
			num2++;
		}else{
			(*mit).second=1;
		}
	}
	if (num2%2==0){
		cout<<A.size()<<endl;
	}else{
		cout<<A.size()-1<<endl;
	}

	A.clear();
	return 0;
}

Measured memory_bytes: 6528
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Problems 1157
Problem A: ICPC 得点集計ソフトウェア
"""
while True:
    n = int(input())
    if  n == 0:
        break
    sum, s_min, s_max = 0, 1001, -1
    for i in range(n):
        score = int(input())
        s_min = min(s_min, score)
        s_max = max(s_max, score)
        sum += score
    print((sum-s_min-s_max)//(n-2))



Measured memory_bytes: 5612
#include<stdio.h>

int main(void){
	long long int red=0,blue=0,high=0,lengh=0,deeper=0;
	scanf("%lld %lld  %lld",&high,&lengh,&deeper);
	
	if(high<=lengh){
		if(lengh<=deeper){
			red=high*lengh*(deeper/2+deeper%2);
			blue=high*lengh*(deeper/2);
		}
		else{
			red=high*(lengh/2+lengh%2)*deeper;
			blue=high*(lengh/2)*deeper;
		}
	}
	else if(high<=deeper){
		if(deeper<=lengh){
			red=high*(lengh/2+lengh%2)*deeper;
			blue=high*(lengh/2)*deeper;
		}
		else{
			red=high*lengh*(deeper/2+deeper%2);
			blue=high*lengh*(deeper/2);
		}
	}
	else{
		if(deeper<=high){
			red=(high/2+high%2)*lengh*deeper;
			blue=(high/2)*lengh*deeper;
		}
		else{
			red=high*lengh*(deeper/2+deeper%2);
			blue=high*lengh*(deeper/2);
		}
	}
	
	printf("%lld\n",red-blue);
	
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <deque>
#include <math.h>
#include <map>
#include <bitset>
#include <queue>
#include <list>
#include <utility>

//#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using p = pair<int, int>;
using Graph = vector<vector<int>>;
#define rep(i,n)  for(int i = 0; i < n ; i++)
int dx[4]{ -1,0,1,0 };
int dy[4]{ 0,1,0,-1 };

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int d = min(a, min(b,c));
	int e = max(a, max(b, c));
	if (e - d == a || e - d == b || e - d == c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;

int main(void){
	
	int a[3];

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

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			if (a[j] > a[j + 1])
				swap(a[j], a[j + 1]);
		}
	}

	for (int i = 0; i < 3; i++) {
		if (i != 0)
			cout << ' ' << a[i];
		else
			cout << a[i];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 3076
using System;

public class Program{
    public static void Main(){
        string[] s = Console.ReadLine().Split(' ');
        int time = int.Parse(s[0]);
        int criterialDistance = int.Parse(s[1]);
        int pointNum = 0;
        
        for (int i = 0; i < time; i++) {
            string[] coordinates = Console.ReadLine().Split(' ');
            int x = int.Parse(coordinates[0]);
            int y = int.Parse(coordinates[1]);
            double pointDistance = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
            
            if (pointDistance <= criterialDistance) {
                pointNum++;
            }
        }
        Console.WriteLine(pointNum);
    }
}

Measured memory_bytes: 45920
import sys

N,K = map(int, input().split())
res = 0
if K==0:
    print(N*N)
    sys.exit(0)
for i in range(N):
    i += 1
    if i-K<=0:
        continue
    amari = N % i
    amari = amari - K + 1
    re = N // i
    if amari <= 0:
        amari = 0
    res += re*(i-K) + amari
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,i,n) lower_bound(v.begin()+i,v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mod 998244353
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
vector<l> fact(l n)
{
	vector<l> v;
	for(l i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			v.pb(i);
		}
	}
	return v;
}
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a)%mod;
		}
		b>>=1;
		a=(a%mod*a%mod)%mod;
	}
	return ans;
}//prefixsums
void frooty()
{
	l a[5];
	l ans=0;
	for(l i=0;i<5;i++)
	{
		cin>>a[i];
		if(a[i]==0)
			ans=i+1;
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
	//cin>>q;
	while(q--)
	{
		frooty();
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	ll n;string s,t;
	cin>>n>>s>>t;
	ll ans=0;
	for(ll i=0;i<n;i++){
		if(s==t){
			break;
		}
		ans++;
		s.erase(s.begin()+0);
		t.pop_back();
	}
	cout << 2*n-(n-ans);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
A,B,C,D=map(int,input().strip().split())

fin=False
while fin==False:
    C-=B
    if C<=0:
        fin=True
        win="t"
    else:
        A-=D
        if A<=0:
            fin=True
            win="a"
        else:
            pass

if win=="t":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
#include <stdio.h>
#include <cmath>
#include <algorithm>

int main(){
	int n,k,S,max,count;

	while(true){
		scanf("%d %d",&n,&k);
		if(n == 0 && k == 0)break;
		max = -1000000001;
		S = 0;
		count = 0;
		int array[n];
		for(int i = 0; i < n; i++){
			scanf("%d",&array[i]);
			count++;
			if(count == k){
				S += array[i];
				max = (max >= S)?max:S;
			}else if(count >  k){
				S -= array[i-k];
				S += array[i];
				max = (max >= S)?max:S;
			}else{
				S += array[i];
			}
		}
		printf("%d\n",max);
	}

	return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    string s;
    cin >> s;
    int g = 0, p = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'p') p++;
        else g++;
    }
    cout << (g-p) / 2 << endl;
    return 0;
}

Measured memory_bytes: 512
/**
* Copyright(c)
* All rights reserved.
* Author : zzy
* Date : 2020-04-12-20.06.59
*/
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <limits.h>
#include <string>
#include <iostream>
#include <queue>
#include <math.h>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <iterator>
#include <list>
#include <cstdio>
#include <iomanip>
#include <climits>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

i64 pref[300][300];
i64 k;
i64 ans = 0;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    for (int i = 1; i <= 200; ++i) {
        for (int j = 1; j <= 200; ++j) {
            pref[i][j] = __gcd(i, j);
        }
    }
    cin >> k;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            int temp = pref[i][j];
            for (int o = 1; o <= k; ++o) {
                ans += pref[temp][o];
            }
        }
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 4120
#include <stdio.h>
#include <ctype.h>

int main(){
    int i, alpha[26];
    char ch;

    for(i = 0; i < 26; i++)alpha[i] = 0;

    while(1){
        ch = getchar();
        if(ch == EOF)break;

        if(isalpha(ch)){
            if(isupper(ch))alpha[ch - 65]++;
            else alpha[ch - 97]++;
        }
    }

    ch = 'a';
    for(i = 0; i < 26; i++, ch++){
        printf("%c : %d\n", ch, alpha[i]);
    }
}


Measured memory_bytes: 2060
s = gets.chomp.chars
t = gets.chomp.chars

table = {}
s.each.with_index do |ch, i|
  table[ch] = [] unless table[ch]
  table[ch].push(i)
end

i = -1
loop_count = 0
pos = -1
t.each do |ch|
  unless table[ch]
    puts '-1'
    exit 0
  end
  j = table[ch].bsearch { |j| j > i }
  unless j
    j = table[ch][0]
    loop_count += 1
  end
  i = j
  pos = loop_count * s.size + j + 1
end
puts pos


Measured memory_bytes: 13308
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    ll n, k; cin >> n >> k;
    int ans = 0;
    while(n > 0) {
        n /= k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

int gcd(int a,int b){
    if (a%b==0) return(b);
    else return(gcd(b,a%b));
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    
    rep(i, n) cin >> a[i];
    
    int tmp_gcd = a[0];
    rep(i, n) {
        tmp_gcd = gcd(tmp_gcd, a[i]);
    }
    cout << tmp_gcd << endl;

    return 0;
    
}


Measured memory_bytes: 640
// 2020-08-26 17:04:14
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
const int MX = 1010;
void answer() {
  int n, k;
  cin >> n >> k;
  vector<vector<int> > b(k + 1, vector<int>(2 * k + 1, 0));
  vector<vector<int> > w(k + 1, vector<int>(2 * k + 1, 0));
  rep(i, n) {
    int x, y;
    char c;
    cin >> y >> x >> c;
    int xd = 0;
    if (((x / k) + (y / k)) % 2) xd = k;
    if (c == 'B') {
      b[y % k + 1][x % k + xd + 1] += 1;
    } else {
      w[y % k + 1][x % k + xd + 1] += 1;
    }
  }
  rep(i, k) rep(j, 2 * k) {
    b[i + 1][j + 1] += b[i][j + 1] + b[i + 1][j] - b[i][j];
    w[i + 1][j + 1] += w[i][j + 1] + w[i + 1][j] - w[i][j];
  }
  auto sum = [&](const vector<vector<int> >& v, int ni, int nj) {
    int mi = ni - k, mj = nj - k;
    chmin(ni, k);
    chmin(nj, 2 * k);
    chmax(mi, 0);
    chmax(mj, 0);
    return v[ni][nj] - v[ni][mj] - v[mi][nj] + v[mi][mj];
  };
  int ans = 0;
  rep(_, 2) {
    repc(i, k) repc(j, k) {
      int now = 0;
      now += sum(w, i, j);
      now += sum(w, i, j + k + k);
      now += sum(w, i + k, j + k);
      now += sum(b, i, j + k);
      now += sum(b, i + k, j);
      now += sum(b, i + k, j + k + k);
      chmax(ans, now);
    }
    swap(w, b);
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 19012
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
  
int main() {
  int n;cin>>n;
  int no;
  char mark;
  int card[4][14];
  for(int m=0;m<4;m++){
  	for(int i=1;i<=13;i++){
    	card[m][i]=0;
	  }
  }

   
  for(int i=0;i<n;i++){
    cin>>mark>>no;
    if(mark=='S') card[0][no]=1;
    if(mark=='H') card[1][no]=1;
    if(mark=='C') card[2][no]=1;
    if(mark=='D') card[3][no]=1;
  }
  
  for(int m=0;m<4;m++){
  	for(int i=1;i<=13;i++){
    	if(card[m][i]==1) continue;
    	if(m==0) cout<<'S'<<" "<<i<<endl;
    	if(m==1) cout<<'H'<<" "<<i<<endl;
      	if(m==2) cout<<'C'<<" "<<i<<endl;
      	if(m==3) cout<<'D'<<" "<<i<<endl;
  }
  }
}
 


Measured memory_bytes: 3124
#include <cstdio>
#include <iostream>

using namespace std;

const int MAXN = 110;
const int MAXK = 100010;
const int MOD = 1e9+7;

int n, k, a[MAXN];
int f[MAXN][MAXK];

inline int sum(int i, int l, int r)
{
	if(!l) return f[i][r];
	else return (f[i][r] - f[i][l-1] + MOD) % MOD;
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	f[0][0] = 1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=k;j++){
//			for(int l=min(0, j-a[i]);l<=j;l++){
//				f[i][j] = (f[i][j] + f[i-1][l])%MOD;
//			}
			f[i][j] = sum(i-1, max(0, j-a[i]), j);
		}
		for(int j=1;j<=k;j++)
			f[i][j] = (f[i][j-1] + f[i][j]) % MOD;
	}
	printf("%d\n",f[n][k]);
	return 0;
}

Measured memory_bytes: 40832
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int w = Integer.parseInt(scanner.nextLine());
        int n = Integer.parseInt(scanner.nextLine());
        int a[] = new int[n];
        int b[] = new int[n];
        int z[] = new int[w];
        for (int i = 0; i < n; i++) {
            String s = scanner.nextLine();
            String t[] = s.split(",");
            a[i] = Integer.parseInt(t[0]);
            b[i] = Integer.parseInt(t[1]);
        }
        for (int i = 0; i < w; i++) {
            int p = i + 1;
            for (int j = 0; j < n; j++) {
                if (p == a[j]) {
                    p = b[j];
                } else if (p == b[j]) {
                    p = a[j];
                }
            }
            z[p-1] = i + 1;
        }
        for (int i = 0; i < w; i++) {
            System.out.println(z[i]);
        }
    }
}


Measured memory_bytes: 25876
s = gets.strip

words = ['dream', 'dreamer', 'erase', 'eraser']

until s.empty? do
  reduced = false
  words.map do |w|
    if s[-w.size, w.size] == w
      s = s[0..-w.size-1]
      reduced = true
      break
    end
  end

  unless reduced
    puts 'NO'
    exit 0
  end
end

puts 'YES'

Measured memory_bytes: 56256
import math
a, b, C = map(float, input().split())
print('%f' %(a * b * math.sin(math.pi * C / 180.0) / 2))
print('%f' %(a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.pi * C / 180.0))))
print(('%f' %(b * math.sin(math.pi * C / 180.0) )))

Measured memory_bytes: 7840
N, M = list(map(int, input().split()))
SC = [list(map(int, input().split())) for _ in range(M)]
ans = [0] * N
used = []
for i in range(M):
  if(ans[SC[i][0] - 1] != SC[i][1] and SC[i][0] in used):
    print(-1)
    break
  elif(SC[i][0] == 1 and SC[i][1] == 0 and N != 1):
    print(-1)
    break
  else:
    ans[SC[i][0] - 1] = SC[i][1]
    used.append(SC[i][0])
else:
  if(ans[0] == 0 and N != 1):
    ans[0] = 1
  print(''.join([str(n) for n in ans]))

Measured memory_bytes: 3064
#include<iostream>
#include<list>
#include<string>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
using namespace std;
int main(){
	int n,m,k,f,c; string b1,b2;
	while(cin>>n,n){
		map<string,int> cost;
		map<string,list<string> > recipe;
		rep(i,n)cin>>b1>>c,cost[b1]=c;
		cin>>m; rep(i,m){
			cin>>b1>>k;
			list<string> r;
			rep(j,k)cin>>b2,r.push_back(b2);
			recipe[b1]=r;
		}
		f=0; __typeof(recipe.begin()) p;
		while(!f){
			f=1;
			foreach(i,cost)if((p=recipe.find(i->first))!=recipe.end()){
				c=0;
				foreach(j,p->second)c+=cost[*j];
				if(c<i->second)i->second=c,f=0;
			}
		}
		cin>>b1;
		cout<<cost[b1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll H,W,N;
  cin>>H>>W>>N;
  map<pair<ll,ll>,ll> L;
  REP(n,N){
    ll A,B;
    cin>>A>>B;
    for(ll i=A-2; i<=A; ++i){
      for(ll j=B-2; j<=B; ++j){
        L[MP(i,j)]++;
      }
    }
  }
  
  ll ANS[10],cnt=0;
  REP(i,10) ANS[i]=0;
  FORE(v,L){
    if(1<=v.first.first && v.first.first<=H-2 && 1<=v.first.second && v.first.second<=W-2){
      ANS[v.second]++;
      cnt++;
    }
  }
  
  ANS[0]=(H-2)*(W-2)-cnt;
  REP(i,10) cout<<ANS[i]<<endl;
  return 0;
}

Measured memory_bytes: 59876
#include <stdio.h>
typedef long long ll;
int min(int x, int y) { return x < y ? x : y; }
int main() {
	int n;
	ll cnt = 0, Rcnt = 0, Gcnt = 0, Bcnt = 0;
	char s[4001];
	scanf("%d%s", &n, s);
	for (int i = 0; i < n; i++) {
		switch (s[i]) {
			case 'R':
				Rcnt++;
				break;
			case 'G':
				Gcnt++;
				break;
			case 'B':
				Bcnt++;
				break;
			default:
				break;
		}
	}
	cnt = Rcnt * Gcnt * Bcnt;
	for (int i = 1; i < n - 1; i++) {
		for (int j = 1; j <= min(i, n - i - 1); j++) {
			if (s[i - j] != s[i + j] && s[i - j] != s[i] && s[i + j] != s[i]) {
				cnt--;
			}
		}
	}
	printf("%lld\n", cnt);
	return 0;
}

Measured memory_bytes: 1740
N = input()
S = raw_input()

opened = 0
min_opened = 0
for c in S:
    if c == '(' :
        opened += 1
    else:
        opened -= 1
        min_opened = min(opened, min_opened)

closed = 0
min_closed = 0
for c in S[::-1]:
    if c == ')' :
        closed += 1
    else:
        closed -= 1
        min_closed = min(closed, min_closed)

op = '(' * -min_opened if min_opened < 0 else ''
cl = ')' * -min_closed if min_closed < 0 else ''
print op + S + cl


Measured memory_bytes: 2568
#include<iostream>
#include<string>
using namespace std;
 
int main() {
	string s;
	int count = 0;
	cin >> s;
 
	for (int i = 0; i < s.length()-1; i++) {
		if (s[i] != s[i + 1]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
main(){

	int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
	if(a!=b&&a!=c&&b!=c)
	{
	printf("3");
	}
	else if(a==b&&a!=c||a==c&&a!=b||b==c&&c!=a)
	{
	printf("2");
	}
	else{printf("1");}
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(100000)

n, m=map(int, input().split())
a=[0 for i in range(m)]
b=[0 for i in range(m)]
g=[list() for i in range(1+n)]
#print(g)

par=[i for i in range(n)]
cnt_con=[1 for i in range(n)]

def root(x):
    if x==par[x]:
        return x
    else:
        par[x]=root(par[x])
        return par[x]
def connect(x,y):
    #par[x]=root(x)
    #par[y]=root(y)
    if root(x)==root(y):
        0
    else:
        cnt_con[root(y)]+=cnt_con[root(x)]
        par[root(x)]=root(y)      
    return

for i in range(m):
    a[i], b[i]=map(int, input().split())
    a[i], b[i]=a[i]-1, b[i]-1


tmp=int(n*(n-1)/2)
ans=[0]*m
ans[-1]=tmp
#ans[0]=0
#print('a,b=',a,b)
for i in range(m-1,-1,-1):
    ans[i]=tmp
    if root(a[i])==root(b[i]):
        0
    else:
        tmp-=cnt_con[root(a[i])]*cnt_con[root(b[i])]
    connect(a[i],b[i])
    #print('i,tmp',i,(a[i],b[i]),ans[i],tmp,par,cnt_con)
    

    
for i in range(m):
    print(ans[i])



Measured memory_bytes: 344988
x = int(input())

if x==1:
    print(0,-1);exit()

num_li = [i**5 for i in range(1,1000)]

for i in range(1000):
    a = num_li[i]
    if x-a in num_li:
        b = num_li.index(x-a)+1
        a = -(num_li.index(a)+1)
        break
    if x+a in num_li:
        b = num_li.index(x+a)+1
        a = num_li.index(a)+1
        break

print(b,a)

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

using namespace std;

typedef int in;
#define int long long

in main(){
    int n,m,k,ans;
    cin >> n >> m >> k;
    cout << (ans = n * k - m) << endl;
    for(int i = 1 ; i < 10 ; i ++){
        ans = n * ans - m;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
	//入力機構
	unsigned long long n,m;
	long long d;//intなら2*(10^9)程度なら表現できる
	std::cin>>n>>m>>d;


	//処理機構
	//平均を求めれば良い、即ち隣り合う数字の差がdになる組み合わせの総数を求めればよい
	//数字の並び方も全通りある
	//(ちがう)1からnまでの数字を2つ選んだ時に、差の絶対値がdである順列の総数を求めてm-1倍すれば良さげ。m>=2なのでいける。
	//(ちがう?)隣り合う2つの数字が総数に与える影響は、1からnまでの数字を2つ選んだ時に、差の絶対値がdである順列の総数を求めて、その2つの数字以外の組み合わせ数n^(m-2)をかけてあげれば求まる。それをm-1倍すれば総数が求まるはず。m>=2なのでいける。
	//平均化する時はn^mで割れば良い。ここが一番厳しいかも。数値誤差が出るからdoubleを用いる
	//まとめると、pairnum*(m-1)*(n^(m-2))/(n^m)=pairnum*(m-1)/(n^2)
	double ans;
	//順列の総数は(n-d)*2で求められる。ただしd==0だと、(a,b)と(b,a)を別の順列として見れないから*2しない場合分けする。
	//size_t pairnum=n-d;
	unsigned long long pairnum=n-d;
	if(d!=0){
		pairnum*=2;
	}
/*
	//const size_t total=pairnum*(m-1);//これだと余裕でオーバーフローする
	ans=pairnum*(m-1);//違うやり方
	//平均化
	for(size_t i=0;i<m;i++){
		ans/=n;
	}
//*/
	//ans=pairnum*(m-1)/n/n;//double化されていない
	//ans=((double)pairnum)*(m-1)/n/n;//精度が足りない？
	unsigned long long a=((unsigned long long)pairnum)*(m-1),b=((unsigned long long)n)*n;
	double aa=a,bb=b;
	double ansa=aa/bb;
	ans=((double)a)/b;
	//出力機構
	//std::cout<<ans<<std::endl;
	printf("%.10f",ans);

	return 0;
}



Measured memory_bytes: 256
a, b, k = map(int, input().split())
if b-a > pow(10, 5):
    list_ANS = [i for i in range(a, a+pow(10, 5))] + [i for i in range(b - pow(10, 5), b+1)]
else:
    list_ANS = [i for i in range(a, b+1)]

for _ in range(k):
    if len(list_ANS) != 0:
        a = list_ANS.pop(0)
        print(a)
    else:
        break
list_A = []
for _ in range(k):
    if len(list_ANS) != 0:
        b = list_ANS.pop(-1)
        list_A.append(b)

    else:
        break
if len(list_A) != 0:
    list_A.reverse()
    for i in list_A:
        print(i)

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


#define INF (1<<31)-1
#define LINF (1LL<<63)-1LL
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin>>n;

    vector<int> l(2*n);
    rep(i,2*n){
        cin>>l[i];
    }

    sort(all(l),greater<int>());

    rep(i,2*n){
        ans += l[i+1];
        ++i;
    }

    cout<<ans<<endl;
    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 3616
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    X,Y=mis()
    for a in range(1000):
        for b in range(1000):
            if a+b==X and 2*a+4*b==Y:
                print(Yes)
                return
    print(No)

main()



Measured memory_bytes: 9988
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
#include<set>

using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;

#define MOD 1000000007



int main()
{
  string S;
  cin >> S;
  ll N = S.size();

  ll ans = (N*(N-1))/2+1;
  ll count[26];
  REP(i,0,26){
    count[i] = 0;
  }
  REP(i,0,N){
    count[S[i] - 'a']++;
  }
  REP(i,0,26){
    if(count[i]>=2){
    ans -= (count[i] * (count[i] - 1)) / 2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr bool isPrime(const int &n) {
  if (n == 1) return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}

void solve() {
  int n;
  while (cin >> n) {
    int l = n - 1, r = n + 1;
    while (!isPrime(l)) l--;
    while (!isPrime(r)) r++;
    cout << l << ' ' << r << endl;
  }
}

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

int main()
{
    int n;
    cin >> n;
    int arr[100];
    for(int i=0;i<=100;i++)
    arr[i]=0;
    long long int ans=0;
    if(n<10)
    cout << n << endl;
    else
    {
        for(int i=10;i<=n;i++)
        {
            int f=i/pow(10,(int)log10(i));
            int l=i%10;
            if(f==l)
            ans+=3;
            if(l!=0)
            {
                ans+=arr[f*10+l]*2;
                arr[l*10+f]+=1;
            }
        }
        cout << ans+9 << endl;
    }
    //
    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  int N; cin >> N;
  vector<int> X(N); vector<int> Y(N);
  for(int i = 0; i < N; i++){cin >> X[i] >> Y[i];}
  
  if( N == 1){ cout << 1 << endl; return 0;}
  
  map<pair<int,int>, int > mp;
  
  for(int i = 0; i < N ; i++){
    for(int j = 0; j < N; j++){
      if( i == j){ continue;}
      int a = X[j] - X[i]; int  b = Y[j] - Y[i];
      mp[make_pair( a, b)]++;}}
  
  int res = 0;
  
  for( auto ne : mp){
    res = max( res, ne.second);}
  
  cout << N - res << endl; return 0;}
      
      

Measured memory_bytes: 384
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 12, 2020 07:40:30 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  D = [int(input()) for _ in range(N)]

  print(len(set(D)))


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 9168
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn usize() -> usize {
    read()
}

fn vec_usize(n: usize) -> Vec<usize> {
    let mut vec = Vec::new();
    for _ in 0..n {
        vec.push(usize())
    }
    vec
}

fn main() {
    let n = usize();
    let ls = vec_usize(n).into_iter();

    let max = ls.clone().max().unwrap();
    let sum: usize = ls.clone().sum();

    if max * 2 < sum {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

const int MAX = 1001000;

int main() {
	bool is_p[MAX] = {0};
	for ( int i = 2; i < MAX; i++ ) {
		for ( int j = 2; j*i < MAX; j++ ) {
			is_p[i*j] = true;
		}
	}

	vector<int> p;	
	for ( int i = 2; i < MAX; i++ ) {
		if ( !is_p[i] ) p.push_back(i);
	}
		
	int N, P;
	while ( cin >> N >> P, N != -1 ) {
		vector<int> v;
		int id = upper_bound(p.begin(), p.end(), N)-p.begin();
		//cout << p[id] << endl;
		for ( int i = id; i < id+110; i++ ) {			
			for ( int j = i; j < id+110; j++ ) {
				v.push_back(p[i]+p[j]);
			}
		}
		sort(v.begin(), v.end());
		cout << v[P-1] << endl;
	}

	return 0;
}



Measured memory_bytes: 4228
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    string s,t;
    cin>>s>>t;
    int c=0;
    for(int i=0;s[i];i++)
    {
        if(s[i]==t[i])
            c++;
    }
    cout<<c<<endl;



}
//Alhamdulillah










Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

vector <int> v,a;

int main() {
    
    string s;
    cin >> s;
    string a;
    a = "keyence";
    if(s.substr(0,a.length()) == a){
        cout << "YES" << endl;
    }else if (s.substr(s.length()-a.length(), a.length()) == a){
        cout << "YES" << endl;
    }else{
        int posts;
        for (int i=0;i<s.length();i++){
            if(s[i] != a[i]){
                posts = i;
                break;
            }
        }
        if(s.substr(s.length() - a.length() + posts, a.length() - posts) == a.substr(posts, a.length() - posts)){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}




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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

double query(int l, int r, vector<double>& acc){
    if(l - 1 < 0) return acc[r];
    return acc[r] - acc[l-1];
}

int main(){
    fcin;

    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    for(int& i : a) cin >> i;

    vector<double> exp(n);

    for(int i = 0; i < n; i++) exp[i] = (1 + a[i]) / 2.0;

    vector<double> acc(n, 0);
    acc[0] = exp[0];
    for(int i = 1; i < n; i++) acc[i] = acc[i-1] + exp[i];

    double ans = 0.0;
    for(int i = 0; i < n - k + 1; i++){
        double sum = query(i, i + k - 1, acc);
        ans = max(ans, sum);
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}



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

namespace ConsoleApp42
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] pos =Console.ReadLine().Split(' ');
            int W = int.Parse(pos[0]);
            int a = int.Parse(pos[1]);
            int b = int.Parse(pos[2]);

            if ((a+W)< b)
            {
                int answer1 = b - (a + W);
                Console.WriteLine(answer1);
            }else if ((b+W)< a)
            {
                int answer2 = a - (b + W);
                Console.WriteLine(answer2);
            }else if (a<=b && b<=(a+W) ||a<=(b+W) && b+W<=(a+W))
            {
                Console.WriteLine(0);
            }
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
a = list(map(int, input().split()))

ans = 0
nonleaf_nodes = []
current = 1

for depth in range(0, n+1):
    c = current-a[depth]
    if c < 0: # 目いっぱい頂点を増やしても葉が足りない
        print(-1)
        exit()
    nonleaf_nodes.append(c)
    current = c*2
nonleaf_nodes[-1]=0

ans = a[-1]
for depth in range(n-1, -1, -1):
    nonleaf_nodes[depth] = min(nonleaf_nodes[depth], nonleaf_nodes[depth+1]+a[depth+1])
    ans += nonleaf_nodes[depth] + a[depth]
print(ans)



    

Measured memory_bytes: 673584
import sys
input = sys.stdin.readline

def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

def main():
    n = int(input())
    A = list(map(int, input().split()))
    i = partition(A, 0, n-1)
    for j in range(n):
        if j:
            print(' ', end='')
        if j == i:
            print('[', end='')
        print(A[j], end='')
        if j == i:
            print(']', end='')
    print()
if __name__ == '__main__': main()


Measured memory_bytes: 15596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int A,B,C,K;cin>>A>>B>>C>>K;
  int i=0;
  while(A>=B){
    B*=2;
    i++;
  }
  while(B>=C){
    C*=2;
    i++;
  }
  if(i<=K)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const ll MOD = 998244353;

ll p[200005], p2[200005];

ll powMod(ll n, ll p, ll mod) {
	ll res = 1;
	while (p) {
		if (p & 1) (res *= n) %= mod;
		(n *= n) %= mod;
		p >>= 1;
	}
	return res;
}

ll invMod(ll n, ll mod) {
	return powMod(n, mod - 2, mod);
}

ll fact[200005], invFact[200005];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    p[0] = 1;
    fact[0] = 1;
    invFact[0] = 1;
    ll n, m, k;
    cin >> n >> m >> k;
    for(ll i=1; i<=n; i++)
    {
        p[i] = (p[i-1] * (m-1))%MOD;
        fact[i] = (fact[i-1] * i) % MOD;
        invFact[i] = (invFact[i-1] * invMod(i, MOD))%MOD;
    }
    ll ans = 0;
    for(ll comp = n-k; comp <= n; comp++)
    {
        ll t = p[comp-1];
        t = (t * m) % MOD;
        t = (t * fact[n-1]) % MOD;
        t = (t * invFact[comp-1]) % MOD;
        t = (t * invFact[n - comp]) % MOD;
        ans = (ans + t) % MOD;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8300
def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
    c = 0
    for x in a:
        c += -(-x//arg) - 1
    return c <= k

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n,k = map(int,input().split())
a = list(map(int,input().split()))
print(meguru_bisect(0,10**9+1))

Measured memory_bytes: 31164
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , h , c = 0 , d = 0;
    cin >> n >> h;
    int a[n] , b[n];
    for( int i = 0 ; i < n ; i++ ) {
        cin >> a[i] >> b[i];
        d = max( d , a[i] );
    }
    sort( b , b + n );
    for ( int i = n - 1 ; i >= 0 ; i-- ) {
        if ( b[i] < d ) break;
        h -= b[i];
        c++;
        if ( h <= 0 ) {
            cout << c;
            return 0;
        }
    }
    cout << c + (h - 1) / d + 1;
}


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

int main(void){
  int N, K;
  string S;
  cin >> N >> K >> S;
  if(S[K - 1] == 'A') S[K - 1] = 'a';
  if(S[K - 1] == 'B') S[K - 1] = 'b';
  if(S[K - 1] == 'C') S[K - 1] = 'c';
  cout << S;
  
  return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
takahashi_attack = c // b
aoki_attack = a // d
if c % b != 0:
    takahashi_attack += 1
if a % d != 0:
    aoki_attack += 1
if takahashi_attack <= aoki_attack:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9156
#include<iostream>
#include<algorithm>
using namespace std;
int N;
long A[2<<17];
long dp[2<<17][3];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<=N;i++)for(int j=0;j<3;j++)dp[i][j]=-9e18;
	dp[0][0]=0;
	for(int i=0;i<N;i++)for(int j=0;j<3;j++)
	{
		if(dp[i][j]<-1e18)continue;
		dp[min(i+2,N)][j+(i+2==N)]=max(dp[min(i+2,N)][j+(i+2==N)],dp[i][j]+A[i]);
		if(j<2)dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]);
	}
	cout<<dp[N][N%2?2:1]<<endl;
}

Measured memory_bytes: 9836
#include <iostream>
#include <vector>

using namespace std;
const int MAX = 7368791+1;

int main(){
    while(1){
        int m,n;
        cin >> m >> n;

        if(n==0) break;

        vector<bool> v(MAX,false);
        int count=0;

        for(int i=m; ; i++){
            if(count<n){
                if(!v[i]){
                    for(int j=i; j<MAX; j+=i){
                        v[j]=true;
                    }
                    count++;
                }
            }else{
                if(!v[i]){
                    cout << i << endl;
                    break;
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3984