akhauriyash/Code-Regression huggingface dataset:
/*****************************************************

Code by: Vichitr
Compiled On: 23rd March 2019

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf pop_front
#define mp make_pair
#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ip pair<int, int>
#define N 100007
const ll MOD = 1e9+7;
const ll SZ = 107;


signed main()
{
    fast;

    int n, W;
    cin>>n>>W;
    int w[n+5], v[n+5];
    for(int i=0;i<n;i++) cin>>w[i]>>v[i];
    int dp[n+5][W+1];
    for(int i=0;i<=n;i++)
    {
        for(int j = 0;j<=W;j++)
        {
            if(i==0 or j==0)
                dp[i][j] = 0;
            else if(w[i-1]<=j)
                dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]], dp[i-1][j]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    int ans = dp[n][W];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 80256
#include<stdio.h>
 
int main()
{
  int t[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v;

      
    
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",t[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}

Measured memory_bytes: 612
while True:
    a, op, b = input().split()
    if op == "?":
        break
    elif op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    elif op == "/":
        print(int(a) // int(b))




Measured memory_bytes: 5592
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M = map(int, readline().split())
A = list(map(int, readline().split())) + [0]
B = list(map(int, readline().split())) + [0]
mod = 10 ** 9 + 7
A.sort()
B.sort()
row = 0  # ある数字を書き込むことが可能な行の数
col = 0
available = 0
s = N * M
answer = 1
for i in range(N * M, 0, -1):
    if i == A[-1] == B[-1]:
        available += row + col  # i以下の数字が使用可能な行と列が一つ増える
        row += 1
        col += 1
        A.pop()
        B.pop()
    elif i == A[-1]:
        available += col - 1
        answer = answer * col % mod
        row += 1
        A.pop()
    elif i == B[-1]:
        available += row - 1
        answer = answer * row % mod
        col += 1
        B.pop()
    else:
        if available == 0:
            print(0)
            exit()
        answer = answer * available % mod
        available -= 1

print(answer)


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

using namespace std;

class D3
{
public:
	double x;
	double y;
	double z;

	//?????????????????????
	D3 ( double x_ = 0.0 , double y_ = 0.0 , double z_ = 0.0 )
	{
		x = x_;
		y = y_;
		z = z_;
	}

	//??????
	D3 Cross_product ( D3 partner )
	{
		D3 ret ( y*partner.z - z*partner.y , z*partner.x - x*partner.z , x*partner.y - y*partner.x );
		return ret;
	}

	//??????
	double Inner_product ( D3 partner )
	{
		return x*partner.x + y*partner.y + z*partner.z;
	}

	//?????????????????????????????????
	D3 Make_vector ( D3 partner )
	{
		D3 ret ( partner.x - x , partner.y - y , partner.z - z );
		return ret;
	}

	//???????§????2????????????????????¢???????±???????
	double S_vec ( D3 A , D3 B )
	{
		D3 G;
		G = A.Cross_product ( B );
		return sqrt ( G.Inner_product ( G ) ) / 2;
	}

	//??????????????¢???????±???????
	double S_point ( D3 A , D3 B , D3 C )
	{
		return S_vec ( A.Make_vector ( B ) , A.Make_vector ( C ) );
	}

	//???????§????3????????????????????????????±???????
	double V_vec ( D3 A , D3 B , D3 C )
	{
		D3 G;
		G = A.Cross_product ( B );
		return G.Inner_product ( C ) / 6;
	}

	//4???????????????????±???????
	double V_point ( D3 A , D3 B , D3 C , D3 D )
	{
		return V_vec ( A.Make_vector ( B ) , A.Make_vector ( C ) , A.Make_vector ( D ) );
	}

	D3 operator+( D3 partner )
	{
		return D3 ( x + partner.x , y + partner.y , z + partner.z );
	}

	D3 operator-( D3 partner )
	{
		return D3 ( x - partner.x , y - partner.y , z - partner.z );
	}

	D3 operator*( D3 partner )
	{
		return D3 ( x * partner.x , y * partner.y , z * partner.z );
	}

	D3 operator/( D3 partner )
	{
		return D3 ( x / partner.x , y / partner.y , z / partner.z );
	}

	D3 operator*( double d )
	{
		return D3 ( x * d , y * d , z * d );
	}

	D3 operator/( double d )
	{
		return D3 ( x / d , y / d , z / d );
	}

	bool operator==( D3 partner )
	{
		return x == partner.x&&y == partner.y&&z == partner.z;
	}

	double length ()
	{
		return sqrt ( x*x + y*y + z*z );
	}

	//???????????????????????????
	//????????¨???
	D3 Unit_vec ()
	{
		return D3 ( *this ) / ( *this ).length ();
	}

	//????????????????????????
	D3 Inverse_vec ()
	{
		return D3 ( *this )*-1;
	}

	//?????´????????????
	bool Vertical ( D3 partner )
	{
		return ( *this ).Inner_product ( partner ) == 0;
	}

	//??????????????????
	bool Parallel ( D3 partner )
	{
		return ( *this ).Unit_vec () == partner.Unit_vec () || ( *this ).Unit_vec ().Inverse_vec () == partner.Unit_vec ();
	}

};

int main ()
{
	double x1 , y1 , x2 , y2 , x3 , y3 , xp , yp;
	while( cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp )
	{
		D3 X ( x1 , y1 ) , Y ( x2 , y2 ) , Z ( x3 , y3 ) , P ( xp , yp ) , calc;
		if( abs ( calc.S_point ( X , Y , Z ) - ( calc.S_point ( X , Y , P ) + calc.S_point ( X , Z , P ) + calc.S_point ( Z , Y , P ) ) ) < 1e-6 )
		{
			cout << "YES" << endl;
		} else
		{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1228
import java.io.IOException;
import java.util.Scanner;

/**
 * 挿入ソート
 * 
 *
 */

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

		int n = s.nextInt();
		
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = s.nextInt();
		}
		
		printArray(arr);
		insertionSort(arr, n);
	}
	
	public static void insertionSort(int[] arr, int n) {
		for (int i = 1; i < n; i++) {
			int v = arr[i];
			int j = i-1;
			while (j >= 0 && arr[j] > v) {
				arr[j+1] = arr[j];
				j--;
			}
			arr[j+1] = v;
			printArray(arr);
		}
	}
	
	public static void printArray(int[] arr) {
		String ans = "";
		for (int i = 0; i < arr.length; i++) {
			ans += arr[i] + " ";
		}
		System.out.println(ans.trim());
	}
}


