akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int base=1e9+7;
int n;
int a[25][25];
int f[1<<21];
void Input()
{
    cin >> n;
    FOR(i,1,n) FOR(j,1,n) cin >> a[i][j];
}
int calc(int mask, int i)
{
    int &res=f[mask];
    if (res!=-1) return res;
    res=0;
    REP(j,n) if ((mask>>j&1)&&a[i][j+1]) {
        res+=calc(mask&(~(1<<j)),i-1);
        if (res>=base)
            res-=base;
    }
    return res;
}
void Solve()
{
    fillchar(f,sizeof(f),255);
    f[0]=1;
    cout << calc((1<<n)-1,n);
}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}


Measured memory_bytes: 8448
#include<stdio.h>
#include<iostream>
#include<vector>
#include <cstdlib>

using namespace std;

int kaijou(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
  int n;
  int ans=0,a=0,b=0;
  cin>>n;
  vector<int> p(n),q(n);
  for(int i=0;i<n;i++) cin>>p[i];
  for(int i=0;i<n;i++) cin>>q[i];
  
  int tmp_n=n;
  a+=(p[0]-1)*kaijou(tmp_n-1);
  b+=(q[0]-1)*kaijou(tmp_n-1);
  int k=1;
  while(k!=n-1){
    int rank_p=0,rank_q=0;
    for(int i=k;i<n-1;i++){
      //cout<<"p[k]="<<p[k]<<" p[i+1]="<<p[i+1]<<endl;
      if(p[k]>p[i+1]){
        rank_p++;
      }
      if(q[k]>q[i+1]){
        rank_q++;
      }
    }
    tmp_n--;
    a+=rank_p*kaijou(tmp_n-1);
    b+=rank_q*kaijou(tmp_n-1);
    //cout<<rank<<kaijou(tmp_n-1)<<endl;
    k++;
  }
  
  ans=abs(a-b);
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
using namespace std;


int main()
{	
	int a,b,d,r;
	double f;

	cin >> a >> b;

	d = a / b;
	r = a%b;
	f = (double)a / (double)b;

	cout << d << " " << r << " ";
	

	cout << fixed << setprecision(5) << f << endl;


	return 0;
}

Measured memory_bytes: 1248
N = gets.to_i
a = gets.split.map(&:to_i)
result = 1
if !a.any? 0
  a.each do |i|
    if result <= 10 ** 18
      result = result * i
    end
  end
else
  result = 0
end
puts result if result <= 10 **18
puts -1 if result > 10 ** 18


Measured memory_bytes: 21588
N=input()
Alist=list(map(int, input().split()))

MultipliedNum=1
index=0

if min(Alist)==0:
    print(0)
    index=1

else:
    for i in Alist:
        MultipliedNum*=i

        if MultipliedNum>10**18:
            print(-1)
            index=1
            break
            
if index==0:
    print(MultipliedNum)

Measured memory_bytes: 21760
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char s[10001];
int n;
cin >> n;
cin >> s;
int temp;
int s_size = strlen(s);
REP(i,s_size) {
  temp = s[i] - 'A';
  temp = (temp+n)%26;
  s[i] = temp + 'A';
}
cout << s << endl;
return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split()[:2])
SN=[input() for _ in range(H)]
SNc=[[0]*(W+2) for _ in range(H+2)]

for i in range(H):
    for j in range(W):
        if SN[i][j]=="#":
            SNc[i+1][j+1]-=100
            SNc[i][j]+=1
            SNc[i][j+1]+=1
            SNc[i][j+2]+=1
            SNc[i+1][j]+=1
            SNc[i+1][j+2]+=1
            SNc[i+2][j]+=1
            SNc[i+2][j+1]+=1
            SNc[i+2][j+2]+=1

for i in range(1,H+1):
    for j in range(1,W+1):
        if SNc[i][j]<0:
            print('#',end="")
        else:
            print(SNc[i][j],end="")
    print()            

Measured memory_bytes: 3444
import numpy as np

N, M, C = map(int, input().split())

ret = 0

B = np.array(list(map(int, input().split())))
for _ in range(N):
    A = np.array(list(map(int, input().split())))

    if np.dot(A, B) + C > 0:
        ret += 1

