akhauriyash/Code-Regression huggingface dataset:
/**
 * author: dannysmyda
 */ 
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    map<long long,long long > L;
    map<long long,long long> R;
    
    for(int i = 1; i <= N; i++) {
        int H;
        cin >> H;
        L[i+H]++;
        R[i-H]++;
    }
    
    auto it = L.begin();
    long long ans = 0;
    while(it != L.end()) {
        long long X = it->first; 
        ans = ans + (it->second * R[X]);
        it++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 37824
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Problems problems = new Problems();
        problems.problemE_Knapsack2();
    }
}

class Problems {
    void problemE_Knapsack2() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        long[] weight = new long[N];
        int[] value = new int[N];
        int V_MAX = 0; // possible maximum value we can take
        // read data
        for (int i = 0; i < N; i++ ){
            weight[i] = sc.nextLong();
            value[i] = sc.nextInt();
            V_MAX+=value[i];
        }

        // create dp function
        // DP[i][v] : min weight that achieves value v with item 1 ~ i
        long[][] DP = new long[N+1][V_MAX + 1];

        // initialisation: without any item, the problem is infeasible
        for (int v = 1; v <= V_MAX; v++)
            DP[0][v] = Integer.MAX_VALUE;  // set infinity weight
        DP[0][0] = 0; // if no value is required -> weight is zero

        // loop for dp
        for (int i=1; i <= N; i++) {
            for (int v=1; v <= V_MAX; v++) {
                DP[i][v] = DP[i-1][v];
                // when we can include the item
                if (v >= value[i-1]) {
                    // whether include item i or not
                    DP[i][v] = Math.min(DP[i-1][v], DP[i - 1][v - value[i - 1]] + weight[i - 1]);
                }
            }
        }

        // loop for ans
        for (int v = V_MAX; v>=0; v--) {
            // stop when DP is equal or smaller than W
            if (DP[N][v] <= W) {
                System.out.println(v);
                return;
            }
        }
    }
}

Measured memory_bytes: 126676
#include<stdio.h>

int fib( int);
int F[45];
int main() {
	int n,i;
	
	scanf("%d",&n);

	printf("%d\n",fib(n));

	return 0;
}
	
	
	
	int fib(int n) {
		int t;
		
	if(t=F[n]) return F[n];	
else	if(n==0 || n==1) t=1; 
	else t= fib(n-2) + fib(n-1);
F[n]=t;
return t;
			}