Measured memory_bytes: 45676
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  n, req = map(int, input().split())
  stores = [tuple(map(int, input().split())) for _ in range(n)]
  stores.sort(key=lambda x: x[0])
  money = 0
  
  for p, c in stores:
    if req == 0:
      break
    
    c = min(c, req)
    
    money += c * p
    req -= c
  
  print(money)


if __name__ == '__main__':
  main()



Measured memory_bytes: 18132
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
	int n, k;
	cin >> n >> k;
	int w[n], d[n];
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> d[i];
	}
	int LPos = 0, RPos = 2 * LINF;

	auto Sum = [&](int Pos) {
		int Cnt = 0;
		for (int i = 0; i < n; i++) {
			if (w[i] <= Pos) Cnt += ((Pos - w[i]) / d[i]) + 1;
		}
		return Cnt >= k;
	};

	while (RPos - LPos > 1) {
		int Mid = (LPos + RPos) / 2;
		if (Sum(Mid)) RPos = Mid;
		else LPos = Mid;
	}
	cout << RPos << endl;
	return 0;
}

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

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var nums = new long[87];
        nums[0] = 2;
        nums[1] = 1;
        for(int i = 2; i <= 86; i++)
        {
            nums[i] = nums[i - 1] + nums[i - 2];
        }

        Console.WriteLine(nums[N]);
    }
}

Measured memory_bytes: 27472
a,b,k=map(int,input().split())
for i in range(k):
  if i%2==0:
    if a%2==1:
      a-=1
    b+=a//2
    a//=2
  else:
    if b%2==1:
      b-=1
    a+=b//2
    b//=2
print(a,b)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
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(){
  while(1){
	int a,b,c,x,n;
	int s[200];
	cin>>n>>a>>b>>c>>x;
	if(a==0&&b==0&&c==0&&n==0&&x==0)
	  break;
	REP(i,n){
	  cin>>s[i];
	}

	//cout << s[0] << endl;//

	int ransu = x;
	int count = 0;
	int m=0;
	while(1){
	  if(count > 10000){
		count = -1;
		break;
	  }
	  if(ransu == s[m]){
		m++;
	  }
	  if(m==n){
		break;
	  }
	  ransu = (a*ransu+b)%c;
	  count++;
	}  
	cout << count << endl;
  }

}

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

