akhauriyash/Code-Regression huggingface dataset:
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;

procedure main is
   N: Integer;
begin
   get(N);
   N := N rem 10;
   if (N = 0) then put_line("pon");
   elsif (N = 1) then put_line("pon");
   elsif (N = 2) then put_line("hon");
   elsif (N = 3) then put_line("bon");
   elsif (N = 4) then put_line("hon");
   elsif (N = 5) then put_line("hon");
   elsif (N = 6) then put_line("pon");
   elsif (N = 7) then put_line("hon");
   elsif (N = 8) then put_line("pon");
   else put ("hon");
   end if;
end main;

Measured memory_bytes: 3664
import java.util.*;

class Main {
    public static void main(String[] args) {
        final long MOD = 1_000_000_007L;
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        int B[] = new int[61];
        for (int i = 0; i < N; i++) {
            long A = Long.parseLong(sc.next());
            for (int j = 0; j < 61; j++) {
                B[j] += (int) (A % 2);
                A /= 2;
                if (A == 0)
                    break;
            }
        }
        sc.close();

        long sum = 0L;
        for (int j = 0; j < 61; j++) {
            sum += (long) B[j] * (N - B[j]) * Math.pow((double) 2, (double) j) % MOD;
            sum %= MOD;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 65160
import fractions
n,x = map(int,input().split())
s = set(map(int,input().split()))
s.add(x)
l = list(s)
l.sort()
for i in range(len(l)-1):
  if i == 0:
    y = l[1]-l[0]
  else:
    y = fractions.gcd(l[i+1]-l[i],y)
print(y)

Measured memory_bytes: 93588
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int[] As = new int[N];
            for (int i = 0; i < N; i++)
            {
                As[i] = int.Parse(Console.ReadLine());
            }
            var sortedAs = As.OrderByDescending(x => x).ToArray();

            for (int i = 0; i < N; i++)
            {
                if (As[i] == sortedAs[0])
                {
                    Console.WriteLine(sortedAs[1]);
                }
                else
                {
                    Console.WriteLine(sortedAs[0]);
                }
            }
        }
    }
}

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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,r,x,y,m,n;
        cin>>n>>k;
        vi v(n);
        cin>>v;
        for(i=k;i<n;i++)
        {
            if(v[i]>v[i-k])cout<<"Yes\n";
            else cout<<"No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 4780
n = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
coa=[0]*(n+1)
cob=[0]*(n+1)
for i in a:
  coa[i]+=1
for i in b:
  cob[i]+=1
for i in range(n+1):
  if coa[i]+cob[i]>n:print("No");exit()
b.sort(reverse=True)
ans = b[:]
changed=0
for i in range(n):
  if a[i]==b[i]:
    ans[i],ans[changed]=ans[changed],ans[i]
    changed+=1
chenged_b=-1
for i in range(n):
  if a[i]==ans[i]:
    ans[i],ans[chenged_b]=ans[chenged_b],ans[i]
    chenged_b-=1
print("Yes")
print(*ans)

Measured memory_bytes: 119776
#include<iostream>

using namespace std;

void print(long A[], long n) {
	cout << A[0];
	for (long i = 1; i < n; i++) {
		cout << " " << A[i];
	}
	cout << endl;
}

long selectionSort(long A[], long n) {
	long cnt = 0;
	for (long i = 0; i < n; i++) {
		long minj = i;
		for (long j = i; j < n; j++) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
		if (minj != i) {
			long v = A[i];
			A[i] = A[minj];
			A[minj] = v;
			cnt++;
		}
	}
	return cnt;
}

int main() {
	long n;
	cin >> n;
	long A[n];
	for (long i = 0; i < n; i++) {
		cin >> A[i];
	}
	
	long cnt = selectionSort(A, n);
	print(A, n);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1160
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N,M = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
Y = [list(map(int,input().split())) for _ in range(M)]
for i in range(N):
    dmin = 10**9
    for j in range(M-1,-1,-1):
        d = dist(X[i],Y[j])
        if d<=dmin:
            dmin = d
            ind = j+1
    print(ind)

Measured memory_bytes: 39664
using System;

namespace ABC174.Problems
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string[] ss1 = Console.ReadLine().Split(" ");
            int n = int.Parse(ss1[0]);
            long d = long.Parse(ss1[1]);

            int res = 0;
            for (int i = 0; i < n; i++)
            {
                string[] strs = Console.ReadLine().Split(" ");
                long x = long.Parse(strs[0]);
                long y = long.Parse(strs[1]);
                if (x * x + y * y <= d * d)
                {
                    res++;
                }
            }
            Console.WriteLine(res);

            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 40660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    int ans = 0;
    int max_h = 0;
    rep(i, N)
    {
        if (H[i] >= max_h)
        {
            ans++;
            max_h = H[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;
// mp::cpp_int
// mp::cpp_dec_float_100



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll x;
  cin >> x;
  
  rep(i, -6207, 6208) {
    rep(j, -6207, 6208) {
      ll a = i*i*i*i*i;
      ll b = j*j*j*j*j;
      if(a-b == x) {
        cout << i << " " << j << "\n";
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3648
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,w;
	std::cin >> n >> w;
	std::vector<std::pair<int,int> > a(n);
	rep(i,n) std::cin >> a[i].first >> a[i].second;
	std::vector<std::vector<std::vector<int> > > dp(n+1,std::vector<std::vector<int> > (n+1,std::vector<int> (n*3+1,0)));
	int w1 = a[0].first;
	debug(w1);
	rep(i,n) {
		rep(j,n+1) {
			rep(k,n*3+1) {
				if(k-a[i].first+w1>=0 && j>0) dp[i+1][j][k] = std::max(dp[i][j][k],dp[i][j-1][k-a[i].first+w1]+a[i].second);
				else dp[i+1][j][k] = dp[i][j][k];
			}
		}
	}
	debug(dp);
	int max = 0;
	rep(j,n+1) {
		rep(k,n*3+1) {
			if(w1*j+k<=w) max = std::max(max,dp[n][j][k]);
		}
	}
	print(max);
	return 0;
}


Measured memory_bytes: 24832
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<ill> a(n);
  ill sum = 0;
  rep(i, 0, n) {
    cin >> a[i]; sum += a[i];
  }
  //cout << sum << "\n";
  int q;
  cin >> q;
  vector<ill> b(q), c(q);
  rep(i, 0, q) cin >> b[i] >> c[i];
  vector<ill> v(100000, 0);
  rep(i, 0, n) v[a[i]-1]++;
  //rep(i, 0, 3) cout << v[i] << " ";
  rep(i, 0, q) {
    sum -= v[b[i]-1] * b[i];
    sum += v[b[i]-1] * c[i];
    v[c[i]-1] += v[b[i]-1];
    v[b[i]-1] = 0;
    cout << sum << "\n";
  }
}


Measured memory_bytes: 6380
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] ch = str.toCharArray();
    if(ch[2] == ch[3] &&ch[4]==ch[5]){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#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;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,l;
	cin >> n;
	ll ans = 0;
	for(ll i = 0; i < n; i++) {
		cin >> l;
		while(l % 2 == 0){
			l /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, b, c;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  int k;
    cin >> n>>k;
  	if(500*n>=k){
      return yes,0;
    }
  no;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(S: str):
    sl = list(S)
    rs = sl[::-1]
    
    from math import ceil
    print(ceil([sl[i] != rs[i] for i in range(len(S))].count(True)/2))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

int main() {
  int h,w;
  cin >>h>>w;
  vector<vector<char>> data(h,vector<char>(w));
  vector<int>height(h);
  vector<int>weight(w);
  for(int i=0;i<h;i++)
    for(int k=0;k<w;k++){
      cin>>data.at(i).at(k);
      if(data.at(i).at(k)=='#'){height.at(i)++;weight.at(k)++;}
    }
  for(int i=0;i<h;i++)
    for(int k=0;k<w;k++){
      if(height.at(i)!=0 && weight.at(k)!=0)
        cout<<data.at(i).at(k);
      if(k==w-1 && height.at(i)!=0) cout<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

ll N;
ll bit[200005][20];

bool check[20];

void cal(ll inp, ll index){
    rep(i,20){
        bit[index][i] = inp%2;
        inp/=2;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N;
    rep(i,N){
        ll inp; cin >> inp;
        cal(inp, i);
    }
    
    rep(i,20) check[i] = false;

    ll from = 0;
    ll till = 0;
    ll ans = 0;
    
    while((from!=N)){
        while(1){
            if(till == N) goto outside;
            rep(i,20){
                if(bit[till][i] == 1 && check[i] == true)
                goto outside;
            }
            rep(i,20){
                if(bit[till][i] == 1) check[i] = true;
            }
            till++;
        }
    outside:// label
        
        cerr << from << " "<< till-1 << endl;

        ans+=((till)-(from));
        //delete from;
        rep(i,20){
            if(bit[from][i] == 1) check[i] = false;
        }
        from++;
    }
    
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

main() {
    while(1) {
        int n, m;
        cin >> n >> m;
        if(!n and !m) return 0;
        vector<int> ans(m);
        for(int i = 0; i < n; ++i) {
            int d, x;
            cin >> d >> x;
            ans[d - 1] = max(ans[d - 1], x);
        }
        cout << accumulate(ans.begin(), ans.end(), 0LL) << endl;
    }
}


Measured memory_bytes: 3028
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;



int main() {
	int n, z, w; cin >> n >> z >> w;
	int a[2000];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	if (n == 1) {
		cout << abs(a[0] - w) << endl;
	}
	else {
		cout << max(abs(a[n - 1] - a[n - 2]), abs(a[n - 1] - w)) << endl;
	}



}


Measured memory_bytes: 256
def rec(lst,d):
    for i in range(1,len(lst)+1):
        if i not in lst:
            lst[d]  = i
            if d+1 == len(lst):
                a = list(lst)
                P.append(a)
                lst[d] = 0
                return
            else:
                rec(lst,d+1)
                lst[d] = 0

N = int(input())

P = []

lst = []
for i in range(N):
    lst.append(0)

rec(lst,0)

for i in range(len(P)):
    print(*P[i])



Measured memory_bytes: 78924
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    int x,t;
    cin >> x >> t;
    cout << max(0, x-t);
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    byte[][][] dorm = new byte[4][3][10];
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    int B, F, R;
    byte V;
    
    while (N != 0) {
      B = in.nextInt() - 1;
      F = in.nextInt() - 1;
      R = in.nextInt() - 1;
      V = in.nextByte();
      dorm[B][F][R] += V;
      N--;
    }
    StringBuilder output = new StringBuilder();
    String crlf = System.getProperty("line.separator");
    
    for (int b = 0; b < 4; b++) {
      for (int f = 0; f < 3; f++) {
        for (int r = 0; r < 10; r++) {
          output.append(" ").append(dorm[b][f][r]);
        }
        if (b != 3 || f != 2) output.append(crlf);
      }
      if (b != 3) output.append("####################").append(crlf);
    }
    
    System.out.println(output.toString());
  }
}

Measured memory_bytes: 21032
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	b := iSScan(n)
	c := iSScan(n - 1)
	ans := sum(b)
	for i := 0; i < n-1; i++ {
		if a[i+1]-a[i] == 1 {
			ans += c[a[i]-1]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    vector<int> u(n), d(n);
    rep(i, n){
        u[i] = a[i] + i;
        d[i] = a[i] - i;
    }
    map<int, int> mp;
    rep(i, n)mp[u[i]]++;

    ll ans = 0;
    for(int v : d){
        ans += mp[-v];
    }
    cout << ans << endl;
}

Measured memory_bytes: 22684
import sys

N, P = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))

even = odd = 0
for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

if odd == 0 and P == 0:
    print(2 ** even)
elif odd == 0 and P == 1:
    print(0)
else:
    print(2 ** (N - 1))


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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
vector<ll> A;

int main()
{
	scanf("%d",&N);
	A.assign(N,0ll);
	FOR(i,0,N){
		scanf("%lld",&A [i]);
	}

	ll sum = 0;
	FOR(i,0,N){
		sum += A [i];
	}

	vector< pair<int,int> > ans;
	if(sum >= 0){
		int prev = -1;
		FOR(i,0,N) if(A [i] >= 0){
			if(prev != -1){
				ans.push_back(make_pair(prev,i));
				A [i] += A [prev];
			}
			prev = i;
		}
		FOR(i,0,N) if(A [i] < 0){
			ans.push_back(make_pair(prev,i));
			A [i] += A [prev];
		}
		FOR(i,1,N){
			ans.push_back(make_pair(i - 1,i));
		}
	}
	else{
		int prev = -1;
		FOR(i,0,N) if(A [i] < 0){
			if(prev != -1){
				ans.push_back(make_pair(prev,i));
				A [i] += A [prev];
			}
			prev = i;
		}
		FOR(i,0,N) if(A [i] >= 0){
			ans.push_back(make_pair(prev,i));
			A [i] += A [prev];
		}
		for(int i = N - 1;i > 0;i--){
			ans.push_back(make_pair(i,i - 1));
		}
	}
	
	printf("%lu\n",ans.size());
	FOR(i,0,ans.size()){
		printf("%d %d\n",ans [i].first + 1,ans [i].second + 1);
	}

	return 0;
}


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

signed main()
{
	int a,n,sum=0;
	scanf("%d%d",&a,&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		sum+=x;
	}
	if(sum>=a)
		printf("Yes");
	else
		printf("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(min(B,D)<max(A,C)){
    cout << '0' << endl;
  }else{
    cout << min(B,D)-max(A,C) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
int main(){
    cin >> N;
    cout << (N+1)*N/2 << endl;
}

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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n;
  cin >> n;
  
  ull a;
  cin >> a;
  ull gc = a;
  for(int i=1;i<n;i++){
    cin >> a;
    gc = gcd(a,gc);
  }
  cout << gc << endl;

  return 0;
}



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

int main() {
  int N, z;
  z = 0;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    
    int x, y;
    cin >> x >> y;
    z += (y - x + 1);
  }
  
  cout << z << endl;  

}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for h in range(a +1):
    for i in range(b +1):
        for j in range(c +1):
            if h *500 + i *100 + j *50 == x:
                count += 1
print(count)

Measured memory_bytes: 3060
# AOJ 0227: Thanksgiving
# Python3 2018.6.24 bal4u

while 1:
	n, m = map(int, input().split())
	if n == 0: break
	p = list(map(int, input().split()))
	p.sort(reverse=True)
	ans = 0
	for i in range(1, n+1):
		if i % m: ans += p[i-1]
	print(ans)


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

// using ll = long long;
#define int long long
using P = pair<int, int>;
using PP = pair<P, P>;  // city_id, pre_id, year, id

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
bool SortByYear(PP a, PP b) {
  // yearが重複しないことは保証されている
  return a.second.first < b.second.first;
}
bool SortByCityId(PP a, PP b) {
  // もしかしていらない？
  return a.first.first < b.first.first;
}
void PrintWithZero(int id) {
  string id_s = to_string(id);
  REP(i,6-id_s.size()) {
    cout << "0";
  }
  cout << id_s;
}
/***** MAIN *****/
signed main() {
  int n, m;
  cin >> n >> m;
  vector<PP> v(m);
  REP(i,m) {
    int prefecture, year;
    cin >> prefecture >> year;
    v[i] = PP(P(i, prefecture), P(year, 0));
  }
  sort(ALL(v), SortByYear);
  map<int, int> mp; // その県の市が何回登場したか
  REP(i,m) {
    ++mp[v[i].first.second];
    v[i].second.second = mp[v[i].first.second];
  }
  sort(ALL(v), SortByCityId);
  REP(i,m) {
    PrintWithZero(v[i].first.second);
    PrintWithZero(v[i].second.second);
    cout << "\n";
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 10880
#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,k;
  cin>>n>>k;
  vi a(30,0);
  rep(i,n){
    string s;
    cin>>s;
    a[s[0]-'A']++;
  }

  int ans=0;
 
  while(true){
    sort(all(a));
    reverse(all(a));
    if(a[k-1]==0) break;
    ans++;
    rep(i,k){
      a[i]--;
    }
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>

using namespace std;

long long n , k;
long long a[100010] , sum[100010] , sum2[100010];
long long minn;
long long maxx;

int main()
{
    while( scanf("%lld%lld" , &n , &k) != EOF )
    {
        a[0] = 0;
        sum[0] = 0;
        sum2[0] = 0;
        minn = 100000000000001;
        maxx = -100000000000001;
        for(long long i=1; i<=n; i++)
        {
            scanf("%lld" , &a[i]);
            if(a[i] > 0)
            {
                sum[i] = sum[i-1]+a[i];
                sum2[i] = sum2[i-1];
            }
            else
            {
                sum2[i] = sum2[i-1]+a[i];
                sum[i] = sum[i-1];
            }
            if( i>=k )
            {
                long long tmp = sum[i] - sum[i-k];
                if(tmp < minn)
                {
                    minn = tmp;
                }
                tmp = sum2[i]-sum2[i-k];
                if(tmp > maxx)
                {
                    maxx = tmp;
                }
            }
        }
       printf("%lld\n" , max(sum[n]+maxx , sum[n]-minn));
    }


    return 0;
}
//Flower

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

int main(){
    //入力
    int A,B;

    cin >> A >> B;
    
    if(A==B){
        cout << "Draw" << endl;
    }else if((A==1)||(B!=1&&A>B))
    {
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b,c; cin >> a >> b >> c;
	if(b-a == c-b)
    cout <<"YES" << endl;
    else
    cout <<"NO"<< endl;
}


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

int main() {
   int N;
  cin >> N;
  vector<long long int> A(N+1), B(N);
  for (int i = 0; i < N+1; ++i) cin >> A.at(i);
  for (int i = 0; i < N; ++i) cin >> B.at(i);
  
  long long int cnt = 0;
  for(int i = 0; i < N; ++i) {
    if(A.at(i) >= B.at(i)) cnt += B.at(i);
    else {
      if( A.at(i)+A.at(i+1) <= B.at(i) ) {
        cnt += A.at(i)+A.at(i+1);
        A.at(i+1) = 0;
      }
      else {
        cnt += B.at(i);
        A.at(i+1) -= (B.at(i)-A.at(i));
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N;
	cin >> N;


	int K[10][10] = {};

	rep1(i, N) {
		string S = to_string(i);

		K[S[0] - '0'][S[S.size() - 1] - '0']++;
	}

	ll kotae = 0;
	rep1(i, 9) rep1(j, 9) {
		kotae += ll(K[i][j]) * K[j][i];
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
import sys
import collections
import heapq
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    AB = []
    for _ in range(N):
        a, b = map(int, input().split())
        AB.append((a, b))
    AB.sort(key=lambda x: x[0])

    H = []
    I = 0
    ans = 0
    for m in range(M):
        for i in range(I, N):
            if AB[i][0] <= m+1:
                heapq.heappush(H, -AB[i][1])
                I += 1
            else:
                break
        if H:
            ans += -heapq.heappop(H)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20652
n = gets.to_i

cntN  = 0
cntBA = 0
cntB  = 0
cntA  = 0


n.times do
  tmp = gets.chomp.chars
  (tmp.size - 1).times do |i|
    if [tmp[i], tmp[i + 1]] == ['A', 'B']
      cntN += 1
    end
  end
  if [tmp[0], tmp[-1]] == ['B', 'A']
    cntBA += 1
  elsif tmp[0] == 'B'
    cntB += 1
  elsif tmp[-1] == 'A'
    cntA += 1
  end
end

ans = [cntBA - 1, 0].max
ans += cntN

if cntBA > 0
  if cntB > 0
    ans += 1
    cntB -= 1
  end
  if cntA > 0
    ans += 1
    cntA -= 1
  end
end

ans += [cntB, cntA].min

puts ans


Measured memory_bytes: 1788
//============================================================================
// Name        : atcoder.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int x,a,b;
int main(){
	cin>>x>>a>>b;

	if(abs(x-a)<abs(x-b))cout<<"A"<<endl;
	if(abs(x-a)>abs(x-b))cout<<"B"<<endl;

	return 0;
}



Measured memory_bytes: 256
use proconio::{input, fastout};

const TYPE_COUNT: usize = 26;

#[fastout]
fn main() {
    input! {
        d: usize,
        cc: [usize; TYPE_COUNT],
        ss: [[usize; TYPE_COUNT]; d],
    }

    let mut last = vec![0; TYPE_COUNT];

    for s in ss {
        let mut max = 0;
        let mut index = 0;
        for (i, x) in s.into_iter().enumerate() {
            let x = x + cc[i] * last[i] * 5;
            if max < x {
                max = x;
                index = i;
            }
        }
        for l in last.iter_mut() {
            *l += 1;
        }
        last[index] = 0;
        println!("{}", index+1);
    }
}

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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(i % 2 == 0 && s[i] == 'L'){
			cout << "No" << endl;
			return 0;
		}
		if(i % 2 == 1 && s[i] == 'R'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}
 

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    vector<ll> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());
    ll K;
    cin >> K;
    rep(i, K) A.back() *= 2;
    cout << accumulate(A.begin(), A.end(), 0LL) << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  ll ans = 0;
  ll ra = 0, lb = 0, katu = 0;

  REP(i, N) {
    cin >> s[i];
    REP(j, s[i].size() - 1) {
      if (s[i][j] == 'A' && s[i][j + 1] == 'B') ans++;
    }
    if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') {
      katu++;
      continue;
    }
    if (s[i][0] == 'B') lb++;
    if (s[i][s[i].size() - 1] == 'A') ra++;
  }
  if (ra == 0 && lb == 0) {
    katu--;
  }

  cout << max(ans + min(ra, lb) + max(katu, (ll)0), (ll)0) << endl;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 50005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a, p;
  cin >> a >> p;
  ll val = a * 3 + p;
  cout << val / 2 << en;
  return 0;
}

/*
1
11 5 8 3 4
NEESSWWNESE
 */

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fin(ans) cout << ans << endl

int main(void) {
  int a, b;
  cin >> a >> b;
  int c = a - 2*b;
  if (c <= 0)
    fin(0);
  else
    fin(c);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
const int N = 2e5 + 7;
int n, ans = 0;
int a[N], b[N], cnt = 0; 
int pr(int i) { return (i - 1 + n) % n; }
int nx(int i) { return (i + 1) % n; }
set <ii> ms;
void mem(int i) {
    if (a[i] < b[i] && b[pr(i)] + b[nx(i)] < b[i]) ms.insert({b[i], i});
}
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) {
        cnt += a[i] == b[i];
        mem(i);
    }
    while (ms.size() && cnt < n) {
        int i = ms.rbegin()->second; ms.erase(*ms.rbegin());
        int d = b[pr(i)] + b[nx(i)];
        if (b[i] % d <= a[i]) {
            if (b[i] % d == a[i] % d) {
                ans += (b[i] - a[i]) / d;
                ++cnt;
                b[i] = a[i];
                mem(pr(i)); mem(i); mem(nx(i));
                continue;
            }
            else {
                cout << "-1\n";
                exit(0);
            }
        }
        ans += b[i] / d;
        b[i] %= d;
        mem(pr(i)); mem(i); mem(nx(i));
    }
    if (cnt == n) cout << ans << '\n';
    else cout << "-1\n";
}   

Measured memory_bytes: 9600
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<map>
#define RI register int
#define CI const int&
#define VI vector <int>:: iterator
using namespace std;
const int N=100005,mod=998244353,base=(long long)1e18%mod;
int n,x,y,ans,pw[N];
inline void inc(int& x,CI y)
{
	if ((x+=y)>=mod) x-=mod;
}
class Graph
{
	private:
		vector <int> v[N]; int m,sg[N];
		inline int SG(CI x)
		{
			if (~sg[x]) return sg[x]; map <int,bool> ext;
			for (VI to=v[x].begin();to!=v[x].end();++to) ext[SG(*to)]=1;
			while (ext[++sg[x]]); return sg[x];
		}
	public:
		int mx,c[N];
		inline void solve(void)
		{
			RI i; for (scanf("%d",&m),i=1;i<=m;++i)
			if (scanf("%d%d",&x,&y),x<y) v[x].push_back(y); else v[y].push_back(x);
			for (memset(sg,-1,sizeof(sg)),i=1;i<=n;++i) if (!~sg[i]) sg[i]=SG(i);
			for (i=1;i<=n;++i) mx=max(mx,sg[i]),inc(c[sg[i]],pw[i]);
		}
		inline void output(void)
		{
			RI i; printf("%d\n",mx);
			for (i=1;i<=n;++i) printf("%d ",sg[i]); putchar('\n');
			for (i=1;i<=n;++i) printf("%d ",c[i]); putchar('\n');
		}
}G[3];
int main()
{
	RI i,j; for (scanf("%d",&n),pw[0]=i=1;i<=n;++i) pw[i]=1LL*pw[i-1]*base%mod;
	for (i=0;i<3;++i) G[i].solve();
	for (i=0;i<=G[0].mx;++i) for (j=0;j<=G[1].mx;++j)
	inc(ans,1LL*G[0].c[i]*G[1].c[j]%mod*G[2].c[i^j]%mod);
	return printf("%d",ans),0;
}

Measured memory_bytes: 14976
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    println!("{}", solve(&input));
}

const MODULO: i64 = 1_000_000_007;

fn solve(input: &str) -> i64 {
    let mut iter = input.split_whitespace().map(|w| w.parse().unwrap());
    let n: i64 = iter.next().unwrap();
    let a: i64 = iter.next().unwrap();
    let b: i64 = iter.next().unwrap();
    let mut ans = power(2, n);
    ans = (ans + MODULO - 1) % MODULO;
    ans = (ans + MODULO - binom(n, a)) % MODULO;
    ans = (ans + MODULO - binom(n, b)) % MODULO;
    ans
}

fn power(base: i64, exponent: i64) -> i64 {
    let mut acc = 1;
    let mut base = base;
    let mut exponent = exponent;
    while exponent != 0 {
        if exponent & 1 == 1 {
            acc = acc * base % MODULO;
        }
        base = base * base % MODULO;
        exponent >>= 1;
    }
    acc
}

fn inverse(x: i64) -> i64 {
    power(x, MODULO - 2)
}

fn binom(n: i64, k: i64) -> i64 {
    let mut numer = 1;
    let mut denom = 1;
    for i in 0..k {
        numer = numer * (n - i) % MODULO;
        denom = denom * (k - i) % MODULO;
    }
    numer * inverse(denom) % MODULO
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;

int main(){
    long long N;
    const long long mod=1000000007;
    cin>>N;
    long long dp[2][2][N+10];
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<=N+9;k++){
                dp[i][j][k]=0;
            }
        }
    }
    dp[0][0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                for(int l=0;l<=9;l++){
                    //cout<<i<<","<<j<<","<<k<<","<<dp[j][k][i]<<endl;
                    dp[j][k][i]%=mod;
                    if(l!=0&&l!=9) dp[j][k][i+1]+=dp[j][k][i];
                    else if(l==0) dp[1][k][i+1]+=dp[j][k][i];
                    else if(l==9) dp[j][1][i+1]+=dp[j][k][i];
                }
            }
        }
    }
    cout<<dp[1][1][N]%mod<<endl;
}


Measured memory_bytes: 34772
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

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

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll a,b;
    cin >> a >> b;
    if((a+b) % 2) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (a+b)/2 << endl;
    }
}


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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	int d,n,k;cin>>n>>k;
	vb dig(10,true);
	repi(i,k){
		cin>>d;
		dig[d]=false;
	}
	bool ch=true;
	while(n){
		ch=true;
		d=n;
		while(d){
			if(dig[d%10]==false) ch=false;
		d/=10;
		}
		if(ch) break;
	n++;
	}
	db(n);
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 256
# ABC091C - 2D Plane 2N Points (ARC092C)
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = sorted(
        [tuple(map(int, input().split())) for _ in range(N)],
        key=lambda x: x[1],
        reverse=1,
    )
    B = sorted([tuple(map(int, input().split())) for _ in range(N)])
    ans, memo = 0, set()
    for bx, by in B:
        for i, (ax, ay) in enumerate(A):
            if i not in memo and ax < bx and ay < by:
                ans += 1
                memo |= {i}
                break
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; ++i) {
        cin >> A[i];
    }
    cout << (N+K-3) / (K-1) << endl;
    return 0;
}


Measured memory_bytes: 640