akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int r = 0;
	for (int i = 1; i <= n; i++) {
		int c = 0, tmp = i;
		for (int j = 0; j < 5; j++) c += tmp % 10, tmp /= 10;
		if (a <= c && c <= b) r += i;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
a=[]
for i in range(0,n):
  a.append(int(input()))
a.insert(0,-1)
res=0
index=1
for i in range(0,n):
  if a[index]==-1:
    res=-1
    break
  ti=a[index]
  a[index]=-1
  index=ti
  
  res=res+1

  if index==2:
    break
print(res)



Measured memory_bytes: 7084
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


int modpow(int a,int n,int m=mod)
{
	int ans=1;
	while(n)
	{
		if(n%2)
			ans=((long long)ans*a)%m;
		a=((long long)a*a)%m;
		n/=2;
	}
	return ans;
}

signed main()
{
	fio
	inp(n) inp(k)
	vector<int> ans(k+1);
	for(int i=k;i>=1;i--)
	{
		ans[i]+=modpow(k/i,n);
		ans[i]%=mod;
		for(int j=i*2;j<=k;j+=i)
		{
			ans[i]-=ans[j];
			ans[i]%=mod;
		}
	}
	int fans=0;
	for(int i=1;i<=k;i++)
	{
		fans+=(ans[i]*i)%mod;
		fans%=mod;
	}
	fans+=mod;
	fans%=mod;
	cout<<fans<<'\n';
	printclock;
}

Measured memory_bytes: 3992
N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得
ac = s.count("AC")
wa = s.count("WA")
tle = s.count("TLE")
re = s.count("RE")
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 16276
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF32		INT32_MAX
#define	INF64		INT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);


// main function
int main()
{
	ll A = 0;
	ll B = 0;
	ll K = 0;
	ll ans = 1;

	cin >> A >> B >> K;
	ll tmp = (A >= B) ? B : A;
	ll cnt = 0;
	for (ans = tmp; ans > 1; --ans ) {
		if (A % ans == 0 && B % ans == 0) {
			cnt++;
			if (cnt == K) break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 83333,mo=998244353;
int n,a,b,fac[N],ifac[N];char s[N],t[N];
int power(int a, int n){
	int res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;
		a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
int g[N],f[N],w[N],x[N],y[N];
inline void fft(int *a, int n, int tp){
	for(int i=1,j=0;i<n;i++){
		for(int k=n>>1;!((j^=k)&k);k>>=1);if(i<j)swap(a[i],a[j]);
	}
	for(int j=2;j<=n;j<<=1){
		w[0]=1;w[1]=power(3,(mo-1)/j);if(tp==-1)w[1]=power(w[1],mo-2);
		rep(i,2,(j>>1)-1)w[i]=1LL*w[i-1]*w[1]%mo;
		for(int k=0;k<n;k+=j)rep(i,0,(j>>1)-1){
			int x=a[k+i],y=1LL*a[k+i+(j>>1)]*w[i]%mo;
			a[k+i]=x+y<mo?x+y:x+y-mo;a[k+i+(j>>1)]=x-y>=0?x-y:x-y+mo;
		}
	}
}
inline void mul(int *_a, int *_b, int *c, int m){
	int n;for(n=1;n<=m+m;n<<=1);
	rep(i,0,m)x[i]=_a[i],y[i]=_b[i];rep(i,m+1,n-1)x[i]=y[i]=0;
	fft(x,n,1);fft(y,n,1);
	rep(i,0,n-1)x[i]=1LL*x[i]*y[i]%mo;
	fft(x,n,-1);int ni=power(n,mo-2);rep(i,0,n-1)c[i]=1LL*x[i]*ni%mo;
}
inline void solve(int n){
	if(!n){g[0]=1;return;}
	if(n==1){rep(i,0,b)g[i]=ifac[i+1];return;}
	if(n&1){
		solve(n-1);rep(i,0,b)f[i]=ifac[i+1];mul(g,f,g,b);
	}
	else{
		solve(n>>1);mul(g,g,g,b);
	}
}
int main() {
	scanf("%s%s",s+1,t+1);n=strlen(s+1);
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
	rep(i,1,n)a+=s[i]=='1'&&t[i]=='0',b+=s[i]=='1'&&t[i]=='1';
	/*f[0][0]=1;
	rep(i,1,a)rep(j,0,b)rep(k,0,j)
		f[i][j]=(f[i][j]+1LL*f[i-1][k]*fac[b-k]%mo*ifac[b-j]%mo*ifac[j-k+1])%mo;*/
	solve(a);rep(i,0,b)g[i]=1LL*g[i]*fac[b]%mo*ifac[b-i]%mo;
	
	ll res=0;rep(j,0,b)res+=1LL*g[j]*fac[b-j]%mo;res=res%mo*fac[a+b]%mo*fac[a]%mo;cout<<res;
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B;
	cin >> A >> B;

	cout << max({ A + B,A - B,A * B }) << endl;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x

        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

def solve(uf, except_list):
    ret = [0]
    for i in range(1, N + 1):
        ret.append(uf.size(i) - 1 - len(except_list[i]))
    return ret

if __name__ == '__main__':
    N, M, K = map(int, input().split())
    except_list = [[] for _ in range(N + 1)]
    uf = UnionFind(N + 1)

    for _ in range(M):
        a, b = map(int, input().split())
        except_list[a].append(b)
        except_list[b].append(a)
        uf.union(a, b)

    for _ in range(K):
        c, d = map(int, input().split())
        if not uf.same(c, d):
            continue
        except_list[c].append(d)
        except_list[d].append(c)

    for ans in solve(uf, except_list)[1:]:
        print(ans, end=' ')

Measured memory_bytes: 115940
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw3(15,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,14) pw3[i]=3*pw3[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    ll now=A[0];
    ll situ=0;
    
    ll ans=1;
    FOR(i,1,N){
        if(situ==0){
            if(now<A[i]) situ=1;
            else if(A[i]<now) situ=2;
        }
        else if(situ==1){
            if(now<A[i]){}
            else if(A[i]<now){
                ans++;
                situ=0;
            }
        }
        else{
            if(now>A[i]){}
            else if(A[i]>now){
                ans++;
                situ=0;
            }
        }
        now=A[i];
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

int fact[10];

bool same(vector<int> a, vector<int> b) {
    int n = a.size();
    for (int i = 0; i < n; ++i) {
        if (a[i] != b[i]) {
            return false;
        }
    }
    return true;
}

int main() {

    FAST_IO;

    int n;
    cin >> n;

    vector<int> a(n), f(n), s(n);

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

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

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

    int r1, r2;
    for (int i = 0; i < fact[n]; ++i) {
        if (same(a, f)) {
            r1 = i + 1;
        }
        if (same(a, s)) {
            r2 = i + 1;
        }
        next_permutation(a.begin(), a.end());
    }
    
    cout << abs(r1 - r2) << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    P = list(map(int,input().split()))
    min_val = 2*10e5
    count = 1
    for i in range(1,N):
        if min_val > P[i-1]:
            min_val = P[i-1]
        if P[i] <= min_val:
            count += 1
    print(count)
if __name__ == '__main__':
    main()


Measured memory_bytes: 24744
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	var cnt int
	for i := 0; i < n; {
		l, r := i, i+1
		for r+1 < n && (a[r]-a[l])*(a[r+1]-a[r]) >= 0 {
			r++
		}
		cnt++
		i = r + 1
	}
	fmt.Print(cnt)
}


Measured memory_bytes: 3072
N, K = map(int, input().split())
mod = 10**9 + 7 
ans = 0 
for i in range(K, N + 2): 
        ans += (((N*(N + 1) // 2) - ((N - i)*(N - i + 1) // 2)) - ((i - 1)*i // 2) + 1) % mod 
print(ans % mod)

Measured memory_bytes: 63372
N = input()
D = map(int, raw_input().split())

cnt=0
lop=0

while lop<N-2:
  if max(D[lop],D[lop+1],D[lop+2])!=D[lop+1] and min(D[lop],D[lop+1],D[lop+2])!=D[lop+1]:
    cnt=cnt+1
  lop=lop+1
print (cnt)


Measured memory_bytes: 2568
def main():
    n, m = map(int, input().split())
    num_list = list(map(int, input().split()))

    vote_num = sum(num_list)

    count = 0

    for i in range(n):
        if vote_num * 1/(4*m) <= num_list[i]:
            count += 1

    print('Yes' if count >= m else 'No')

if __name__ == '__main__':
    main()

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

int X[505][505];
int C[505][505];

int main() {
    int N, M, Q; cin >> N >> M >> Q;
    vector<int> L(M), R(M);
    rep(i, M){
        cin >> L[i] >> R[i];
        X[L[i]][R[i]]++;
    }

    for (int i = 1; i <= N; i++){
        for (int j = 1; j <= N; j++){
            C[i][j] = C[i][j-1] + X[i][j];
        }
    }

    rep(k, Q){
        int p, q; cin >> p >> q;
        int ans = 0;
        for (int i = p; i <= q; i++){
            ans += C[i][q] - C[i][p-1];
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 6916
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    a, b = MS()
    A = a * int(b)
    B = b * int(a)

    if A <= B:
        print(A)
    else:
        print(B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()
{
    ll k;
    cin >> k;
    ll r = 0;
    ll result = -1;
    rep(i, k)
    {
        r = (r * 10 + 7) % k;
        if (r == 0)
        {
            result = i + 1;
            break;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3204
a1_1,a1_2,a1_3 = map(int,input().split())
a2_1,a2_2,a2_3 = map(int,input().split())
a3_1,a3_2,a3_3 = map(int,input().split())
n = int(input())
k = list(int(input()) for i in range(n)) 

if a1_1 in k and a1_2 in k and a1_3 in k :
  print("Yes")

elif a2_1 in k and a2_2 in k and a2_3 in k :
  print("Yes")

elif a3_1 in k and a3_2 in k and a3_3 in k :
  print("Yes")

elif a1_1 in k and a2_1 in k and a3_1 in k :
  print("Yes")

elif a1_2 in k and a2_2 in k and a3_2 in k :
  print("Yes")

elif a1_3 in k and a2_3 in k and a3_3 in k :
  print("Yes")

elif a1_1 in k and a2_2 in k and a3_3 in k :
  print("Yes")

elif a1_3 in k and a2_2 in k and a3_1 in k :
  print("Yes")

else : 
  print("No")

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

int main()
{
  int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i, n)
    cin >> a[i];
  rep(i, n)
    cin >> b[i];
  rep(i, n)
    cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  rep(i, n)
    ans += (lower_bound(a.begin(), a.end(), b[i]) - a.begin()) * (n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin()));
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int a, b, c, d, e, f, g, h, i; cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
    cout << (a - b == d - e && a - b == g - h && b - c == e - f && e - f == h - i && a - d == b - e && b - e == c - f && d - g == e - h && e - h == f - i ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanRunes()
	n := len(s)
	q := scanInt()
	ans := make([]rune,n+q*2)
	for i := 0; i < n; i++ {
		ans[i+q] = s[i]
	}
	l := q
	r := q+n-1
	now := true

	for i := 0; i < q; i++ {
		num := scanInt()
		if num == 1 {
			if now {
				now = false
			} else {
				now = true
			}
		} else {
			f := scanInt()
			c := scanRunes()
			if f == 1 {
				if now {
					l--
					ans[l] = c[0]
				} else {
					r++
					ans[r] = c[0]
				}
			} else {
				if now {
					r++
					ans[r] = c[0]
				} else {
					l--
					ans[l] = c[0]
				}
			}
		}
		// debug(string(ans),l,r,now)
	}

	ans = ans[l:r+1]
	for i := 0; i < len(ans); i++ {
		if now {
			// a[i] = ans[i]
			fmt.Fprint(wr, string(ans[i]))
		} else {
			// a[i] = ans[r-(i-l)]
			fmt.Fprint(wr, string(ans[len(ans)-1-i]))
		}
	}

	fmt.Fprintln(wr)
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(void){
    int n, m, l;
    cin >> n >> m >> l;
    int matrix1[n][m], matrix2[m][l];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> matrix1[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> matrix2[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            long sum = 0;
            for (int k = 0; k < m; k++) {
                sum += matrix1[i][k] * matrix2[k][j];
            }
            cout << sum;
            if (j < l-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  vector<int> w(N-1);
  rep(i,N)cin >> v[i];
  int sum = 0;
  rep(i,N){
    int x;cin >> x;
    sum += x;
  }
  rep(i,N-1)cin >> w[i];
  rep(i,N-1) if(v[i]+1 == v[i+1]) sum += w[v[i]-1];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		String ans = 500 * k >= x ? "Yes" : "No";
		System.out.println(ans);
		sc.close();
	}
}



Measured memory_bytes: 21712
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    string s,t;
    cin >> s >> t;
    int tsize = (int)t.length();
    int ssize = (int)s.length();
    
    string ssub[100];
    REP(i,ssize-tsize+1){
        ssub[i]=s.substr(i,tsize);
    }
    for(int i=ssize-tsize; i>=0; --i){
        bool ans = true;
        REP(j,tsize){
            if(ssub[i][j]!='?' && ssub[i][j]!=t[j]) ans = false;
        }
        if(ans){
            REP(j,tsize){
                s[i+j] = t[j];
            }
            REP(j,ssize){
                if(s[j]=='?') s[j]='a';
            }
            cout << s << ENT;
            return 0;
        }
    }
    
    cout << "UNRESTORABLE" << ENT;
    return 0;
}

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


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

using namespace std;

int main()
{
 	string s;
  	cin >> s;
  	sort(s.begin(), s.end());
  
  	if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
      	cout << "Yes\n";
  	else
      	cout << "No\n";
  
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int n; cin >> n;
    int k; cin >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    ll min = 1e18;
    for(int i=0; i+k<=n; i++) {
        if(min > a[i+k-1]-a[i]) min = a[i+k-1]-a[i];
    }
    cout << min;
}



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

int n;
using ll = long long;
ll a[2000010];
ll now1,now2;
ll ans;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++) now2+=a[i];
	now1+=a[1];
	now2-=a[1];
	ans=abs(now1-now2);
	for (int i=2;i<n;i++)
	{
		now1+=a[i];
		now2-=a[i];
		ans=min(ans,abs(now1-now2));
	}
	cout<<ans;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll mod=998244353;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


struct S{
    ll in,n0,sz;
};

struct F{
    ll cnt;
};


S e(){
    return {0,0,0};
}

F id(){
    return {0};
}

S op(S l, S r){
    ll lt = l.sz*(l.sz+1)/2 - l.in;
    ll rt = r.sz*(r.sz+1)/2 - r.in;
    ll nz = l.sz + r.sz;
    ll nn0 = l.n0 + r.n0;
    ll ni = nz*(nz+1)/2 - lt - rt - (r.sz-r.n0)*l.sz - r.n0*l.n0;
    return {ni, nn0, nz};
}

S mapping(F f, S x){
    if(f.cnt % 2 == 0) return x;
    ll T = x.sz*(x.sz+1)/2 - x.in;
    ll ni = T - x.n0*(x.n0+1)/2 - (x.sz-x.n0)*(x.sz-x.n0+1)/2;
    return {ni, x.sz-x.n0, x.sz};
}

F composition(F f, F node){
    return {f.cnt + node.cnt};
}


int main(){
    int n,q;cin >> n >> q;
    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        ll x;cin >> x;
        a[i] = {0, not x, 1};
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
    while(q--){
        int t,l,r;cin >> t >> l >> r;
        l--;
        if(t == 1){
            seg.apply(l, r, {1});
        }
        else{
            cout << seg.prod(l, r).in << endl;
        }
    }
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,l;
    cin >> n >> l;
    int32 ans = (l + l + n - 1) * n / 2;
    if(0 < l){
        ans -= l;
    }else if(l + n -1 < 0){
        ans -= l + n - 1;
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		char S[] = x.toCharArray();
		String y = sc.next();
		char T[] = y.toCharArray();
		int count = 0;
		for (int i = 0; i < 3; i++) {
			if(S[i] == T[i]) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 22996
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var c = Console.ReadLine().ToCharArray();
            Console.WriteLine(Convert.ToChar(Convert.ToByte(c[0]) + 1));
        }
    }
}


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

int main() {
    long a, b;
    cin>>a >>b;
    int count=1;
    while(b*count%a!=0){
        count++;
    }
    cout<<b*count<<endl;
}

Measured memory_bytes: 3640
def selectionSort(a, n)
  cnt = 0
  (0..n-1).each do |i|
    minj = i
    (i..n-1).each do |j|
      if a[j] < a[minj]
        minj = j
      end
    end
    if i != minj
      tmp = a[i]
      a[i] = a[minj]
      a[minj] = tmp
      cnt += 1
    end
  end
  puts a.join(' ')
  puts cnt
end

n = gets.to_i
a = gets.split.map(&:to_i)
selectionSort(a, n)


Measured memory_bytes: 6860
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int r;
    cin >> r;
    string ans = "AGC";
    if(r < 1200) ans = "ABC";
    else if(r < 2800) ans = "ARC";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 15
using namespace std;
int n,m,p[M],cnt[M];
vector<int> in[M];
int main()
{
    while (~scanf("%d %d", &n,&m)) {
        REP(i,1,m) {
            in[i].clear();
            int x,y;
            scanf("%d",&x);
            while (x--) {
                scanf("%d", &y);
                in[i].push_back(y);
            }
        }

        REP(i,1,m) scanf("%d", &p[i]);

        int ans = 0;
        REP(i,0,(1<<n)-1) {
            MSET(cnt,0);
            REP(j,1,m) for (int k:in[j]) if((1<<(k-1)) & i) cnt[j]++;
            int cc=0;
            REP(j,1,m) if(cnt[j]%2 == p[j]) cc++;
            if (cc==m) ans++;
        }
        printf("%d\n", ans);

    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    ll h, w, d;
    cin >> h >> w >> d;
    vector<vector<ll>> a(h, vector<ll>(w));
    map<ll, pair<ll, ll>> pos;
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
            pos[a[i][j]] = make_pair(i, j);
        }
    }
    vector<ll> dist(h * w + 1, 0);
    reps(i, d + 1, sz(dist)) {
        dist[i] = dist[i - d] + abs(pos[i].first - pos[i - d].first) + abs(pos[i].second - pos[i - d].second);
    }
    ll q;
    cin >> q;
    rep(i, q) {
        ll l, r;
        cin >> l >> r;
        cout << (dist[r] - dist[l]) << endl;
    }
    return 0;
}


Measured memory_bytes: 8192
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,l,r) for (int i=l; i<=r; i++)
typedef long long ll;
using namespace std;

const int N=200010;
int n,cnt,ans,a[N],p[N];

int main(){
	scanf("%d",&n); cnt=1;
	rep(i,1,n) scanf("%d",&a[i]),p[a[i]]=i;
	rep(i,2,n) if (p[i-1]<p[i]) cnt++; else ans=max(ans,cnt),cnt=1;
	printf("%d\n",n-max(ans,cnt));
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
#include <cstdio>
#include <iomanip>
using namespace std;

int main(void) {
	long long n, m, d;
	double x, y;
	cin >> n >> m >> d;
	x = (m - 1) * (n - d);
	y = n * n;
	if (d > 0) {
		x *= 2.0;
	}

	cout << setprecision(10) << x/y << endl;

	return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10 , inf = 2e9 + 10;
int n , c , K , a[N];

int main(){
  scanf("%d%d%d",&n,&c,&K);
  rep(i,0,n) scanf("%d",a+i);
  sort(a,a+n);
  int ans=0,sum=0,limit=inf;
  rep(i,0,n) {
    if(sum==c||a[i]>limit) {
      ans++;
      sum=0;
      limit=inf;
    }
    if(sum==0) limit=a[i]+K;
    sum++;
  }
  if(sum) ans++;
  printf("%d\n",ans);
  return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

bool is_Prime(int x){
  if(x < 2)return false;
  else if(x == 2) return true;
  for(ll i = 2; i*i <= x; i++) if(x%i == 0) return false;
  return true;
}
vl res;
vl prime;
ll n;

signed main()
{
  gearup;
  cin >> n;
  //素数格納
  for(int i=2;i<=55555;i++){
    if(is_Prime(i) && (i % 5) == 1)prime.push_back(i);
  }
  rep(i,n){
    if(i)cout << " ";
    cout << prime[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
def main():
    N, D = map(int, input().split())

    xs = []
    ys = []
    for i in range(N):
        X, Y = map(int, input().split())
        xs.append(X)
        ys.append(Y)

    c = 0
    for p, q in zip(xs, ys):
        if (p ** 2 + q ** 2) ** 0.5 <= D:
            c += 1

    print(c)


if __name__ == "__main__":
    main()


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

int main(){
	int n, q, query, x, t;
	
	cin>>n>>q;
	
	stack<int> sta[n];
	
	for(int i = 0; i < q; i++){
		cin>>query>>t;
		
		if(query == 0){
			cin>>x;
			sta[t].push(x);
		} else if(query == 1){
			if(!sta[t].empty())cout<<sta[t].top()<<endl;
		} else {
			if(!sta[t].empty())sta[t].pop();
		}
	}
	
	return 0;
}


Measured memory_bytes: 4256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0;


    cin>>n;
    int m=n;


    while(n!=0)
    {
        sum+=(n%10);
        n=n/10;
    }

    if(m%sum==0)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;

    return 0;


}


Measured memory_bytes: 764
N=input()

Data=[]
for i in range(N):
    Data.append(map(int,raw_input().split()))
    
Data.sort(key=lambda x:x[2], reverse=True)
for i in range(0,101):
    for j in range(0,101):
        H=Data[0][2]+abs(Data[0][0]-i)+abs(Data[0][1]-j)
        k=1
        while k<N:
            if (H-abs(Data[k][0]-i)-abs(Data[k][1]-j)<=0 and Data[k][2]==0)\
             or H==Data[k][2]+abs(Data[k][0]-i)+abs(Data[k][1]-j):
                k+=1
            else:
                break
        if k==N:
            print i,j,H
            exit()

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


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

  int N;
  cin >> N;
  map<pair<lint, lint>, pair<lint, lint>> mp;
  lint zero = 0;

  for (int i = 0; i < N; i++) {
    lint A, B;
    cin >> A >> B;
    if (A == 0 && B == 0) {
      zero++;
      continue;
    }
    if (A == 0) {
      mp[{0, 1}].first++;
      continue;
    }
    if (B == 0) {
      mp[{0, 1}].second++;
      continue;
    }
    lint g = __gcd(abs(A), abs(B));
    A /= g;
    B /= g;
    if (abs(A) == abs(B)) {
      if (A * B > 0) {
        mp[{1, 1}].first++;
      } else {
        mp[{1, 1}].second++;
      }
      continue;
    }
    int cur = 0;
    if (abs(A) > abs(B)) swap(A, B), A *= -1, cur = 1;
    if (B < 0) A *= -1, B *= -1;
    if (cur == 0) mp[{A, B}].first++;
    if (cur == 1) mp[{A, B}].second++;
  }

  const lint mod = 1e9 + 7;

  vector<lint> power(N + 1, 0);
  power[0] = 1;
  for (int i = 1; i <= N; i++) {
    power[i] = 2ll * power[i - 1] % mod;
  }

  lint ans = 1;
  for (auto i : mp) {
    // if (i.first.first == i.first.second) {
    //   ans *= i.second.first + 1;
    //   continue;
    // }
    // cout << i.second.first << " " << i.second.second << " a\n";
    ans *= power[i.second.first] + power[i.second.second] - 1;
    ans %= mod;
  }

  ans += zero;
  ans %= mod;

  ans--;
  ans += mod;
  ans %= mod;

  cout << ans << "\n";

}

Measured memory_bytes: 20356
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {

		FastScanner sc = new FastScanner();
		char n[] = sc.next().toCharArray();

		boolean result = true;
		for (int i = 0; i < n.length; i++) {
			if (n[i] == (((i + 1) % 2 == 0) ? 'R' : 'L')) {
				System.out.println("No");
				return;
			}
		}

		System.out.println(result ? "Yes" : "No");
	}
}

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 21076
N=int(input())
L=[]
for i in range(N):
  L.append(list(map(int,input().split())))
def distance(a,b):
  import math
  return math.sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
dist=0
for i in range(N-1):
  for j in range(i+1,N):
    dist+=distance(L[i],L[j])
if N==2:
  print(dist)
else:
  print(dist*2/N)

    


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a+1<=c*2){
        rep(i,a,b+1)cout<<i<<endl;
    }else {
        rep(i,a,a+c)cout<<i<<endl;
        rep(i,b-c+1,b+1)cout<<i<<endl;
    }
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 256
//****************************//
/**********  main *************/
//****************************//
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for(i = 0; i < n; i++)
#define FOR(i, a, b) for(i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

double pi = 3.141592653589793;

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

int main() {

    std::cin.tie(0);

    int n, k;
    int i,tmp=0;

    cin >> n >> k;

    vector<int> p(n);

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

    sort(p.begin(), p.end()); // vector

    for(i = 0; i < k; i++) {
        tmp = p[i] + tmp;
    }    

    cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 3592
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val H1 = ni()
    val M1 = ni()
    val H2 = ni()
    val M2 = ni()
    val K = ni()
    val r = H2 * 60 + M2 - K
    val l = H1 * 60 + M1
    val ans = max(0, r - l)
    out.println(ans)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


Measured memory_bytes: 34660
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int MAXN = 234567;
const LL MOD = (LL)1e9 + 7;
LL pw2[MAXN];

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

LL mul(LL a, LL b) {
    return (a * b) % MOD;
}

int main() {
    pw2[0] = 1;
    for (int i = 1; i < MAXN; i++)
        pw2[i] = (pw2[i - 1] * 2) % MOD;
    int N;
    scanf("%d", &N);
    map<pll, LL> mp;
    LL a0b0 = 0, a0 = 0, b0 = 0;
    for (int i = 0; i < N; i++) {
        LL a, b;
        scanf("%lld %lld", &a, &b);
        if (a == 0 && b == 0) a0b0++;
        else if (a == 0) a0++;
        else if (b == 0) b0++;
        else {
            LL coef = 1;
            if ((a < 0 && b > 0) || (a > 0 && b < 0))
                coef = -1;
            a = abs(a), b = abs(b);
            assert(a > 0);
            assert(b > 0);
            LL g = gcd(a, b);
            a /= g, b /= g;
            pll tmp = make_pair(coef * a, b);
            mp[tmp]++;
        }
    }
    LL ans = 1;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        pll p = it->first;
        LL a = p.first, b = p.second;
        LL x = it->second;
        //if (used.count(p)) continue;
        pll rv = make_pair(-b, a);
        if (a < 0) {
            rv.first *= -1;
            rv.second *= -1;
        }
        assert(rv.second > 0);
        if (mp.count(rv)) {
            LL y = mp[rv];
            LL tmp = (pw2[x] + pw2[y] - 1) % MOD;
            mp.erase(rv);
            ans = (ans * tmp) % MOD;
        } else {
            ans = (ans * pw2[x]) % MOD;
        }
    }
    ans = mul(ans, (pw2[a0] + pw2[b0] - 1) % MOD) % MOD;
    printf("%lld\n", (ans + a0b0 -1 + MOD) % MOD);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 18004