akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>

#define IOS ios::sync_with_stdio(false); cin.tie(0)

using namespace std;

int main()
{
	int n;
	int i;
	long long sum = 0;
	cin >> n;
	vector<long long> cnt(100002);
	for (i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		cnt[tmp]++;
		sum += tmp;
 	}
	int q;
	cin >> q;
	for (i = 0; i < q; i++)
	{
		long long t, f;
		cin >> t >> f;
		sum -= t * cnt[t];
		sum += f * cnt[t];
		cnt[f] += cnt[t];
		cnt[t] = 0;
		cout << sum << "\n";
	}
	
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int a, b, c;
  set<int> s;
  cin >> a >> b >> c;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout << ((int)s.size() == 2 ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    ull amt=1000, stock=0, today, tomorrow;
    int N, i;
    std::cin >> N;

    vi rate(N+1, 0);
    floop(N)
        std::cin >> rate[i];

    for(i=1; i <= N; ++i)
    {
        today = rate[i-1], tomorrow = rate[i];
        if(today > tomorrow)
        {
            amt += (stock*today);
            stock = 0;
        }

        else if(today == tomorrow)
            continue;
        
        else // today < tomorrow
        {
            if(stock > 0)
            {
                amt += (stock*today);
                stock = 0;
            }

            stock = amt/today;
            amt -= stock*today;
        }
    }
    
    print(amt);

    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a;
    cin >> a;
    int b;
    cin >> b;
    int res = min(n * a, b);
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
string s;
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>s;
    bool chk=true;
    if(s[0]!='A')chk=false;
    int c=0;
    for(int i=2; i<sz(s)-1; i++)
        if(s[i]=='C')c++;
    if(!c || c>1)chk=false;
    for(int i=0; i<sz(s); i++)
    {
        if(s[i]!='A' && s[i]!='C')
        {
            bool flag=false;
            for(char ch='a'; ch<'z'; ch++)
                if(s[i]==ch)flag=true;
            if(!flag)chk=false;
        }
    }
    if(chk)cout<<"AC\n";
    else cout<<"WA\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int A,B,K,R[100];
    R[0]=1;
    int k=1;
    scanf("%d %d %d",&A,&B,&K);
    for (int i=2; i<=100; i++) {
        if(A%i==0 && B%i==0){
            R[k]=i;
            k++;
        }
    }
    k-=K;
    printf("%d\n",R[k]);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <iostream>
#include <iomanip>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_map;
using std::unordered_set;
using std::vector;
using std::lower_bound;
using std::upper_bound;

int main(int argc, char* argv[]) {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int max = -1;
  for (int i = 0; i < n - 1; ++i) {
    max = std::max(max, a[i + 1] - a[i]);
  }
  max = std::max(max, a[0] + k - a[n - 1]);
  cout << k - max;
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

struct RMinQ {
	static const int MAX_N = 1 << 18;
	int n, dat[2 * MAX_N - 1];
	RMinQ() {}
	RMinQ(int n_) { init(n_); }
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		for (int i = 0; i < 2 * n - 1; i++) dat[i] = INT_MAX;
	}
	void update(int k, int a) {
		k += n - 1;
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return INT_MAX;
		if (a <= l && r <= b) return dat[k];
		else {
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return min(vl, vr);
		}
	}
	int query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

struct RMaxQ {
	static const int MAX_N = 1 << 18;
	int n, dat[2 * MAX_N - 1];
	RMaxQ() {}
	RMaxQ(int n_) { init(n_); }
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		for (int i = 0; i < 2 * n - 1; i++) dat[i] = -1;
	}
	void update(int k, int a) {
		k += n - 1;
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return 0;
		if (a <= l && r <= b) return dat[k];
		else {
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return max(vl, vr);
		}
	}
	int query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

vector<int> p(200000);
RMinQ minq(200000);
RMaxQ maxq(200000);

signed main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> p[i];

	for (int i = 0; i < n; ++i)
		minq.update(i, p[i]);

	for (int i = 0; i < n; ++i)
		maxq.update(i, p[i]);

	vector<int> eq(n - 1);
	for (int i = 0; i < n - 1; ++i) {
		if (p[i] < p[i + 1])
			eq[i] = 1;
		else
			eq[i] = 0;
	}

	int tmp = 0;
	int c = 0;
	for (int i = 0; i < n - 1; ++i) {
		int new_tmp = eq[i] ? tmp + eq[i] : 0;
		if (tmp < k - 1 && new_tmp >= k - 1)
			c++;
		tmp = new_tmp;
	}

	int ans = 1 - max(c - 1, 0);
	for (int i = 1; i <= n - k; ++i) {
		if (p[i - 1] < minq.query(i, i + k - 1) && maxq.query(i, i + k - 1) < p[i + k - 1])
			continue;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6016
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20170410_AOJ
{
    class ALDS1_9A
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int n = int.Parse(line);
                int[] H = new int[n + 1];

                int[] vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                Array.Copy(vals, 0, H, 1, n);
                for (int i = 1; i <= n; i++)
                {
                    Console.Write(string.Format("node {0}: key = {1}, ", i, H[i]));
                    int p = i / 2;
                    if(p>0)
                    {
                        Console.Write(string.Format("parent key = {0}, ", H[p]));
                    }
                    int l = 2 * i;
                    if(l<=n)
                    {
                        Console.Write(string.Format("left key = {0}, ", H[l]));

                        int r = l + 1;
                        if (r <= n)
                        {
                            Console.Write(string.Format("right key = {0}, ", H[r]));
                        }
                    }
                    Console.WriteLine();
                }
            }
        }
    }
}



Measured memory_bytes: 9688
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var H = items[0];
            var N = items[1];
            var A = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();

            var total = A.Sum();
            var answer = total >= H ? "Yes" : "No";

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 19680
import numpy as np

l = list(input())
l = np.array(l)


state = 'AC'

if l[0] != 'A':
    state = 'WA'
else:
    l[0] = 'a'
    l2 = l[2:-1].copy()
    Cplace = np.where(l2=='C')[0]

    if len(Cplace) == 1:
        l2[Cplace[0]] = 'c'
        l[2:-1] = l2
        arr = ''.join(l)
        if not arr.islower():
            state = 'WA'

    else:
        state = 'WA'

print(state)



Measured memory_bytes: 15652
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
// #define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    ll n;
    cin>>n;
    vll v;
    rep2(i,1,10){
        v.pb(111*i);
    }
    ll s=LB(v,n);
    cout<<v[s]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int D; cin >> D;
    vector<int> c(27);
    for (int i = 1; i < 27; i++) {
        cin >> c[i];
    }

    vector<vector<int>> s(D+1, vector<int> (27));
    for (int i = 1; i < D+1; i++) {
        for (int j = 1; j < 27; j++) {
            cin >> s[i][j];
        }
    }

    vector<int> t(D+1);

    ll score = 0;
    vector<int> last(27, 0);
    int M;
    int MJ;
    for (int i = 1; i < D+1; i++) {
        M = 0;
        for (int j = 1; j < 27; j++) {
            if(s[i][j] + c[j] * (i-last[j]) > M){
                M = s[i][j] + c[j] * (i-last[j]);    
                MJ = j;
            }
        }
        t[i] = MJ;
        score += s[i][MJ];
        last[MJ] = i;
        for (int j = 1; j < 27; j++) {
            score -= c[j] * (i - last[j]);
        }
    }
    
    //ここまでが貪欲解の導出
    //ここから微調整

    // そのコンテストが開催された日の集合
    vector<set<int>> day(27, set<int> ());
    for (int i = 1; i < D+1; i++) {
        day[t[i]].insert(i);
    }
    for (int i = 1; i < 27; i++) {
        day[i].insert(0);
        day[i].insert(D+1);
    }

    //更新作業
    //i回目の更新では、i%D日目の開催をt[i%D]+7i%26に変更し、差分が正だったら更新
    int CNT = 100000;
    int dd, qq;
    int d1, d2;
    auto itr1 = day[1].lower_bound(0);
    dd = 1;
    ll diff;
    for (int i = 0; i < CNT; i++) {
        diff = 0;
        
        day[t[dd]].erase(dd);

        qq = rand() % 26 + 1;

        diff += s[dd][qq];
        diff -= s[dd][t[dd]];
        
        itr1 = day[qq].lower_bound(dd);
        d2 = *itr1;
        itr1--;
        d1 = *itr1;
        diff += c[qq] * (dd - d1) * (d2 - dd);

        itr1 = day[t[dd]].lower_bound(dd);
        d2 = *itr1;
        itr1--;
        d1 = *itr1;
        diff -= c[t[dd]] * (dd - d1) * (d2 - dd);

        //差分が正なら更新
        if(diff > 0){
            // tとsetを更新
            t[dd] = qq;
            day[qq].insert(dd);
        }
        else{
            day[t[dd]].insert(dd);
        }

        //ddを更新
        dd++;
        if(dd == D+1) dd = 1;

    }
    for (int i = 1; i < D+1; i++) {
        printf("%d\n", t[i]);
    }

}