typedef long long ll;

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n; cin >> n;
	ll temp = 10, ans = 0;
	while (temp <= n) {
		ans += n/temp;
		temp *= 5;
	}
	cout << (n&1LL ? 0 : ans) << endl;
	return 0;
}

Measured memory_bytes: 384
n = int(input())
MAX_N = 10**6
dp = [MAX_N] * MAX_N
dp[0] = 0

for i in range(1,n+1):
  dp[i] = i
  if i >= 6:
    for j in range(1,10):
      if i - 6**j < 0 :
        break
      dp[i] = min(dp[i], dp[i-6**j] + 1)
    
  if i >= 9:
    for j in range(1,10):
      if i - 9**j < 0 :
        break
      dp[i] = min(dp[i], dp[i-9**j] + 1)
      
print(dp[n])      

Measured memory_bytes: 50284
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;

int N;
string S;

int main() {
	cin >> N >> S;
	vector<vector<pair<int, int> > > dp(N, vector<pair<int, int> > (N, make_pair(0, 0)));
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (S[i] == S[j]) {
				if (i > 0 && i != j - 1) {
					dp[i][j].first = dp[i - 1][j - 1].first + 1;
					dp[i][j].second = dp[i - 1][j - 1].second - 1;
				}
				else {
					dp[i][j].first = 1;
				}
				if (dp[i][j].first == 1) {
					dp[i][j].second = j - i - 1;
				}
				ans = max(ans, dp[i][j].first);
				if (dp[i][j].second == 0) {
					dp[i][j].first = 1;
					dp[i][j].second = j - i - 1;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 195840
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<numeric>
//#include <bits/stdc++.h>
#include<cstring>
#include<iostream>
#include<functional>
using namespace std;

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

	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];

	int AA, BB;
	AA = (N - 1) / (K - 1);
	BB = (N - 1) % (K - 1);

	if (BB != 0)
		cout << AA + 1 << endl;
	else
		cout << AA << endl;
	
	//cin >> N;

		return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

	cin >> k;

	if (k % 2 == 1)
	{
		cout << b - a << endl;
	}
	else {
		cout << a - b << endl;
	}
	/*rep(i, k)
	{
		cout << b + c << " " << a + c << " " << a + b << endl;
		ll worka = a, workb = b, workc = c;
		a = workb + workc;
		b = worka + workc;
		c = worka + workb;
	}*/
	return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  [l,r] <- map (read :: String -> Int) . words <$> getLine
  let r_ = mod r 2019
  let l_ = if r-l < 2019 then r_ - ((mod r 2019) - (mod l 2019)) else r_ - 2018
  print $ ans l_ r_
 
ans :: Int -> Int -> Int
ans m n = minimum [mod (i*j) 2019 | i <- [m..n], j <- [m..n], i < j]


Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int x;
	cin >> x;
	int a, b;
	cin >> a >> b;
	x -= a;
	while (x - b >= 0) {
		x -= b;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
N,A,B,C,D = map(int,input().split())
S = input()
clear = True

# A->CかB->Dどっちかの区間に##があったらfalse
# B<Cが保証されないから両方やる
if C<D:
    tmp_s = 0
    for s in S[A-1:C]:
        if s == '#' and tmp_s>0 :
            clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0

    tmp_s = 0
    for s in S[B-1:D]:
        if s == '#' and tmp_s>0 :
            clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0

    if clear == True:
        print('Yes')
    else:
        print('No')
    
# A<B<D<Cだから、AがBを追い抜くスペースが必要
# _B-D_の中に...があればOKっぽい
elif D<C:
    # とりま##の可能性を見る
    tmp_s = 0
    for s in S[A-1:C]:
        if s == '#' and tmp_s>0 :
            clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0
    # ...を探す
    if clear == True:
        tmp_s = 0
        tmp_d = 0
        clear = False
        for s in S[B-2:D+1]:
            if s == '.' and tmp_d>=2 : # ...
                tmp_s += 1
                clear = True
            elif s == '.' and tmp_s>=0: # #->.
                tmp_d += 1
                tmp_s = 0
            elif s == '#' and tmp_d>=0: # .->#
                tmp_s += 1
                tmp_d = 0
        if clear == True:
            print('Yes')
        else:  
            print('No')
    else:
        print('No')


Measured memory_bytes: 3700
import bisect
N=int(input())
A=sorted(map(int,input().split()))
B=sorted(map(int,input().split()))
C=sorted(map(int,input().split()))
x=[1 for _ in range(N)]
ans=0
for i in range(N):
        a=bisect.bisect_left(A,B[i]) 
        c=N-bisect.bisect_right(C,B[i])
        ans+=a*c
print(ans)

Measured memory_bytes: 23360
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
typedef array<int, 3>arr3;
void die(string s) { cout << s << endl; exit(0); }
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };


void solve() {
	ll X, Y; cin >> X >> Y;
	int ans = 0;
	while (X <= Y) {
		X *= 2;
		ans++;
	}
	print(ans);
}


signed main() {
	solve();
}



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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s.substr(2,1)==s.substr(3,1) && s.substr(4,1)==s.substr(5,1)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    tmp, i, p = 0, 1, 0
    while True:
        p = (p * 10 + 7) % K
        if not p:
            print(i)
            break
        i += 1


Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main(){
	int N,L;
	cin >> N >> L;
	int sum = (L-1)*N + N*(N+1)/2;
	//cout << sum << endl;

	int ans;

	if (L<= -N)
	{
		ans = sum - (L+N-1);
	}
	else if(L >= 1){
		ans = sum -L;
	}
	else{
		ans = sum;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using PL = pair<ll,ll>;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
constexpr int INF = (1 << 29);
constexpr ll INF_ = (1LL << 58);
constexpr ld EPS = (1e-10);
constexpr ld PI_ = 3.141592653589793238;//46264338327950288
constexpr ld E_ = 2.71828182845904523;//5360287471352
constexpr ll MOD = 1000000007;
//// functions (integer)_________________________________
ll modpow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a % m;
		a = a * a%m; n >>= 1;
	}
	return res;
}
long long modinv(long long a, long long p, long long mod){
  return modpow(a,p-2,mod);
}
////-----------------------------------------------------



int main(){
  int N;vector<ll> A; set<ll>P; map<ll,ll> B;
  cin >> N;
  RPT(i,0,N){
    ll a; cin >> a;
    A.push_back(a);
  }
  sort(A.begin(),A.end());

  FOR(i,2,1000003){
    bool ynprime = true;
    for(auto x : P){
      if(i % x == 0){ ynprime = false; break; }
      if( x*x > i ) break;
    }
    if(ynprime) P.insert(i);
  }

  RPT(i,0,N){
    ll ttl = A[i];
    set<ll>::iterator it = P.find(A[i]);
    if(it!=P.end()){
      ttl = 1;
      if(B[A[i]]<1) B[A[i]] = 1;
    }
    for(auto x : P){
      ll cnt = 0;
      if(x > A[i] || ttl == 1) break;
      while(ttl % x == 0){
        ttl /= x;
        cnt++;
      }
      if(cnt){
        if(B[x]<cnt) B[x] = cnt;
      }
    }
    if(ttl != 1) {
      P.insert(A[i]);
      B[A[i]] = 1;
    }
  }

  ll L=1, Ainv = 0;
  for(auto x : P){
    L = ((L * (modpow(x,B[x],MOD))%MOD)) % MOD;
  }
  RPT(i,0,N){
    Ainv = (Ainv + ((modpow(A[i],MOD-2,MOD)%MOD)%MOD) ) % MOD;
  }
  ll ans = (Ainv * L) % MOD;
  //ll ans = (Ainv % MOD);
  cout << ans << endl; 
  //cout << L << endl << Ainv << endl;for(auto x: P) if(B[x]) cout << x << "^" << B[x] << " ";
  return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
	using u64 = std::uint_fast64_t;

public:
	u64 a;

	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};

using i64 = std::int64_t;
constexpr i64 Mod = 1e9 + 7;

modint<Mod> fact[3000000];

int main() {
	fact[0] = 1;
	for (int i = 1; i < 3000000; ++i)
		fact[i] = fact[i - 1] * i;

	i64 X, Y;
	std::cin >> X >> Y;

	const i64 s = (-X + 2 * Y) / 3;
	const i64 t = (2 * X - Y) / 3;

	if ((-X + 2 * Y) % 3 != 0 || (2 * X - Y) % 3 != 0 || s < 0 || t < 0)
		std::cout << 0 << std::endl;
	else
		std::cout << (fact[s + t] / (fact[s] * fact[t])).value() << std::endl;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
    ll n;cin >> n;
    vvl f(n,vl(10));
    vvl p(n,vl(11));
    rep(i,n){
        rep(j,10){
            cin >> f[i][j];
        }
    }
    rep(i,n){
        rep(j,11){
            cin >> p[i][j];
        }
    }
    ll ans=-inf;
    for(int bit=1;bit<(1<<10);bit++){
        ll price=0;
        rep(i,n){
            ll count=0;
            rep(j,10){
                if((bit&1<<j)!=0&&f[i][9-j]==1)count++;
            }
            price+=p[i][count];
        }
        ans=max(ans,price);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n;
    cin >> n;
    cout << n/3 << endl;

    return 0;
}


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

namespace ITP1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            //3つの整数a,b.cを読み込み、a<b<cならYes、そうでなければNoを出力する

            string[] x = Console.ReadLine().Split();
            int a = int.Parse(x[0]);
            int b = int.Parse(x[1]);
            int c = int.Parse(x[2]);

            if (a<b && b<c)
            {
                Console.WriteLine("Yes");
            }

            //if (a < b)
            //{
            //    if (b<c)
            //    {
            //        Console.WriteLine("Yes");
            //    }
            //    else
            //    {
            //        Console.WriteLine("No");
            //    }
            //}
            else
            {
                Console.WriteLine("No");
            }

            Console.ReadKey();
        }
    }
}



