akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

const int dd = (int)1e5 + 7;
int d[dd];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	fill(d, d + dd, (int)1e9);
	
	int k;
	cin >> k;
	
	priority_queue<pair<int, int> > S;
	
	for (int i = 1; i <= min(9, k); i++) {
		d[i % k] = i;
		S.push({ -d[i % k], i % k });
	}
	
	while (S.size()) {
		int mod = S.top().second;
		int len = -S.top().first;
		
		S.pop();
		
		if (d[mod] != len) continue;
		
		for (int c = 0; c < 10; c++) {
			int to = (mod * 10 + c) % k;
			if (d[to] > d[mod] + c) {
				d[to] = d[mod] + c;
				S.push({ -d[to], to });
			}
		}
	}
	
	cout << d[0] << "\n";
	return 0;
}

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

int main(){
  size_t N,K;
  cin >> N >> K;

  vector<int> perm(N);
  for(size_t i=0; i<N; i++){
    cin >> perm.at(i);
    perm.at(i)--; // 1-indexed -> 0-indexed
  }

  vector<int64_t> data(N);
  for(size_t i=0; i<N; i++){
    cin >> data.at(i);
  }

  vector<int64_t> memo(N);
  for(size_t i=0; i<N; i++){
    vector<int64_t> memo_cycle;
    memo_cycle.emplace_back(0);
    size_t v= perm.at(i);
    int64_t cumsum= data.at(v);
    while(memo_cycle.size() < K && v != i){
      memo_cycle.emplace_back(cumsum);
      v= perm.at(v);
      cumsum+= data.at(v);
    }
    size_t Kcycle= memo_cycle.size();
    int64_t score_loop= cumsum;
    memo_cycle.emplace_back(score_loop);

    int64_t score_i= INT64_MIN;
    for(size_t r= 1; r<= Kcycle; r++){
      if(score_loop <= 0){
        score_i= max(score_i, memo_cycle.at(r));
      }
      else{
        int64_t cand= memo_cycle.at(r)+ score_loop* ((K-r)/Kcycle);
        score_i= max(score_i, cand);
      }
    }
    memo.at(i)= score_i;
  }

  int64_t ans= INT64_MIN;
  for(auto score:memo){
    ans= max(ans, score);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3800
#include<stdio.h>

int FI(int);

int F[44];

int main(){
  int n,i;

  scanf("%d",&n);
  for(i=0;i<n;i++)F[i]=-1;

  printf("%d\n",FI(n));

}

int FI(int n){

  if(n==0||n==1) return 1;

  if(F[n-1]==-1) F[n-1]=FI(n-1);
  if(F[n-2]==-1) F[n-2]=FI(n-2);

  return F[n-1]+F[n-2];
}
  



Measured memory_bytes: 2108
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/
ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll number1,ll number2){
	return number1 * number2 / gcd(number1,number2);	
}

int main() {
	
	ll n;
	scanf("%lld", &n);
	ll ans = (ll)n / (ll)11 * (ll)2;
	n %= 11;
	if(n <= 6 && n != 0)++ans;
	else if(n != 0) ans += 2;
	printf("%lld\n", ans);
	
	Please AC;
}


Measured memory_bytes: 256
x_1, y_1, x_2, y_2 = map(int, input().split())

x = x_2-x_1
y = y_2-y_1
x_3, y_3 = x_2-y, y_2+x
x_4, y_4 = x_3-x, y_3-y
print(x_3, y_3, x_4, y_4)

Measured memory_bytes: 2940
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N, K;
  scanln(N, K);
  long ans = 0;
  while(N > 0) {
    N /= K;
    ans++;
  }
  ans.writeln;
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        long m = in.nextLong();
        PriorityQueue<Long> pq = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            pq.add(-in.nextLong());
        }
        for (int i = 0; i < m; i++) {
            long current = -pq.poll();
            pq.add(-current/2);
        }
        long res = 0;
        while(!pq.isEmpty()) {
            res += -pq.poll();
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 60300
N,M = map(int, input().split())
L = [[int(x) for x in input().split()] for _ in range(M)]

l = 0
r = N+1
for i in range(M):
    l = max(l, L[i][0])
    r = min(r, L[i][1])
    
if r-l >= 0:
    print(r-l+1)
else:
    print(0)

Measured memory_bytes: 21156
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string N;
    cin >> N;
    if ((N[0] == N[1] && N[0] == N[2]) || (N[1] == N[2] && N[1] == N[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = 0;
	rep(i, n) {
		if ((i + 1) % 2 == 1) {
			if (a[i] % 2 == 1) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
	int n;cin>>n;
	vector<int>v(n);
	for(auto&& u:v)cin>>u;
	int ret=0,cur=1;
	rep(i,n-1){
		if(v[i]==v[i+1])cur++;
		else {ret+=cur/2;cur=1;}
	}
	ret+=cur/2;
	cout<<ret<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int_fast64_t
using namespace std;
main() {
    int s; cin >> s;
    int k = sqrt(s) + 0.9999999999L;
    int g = (s + k - 1) / k;
    cout <<               0 << ' ' << 0 << ' ';
    cout << (k - s % k) % k << ' ' << k << ' ';
    cout <<               g << ' ' << 1 << ' ';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  string ans;
  int k;
  int ng[10] = {};
  int d;
  bool big = false;

  cin >> s >> k;
  for(int i = 0;i < k;i++){
    cin >> d;
    ng[d] = 1;
  }
  
  for(int i = 0;i < s.size();i++){
    for(int j = 0;j < 10;j++){
      if(ng[j] == 0 && big){
	ans += (j + '0');
	break;
      }else if(ng[j] == 0 && s[i] - '0' <= j){
	if(s[i] - '0' < j) big = true;
	ans += (j + '0');
	break;
      }
    }
    
    if(ans.size() != i + 1){
      int j;
      if(i == 0) j = 1;
      else j = 0;
      for(j;j < 10;j++){
	if(ng[j] == 0){
	  ans += (j + '0');
	  break;
	}
      }
    }
  }
  
  if(ans < s){
    for(int j = 0;j < 10;j++){
      if(ng[j] == 0){
	ans += (j + '0');
	break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

using namespace std;

using lint = long long;

lint INF = numeric_limits<lint>::max();

int main() {
    lint s, t, d;
    cin >> s >> t >> d;

    vector<lint> w(d);
    for (auto& a : w) cin >> a;
    lint wsum = accumulate(w.begin(), w.end(), 0LL);

    lint ans = INF;
    if (wsum >= 0) {
        // 最初の1週だけ見る
        for (int i = 0; i <= d; ++i) {
            if (s <= t) {
                ans = i;
                break;
            }
            if (i < d) s += w[i];
        }
    } else {
        lint ok = 100001, ng = -1;
        while (ok - ng > 1) {
            lint mid = (ok + ng) / 2;
            lint ss = s + mid * wsum;

            bool judge = false;
            for (int i = 0; i <= d; ++i) {
                if (ss <= t) {
                    ans = min(ans, mid * d + i);
                    judge = true;
                }
                if (i < d) ss += w[i];
            }

            (judge ? ok : ng) = mid;
        }
    }

    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,c=0;
  cin >> n;
  for(int i=0;i<3;i++){
  int  r=n%10;
    if(r==7){
       cout << "Yes" << "\n";
      c++;
      break;
    }
    n=n/10;
  }
  if(c==0){
    cout << "No" << "\n";
  }
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#define Max 1
#define Min -1
using namespace std;

typedef long long LL;
const int N = 1e5 + 5;

int arr[N], ope[N], n;
LL dp[3][N];
char s[5];

int main() {
  scanf("%d", &n);
  ope[1] = 1;
  for (int i = 1; i <= n; i ++) {
    scanf("%d", &arr[i]);
    if (i != n) {
      scanf("%s", s);
      if (s[0] == '+') ope[i + 1] = 1;
      else ope[i + 1] = -1;
    }
  }
  dp[1][0] = dp[2][0] = -1e16;
  for (int i = 1; i <= n; i ++) {
    dp[0][i] = dp[0][i - 1] + arr[i] * ope[i];
    dp[1][i] = dp[1][i - 1] - arr[i] * ope[i];
    dp[2][i] = dp[2][i - 1] + arr[i] * ope[i];
    if (ope[i] == -1) {
      dp[2][i] = max(dp[2][i], dp[1][i]);
      dp[1][i] = max(dp[1][i], dp[0][i]);
    }
    dp[0][i] = max(dp[0][i], dp[1][i]);
    dp[1][i] = max(dp[1][i], dp[2][i]);
  }
  printf("%lld\n", dp[0][n]);
  return 0;
}


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

typedef long long ll;

void solve(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B){
  ll rv = 0;
  vector<ll> sA(N+1,0);
  vector<ll> sB(M+1,0);
  for (ll i = 0; i < N; ++i) {
    sA[i+1] = A[i] + sA[i];
  }
  for (ll i = 0; i < M; ++i) {
    sB[i+1] = B[i] + sB[i];
  }

  ll j = M;
  for (ll i = 0; i <= N; ) {
    if (sA[i] + sB[j] <= K) {
      rv = max(rv, i+j);
      i++;
      continue;
    } else {
      if (j != 0) {
        j--;
      } else {
        i++;
      }
    }
  }
  cout << rv << endl;
}

int main() {
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  std::vector<long long> B(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&B[i]);
  }
  solve(N, M, K, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 9616
fun main(args:Array<String>?): Unit {
    while(true){
        val l = readLine()!!.trim()
        if (l == "0") return
        val state = List(2){readLine()!!.trim()}.reversed() + l
        println(listOf('w', 'b').find{c ->
            (0 until 3).any{x -> (0 until 3).all{y -> state[y][x] == c} || (0 until 3).all{y -> state[x][y] == c}} ||
                    (state[1][1] == c && ((state[0][0] == c && state[2][2] == c) || (state[0][2] == c && state[2][0] == c)))
        } ?: "NA")
    }
}


Measured memory_bytes: 31936
#include <stdio.h>
 
#define MAX_N       100
#define QUE_SIZE    10000
 
 
/* priority queue */
typedef struct _QueItem {
    int cost;
    int id;
} QueItem;
QueItem heapq[QUE_SIZE]; /* index 0: unuse, index 1.. : que */
int quecnt;
 
void enq(QueItem a);
QueItem deq();
int qcmp(QueItem a, QueItem b);
 
 
int cost[MAX_N];
int path[MAX_N][MAX_N];
 
 
int main(){
    int n,u,k,v,c;
    int i,j,tn,tk;
    int fin_cnt;
    QueItem item,item2;
    /* init */
    for(i=0;i<MAX_N;i++){
        for(j=0;j<MAX_N;j++){
            path[i][j]=-1;
        }
        cost[i]=-1;
    }
    /* input */
    scanf("%d",&n);
    for(tn=0;tn<n;tn++){
        scanf("%d %d",&u,&k);
        for(tk=0;tk<k;tk++){
            scanf("%d %d",&v,&c);
            path[u][v]=c;
        }
    }
 
    /* calc */
    cost[0] = 0;
    for(i=1;i<n;i++){
        if(path[0][i]>=0){
            item.cost = path[0][i];
            item.id   = i;
            enq(item);
        }
    }
 
    fin_cnt = 1;
    while(fin_cnt<n){
        item = deq();
        if(cost[item.id]<0){
            cost[item.id]=item.cost;
            fin_cnt++;
            for(i=0;i<n;i++){
                if(path[item.id][i]>=0 && cost[i]<0){
                    item2.cost = item.cost + path[item.id][i];
                    item2.id   = i;
                    enq(item2);
                }
            }
        }
    }
 
    /* output */
    for(i=0;i<n;i++){
        printf("%d %d\n",i,cost[i]);
    }
 
    return 0;
}
 
 
 
 
/* add a to heapq */
void enq(QueItem a){
    int i;
    QueItem tmp;
    quecnt++;
    heapq[quecnt] = a;
    for(i=quecnt;i/2>0;i/=2){
        if(qcmp(heapq[i/2],heapq[i]))break;
        tmp = heapq[i];
        heapq[i] = heapq[i/2];
        heapq[i/2] = tmp;
    }
}
 
/* get highest priority item in heapq */
QueItem deq(){
    int i,target;
    QueItem tmp,ret;
    ret = heapq[1];
    heapq[1] = heapq[quecnt];
    quecnt--;
    for(i=1;i*2<=quecnt;){
        if( i*2+1<=quecnt && qcmp(heapq[i*2+1],heapq[i]) ){
            if( qcmp(heapq[i*2],heapq[i*2+1]) ){
                target = i*2;
            }else{
                target = i*2+1;
            }
        }else if( qcmp(heapq[i*2],heapq[i]) ){
            target = i*2;
        }else{
            break;
        }
        tmp = heapq[i];
        heapq[i] = heapq[target];
        heapq[target] = tmp;
        i = target;
    }
    return ret;
}
 
/* return TRUE if priority(a) > priority(b) */
int qcmp(QueItem a, QueItem b){
    return (a.cost<b.cost);
}


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

int main()
{
	int n,k;
    cin >> n >> k;
    int arr[n];
    for(int i=0;i<n;i++) cin >> arr[i];
    sort(arr,arr+n);
    int sum = 0;
    for(int i=0;i<k;i++) sum += arr[i];
    cout << sum << endl;
        
	return 0;
}

Measured memory_bytes: 3652
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int N, M, C; std::cin >> N >> M >> C;
  std::vector<int> B(M);
  for (int i = 0; i < M; ++i) std::cin >> B[i];

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    int num = 0;
    for (int j = 0; j < M; ++j) {
      int k; std::cin >> k;
      num += B[j] * k;
    }

    if (num + C > 0) ++cnt;
  }
  std::cout << cnt << std::endl;
}


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

int main(){
    int64_t n ;
    cin >> n ;
    int64_t ans = n ;
    for (size_t i = 1; i < sqrt(n)+1; i++)
    {
        /* code */
        if (n%i==0)
        {
            /* code */
            if (ans > i + n/i -2)
            {
                /* code */
                ans = i + n/i -2 ;
            }
            
        }
        
    }
    cout << ans << endl ;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int m, n;
    while(true)
    {
        cin>>m>>n;
        if(m==0&&n==0)break;
        for(int i=1;i<=m;i++)
        {
            for(int j=1;j<=n;j++)
            {
                if(i==1||j==1||i==m||j==n)
                {
                    cout<<'#';
                }
                else
                {
                    cout<<'.';
                }
                
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3092
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n + 1],
        b: [u64; n]
    };

    let mut a: Vec<u64> = a;
    let mut count = 0;

    for i in 0..n {
        if a[i] < b[i] {
            let x = b[i] - a[i];
            if a[i + 1] >= x {
                count += x;
                a[i + 1] -= x;
            } else {
                count += a[i + 1];
                a[i + 1] = 0;
            }
            count += a[i];
            a[i] = 0;
        } else {
            a[i] -= b[i];
            count += b[i];
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 5708
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, Q; cin >> N >> Q;
    string S; cin >> S;

    vector<int> cum(S.size()+10, 0);
    rrep (i, 1, S.size()) {
        int cnt = 0;
        if (S[i-1] == 'A' and S[i] == 'C') cnt = 1;
        cum[i] = cnt + cum[i-1];
    }

    rep (i, 0, Q) {
        int l, r; cin >> l >> r; --l; --r;
        cout << cum[r] - cum[l] << endl;
    }
}

Measured memory_bytes: 1408
using System;
using System.Linq;
namespace ABC
{
	class Program
	{
		static void Main(string[] args)
		{
			  int[] n_t = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
				int bestC = 1001;
				for(int i = 0;i < n_t[0];i++)
				{
					int[] c_t = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
					if(c_t[1] <= n_t[1] && bestC > c_t[0]) bestC = c_t[0];
				}
				Console.WriteLine(bestC==1001?"TLE":bestC.ToString());
		}
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans1 = a * x + b * y;
  int ans2 = c * x * 2 + b * max(0, y - x);
  int ans3 = c * y * 2 + a * max(0, x - y);
  cout << min(ans1, min(ans2, ans3)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>
const int N = 2e5 + 10;

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    int ans = a[2] - a[1];
    a[0] += ans;
    int diff = a[2] - a[0];
    if(diff % 2 == 1) {
        ans += 2;
    }
    ans += diff / 2;
    cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String[] temp = in.nextLine().trim().split("\\s");
        int n = Integer.parseInt(temp[0]);
        int w = Integer.parseInt(temp[1]);
        int[] warr = new int[n];
        int[] varr = new int[n];
        for(int i = 0; i < n; i++)
        {
            temp = in.nextLine().trim().split("\\s");
            warr[i] = Integer.parseInt(temp[0]);
            varr[i] = Integer.parseInt(temp[1]);
        } 
        in.close();
        int bound = n*1000;
        long[][] dp = new long[n+1][bound+1];
        for(int i = 1; i <= bound; i++){
            dp[0][i] = Long.MAX_VALUE/2;
        }

        for(int i = 1; i <= n; i++){
            for(int j = 0; j <= bound; j++){
                dp[i][j] = dp[i-1][j];
                if(j >= varr[i-1]){
                    dp[i][j] = Math.min(dp[i][j], dp[i-1][j-varr[i-1]] + warr[i-1]);
                }
            }
        }

        for(int i = bound; i >= 0; i--){
            if(dp[n][i] <= w){
                System.out.println(i);
                break;
            }
        }
    }
}

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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define forI(n) for(ll i = 0 ; i<n ; i++) 
#define forD(an) for(ll i = n-1 ; i>=0 ; i--)
#define MOD 1000000007

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n; cin>>n; cout<<(n+1)/2;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
	int a, b;
	if (scanf("%d", &a) == -1)return 0;
	if (scanf("%d", &b) == -1)return 0;

	if (a <= b)
	{
		printf("%d\n", a);
	}
	else
	{
		printf("%d\n", a - 1);
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int m,f,r;

	while(1)
	{
		scanf("%d %d %d",&m,&f,&r);
		if((m==-1)&&(f==-1)&&(r==-1))
		{
			break;
		}
		else if((f==-1)||(m==-1)||(m+f<30))
		{
			printf("F\n");
		}
		else if(m+f>=80)
		{
			printf("A\n");
		}
		else if((m+f>=65)&&(m+f<80))
		{
			printf("B\n");
		}
		else if(((m+f>=50)&&(m+f<65))||((m+f>=30)&&(m+f<50)&&(r>=50)))
		{
			printf("C\n");
		}
		else if((m+f>=30)&&(m+f<50)&&(r<50))
		{
			printf("D\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
n = int(input())
a,b,c = [list(map(int,input().split())) for i in range(3)]
x = 0
d = -10
for i in range(n):
    y = b[a[i]-1]
    x += y
    if a[i]-1 == d:
        x+= c[d-1]
    d = a[i]
print(x)

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	int a[n + 1][n + 1];
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			cin>>a[i][j];
		}
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			int mn = 2e9;
			for(int k = 1; k <= n; k++){
				if(i != k && j != k)mn = min(mn, a[i][k] + a[k][j]);
			}
			if(mn < a[i][j]){
				cout<<-1<<endl;
				exit(0);
			}
			if(mn > a[i][j])ans += a[i][j];
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 640
#define Z(x,i)(x[i]+x[n/2+i])
int x[99],y[99],X,Y;
n,i;main(){
	for(gets(x);~scanf("%d %d",x+n,y+n);n++);
	if(!(n&1))for(X=Z(x,0),Y=Z(y,0);
		i<n/2&&Z(x,i)==X&&Z(y,i)==Y;
	i++);
	printf(i==n/2?"%f %f\n":"NA\n",X/2.0,Y/2.0);exit(0);
}

Measured memory_bytes: 636
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		int N, M;
		cin >> N >> M;

		vector<int> A( N );
		for( int i = 0; i < N; ++i ) { cin >> A[i]; }
		sort( A.begin(), A.end() );

		vector<pair<int, int>> cb( M );
		for( int i = 0; i < M; ++i ) {
			int b, c;
			cin >> b >> c;
			cb[i] = { c, b };
		}
		sort( cb.begin(), cb.end(), greater<>() );

		priority_queue<int> q;
		for( int i = 0; i < M; ++i ) {
			int b = cb[i].second;
			while( q.size() < N && b-- ) { q.push( cb[i].first ); }
		}

		long ans = 0;
		for( int i = 0; i < N; ++i ) {
			int x = 0;
			if( !q.empty() ) {
				x = q.top();
				q.pop();
			}
			ans += max( x, A[i] );
		}

		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


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

int main() {
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<bitset>
using namespace std;
#define rep(i,a,b) for(register int i = a; i < b; ++ i)
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mkp make_pair

const int N = 100;
const ll mod = (ll)1e9 + 7;
char mp[2][N];

int main() {
	int n,i;
	ll ans;
	scanf("%d",&n);
	scanf("%s%s",mp[0],mp[1]);
	ans = 3;
	if(mp[0][0] == mp[1][0]) {
		i = 1;
	}
	else {
		i = 2;
		ans *= 2;
		ans %= mod;
	}
	for(; i < n; ++ i) {
		if(mp[0][i] == mp[1][i]) {
			if(mp[0][i - 1] == mp[1][i - 1]) {
				ans *= 2;
				ans %= mod;
			}
		/*	else {
				ans *= 1;
			}*/
		}
		else {
			if(mp[0][i - 1] == mp[1][i - 1]) {
				ans *= 2;
				ans %= mod;
			}
			else {
				ans *= 3;
				ans %= mod;
			}
			++ i;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())

t = []
x = []
y = []

# 旅行プランが実行可能か
can = True

for i in range(N):
    t1, x1, y1 = [int(j) for j in input().split()]
    t.append(t1)
    x.append(x1)
    y.append(y1)

    if x[i] + y[i] <= t[i]:
        if (t[i] - x[i] - y[i]) % 2 == 1:
            can = False
    else:
        can = False

if can == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 11784
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char
import Data.Array.IO
import Data.Time.Calendar.MonthDay

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete



main = do
    [m, d] <- getInts
    when (m/=0) ((putStrLn $ ["Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"] !! (flip mod 7 $ monthAndDayToDayOfYear True m d)) >> main)

Measured memory_bytes: 4028
#include<iostream>
#include<algorithm>
#include<cmath>
#define DN 3005
using namespace std;
int poz,vf;
string s,t;
int main()
{
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        poz=0;
        vf=1;
        for(int j=i;j<s.size();j++)
        {
            if(s[j]!=t[poz])
            {
                vf=0;
                break;
            }
            poz++;
        }
        for(int j=0;j<i;j++)
        {
            if(s[j]!=t[poz])
            {
                vf=0;
                break;
            }
            poz++;
        }
        if(vf)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}


Measured memory_bytes: 256
x=int(input())
import math
x5=math.ceil(x**0.2)
#print(x5)
import numpy as np 
while(True):
    for ii in np.arange(x5,-1,-1):
        for jj in range(x5+1):
            #print("a,b",ii,jj)
            if ii**5-jj**5==x:
                print(ii,jj)
                exit()
            if ii**5+jj**5==x:
                print(ii,-jj)
                exit()
    x5*=2

Measured memory_bytes: 27140
# include<iostream>
# include<cstdio>
# include<cstdlib>
# include<cstring>
using namespace std;

int top, s[200];
int pop() {
    top--;
    return s[top+1];
}
int push(int a) {
    s[++top] = a;
}

int main() {
    int a, b;
    char c[3];
    top = 0;
    while(cin >> c) {
        if(c[0] =='+') {
            b = pop();
            a = pop();
            push(a+b);
        } else if (c[0] =='-') {
            b = pop();
            a = pop();
            push(a-b);
        } else if (c[0] =='*') {
            b = pop();
            a = pop();
            push(a*b);
        } else {
            push(atoi(c));
        }
    }
    cout << pop() << endl;
    return 0;
}


Measured memory_bytes: 3096
import math
n = int(input())

def factorize_rec(n, factor):
    for i in range(2, math.floor(math.sqrt(n)) + 1):
        if n % i == 0:
            factor.append(i)
            return factorize_rec(n/i, factor)
    factor.append(int(n))
    return factor

def factorize(n):
    return factorize_rec(n, [])

print(str(n) +":", end=" ")
# for i in factorize(n):
#     print(i, end=" ")
print(*factorize(n), sep=' ')


Measured memory_bytes: 5668
h = int(input())
l_goukei = list()
counter = 0
while(sum(l_goukei) < h):
    if len(l_goukei) == 0:
        l_goukei.append(1)
    else:
        l_goukei.append(l_goukei[-1] * 2)
print(sum(l_goukei))




Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)



int main() {
    ll n;
    cin >> n;
    ll a[n+1];
    rep(i,n) cin >> a[i+1];
    ll ans=0;
    ll ima=1;
    bool OK=false;
    for(ll i=1;i<=n;i++){
        if(a[i]==ima){
            ima++;
        }
        else{
            ans++;
        }
        if(a[i]==1) OK=true;
    }
    if(OK) cout << ans << endl;
    else cout << -1 << endl;
}





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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define whatIs(x) cout<<#x<<" is "<<x<<endl;
#define fillA(a,value) memset(a,value,sizeof(a));
#define len(s) s.length()
#define reached cout<<"reached "<<endl;
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define prq priority_queue<int>
#define mii map<int,int>
#define msi multiset<int>
#define nl "\n"
#define sii set<int,int>
#define sz size

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	int x,y,z;
	cin>>x>>y>>z;
	x-=2*z;
	int ans=0;
	FOR(i,1,100000)
	{
		if(y*i+(i-1)*z<=x)
			ans=i;
		else break;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const int N = 400 + 5;

ll dp[N][N];
ll pre[N];
int a[N];

ll sol(int l ,int r) {
    if(l == r) return 0;

    ll &ret = dp[l][r];
    if(ret != -1) return ret;

    ret = 1e18L;
    for(int i = l; i < r; i++) {
        ret = min(ret, sol(l, i) + sol(i + 1, r) + pre[r + 1] - pre[l]);
    }

    return ret;
}



int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    memset(dp, -1, sizeof(dp));

    int n;
    cin >> n;

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

    for(int i = 0; i < n; i++) pre[i + 1] = pre[i] + a[i];

    cout << sol(0, n - 1) << "\n";
}








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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long int 
typedef pair<int,int> pii;
vector<int>v;
map<int,int>op;
#define MAX 200005
bool visited[MAX];
vector<int>adj[MAX];
const int M=1e9+7;
int n,m;
const ll INF = 1LL << 60;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); 
	cin>>n;
	int we;
	cin>>we;
	ll wt[n],val[n];
	for(int i=0;i<n;i++){
		cin>>wt[i]>>val[i];
	}
	ll dp[n+1][we+1];
	for(int i=0;i<=n;i++)
	{
		for(int w=0;w<=we;w++)
		{
			if(i==0 || w==0)
				dp[i][w]=0;
			else if(wt[i-1]<=w)
				dp[i][w]=max(val[i-1]+dp[i-1][w-wt[i-1]],dp[i-1][w]);
			else
				dp[i][w]=dp[i-1][w];
		}
	}
	cout<<dp[n][we]<<endl;
	return 0;	
}


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

int main(){
  int x,n,ans=100,tmp=100;
  cin >> x >> n;
  vector<int> p(n),test(102);
  for(int i=0;i<=101;i++)test.at(i)=i;
  for(int i=0;i<n;i++){
    cin >> p.at(i);
    test.erase(remove(test.begin(),test.end(),p.at(i)),test.end());
  }
  for(int i:test){
    if(abs(x-i)<tmp){
      ans=i;
      tmp=abs(x-i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main() {
    //freopen("datain.txt","r",stdin);
    int n,k,tot=0,temp;
    cin>>n>>k;
    for (int i=0;i<n;++i) {
        cin>>temp;
        tot+=(min(temp,(k-temp)));
    }
    cout<<tot*2<<endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]

start = 1
end = n
for pair in lst:
    start = max(start, pair[0])
    end = min(end, pair[1])
print(end - start + 1) if end - start + 1 >= 0 else print(0)

Measured memory_bytes: 27336
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("cbaa");
            WillReturn.Add("daacc");
            WillReturn.Add("acacac");
            //aac
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3");
            WillReturn.Add("a");
            WillReturn.Add("aa");
            WillReturn.Add("b");
            //
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        string[] SArr = InputList.Skip(1).ToArray();

        var AnswerDict = new Dictionary<char, int>();
        for (char I = 'a'; I <= 'z'; I++) AnswerDict[I] = int.MaxValue;

        foreach (string EachStr in SArr) {
            var CurrDict = new Dictionary<char, int>();
            for (char I = 'a'; I <= 'z'; I++) CurrDict[I] = 0;

            foreach (char EachChar in EachStr) {
                CurrDict[EachChar]++;
            }

            for (char I = 'a'; I <= 'z'; I++) {
                if (CurrDict[I] < AnswerDict[I])
                    AnswerDict[I] = CurrDict[I];
            }
        }

        var sb = new System.Text.StringBuilder();
        for (char I = 'a'; I <= 'z'; I++) {
            if (AnswerDict[I] > 0) {
                for (int J = 1; J <= AnswerDict[I]; J++) {
                    sb.Append(I);
                }
            }
        }
        Console.WriteLine(sb.ToString());
    }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
int main(){
	ll n;
	ll a[110]={-1};
	cin>>n;
	ll m=0;
	rep(i,0,n){
		cin>>a[i];
		m=max(m,a[i]);
	}
	ll ans=0;
	rrep(i,m+1,1){
		rep(j,0,n){
			if(a[j]==i){
				if(a[j]>a[j+1])ans++;
				a[j]--;		
			}

		}
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input().split()
# N = int(input().split())
# K, N = [int(x) for x in input().split()]

S = input()

if S == "ABC":
    print("ARC")
else:
    print("ABC")

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	string s,s1,s2;
	cin>>s;
	s1=s.substr (0,n/2);
	s2=s.substr (n/2);
	if (s1==s2)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
head = ["M","A","R","C","H"]
num = [0] * 5
ans = 0

for _ in range(n):
    s = input()[0]
    
    for i in range(5):
        if s == head[i]:
            num[i] += 1
            break
            
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += num[i] * num[j] * num[k]
            
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<stack>

using namespace std;

int main(){
	string str;
	int a,b;
	stack<int> s;
	while(cin >> str){
		switch(str[0]){
			case '+': a=s.top();s.pop();b=s.top();s.pop();s.push(b+a);break;
			case '-': a=s.top();s.pop();b=s.top();s.pop();s.push(b-a);break;
			case '*': a=s.top();s.pop();b=s.top();s.pop();s.push(b*a);break;
			default : s.push(stoi(str));break;
		}
	}	
	cout << s.top() << endl;
	return 0;
}

Measured memory_bytes: 3168
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

def func(level, x):
    debug(level, x)
    if level == 0 and x == 1:
        return 1
    elif level == 0 and x <= 0:
        return 0
    npast = num[level - 1]
    if x <= npast + 1:
        tmp = func(level - 1, x - 1)
        debug('a', level, x, tmp)
        return tmp
    elif x == npast + 2:
        tmp = func(level - 1, x - 2)
        debug('b', level, x, tmp + 1)
        return tmp + 1
    else:
        tmp1  = num2[level - 1]
        debug('tmp1', tmp1)
        if x == npast * 2 + 3:
            debug('aa', x - npast - 3)
            tmp2 = func(level - 1, x - npast - 3)
        else:
            tmp2 = func(level - 1, x - npast - 2)
        debug('c', level, x, tmp1 + 1 + tmp2)
        return tmp1 + 1 + tmp2

n, x = MAP()
num = [1]
for i in range(2, n + 1):
    num.append(2 * num[-1] + 3)
num2 = [1]
for i in range(2, n + 1):
    num2.append(2 * num2[-1] + 1)
debug(num)
debug(num2)
ans = func(n, x)
print(ans)


Measured memory_bytes: 60652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String s = in.next();
			long q = in.nextLong();
			ArrayDeque<String> deq = new ArrayDeque<String>();
			deq.offer(s);
			boolean flg = true;
			for (long i = 0; i < q; i++) {
				int t = in.nextInt();
				if (t == 1) {
					flg = !flg;
				} else if (t == 2) {
					int f = in.nextInt();
					if (f == 1) {
						if (flg) {
							deq.offerFirst(in.next());
						} else {
							deq.offerLast(in.next());
						}
					} else if (f == 2) {
						if (flg) {
							deq.offerLast(in.next());
						} else {
							deq.offerFirst(in.next());
						}
					}
				}
			}
			StringBuilder sb = new StringBuilder();
			while (!deq.isEmpty()) {
				sb.append(deq.pop());
			}
			if (flg) {
				out.println(sb.toString());
			} else {
				out.println(sb.reverse().toString());
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 54772
import fractions

def lcm(x, y):
	return (x * y) // fractions.gcd(x, y)

a = input()
a, b, c, d = [int(i) for i in a.split(" ")]
dc = (b // c) - ((a-1) // c)
dd = (b // d) - ((a-1)  // d)
dcd = (b // lcm(c, d)) - ((a-1) // lcm(c, d))
print((b - a) + 1 - (dc + dd - dcd))

Measured memory_bytes: 5048