print(ret)


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

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}
int main() {
  int n,k;
  cin >> n >> k;
  if(n%k == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  return 0;
}



Measured memory_bytes: 256
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = [0 for _ in range(n + 1)]
ans = 0
for i in range(1, n + 1):
  d[i] = d[i - 1] + l[i - 1]
for j in range(n + 1):
  if d[j] <= x:
    ans += 1
print(ans)

Measured memory_bytes: 3064
use strict;
use warnings;

my ($n, $a, $b);
{
  my $in = <STDIN>;
  ($n, $a, $b) = split(" ", $in);
}
if ($a==0) {
  print "0\n";
  exit
}
my $ans = $a * int($n/($a + $b));
my $c = $n%($a + $b);
if ($c>$a) {
  $ans += $a;
} else {
  $ans += $c;
}
print "$ans\n";

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    for(;;){
        int b;
        cin >> b;
        if(b == 0)
            return 0;

        int ans = 1;
        int begin = b;
        for(int n=2; n*(n+1)/2<=b; ++n){
            if(n % 2 == 0){
                if(b % n != 0 && 2 * b % n == 0){
                    ans = n;
                    begin = b / n - n / 2 + 1;
                }
            }
            else{
                if(b % n == 0){
                    ans = n;
                    begin = b / n - n / 2;
                }
            }
        }
        cout << begin << ' ' << ans << endl;
    }
}



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
int n;
long long k;
vector<int> a;
vector<long long> cnt;
int main(void){
    cin >> n >> k;
    a.assign(n+1, 0);
    for(int i=1;i<=n;i++) cin >> a[i];
    
    cnt.assign(n+1, -1);
    int x = 1;
    for(;k>0;){
        cnt[x] = k;
        x = a[x];
        k--;
        if(cnt[x] != -1){
            long long c = cnt[x]-k;
            k %= c;
            while(k--){
                x = a[x];
            }
        }
    }
    cout << x << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h, w;
  cin >> h >> w;
  ll ans = LINF;
  FOR(i, 1, h) {
    ll h1 = i;
    ll h2 = (h-i) / 2;
    ll h3 = h - (h1 + h2);
    ans = min(ans, w * (max(h1, max(h2, h3)) - min(h1, min(h2, h3))));
    h2 = h3 = h - h1;
    ll w2 = w / 2;
    ll w3 = w - w2;
    ans = min(ans, max(h1 * w, max(h2 * w2, h3 * w3)) - min(h1 * w, min(h2 * w2, h3 * w3)));
  }
  FOR(i, 1, w) {
    ll w1 = i;
    ll w2 = (w-i) / 2;
    ll w3 = w - (w1 + w2);
    ans = min(ans, h * (max(w1, max(w2, w3)) - min(w1, min(w2, w3))));
    w2 = w3 = w - w1;
    ll h2 = h / 2;
    ll h3 = h - h2;
    ans = min(ans, max(w1 * h, max(w3 * h3, w2 * h2)) - min(w1 * h, min(w2 * h2, w3 * h3)));
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100
using namespace std;
typedef long long ll;
bool used[N];
  
ll SumD(ll a,ll d,ll n){return (n*(2*a+(n-1)*d))/2;}
  
bool mark(ll n){
  bool res=1;
  for(ll i=1;i*i<=N;i++)res&=!used[i],used[i]=1;
  return res;
}
  
int main(){
  while(1){
    ll n,m,p[21];
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<m;i++)cin>>p[i];
    sort(p,p+m);
    
    ll sum=0,cnt=0;
    for(int i=0;i<m;i++){
      sum+=SumD(p[i],p[i],n/p[i]);
      cnt+=n/p[i];
      memset(used,0,sizeof(used));
      for(int j=0;j<i;j++){
    ll lcm=(p[i]/__gcd(p[i],p[j]))*p[j];
    if(!mark(lcm))continue;
    sum-=SumD(lcm,lcm,n/lcm);
    cnt-=(n/lcm);
      }
    }
    printf("%.8f\n",(1.0*SumD(1,1,n)-sum)/max(1LL,(n-cnt)));
  }
  return 0;
}

Measured memory_bytes: 3260
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter


def main():

    N = int(input())
    A = list(map(int, input().split()))
    arr = [abs(i - (N - i - 1)) for i in range(N)]
    result = 0
    mod = 10**9 + 7

    if Counter(A) == Counter(arr):
        result = (2**(N // 2)) % mod

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20676
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int a = Cin.Ni();
        int b = Cin.Ni();
        int c = Cin.Ni();

        Console.WriteLine(a <= c && c <= b ? "Yes" : "No");
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ll a,b,n; cin >> a >> b >> n;
  if(b - 1 <= n) n = b-1;
  if(n == 0) n = 1;
  cout << a*n/b - a*(n/b) << endl;
  return 0;
}


Measured memory_bytes: 3592
def gcd(a,b) :
    r = a % b
    if r == 0 :
        return b
    else :
        return gcd(b,r)

N = int(input())

A = list(map(int,input().split()))

L = [0] * N
R = [0] * N

for i in range(N) :  # iより左(右)
    if i == 0 :
        L[i] = A[i]
        R[-i-1] = A[-i-1]
    else :
        L[i] = gcd(L[i-1], A[i-1])
        R[-i-1] = gcd(R[-i],A[-i])

ans = 1

for i in range(N) :
    if i == 0 :
        new = R[i]
    elif i == N-1 :
        new = L[i]
    else :
        new = gcd(L[i],R[i])
    if ans < new :
        ans = new

print(ans)

Measured memory_bytes: 63984
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextLong();
		}
		long num = lcm(a,n);
		//System.out.println(l);
		long deno = sum(a,n,num);
		//System.out.println(deno);
		double ans = num / (double)deno;
		System.out.println(ans);
	
	}
	
	public static long gcd(long a, long b){
		if(a == 0)
			return b;
		
		return gcd(b%a,a);
	}
	
	public static long lcm(long[] a, long n){
		long lc = 1;
		for(int i = 0; i < n; i++){
			lc =  (lc * a[i])/gcd(lc,a[i]);
		}
		return lc;
	}
	
	public static long sum(long[] a,int n,long num){
		long count = 0;
		for(int i = 0; i < n; i++){
			count += (num/a[i]);
		}
		return count;
	}
	
	
	
	}