Measured memory_bytes: 2112
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int n, d[60];
    cin >> n;
    REP(i, n) cin >> d[i];
    REP(i, n){
        for(int j=i+1; j<n; j++){
            ans += d[i]* d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long cnt = (n/11)*2;
		long m=n%11;
		if(m>0&&m<=6)cnt++;
		if(m>6)cnt += 2;
		System.out.println(cnt);
		sc.close();
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl

int BE(int b,int e){
    int r=1;
    while(e){
        if(e&1){
            r=(r*b)%MOD;
        }
        b=(b*b)%MOD;
        e >>=1;
    }
    return r%MOD;
}

int inv(int t){
    return BE(t,MOD-2);
}

signed main(void){
    //この問題を解くなら逆元を習得しろ
    int N,A,B,C;
    int fact[214514];
    cin >> N >> A >> B >> C;
    
    fact[0]=1;
    fact[1]=1;
    REP(i,2*N+10){
        fact[i+2]=(fact[i+1]*(i+2))%MOD;
    }
    if(A<B)swap(A,B);
    
    int Ans=0;
    A=(A*inv(100-C))%MOD;
    B=(B*inv(100-C))%MOD;
    int An=BE(A,N);
    int Bn=BE(B,N);
    int num=0;
    int a=1,b=1;
    for(int i=0;i<N;i++){
        num=(An*b)%MOD;
        num=(num*(N+i))%MOD;
        num=(num*fact[N-1+i])%MOD;
        num=(num*inv(fact[i]))%MOD;
        num=(num*inv(fact[N-1]))%MOD;
        Ans=(Ans+num)%MOD;
        b=(b*B)%MOD;
    }
    for(int i=0;i<N;i++){
        num=(Bn*a)%MOD;
        num=(num*(N+i))%MOD;
        num=(num*fact[N-1+i])%MOD;
        num=(num*inv(fact[i]))%MOD;
        num=(num*inv(fact[N-1]))%MOD;
        Ans=(Ans+num)%MOD;
        a=(a*A)%MOD;
    }
    //cout << (Ans)%MOD << endl;
    
    
    Ans=(Ans*(100*inv(100-C)%MOD))%MOD;
    cout <<Ans << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back


int main(){

 int n; cin>>n;
 int a[n];

 rep(i,n)
   cin>>a[i];

   int ans=0;

   rep(i,n){

    if(a[i] == i+1){
        ans++;
        if(i == n-1) swap(a[i],a[i-1]);
        else  swap(a[i],a[i+1]); }
   }

    cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int lim = sc.nextInt();
        int[] hum = new int[n];
        int ans = 0;
        for(int i = 0; i < n; i++){
            if(sc.nextInt() >= lim){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 48944
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)

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

int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//CODE TONOY
	int n;
    string s;
    cin >> n >> s;
 
    int r=0, g=0, b=0;
    for (int i=0;i<n;i++){
        if(s[i]=='R') r++;
        if(s[i]=='G') g++;
        if(s[i]=='B') b++;
    }
 
    ll ans = (ll) r * g * b;
 
    for (int i=0;i<n;i++){
        for (int j=0;j<n;j++){
            if(i<j){
                int k = j*2-i;
                if(k<n && s[i] != s[j] && s[j] != s[k] && s[k] != s[i]){
                    ans--;
                }
            }
        }
    }
    cout << ans << endl;
	return 0;
}

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

int main(){
    int n=0,i=0;
    double taxbefore1=0,taxbefore2=0;
    cin >> n;
    taxbefore1 = n/1.08;
    taxbefore2 = (n+1)/1.08;
    //cout << taxbefore1 << " " << taxbefore2 << endl;
    for(int i=0;i<=n;i++){
        if(taxbefore1<=(double)i&&(double)i<taxbefore2){cout << i << endl;break;}
        if(i==n){cout << ":(" << endl;break;}
    }

    return 0;
}

Measured memory_bytes: 256
def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist

def submit():
    n, alist = read_input()

    near_occurs = {}
    max_x = max(alist)
    for i in range(max_x + 1):
        near_occurs[i] = []

    for a in alist:
        near1 = a - 1
        near2 = a + 1

        if near1 >= 0:
            near_occurs[near1].append(a)

        near_occurs[a].append(a)

        if near2 <= max_x:
            near_occurs[near2].append(a)


    near_occurs = list(near_occurs.items())
    near_occurs.sort(key=lambda x: len(x[1]), reverse=True)

    print(len(near_occurs[0][1]))


if __name__ == '__main__':
    submit()

Measured memory_bytes: 77356
n = int(input())
cards = {
    'S': [],
    'H': [],
    'C': [],
    'D': []
}

for _ in range(n):
    color, rank = input().split()
    cards[color].append(rank)

for color in ['S', 'H', 'C', 'D']:
    for rank in [x for x in range(1, 14) if str(x) not in cards[color]]:
        print(color, rank)

Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std;
#define chmax(a,b) if(a<b)a=b
#define pb push_back
const int N=1e5+5;

int n,m;
int dp[N];
vector<int> e[N];

int dfs(int x)
{
	int ans=0;
	if(dp[x]) return dp[x];
	for(int i=0;i<e[x].size();i++)
		chmax(ans,dfs(e[x][i])+1);
	return dp[x]=ans;
}

int main()
{
	
	cin>>n>>m;
	while(m--)
	{
		int u,v;
		cin>>u>>v;
		e[u].pb(v);
	}
	for(int i=1;i<=n;i++)
		e[0].pb(i);
	cout<<dfs(0)-1<<'\n';
	
	return 0;
}

Measured memory_bytes: 8696
N,L=map(int,input().split())
J=[]
for i in range(N):
    J.append(L+i)
for i in J:
    if i == 0:
        J.pop(J.index(0))
        print(sum(J))
        exit(0)
J.sort()
print(sum(J[1:]) if J[0]>0 else sum(J[:-1]))

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

int main(){
  int N, Q; string S;
  cin >> N >> Q >> S;
  vector<int> T(N);
  for(int i = 1; i < N; i++){
    if(S.at(i) =='C' && S.at(i - 1) == 'A'){ T.at(i) =  T.at(i-1) + 1;}
    else{if(i == 1){ T.at(i) = 0;}else{T.at(i) = T.at(i-1);}}
  }
  
  int l, r;
  for(int i = 0; i < Q; i++){
    cin >> l >> r;
    int ans = T.at(r - 1) - T.at(l - 1);
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int a = 0;
  int b = 0;
  int ab = 0;
  for(int i=0; i<N; i++){
    string S = vec.at(i);
    if(S.at(0) == 'B' && S.at(S.size()-1) == 'A'){
      ab++;
    }
    else if(S.at(0) == 'B'){
      a++;
    }
    else if(S.at(S.size()-1) == 'A'){
      b++;
    }
  }
  int ans = 0;
  if(ab > 0){
    ans += ab - 1;
    if(a > 0){
      ans++;
      a--;
    }
    if(b > 0){
      ans++;
      b--;
    }
  }
  ans += min(a,b);
  
  for(int i=0; i<N; i++){
    string T = vec.at(i);
    for(int j=0; j<T.size()-1; j++){
      if(T.at(j) == 'A' && T.at(j+1) == 'B'){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
my $num = <STDIN>;
my $in = <STDIN>;
chomp $in, $num;
my @a = split / /, $in;
my $diff = 999999999;
for (my $i = 1; $i < @a; ++$i) {
	my $b_sum = 0;
	for (my $j = 0; $j < $i; ++$j) {
		$b_sum += $a[$j];
	}
	my $a_sum = 0;
	for (my $k = $i; $k < @a; ++$k) {
		$a_sum += $a[$k];
	}
	if ($diff > abs($a_sum - $b_sum)) {
		$diff = abs($a_sum - $b_sum);
	}
}
print $diff , "\n";

Measured memory_bytes: 512
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] %= m;
    }
    vector<int> accum(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        accum[i] = (accum[i - 1] + a[i - 1]) % m;
    }
    map<int, long long> dat;
    for (int i = 0; i <= n; i++) {
        dat[accum[i]]++;
    }
    long long ans = 0;
    for (auto t : dat) {
        ans += t.second * (t.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
 
using namespace std;
 
int main(void){
  unsigned int W, H, m, n;
  cin >> W >> H >> m >> n;
  float fW = float(W);
  float fH = float(H);

  float S = fW*fH/2.0;

  bool bTwoWays;
  if(2*m==W && 2*n==H){
    bTwoWays = true;
  }else{
    bTwoWays = false;
  }
  
  if(bTwoWays){
	  cout << S << " " << 1 << endl;
  }else{
	  cout << S << " " << 0 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
e=enumerate
(h,w),*a=[list(map(int,t.split()))for t in open(0)]
dp=[0]*w
c=12800
for i,a in e(zip(a,a[h:])):
  for j,(x,y)in e(zip(*a)):
    x=abs(x-y)
    t=0
    if j:t|=dp[j-1]<<x|dp[j-1]>>x
    if i:t|=dp[j]<<x|dp[j]>>x
    dp[j]=t if i+j else 2**c<<x
*a,=map(int,(bin(dp[w-1])[2:]).zfill(25601))
print(min(i for i,(f,g)in e(zip(a[12800:],a[12800::-1]))if f+g))

Measured memory_bytes: 3900
#include<iostream>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  int kyo[N],iin,tou[N],top=0,topi;
  for(int i=0;i<N;i++){
    tou[i] = 0;
    cin >> kyo[i];
  }
  for(int j=0;j<M;j++){
    cin >> iin;
    for(int i=0;i<N;i++){
      if(iin>=kyo[i]){
	tou[i]++;
	if(tou[i]>top){
	  top = tou[i];
	  topi = i;
	}
	else if(tou[i]==top&&i<topi){
	  top = tou[i];
	  topi = i;
	}
	break;
      }
    }
  }
  cout << topi+1 << endl;
  return 0;
}

Measured memory_bytes: 1164
# 1つ見れば、マス目に対する高さが確定する
# 100件についてテスト
import numpy as np
N = int(input())
U = 100
XYH = np.array([[int(x) for x in input().split()] for _ in range(N)])
XYH = XYH[np.argsort(-XYH[:,2])] # 高い順なので0番目は正

x0,y0,h0 = XYH[0]
dx = np.abs(np.arange(U+1) - x0)
dy = np.abs(np.arange(U+1) - y0)
# そこに頂上があるとするとその高さ
H = dx[:,None] + dy[None,:] + h0
possible = np.full_like(H, True)

for x,y,h in XYH[1:]:
  dx = np.abs(np.arange(U+1) - x)
  dy = np.abs(np.arange(U+1) - y)
  possible &= (np.maximum(H-dx[:,None]-dy[None,:],0) == h)

nz = possible.nonzero()
x,y = nz[0][0], nz[1][0]
h = H[x,y]
print(x,y,h)


Measured memory_bytes: 14848
#include<stdio.h>

int main(void){
  int N,A,B,t,i,num=0;

  scanf("%d%d%d",&N,&A,&B);
  for(i=0;i<N;i++){
    scanf("%d",&t);
    if(t<A || t>=B) num++;
  }
  printf("%d\n",num);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vvll vecror<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
 
 


void solve()
{
	ll n,sum=0;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		if(i%3!=0 && i%5!=0)
			sum+=i;;
	}
	cout<<sum;
 	return;
}

int main()
{
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3632
S = input()
st_list =  []

for i in range(len(S)+1):
    if i==0:
        if S[i] == '<':
            st_list.append(i)
    elif i == (len(S)):
        if S[i-1] == '>':
            st_list.append(i)
    else:
        if (S[i-1] == '>') & (S[i] == '<'):
            st_list.append(i)
ans = [0] * (len(S)+1)
for i in st_list:
    j = i +1
    if j > (len(S)):
        pass
    else:
        while S[j-1] == '<':
            ans[j] = ans[j-1]+1
            j += 1
            if j > (len(S)):
                break

for i in st_list:
    j = i -1

    if j < 0:
        pass
    else:
        while S[j] == '>':
            ans[j] = max(ans[j+1]+1,ans[j])
            j -= 1
            if j < 0:
                break

print(sum(ans))

Measured memory_bytes: 86092
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "vector"

using namespace std;

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

	int N,L,R;
	cin >> N;
	vector<vector<int>>edge(N);
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		L--;
		R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	vector<int>dir(N);
	queue<int>Q;
	vector<bool>flag(N, true);
	for (int i = 0; i < N; i++) {
		dir[i] = edge[i].size();
		if (dir[i] == 1) {
			Q.push(i);
			flag[i] = false;
		}
	}
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			dir[i]--;
			if (dir[i] == 1) {
				Q.push(i);
				flag[i] = false;
			}
		}
	}
	int K;
	cin >> K;
	for (int i = 0; i < K; i++) {
		cin >> L >> R;
		L--;
		R--;
		if (flag[R] && flag[L]) {
			cout << 2 << endl;
		}
		else {
			cout << 1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 8672
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#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,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    double mean = 0;
    rep(i,n) mean += (float) a[i]/n;
    int A = (int) mean;
    int B = A + 1; int C = A - 1;
    auto solve = [&](auto mid){
        int ans = 0;
        rep(i,n){
            ans += pow((mid-a[i]),2);
        }
        rn ans;
    };
    cout << min(solve(A),min(solve(B),solve(C)));
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int sum[];
    sum = new int[100];
    sum[0] = (r*x2000)-D;

    for(int i = 1;i < 11;i++){
      sum[i] = (r*sum[i-1])-D;
    }
    for(int n = 0;n < 10;n++){
      System.out.println(sum[n]);
    }
  }
}


Measured memory_bytes: 23636
import * as fs from 'fs';

namespace AtCoder.abc001 {

    class Program {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         *
         * out
         *
         */
        main(): void {
            const [n, m]: number[] = this.args[0].split(' ').map(Number);

            let ans1: number = 0;
            if (n <= 1) {
                ans1 = 0;
            } else if (n === 2) {
                ans1 = 1;
            } else {
                ans1 = this.factorial(n) / (this.factorial(2) * this.factorial((n - 2)));
            }

            let ans2: number = 0;
            if (m <= 1) {
                ans2 = 0;
            } else if (m === 2) {
                ans2 = 1;
            } else {
                ans2 = this.factorial(m) / (this.factorial(2) * this.factorial((m - 2)));
            }
            
            console.log(ans1+ans2);

        }

        factorial(num: number): number {


            if (num <= 1) {
                return 1;
            } else {
                return num * this.factorial(num - 1);
            }
        }
    }

    const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const prg = new Program(args);
    prg.main();
}



Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}

map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
int main() {
    ll x;
    cin >> x;
    ll big = 0;
    if (x == 1) {
        cout << 1 << endl;
        return 0;
    }
    REP(i, x) {
        rep(j, 2, x) {
            if (modpow(i, j, mod) > x) {
                break;
            }
            if (modpow(i, j, mod) > big) {
                big = modpow(i, j, mod);
                // cout << i << " " << j << " " << big << endl;
            }
        }
    }
    cout << big << endl;
}

Measured memory_bytes: 3668
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    long long n,s1,s2,j,k;
    scanf("%lld",&n);
    s1=n;
    s2=0;
    j=0;
    while(s1)
    {
        s2=s2+s1%10;
        k=s1;
        s1=s1/10;
        j++;
    }
    s2=max(s2,(j-1)*9+k-1);
    printf("%lld\n",s2);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

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



void solve(long long N, std::string S){
    long long ans=0;
    rep(i,N-2){
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')ans++;
    }
    cout<<ans<<endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#%%
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
q = int(input())
l, r = [0] * q, [0] * q
for i in range(q):
    l[i], r[i] = map(int, input().split())

reach = [0] * (w * h)
for i in range(h):
    for j in range(w):
        reach[a[i][j] - 1] = [i, j]
#print(reach)

count = [0] * (w * h)
for i in range((w * h)):
    if i - d < 0 : 
        pass
    else:
        count[i] = count[i - d] + (abs(reach[i][0] - reach[i - d][0]) + abs(reach[i][1] - reach[i - d][1]))
#print(count)

for i in range(q):
    print(count[r[i] - 1] - count[l[i] - 1]) 

Measured memory_bytes: 30080
import sys
n, k = map(int, input().split())
n %= k
x1 = n

while True:
    n = abs(x1 - k)
    x2 = abs(n - k)
    if x1 >= n and n <= x2:
        print(n) 
        sys.exit()
    else:
        x1 = n

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
int frog(int arr[], int n) {
	int temp[n];
	for (int i = 1; i < n; i++) {
		temp[i] = 1e9;

	}
	temp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < i + 3; j++) {
			temp[j]=min(temp[j],abs(arr[i]-arr[j])+temp[i]);

		}
		
	}
       return temp[n - 1];
}
int main(){
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	cout << frog(arr, n);
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
    public Main(){
        Scanner SC = new Scanner(System.in);

        int A = Integer.parseInt(SC.next());
        int B = Integer.parseInt(SC.next());
        int C = Integer.parseInt(SC.next());
        int D = Integer.parseInt(SC.next());

        while(true){
            C -= B;
            if(C <= 0){
                System.out.println("Yes");
                break;
            }
            A -= D;
            if(A <= 0){
                System.out.println("No");
                break;
            }
        }
    }

    public static void main(String args[]){
        Main main = new Main();
    }
}


Measured memory_bytes: 35720
#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;
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; }
ll MOD = 1000000007;

int main(){
  string s,t; cin >> s >> t;
  int sn = s.size(), tn = t.size();
  int ans = t.size();
  for(int i = 0; i <= sn - tn; i++){
    int count = 0;
    for(int j = 0; j < tn; j++){
      if(s[j+i] != t[j]){
        count++;
      }
    }
    ans = min(ans,count);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vi adj[200005];
int a[200005]={0},visited[200005]={0};

void dfs(int node)
{
	visited[node]=1;

	for(int i=0;i<adj[node].size();i++)
	{
		if(visited[adj[node][i]]==0)
		{
			a[adj[node][i]]+=a[node];
			dfs(adj[node][i]);
		}
	}
}
int main()
{
	ios

	int n,q,x,y;
	cin>>n>>q;

	for(int i=1;i<n;i++)
	{
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}

	while(q--)
	{
		cin>>x>>y;
		a[x]+=y;
	}

	dfs(1);

	for(int i=1;i<=n;i++)
	cout<<a[i]<<" ";
}


Measured memory_bytes: 24320
# coding: utf-8
# 60

while True:
    a = input()
    if a=='-':
        break
    m = int(input())
    k = [int(input()) for i in range(m)]
    K = sum(k)
    if K==1:
        I=a[0:K]
        R = a[K:]
        a = R+I
        print(a)
    elif len(a)%K==0:
        print(a)
    else:
        while K>len(a):
            K -= len(a)
        I = a[0:K]
        R = a[K:]
        a = R+I
        print(a)
        
    



Measured memory_bytes: 5604
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	int l = 0, r = 0;
	ll ans = 0, sum = 0;
	while(r < n){
		bool ok = true;
		rep(i,21){
			if((a[r] >> i & 1) && (sum >> i & 1)) ok = false;
		}
		if(ok){
			sum += a[r];
			++r;
			ans += r - l;
		}
		else{
			sum -= a[l];
			++l;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,w;
  cin>>n>>w;
  vector<P> v(n);
  rep(i,n){
    cin>>v[i].F>>v[i].S;
  }

  map<int,int> mp1,mp2;
  rep(bit,(1<<(n/2))){
    P p=P(0,0);
    rep(i,n/2){
      if(bit&(1<<i)){
        p=P(p.F+v[i].F,p.S+v[i].S);
      }
    }
    //cout<<bit<<' '<<p.F<<' '<<p.S<<endl;
    if(mp1.find(p.S)==mp1.end()){
      mp1[p.S]=p.F;
    }else{
      mp1[p.S]=max(mp1[p.S],p.F);
    }
  }

  int p=0;
  for(auto m:mp1){
    p=max(p,m.S);
    mp1[m.F]=max(m.S,p);
  }

  rep(bit,(1<<(n/2+n%2))){
    P p=P(0,0);
    rep(i,n/2+n%2){
      if(bit&(1<<i)){
        p=P(p.F+v[i+n/2].F,p.S+v[i+n/2].S);
      }
    }
    if(mp2.find(p.S)==mp2.end()){
      mp2[p.S]=p.F;
    }else{
      mp2[p.S]=max(mp2[p.S],p.F);
    }
  }

  p=0;
  for(P m:mp2){
    p=max(p,m.S);
    mp2[m.F]=max(m.S,p);
  }
  int ans=0;
  for(P m:mp1){ 
    auto it=mp2.lower_bound(w-m.F+1);
    if(it==mp2.begin()) continue;
    it--;
    ans=max(ans,m.S+it->S);
  }
  
  cout<<ans<<endl;

}


Measured memory_bytes: 134088
N, M = map(int, input().split())
X, Y = [], []
for i in range(M):
    tmp = list(map(int, input().split()))
    X.append(tmp[0])
    Y.append(tmp[1])
box_ball = [1] * N
red = [False] * N
red[0] = True
for x, y in zip(X, Y):
    if red[x-1]:
        red[y-1] = True
    box_ball[x-1] -= 1
    box_ball[y-1] += 1
    if box_ball[x-1] == 0:
        red[x-1] = False
print(red.count(True))


Measured memory_bytes: 12548
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N;
	scanf("%d",&N);

	switch(N%10){
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		printf("hon\n");
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		printf("pon\n");
		break;
	default:
		printf("bon\n");
		break;
	}

	return 0;
}


Measured memory_bytes: 3652
/**
*    author:  boutarou
*    created: 18.06.2020 23:06:11
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const double PI = 3.1415926535897932;

int n, k;
lint a[100005];
lint all_sum[100005], pl_sum[100005];
lint ans = 0;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	all_sum[0] = 0, pl_sum[0] = 0;
	rep(i, n) {
		all_sum[i + 1] = all_sum[i] + a[i];
		pl_sum[i + 1] = pl_sum[i] + (a[i] >= 0 ? a[i] : (lint)0);
	}
	for (int i = 0; i <= n - k; i++) {
		chmax(ans, pl_sum[n] - (pl_sum[i + k] - pl_sum[i]));
		chmax(ans, pl_sum[n] - (pl_sum[i + k] - pl_sum[i]) + (all_sum[i + k] - all_sum[i]));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 5968
import math
 
prime = [0 for i in range(11000)]
k = 0
r = 105000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        prime[k] = i+1
        k += 1
        l = i
        for j in range(2*i+1,r,i+1):
            p[j] = 0


for i in range(l+1,r):
    if p[i]:
        prime[k] = i+1
        k += 1
        
while True:
    n = int(raw_input())
    if not n:
        break
    print sum(prime[:n])

Measured memory_bytes: 8640
#include<iostream>
using namespace std;
int main(){
  long long x;
  cin >> x;
  string ss = "";
  if (x<=26){
  	ss = (x-1)+'a';
  }
  else{
  	while (x>=1){
  		char ch = (x-1)%26+'a';
  		if (ch==0){
  			 ch='z';
  		}
  		if (x%26==0) x--;
  		x /= 26;
  		ss = ch + ss;
  	}
  }
  cout << ss << endl;
}
// be careful with z 


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    vector<int> v(4);
    rep(i, 3) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a]++;
        v[b]++;
    }
    sort(v.begin(), v.end());
    vector<int> t = {1, 1, 2, 2,};
    bool b = v == t;
    string ans = b ? "YES" : "NO";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
bool f(int x) {
	int digit = 0;
	while (x) {
		x /= 10;
		digit++;
	}
	return digit % 2 == 1;
}
int main() {
	int N;cin >> N;
	int cnt = 0;
	for (int i = 1;i < N+1;i++) {
		if (f(i)) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include <cstdint>
using namespace std;
int main(){
long long a,b,c,d;
cin>>a>>b>>c>>d;
long long mx1=max(a*c,a*d);
long long mx2=max(b*c,b*d);
if(mx1>mx2)
    cout<<mx1;
else
cout<<mx2;

}



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

int main(void){
  int T1, T2, R1, R2;
  cin >> T1 >> T2 >> R1 >> R2;

  if(R1 == -1 || R2 == -1){
    if(T1 == T2){
      cout << "Draw" << endl;
      return 0;
    }else if(T1 < T2){
      cout << "Alice" << endl;
    }else{
      cout << "Bob" << endl;
    }
  }else{
    if(R1 == R2){
      cout << "Draw" << endl;
    }else if(R1 < R2){
      cout << "Bob" << endl;
    }else{
      cout << "Alice" << endl;
    }
  }
}



Measured memory_bytes: 3120
class UnionFind(object):
    def __init__(self, n):
        self.parent={i:i for i in range(1,n+1)}
        self.size={i:1 for i in range(1,n+1)}
    def find(self, a):
        if self.parent[a]!=a:
            self.parent[a]=self.find(self.parent[a])
        return self.parent[a]
    def getsize(self, a):
        return self.size[self.find(a)]
    def unite(self, a, b):
        a=self.find(a)
        b=self.find(b)
        if a==b:return
        if self.size[a]>self.size[b]:
            self.size[a]+=self.size[b]
            self.parent[b]=a
        else:
            self.size[b]+=self.size[a]
            self.parent[a]=b
    def isunited(self, a, b):
        return self.find(a)==self.find(b)

N, M = map(int, input().split())
l = [tuple(map(int, input().split())) for _ in range(M)]
ans = []
uft = UnionFind(N)

c = 0
ans.append(N*(N-1)//2)
for a, b in l[1:][::-1]:
    ba, bb = uft.getsize(a), uft.getsize(b)
    pa, pb = ba*(ba-1)//2, bb*(bb-1)//2

    uft.unite(a, b)
    size = uft.getsize(a)
    pc = size*(size-1)//2

    if pa!=pc and pb!=pc:
        c += pc - pa - pb
    ans.append(N*(N-1)//2-c)

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

Measured memory_bytes: 41796
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if( a == 1 ){
		a = 100;
	}
	if( b == 1 ){
		b = 100;
	}
	if( a > b ){
		cout << "Alice" << endl;
	} else if( a < b ){
		cout << "Bob" << endl;
	} else {
		cout << "Draw" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#define RG register
#define IL inline
#define pi acos(-1.0)

#define inf 1e8
using namespace std;

int n,m,R;
int land[300][300],water[300][300],dp[1005][300];
int a[1005];

void pre(){
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++){
          land[i][j]=land[j][i]=inf;
          water[i][j]=water[j][i]=inf;
        }
    for(int i=1;i<=n;i++)
         land[i][i]=0,water[i][i]=0;
}

void floyd(){
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++){
                if(k==i||k==j||i==j) continue;
                water[i][j]=min(water[i][j],water[i][k]+water[k][j]);
                land[i][j]=min(land[i][j],land[i][k]+land[k][j]);
            }
}

int main(){
    while(scanf("%d%d",&n,&m)==2){
     
     if(n==0&&m==0) break;
     pre();
     for(int i=1;i<=m;i++){
         int l,r; char str[10];
         int w;
         scanf("%d%d%d",&l,&r,&w);
         scanf("%s",str);
         if(str[0]=='L') land[l][r]=land[r][l]=min(land[r][l],w);
         else water[l][r]=water[r][l]=min(water[r][l],w);
    }
    floyd();
    scanf("%d",&R);
    for(int i=1;i<=R;i++)
        for(int j=1;j<=n;j++)
          dp[i][j]=inf;
    for(int i=1;i<=R;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
      dp[1][i]=water[a[1]][i]+land[i][a[1]];//第一次出发可以将船停到任意处再坐船回到当前目标点
   
   for(int i=1;i<=R;++i){
   		for(int j=1;j<=n;++j){
   			if(dp[i][j]!=inf){
   				dp[i+1][j]=min(dp[i+1][j],dp[i][j]+land[a[i]][a[i+1]]);
   				for(int k=1;k<=n;++k){
   					dp[i+1][k]=min(dp[i+1][k],
					dp[i][j]+land[a[i]][j]+water[j][k]+land[a[i+1]][k]
					   );
				   }
			   }
		   }
   }
     int minn=inf;
     for(int i=1;i<=n;i++)
        minn=min(minn,dp[R][i]);
     printf("%d\n",minn);
    }
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }

//merge [l,m) with [m,r)
void Merge(VI& dat, VI& tmp, int l, int m, int r) {
    int i = l, j = m, k = l;
    for (; i < m || j < r; ++k) {
        if (i == m)
            tmp[k] = dat[j++];
        else if (j == r)
            tmp[k] = dat[i++];
        else if (dat[i] < dat[j])
            tmp[k] = dat[i++];
        else
            tmp[k] = dat[j++];
    }
    for (k = l; k < r; ++k)
        dat[k] = tmp[k];
}

void MergeSort(VI& a) {
    int n = a.size();
    VI tmp(n);
    for (int range = 1; range < n; range *= 2) {
        for (int i = 0; i < n; i += range * 2) {
            if (i + range < n)
                Merge(a, tmp, i, i + range, min(i + range * 2, n));
        }
    }
}

int main() {
    init();
    
    int n, k; cin >> n >> k;
    VI h(n); cin >> h;
    MergeSort(h);
    ll ans = 0;
    FOR(i, 0, n - k)ans += h[i];
    print(ans);

    return 0;
}

Measured memory_bytes: 4688
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    cout<<"AB"<<(in()<1000?'C':'D')<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int maxx=1e5+10;
VI G[maxx];
int ans[maxx];
int vis[maxx];
void bfs(int u){
	memset(ans,0,sizeof(ans));
	vis[u]=0;
	ans[u]=0;
	queue<int>q;
	q.push(u);
	while( !q.empty() ){
		int t=q.front();
		q.pop();
		rep(i,0,SZ( G[t] ) ){
			int h=G[t][i];
			if(!vis[h]){
				ans[h]=t;
				q.push(h);
				vis[h]=1;
			}
		}
	}
} 
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	rep(i,0,m){
		int a,b;
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	bfs(1);
	rep(i,2,n+1){
		if(ans[i]==0){
			printf("No");
			return 0;
		}
	}
	printf("Yes\n");
	rep(i,2,n+1){
		printf("%d\n",ans[i]);
	}
} 

Measured memory_bytes: 10928
def nbasesum(value,n):
    nbasevalue = 0
    while value > 0:
        nbasevalue += value%n
        value //= n
    return nbasevalue

N = int(input())
ans = nbasesum(N,9)

for i in range(N+1):
    c6 = i
    c9 = N-i
    ans = min(ans, nbasesum(c9,9)+nbasesum(c6,6))

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
  ll h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
  } else {
    cout << ((h+1) / 2) * ((w+1) / 2) + (h / 2) * (w / 2) << endl;
  }
}

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

#define loop(n) for(ll i=0;i<n;i++)

using namespace std;

typedef long long int ll;

int main() {
    ll b[100000],n,t,x = 0,y = 100000;
    memset(b,0,sizeof(ll[100000]));
    cin >> n;
    loop(n) {
        cin >> t;
        x = max(x,t);
        y = min(y,t);
        b[t]++;
    }
    
    if((x==y && (x+1 == n || x*2 <= n)) || (x==y+1 && b[y] + 1 <= x && x <= b[y] + b[x] / 2)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
int main(){
  string s;
  cin >> s;
  cout << s.substr(0,3) << endl;
}

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin>>s;
    for(int i=0;i<s.length();i+=2)
    {
        if(s[i]=='L')
        {
            cout<<"No";
            return 0;
        }
    }

    for(int i=1;i<s.length();i+=2)
    {
        if(s[i]=='R')
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}




Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def enumfif(n, mod):
    f = [0] * (n+1)
    invf = [0] * (n+1)
    f[0] = 1
    for i in range(1, n+1):
        f[i] = f[i-1] * i % mod
    a = f[n]
    b = mod
    p, q = 1, 0
    while b > 0:
        c = a//b
        d = a
        a = b
        b = d % b
        d = p
        p = q
        q = d - c * q
    invf[n] = p + mod if p < 0 else p
    for i in range(n-1,-1,-1):
        invf[i] = invf[i+1] * (i+1) % mod
    return [f, invf]

x, y = na()
mod = 1000000007
if (x+y) % 3 != 0:
    print(0)
else:
    # 2a+b = x
    # a+2b = y
    a = (2*x-y)//3
    b = (2*y-x)//3
    if a < 0 or b < 0:
        print(0)
    else:
        fif = enumfif(1500005, mod)
        print(fif[0][a+b] * fif[1][a] * fif[1][b] % mod)


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

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    int tans=0,ans=0;
    for (int i=0;i<n-1;i++) {
        if (s[i]==s[i+1]) ans++;
    }
    ans = min(n-1,ans+2*k);
    cout << ans << endl;
}

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

int main(void)
{
	int a, b, c;
	int i = 0;
	cin >> a >> b >> c;

	for (a; a <= b;)
	{
		if (c % a == 0)
		{
			i++;
		}
		a++;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
ll mod = LLONG_MAX;
ll power(ll a, ll b)
{
	if(b == 0) return 1;
	ll ans = power(a, b/2);
	ans = (ans*ans)%mod;
	if(b%2) ans*=a;
	return ans%mod;
}
ll mul(ll a,ll n, ll mod)
{
	ll ret;
	if(n==0) return 0;
	ret = mul(a,n/2, mod);
	ret = (ret+ret)%mod;
	if(n%2)	ret=(ret+a)%mod;
	return ret;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	long double a, b;
	cin >> a >> b;
	ll ans = a*b;
	cout << ans;
}

Measured memory_bytes: 3748
import bisect
n = int(input())
a = list(map(int, input().split())); a.sort()
b = list(map(int, input().split())); b.sort()
c = list(map(int, input().split())); c.sort()
ab = [0 for i in range(n)]
ans = 0

for i in range(n):
  ab[i] = ab[i-1] + bisect.bisect_left(a, b[i])
for i in range(n):
  tmp = bisect.bisect_left(b, c[i])
  if tmp != 0:
  	ans += ab[tmp-1] 

print(ans)


Measured memory_bytes: 106308