akhauriyash/Code-Regression huggingface dataset:
N = int(input())
input_line = [input() for _ in range(N)]
count = {}
for w in input_line:
    if w in count:
        count[w] += 1
    else:
        count[w] = 1
max_values = max(count.values())
keys = [k for k, v in count.items() if v == max_values]
for w in sorted(keys):
    print(w)


Measured memory_bytes: 101276
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(void){

  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  vector<ll> dp(k+1,-1);
  dp[0]=0;

  rep1(i,k){
    ll jud=1;
    rep(j,n){
      if(i-a[j] < 0) continue;
      jud*=dp[i-a[j]];
    }
    if(jud){
      dp[i]=0;
    }
    else{
      dp[i]=1;
    }
  }

  rep(i,k+1){
    //cout << dp[i] << " ";
  }
  //cout << endl;

  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;

}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

  int res = 0;

  while (true) {
    bool exist_odd = false;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 != 0) exist_odd = true;
    }
    if (exist_odd) break;

    for (int i = 0; i < N; i++) {
      A[i] /= 2;
    }
    res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n m ->
    let check c =
        let a = max (c - n) 0 in
        m - 2 * a >= 2 * c 
    in
    let rec loop l r =
        if l = r then l - 1 else
            let m = (l + r) / 2 in
            if check m then loop (m + 1) r else loop l m
    in
    loop 0 10000000000000 |> Printf.printf "%d\n"
)

Measured memory_bytes: 3848
fun main(args: Array<String>) {
    readLine()
    val input = readLine()!!.split(" ").map(String::toLong)

    input.forEach {
        if (it == 0L) {
            println(0)
            return
        }
    }

    var prod = 1L
    input.forEach {
        if (it <= 1000000000000000000L / prod) {
            prod *= it
        } else {
            println(-1)
            return
        }
    }

    println(prod)
}


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    ll r;
    cin>>r;
    ld x=2*pi*r;
    cout<<preci(7)<<x<<nl;
    return 0;
}


Measured memory_bytes: 3792
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
using namespace std;

int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//long x[100001];
	//string s[1001];
	cin >> a;
	ans = 10000000;
	for ( b = 1; b < a; b++)
	{
		ans = min(ans, (((a - b) % 100000) - ((a - b) % 10000)) / 10000 + (((a - b) % 10000) - ((a - b) % 1000)) / 1000 + (((a - b) % 1000) - ((a - b) % 100)) / 100 + (((a - b) % 100) - ((a - b) % 10)) / 10 + ((( a-b) % 10))+ ((( b) % 100000) - (( b) % 10000)) / 10000 + ((( b) % 10000) - (( b) % 1000)) / 1000 + ((( b) % 1000) - (( b) % 100)) / 100 + ((( b) % 100) - (( b) % 10)) / 10 + (((b) % 10)));
	}


	cout << ans << endl;
	return 0;
}

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

