akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int a,b,c;
    
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    
    if(a < b && b < c)
        printf("Yes\n");
    else
        printf("No\n");
        
    return 0;
    
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define ll long long
using namespace std;
//const int MOD = 1189732207;
const int MOD = 1000000009;
int cnt[5001][10001];
int res[10001];
ll pow1(ll n, ll p, int MOD){
  ll r, c;
  r = 1;
  c = n;
  while(p){
    if(p & 1){
      (r *= c) %= MOD;
    }
    (c *= c) %= MOD;
    p /= 2;
  }
  return r;
}
int n, k;
int calc(int r[], int s, int MOD){

  int cnt1 = 0;
  for(int i = 0;i < k;i++)
    cnt1 += r[i], (cnt1 >= MOD && (cnt1 -= MOD));
  cnt1 = (pow1(2, s, MOD) - cnt1 + MOD) % MOD;
  return cnt1;
}
int main(){
  cin >> n >> k;
  int a[n + 1];
  for(int i = 1;i <= n;i++)
    cin >> a[i];
  cnt[0][0] = 1;

  for(int i = 1;i <= n;i++){
    for(int j = 0;j <= 10000;j++){
      cnt[i][j] = cnt[i - 1][j];
      if(a[i] <= j)
        cnt[i][j] += cnt[i - 1][j - a[i]];
      if(cnt[i][j] >= MOD)
        cnt[i][j] -= MOD;
    }
  }
  int cnt1 = calc(cnt[n], n, MOD);
//  int cnt11 = calc(cnt[n], n, MOD2);

  int ans = 0;
  for(int i = 1;i <= n;i++){
    for(int j = 0;j <= 10000;j++){
      res[j] = cnt[n][j];
    }
    for(int j = a[i];j <= 10000;j++){
      res[j] -= res[j - a[i]];
      if(res[j] < 0)
        res[j] += MOD;
    }
    int cnt2 = calc(res, n - 1, MOD);
//    int cnt22 = calc(res, n - 1, MOD2);
//    cout << cnt2 << endl;
    if(cnt2 * 2 % MOD == cnt1)
      ans++;
  }
  cout << ans;
}


Measured memory_bytes: 195584
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,h,m = 0,a;
    cin >> n >> h;
    vector<ll> b(n);
    rep(i,n){
        cin >> a >> b[i];
        chmax(m,a);
    }
    RSORT(b);
    ll cnt = 0,c = 0;
    rep(i,n){
        if (b[i] > m){
            c += b[i];
            cnt++;
        }
        if (c >= h){
            PRINT(cnt);
            return 0;
        }
    }
    h -= c;
    if (h%m == 0) PRINT(cnt+h/m);
    else PRINT(cnt+h/m+1);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