Measured memory_bytes: 23252
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<(x)<<endl
#define p2(x,y)                 out<<(x)<<' '<<(y)<<endl
#define p3(x,y,z)               out<<(x)<<' '<<(y)<<' '<<(z)<<endl
#define p4(x,y,z,w)             out<<(x)<<' '<<(y)<<' '<<(z)<<' '<<(w)<<endl
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<(ix == n-1? '':' '); out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define pl(x)                   out<<(x)
#define pll(x)                  out<<(x)<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


void ssolve(std::istream& in, std::ostream& out){
    int x; s(x);
    p(x==1?0:1);
}

class ANot {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    ANot solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3596
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
// #ifndef RAHUL
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif

long long a,b,c,d,e,f,g,h;


cin>>a;
cin>>b>>c;

if (a==1)
{
	/* code */
	cout<<"Hello World";
}

else{
	cout<<b+c<<endl;
}

return 0;
}

Measured memory_bytes: 3592
s = input()
X, Y = map(int, input().split())

t = [len(x) for x in s.split('T')]

tx = t[2::2]
M = len(tx)
dpx = {t[0]}
for i in range(M):
    tmp = set()
    for x in dpx:
        tmp.add(x + tx[i])
        tmp.add(x - tx[i])
    dpx = tmp

ty = t[1::2]
M = len(ty)
dpy = {0}
for i in range(M):
    tmp = set()
    for y in dpy:
        tmp.add(y + ty[i])
        tmp.add(y - ty[i])
    dpy = tmp

if X in dpx and Y in dpy:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3884
len, truck_cnt = gets.chomp.split(' ').map(&:to_i)
loads = readlines.map(&:chomp).map(&:to_i)

max_load = loads.max
avg_load_per_truck = loads.sum / truck_cnt
min_cap = max_load > avg_load_per_truck ? max_load : avg_load_per_truck
max_cap = max_load * len / truck_cnt + 1
# cap = (min_cap + max_cap) / 2
while true
  l_sum = 0
  truck_i = 1
  truck_overflow = false
  cap = (min_cap + max_cap) / 2
  loads.each do |l|
    if l_sum + l > cap
      truck_i += 1
      if truck_i > truck_cnt
        truck_overflow = true
        break
      end
      l_sum = l
    else
      l_sum += l
    end
  end
  if truck_overflow
    min_cap = cap + 1
  else
    max_cap = cap
  end
  break if min_cap == max_cap
