akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cassert>
using namespace std;

inline int rgb(char c) {
    switch (c) {
        case 'R': return 0;
        case 'G': return 1;
        case 'B': return 2;
    }
    assert(false);
}

int main() {
    long long N; cin >> N;
    string S; cin >> S;

    //cerr << "[" << S << "]" << endl;

    // !A && !B
    long long c1 = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N-1; ++j) {
            int k = j + (j - i);
            if (k >= N) continue;
            if (S[i] == S[j] || S[i] == S[k] || S[j] == S[k]) {
                ++c1;
            }
        }
    }

    // !A
    int freq[3] = {0, 0, 0};
    for (int i = 0; i < N; ++i) {
        freq[rgb(S[i])]++;
    }
    long long c2 = 0;
    // 同じ色×3
    for (int i = 0; i < 3; ++i) {
        long long n = freq[i];
        c2 += n * (n-1) * (n-2) / 6;
    }
    // 同じ色×2 + 別の色
    for (int i = 0; i < 3; ++i) {
        long long n = freq[i];
        long long m = 0;
        for (int j = 0; j < 3; ++j) {
            if (j != i) m += freq[j];
        }
        c2 += (n * (n-1) / 2) * m;
    }

    // !B
    long long c3 = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N-1; ++j) {
            int k = j + (j - i);
            if (k >= N) continue;
            //cerr << i << ", " << j << ", " << k << endl;
            ++c3;
        }
    }

    long long all = N * (N-1) * (N-2) / 6;

    //cerr << "c1 = " << c1 << "; c2 = " << c2 << "; c3 = " << c3 << "; all = " << all << endl;

    cout << all - c2 - c3 + c1 << endl;

    return 0;
}



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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr int MAX = 55555;
std::vector<int> primes[5];
bool isNotPrime[MAX + 1];

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    primes[2].emplace_back(2);
    for(int i=4;i<=MAX;i+=2){
        isNotPrime[i] = true;
    }
    
    for(int i=3;i<=MAX;i+=2){
        unless(isNotPrime[i]){
            primes[i % 5].emplace_back(i);

            for(int j=i*2;j<=MAX;j+=i){
                isNotPrime[j] = true;
            }
        }
    }

    int N;
    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cout << primes[1][i] << " \n"[i + 1 == N];
    }
}


Measured memory_bytes: 384
/* Generated by powerful Codeforces Tool
 * Author: rockphy
 * Time: 2020-06-11 22:35:14
**/
#include  <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int X, N; cin >> X >> N;
    vector<int> a;
    for(int i=0; i<N; ++i){
        int tmp; cin >> tmp;
        a.push_back(tmp);
    }
    int rtn = X;
    auto p = find(a.begin(), a.end(), X);
    auto q = find(a.begin(), a.end(), X);
    int i=0;
    while((p-a.begin()!=N)&&(q-a.begin()!=N)){ // if p q both in
        ++i;
        p = find(a.begin(), a.end(), (X+i));
        q = find(a.begin(), a.end(), (X-i));
        // cout << i << ' ' << p-a.begin() << ' ' << q-a.begin() << '\n';
    }
    if(q-a.begin()==N){
        rtn = X-i;
    }else{
        rtn = X+i;
    }
    cout << rtn  << '\n';
}

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

int main() {
  int n;
  cin >> n;
  long long sum = 0;
  vector<int>cnt(n+1,0);
  vector<int>data(n);
  for(int i = 0;i < n;i++){
    cin >> data[i];
    cnt[data[i]]++;
    sum += cnt[data[i]]-1;
  }
  for(int i = 0;i < n;i++){
    cout << sum-(cnt[data[i]]-1) << endl;
  }
}


Measured memory_bytes: 4096
#include <iostream>
#include <unordered_map>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>
#include <unordered_set>

using namespace std;

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

	int res = a - (2 * b);

	if (res < 0) res = 0;

	cout << res;
}


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