Measured memory_bytes: 15956
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn gcd(a : usize, b: usize) -> usize {
    if b > a {
        return gcd(b, a);
    }
    if a % b == 0 {
        return b;
    }
    gcd(b, a % b)
}

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize,
    }
    let cd = c * d / gcd(c, d);
    let a_div_c = (a - 1) / c;
    let a_div_d = (a - 1) / d;
    let a_div_cd = (a - 1) / cd;
    let b_div_c = b / c;
    let b_div_d = b / d;
    let b_div_cd = b / cd;
    println!("{}", (b - b_div_c - b_div_d + b_div_cd) - (a - 1 - a_div_c - a_div_d + a_div_cd));
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<numeric>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int N,X;

signed main(){
	cin>>N>>X;
	if(X==1||X==2*N-1){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
		list<int> L(2*N-1);
		iota(L.begin(),L.end(),1);
		L.remove(X-1);
		L.remove(X);
		L.remove(X+1);
		auto itr=L.begin();
		advance(itr,N-2);
		L.insert(itr,X-1);
		L.insert(itr,X);
		L.insert(itr,X+1);
		for(auto x:L){
			cout<<x<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 7808
/*
 * @Author: Patchouli_ 
 * @Date: 2020-02-09 20:23:47 
 * @Last Modified by:   Patchouli_ 
 * @Last Modified time: 2020-02-09 20:23:47 
 */
#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int ret=0,pos=1;char c=getchar();
    while(!isdigit(c) && c!='-' )c=getchar();
    if(c=='-')	pos=-1,c=getchar();
    while(isdigit(c))ret=(ret<<3)+(ret<<1)+c-48,c=getchar();
    return pos*ret;
}
string str;
signed main(){
	cin>>str;
	for(int i=str.length();i>=1;--i) cout<<'x';
}

Measured memory_bytes: 256
c1, c2, c3 = map(int, input().split())
c4, c5, c6 = map(int, input().split())
c7, c8, c9 = map(int, input().split())

frag = 0
x = c4 - c1
y = c5 - c2
z = c6 - c3
if x != y or y != z:
    frag = 1
x = c4 - c7
y = c5 - c8
z = c6 - c9
if x != y or y != z:
    frag = 1
x = c2 - c1
y = c5 - c4
z = c8 - c7
if x != y or y != z:
    frag = 1
x = c2 - c3
y = c5 - c6
z = c8 - c9
if x != y or y != z:
    frag = 1
if frag == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2 - (y2 - y1) << ' ' << y2 + (x2 - x1) << ' '
		 << x1 - (y2 - y1) << ' ' << y1 + (x2 - x1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

unordered_map<long, set<pair<long, long>>> mp;  
unordered_map<long, bool> used;
map<long, long> result;

void rec(long current) {
  auto naibors = mp[current];
  for (auto it: naibors) {
    long node = it.first;
    long weight = it.second;
    if (used[node]) continue;
    result[node] = (result[current] + weight) % 2;
    used[node] = true;
    rec(node);
  }
}

int main(void) {
  long N;
  cin >> N;

  rep (i, N) {
    long u, v, w;
    cin >> u >> v >> w;
    mp[u].insert(make_pair(v, w));
    mp[v].insert(make_pair(u, w));
  }

  result[1] = 0;
  used[1] = true;
  rec(1);

  for (auto it: result) {
    cout << it.second << endl;
  }

  return 0;
}


Measured memory_bytes: 43940
n,m = gets.split.map &:to_i
cnt = Array.new(n,0)
m.times do
  a,b = gets.split.map &:to_i
  a -= 1
  b -= 1
  cnt[a] += 1
  cnt[b] += 1
end

if cnt.all?{|v|v.even?}
  puts "YES"
else
  puts "NO"
end



Measured memory_bytes: 2556
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	ll N, M;
	cin >> N >> M;
	ll res;
	if (N > 1 && M > 1) res = (N - 2)*(M - 2);
	else if (N > 1) res = N - 2;
	else if (M > 1) res = M - 2;
	else res = 1;
	cout << res << "\n";

	return 0;
}

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

using namespace std;
using i64 = long long int;
using P = pair<i64, i64>;

struct edge{
    i64 src, to, cost;
    edge(i64 to, i64 cost) : src(-1), to(to), cost(cost) {}
    edge(i64 src, i64 to, i64 cost) : src(src), to(to), cost(cost) {}
    bool operator <(const edge &u){
        return this->cost < u.cost;
    };
};

using Graph = vector<vector<edge>>;

const i64 INF = numeric_limits<i64>::max();

vector<i64> dijkstra(Graph G, i64 s){
    i64 n = G.size();
    vector<i64> dist(n, INF);
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(0, s);
    while(!que.empty()){
        P t = que.top(); que.pop();
        i64 cost = t.first, u = t.second;
        if(cost > dist[u]) continue;
        for(auto e : G[u]){
            i64 v = e.to;
            if(cost + e.cost < dist[v]){
                dist[v] = cost + e.cost;
                que.emplace(dist[v], v);
            }
        }
    }
    return dist;
}

int main(){
    i64 v, e, r;
    cin >> v >> e >> r;
    Graph G(v);
    for(i64 i = 0; i < e; ++i){
        i64 s, t, d;
        cin >> s >> t >> d;
        G[s].emplace_back(s, t, d);
    }
    auto dist = dijkstra(G, r);
    for(auto d: dist){
        if(d == INF) cout << "INF" << endl;
        else cout << d << endl;
    }
}


Measured memory_bytes: 39112
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,K;cin >> N >> K;
    double a = 1/(double)N;
    double res = 0;
    for(int i=1;i<=N;i++){
        int b = i,cnt=0;
        while(b<K){b*=2;cnt++;}
        res+=a*pow(0.5,cnt);
    }
    cout << fixed << setprecision(13) << res << endl;
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<vector>
using namespace std;
int main()
{
	int n,m;
	int *cnt;
	vector<int> num;
	scanf("%d %d",&n,&m);
	cnt = new int [n];
	for(int  i=0;i<n;i++)
	{
		int temp;
		scanf("%d",&temp);
		num.push_back(temp);
		cnt[i]=0;
	}
	for(int i=0;i<m;i++)
	{
		int temp;
		scanf("%d",&temp);
		for(int j=0;j<n;j++)
		{
			if(num[j]<=temp)
			{
				cnt[j]++;
				break;
			}
		}
	}
	int max=0;
	int ele=0;
	for(int i=0;i<n;i++){
		if(cnt[i]>max)
		{
			max = cnt[i];
			ele = i;
		}
	}
	printf("%d\n",ele+1);
	return 0;
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll INF=1e9+7;

int main()
{
 hs;
 ll r;
 cin>>r;
 ld ans=2*pi*r;
 cout <<fixed<<setprecision(20)<<ans<<"\n";
 return 0;

}


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

int main(){
    int n, x;
    cin >> n >> x;
    if (x == 1 || x == 2*n - 1) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        if (n == 2) {
            cout << 1 << endl;
            cout << 2 << endl;
            cout << 3 << endl;
            exit(0);
        }

        vector<int> ans(2*n);
        for (int i = 0; i < 2*n; i++) ans[i] = i;
        if (x!= n) {
            if (x != 2){
                swap(ans[n], ans[x]);
                swap(ans[1], ans[n-1]);
                swap(ans[2*n - 1], ans[n+1]);
                swap(ans[1], ans[n+2]);
            }
            else{
                swap(ans[n], ans[x]);
                swap(ans[1], ans[n+1]);
                swap(ans[2*n - 1], ans[n-1]);
            }
        }
        for (int i = 1; i < 2*n; i++) cout << ans[i] << endl;
    }
}


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

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

  map<char, int> mp;
  rep (i, n) {
    string s;
    cin >> s;

    map<char, int> tmp;

    for (auto c: s) tmp[c]++;

    if (i == 0) {
      for (auto c: s) mp[c]++;
      continue;
    }

    for (char c = 'a'; c <= 'z'; c++) {
      if (tmp[c] < mp[c]) mp[c] = tmp[c];
    }
  }

  vector<char> ans;
  for (char c = 'a'; c <= 'z'; c++) {
    rep (i, mp[c]) ans.push_back(c);
  }
  sort(ans.begin(), ans.end());

  rep (i, ans.size()) cout << ans[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll x,y;
    cin>>x>>y;
    ll ans=0;
    if((x>=0&&y>0)||(x<0&&y<=0)){
        if(x<=y) ans=abs(y-x);
        else ans+=abs(y-x)+2;
    }
    else ans=abs(abs(y)-abs(x))+1;
    cout<<ans;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, K;
  cin >> N >> K;
  vector<lint> H(N+2);
  FOR(i, 1, N+1) cin >> H[i];
  vector<vector<lint>> dp(N+2, vector<lint>(K+1, 1e18));
  dp[0][0] = 0;
  FOR(i, 1, N+2) REP(j, i) REP(k, K+1) {
    int delcnt = i - j - 1;
    if(k-delcnt >= 0) dp[i][k] = min(dp[i][k], dp[j][k-delcnt] + max(0LL, H[i]-H[j]));
  }
  cout << dp[N+1][K] << endl;
}

Measured memory_bytes: 3936
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;

typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

lint mod = 998244353;

lint pow(lint a, lint n){
    lint ans = 1;
    lint base = a;
    while(n>0){
        if (n%2) ans = ans*base%mod;
        n = n/2;
        base = base*base%mod;
    }
    return ans;
}

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



    lint n; cin>>n;
    vector<pll> rt(n);
    for (int i=0; i<n; ++i) cin>>rt[i].first>>rt[i].second;
    sort(rt.begin(), rt.end());

    vl last(n);
    stack<lint>  seg;

    last[n-1] = n-1;
    seg.push(n-1);
    for (int id = n-2; id >=0; --id){
        lint r = rt[id].first + rt[id].second;
        while(!seg.empty()){
            lint left = seg.top();
            if (r > rt[left].first){
                seg.pop();
            } else {
                break;
            }
        }
        lint rid = n-1;
        if (!seg.empty()){
            rid = seg.top() - 1;
        }
        seg.push(id);
        last[id] = rid;

    }

    vl ans(n+1, -1);
    ans[n] = 1;
    for (int i= n-1; i>=0; --i){
        ans[i] = ans[last[i]+1];
        ans[i] = (ans[i+1] + ans[i])%mod;
    }
    cout<<ans[0];

}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, d;
  cin >> n >> d;
  ll tmp = d*2+1;
  if (n % tmp == 0) cout << n/tmp << endl;
  else cout << n/tmp+1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = 1; i < (ll)(n); i++)
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法によるmod累乗計算
//a = 底、　n = 指数
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//nCa 
ll comb(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}