constexpr int MX = 100005;
int x, y, a, b, c, p[MX], q[MX], r[MX], d, e, f;
long long ans;
int main(){
	scanf("%d%d%d%d%d", &x, &y, &a, &b, &c);
	rep(i,a) scanf("%d", p+i);
	rep(i,b) scanf("%d", q+i);
	rep(i,c) scanf("%d", r+i);
	sort(p, p+a, greater<int>());
	sort(q, q+b, greater<int>());
	sort(r, r+c, greater<int>());
	p[x] = q[y] = r[c] = 0;
	x += y;
	rep(i,x){
		if(p[d] >= q[e] && p[d] >= r[f]) ans += p[d++];
		else if(q[e] >= r[f]) ans += q[e++];
		else ans += r[f++];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1408
import sys
import numpy as np

input = sys.stdin.readline

N = int(input())
A, B, C = [], [], []
for i in range(N):
    a, b, c = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)

DP = np.zeros((N, 3))
DP[0, 0] = A[0]
DP[0, 1] = B[0]
DP[0, 2] = C[0]

for i in range(N-1):
    DP[i+1, 0] = A[i+1] + max(DP[i, 1], DP[i, 2])
    DP[i+1, 1] = B[i+1] + max(DP[i, 0], DP[i, 2])
    DP[i+1, 2] = C[i+1] + max(DP[i, 0], DP[i, 1])

print(int(max(DP[-1, 0], DP[-1, 1], DP[-1, 2])))

Measured memory_bytes: 26416
a,b = gets.split(" ")
a = a.to_i
b = b.to_i

tmp_a = a
tmp_b = b

#最大公約数を求める
#大小の入れ替え
if b > a
    tmp = a
    a = b
    b = tmp
end

#最大公約数を出す
r = a % b
while r != 0 do
    a = b
    b = r
    r = a % b
end

puts tmp_a * tmp_b / b

Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(Math.abs(a-x) < Math.abs(b-x)){
            System.out.println("A");
        } else {
            System.out.println("B");

        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  cout << max(a1, max(a2, a3)) - min(a1, min(a2, a3)) << endl;
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int n, a, b;

int main(){
	cin >> n >> a >> b;
	
	cout << min(a,b) << " " << max(0,a+b-n) << endl;
	
	return 0;
}

Measured memory_bytes: 256
n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    ans = 1
    for i in range(1, 10**6+1):
        if pow(i, n, 10**20) > p:
            break

        if p % pow(i, n, 10**20) == 0:
            ans = i
    print(ans)


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX_N 100000
#define MAX_M 100000
const int MAX = 100100;
const int MOD = 1000000007;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecbvecb vector<vector<bool>>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL<<60;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;


int n,m;
vecvec G;
int dp[MAX];


int rec(int v){
  if(dp[v]!=-1) return dp[v];
  int res=0;
  for(auto node:G[v]){
    res=max(res,rec(node)+1);
  }
  return dp[v]=res;
}
int main() {
  cin>>n>>m;
  G.assign(n,vec());
  for(int i=0;i<m;i++){
    int s,e;
    cin>>s>>e;
    s--;e--;
    G[s].push_back(e);
  }
  for(int i=0;i<n;i++) dp[i]=-1;
  int res=0;
  for(int i=0;i<n;i++) res=max(res,rec(i));
  cout<<res<<endl;
}


Measured memory_bytes: 8192
n = int(input())
s = input()
rcnt = s.count('R')
gcnt = s.count('G')
bcnt = s.count('B')

ans = rcnt*gcnt*bcnt

for i in range(n):
  for d in range(n):
    j = i + d
    k = j + d
    if k >= n:
      break
    if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
      ans -= 1
print(ans)

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	char a,b,c;
	cin >> a >> b>> c;
	int ans = 0;
	if(a == '1') ans++;
	if(b == '1') ans++;
	if(c == '1') ans++;
	cout << ans << "\n";	
	return 0;
}

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

int main() {
	int n,sum=0,a,b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		sum+=b-a+1;
	}
	cout<<sum<<endl;
	return 0;
}



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

int main(){
int N , M;
cin >> N >> M;
int A[10010];
int sum = 0;

for(int i = 0; i < M; i++) {
  cin >> A[i];
  sum+= A[i];
}
if(sum > N) cout << -1 << endl;
else cout << N - sum << endl;

}