end
puts min_cap


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

using namespace std;

typedef long long LL;

LL ans;

void get(LL p,LL q)
{
    if(p % q == 0)
    {
        ans += p * 2 - q;
        return;
    }
    else
    {
        ans += (p - p % q) * 2;
        get(q,p%q);
    }
}

int main()
{
    LL n,m,a,b;
    cin >> n >> m;
    ans = n;
    n -= m;
    a = max(n,m),b = min(n,m);
    get(a,b);
    cout << ans << endl;
    return 0;
}

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

#define REP(var, start, count) for(int var=start; var<count; var++)

int main(void) {
	int N;
	cin >> N;
	
	int maxrank = 0;
	int score = -1;
	REP(i,0,N) {
		int A, B;
		cin >> A >> B;
		if ( A > maxrank ) {
			score = B;
			maxrank = A;
		}
	}
	
	cout << (maxrank+score) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll  x; cin>>x;
    ll  a = 100.0;

    int ans = 0;
    while (a < x) {
        ans++;
        ll b = a/100;
        a += b;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin>>s;
    if(s[0] == 'S')
        cout<<"Cloudy"<<endl;
    else if(s[0] == 'R')
         cout<<"Sunny"<<endl;
    else
        cout<<"Rainy"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it!= v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
#define MOD 1000000007
//////////////////////////////////////////

int main(){
  ins(S);
  if(sz(S) == 3) reverse(all(S));
  out(S);
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
#print(S)
ans = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            ans[i][j] = "#"
        else:
            c = 0
            for dx in [-1,0,1]:
                for dy in [-1,0,1]:
                    if 0 <= i+dy <= H-1 and 0 <= j+dx <= W-1 and S[i+dy][j+dx] == "#":
                        c += 1
            ans[i][j] = str(c) 
for i in range(H):
    output = "".join(ans[i])
    print(output)

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

using namespace std;

#define int long long

const int maxn=3e5+5,mod=1e9+7;

int n,backet1[maxn],backet2[maxn],a[maxn],ans;

inline int read(){
	int x=0,f=1;
	char p=getchar();
	while(!isdigit(p)){
		if(p=='-') f=-1;
		p=getchar();
	}
	while(isdigit(p)) x=(x<<3)+(x<<1)+(p^48),p=getchar();
	return x*f;
} 

inline int power(int a,int b){
	int ans=1;
	while(b){
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}

signed main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++){
		int cnt=0;
		while(1){
			if(cnt>=62) break;			
			if(a[i]&(1LL<<cnt)) backet1[cnt]++;
			else backet2[cnt]++;
			cnt++;
		}
	}
	for(int i=1;i<=n;i++){
		int cnt=0;
		while(1){
			if(cnt>=62) break;
			if(a[i]&(1LL<<cnt)) ans= (ans+ ( backet2[cnt]* ((1LL<<cnt)%mod) %mod ) %mod) %mod;
			else                ans= ( ans+ (backet1[cnt]* ((1LL<<cnt)%mod) %mod )%mod)%mod;
			cnt++;
		}
	}
	cout<<(ans*power(2,mod-2)%mod)<<endl;
	return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int p, q, r, min = 1000;
    vector<int>as(3);
    for (int i = 0; i < 3; i++){
        cin >> as[i];
    }
    sort (as.begin(), as.end());
    cout << as[0] + as[1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using ll=long long;
const ll MOD = 1000000007;

vector<ll> primes = 
{
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,
73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173
,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,
283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,
419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,
547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,
661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,
811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,
947,953,967,971,977,983,991,997
};
set<ll> large_primes;

ll div_count[10000][168]={};
ll max_div_count[168]={};

ll mypow(ll _x,ll _n)
{
  ll ret = 1;
  while(0<_n){
    if((_n % 2) == 0){
      _x = (_x*_x)%MOD;
      _n >>= 1;
    }
    else{
      ret = (ret*_x)%MOD;
      --_n;
    }
  }
  return ret;
}

void solve(ll N, std::vector<ll> A){
  // primes.push_back(2);
  // primes.push_back(3);
  // primes.push_back(5);
  // primes.push_back(7);
  // for(int i=11;i<1000000;i+=2){
  //   bool found=true;
  //   for(auto p:primes){
  //     if(i%p==0){
  // 	found=false;
  // 	break;
  //     }
  //   }
  //   if(found)primes.push_back(i);
  // }
  int sz=A.size();
  for(int i=0;i<sz;i++){
    for(int j=0;j<(int)primes.size();j++){
      while((A[i]/primes[j])*primes[j]==A[i]){
	div_count[i][j]++;
	A[i]/=primes[j];
      }
      if(max_div_count[j]<div_count[i][j])
	max_div_count[j]=div_count[i][j];
    }
  }
  for(int i=0;i<sz;i++){
    if(A[i]!=1)
      large_primes.insert(A[i]);
  }

  ll ans=0;
  for(int i=0;i<sz;i++){
    ll result=1;
    for(int j=0;j<(int)primes.size();j++){
      result*=mypow(primes[j],max_div_count[j]-div_count[i][j]);
      result%=MOD;
    }
    for(auto p:large_primes){
      if(p!=A[i]){
	result*=p;
	result%=MOD;
      }
    }
    ans+=result;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

int main(){
  ll N;
  scanf("%lld",&N);
  std::vector<ll> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 13696
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define rep(i, n) rep(int i=0; i<n; i++)
using namespace std;

int main(){
  int N;
  cin >> N;
  string S[N];
  for(int i=0; i<N; i++)
    cin >> S[i];

  map<string, int> m;

  for(int i=0; i<N; i++)
    m[S[i] ]++;

  cout<<m.size()<<endl;
  


  return 0;
}


Measured memory_bytes: 25372
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
///////////////////////////////////////////////////////////////////////////////////

int main(){
    ll n;
    cin>>n;
    cout<<"Christmas";
    rep(i,25-n){
        cout<<" Eve";
    }
    cout<<""<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
s = list(input())
n = int(input())
q = deque(s)
Reverse = 0

for i in range(n):
    Input = input().split()
    if int(Input[0]) == 1:
        Reverse = abs(Reverse-1)
        continue
    else:
        if int(Input[1]) == 1:
            if Reverse == 0:
                q.appendleft(Input[2])
            else:
                q.append(Input[2])
        else:
            if Reverse == 0:
                q.append(Input[2])
            else:
                q.appendleft(Input[2])
if Reverse==1:
    q.reverse()
print(''.join(q))     



Measured memory_bytes: 9204
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: usize,
        k: usize,
        p: [f64; n],
    }

    let mut max = 0.0;
    for j in 0..k {
        max = max + p[j] + 1.0;
    }
    let mut tmp = max;
    
    for i in 1..n-k+1 {
        tmp = tmp - p[i-1] + p[i+k-1];
//        println!("{}",tmp/2.0);
        if tmp > max {
            max = tmp;
        }
    }
    println!("{}",max/2.0);
}


Measured memory_bytes: 6524
N = int(input())

def factorial(n, p):
    if n == 0: return 0
    return n//p + factorial(n//p, p)

def duble_factorial(n, p):
    if n%2 == 1:
        return factorial(n,p) - duble_factorial(n-1, p) # n!! = n!/(n-1)!!だからpで割ると引き算で表せるよね
    else:
        res = factorial(n//2, p)
        if p == 2: 
            res += n//2
        return res

ans = min(duble_factorial(N,2), duble_factorial(N,5))
print(ans)

Measured memory_bytes: 3064
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
//   ios_base::sync_with_stdio(false);
//   cin.tie(NULL);
//   cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
  // tes(t)
  // {
    int n,k;
    cin>>n>>k;
    int a[n];
    rep(i,0,n-1)
    cin>>a[i];
    int res[k+1]={0};
    res[0]=0;
    for(int i=1;i<=k;i++)
    {
      for(int j=0;j<n;j++)
      {
        if(a[j]<=i)
        {
          if(res[i-a[j]]==0)
          {
            res[i]=1;
            break;
          }
          else {
            res[i]=0;
          }
        }
      }
    }
    if(res[k]==1)
    cout<<"First";
    else cout<<"Second";
  // }
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<tuple<string, int, int>> P(N);
        rep(i, N) {
            cin >> get<0>(P[i]) >> get<1>(P[i]);
            get<2>(P[i]) = i + 1;
            get<1>(P[i]) *= -1;
        }
        sort(all(P));
        rep(i, N) cout << get<2>(P[i]) << endl;
        return 0;
    }
};

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,c;
  cin>>r>>c;
  int a[101][101]={};
  
  for(int i=0;i<r;i++)
    for(int j=0;j<c;j++) cin>>a[i][j];
 
  for(int i=0;i<r;i++)
    for(int j=0;j<c;j++) a[r][c] += a[i][j];

  for(int i=0;i<r;i++){
    int sum=0;
    for(int j=0;j<c;j++) sum+=a[i][j];
    a[i][c] = sum;
    }

  for(int j=0;j<c;j++){
    int sum=0;
    for(int i=0;i<r;i++) sum+=a[i][j];
    a[r][j] = sum;
    }

  for(int i=0;i<=r;i++){
    for(int j=0;j<=c;j++){
      if(j) cout<<" ";
      cout<<a[i][j];
     }
  cout<<endl;
  }
return 0;
}


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

int main() {
  ios::sync_with_stdio(false);

  string S, T;
  cin >> S >> T;

  vector<int> X(26, -1), Y(26, -1);

  for (int i = 0; i < S.size(); i++) {
    int x = S.at(i) - 'a';
    int y = T.at(i) - 'a';
    if (X.at(x) != -1 || Y.at(y) != -1) {
      if (X.at(x) != y || Y.at(y) != x) {
        cout << "No" << "\n";
        return 0;
      }
    }
    X.at(x) = y;
    Y.at(y) = x;
  }

  cout << "Yes" << "\n";
}

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

int main(){
  int N;
  cin >> N;
  vector<int> Blue = vector<int>(N);
  for(int i = 0;i<N;i++){ 
    cin >> Blue.at(i);
  }
  
  sort(Blue.begin(),Blue.end());
  
  int ans=0;
  bool Switch = false;
  
  
   for(int i = N-1;i>=0;i--){
   	if(!Switch){
   	ans+=Blue.at(i);
      Switch=true;
   	}	
  	 else if(Switch){
   	ans-=Blue.at(i);
      Switch=false;
   	}	
   }
  
  cout << ans <<endl;
}


Measured memory_bytes: 256
# B - Tournament
from collections import deque
import sys
sys.setrecursionlimit(10**5)

N = int(input())
child = [deque([]) for _ in range(N+1)]
for i in range(2,N+1):
    a = int(input())
    child[a].append(i)

def dp(i):
    if len(child[i])==0:
        return 0
    dp_list = []
    while len(child[i])>0:
        dp_list.append(dp(child[i].popleft()))
    dp_list.sort(reverse=True)
    return max([dp_list[i]+i+1 for i in range(len(dp_list))])

print(dp(1))

Measured memory_bytes: 188268
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int x;
  cin >> x;
  if(x == 7 || x == 5 || x == 3) {
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <numeric>
#include <utility>


namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  std::vector<u64> a(n);
  for (auto &e : a) {
    std::cin >> e;
  }
  u64 ans = std::numeric_limits<u64>::max();
  const u64 sum = std::accumulate(a.cbegin(), a.cend(), static_cast<u64>(0));
  u64 acc = a[0];
  for (const usize i : rep(1, n)) {
    chmin(ans, difference(acc, sum - acc));
    acc += a[i];
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var A = cin.ReadIntArray(N);
            var B = cin.ReadIntArray(N);
            var C = cin.ReadIntArray(N-1);

            var ans = 0;
            var beforeRyouri = N;
            for(var i=0; i<N; i++)
            {
                var ryouri = A[i]-1;
                var manzoku = B[ryouri];
                if((ryouri-1) == beforeRyouri)
                {
                    manzoku += C[beforeRyouri];
                }
                ans += manzoku;
                beforeRyouri = ryouri;
            }

            WriteLine(ans);
        }

        static long GcdArray(long[] array)
        {
            var ans = array[0];
            for(var i=1; i<array.Length; i++)
            {
                ans = Gcd(ans, array[i]);
            }
            return ans;
        }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  cout << "A" << b.at(0) << "C" << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# N, K = [int(x) for x in input().split()]

N, M = [int(x) for x in input().split()]

H = np.array([int(x) for x in input().split()])

good = [1] * N

road = []
for m in range(M):
    a, b = [int(x) for x in input().split()]

    if H[a-1] == H[b-1]:
        good[a-1] = 0
        good[b-1] = 0
    elif H[a-1] < H[b-1]:
        good[a-1] = 0
    else:
        good[b-1] = 0

print(sum(good))



Measured memory_bytes: 38576
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

const Inf = 1 << 60

func main() {
	H, W, K := ReadInt(), ReadInt(), ReadInt()
	x1, y1, x2, y2 := ReadInt()-1, ReadInt()-1, ReadInt()-1, ReadInt()-1
	x1, y1 = y1, x1
	x2, y2 = y2, x2
	c := make([]string, H)
	for y := 0; y < H; y++ {
		c[y] = ReadString()
	}

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

	toID := func(x, y, dir int) int {
		return 4*(W*y+x) + dir
	}
	splatID := func(id int) (x, y, dir int) {
		return id / 4 % W, id / 4 / W, id % 4
	}

	dist := make([]int, W*H*4)
	for i := 0; i < W*H*4; i++ {
		dist[i] = Inf
	}

	q := Heap{}
	push := func(dir, x, y, cost int) {
		id := toID(x, y, dir)
		if dist[id] <= cost {
			return
		}
		dist[id] = cost
		q.push(State{
			Cost: cost,
			ID:   id,
		})
	}

	for i := 0; i < 4; i++ {
		push(i, x1, y1, 0)
	}
	for len(q) > 0 {
		now := q.pop()
		x, y, dir := splatID(now.ID)
		if c[y][x] == '@' {
			continue
		}
		if dist[now.ID] < now.Cost {
			continue
		}
		dist[now.ID] = now.Cost
		if x == x2 && y == y2 {
			break
		}
		for i := 0; i < 4; i++ {
			push(i, x, y, (now.Cost+K-1)/K*K)
		}
		nx := x + dx[dir]
		ny := y + dy[dir]
		if 0 <= nx && nx < W && 0 <= ny && ny < H {
			push(dir, nx, ny, now.Cost+1)
		}
	}
	ans := Inf
	for i := 0; i < 4; i++ {
		id := toID(x2, y2, i)
		if dist[id] < ans {
			d2 := (dist[id] + K - 1) / K
			if d2 < ans {
				ans = d2
			}
		}
	}
	if ans < Inf {
		fmt.Println(ans)
	} else {
		fmt.Println(-1)
	}
}

type State struct {
	Cost, ID int
}

type HeapElement = State
type Heap []HeapElement

func (h Heap) Less(i, j int) bool    { return h[i].Cost < h[j].Cost }
func (h Heap) Len() int              { return len(h) }
func (h Heap) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *Heap) Push(x interface{})   { *h = append(*h, x.(HeapElement)) }
func (h *Heap) Pop() (x interface{}) { *h, x = (*h)[:len(*h)-1], (*h)[len(*h)-1]; return }
func (h *Heap) push(v HeapElement)   { heap.Push(h, v) }
func (h *Heap) pop() HeapElement     { return heap.Pop(h).(HeapElement) }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 84624
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	result := true
	p := ""
	m := make(map[string]bool)
	for i := 0; i < n; i++ {
		var w string
		fmt.Scan(&w)
		if _, ok := m[w]; ok {
			result = false
			break
		}
		if len(p) > 0 && w[0] != p[len(p) - 1] {
			result = false
			break
		}
		m[w] = true
		p = w
	}

	if result {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
N,K = map(int,input().split())
answer = 0
for i in range(0,K) :
    if i*2 % K == 0 :
        if i != 0 :
            if i <= N%K :
                answer += (N//K+1)**3
            else :
                answer += (N//K)**3
        else :
            answer += (N//K)**3
print(answer)



Measured memory_bytes: 2940