int main()
{
    int i,ck=0,y;
    char arr[5];

    cin>>y;
   sprintf(arr,"%d",y);
   for(i=0;i<4;i++)
    {
        if(arr[i]=='2')
        {
            ck=ck+1;
        }
    }
    cout<<ck<<endl;


    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

class SCC:
    def __init__(self, n):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.graph_rev = [[] for _ in range(n)]
        self.already = [False]*n
    
    def add_edge(self, fr, to):
        if fr == to:
            return
        self.graph[fr].append(to)
        self.graph_rev[to].append(fr)
    
    def dfs(self, node, graph):
        self.already[node] = True
        for n in graph[node]:
            if self.already[n]:
                continue
            self.dfs(n, graph)
        self.order.append(node)
    
    def first_dfs(self):
        self.already = [False]*self.n
        self.order = []
        for i in range(self.n):
            if self.already[i] == False:
                self.dfs(i, self.graph)
    
    def second_dfs(self):
        self.already = [False]*self.n
        self.ans = []
        for n in reversed(self.order):
            if self.already[n]:
                continue
            self.already[n] = True
            self.order = []
            self.dfs(n, self.graph_rev)
            self.order.reverse()
            self.ans.append(self.order)

    def scc(self):
        self.first_dfs()
        self.second_dfs()
        return self.ans


def main():
    n, m = map(int, input().split())
    scc = SCC(n)

    for i in range(m):
        a, b = map(int, input().split())
        scc.add_edge(a, b)
    
    scc_list = scc.scc()

    print(len(scc_list))
    for s in scc_list:
        print(len(s), end=" ")
        print(*s)

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 200108
#include<stdio.h>
int main()
{
    unsigned long long int x, y;
    scanf("%lld %lld", &x, &y);
    unsigned long long int ans = 0;
    while (x <= y)
    {
        ans++;
        x *= 2;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String s = br.readLine();
        int ans = 0;
        
        for(int i = 0; i < s.length() / 2; i++){
            if(s.charAt(i) != s.charAt(s.length() - i - 1)){
                ans++;
            }
        }
        
        out.println(ans);
        out.close();
        
    }
}

Measured memory_bytes: 32764
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

int64 calc(const char *s,const int n,const int k){
  int64 res=0;
  int cntD=0;
  int cntM=0;
  int64 cntDM=0;
  int i;
  for(i=0;i<k;i++){
    if(s[i]=='D'){
      cntD++;
    } else if(s[i]=='M'){
      cntM++;
      cntDM+=cntD;
    } else if(s[i]=='C'){
      res+=cntDM;
    }
  }
  int64 cntLDM=0;
  for(i=k;i<n;i++){
    if(s[i-k]=='D'){
      cntLDM+=cntM;
      cntD--;
    } else if(s[i-k]=='M'){
      cntM--;
    }
    if(s[i]=='D'){
      cntD++;
    } else if(s[i]=='M'){
      cntM++;
      cntDM+=cntD;
    } else if(s[i]=='C'){
      res+=cntDM-cntLDM;
    }
  }
  return res;
}

void run(void){
  int n;
  scanf("%d",&n);
  char *s=(char *)calloc(n+1,sizeof(char));
  scanf("%s",s);
  int q;
  scanf("%d",&q);
  while(q--){
    int k;
    scanf("%d",&k);
    int64 ans=calc(s,n,k);
    printf("%lld\n",ans);
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


int main(void) {
  ll N, M;
  cin >> N >> M;
  ll i;
  
  priority_queue<ll> q;
  for(i=0; i<N; i++) {
    ll a;
    cin >> a;
    q.push(a);
  }
  
  for(i=0; i<M; i++) {
    ll u=q.top();
    q.pop();
    q.push(u/2);
  }
  
  ll ans=0;
  for(i=0; i<N; i++) {
    ans+=q.top();
    q.pop();
  }
  
  pt(ans);
}


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

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> c(h);
    rep(i,h) cin>>c[i];

    rep(i,h){
        cout<<c[i]<<"\n";
        cout<<c[i]<<"\n";
    }
    return 0;
}

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

int main(){
    int N,M,max = 0;
    int cnt = 0;
    cin >> N;
    vector<string> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    cin >> M;
    vector<string> b(M);
    for(int i = 0; i < M; i++){
        cin >> b.at(i);
    }

    for(int i = 0; i < N; i++){
        string t;
        t = a.at(i);
        for(int j = i; j < N; j++){
            if(t == a.at(j)) cnt++;
        }
        for(int j = 0; j < M; j++){
            if(t == b.at(j)) cnt--;
        }
        if(max <= cnt) max = cnt;
        cnt = 0;
    }
    cout << max << endl;
}

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

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    priority_queue<ll> pq;
    REP(i, n){
        cin >> a[i];
        pq.push(a[i]);
    }
    ll ans = 0;
    REP(i, m){
        auto top = pq.top();
        pq.pop();
        pq.push(top / 2);
    }

    REP(i, n){
        ans += pq.top();
        pq.pop();
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        if((a == 5) && (b == 5) && (c == 7)){
            System.out.println("YES");
        }else if((a == 5)&&(b == 7)&&(c==5)){
            System.out.println("YES");
        }else if((a==7)&&(b==5)&&(c==5)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23124
/*/ Author: KaySeeKay /*/

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

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)	
#define fn1 for( int i =1;i<=n;	i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;	
const int INF = 1e18L;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __trace_out_var(a);
    cerr << "; ";
    __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int dp[N];

signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int a,b,c,d;
		cin >>a>>b>>c>>d;
		int ans =-1e18;
		ans=max(ans,max(a,b)*max(c,d));		
		ans=max(ans,max(a,b)*min(c,d));		
		ans=max(ans,min(a,b)*max(c,d));		
		ans=max(ans,min(a,b)*min(c,d));		
		cout<<ans;
	}
	return 0;
}

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

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            long[] A = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);

            int Q = int.Parse(Console.ReadLine());

            List<int[]> BC = new List<int[]>();

            int[] count = new int[100001];

            for(int i = 0; i < A.Length; i++)
            {
                count[A[i]]++;
            }

            long answer = A.Sum();

            for(int i = 0; i < Q; i++)
            {
                BC.Add(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));

                answer += ((BC[i][1] - BC[i][0]) * count[BC[i][0]]);

                Console.WriteLine(answer);

                count[BC[i][1]] += count[BC[i][0]];

                count[BC[i][0]] = 0;
            }
        }
    }
}