Measured memory_bytes: 3760
package main

import (
	"fmt"
)

func main() {
  
	var N,M int
 
	fmt.Scan(&N,&M)
 
	H := SliceInt(N)
	A:= SliceInt(M)
	B:= SliceInt(M)
	all := make(map[int]int)
 
 
	for i:=0;i<N;i++{
 
		fmt.Scan(&H[i])
 
		all[i] = 1
 
	}
 
	for i:=0;i<M;i++{
 
		fmt.Scan(&A[i],&B[i])
	}
 
 
	for i:=0;i<M;i++{
 
		a := A[i]
		b := B[i]
 
		if H[a-1] >= H[b-1]{
 
			all[b-1] = 0
 
		}
	
		if H[b-1] >= H[a-1]{
		
			all[a-1] =0

		}
 
	}
 
	cnt :=0
 
	for _,val :=  range all{
 
		if val == 1{
			cnt++
		}
	}
 
	fmt.Println(cnt)
}

//SliceInt 引数サイズのSliceを返す
func SliceInt(a int) []int {

	IntSample := make([]int, a)

	return IntSample

}

Measured memory_bytes: 14976
import sys
input = sys.stdin.readline
N = int(input())
res = [0] * (N + 1)
x = 1
while x * x <= N:
  y = 1
  while y * y <= N:
    z = 1
    while z * z <= N:
      if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x in range(1, N + 1):
        res[x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x] += 1
      z += 1
    y += 1
  x += 1 