Measured memory_bytes: 3656
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	int n;
	string s;
	cin >> n >> s;
	int tmp = 0;
	for (int i = 0; i < s.length(); i++) {
		// cout << i << " " << s << endl;
		if (s[i] == '(') {
			tmp++;
		} else {
			if (tmp == 0) {
				s = '(' + s;
				i++;
			} else {
				tmp--;
			}
		}
	}
	for (int i = 0; i < tmp; i++) {
		s = s + ')';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#57単語の検索
W=str(input())
w=str.upper(W)
c=[]
while True:
    T=str(input())
    t=str.upper(T)
    s=t.split()
    if T==('END_OF_TEXT'):
        break
    a=s.count(w)
    c.append(a)
print(sum(c))


Measured memory_bytes: 5556
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    long long n, p;
    cin >> n >> p;
    long long ans = 1;
    if(n == 1){
        cout << p << "\n";
        return 0;
    }
    for(int i = sqrt(p); i > 1; i--){
        if(p % i) continue;
        long long score = p;
        bool check = true;
        for(int j = 0; j < n; j++){
            if(score % i){
                check = false;
                break;
            }
            score /= i;
        }
        if(check){
            ans = i;
            break;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
   
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int C = B*2;
        
    if(A>C){
    	System.out.println(A-C);
    }else{
    	System.out.println(0);
    }
        
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


int main(){
    int N,L;
    cin >> N >>L ;
    int taste = 0;
    int mi = 1000000;
    for(int i=1;i<=N;i++){
        taste += (i+L-1);
        if(abs(i+L-1)<abs(mi))mi = i+L-1;
    }
    cout << taste-mi << endl;
    return 0;
}

Measured memory_bytes: 256
a,b,m = gets.chomp.split.map(&:to_i)
as = gets.chomp.split.map(&:to_i)
bs = gets.chomp.split.map(&:to_i)
ts = m.times.map{gets.chomp.split.map(&:to_i)}
min = as.min + bs.min
ts.each do |x,y,c|
  sum = as[x-1] + bs[y-1] - c
  min = sum if min > sum
end
puts min


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

ll N;

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n/i);
            }
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

int main() {
    cin >> N;
    
    vector<ll> div_N = divisor(N);

    ll ans = 1.0e18;
    for (int i = 0; i < (div_N.size()+1)/2; i++) {
        if (i > div_N.size()/2) {
            break;
        }
        else {
            ans = min(ans, div_N[i] + div_N[div_N.size() - 1 - i] -2);
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 384
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
email.kishor.josephite@gmail.com
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vi vector<int>v
#define si vector<int>s

/*for(vector<int>iterator it=v.begin();it!=v.end();it++)
{
    cout<<*it<< " ";
}
cout<< endl;
*/


//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // open;
    // close;
    LL n,tmp=0;
    cin>>n;
    for(int i=n;; i++)
    {
        if((i%111)==0)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define st(it) sort(it.begin(),it.end())
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/


int main(){
	int t = 0;
        rep(i,4){
          int j;
          scanf("%d",&j);
          t += j;
        }
        printf("%d\n",t/60);
        printf("%d\n",t%60);
	return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<ll, ll> p;

int n, w;

int main(){
  cin >> n >> w;
  vector<p> v1;
  vector<p> v2;
  vector<p> v3;
  vector<p> v4;
  vector<p> v;
  for (int i = 0; i < n; i++) {
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    v.push_back({tmp1, tmp2});
  }
  sort(all(v));
  int tmp = v[0].first;

  for(auto a : v){
    if(a.first == tmp) v1.push_back({a.second, a.first});
    if(a.first == tmp+1) v2.push_back({a.second, a.first});
    if(a.first == tmp+2) v3.push_back({a.second, a.first});
    if(a.first == tmp+3) v4.push_back({a.second, a.first});
  }
  sort(rall(v1));
  sort(rall(v2));
  sort(rall(v3));
  sort(rall(v4));

  ll res = 0;

  for (int i = 0; i <= int(v1.size()); i++) {
    for (int j = 0; j <= int(v2.size()); j++) {
      for (int k = 0; k <= int(v3.size()); k++) {
        for (int l = 0; l <= int(v4.size()); l++) {
          // int w_sum = v1[0].second * i + v2[0].second * j + v3[0].second * k + v4[0].second * l;
          ll w_sum = 0;
          if(v1.size() > 0) w_sum += v1[0].second * i;
          if(v2.size() > 0) w_sum += v2[0].second * j;
          if(v3.size() > 0) w_sum += v3[0].second * k;
          if(v4.size() > 0) w_sum += v4[0].second * l;

          if(w_sum > w) continue;
          ll sum = 0;
          for (int ii = 0; ii < i; ii++) sum += v1[ii].first;
          for (int jj = 0; jj < j; jj++) sum += v2[jj].first;
          for (int kk = 0; kk < k; kk++) sum += v3[kk].first;
          for (int ll = 0; ll < l; ll++) sum += v4[ll].first;
          res = max(res, sum);
        }
      }
    }
  }
  cout << res << endl;
}


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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

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

    if(a+b >= x){
        if(a > x){
            cout << "NO\n";
        }else{
            cout << "YES\n";
        }
    }else{
        cout << "NO\n";
    }

	return 0;
}


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


int main(){
    int n; cin >> n;
    map<ll,ll> m;
    ll amax = 0;
    vector<ll> a(n); rep(i,n){
        cin >> a[i];
        m[a[i]]++;
        if(amax < a[i]) amax = a[i];
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(m[a[i]] >= a[i]) ans += m[a[i]]-a[i];
        else ans += m[a[i]];
        m[a[i]] = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder(101);
		while(sc.hasNext()){
			char[] s = sc.next().toCharArray();
			sb.setLength(0);						//1文字ずつ
			char a = sc.next().charAt(0);
			if(a == 'X')break;
			if(a == 'U') {
				if(!(s[0] <= 'Z')) {
					s[0] = Character.toUpperCase(s[0]);
				}
			}
			else {
				if(s[0] <= 'Z') {
					s[0] = Character.toLowerCase(s[0]);
				}
			}
			sb.append(s[0]);
			for(int i=1;i<s.length;i++) {
				if(s[i]=='_') {
					s[i+1] = Character.toUpperCase(s[i+1]);
				}
				else if(s[i]<='Z' && a =='D') {
					s[i] = Character.toLowerCase(s[i]);
					sb.append('_').append(s[i]);
				}
				else sb.append(s[i]);
			}
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 26196
// atcoder/abc144/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;

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

  int n;
  lli k;
  while (cin >> n >> k) {
    vector<lli> a(n);
    vector<lli> f(n);
    cin >> a >> f;


    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());

    auto fn = [&] (lli x) {
      lli y = k;
      for (int i = 0; i < a.size(); ++i) {
        y -= max(0LL, a[i] - (x / f[i]));
      }
      return 0 <= y;
    };

    lli small = 0;
    lli large = 1e18+1;
    while (small + 1 < large) {
      lli mid = (small + large) / 2;
      if (fn(mid)) large = mid;
      else small = mid;
    }

    if (fn(small)) cout << small << endl;
    else cout << large << endl;
  }

  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL N = 1e5;
vector<pair<LL, LL>> adj[(LL)1e5 + 1];
vector<bool> visited((LL)1e5 + 1, false);
//vector<int> color((LL)1e5 + 1, -1);
void dfs(LL s)
{
    if (!visited[s])
    {
        visited[s] = true;
        //color[s] = col;
        for (auto x : adj[s])
        {
            if (x.second & 1)
            {
                dfs(x.first);
            }
            else
            {
                dfs(x.first);
            }
        }
    }
}

int main()
{
    fastinput;
    LL n, i, j, k, t, temp, M, tc;
    cin >> n>>tc;
    for (i = 1; i <= tc; i++)
    {
        cin >> j >> k >> t;
        adj[j].pb({k, t});
        adj[k].pb({j, t});
    }

    LL cnt = 0;
    for (i = 1; i <= n; i++)
    {
        if (!visited[i])
        {
            dfs(i);
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 11008
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(int arg_value,int arg_watch_id){
		value = arg_value;
		watch_id = arg_watch_id;
	}
	bool operator<(const struct Info &arg) const{
		return value < arg.value;
	};

	int value,watch_id;
};

int calc(int hour,int minute,int second){
	return 3600*hour+60*minute+second;
}

int N;

void func(){

	int a,b,c,hour,minute,second,tmp_hour,tmp_minute,tmp_second;

	vector<Info> V;

	for(int loop = 0; loop < N; loop++){
		scanf("%d %d %d",&a,&b,&c);

		for(int i = 0; i < 6; i++){

			switch(i){
			case 0: //H:M:S
				hour = a;
				minute = b;
				second = c;
				break;
			case 1: //H:S:M
				hour = a;
				minute = c;
				second = b;
				break;
			case 2: //M:H:S
				hour = b;
				minute = a;
				second = c;
				break;
			case 3: //M:S:H
				hour = c;
				minute = a;
				second = b;
				break;
			case 4: //S:H:M
				hour = b;
				minute = c;
				second = a;
				break;
			case 5: //S:M:H
				hour = c;
				minute = b;
				second = a;
				break;
			}

			for(int diff = 0; diff <= 59; diff++){
				tmp_hour = (hour+diff)%60;
				tmp_minute = (minute+diff)%60;
				tmp_second =  (second+diff)%60;

				if(tmp_hour%5 != tmp_minute/12)continue;
				tmp_hour /= 5;
				V.push_back(Info(calc(tmp_hour,tmp_minute,tmp_second),loop));
			}
		}
	}

	sort(V.begin(),V.end());

	bool check[10],FLG;

	int minimum = BIG_NUM,ans_left,ans_right;

	for(int left = 0; left < V.size(); left++){
		for(int right = left+N-1; right < V.size();right++){
			for(int i = 0; i < N; i++)check[i] = false;
			for(int i = left; i <= right; i++)check[V[i].watch_id] = true;

			FLG = true;
			for(int i = 0; i < N; i++){
				if(!check[i]){
					FLG = false;
					break;
				}
			}

			if(FLG){
				if(minimum > V[right].value-V[left].value){
					minimum = V[right].value-V[left].value;
					ans_right = V[right].value;
					ans_left = V[left].value;
				}
				break;
			}
		}
	}

	printf("%02d:%02d:%02d %02d:%02d:%02d\n",ans_left/3600,(ans_left%3600)/60,(ans_left%3600)%60,ans_right/3600,(ans_right%3600)/60,(ans_right%3600)%60);
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    bool yes = false;
    for (int i = 1;i < 1251;i++){
        int a, b;
        a = i * 0.08;
        b = i * 0.1;
        if (a == A){
            if(b == B){
                cout << i << endl;
                yes = true;
                break;
            }
        }
    }
    if (yes == false)
    cout << "-1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 main() {
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << fixed << setprecision(10) << sqrt(pow(c-a,2) + pow(d-b,2)) << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    int base=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==1)base=i;
    }
    int ans=0;
    ans+=(n-1)/(k-1);
    if((n-1)%(k-1)!=0)ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
 
 
int main(){
    int N;
    scanf("%d",&N);
    int S[N];
    for(int i = 0; i < N; i++)scanf("%d",&S[i]);
 
    int M;
    scanf("%d",&M);
 
    int Q[M];
    for(int i = 0; i < M; i++)scanf("%d",&Q[i]);
    sort(Q,Q+M);
 
    int left = 0,right,m,count = 0;
 
    for(int i = 0; i < M; i++){
        right = N-1;
        m = (left+right)/2;
 
        while(left <= right){
            if(S[m] == Q[i]){
                count++;
                left= m+1;
                break;
            }else if(S[m] > Q[i]){
                right = m-1;
            }else{ //S[m] < Q[i]
                left = m+1;
            }
            m = (left+right)/2;
        }
    }
    printf("%d\n",count);
}


Measured memory_bytes: 3796
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    ll N;
    cin >> N;
    vector<ll> lucas(100);
    lucas[0] = 2, lucas[1] = 1;
    for(int i = 2; i <= N; i++) {
        lucas[i] = lucas[i - 1] + lucas[i - 2];
    }
    cout << lucas[N] << endl;
    return 0;
}

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

int
main(){
    int n, alice=0, bob=0;
    cin >> n;
    stack<int> s;
    int arr[n];
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr+n);

    for(auto i : arr)
        s.push(i);
    while(!s.empty()){
        alice += s.top();
        s.pop();
        if(!s.empty())
            bob += s.top();
        else
            break;
        if(!s.empty())
            s.pop();
        else
            break;
    }
    cout << alice - bob << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cctype>
#include <complex>

using namespace std;

struct station {
    int c,s,f;
};

int howlong(const vector<station>& stations, int t, size_t i)
{
    if(i >= stations.size() - 1) return 0;
    auto& s = stations[i];
    int wait = t < s.s ?
        s.s - t :
        t % s.f == 0 ? 0 : s.f - t % s.f;
    int next =  wait + s.c;
    return next + howlong(stations, t + next, i + 1);
}

int main()
{
    size_t n;
    cin >> n;
    
    vector<station> stations;
    stations.reserve(n);
    for(size_t i = 0; i < n; ++i){
        station s;
        cin >> s.c >> s.s >> s.f;
        stations.push_back(move(s));
    }
    
    for(size_t i = 0; i < n; ++i){
        cout << howlong(stations, 0, i) << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 256
// Problem : B - Go to Jail
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include<bits/stdc++.h>
#define 	ll		    long long
#define 	rep(i,a,n)  for(int i=a;i<n;i++)
#define		rof(i,a,n)	for(int i=a;i>=n;i--)
#define 	MOD 		1000000007
#define 	ff 			first
#define 	ss 			second
#define 	pb 			push_back
#define 	all(x) 		(x).begin(),(x).end()
#define 	dg(x)		cerr << x << endl;
#define 	endl		"\n"


using namespace std;
const int N = 1e5 + 5;

void solve(){
	int n; cin >> n;
	
	pair<int,int> ar[n];
	rep(i, 0, n)
		cin >> ar[i].ff >> ar[i].ss;
		
	bool ans = false;
	rep(i, 2, n){
		
		if((ar[i].ff == ar[i].ss) && (ar[i - 1].ff == ar[i -1].ss) && (ar[i -2 ].ff == ar[i - 2].ss)){
			ans = true;
			break;
		}
	}
	if(ans)
		cout <<  "Yes";
	else
		cout << "No";
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 3652
n = int(input())
b = True
k = 0 #カウント用
i = 0
if n == 0:
    print(0)
elif n % 2 == 1:
    print(0)
else:
    while n // (10  * (5 ** i)) > 0:
        k += n // (10 * (5 ** i))
        i += 1
    print(k)

Measured memory_bytes: 38256
fn main() {
    let n = readln();
    let a: Vec<i64> = readln();
    let b: Vec<i64> = readln();
    let mut s = 0;
    let mut t = 0;
    for i in 0..n {
        if a[i] < b[i] {
            let diff = b[i] - a[i];
            s += (diff + 1) / 2;
            t += diff % 2;
        } else {
            let diff = a[i] - b[i];
            t += diff;
        }
    }
    if s >= t {
        println!("Yes");
    } else {
        println!("No");
    }
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll dp[3100][3100];
const ll md=998244353;
int main(){
	dp[0][0]=1;
	ll a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	for(int i=1;i<3100;i++){
		dp[0][i]=dp[0][i-1]*a%md;
		dp[i][0]=dp[i-1][0]*b%md;
	}
	for(int i=1;i<=c-a;i++){
		for(int j=1;j<=d-b;j++){
			dp[i][j]=dp[i-1][j]*(j+b)%md+dp[i][j-1]*(i+a)%md-(dp[i-1][j-1]*(i-1+a)%md*(j-1+b)%md)%md+md;
			dp[i][j]%=md;
		}
	}
	printf("%lld\n",dp[c-a][d-b]);
	return 0;
}


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



int main(){
	int n, k, d, a;
	cin >> n >> k;

	set<int> bag;
	for(int i=1; i <= n; i++) bag.insert(i);

	while(k--){
		cin >> d;
		while(d--){
			cin >> a;
			if(bag.count(a)) bag.erase(a);
		}
	}

	cout << bag.size() << endl;
}


Measured memory_bytes: 3568
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)
	n := a
	p := b

	if a < b {
		n, p = b, a
	}
	for i := 0; i < n; i++ {
		fmt.Print(p)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

/*
const int N=,P=;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }
*/

long long s, ax, ay, bx, by;
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("d.in", "r", stdin); 
#endif
	cin >> s;
	ax = by = (long long) sqrt(s);
	if (ax * by < s) ++ax, ++by;
	cerr << ax << " " << by << endl;
	bx = ax * by - s, ay = 1;
	printf("%lld %lld %lld %lld %lld %lld\n", 
		0ll, 0ll, ax, ay, bx, by);
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: i32,
        l: [i32; n],
    }

    let k: i32 = *l.iter().max().unwrap();
    let s: i32 = l.iter().sum();

    if k < s - k {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
// Try AtCoder
// author: Leonardone @ NEETSDKASU
let buf = '';
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
  let s = process.stdin.read();
  if (s !== null) { buf += s.toString(); }
});
process.stdin.on('end', () => {
  let [a, b, c] = buf.trim().split(' ');
  if (a === b) {
    console.log(c);
  } else if (b === c) {
    console.log(a);
  } else {
    console.log(b);
  }
});

Measured memory_bytes: 7500
#include <iostream>
#include <vector>
#include <bitset>
#include <map>
#include <list>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <tuple>
#include <utility>
#include <iterator>

#include <cstdio>
#include <cstdint>
#include <cmath>

using namespace std;

constexpr double pi = 3.141592653589793238462643383279502884197169399375;

namespace shamal{
	template<typename F, typename IndexType, typename TargetType>
	pair<bool, IndexType> lower_bound(F const& func, IndexType left, IndexType right, TargetType const& t){
		while(left <= right){
			auto const mid = left + (right - left) / 2;
			auto const val = func(mid);
			if(val > t){
				right = mid - 1;
			}else if(val < t){
				left = mid + 1;
			}else{ //if(left == right)
				right = mid;
			}
		}

		return {func(left) == t, left};
	}

	template<typename F, typename IndexType, typename TargetType>
	pair<bool, IndexType> binary_search(F const& func, IndexType left, IndexType right, TargetType const& t){
		while(left <= right){
			auto const mid = left + (right - left) / 2;
			auto const val = func(mid);
			if(val > t){
				right = mid - 1;
			}else if(val < t){
				left = mid + 1;
			}else{ //if(left == right)
				return {true, mid};
			}
		};

		return {false, left};
	}
};


int main(void)
{
	int n;
	cin >> n;
	list<pair<double, double>> vertexes;
	vertexes.push_back({0.0, 0.0});
	vertexes.push_back({100.0 / std::pow(3.0, n), 0.0});

	constexpr auto sixty_deg = pi / 3.0;

	while(vertexes.back().first < 100.0){
		auto offset = vertexes.back().first;
		decltype(vertexes) work;
		for(auto const& x : vertexes){
			work.push_back({
					x.first * cos(sixty_deg) - x.second * sin(sixty_deg) + offset,
					x.first * sin(sixty_deg) + x.second * cos(sixty_deg)
			});
		}
		work.pop_front();
		vertexes.merge(work);

		work.clear();
		offset = vertexes.back().first;
		for(auto ite = vertexes.rbegin(); ite != vertexes.rend(); ite++){
			auto const& x = *ite;
			work.push_back({
					2.0 * offset - x.first,
					x.second
			});
		}
		work.pop_front();
		vertexes.merge(work);
	}

	for(auto const& x : vertexes)
		cout << x.first << ' ' << x.second << endl;

	return 0;
}

Measured memory_bytes: 3516
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
manzoku = 0

for i in range(n):
    manzoku += b[a[i]-1]
    if i != 0:
        if (a[i]==a[i-1]+1):
            manzoku += c[a[i-1]-1]

print(manzoku)

Measured memory_bytes: 3064
//Rally

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
using ll = long long;
#define range(a) a.begin(),a.end()
const int inf = 1000000000; 

int main (){
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i,0,N)cin >> X[i];
    sort(range(X));
    int sum,Ans=inf;
    rep(i,1,101){
        sum = 0;
        rep(j,0,N)sum+=(X[j]-i)*(X[j]-i);
        Ans = min(Ans,sum);
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;
typedef long long ll;

int main() {
  int K,S;
  cin >> K >> S;
  int cnt=0;
  for (int X=0; X <= K; X++) {
    for (int Y=0; Y <= K; Y++) {
      int Z = S - Y -X;
      if (0 <= Z && Z <=K) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3564
import math as m

n = int(input())
dp = [-1]*(n+1)
dp[0] = 0

k_six =int(m.log(n, 6)) + 1
k_nine = int(m.log(n, 9)) + 1

plus = set([1] + [6**(i+1) for i in range(k_six)] + [9**(i+1) for i in range(k_nine)])

for i in range(n+1):
    for p in plus:
        if i + p > n:
            continue
        if dp[i+p]<0:
            dp[i+p] = dp[i] + 1
        else:
            dp[i+p] = min(dp[i]+1, dp[i+p])

#print(dp)
print(dp[-1])

Measured memory_bytes: 3828
def solve():
    N = int(input())
    a = list(map(int, input().split()))
    
    max_idx, min_idx = -1, -1
    max_a, min_a = -10 ** 6, 10 ** 6
    for i, ai in enumerate(a):
        if max_a < ai:
            max_a = ai
            max_idx = i
        if ai < min_a:
            min_a = ai
            min_idx = i
    
    ans = []
    if abs(min_a) <= abs(max_a):
        for i in range(N):
            ans.append([max_idx + 1, i + 1])
        for i in range(N - 1):
            ans.append([i + 1, i + 2])
    else:
        for i in range(N):
            ans.append([min_idx + 1, i + 1])
        for i in range(N, 1, -1):
            ans.append([i, i - 1])
    
    print(len(ans))
    for x, y in ans:
        print(x, y)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        InputStreamReader r = new InputStreamReader(System.in);
        int A1 = nextInt(r);
        int A2 = nextInt(r);
        int A3 = nextInt(r);
        String ans = A1+A2+A3 < 22 ? "win" : "bust";
        System.out.println(ans);
    }

    public static int nextInt(InputStreamReader r) throws Exception {
        String str = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            str += (char)c;
        }
        return Integer.parseInt(str);
    }
}


Measured memory_bytes: 22612
import numpy as np
from functools import reduce
import fractions

def main():
    N, X = map(int, input().split())
    x = np.absolute([int(i)-X for i in input().split()])
    if N == 1:
        print(x[0])
    else:
        print(reduce(fractions.gcd, x))


if __name__ == '__main__':
    main()

Measured memory_bytes: 25012
// Left を、釣り合うなら Balanced を、右に傾くなら Right
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a+b>c+d) cout << "Left" <<endl;
  else if (a+b<c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,r,l) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define INF (1LL<<62)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef tuple<long double,int,int> tdii;
const double PI = atan(1)*4;
const int MAXN = 405;
const double EPS = 1e-9;
pll dp[MAXN][MAXN]; //NUMERO  -  COSTO

int main (){
    ll n, c;
    cin>>n;
    forn(i,n){
        cin>>c;
        dp[0][i]=pll(c,0);
    }
    forn(i,n-1){
        c = dp[0][i].fi+dp[0][i+1].fi;
        dp[1][i]=pll(c,c);
    }

    fore(i,2,n-1){
        forn(j,n-i){
            c = LONG_LONG_MAX;
            forn(k, i){
                c=min(c, dp[i-1-k][j].se+dp[i-1-k][j].fi+dp[k][i+j-k].se+dp[k][i+j-k].fi);
            }
            dp[i][j] = pll(dp[i-1][j].fi+dp[0][i+j].fi,c);
        }
    }
//    forn(i,n){
//        forn(j,n){
//            if(i==0 || i==n-1)cout<<dp[i][j].fi<<" "<<dp[i][j].se<<"        ";
//            else cout<<dp[i][j].fi<<" "<<dp[i][j].se<<"     ";
//        }
//        cout<<endl;
//    }
    cout<<dp[n-1][0].se<<el;
}


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

typedef long long ll;

int main () {
    #ifdef TooLazy
        freopen("in.txt", "r", stdin);
    #endif // TooLazy

    ll q, h, s, d, n, mn1, mn2;

    cin >> q >> h >> s >> d >> n;

    mn1 = s;
    mn1 = min(mn1, q * 4LL );
    mn1 = min(mn1, h * 2LL );

    mn2 = d;
    mn2 = min(mn2, q * 8LL );
    mn2 = min(mn2, h * 4LL );
    mn2 = min(mn2, s * 2LL );


    ll ans = 0LL;

    if( n >= 2 ) {
        ll temp = n/2LL;
        ans += temp * mn2;
        n %= 2LL;
    }

    if( n==1LL ) {
        ans += mn1;
    }

    cout << ans << "\n";

    return 0 ;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (b < 10)b = a * 10 + b;
	else if (b < 100)b = a * 100 + b;
	else b = a * 1000 + b;
	if (int(sqrt(b))*int(sqrt(b)) == b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int N, K, Q;
    scanf("%d %d %d", &N, &K, &Q);
    int ans_r[N], cor[Q];
    for (int i = 0; i < N; i++) ans_r[i] = K - Q;
    for (int i = 0; i < Q; i++) {
        int tmp;
        scanf("%d", &tmp);
        cor[i] = tmp;
    }
    for (int i = 0; i < Q; i++) {
        ans_r[cor[i] - 1]++;
    }
    for (int i = 0; i < N; i++) {
        if (ans_r[i] <= 0) {
            printf("No\n");
        } else {
            printf("Yes\n");
        }
    }
}

Measured memory_bytes: 1280