int main(){
	string s;
	cin >> s;
	long long sum = 0;
	long long len = s.size();
	for(long long i=0;i<len;i++){
			long long  t = i,js1=0,js2=0;
			while(1){
				if(t == len-1){
					if(s[t] == '<')
						js1++;
					else
						js2++; 
					break;
				}
				if(s[t] == '>' && s[t + 1]  == '<'){
					js2++;
					break;
				}
				if(s[t] == '>')
					js2++;
				else if(s[t] == '<')
					js1++;
				t++;
			}
			i = t;
			if(js1 <= js2){
				long long  ss1 = 0;
				sum += (ss1 + (js1-1)) * js1 / 2;
				long long  ss2 = 1;
				sum += (ss2 + js2) * js2 / 2; 
			}
			else{
				long long  ss1 = 1;
				sum += (ss1 + js1) * js1 / 2;
				long long  ss2 = 0;
				sum += (ss2 + (js2-1)) * js2 / 2;
			}
	} 
	printf("%lld\n",sum);
	return 0; 
} /*
<>>><<>>>>><<<<
*/

Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

using namespace std;

#define ll long long

int main(void){
    vector<vector<int>> a(3, vector<int>(3, 0));
    for(int i = 0;i < 3;++i){
        for(int j = 0;j < 3;++j){
            cin >> a[i][j];
        }
    }

    int n;
    cin >> n;
    vector<int> b(n);
    for(int i = 0;i < n;++i)    cin >> b[i];

    for(int b_i = 0;b_i < n;++b_i){
        for(int a_i = 0;a_i < 3;++a_i){
            for(int a_j = 0;a_j < 3;++a_j){
                if(b[b_i] == a[a_i][a_j]){
                    a[a_i][a_j] = 0;
                }
            }
        }
    }

    int ans_flag = 0;

    for(int i = 0;i < 3;++i){
        if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0){
            ans_flag = 1;
        }
    }
    if(ans_flag == 0){
        for(int j = 0;j < 3;++j){
            if(a[0][j] == 0 && a[1][j] == 0 && a[2][j] == 0){
                ans_flag = 1;
            }
        }
    }
    if(ans_flag == 0){
        if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0){
            ans_flag = 1;
        }
        if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0){
            ans_flag = 1;
        }
    }

    if(ans_flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    // cout << endl;
    // for(int i = 0;i < 3;i++){
    //     for(int j = 0;j < 3;++j){
    //         cout << a[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    return 0;
}

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

#define ll long long;

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

	string s;
	cin>>s;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
    	cout<<"Yes";
    else
    	cout<<"No";

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
int arr[9], N, M, ans;
bool flg[9], e[9][9];
void dfs(int x){
	if(x == N){
		bool t = true;
		for(int i=1; i<N; i++){
			t &= e[arr[i-1]][arr[i]];
		}
		ans += t;
		return;
	}
	for(int i=0; i<N; i++){
		if(!flg[i]){
			flg[i] = true;
			arr[x] = i;
			dfs(x + 1);
			flg[i] = false;
		}
	}
	return;
}
int main(){
	scanf("%d%d", &N, &M);
	while(M--){
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		e[a][b] = true;
		e[b][a] = true;
	}
	flg[0] = true;
	arr[0] = 0;
	dfs(1);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1732
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    var num = input[0];
		var scores = [];
		for(var i=1;i<input.length;i++){
			scores.push(Number(input[i]));
		}
		var max = 0;
		scores.sort();
		var total = eval(scores.join("+"));
		if(total % 10 != 0){
			console.log(total);
			return;
		}
		for(var i=0;i<scores.length;i++){
			if((total - scores[i]) % 10 != 0 && (total - scores[i]) > max){
				max = (total - scores[i]);
			}
		}
		console.log(max);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast


    int n;
    cin>>n;

    vector<int> dp(3,0);

    forn(idx,0,n)
    {
        vi v(3),new_dp(3,0);
        forn(j,0,3)
        {
            cin>>v[j];
        }

        forn(i,0,3)
        {
            forn(j,0,3)
            {
                if(i!=j)
                {
                    new_dp[j] = max(new_dp[j],dp[i]+v[j]);
                }
            }
        }

        dp = new_dp;
    }    

    cout<<max(dp[0],max(dp[1],dp[2]));

    return 0;
}                   

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  vector<int> s(n+1,0);
  REP(i,n) s[i+1] = s[i] + a[i];

  vector<int> dp[n];
  REP(i,n) dp[i].assign(n+1,INF);
  REP(i,n) dp[i][i+1] = 0;

  FOR(i,2,n+1){
    REP(j,n){
      if(i+j > n) break;
      FOR(k,j+1,j+i) dp[j][j+i] = min(dp[j][j+i],dp[j][k]+dp[k][j+i]+s[j+i]-s[j]);
    }
  }

  cout << dp[0][n] << endl;

  return 0;
}