int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  int ans = h[0];
  REP(i,n){
    if(h[i] > h[i-1]){
      ans += h[i]-h[i-1];
    }
  }
  cout << ans <<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  char a = s.at(0), b = s.at(1), c = s.at(2), d = s.at(3);
  if(a == b && b == c) cout << "Yes" << endl;
  else if(b == c && c == d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

using ll = long long;

ll sum(ll l, ll r, ll len)
{
    ll f = r / 3 - l / 3;
    ll b = r / 5 - l / 5;
    ll fb = r / 15 - l / 15;
    ll other = ((r - l) - (f + b - fb)) * len;

    return other + (f + b - 2 * fb) * 4 + fb * 8;
}

ll c(ll x)
{
    ll p = 1, len = 1;
    ll res = 0;
    while (p * 10 <= x) {
        res += sum(p - 1, p * 10 - 1, len);
        len++;
        p *= 10;
    }
    res += sum(p - 1, x - 1, len);
    return res;
}

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

    if (n == 1) {
        cout << "12Fizz4BuzzFizz78Fiz" << endl;
        return 0;
    }

    ll l = 0, r = n;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (c(mid) < n) {
            l = mid;
        } else {
            r = mid;
        }
    }

    ll st = n - c(l);
    
    string s;
    for (ll i = l; i < l + 100; i++) {
        if (i % 15 == 0) {
            s += "FizzBuzz";
        } else if (i % 3 == 0) {
            s += "Fizz";
        } else if (i % 5 == 0) {
            s += "Buzz";
        } else {
            s += to_string(i);
        }
    }
    cout << s.substr(st - 1, 20) << endl;
    return 0;
}