Measured memory_bytes: 52160
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> X(M), sub(M, 0);
    rep(i, M) cin >> X[i];
    sort(X.begin(), X.end());

    rep(i, M - 1)
    {
        sub[i + 1] = X[i + 1] - X[i];
    }
    sort(sub.begin(), sub.end(), greater<int>());
    int ans = 0;
    reps(i, M, N - 1)
    {
        ans += sub[i];
    }
    cout << ans << endl;
 //   system("pause");
    return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
# 標準入力の取得
S = input()


def main() -> None:
    """Entry point
    """
    # 求解処理
    """
    先週"ABC"が開催された場合は"ARC"、
    先週"ARC"が開催された場合は"ABC"を返す
    """
    result = ""
    if S == "ABC":
        result = "ARC"
    elif S == "ARC":
        result = "ABC"

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int a, b, k, i, cnt = 0; cin >> a >> b >> k;
    if (a < b) swap(a, b);
    for (i = b; cnt < k; i--) if (a%i == 0 && b%i == 0) cnt++;
    cout << i + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

// いい感じにするやつ
void comb_table(vvl &C, ll N) {
  REP(i, N) {
    REP(j, i + 1) {
      if (j == 0 or j == i) {
        C[i][j] = 1LL;
      } else {
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
      }
    }
  }
}
int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vl V(N, 0);
  REP(i, N) cin >> V[i];
  sort(ALL(V), REV(ll));
  ll min = llINF;
  ll notmin = 0;
  long double sum = 0;
  vvl C = VVL(51, 51, 0);
  comb_table(C, 51);
  REP(i, A) {
    sum += V[i];
    if (V[i] < min) {
      min = V[i];
      notmin = i;
    }
  }
  ll count = 0;
  FOR(i, notmin, N) {
    if (V[i] == min)
      count++;
  }
  cout << fixed;
  cout << (sum / A) << endl;

  if (notmin == 0) {
    ll ans = 0;
    FOR(i, A, B + 1) { ans += C[count][i]; }
    cout << ans << endl;
  } else {
    cout << C[count][A - notmin] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize "O3"

#define F first
#define S second

#include <bits/stdc++.h>

using namespace std;

typedef __int128 T;
typedef pair<int, int> PII;

int n, m;
T a[50];
PII ans[100];

void go_pos() {
  for(int i = 1; i < n; ++i) {
    while(a[i] < a[i-1]) {
      int mxi = max_element(a, a+n) - a;
      ans[m++] = {mxi, i};
      a[i] += a[mxi];
    }
  }
}
void go_neg() {
  for(int i = n-2; i >= 0; --i) {
    while(a[i+1] < a[i]) {
      int mni = min_element(a, a+n) - a;
      ans[m++] = {mni, i};
      a[i] += a[mni];
    }
  }
}

int main() {
  int mx = INT_MIN, mn = INT_MAX;
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) {
    int x; scanf("%d", &x);
    a[i] = x;
    if(x > 0)
      mx = max(mx, x);
    if(x < 0)
      mn = min(mn, x);
  }
  if(is_sorted(a, a+n)) {
    puts("0");
    exit(0);
  }
  if(mx == INT_MIN) go_neg();
  else if(mn == INT_MAX) go_pos();
  else if(abs(mn) > mx) go_neg();
  else go_pos();
  //assert(is_sorted(a, a+n));
  //assert(m <= 2 * n);
  printf("%d\n", m);
  for(int i = 0; i < m; ++i)
    printf("%d %d\n", ans[i].F+1, ans[i].S+1);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;

    int a=K;
    a--;
    K+= a;

    if (N>=K){
        cout << "YES" <<endl;
    }else{
        cout << "NO" <<endl;
    }
}

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