Measured memory_bytes: 1664
module ABC101

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_C
  private :: calculate_min_num_operations

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_C

    ! variables for this <subroutine>
    integer(INT32) :: len_sequence
    integer(INT32) :: num_elements_replacing

    ! STEP.01
    ! read out ...
    ! 1. the length of the given sequence
    ! 2. the number of elements to replace at once
    read(unit=INPUT_UNIT, fmt=*) len_sequence, num_elements_replacing

    ! STEP.02
    ! calculate & output minumum value of the number of operations that can be realized in a given sequence
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') calculate_min_num_operations(len_sequence, num_elements_replacing)

    ! STEP.END
    return

  end subroutine task_C

  pure function calculate_min_num_operations (len_sequence, num_elements_replacing) result(num_operations)

    ! arguments for this <function>
    integer(INT32), intent(in) :: len_sequence
    integer(INT32), intent(in) :: num_elements_replacing

    ! return value of this <function>
    integer(INT32) :: num_operations

    num_operations &!
      = ceiling( &!
        real(len_sequence           - 1_INT32, kind=REAL64) / &!
        real(num_elements_replacing - 1_INT32, kind=REAL64),  &!
        kind=INT32                                            &!
      )

      return

  end function calculate_min_num_operations

end module ABC101


program main

  ! <module>s to import
  use, non_intrinsic :: ABC101

  ! require all variables to be explicitly declared
  implicit none

  call task_C

end program main

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) (a & 1 ^ b & 1 ^ 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;

ll N,M,Q,K,L;
string S;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> M;
	int s = 0;
	bool red[100010] = {};
	int num[100010];
	rep1(i,N) num[i] = 1;
	red[1] = 1;
	rep(i,M){
		int x,y;
		cin >> x >> y;
		if(red[x] && !red[y]) red[y] = 1;
		--num[x],++num[y];
		if(!num[x]) red[x] = 0;
	}
	rep1(i,N) s += red[i];
	cout << s << endl;
}






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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a,b;
	set<int> edge[n];
	for (int i = 0; i < n-1; ++i)
	{
		cin>>a>>b;--a;--b;
		edge[a].insert(b);
		edge[b].insert(a);
	}
	int c[n];
	long long s=0LL;
	for (int i = 0; i < n; ++i)
	{
		cin>>c[i];
		s+=(long long)c[i];
	}
	sort(c,c+n);
	reverse(c,c+n);
	cout<<(long long)s-c[0]<<endl;
	queue<int> que;
	int memo[n]={},d[n],cnt=0;
	que.push(0);
	memo[0]=1;
	while (cnt<n)
	{
		int now=que.front();que.pop();
		d[now]=c[cnt];
		++cnt;
		for (auto i = edge[now].begin(); i != edge[now].end(); ++i)
		{
			if (memo[*i]==0)
			{
				memo[*i]=1;
				que.push(*i);
			}
		}
	}
	cout<<d[0];
	for (int i = 1; i < n; ++i)
	{
		cout<<" "<<d[i];
	}
	cout<<endl;
	return 0;
}


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

def hcfnaive(x, y): 
  if(y == 0): 
    return x 
  else: 
    return hcfnaive(y, x % y)

def lcm(x, y):
    return (x * y) // hcfnaive(x, y)

print(lcm(A, B))

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;

int n;
int p[30], l[30], r[30];

void dfs(int n, int depth){
  if(p[n] == -1){
    cout << "depth = " << depth << ", ";
    return ;
  }

  dfs(p[n], depth + 1);
  return ;
}

int height(int i, int h){
  int hl = 0, hr = 0;

  if(l[i] == -1 && r[i] == -1) return h;
  if(l[i] != -1) hl = height(l[i], h + 1);
  if(r[i] != -1) hr = height(r[i], h + 1);

  return max(hl, hr);
}