Measured memory_bytes: 3252
#include "bits/stdc++.h"

using namespace std;

using ll = long long int;

int main(){
  ll n;
  cin>>n;
  ll a[10001],b[10001];
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  ll x=0,y=0;
  for(int i=0;i<n;++i){
    cin>>b[i];
    if(b[i]-a[i]>0)x+=(b[i]-a[i])/2;
    else y+=a[i]-b[i];
  }
  if(x>=y)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include<cstdio>
using namespace std;
typedef long long int ll;
static const int MAX_H = 1000;
static const int MAX_W = 1000;
static const ll MOD = 1000000007;

int H, W;
char field[MAX_H][MAX_W + 1];
ll memo[MAX_H][MAX_W];

int main(){
	scanf("%d %d", &H, &W);
	for(int i = 0; i < H; i++) scanf("%s", field[i]);
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(field[i][j] == '#') continue;
			if(i == 0 && j == 0) memo[i][j] = 1;
			else if(i == 0) memo[i][j] = memo[i][j - 1];
			else if(j == 0) memo[i][j] = memo[i - 1][j];
			else memo[i][j] = memo[i][j - 1] + memo[i - 1][j];
			memo[i][j] %= MOD;
		}
	}
	printf("%lld\n", memo[H - 1][W - 1]);
	return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
