akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

int main() {
    int N;
    string s;
    cin >> N;
    cin >> s;
    vector<int> R(N + 5, 0);
    vector<int> G(N + 5, 0);
    vector<int> B(N + 5, 0);
    int num_r = 0;
    int num_g = 0;
    int num_b = 0;
    for (int i = N - 1; i >= 0; --i) {
        char c = s[i];
        if (c == 'R') {
            num_r++;
        } else if (c == 'G') {
            num_g++;
        } else {
            num_b++;
        }
        R[i] = num_r;
        G[i] = num_g;
        B[i] = num_b;
    }
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N - 1; ++j) {
            if (s[i] == s[j]) continue;
            if (s[i] != 'R' && s[j] != 'R') {
                ans += R[j + 1];
                if (j + (j - i) < N && R[j + 1] > 0 && s[j + (j - i)] == 'R') --ans;
            }
            if (s[i] != 'G' && s[j] != 'G') {
                ans += G[j + 1];
                if (j + (j - i) < N && G[j + 1] > 0 && s[j + (j - i)] == 'G') --ans;
            }
            if (s[i] != 'B' && s[j] != 'B') {
                ans += B[j + 1];
                if (j + (j - i) < N && B[j + 1] > 0 && s[j + (j - i)] == 'B') --ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll n,y;
    cin >> n >> y;
    rep(i,n+1){
        rep(j,n+1){
            int k = n - i - j;
            if(k < 0) continue;
            if(i*10000+j*5000+k*1000 == y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " <<  -1 << " " <<  -1 << endl;
    return 0;
}

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

int a[222222];
int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = k; i < n; i++)
        cout << (a[i - k] < a[i] ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 4412
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

struct card {
    char suit;
    int  value;
};

static void printOut(const struct card C[], int N) {
    int i;

    for ( i = 0; i < N; i++ ) {
        printf("%c%d%s", C[i].suit, C[i].value, i == N -1 ? "" : " ");
    }
    printf("\n");

    return;
}


static inline void swap(struct card C[], int a, int b) {
    struct card t;

    t = C[a];
    C[a] = C[b];
    C[b] = t;
}
    

static void bubbleSort(struct card C[], int N) {
    int i, j;

    for ( i = 0; i < N; i++) {
        for ( j = N - 1; j > i; j-- ) {
            if ( C[j].value < C[j-1].value ) {
                swap(C, j, j-1);
            }
        }
    }

    return;
}

static void selectionSort(struct card C[], int N) {
    int i, j, minj;

    for ( i = 0; i < N; i++) {
        minj = i;
        
        for ( j = i; j < N; j++) {
            if ( C[j].value < C[minj].value ) {
                minj = j;
            }
        }
//        if ( i != minj ) {
        {
            swap(C, i, minj);
        }
    }

    return;
}

/* 0: Not Stable, 1: Stable */
static int isStable(const struct card input[], const struct card sorted[], int N) {
    int i, j;

    for ( i = 1; i < N; i++ ) {
        if ( sorted[i - 1].value == sorted[i].value ) {
            int p = -1;
            int q = -1;
            for ( j = 0; j < N; j++ ) {
                if ( (sorted[i - 1].value == input[j].value) && (sorted[i - 1].suit == input[j].suit ) ) {
                    p = j;
                }
                if ( (sorted[i].value == input[j].value) && (sorted[i].suit == input[j].suit ) ) {
                    q = j;
                }
                if ( (p >= 0) && (q >= 0) ) {
                    break;
                }
            }
            if ( p > q ) {
                return 0;
            }
        }
    }

    return 1;
}

int main(int argc, char* argv[]) {
    int ret;
    int i;
    int N;
    struct card *input;
    struct card *sorted;
    int s, v;

    ret = scanf("%d\n", &N);
    assert( ret == 1 );
    assert( (1 <= N) && N <= 100 );

    input = malloc(sizeof(struct card) * N);
    assert( input != NULL );

    memset(input, 0x00, sizeof(struct card) * N);
    i = 0;
    while ( ((s = fgetc(stdin)) != EOF) && ((v = fgetc(stdin)) != EOF) && (i < N) ) {
        assert( (s == 'S') || (s == 'H') || (s == 'C') || (s == 'D' ) );
        assert( isdigit(v) );

        input[i].value = v - '0';
        input[i].suit  = s;

        int c = fgetc(stdin);
        if ( c == ' ' ) {
            i++;
        } else {
            break;
        }
    }

    sorted = malloc(sizeof(struct card) * N);
    assert( input != NULL );

    memcpy(sorted, input, sizeof(struct card) * N);
    bubbleSort(sorted, N);
    printOut(sorted, N);
    printf("%s\n", isStable(input, sorted, N) ? "Stable" : "Not stable");

    memcpy(sorted, input, sizeof(struct card) * N);
    selectionSort(sorted, N);
    printOut(sorted, N);
    printf("%s\n", isStable(input, sorted, N) ? "Stable" : "Not stable");

    free(input);
    free(sorted);    

    return 0;
}
    



Measured memory_bytes: 2120
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        if (n==0) break;
        vector<pii> ps(n);
        for (int i = 0; i < n; i++)
            cin >> ps[i].second >> ps[i].first;
        sort(ps.begin(), ps.end());
        auto f = [&]() {
            int now = 0;
            for (int i = 0; i < n; i++) {
                now += ps[i].second;
                if (ps[i].first < now) return false;
            }
            return true;
        };
        if (f()) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> point;

const int mod = 1e9 + 7;

int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}

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

  int h, w, n; cin >> h >> w >> n;
  cout << n / max(h, w) + ( (n % max(h, w)) != 0);
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int A, B;
    cin >> A >> B;

    if (A >= 10 || B >= 10){
        cout << -1 << endl;
        return 0;
    }

    cout << A * B << endl;

    return 0;
}


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

int main() {
	int n, a[110], cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			cnt++;
			i++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
public class Main {
  public static void main(String[] args) {
    java.util.Scanner scanner = new java.util.Scanner(System.in);
    
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    
    int x = scanner.nextInt();
    
    int sum = 0;
    int count = 0;
    for (int i = 0; i <= a; i++) {
      for(int j = 0; j <= b; j++) {
        for(int k = 0; k <= c; k++) {
          sum = 500 * i + 100 * j + 50 * k;
          if (sum == x ) {
            count++;
          }
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21972
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

vt pow_mod_rep_square(vt n, vt p, vt mod) { //mod付き
	if (p == 0) return 1;
	else if (p % 2 == 0) {
		vt t = pow_mod_rep_square(n, p / 2, mod);
		return t * t % mod;
	}
	else return n * pow_mod_rep_square(n, p - 1, mod) % mod;
}

vt inv_Felmat(vt a, vt mod) {
	return pow_mod_rep_square(a, mod - 2, mod);
}

vt permutation_mod(vt n, vt k, vt mod) { //mod付き順列
	if (k == 1) return n % mod;
	return permutation_mod(n, k - 1, mod) * (n - k + 1) % mod;
}

vt comb_mod(vt n, vt k, vt mod) { //mod付き二項係数
	if (k == 0) return 1;
	return (permutation_mod(n, k, mod) * inv_Felmat(permutation_mod(k, k, mod), mod)) % mod;
}

int main() {
	ll x, y, ans;
	cin >> x >> y;
	if (x + y % 3 == 0) {
		cout << 0;
		return 0;
	}
	if (!(2 * x - y >= 0 && (2 * x - y) % 3 == 0 && 2 * y - x >= 0 && (2 * y - x) % 3 == 0)) {
		cout << 0;
		return 0;
	}
	ll a, b;
	a = (2 * y - x) / 3;
	b = (2 * x - y) / 3;


	cout << comb_mod(a + b, b, MOD);

	return 0;
}

Measured memory_bytes: 10624
function main()
	N=parse(Int,readline())
	A=map(x->parse(Int,x),split(readline()))
	if N==1
		println(1)
		exit()
	end
	ans=1
	i=3
	now=A[1]<A[2] ? 1 : A[1]>A[2] ? -1 : 0
	while i<=N
		if now==1&&A[i-1]>A[i]
			ans+=1
			i+=1
			if i<=N
				now=A[i-1]<A[i] ? 1 : A[i-1]>A[i] ? -1 : 0
			end
		elseif now==-1&&A[i-1]<A[i]
			ans+=1
			i+=1
			if i<=N
				now=A[i-1]<A[i] ? 1 : A[i-1]>A[i] ? -1 : 0
			end
		elseif now==0&&A[i-1]!=A[i]
			now=A[i-1]<A[i] ? 1 : -1
		end
		i+=1
	end
	println(ans)
end
main()


Measured memory_bytes: 124268
fun main(args : Array<String>) {
    val (n, p) = readLine()!!.split(" ").map { it.toLong() }

    if (n == 1L) {
        println(p)
        return
    }

    val nums = decom(p)
    val nn = mutableMapOf<String, Long>()

    var tmp = p
    nums.forEach {
        while (it != 1L && tmp % it == 0L) {
            tmp /= it
            nn[it.toString()] = (nn[it.toString()] ?: 0L) + 1L
        }
    }
    nn[tmp.toString()] = 1

    var ans = 1L
    nn.filter { it.value >= n }.forEach {
        ans *= Math.pow(it.key.toDouble(), (it.value / n).toInt().toDouble()).toLong()
    }

    println(ans)
}

fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}


Measured memory_bytes: 52772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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; }
ll mod = 1e9+7;


int main(){
    int a,b; cin >> a >> b;
    ll gcd;
    gcd = __gcd(a,b);
    ll ans;
  ans = a/gcd * b/gcd * gcd;
    cout << ans<< endl;
}

Measured memory_bytes: 256
from collections import Counter


def solve(kisoku_S, max_len):
    for k in range(1, max_len):
        k_s = Counter([s[0:k] for s in kisoku_S])
        if all(c == 1 for s, c in k_s.items()):
            return k
    return -1


if __name__ == "__main__":
    while True:
        n = int(input())
        if n == 0:
            break
        S = [input() for _ in range(n)]
        kisoku_S = []
        for i in range(n):
            tmp = S[i][0]
            for j in range(1, len(S[i])):
                if (
                    S[i][j - 1] == "a"
                    or S[i][j - 1] == "i"
                    or S[i][j - 1] == "u"
                    or S[i][j - 1] == "e"
                    or S[i][j - 1] == "o"
                ):
                    tmp += S[i][j]
            kisoku_S.append(tmp)

        max_len = len(max(kisoku_S, key=lambda x: len(x)))+1
        print(solve(kisoku_S=kisoku_S, max_len=max_len))




Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
 
const int mod = 1e9+7;
vector<int> to[100005];
int k;
ll ans = 1;

int dfs(int v, int p=-1) {
    for (int u : to[v]) {
        if (u == p) continue;
        dfs(u, v);
    }
    int nk = (p==-1) ? k : k-2;
    int c = (p==-1) ? sz(to[v])+1 : sz(to[v])-1;
    rep(i, c) {
        ans *= nk-i;
        ans %= mod;
    }
}

int main() {
    int n; cin >> n >> k;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(0);
    cout << ans << endl;

}

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

int main() {
  int n;
  cin >> n;
  vector<int64_t> lucas(n + 1);
  if (n == 0) {
    cout << 2 << endl;
  } else if (n == 1) {
    cout << 1 << endl;
  } else {
    lucas.at(0) = 2;
    lucas.at(1) = 1;
    for(int i = 2; i < n + 1; i++) {
      lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
    }
    cout << lucas.at(n) << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int dp[100010];

int main()
{
	ll n;cin >> n;
	
	REP(i,n)dp[i] = n;
	
	dp[1] = 1;
	
	REP(q,23)
	{
		for(int i = 1;i < n;i++)
		{		
			int tmp = i;
			REP(j,55)
			{
				dp[(tmp*10)%n] = min(dp[(tmp*10)%n],dp[tmp]);
				tmp = (tmp*10)%n;
			}
			dp[(i+1)%n] = min(dp[(i+1)%n],dp[i]+1);
		}
	}	
	
	cout << dp[0] << endl;
	
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define FORE(i,a,b) for (int i=(int)(a);i<=(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REPE(i,n) FOR(i,0,n)

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

int main() {
  int N; cin >> N;
  vector<int> p(N);
  REP(i,N) cin >> p[i];
  vector<int> q = p;

  sort(ALL(q));

  int cnt = 0;
  REP(i,N) if (p[i] != q[i]) cnt++;
  if (cnt == 2 || cnt == 0) puts("YES");
  else puts("NO");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A, B;
  rd(A);
  rd(B);
  if(A < B){
    swap(A, B);
  }
  if(A==B){
    wt_L(A+B);
    wt_L('\n');
  }
  else{
    wt_L(2*A-1);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190608-2

// --- original code ---
// {
//   int A, B;
//   rd(A,B);
//   if(A < B) swap(A, B);
//   wt( if[A==B, A+B, 2A-1] );
// }


Measured memory_bytes: 256
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(pair<int,int> a, pair<int,int> b)
{
    int l1=a.ss-a.ff+1;
    int l2=b.ss-b.ff+1;
    if(l1!=l2) return l1>l2;
    return a.ff > b.ff;
}
std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);


void solve(){
  int n; cin>>n;
  int a[n]; f(i,0,n) cin>>a[i];
  int cnt=0;
  f(i,0,n) f(j,i+1,n) f(k,j+1,n){
    if(a[i]==a[j]) break;
    if(a[i]==a[k]) continue;
    if(a[j]==a[k]) continue;
    if(a[i]<a[j]+a[k] && a[j]<a[i]+a[k] && a[k]<a[j]+a[i]) ++cnt;
  }
  cout<<cnt;
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!


Measured memory_bytes: 3652
using System;

namespace AtCoderABC126C
{
    class Program
    {
        static void Main(string[] args)
        {
            double ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            for(int i=1;i<N+1;i++)
            {
                int j = N;
                int Buffer = i;

                while(K>Buffer)
                {
                    j = j * 2;
                    Buffer = Buffer * 2;
                }

                ans += (double)1 / j;

            }


            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException
	{
		int m,f,r,sum;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		for(int i=0; i<255; i++)
		{
			String[] mfr = br.readLine().split(" ");
			m = Integer.parseInt(mfr[0]);
			f = Integer.parseInt(mfr[1]);
			r = Integer.parseInt(mfr[2]);

			sum = m+f;

			if(sum+r == -3) i=255;

			else if(m*f < 0 || sum < 30) System.out.println("F");

			else if(30 <= sum && sum < 50) System.out.println( (50 <= r) ? 'C' : 'D');

			else if(50 <= sum && sum < 65) System.out.println("C");

			else if(65 <= sum && sum < 80) System.out.println("B");

			else if(80 <= sum ) System.out.println("A");

		}
	}
}

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

bool islower(char c)
{
  return (c>='a' && c<='z');
}

bool isupper(char c)
{
  return (c>='A' && c<='Z');
}

char to_upper(char c)
{
  return c-0x20;
}

char to_lower(char c)
{
  return c+0x20;
}

int main()
{
  string s="";
  bool flag=false;
  while(true)
  {
    char c;
    scanf("%c", &c);
    if(c=='\n'&&flag) break;
    else if(c=='\n') flag=true;
    else flag=false; 
    s.push_back(c);
  }
  map<char,int> mp;
  for (char i = 'a'; i <= 'z'; ++i)
  {
    mp[i]=0;
  }
  for (int i = 0; i < s.size(); ++i)
  {
    if(isupper(s[i])) s[i]=to_lower(s[i]);
    mp[s[i]]++;
  }

  for (char i = 'a'; i <= 'z'; ++i)
  {
    cout<<i<<" : "<<mp[i]<<endl;
  }
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    if (S == "RRR") puts("3");
    else if (S == "RRS" or S == "SRR") puts("2");
    else if (S == "SSS") puts("0");
    else puts("1");
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> item(10e5 + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        item[a[i]]++;
    }
 
    int q;
    cin >> q;
    vector<int> b(q), c(q);
    for (int i = 0; i < q; i++) cin >> b[i] >> c[i];

    long long sum = 0;
    for (int i = 0; i < n; i++) sum += a[i];

    for (int i = 0; i < q; i++) {
         sum += (c[i] - b[i]) * item[b[i]];
         item[c[i]] += item[b[i]];
         item[b[i]] = 0;
         cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 8276
N,M=map(int,input().split())
H=list(map(int,input().split()))

G=[0]*N
for i in range(M):
    a,b = map(int,input().split())
    a = a-1
    b = b-1
    if H[a] > H[b]:
        G[b] = 1
    elif H[a] < H[b]:
        G[a] = 1
    else:
        G[a] = 1
        G[b] = 1

cnt = 0
for i in range(N):
    if G[i] == 0:
        cnt += 1

print(cnt)
    


Measured memory_bytes: 19860
A,B,C,D=map(int,input().split())
c_dividable=B//C-(A-1)//C
d_dividable=B//D-(A-1)//D
def gcd(a,b):
  if a==b:
    return a
  else:
    if a%b==0:
      return b
    while a%b!=0:
      return gcd(b,a%b)
v=C*D//gcd(C,D)
cd_dividable=B//v-(A-1)//v
print(B-A+1-(c_dividable+d_dividable-cd_dividable))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a+b==15) { cout<<"+"<<endl; }
  else if(a*b==15) { cout<<"*"<<endl; }
  else { cout<<"x"<<endl; }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,f,g,h,i;
	cin>>a>>b>>e;
	c=e*3-a-b;
	g=e*3-e-c;
	d=e*3-a-g;
	f=e*3-d-e;
	h=e*3-b-e;
	i=e*3-g-h;
	cout<<a<<" "<<b<<" "<<c<<endl;
	cout<<d<<" "<<e<<" "<<f<<endl;
	cout<<g<<" "<<h<<" "<<i;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 200005
int a[N],b[N],n,m;
struct SMT
{
	#define ls (u<<1)
	#define rs (u<<1|1)
	#define mid ((l+r)/2)
	int t[N*4];
	void update(int u,int l,int r,int L,int R)
	{
		if(L<=l&&r<=R)
		{
			t[u]=1;
			return ;
		}
		if(mid>=L) update(ls,l,mid,L,R);
		if(mid<R) update(rs,mid+1,r,L,R);
		if(t[ls]&&t[rs]) t[u]=1;
	}
	int query(){return t[1];}
}smt;
struct SMT2
{
	#define ls (u<<1)
	#define rs (u<<1|1)
	#define mid ((l+r)/2)
	int t[N*4];
	void build(int u,int l,int r)
	{
		t[u]=inf;
		if(l==r) return ;
		build(ls,l,mid),build(rs,mid+1,r);
	}
	int tag[N*4];
	void pushdown(int u)
	{
		if(tag[u])
		{
			tag[ls]=tag[rs]=1;
			t[ls]=t[rs]=inf;
			tag[u]=0;
		}
	}
	void update(int u,int l,int r,int L,int R)
	{
		if(L<=l&&r<=R)
		{
			t[u]=inf,tag[u]=1;
			return ;
		}
		pushdown(u);
		if(mid>=L) update(ls,l,mid,L,R);
		if(mid<R) update(rs,mid+1,r,L,R);
		t[u]=min(t[ls],t[rs]);
	}
	void update2(int u,int l,int r,int pl,int v)
	{
		if(l==r) {t[u]=min(t[u],v); return ;}
		pushdown(u);
		if(pl<=mid) update2(ls,l,mid,pl,v);
		else update2(rs,mid+1,r,pl,v);
		t[u]=min(t[ls],t[rs]);
	}
	int query(){return t[1];}
}smt2;
set<pii> s;
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) a[i]=read(),b[i]=read();
	// int tmin=inf;
	for(int i=1;i<=m;i++) s.insert(mp(i,0));
	// smt2.build(1,1,m);
	for(int i=1;i<=n;i++)
	{
		int R=smt.query();
		smt.update(1,1,m,a[i],b[i]);
		smt2.update(1,1,m,a[i],b[i]);
		// for(auto [u,v]:s) printf("%d %d\n",u,v); cout<<"\n";
		{
			auto x=s.lower_bound(mp(a[i],0));
			vector<pii> er;
			int ans=smt2.query()+i,res=inf;
			while(x!=s.end()&&(*x).fir<=b[i])
			{
				auto [u,v]=*x;
				if(b[i]!=m) res=min(res,v+b[i]-u+1+i);
				er.eb(u,v);
				x++;
			}
			for(auto x:er) s.erase(x);
			ans=min(ans,res);
			printf("%d\n",ans>=inf?-1:ans);
			s.insert(mp(b[i]+1,res-i));
			// tmin=min(tmin,ans-i);
			if(b[i]!=m) smt2.update2(1,1,m,b[i]+1,res-i);
		}
	}
	return 0;
}




Measured memory_bytes: 20848
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int > a(n + 2, 0),b(n + 1, 0);
  a[0] = a[n + 1] = 0;
  for(int i = 1; i <= n; i ++){
    cin >> a[i];
  }
  int sum1 = 0;
  for(int i = 0; i < n + 1; i ++){
    b[i] = a[i+1] - a[i];
    sum1 += abs(b[i]);
  }
  for(int i = 1; i <= n; i++){
    if(b[i]*b[i-1] > 0){
      cout << sum1 << endl;
    }else{
      cout << sum1 - abs(b[i-1]) - abs(b[i]) + abs(a[i+1] - a[i -1]) << endl;
    }
  }


  // sort(all(b));
  // max1a = b[n - 1];
  // max2a = b[n - 2];
  // min1a = b[0];
  // min2a = b[1];
  // cout << max1a << ", " <<max2a << ", " <<min1a << ", " <<min2a << endl;
  // REP(i, n){
  //   if(a[i] == max1a){
  //     int ans = (max2a*min1a < 0 ) ? 2*(max2a - min1a) : 2*max((int)abs(max2a),(int)abs(min1a));
  //     cout << "case  1 ";
  //     cout <<ans << endl;
  //   }else if(a[i] == min1a){
  //     int ans = (max1a*min2a < 0 ) ? 2*(max1a - min2a) : 2*max(abs(max1a),abs(min2a));
  //     cout << "case  2 ";
  //     cout << ans << endl;
  //   }else{
  //     int ans = (max1a*min1a < 0 ) ? 2*(max1a - min1a) : 2*max(abs(max1a),abs(min1a));
  //     cout << "case  3 ";
  //     cout << ans << endl;
  //   }
  // }
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
void solve(){
	pii a[3][3];
	map<int,pii> mp;
	rep(i,3){
		rep(j,3){
			cin>>a[i][j].first;
			a[i][j].second=0;
			mp[a[i][j].first]={i,j};
		}
			
	}
	int n;
	cin>>n;
	rep(i,n){
		int temp;
		cin>>temp;
		if(mp.find(temp)==mp.end())
			continue;
		pii pp=mp[temp];
		a[pp.first][pp.second].second=1;
	}
	// check all the rows
	rep(i,3){
		int cnt=0;
		rep(j,3){
			if(a[i][j].second==1)
				cnt++;
		}
		if(cnt==3){
			cout<<"Yes"<<endl;
			return;
		}
	}
	// check all the cols
	rep(j,3){
		int cnt=0;
		rep(i,3){
			if(a[i][j].second==1)
				cnt++;
		}
		if(cnt==3){
			cout<<"Yes"<<endl;
			return;
		}
	}
	// check the first diagonal
	if(a[0][0].second==1 && a[1][1].second==1 && a[2][2].second==1){
		cout<<"Yes"<<endl;
		return;
	}
	if(a[2][0].second==1 && a[1][1].second==1 && a[0][2].second==1){
		cout<<"Yes"<<endl;
		return;
	}
	cout<<"No"<<endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N),g(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    int s,t;cin>>s>>t;
    s--;t--;
    // BFS のためのデータ構造
    vector<int> dist(N, -1),seen(N,-1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[s] = 0;
    que.push(s); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            for(int nnv : G[nv]){
                for(int nnnv : G[nnv]){
                    if(dist[nnnv]!=-1)continue;
                    dist[nnnv]=dist[v]+1;
                    if(nnnv==t){
                        cout<<dist[nnnv]<<endl;
                        return 0;
                    }
                    que.push(nnnv);
                }
            }
        }
    }

    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    cout<<dist[t]<<endl;
}


Measured memory_bytes: 8832
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	//int n; cin >> n;
	string s; cin >> s;
	if(s == "RRR") cout << 3 << endl;
	else if(s=="SSS") cout << 0 << endl;
	else if(s=="RRS"||s=="SRR") cout << 2 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 3632
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n;
    string st;
    cin >> n >> st;

    map<pair<int, string>, int> m;
    rep(s, (1 << n)){
        string a = "";
        string b = "";
        int len = 0;
        rep(i, n){
            if((s >> i) % 2 == 1){
                a.push_back(st[i]);
                len++;
            }else{
                b.push_back(st[i]);
            }
        }
        reverse(b.begin(), b.end());
        a.append(b);

        pair<int, string> p = make_pair(len, a);
        if(m.find(p) == m.end()){
            m.emplace(p, 0);
        }
        m[p]++;
    }

    int ans = 0;
    rep(s, (1 << n)){
        string a = "";
        string b = "";
        int len = 0;
        rep(i, n){
            if((s >> i) % 2 == 0){
                a.push_back(st[n+i]);
                len++;
            }else{
                b.push_back(st[n+i]);
            }
        }
        reverse(a.begin(), a.end());
        a.append(b);

        pair<int, string> p = make_pair(len, a);
        if(m.find(p) != m.end()){
            ans += m[p];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 20736
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int64_t> A(n);
  for(int i=0;i<n;i++) cin>>A[i];
  
  vector<int> flag(n,0);
  int64_t sum=0;
  
  for(int i=0;i<n;i++){
    if((i+A[i])<n) flag[i+A[i]]++;
  }
  
  for(int j=0;j<n;j++){
    if((j-A[j])>=0) sum += flag[j-A[j]];
  }
  
  cout<<sum<<endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x, y;
  
  if (a%d==0) {
    x=a/d;
  }
  else {
    x=a/d+1;
  }
  
  if (c%b==0) {
    y=c/b;
  }
  else {
    y=c/b+1;
  }
  
  if (y>x) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

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

using namespace std;

vector<long long> h, dp;

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

    h.resize(n);
    dp.resize(n);

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

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for (int i = 1; i < n; i++)
        dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]),
                    dp[i - 1] + abs(h[i - 1] - h[i]));

    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
r = input()
n = list(r)
x = int(n[0])*100 + int(n[0])*10 + int(n[0])

if x < int(r):
  print( ((int(n[0])+1)*100 + (int(n[0])+1)*10 + int(n[0])+1))
else:
  print(x)


Measured memory_bytes: 9180
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s,q;
	cin>>s>>q;
	int flag=0,cnt=0;
	int len=s.length();
	for(int i=0;i<len;i++)
	{
		if(s[i]!=q[i])
		{
			flag=1;
		}
		else cnt++;
	}
	if(flag==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cstdio>
//#include<iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include<string>//"reverse(s's it,s's it)"
//#include<functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include<cmath>//"abs" "sqrt"
//#include<numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include<algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
//#include<cassert>//"assert(cond);": error if cond doesn't hold.
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert//also use as v.is(v's it,w's it,w's it);
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
//Add other types in the same way.
const ll M=1000000007;//can be changed
int mod(int a){	return (a+M)%M;	}//M can be a variable
void plmod(ll &a,ll b){	a=(a+b+M)%M;	return;	}
void mnmod(ll &a,ll b){	a=(a-b+M)%M;	return;	}
void mlmod(ll &a,ll b){	a=(a*b)%M;  	return;	}
//Caution! you may need sth larger than "+M"!
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}
//These 2 could be better in long long

int main(){
	string s;
	cin>>s;
	int a[3];
	fill(a,a+3,0);
	for(int i=0;i<s.size();++i){
		if(s[i]=='a') ++a[0];
		else if(s[i]=='b') ++a[1];
		else ++a[2];
	}
	sort(a,a+3);
	int n=(s.size()/3);
	if(s.size()%3==0){
		if(a[0]==n&&a[1]==n&&a[2]==n)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}else if(s.size()%3==1){
		if(a[0]==n&&a[1]==n&&a[2]==n+1)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	if(s.size()%3==2){
		if(a[0]==n&&a[1]==n+1&&a[2]==n+1)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main() {
    int a,b,c,d,e;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;

    vector<int>meals = {a,b,c,d,e};
    int nax, ni;
    nax = 9;
    ni = 0;
    for (int i=0; i<5; i++){
        if (meals.at(i)%10 != 0 and nax%10 >= meals.at(i) % 10){
            nax = meals.at(i);
            ni = i;
        }
    }

    int ans =0;
    
    for (int i=0; i<5; i++){
        if (i != ni){
            ans += ceil(double(meals.at(i)) / 10.0)*10;
        }
        else {
            ans += meals.at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	int v[20];
	int c[20];
	int i;
	int sum=0;
	
	scanf("%d",&n);
	
	for(i=0; i<n;i++){
		scanf("%d",&v[i]);
	}
	
	for(i=0; i<n;i++){
		scanf("%d",&c[i]);
	}
	
	
	for(i=0;i<n;i++)
	{
		if(v[i] >= c[i])
		sum =sum + v[i] - c[i];
	}
	
	printf("%d",sum);
	
	return 0;
}


Measured memory_bytes: 128
import itertools
class WarshallFloyd:
    def __init__(self,n):
        self.v = n
        self.d = [[1e100]*n for _ in range(n)]
        for i in range(n):
            self.d[i][i] = 0

    def path(self,x,y,c):
        if x == y:
            return False
        self.d[x][y] = c
        self.d[y][x] = c
        return True

    def build(self):
        for k in range(self.v):
            for i in range(self.v):
                for j in range(self.v):
                    self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])
        return self.d

n,m,l = map(int,input().split())
wf = WarshallFloyd(n)
for i in range(m):
    a,b,c = map(int,input().split())
    wf.path(a-1,b-1,c)
d = wf.build()
tank = WarshallFloyd(n)
for i,j in itertools.combinations(range(n),2):
    if d[i][j] <= l:
        tank.path(i,j,1)
d = tank.build()
q = int(input())
ans = [0]*q
for i in range(q):
    s,t = map(int,input().split())
    ans[i] = d[s-1][t-1] - 1 if d[s-1][t-1] != 1e100 else -1
print('\n'.join(str(i) for i in ans))


Measured memory_bytes: 127324
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct node{
    int p,l,r;
}Node;
Node ka[MAX];
int n;

void preParse(int u){
    if(u==NIL)
        return;
    printf(" %d",u);
    preParse(ka[u].l);
    preParse(ka[u].r);
}

void inParse(int u){
    if(u==NIL)
        return;
    inParse(ka[u].l);
    printf(" %d",u);
    inParse(ka[u].r);
}

void postParse(int u){
    if(u == NIL)
        return;
    postParse(ka[u].l);
    postParse(ka[u].r);
    printf(" %d",u);
}
int main(void){
    int i,v,l,r,root;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        ka[i].p=NIL;
    for(i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        ka[v].l=l;
        ka[v].r=r;
        if(l != NIL)
            ka[l].p=v;
        if(r != NIL)
            ka[r].p=v;
    }
    for(i=0;i<n;i++)
        if(ka[i].p == NIL)
            root=i;
    puts("Preorder");
    preParse(root);
    puts("");
    puts("Inorder");
    inParse(root);
    puts("");
    puts("Postorder");
    postParse(root);
    puts("");
    return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
using namespace std;

int inf = 2001001000;
void WF(vector<vector<int>> &graph){
	int n = graph.size();
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				if (graph[i][k] == inf || graph[k][j] == inf) graph[i][j] = min(graph[i][j], inf);
				else graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
			}
		}
	}
}


int main(){
	int v, e; cin >> v >> e;
	vector<vector<int>> graph(v,vector<int>(v,inf));
	for (int i=0;i<e;i++){
		int s,t,d; cin >> s >> t >> d;
		graph[s][t] = d;
	}
	for (int i=0;i<v;i++) graph[i][i] = 0;
	WF(graph);
	for (int i=0;i<v;i++) {
		if(graph[i][i] < 0) {
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}
	for (int i=0;i<v;i++){
		for(int j = 0;j < v;j++){
			if (j != v - 1) {
				if (graph[i][j] == inf) cout << "INF" << " ";
				else cout << graph[i][j] << " ";
			} else {
				if (graph[i][j] == inf) cout << "INF" << endl;
				else cout << graph[i][j] << endl;
			}
		}
	}


	return 0;
}




Measured memory_bytes: 3204
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N;
    read(N);
    vector<double> x(N);
    vector<string> u(N);
    for(int i = 0; i < N; i++){
        read(x[i], u[i]);
    }
    double ans = 0;
    for(int i = 0; i < N; i++){
        if(u[i] == "JPY") {
            ans += x[i];
        }
        else {
            ans += 380000 * x[i];
        }
    }
    cout << fixed << setprecision(4) << ans;
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val a = readLine()!!.map { it == '1' }.toBooleanArray()
    val b = readLine()!!.map { it == '1' }.toBooleanArray()
    fun f(i: Int) = (i + a.size) % a.size
    if (b.all { !it }) {
        println(if (a.all { !it }) 0 else -1)
        return
    }
    val left = IntArray(a.size)
    val right = IntArray(a.size)
    var t = b.size - b.lastIndexOf(true) - 1
    for (i in left.indices) {
        left[i] = if (b[i]) 0 else t + 1
        t = left[i]
    }
    t = b.indexOf(true)
    for (i in right.indices.reversed()) {
        right[i] = if (b[i]) 0 else t + 1
        t = right[i]
    }
    var res = a.size * 5
    for (sh in -a.size..a.size) {
        val flip = a.indices
                .filter { a[it] != b[f(it + sh)] }
                .map {
                    Pair(
                        Math.min(left[it], Math.max(left[it] + sh, 0)),
                        Math.min(right[it], Math.max(right[it] - sh, 0))
                    )
                }
                .toTypedArray()
                .sortedBy { -it.first }
        var shifts = 0
        if (!flip.isEmpty()) {
            shifts = flip[0].first
            var tRight = flip[0].second
            for ((pLeft, pRight) in flip.drop(1)) {
                shifts = Math.min(shifts, tRight + pLeft)
                tRight = Math.max(tRight, pRight)
            }
            shifts = Math.min(shifts, tRight)
        }
        res = Math.min(res, shifts * 2 + flip.size + Math.abs(sh))
    }
    println(res)
}


Measured memory_bytes: 122504
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using uint1024_t = mp::uint1024_t;
using namespace std;


int main() {
	ll D; ll G;
	cin >> D >> G;
	vector<pair<ll, ll>>a(D);
	rep(i, D) {
		ll p, c;
		cin >> p >> c;
		a[i].first = p;
		a[i].second = (ll)(i + 1) * 100 * p + c;
	}
	ll ans = 1e10;
	ll i = 0;
	while (i < pow(2, D)) {
		ll sum = 0;
		ll count = 0;
		rep(j, D) {
			if (i&(1LL << j)) {
				sum += a[j].S;
				count += a[j].F;
			}
		}
		if (sum < G) {
			bool flag = true;
			for (int j = D - 1; j >= 0; j--) {
				if (!(i&(1LL << j)) && flag) {
					rep(k, a[j].F - 1) {
						sum += (j + 1) * 100;
						if (sum >= G) {
							count += k + 1;
							flag = false;
							break;
						}
						else if (k == a[j].first - 2) {
							count = 0;
							flag = false;
							break;
						}
					}
				}
			}
		}
		if (count != 0) {
			ans = min(ans, count);
		}
		i++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n,p;
    while (scanf("%d", &n), n != 0){
        p = 0 ;
        while (n!=1)
        {
            p = p + 1;
            if ((n % 2) == 0)
            {
                n = n / 2;
            }
            else
            {
                n = n * 3 + 1;
            }
        }
        printf("%d\n",p);
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>

int main()
{
    int N;
    std::cin >> N;

    int count = 0;
    int ans = 0;
    double sqt;
    for (int i = 1; i <= N; i += 2)
    {
        sqt = std::sqrt(i);
        count = 0;
        for (int j = 1; j <= N; ++j)
        {
            if (i == 0)
                break;
            if (i % j == 0)
                ++count;
        }
        if (count == 8)
            ++ans;
    }

    std::cout << ans << '\n';

    return 0;
}

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

a_nontax = 0
b_nontax = 0
kakaku = -1
a_nontax = int(A/0.08)
b_nontax = int(B/0.10) + 13
kakaku = -1
if a_nontax != b_nontax:
  start = 0
  end = 0
  if a_nontax > b_nontax:
    start = b_nontax
    end = a_nontax
  else:
    start = a_nontax
    end = b_nontax  
  
  for i in range(start, end + 1, 1):
    if int(i*0.08) == A and int(i*0.10) == B:
      kakaku = i
      break
else:
  kakaku = a_nontax  

print(kakaku)

Measured memory_bytes: 3064