void searchsibling(int i){
  if(p[i] == -1) cout << "sibling = " << -1 << ", ";
  else if(l[p[i]] == i) cout << "sibling = " << r[p[i]] << ", ";
  else cout << "sibling = " << l[p[i]] << ", ";
}

void searchdegree(int i){
  if(l[i] == r[i]) cout << "degree = " << 0 << ", ";
  else if(l[i] == -1 || r[i] == -1) cout << "degree = " << 1 << ", ";
  else cout << "degree = " << 2 << ", ";
}

void searchtype(int i){
  if(p[i] == -1) cout << "root";
  else if(l[i] == -1 && r[i] == -1) cout << "leaf";
  else cout << "internal node";
}

void solve(){
  for(int i = 0;i < n;i++){
    cout << "node " << i << ": ";
    cout << "parent = " << p[i] << ", ";
    searchsibling(i);
    searchdegree(i);
    dfs(i, 0);
    cout << "height = " << height(i, 0) << ", ";
    searchtype(i);
    cout << endl;
  }
}

int main(){
  cin >> n;
  for(int i = 0;i < n;i++) p[i] = l[i] = r[i] = -1;
  for(int i = 0;i < n;i++){
    int id, left, right;

    cin >> id >> left >> right;
    l[id] = left;
    r[id] = right;
    p[left] = p[right] = id;
  }

  solve();

  return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define int long long
#define N 100005
using namespace std;
int n,m,a[N],v[N];
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&v[i]);
	int res=0,tmp=1;
	for(int i=1;i<n;i++){
		res+=tmp*v[i]*2;
		tmp=-tmp;
	}
	a[1]=(res+v[n]*2)/2;
	for(int i=2;i<=n;i++)
		a[i]=v[i-1]*2-a[i-1];
	for(int i=1;i<n;i++)printf("%lld ",a[i]);
	printf("%lld\n",a[n]);
	return 0;
}

Measured memory_bytes: 2816
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define inf 1e+9
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define msg(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define pri(a) cout << a << endl;

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

  // ll n,ans=0;
  // cin >> n;
  ll n,k,ans=0;
  cin >> n >> k;

  if(n<10){
    ans = k + 100*(10-n);
  }
  else{
    ans = k;
  }



  pri(ans);

}

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

using namespace std;

int main() {
    string s;
    cin >> s;

    int p = 0;
    for (int i = 0; i < s.length(); i++) {
        if (i < (s.length()+1)/2 && s[i] == 'p') {
            p--;
        }
        if (i >= (s.length()+1)/2 && s[i] == 'g') {
            p++;
        }
    }

    cout << p << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[n+1],b[n+1],s=0;
for(int i=1;i<=n;i++){
	cin>>a[i];
}
for(int i=1;i<=n;i++){
	cin>>b[i];
	if(a[i]-b[i]>0)
	s+=a[i]-b[i];
}
cout<<s;
}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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 f(char a, char b, char c){
    if(a == b && b == c) return 0;
    else if(a == b || b == c || a == c) return 1;
    else return 2;
}