struct edge { int v, w; };
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;
const ll e18 = 1e18;

bool ok = true;

void dfs(int u, vector<vector<edge>>& G, vector<ll>& h) {
	for (edge e: G[u])
		if (h[e.v] == LLONG_MAX) {
			h[e.v] = h[u] + e.w;
			dfs(e.v, G, h);
		}
		else if (h[e.v] != h[u] + e.w) ok = false;
}

int main() {
	int N, M; cin >> N >> M;
	vector<vector<edge>> G(N);
	while (M--) {
		int u, v, w; scanf("%d%d%d", &u, &v, &w);
		u--, v--;
		G[u].pb({v, w}), G[v].pb({u, -w});
	}
	vector<ll> h(N, LLONG_MAX);
	rep(u, N) if (h[u] == LLONG_MAX) h[u] = 0, dfs(u, G, h);
	cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 13312
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;

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

long x[101];
int main() {
	int n,ans=0;
	string s;
	cin >> n;
	cin >> s;
	FOR(i,0, n) {
		int cnt = 0;
		string a, b;
		a = s.substr(0, i);
		b = s.substr(i);
		set<char>seta;
		set<char>setb;
		REP(i, a.length())seta.insert(a[i]);
		REP(i, b.length())setb.insert(b[i]);
		map<char, int>mp;
		for (auto x : seta)mp[x]++;
		for (auto x : setb)mp[x]++;
		for (auto x : mp)if (x.second > 1)cnt++;
		if (cnt > ans)ans = cnt;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve() {
	int ans = 700;
	string s; cin >> s;
	rep(i, s.size())if (s[i] == 'o')ans += 100;
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k, z = 1;
    cin >> n >> k;
    z = k;
    for (int i = 1; i < n; i++) z *= k - 1;
    cout << z;
}


Measured memory_bytes: 256