int main()
{
    int A,B;
    cin >> A >> B;
    int C = A - 2 * B;
    
    if (A >= 2 * B) {
        cout << C << '\n';
    }
    else {
        cout << 0 << '\n';

    }
    

     return 0;
}


Measured memory_bytes: 888
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>     
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int a;

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> a;
   cout << a + a * a + a * a * a;
}               
 
signed main () {                                       
   #ifdef QWERTY
      freopen("input", "r", stdin);
   #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 3608
use std::io::{Read, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut iter = input.split_whitespace();

    loop {
        let n: i32 = iter.next().unwrap().parse().unwrap();
        let x: i32 = iter.next().unwrap().parse().unwrap();
        if n==0 && x==0 {
            break;
        }

        let mut count: i32 = 0;
        for a in 1..n+1 {
            for b in a+1..n+1 {
                let c = x-b-a;
                if b>=c {
                    break;
                }
                if c<=n {
                    count+=1;
                }
            }
        }
        out.write_fmt(format_args!("{}\n", count)).unwrap();
    }
}



Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define MAX 100010
#define pb push_back
#define ll long long
using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {

        ll a,b;
        cin>>a>>b;
        cout<<a*b;
        

    }


    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;


int main(){
  long int dp[4500][4]={0};
  for(int i=0;i<1001;i++){
    dp[i][0]++;
  }
  for(int i=1;i<4;i++){
    for(int j=0;j<4100;j++){
      for(int k=0;k<1001;k++){
        if(j-k>=0){
          dp[j][i]+=dp[j-k][i-1];
        }
      }
    }
  }
  int tmp;
  while(cin>>tmp){
    cout<<dp[tmp][3]<<endl;
  }
}

Measured memory_bytes: 1308
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    string str;
    cin >> str;

    cout << str[0] << str[1] << str[2] << "\n";
}


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

int main(void){
	
	int n,s;
	int s2;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s;
		cout<<"Case "<<i<<":"<<endl;
		for(int k=0;k<10;k++){
			s2=s*s;
			s2/=100;
			s=0;
			for(int j=1;j<=1000;j*=10){
				s+=(s2%10)*j;
				s2/=10;
			}
			cout<<s<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define cc 6.28318530717958623200
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

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

    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n - 1; i++) {
        int x;
        cin >> x;
        mp[x]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << mp[i] << '\n';
    }
    return 0;
}

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

const int inf=1<<25;
int N,M,H,K;

struct node{int to,cost,hour,num;};
vector<node> graph[110];

void add_edge(int from,int to,int cost,int hour,int num){
	node in={to,cost,hour,num};
	graph[from].push_back(in);
}

void add_both_edge(int from,int to,int cost,int hour,int num){
	add_edge(from,to,cost,hour,num);
	add_edge(to,from,cost,hour,num);
}

int s,t;

typedef tuple<int,int,int> state;

int dijkstra(int mask){
	int dist[100][25];
	rep(i,N)rep(j,H+1) dist[i][j]=inf;
	dist[s][0]=0;
	priority_queue<state,vector<state>,greater<state>> q;
	state init(0,s,0);
	q.push(init);
	while(!q.empty()){
		int c,v,t;
		tie(c,v,t)=q.top();q.pop();
		for(auto &e:graph[v]){
			int nc=c;
			if(~mask&(1<<e.num)) nc+=e.cost;
			int nv=e.to;
			int nt=t+e.hour;
			if(nt>H) continue;
			if(dist[nv][nt]>nc){
				dist[nv][nt]=nc;
				q.push(make_tuple(nc,nv,nt));
			}
		}
	}
	int res=inf;
	rep(i,H+1) res=min(res,dist[t][i]);
	return res;
}