int main(void){
    int N; cin >> N;
    string A,B,C; cin >> A >> B >> C;
    int ans = 0;
    REP(i,N){
        ans += f(A[i], B[i], C[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*
N = int(input())
h_list = list(map(int, input().split()))
pour_cnt = 0

def cnt(remains, pour_cnt):
    tmp = []
    next_remains = []
    # print(remains)
    for index, num in enumerate(remains):
        if num != 0:
            tmp.append(num)
            if (index+1 == N):
                min_num = min(tmp)
                pour_cnt += min_num
                for tmp_num in tmp:
                    next_remains.append(tmp_num-min_num)
                tmp = []
        elif len(tmp) != 0:
            min_num = min(tmp)
            pour_cnt += min_num
            for tmp_num in tmp:
                next_remains.append(tmp_num-min_num)
            next_remains.append(0)
            # print(tmp)
            tmp = []
        else:
            next_remains.append(0)

    if next_remains.count(0) == N:
        print(pour_cnt)
    else:
        cnt(next_remains, pour_cnt)

cnt(h_list, pour_cnt)

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

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    int x,y;cin>>x>>y;
    cout<<x*y<<endl;

    return 0;
}

Measured memory_bytes: 3576
def merge(A,left,mid,right):
    global cnt
    inf=float("inf")
    L=A[left:mid]+[inf]
    R=A[mid:right]+[inf]
    length=len(L)-1
    i,j=0,0
    for k in range(left,right):
        if L[i]<=R[j]:
            A[k]=L[i]
            i +=1
        else:
            A[k]=R[j]
            j +=1
            cnt +=length-i


def mergeSort(A,left,right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)


n=int(input())
A=list(map(int,input().split()))
cnt=0
mergeSort(A,0,n)
print(cnt)


Measured memory_bytes: 27472
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;

int gcd(int a, int b) {
return (!a || !b) ? 0 : ((a % b == 0) ? b : gcd(b, a % b));
}

int main() {
	//Code Line
cin >> n;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n ;j++){
for(int k = 1;k <= n ;k++){
a = gcd(i,j);
sum += gcd(a,k);
}
}
}

cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int e[11000][1300];

void f(int n,int m){
  rep(i,11000){
    rep(j,1300){
      e[i][j]=0;
    }
  }
  int r;
  cin>>r;
  while(r-- >0){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(d==1){
      e[c][a+1]++;
    }
    else{
      e[c][a+1]--;
    }
  }
  rep(i,11000){
    FOR(j,1,1300){
      e[i][j]+=e[i][j-1];
    }
    FOR(j,1,1300){
      e[i][j]= (e[i][j]>0);
      e[i][j]+=e[i][j-1];
    }
  }

  int q;
  cin>>q;
  while(q-- >0){
    int a,b,c;
    cin>>a>>b>>c;
    int ans = e[c][b]-e[c][a];
    cout<<ans<<endl;
  }

}


int main(){
  while(1){
    int n,m;
    cin>>n>>m;
    if(n==0) break;
    f(n,m);
  }

  return 0;
}


Measured memory_bytes: 58956
// 
#include<stdio.h>

#define Num 1000

static void outputdisp(int A[], int n);

int main(){
	int n;			/* 入力文字数			*/
	int i;          /* ループ用変数1		*/
	int j;          /* ループ用変数2		*/
	int v;          /* 退避用変数			*/
	int A[Num+1];   /* 数列格納配列			*/

	/* 入力処理 */
	/* 文字数を読み込む */
	scanf("%d", &n);

	/* 数列を読み込む */
	for ( i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}
	
	/* 読み込んだ数列を表示 */
	outputdisp(A, n);

	/* ソート処理 */
	for( i = 1; i < n; i++ ){
		v = A[i];
		j = i-1;
		
		while( ( j >= 0 ) && ( A[j] > v ) ){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		
		/* 出力処理 */
		outputdisp(A, n);
	}


  return 0;
}

void outputdisp(int A[], int n){
	int i;		/* ループ用変数 */ 

	/* 配列Aの数列を出力 */
	for( i = 0; i < n; i++ ){
		if ( i > 0 ){
			printf(" ");
		}
		else{
			/* 処理なし */	
		}

		printf("%d", A[i]);
  	}
  	printf("\n");
}



Measured memory_bytes: 2124
use std::collections::HashSet;
use std::borrow::Borrow;

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()
}

fn judge(s: String) -> bool {
    let mut rud = HashSet::new();

    rud.insert('R');
    rud.insert('U');
    rud.insert('D');

    let mut lud = HashSet::new();

    lud.insert('L');
    lud.insert('D');
    lud.insert('U');

    for i in 0..s.len() {
        let &c = s.chars().nth(i).unwrap().borrow();
        if i % 2 == 0 {
            if !rud.contains(&c) {
                return false;
            }
        } else {
            if !lud.contains(&c) {
                return false;
            }
        }
    }

    return true;
}

fn main() {
    let s: String = read();
    if judge(s) {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

#define int long long
#define ll long long
#define double long double
#define pii pair<int, int>
#define vec vector
#define u_map unordered_map
#define u_set unordered_set
#define str string
#define all(el) el.begin(), el.end()
#define allr(el) el.rbegin(), el.rend()
#define sz(el) (int)el.size()
#define f first
#define s second
#define pb push_back
#define in insert
#define mp make_pair
#define endl "\n"
#define forn(i, n) for (int i = 0; i < n; ++i)

inline int maxi(int &a, int b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(int &a, int b) { if (b < a) { a = b; return 1; } return 0; }

inline int maxi(double &a, double b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(double &a, double b) { if (b < a) { a = b; return 1; } return 0; }

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    vec<int> a(n);
    vec<int> b(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a[i] = x;
        b[i] = y;
    }
    sort(all(a));
    sort(all(b));

    if (n % 2 == 1) {
        cout << max(0LL, b[n / 2] - a[n / 2] + 1);
    } else {
        cout << max(0LL, b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1);
    }

    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VLL a(n);
  rep(i, n) cin >> a[i];
  bool flag = true;
  rep(i,n){
    if(a[i] % 2 == 0){
      if(a[i]%5==0 || a[i]%3==0){
        continue;
      }else{
        flag = false;
      }
    }
  }
  if(flag){
    cout << "APPROVED"
         << "\n";
  }else{
    cout << "DENIED"
         << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5, inf = 1e9+7;
int n, k, i, j;
int A[21][21], dp[1<<21];

int dfs(int mask){
    if(mask==0) return 1;
    if(dp[mask]!=-1) return dp[mask];
    int& ans = dp[mask] = 0;
    int a = n-__builtin_popcount(mask);
    for(int i=0; i<n; i++) if(A[i][a] && (mask>>i&1))
        ans += dfs(mask^(1<<i));
    return ans%=inf;
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n;
    rep(i, 0, n) rep(j, 0, n) cin>>A[i][j];
    memset(dp, -1, sizeof dp);
    cout<<dfs((1<<n)-1);
}

Measured memory_bytes: 16640
s = input()
li = list(map(int,list(s)))

for i in range(8):
  tmp = list(map(int,list(format(i,"03b"))))
  tmp7 = li[0]
  for j in range(3):
    if tmp[j] == 0:
      tmp7 += li[j+1]
    else:
      tmp7 -= li[j+1]
  if tmp7 == 7:
    ans = str(li[0])
    if tmp[0] == 0:
      ans += "+"
    else:
      ans += "-"
    ans += str(li[1])
    if tmp[1] == 0:
      ans += "+"
    else:
      ans += "-"
    ans += str(li[2])
    if tmp[2] == 0:
      ans += "+"
    else:
      ans += "-"
    ans += str(li[3])
    ans += "=7"
    print(ans)
    exit()

Measured memory_bytes: 3064
using System;

public class Hello
{
    public const int INF = 999999999;
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            var s = int.Parse(line[2]);
            var g1 = int.Parse(line[3]);
            var g2 = int.Parse(line[4]);
            if (n == 0 && m == 0 && s == 0 && g1 == 0 && g2 == 0) break;
            s--; g1--; g2--;
            var dp = new int[n, n];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    if (i != j) dp[i, j] = INF;
            for (int i = 0; i < m; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                var b1 = int.Parse(line[0]) - 1;
                var b2 = int.Parse(line[1]) - 1;
                var c = int.Parse(line[2]);
                dp[b1, b2] = c;
            }
            goWarshall(dp);
            var ret = INF;
            for (int i = 0; i < n; i++)
                if (dp[s, i] != INF && dp[i, g1] != INF && dp[i, g2] != INF)
                    ret = Math.Min(ret, dp[s, i] + dp[i, g1] + dp[i, g2]);
            Console.WriteLine(ret);
        }
    }
    public static void goWarshall(int[,] dp)
    {
        var n = dp.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    dp[j, k] = Math.Min(dp[j, k], dp[j, i] + dp[i, k]);
    }
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin>>n;
  if(n/10==9||n%10==9)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30

bool is_prime(ll N){
    for(ll i = 2; i * i <= N; i++){
        if(N % i == 0) return false;
    }
    return true;
}


int main() {
    ll x; cin >> x;
    while(1){
        if(is_prime(x)){
            cout << x << endl;
            return 0;
        }
        x++;
    }

    return 0;
}


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

int main() {
    int n; cin >> n;

    for (int i = 0; i < n + 1; i++) {
        if ((int)(1.08 * i) == n) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long int n,i,j,k=10;
  scanf("%ld",&n);
  for(i=1;i*i<n;i++);
  while(1){if(n%i==0){i=n/i;for(j=1;k<=i;j++)k*=10;printf("%ld",j);return 0;}i--;}
}


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

int main() {
	
	int H, W;
	cin >> H >> W;
	vector<string> vec(H);
	
	for(int i = 0; i < H; i++){
		
		cin >> vec.at(i);

	}
	
	for(int i=0; i<W+2; i++){
		
		cout << "#";
		
	}
	cout << endl;
	
	for(int i=0; i<H; i++){
		
		cout << "#"+vec.at(i)+"#"<<endl;
		
	}
	
	for(int i=0; i<W+2; i++){
		
		cout << "#";
		
	}
	cout << endl;
	
	
}


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

int main(){
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    priority_queue <ll> queP,queQ,queR;
    rp(i,a){
        ll p;
        cin >> p;
        queP.push(p);
    }
    
    rp(i,b){
        ll q;
        cin >> q;
        queQ.push(q);
    }
    rp(i,c){
        ll r;
        cin >> r;
        queR.push(r);
    }
    priority_queue<ll> integrate;
    rp(i,x){
        integrate.push(queP.top());
        queP.pop();
    }
    rp(i,y){
        integrate.push(queQ.top());
        queQ.pop();
    }
    rp(i,c){
        integrate.push(queR.top());
        queR.pop();
    }
    ll answer=0;
    rp(i,x+y){
        answer += integrate.top();
        integrate.pop();
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 8688
A = int(input())
B = int(input())
C = int(input())
X = int(input())

result = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*ｊ + 50*k == X:
                result += 1

print(result)


Measured memory_bytes: 3060
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(2**n):
    x=0
    y=0
    for j in range(n):
        if (i>>j)&1:
            x+=v[j]
            y+=c[j]
    ans.append(x-y)
print(max(ans))


Measured memory_bytes: 113148
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	string s; cin >> s;
	string t = "CODEFESTIVAL2016";
	int ans=0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x;
  vector<int> y;
  vector<int> z;
  for (int i = 0; i <= n-1; ++i) {
    int a;
    cin >> a;
    x.push_back(a);
  }
  for (int i = 0; i <= n-1; ++i) {
    int b;
    cin >> b;
    y.push_back(b);
  }
  for (int i = 0; i <= n-2; ++i) {
    int c;
    cin >> c;
    z.push_back(c);
  }

  int res = 0;
  for (int i = 0; i <= n-1; ++i) {
    if(i==n-1){
    	res = res + y[i];     
    }else{
    	if(x[i+1]-x[i]==1){	
          	res = res + y[i] + z[x[i]-1];  		
        }else{
        	res = res + y[i];
        }     
    }
    }
  cout << res << endl;

}


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

int main(){
 vector<char> s(3);
 int a=0, b=0, c=0;
 for(int i=0; i<3; i++){
  cin>>s[i];
  if(s[i]=='a')a++;
  else if(s[i]=='b')b++;
  else if(s[i]=='c')c++;
 }
 if(a==1&&b==1&&c==1)cout<<"Yes\n";
 else cout<<"No\n";
}


Measured memory_bytes: 256
def main():

    N = int(input())
    A = list(map(int, input().split()))
    ave = sum(A)/N
    min_d = float('inf')
    min_i = None
    for i in range(N):
        d = abs(A[i]-ave)
        if d < min_d:
            min_d = d
            min_i = i
    return min_i

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	ll n;
	cin >> n;
	set < ll > unq;
	auto add = [&](ll r) {
		ll b = n / r - 1;
		if (r < b) {
			unq.insert(b);
		}
		return 0;
	};
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			add(i);
			add(n / i);
		}
	}
	ll sum = 0;
	for (auto &el: unq) {
		sum += el;
	}
	cout << sum << "\n";
}

Measured memory_bytes: 384
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }

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

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

#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int N, a[21][21];
LL dp[22][1 << 21];

#ifdef _MSC_VER
inline unsigned int __builtin_popcount(unsigned int x) { return __popcnt(x); }
#endif // _MSC_VER

int main()
{
  cin >> N;
  REP(i, N) REP(j, N) cin >> a[i][j];

  dp[0][0] = 1;
  REP(i, N)
  {
    REP(msk, 1 << N)
    {
      if (i == __builtin_popcount(msk))
      {
        REP(j, N)
        {
          if (!(msk & (1 << j)) && a[i][j])
          {
            dp[i + 1][msk | (1 << j)] += dp[i][msk];
            dp[i + 1][msk | (1 << j)] %= MOD;
          }
        }
      }
    }
  }
  cout << dp[N][(1 << N) - 1] << endl;
  return 0;
}

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

struct Restaurant
{
    string name;
    int num;
    int point;

    bool operator<(const Restaurant &a) const
    {
        if (name != a.name)
            return name < a.name;
        return point > a.point;
    }
};

int main()
{

    int n;
    cin >> n;
    vector<Restaurant> rests(n);

    for (int i = 0; i < n; i++)
    {
        cin >> rests[i].name >> rests[i].point;
        rests[i].num = i + 1;
    }
    sort(rests.begin(), rests.end());

    for (int i = 0; i < n; i++)
    {
        cout << rests[i].num << endl;
    }
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int a[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans += abs(a[i]);
    }
    sort(a, a + n);
    if (a[0] > 0) {
        ans -= 2 * a[0];
    }
    if (a[n - 1] < 0) {
        ans += 2 * a[n - 1];
    }
    cout << ans << endl;
    for (int i = 1; i + 1 < n; i++) {
        if (a[i] < 0) {
            cout << a[n - 1] << ' ' << a[i] << '\n';
            a[n - 1] -= a[i];
        } else {
            cout << a[0] << ' ' << a[i] << '\n';
            a[0] -= a[i];
        }
    }
    cout << a[n - 1] << ' ' << a[0];
    return 0;
}

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

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

	int ans = 0;
	for (int i = a; i <= b; i++)
	{
		string s = to_string(i);
		string t(s);
		reverse(t.begin(), t.end());

		int x = stoi(s);
		int y = stoi(t);

		if (x == y)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
        int ans = 0;
        int[] a = new int[5];
	for(int i=0;i<5;i++){
	    a[i] = sc.nextInt();
	    if(a[i] == 0) ans = (i+1);
	}
	System.out.println(ans);
    }
}


Measured memory_bytes: 35760
import sys
import numpy as np  # noqa

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


K = int(readline())
C = readline().rstrip().decode()

a = 0  # a: 赤から白に変える操作
b = 0  # b: 白から赤に変える操作
for i in range(len(C)):
    if C[i] == 'R':
        a += 1
mn = a
for i in range(len(C)):
    if C[i] == 'R':
        a -= 1
    else:
        b += 1
    mn = min(mn, min(a, b) + abs(a-b))
print(mn)


Measured memory_bytes: 27064
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < (n); i++)

int main()
{
    int h, n;
    cin >> h >> n;

    int A[n], B[n];
    repi(i, n, 0)
    {
        cin >> A[i] >> B[i];
    }
    int dp[h + 1];
    fill(dp, dp + h + 1, INF);
    dp[0] = 0;
    repi(i, n, 0)
    {
        repi(j, h+1, 0)
        {
            dp[min(j + A[i], h)] = min(dp[min(j + A[i], h)], dp[j] + B[i]); //i番目を使った時と使わなかったときのj+Aiダメージの最小
        }
    }
    cout << dp[h] << endl;
    return 0;
}

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

		static void solve() {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int x = sc.nextInt();
			int sum = 0;
			int[] array = new int[n];
			for(int i = 0; i<n; i++) {
				array[i] = sc.nextInt();
				sum+=array[i];
			}
			sc.close();
			int min = Integer.MAX_VALUE;
			for(int i = 0;i<n;i++) {
				if(array[i]<min) {
					min = array[i];
				}
			}
			int res = (x-sum)/min;
			System.out.println(res+n);
		}
	public static void main(String[] args) {
		solve();

	}

}


Measured memory_bytes: 25172
import java.util.Arrays;
import java.util.Scanner;

class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int a[]=new int[3];
        for(int i=0;i<3;i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        String x="",y="";
        x=Integer.toString(a[2])+Integer.toString(a[1]);
        y=Integer.toString(a[0]);
        
        System.out.println(Integer.parseInt(y)+Integer.parseInt(x));
        
    }
}

Measured memory_bytes: 21716