for r in res[1: ]: print(r)

Measured memory_bytes: 68984
#include<stdio.h>

int main()
{ 
	int N,i,counter,cheaker;
  	int A[200];
  
  	scanf("%d\n",&N);	
  
  	for(i=0;i<N;i++)
      scanf("%d",&A[i]);
   
  while(1)
  {
    for(i=0;i<N;i++)
    {
      	if(A[i]%2!=0)
        {
          cheaker=0;
      	  break;
        }
      cheaker=1;
    } 
    
    if(cheaker==1)
    {
      	for(i=0;i<N;i++)
        {
          	A[i]=A[i]/2;
        }
     counter++;
    }
    
    else break;
  }
  	printf("%d",counter);   
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>


using namespace std;
#define ll long long


int main(void){
    ll N,M,sumB=0;
    cin>>N>>M;
    vector<ll> A(N),B(M),C(M);
    for(ll i=0;i<N;i++) cin>>A.at(i);
    sort(A.begin(),A.end());
    for(ll i=0;i<M;i++) {
      cin>>B.at(i)>>C.at(i);
      sumB+=B.at(i);
    }
    vector<pair<ll,ll>> CB(M);
    for(ll i=0;i<M;i++) CB.at(i)=make_pair(C.at(i),B.at(i));
    sort(CB.begin(),CB.end());
    reverse(CB.begin(),CB.end());
    
    vector<ll> Changing(min(N,sumB));
    ll k=0;
    for(ll i=0;i<min(N,sumB);i++){
        if(CB.at(k).second==0) k++;
        Changing.at(i)=CB.at(k).first;
        CB.at(k).second--;
    }
    
    ll ans=0;
    for(ll i=0;i<min(N,sumB);i++) A.at(i)=max(A.at(i),Changing.at(i));
    for(ll i=0;i<N;i++) ans+=A.at(i);
    cout<<ans<<endl;
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  ll L, R; cin >> L >> R;
  if(R - L < 2019) {
    ll ans = 2018;
    for(ll i = L; i <= R; ++i) {
      for(ll k = i + 1; k <= R; ++k) {
        ll tmp = (i * k) % 2019;
        if(ans > tmp) ans = tmp;
      }
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;

int main(void){
    int H,W,N;
    cin >> H >> W >> N;
    float h = N/H;
    float w = N/W;
    int ans;
    if(h>w){
        if(N%W!=0){
            ans = (N/W)+1;
        }else{
            ans = N/W;
        } 
    }else{
        if(N%H!=0){
            ans = (N/H)+1;
        }else{
            ans = N/H;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const long long mod = 1e9 + 7;

int n;
int arr[MAXN];
int segtree[MAXN];
long long reqd;
long merge(long x, long y){
    return x + y;
}
void segtree_update(int ind, long val){
    for(segtree[ind += n] += val; ind > 1; ind >>= 1)
        segtree[ind >> 1] = merge(segtree[ind], segtree[ind ^ 1]);
}
long segtree_query(int l, int r){
    long res = 0;
    for(l += n, r += n; l < r; l >>= 1, r >>= 1){
        if((l & 1) == 1)
            res = merge(res, segtree[l++]);
        if((r & 1) == 1)
            res = merge(res, segtree[--r]);
    }
    return res;
}
bool check(int mid){
    map<int, int> mp;
    set<int> s;
    s.insert(0);
    int sum = 0;
    int i = 0;
    for(i = 0; i < n; i++){
        sum += (arr[i] <= mid) ? 1 : -1;
        s.insert(sum);
    }
    i = 0;
    for(int x : s)
        mp[x] = i++;
    memset(segtree, 0, sizeof(segtree));
    segtree_update(mp[0], 1);
    sum = 0;
    long long cnt = 0;
    for(i = 0; i < n; i++){
        sum += (arr[i] <= mid) ? 1 : -1;
        cnt += segtree_query(0, mp[sum]);
        segtree_update(mp[sum], 1);
    }
    return cnt >= reqd;
}
void solve(){
    int lo = 0, hi = 1e9, ans = -1;
    long long tot = n * 1LL * (n + 1) >> 1;
    if(tot % 2)
        reqd = (tot + 1) / 2;
    else
        reqd = (tot + 2) / 2;
    while(lo <= hi){
        int mid = (lo + hi) >> 1;
        if(!check(mid))
            lo = mid + 1;
        else{
            hi = mid - 1;
            ans = mid;
        }
    }
    cout << ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i = 0;
    cin >> n;
    for(i = 0; i < n; i++)
        cin >> arr[i];
    solve();
    return 0;
}


Measured memory_bytes: 14168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second 
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define pp pair<ll,ll> 
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1 ;
void solve()
{
    ll n ;
    cin >> n ;
    vector<ll> a(n) , b(n) , c(n) ;
    rep( i , 0 , n ){
        cin >> a[i] ;
    }
    rep( i , 0 , n )
        cin >> b[i] ;
    rep( i , 0 , n - 1 )
        cin >> c[i] ;
    ll ans = 0 ;
    rep( i , 0 , n ){
        ans += b[a[i]-1] ;
        if( i>0 and a[i] == a[i-1] + 1 ){
            ans += c[a[i-1]-1] ;
		
		}
    }
    cout << ans ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,h,w;
long long ans=0;
int main(void){
    cin>>n>>h>>w;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        ans+=min(a/h,b/w);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#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(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, q;
int s[100100];

int main() {
	cin >> n;
	rep(i, n)cin >> s[i];
	int ans = 0;
	cin >> q;
	rep(i, q) {
		int num;
		cin >> num;
		rep(j, n) {
			if (num == s[j]) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3120
H,W = map(int,input().split())
a = [list(input()) for _ in range(H)]

mod = 10**9+7
maze = [[0 for _ in range(W)] for _ in range(H)]

mm = 1
for w in range(W):
    if a[0][w] == '#':
        mm = 0
    maze[0][w] = mm

mm = 1
for h in range(H):
    if a[h][0] == '#':
        mm = 0
    maze[h][0] = mm

for h in range(1,H):
    for w in range(1,W):
        if a[h][w] == ".":
            maze[h][w] = (maze[h-1][w]+maze[h][w-1])%mod

print(maze[H-1][W-1])

Measured memory_bytes: 52436
#include<iostream>

using namespace std;
void looping(int biggest,int smallest){
    string result = "";
    for(int i =0 ; i < biggest; i++){
        result += to_string(smallest);
    }
    cout<<result<<endl;
}
int main(){
    int a,b;

    cin >>a>>b;
   
    if (a == b){
       looping(a,b);
    }else if (a > b){
        looping(a,b);
    }else{
        looping(b,a);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int h = sc.nextInt();
	int w = sc.nextInt();
	String[] a = new String[h];
	for(int i = 0; i < h; i++) {
		a[i] = sc.next();
	}
	for(int i = 0; i <= w; i++) {
		System.out.print("#");
	}
	System.out.println("#");
	for(int i = 0; i < h; i++) {
		System.out.print("#");
		System.out.print(a[i]);
		System.out.println("#");
	}
	for(int i = 0; i <= w; i++) {
		System.out.print("#");
	}
	System.out.println("#");
}
}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

typedef double ld;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 1e8 + 10;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int main(){ _

	int N,M;
	cin >> N >> M;

	vector<vector<int>> g(N+1, vector<int>(N+1, INF));

	vector<tuple<int,int,int>> E;

	while(M--){
		int x,y,z;	
		cin >> x >> y >> z;
		
		g[x][y] = z;
		g[y][x] = z;
		E.pb({x,y,z});
	}

	for(int k = 1; k <= N; k++){
		for(int i = 1; i <= N; i++){
			for(int j = 1; j <= N; j++){
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}

	int ans = 0;
	for(auto [x,y,z] : E){
		if(g[x][y] != z) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
int n, ans = 0;
int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		ans += n / i;
		if (n % i == 0)ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
import bisect
def factor(N):
    arr=[]
    for i in range(1,int(N**0.5)+1):
        if(N%i==0):
            arr.append(i)
            if(N//i!=i):
                arr.append(N//i)
    return arr

N,M=map(int,input().split())
li=sorted(factor(M))
res=1
for i in li:
    if(i>M//N):
        break
    if(M//i>=N):
        res=i
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];
int main(){
    int n,w;
    cin >> n >> w;
    vector<int> x(n),v(n);
    rep(i,n) cin >> x[i] >> v[i];
    dp[0][0] = 0;
    rep(i,n){
        rep(j,100100){
            chmax(dp[i+1][j],dp[i][j]);
            if(j-x[i]>=0){
                chmax(dp[i+1][j],dp[i][j-x[i]]+v[i]);
            }
        }
    }
    cout << dp[n][w] <<endl;
}


Measured memory_bytes: 81756
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vi a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int l = 0, r = n;
  while (r - l > 1) {
    int t = (l + r) / 2;
    vl pw(1, 1);
    if (t != 1) while (pw.back() <= n) {
      pw.push_back(pw.back() * t);
    }
    vi x(1, a[0]);
    vl val(1, 0);
    int cur = a[0];
    bool fail = 0;
    for (int i = 1; !fail && i < n; ++i) {
//      cerr << t << ' ' << i << endl;
      if (a[i] > cur) {
        x.push_back(a[i] - cur);
        cur = a[i];
        val.push_back(0);
      } else {
        while (cur - a[i] >= x.back()) {
          cur -= x.back();
          x.pop_back();
          val.pop_back();
        }
        while (cur > a[i] && val.back()) {
          --x.back();
          --cur;
          val.back() /= t;
        }
        x.back() -= cur - a[i];
        cur = a[i];
        ++val.back();
//        if (t == 2) cerr << cur << ' ' << x.size() << ' ' << x.back() << ' ' << val.back() << endl;
        if (t == 1) {
          fail = 1; break;
        }
        assert(!val.empty() && val.size() == x.size());
        int it = (int)val.size() - 1;
        while (1) {
          if (x[it] >= (int)pw.size() || val[it] < pw[x[it]]) break;
          if (it == 0) {
            fail = 1; break;
          } else {
            val[it] = 0;
            val[it-1]++;
            --it;
          }
        }
      }
    }
    if (fail) l = t;
    else r = t;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 5820
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;

    int ans = -1;
    for (int i = 1; i < 1250 + 1; i++) {
        if ((int)floor(i * 0.08) == a && (int)floor(i * 0.1) == b) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}

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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;

    vector<int> t(N+1, 0);
    vector<int> x(N+1, 0);
    vector<int> y(N+1, 0);
    for(int i = 0; i < N; i++){
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }

    bool ans = true;
    for(int i = 0; i < N; i++){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1]- x[i]) + abs(y[i+1]- y[i]);
        if(dt%2 != dist %2) ans = false;
        if(dt < dist) ans = false;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	set<int> red, green;
	vector<int> p(a), q(b), r(c);
	for (int i = 0; i < a; i++)cin >> p[i];
	for (int i = 0; i < b; i++)cin >> q[i];
	for (int i = 0; i < c; i++)cin >> r[i];
	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	for (int i = 0; i < x; i++)r.push_back(p[i]);
	for (int i = 0; i < y; i++)r.push_back(q[i]);
	sort(r.rbegin(), r.rend());
	ll ans = 0;
	for (int i = 0; i < x + y; i++) {
		ans += r[i];
	}
	cout << ans;
}

Measured memory_bytes: 2552
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t H,W,K;
  cin >> H >> W >> K;
  vector<vector<char>> C(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> C[i][j];
    }
  }

  int64_t res = 0;
  int hmax = (1 << H) - 1;
  int wmax = (1 << W) - 1;
  for (int h = 0; h <= hmax; h++) {
    for (int w = 0; w <= wmax; w++) {
      int bcnt = 0;
      for (int i = 0; i < H; i++) {
        if (((h >> i) & 1) == 1) continue;
        for (int j = 0; j < W; j++) {
          if (((w >> j) & 1) == 1) continue;
          if (C[i][j] == '#') {
            bcnt++;
          }
        }
      }
      if (bcnt == K) {
        res++;
      }
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 3656
use std::cmp::max;
fn main() {
    let n = read::<usize>();

    let mut ansv = vec![];
    for i in 0..n-1 {
        let v = read_vec::<u32>();
        let c = v[0];
        let s = v[1];
        let f = v[2];

        for j in 0..i {
            ansv[j] = ((max(s, ansv[j]) + f - 1) / f) * f + c;
        }

        ansv.push(s+c);
    }

    for a in ansv {
        println!("{}", a);
    }
    println!("0");
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    ll a, b;
    cin >> a >> b;

    cout << lcm(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


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


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')

import numpy as np

def main():
	n,m,x=MI()
	C=[]
	A=[]
	for _ in range(n):
		c_,*A_=LI()
		C.append(c_)
		A.append(A_)
	A=np.array(A)
	
	ans=10**10
	
	for i in range(1<<n):
		B=np.zeros(m)
		cnt=0
		for j in range(n):
			if 1<<j&i:
				cnt+=C[j]
				B+=A[j]
		if np.min(B)>=x:
			ans=min(ans,cnt)
	print(ans if ans!=10**10 else -1)
	





if __name__=="__main__":
	main()


Measured memory_bytes: 27116
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b;
int32_t main(){
CODE_START;
cin>>a;
cin>>b;
cout<<max(0LL,a-b);
}


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

using namespace std;

typedef pair<int, int> P;

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

    int n,m;//????????°,??????
    while(cin>>n>>m,n||m){
        vector<P> v;
        for(int i=0;i<n;i++){
            int d,p;cin>>d>>p;//?????¢,?????????
            v.push_back(P(p,d));
        }
        int res=0;
        sort(v.rbegin(),v.rend());
        for(int i=0;i<n;i++){
            int pot=v[i].first,dis=v[i].second;
            if(dis<=m){
                m-=dis;
                continue;
            }
            else{
                dis-=m;
                m=0;
                res+=pot*dis;
            }
        }
        cout<<res<<endl;
    }
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D; 
  if(A + B == C + D){
    cout << "Balanced" << endl;
  }else if(A + B < C + D){
  	cout << "Right" << endl;
  }else{
    cout << "Left" << endl;
  }}

Measured memory_bytes: 256
//-------------
//include
//-------------
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  vector<string>VS;
typedef  set<int> SI;
typedef  set<string> SS;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	int N,ANS=0;
	cin >> N;
	REP(i, N)
	{
		int F, S;
		cin >> F >> S;
		ANS += (S - F) + 1;
	}
	COUT(ANS);
#ifdef _DEBUG
	while (1);
#endif // _DEBUG

	return 0;
}

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

using namespace std;

int main(){
   
    int a,b;
    
    while(cin >> a >> b){
        
        if(a == 0 && b == 0){
            break;    
        }
        
		if(a > b){
			cout << b << " " << a << endl;
		}else{
			cout << a << " " << b << endl;
		}
    }
    
    return 0;
}

Measured memory_bytes: 3008
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    ans+=b-a+1;
  }
  cout<<ans<<endl;
  
  
  
  return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
    "os"
)

type Move struct {
    from int
    to   int
}

func solve(N int, moves []Move) int {

    var maybe []bool = make([]bool, N)
    var numBalls []int = make([]int, N)
    maybe[0] = true
    for i := 0; i < N; i++ {
        numBalls[i] = 1
    }

    for _, move := range moves {
        //fmt.Printf("move %v->%v\n", move.from, move.to)

        if maybe[move.from-1] {
            maybe[move.to-1] = true
        }
        numBalls[move.from-1]--
        numBalls[move.to-1]++
        if numBalls[move.from-1] == 0 {
            maybe[move.from-1] = false
        }
    }

    ans := 0
    for i := 0; i < N; i++ {
        if maybe[i] {
            ans++
        }
    }

    return ans
}

func main() {

    var N, M int
    fmt.Fscanf(os.Stdin, "%d %d\n", &N, &M)

    var moves []Move
    for i := 0; i < M; i++ {
        var from, to int
        fmt.Fscanf(os.Stdin, "%d %d\n", &from, &to)
        moves = append(moves, Move{from: from, to: to})
    }

    ans := solve(N, moves)
    fmt.Printf("%v\n", ans)
}


Measured memory_bytes: 8832
use text_io::*;
use std::collections::*;
use std::process::exit;
use std::cmp::max;
use std::fs::read;

fn main() {
    let mut n:usize = read!();
    let mut va:Vec<usize> = Vec::new();
    let mut vb:Vec<usize> = Vec::new();
    for i in 0..n+1 {
        let mut a:usize = read!();
        va.push(a);
    }
    let mut sum:usize = 0;
    for i in 0..n {
        let mut a:usize = read!();
        if va[i]<=a {
            sum+=va[i];
            if va[i+1]+va[i]<a {
                sum+=va[i+1];
                va[i+1]=0;
            }
            else {
                va[i+1]=va[i+1]+va[i]-a;
                sum+=a-va[i];
            }
        }
        else {
            sum+=a;
        }
    }
    println!("{}",sum);
}

Measured memory_bytes: 2932
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> n;
	vector<ll> v(n+1);
	v[0] = 2;
	v[1] = 1;
	for (ll i = 2; i <= n; i++) {
		v[i] = v[i - 1] + v[i - 2];
	}
	cout << v[n] << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final String varN = sc.next();
        sc.close();

        int resultNo = Stream.of(varN.split("")).mapToInt(Integer::parseInt).sum();
        String result;
        if (resultNo % 9 == 0) {
            result = "Yes";
        } else {
            result = "No";
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 65496
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        const double pi = 3.14;
        //cout << pi << '\n';
        double r;
        cin >> r; 
        cout << 2 * pi * r << '\n';  
    }
}

Measured memory_bytes: 34684
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    vector<int> s(N); REP(i,N) cin >> s[i];
    int ans = 0; REP(i,N) ans += s[i];
    SORT(s);
    int ptr=0;
    if(ans%10 == 0){
        while(ptr<N && s[ptr]%10 == 0) ptr++;
        cout << (ptr==N ? 0 : ans-s[ptr]) << endl;
    }
    else{
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
class Main{
	public static void main(String args[]){
		BufferedReader readNum = new BufferedReader(new InputStreamReader(System.in));

		try{
			String stringNum = readNum.readLine();
			int Num = Integer.parseInt(stringNum);
			System.out.println((int)Math.pow(Num,3));
		}catch(IOException e){
			System.out.println("error");
		}

	}
}

Measured memory_bytes: 24168
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (_n, m) = get!(usize, usize);
    let mut v = Vec::new();
    for _ in 0..m {
        let tmp = get!(usize, usize);
        v.push(tmp);
    }
    v.sort_by(|a, b| a.1.cmp(&b.1));
    let mut now = v[0].1;
    let mut ans = 1;
    for i in 1..v.len() {
        if now < v[i].1 && now <= v[i].0 {
            ans += 1;
            now = v[i].1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define nav(...) "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
#define oo INT_MAX/2
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug() {cerr<<endl;}
	template<class T> debug& operator<<(T x) {cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<< (pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x) {
		*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(all(x));}
#else
	template<class T> debug& operator <<(const T&) {return *this;}
#endif
};


bool solve(void) {

	string s;
	cin>>s;
	int n = s.length();
	cout << string(n, 'x') << endl;
	return true;
}

int main(int argc, char* argv[]) {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


Measured memory_bytes: 256