int main(void){
	while(cin >> N >> M >> H >> K,N){
		rep(i,N) graph[i].clear();
		rep(i,M){
			int a,b,c,h,r;
			cin >> a >> b >> c >> h >> r;
			a--,b--,r--;
			add_both_edge(a,b,c,h,r);
		}
		cin >> s >> t;
		s--,t--;

		int P;
		cin >> P;
		int dp[1<<8];
		rep(i,1<<K) dp[i]=inf;
		dp[0]=0;
		rep(i,P){
			int l,d;
			cin >> l >> d;
			int mask=0;
			rep(j,l){
				int k;
				cin >> k;
				k--;
				mask|=(1<<k);
			}
			dp[mask]=min(dp[mask],d);
		}
		rep(i,1<<K)rep(j,1<<K) dp[i|j]=min(dp[i|j],dp[i]+dp[j]);

		int ans=inf;
		rep(i,1<<K) ans=min(ans,dp[i]+dijkstra(i));
		if(ans==inf)
			cout << -1 << endl;
		else
			cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1396
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

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

  int ans = 1;
  for (int i = 1; i < N; i++){
    if (S[i] != S[i - 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int N; cin >> N;
    int sumA = 0;

    vector<int> B(N-1);
    for(int i=0; i<N-1; i++){
        cin >> B.at(i);
    }
    
    sumA += B.at(0);

    for(int i=0; i<=N-3; i++){
        if(B.at(i) <= B.at(i+1)){
            sumA += B.at(i);
        }
        else{
            sumA += B.at(i+1);
        }    
    }

    sumA += B.at(N-2);

    cout << sumA << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
//#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
    string S,T;
    cin>>S>>T;
    int ls=S.size(),lt=T.size();
    int ans=0;
    rep(i,ls-lt+1){
        int n=0;
        rep(j,lt){
            if (T[j]==S[i+j]) n++;
        }
        if (ans<n) ans=n; 
    }
    ans=lt-ans;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
//std::ios::sync_with_stdio(false);
using namespace std;
typedef long long ll;
ll n,m;
ll sx;
ll sy;
ll mod=1e9+7;
ll x[200000],y[200000];
int main()
{
    cin>>n>>m;
    for(ll i=1;i<=n;i++)
    {
        cin>>x[i];
    }
    for(ll i=1;i<=m;i++)
    {
        cin>>y[i];
    }
    for(ll i=1;i<=n;i++)
    {
        sx+=((i-1)*x[i]-(n-i)*x[i])%mod;
        sx%=mod;
    }
    for(ll i=1;i<=m;i++)
    {
        sy+=((i-1)*y[i]-(m-i)*y[i])%mod;
        sy%=mod;
    }
    cout<<sx%mod*sy%mod<<endl;
    return 0;
}


Measured memory_bytes: 1792
H,W = map(int,input().split(" "))
ans = 10 ** 10
karians = [0,0,0]
if H % 3 == 0 or W % 3 == 0:
    ans = 0
k = int(W / 2)
for i in range(H + 1):
    karians = [i * W,k * (H - i),(W - k) * (H - i)]
    karians.sort()
    if (karians[2] - karians[0] < ans):
        ans = karians[2] - karians[0]
k = int(H / 2)
for i in range(W + 1):
    karians = [i * H,k * (W - i),(H - k) * (W - i)]
    karians.sort()
    if (karians[2] - karians[0] < ans):
        ans = karians[2] - karians[0]
if(W < ans): ans = W
if(H < ans): ans = H

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
using namespace std;
#pragma warning(disable:4996)
int n, m, q, dist[110000], mark[110000], u[210000], v[210000];
vector<pair<int, int>>x[110000], y[110000], z[110000]; bool used[210000];
bool isgood(int f) {
	for (int i = 0; i < z[f].size(); i++) {
		if (mark[z[f][i].first] == 0 && used[z[f][i].second] == false)return true;
	}
	return false;
}
int main() {
	scanf("%d%d%d", &n, &m, &q); queue<int>Q;
	for (int i = 0; i < m; i++) {
		int a, b; scanf("%d%d", &a, &b); u[i + 1] = a; v[i + 1] = b;
		x[a].push_back(make_pair(b, i + 1)); x[b].push_back(make_pair(a, i + 1));
	}
	Q.push(1); for (int i = 1; i <= n; i++)dist[i] = 999999; dist[1] = 0;
	while (!Q.empty()) {
		int a1 = Q.front(); Q.pop();
		for (int i = 0; i < x[a1].size(); i++) {
			if (dist[x[a1][i].first] > dist[a1] + 1) { dist[x[a1][i].first] = dist[a1] + 1; Q.push(x[a1][i].first); }
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < x[i].size(); j++) {
			if (dist[i] < dist[x[i][j].first]) { y[i].push_back(x[i][j]); }
			if (dist[i] > dist[x[i][j].first]) { z[i].push_back(x[i][j]); }
		}
	}
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		int a; scanf("%d", &a); used[a] = true;
		int E1 = u[a], E2 = v[a];
		if (dist[E1] == dist[E2]) { cnt += 0; }
		else {
			int a1 = 0; if (dist[E1] < dist[E2])a1 = E2; else a1 = E1;
			if (isgood(a1) == false && mark[a1] == 0) {
				queue<int>Q; Q.push(a1); cnt++; mark[a1] = 1;
				while (!Q.empty()) {
					int a2 = Q.front(); Q.pop();
					for (int j = 0; j < y[a2].size(); j++) {
						if (mark[y[a2][j].first] == 0 && isgood(y[a2][j].first) == false) {
							mark[y[a2][j].first] = 1; Q.push(y[a2][j].first); cnt++;
						}
					}
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 25700
# 整数Nの入力
N = int(input())
# 料理番号の数列Aの入力
A = list(map(int, input().split()))
# 満足度の数列Bの入力
B = list(map(int, input().split()))
# 満足度の数列Cの入力
C = list(map(int, input().split()))
# 満足度の合計
Sum = 0

for i in range(N):
	Sum = Sum + B[A[i] - 1]
	if i != 0 and A[i] == A[i - 1] + 1:
		Sum = Sum + C[A[i - 1] - 1]
print(Sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MAX 1000000001

ll power(ll x,ll y,ll p){
    ll res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    ll n;
	    cin >> n;
	    ll a=power(10,n,mod);
	    ll b=2*power(9,n,mod);
	    b%=mod;
	    ll c=power(8,n,mod);
	    if((a-b+c)>=0){
	        cout << a-b+c << endl;
	    }else{
	        cout << a-b+c+mod << endl;
	    }
	}
	return 0;
}

Measured memory_bytes: 3644
A, B, C = map(int, input().split())

if A == B and B == C and A % 2 == 0:
    print("-1")
else:
    ans = 0
    while True:
        if A%2==1 or B%2==1 or C%2==1:
            break
        a = B/2 + C/2
        b = A/2 + C/2
        c = A/2 + B/2
        A, B, C = a, b, c
        ans += 1
    print(ans)
    

Measured memory_bytes: 9252
#include<stdio.h>

int main(void){

  int H;//???
  int W;//?¨?
  int i,j;


  while(1){


    scanf("%d %d",&H,&W);
    if(H==0 && W==0)
      break;

    else{
      for(i=0;i<H;i++){
        if(i==0 || i==H-1){
          for(j=0;j<W;j++){
            printf("#");
          }
          printf("\n");
        }
        else{
          printf("#");
          for(j=1;j<W-1;j++){
            printf(".");
          }
          printf("#\n");
        }
      }printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<int,ll>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int main() {

	int n;
	cin>>n;
	if(n%10==2||n%10==4)cout<<"hon"<<endl;
	if(n%10==5||n%10==7)cout<<"hon"<<endl;
	if(n%10==9)cout<<"hon"<<endl;
	if(n%10==0||n%10==1)cout<<"pon"<<endl;
	if(n%10==6||n%10==8)cout<<"pon"<<endl;
	if(n%10==3)cout<<"bon"<<endl;

	return 0;
}


Measured memory_bytes: 3636
use std::io;

fn read_grid() -> Vec<Vec<char>> {
    let mut line = String::new();
    let mut inputs = Vec::<Vec<char>>::new();
    io::stdin().read_line(&mut line).unwrap();
    let hw: Vec<i32> = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect();
    line.clear();
    for _ in 0..hw[0] {
        io::stdin().read_line(&mut line).unwrap();
        let line_chars: Vec<char> = line.trim().chars().collect();
        inputs.push(line_chars);
        line.clear();
    }
    inputs
}

fn check_sharp(grid: &Vec<Vec<char>>, x: i32, y: i32) -> bool {
    let max_w = (grid[0].len() - 1) as i32;
    let max_h = (grid.len() - 1) as i32;
    if x > max_w || x < 0 {
        return false;
    }
    if y > max_h || y < 0 {
        return false;
    }

    let neighbor = grid[y as usize][x as usize];
    if neighbor == '#' {
        return true;
    }
    return false;
}

fn solve(grid: Vec<Vec<char>>) -> &'static str {
    let h = grid.len();
    let w = grid[0].len();
    for i in 0..h {
        for j in 0..w {
            if grid[i][j] == '.' {
                continue;
            }
            let x = j as i32;
            let y = i as i32;
            if check_sharp(&grid, x + 1, y)
                || check_sharp(&grid, x - 1, y)
                || check_sharp(&grid, x, y + 1)
                || check_sharp(&grid, x, y - 1)
            {
                continue;
            } else {
                return "No";
            }
        }
    }
    "Yes"
}

fn main() {
    let grid = read_grid();
    let res = solve(grid);
    println!("{}", res);
}


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

int main() {
  int N;
  cin >> N;
  vector<int> x(N), y(N), h(N);
  for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> h[i];
  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++) {
      bool f = true;
      int H = 1;
      for (int i = 0; i < N; i++) {
        if (h[i] > 0) H = (abs(x[i] - cx) + abs(y[i] - cy)) + h[i];
      }
      for (int i = 0; i < N; i++) {
        if (max(0, H - (abs(x[i] - cx) + abs(y[i] - cy))) != h[i]) f = false;
      }
      if (f) {
        cout << cx << " " << cy << " " << H << endl;
      }
    }
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n-1];
		int ans = 0;
		for (int i = 0;i < n;i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0;i < n;i++) {
			b[i] = sc.nextInt();
			ans += b[i];
		}
		for (int i = 0;i < n-1;i++) {
			c[i] = sc.nextInt();
		}
		for (int i = 0;i < n-1;i++) {
			if(a[i] == a[i+1] -1) {
				ans += c[a[i]-1];
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23120
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        int c = 0;
        while (x <= y) {
            x *= (long) 2;
            c++;
        }
        System.out.println(c);
    }

}


Measured memory_bytes: 21844
import numpy as np
import functools
import operator
import sys 

X, Y = list(map(int, input().split()))

for x in range(X + 1):
    # turu: x
    # kame: (X - x)

    val = 2 * x + 4 * (X - x)
    

    if val == Y:
        print('Yes')

        sys.exit()

print('No')
    


Measured memory_bytes: 27160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
int main(){
    ll n,ans=0;cin>>n;
    vector<ll> vec(10000000);
    for(ll i=0;i<1000;i++){
        for(ll j=0;j<10000;j++){
            for(int k=0;k<199;k++){
                vec.at(i+j+k)++;
            }
        }
    }
    cout<<n*n*n<<endl;
}


Measured memory_bytes: 78336
<?php
while(true){
    $input = explode(' ', trim(fgets(STDIN)));
    if($input[1] === '+'){
        $result[] = $input[0] + $input[2];
    }elseif($input[1] === '-'){
        $result[] = $input[0] - $input[2];
    }elseif($input[1] === '*'){
        $result[] = $input[0] * $input[2];
    }elseif($input[1] === '/'){
        $result[] = floor($input[0] / $input[2]);
    }else{
        break;
    }
}

echo implode("\n", $result);

?>

Measured memory_bytes: 15492
#include <stdio.h>
int main(){
    int a,b,c,x,i;
    i = 0;
    x = 0;
    scanf("%d %d %d",&a,&b,&c);
    for (x = a;x <= b;x++){
        if(c % x == 0){
        i++;
        }
    }
    printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 2104
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():

    N=int(input())
    H=list(map(int,input().split()))

    d=[1]*N


    for j in range(1,N):
        if H[j-1] >= H[j]:
            d[j]+=d[j-1]
        else:
            continue

    print(max(d)-1)



resolve()

Measured memory_bytes: 14224
s =input()
t = input()

minmin = len(t)
for i in range( 0, ( len(s) - len(t)) +1 ):
    tigamoji = 0
    for j in range( len(t)  ):
        if s[j+i] != t[j]:
            tigamoji += 1
    if tigamoji < minmin:
        minmin = tigamoji
print(minmin)

Measured memory_bytes: 73140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int a,b,c,d;cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0){
			cout<<"Yes"<<"\n";
			return 0;
		}
		a-=d;
		if(a<=0){
			cout<<"No"<<"\n";
			return 0;
		}

	}
}


Measured memory_bytes: 3592
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

int main()
{
    int k;

    cin >> k;


    if (k % 2 == 0) {
        cout << (k / 2) * (k / 2) << endl;
    }
    else {
        cout << (k / 2) * (k / 2 + 1) << endl;
    }

    return 0;

}

Measured memory_bytes: 3636
import collections
import bisect
n=int(input())
a=collections.Counter(map(int,input().split()))
a=list(a.values())
a.sort()
b=[0]*len(a)
b[0]=a[0]
for i in range(len(a)-1):
    b[i+1]=b[i]+a[i+1]
s=sum(a)
#print(a,b)
ans=[i for i in range(0,n+1)]
ans=ans[::-1]
for t in range(1,n+1):
    ANS=ans[n+(-n//t):]
    #print(ANS)
    for A in ANS:
        z=bisect.bisect_right(a,A)
        #print(z)
        if A*t<=(b[z-1] if z>=1 else 0)+A*(len(b)-z):
            print(A)
            break

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>v;
    rep(i,1,sqrt(m)+1){
        if(m%i==0){
            v.push_back(i);
            v.push_back(m/i);
        }
    }
    int ans=0;
    rep(i,0,v.size()){
        if((m/v.at(i))<n)continue;
        ans=max(ans,v.at(i));
    }
    cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
double eps = 1e-10;
int n,L,R;
double P,E,T,lo,hi;
double ans;
bool in(double x)
{
	if(lo<x+eps && x<hi+eps)return 1;
	return 0;
}
void sol(int pos, double l, double r, double s)
{
	if(pos==n)
	{
		if(in((l+r)/2))
			ans += s;
		return;
	}
	if(l>hi+eps)return;
	if(r+eps<lo)return;
	if(in(l) && in(r))
	{
		ans += s;
		return;
	}
	double m = (l+r)/2;
	if(m < T)
	{
		sol(pos+1,l,m,s*P);
		sol(pos+1,m,r,s*(1-P));
	}
	else
	{
		sol(pos+1,l,m,s*(1-P));
		sol(pos+1,m,r,s*P);
	}
}

int main()
{

	while(scanf("%d%d%d",&n,&L,&R)==3)
	{
		scanf("%lf%lf%lf",&P,&E,&T);
		lo = T-E;
		hi = T+E;
		ans = 0;
		sol(0,1.0*L,1.0*R,1.0);
		printf("%.6f\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;
import java.util.stream.IntStream;

public class Main {
    public static String process(TestCase testCase) {
        final String s = testCase.s;
        final int K = testCase.K;

        TreeSet<String> set = new TreeSet<>();
        final int length = s.length();
        IntStream.range(0, K + 1)
                .forEach(i ->
                        IntStream.range(0, length - i)
                                .forEach(j ->
                                        set.add(s.substring(j, j + i + 1))
                                )
                );

        return new ArrayList<>(set).get(K - 1);
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int K = sc.nextInt();

        return new TestCase(s, K);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final String s;
        final int K;

        public TestCase(String s, int K) {
            this.s = s;
            this.K = K;
        }
    }
}


Measured memory_bytes: 29560
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
}

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

int main() {
  int N, K, x;
  int cnt = 0;
  
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    cin >> x;
    if(x > (K-x)) cnt += (K-x)*2;
    else cnt += x*2;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256