akhauriyash/Code-Regression huggingface dataset:
/*
https://t.me/unstoppabIesoIvemachinechannel
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
//#pragma GCC target("popcnt")
//#pragma GCC target("sse4")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;










const int mod = 1e9 + 7;
const int p = 31;
signed main(){
    int n;
    cin >> n;
    string s = "", q = "";
    for (int i = 0; i < n; i++){
        char c;
        cin >> c;
        s += c;
    }
    for (int i = 0; i < n; i++){
        char c;
        cin >> c;
        q += c;
    }
    reverse(rng(q));
    int kek = (1 << n);
    map<pair<int,int>, int> m;
  //  cout << s << ' ' << q << endl;
    for (int i = 0; i < kek; i++){
        ll t = 0;
        ll f = 0;
        for (int j = 0; j < n; j++){
            if (i & (1 << j)){
                t = (t * p + (s[j] - 'a') + 1)%mod;
            }else{
                f = (f * p + (s[j] - 'a') + 1) % mod;
            }
        }
      //  cout << t << ' ' << f << endl;
        m[{t,f}]++;
    }
   // cout << endl;
    ll ans = 0;
    for (int i = 0; i < kek; i++){
        ll t = 0;
        ll f = 0;
        for (int j = 0; j < n; j++){
            if (i & (1 << j)){
                t = (t * p + (q[j] - 'a') + 1)%mod;
            }else{
                f = (f * p + (q[j] - 'a') + 1) % mod;
            }
        }
       // cout << t << ' ' << f << endl;
        ans += m[{t,f}];
    }
    cout << ans;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	string s;
	cin >> s;
	int n;
	n = s.size();

	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  
  for (int tsuru = 0; tsuru <= x; tsuru++) {
    if (tsuru*2 + (x - tsuru)*4 == y) {
      cout << "Yes";
      return 0;
    }
  }
  
  cout << "No";
  
  return 0;
}

Measured memory_bytes: 3628
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
int cnt[12345];
int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
  	int n;
  	cin>>n;
  	string s;
  	cin>>s;
  	int i;
  	rep(i,s.length()){
  		cnt[s[i]]++;
  	}
  	ll ans=1;
  	rep(i,1000){
  		ans*=(cnt[i]+1);
  		ans%=mod;
  	}
  	ans--;
  	ans%=mod;
  	ans+=mod;
  	ans%=mod;
  	cout<<ans<<endl;
    return 0;   
}


Measured memory_bytes: 512
#include <iostream>

int calc_denom(int i) {
    int ret = 0;
    while (i % 100 == 0) {
        i /= 100;
        ret++;
    }
    return ret;
}

int main() {
    int D, N;
    std::cin >> D >> N;
    
    int cnt = 0;
    for (int i=1; i<2000000; ++i) {
        if (calc_denom(i)==D) cnt++;
        if (cnt == N) {
            std::cout << i << std::endl;
            break;
        }
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
参考：http://drken1215.hatenablog.com/entry/2018/05/31/015618
しゃくとり法
・ちょっとだけ整理(smとxorは一致させるから1つでよかった)
"""
 
N = int(input())
aN = list(map(int, input().split()))

l,r,ans = 0,0,0
sm = 0
# 外ループで左を動かす
while l < N:
    # 内ループは条件を満たす限り右を動かす
    while r < N and sm + aN[r] == sm ^ aN[r]:
        sm += aN[r]
        r += 1
    # 左右の差分が、今の左位置からうまくいった合計になる
    ans += r - l
    # 左を動かす分、合計から引く
    sm -= aN[l]
    l += 1
print(ans)


Measured memory_bytes: 23560
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  long N;
  cin >> N;
  vector<long> a(N), b(N), c(N);
  for (long i = 0; i < N; i++) cin >> a[i];
  for (long i = 0; i < N; i++) cin >> b[i];
  for (long i = 0; i < N; i++) cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  long sum = 0;
  for (long i = 0; i < N; i++) {
    long target = b[i];
    long ok1 = -1;
    long ng1 = N;
    while (ng1-ok1 > 1) {
      long mid = (ng1+ok1)/2;
      if (target > a[mid]) {
        ok1 = mid;
      } else {
        ng1 = mid; 
      }
    }
    long ng2 = -1;
    long ok2 = N;
    while (ok2-ng2 > 1) {
      long mid = (ng2+ok2)/2;
      if (target < c[mid]) {
        ok2 = mid;
      } else {
        ng2 = mid;
      }
    }
    sum += (ok1+1)*(N-ok2);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

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


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> S(M);
    REP(i, M) {
        cin >> k[i];
        REP(j, k[i]) {
            int tmp;
            cin >> tmp;
            S[i].push_back(tmp);
        }
    }
    vector<int> p(M);
    REP(i, M) { cin >> p[i]; }
    int res = 0;
    for(int bit = 0; bit < pow(2, N); bit++) {
        REP(i, M) {
            int cnt = 0;
            REP(j, k[i]) {
                if(bit & (1 << (S[i][j] - 1))) {
                    cnt++;
                }
            }
            if(cnt % 2 != p[i]) {
                break;
            }
            if(i == M - 1) {
                res += 1;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, K;
    cin >> N >> K;

    ll zero = 0, half = 0;
    FOR(i, 1, N + 1) {
        if (i % K == 0) zero++;

        if (~K & 1 && i % K == K / 2) half++;
    }

    print(ll(pow(zero, 3) + pow(half, 3)));
}


Measured memory_bytes: 4040
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#define INF (INT_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  char x, y;
  cin >> x >> y;
  if(x == y){
    cout << "=" << endl;
  }
  else if(x < y){
    cout << "<" << endl;
  }
  else{
    cout << ">" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

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

int main() {
  int n;
  cin >> n;
  int tmp;
  int flag = 1;
  rep (i, n) {
    cin >> tmp;
    if (tmp % 2 != 1) {
      if (tmp % 3 != 0) {
        if (tmp % 5 != 0) {
          flag = 0;
        }
      }
    }
  }
  if (flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;


  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {

    int N;
    cin >> N;
    int out = N;
    int a = 0;
    int b = 1;
    for(int i=0;i<N;i++){
        cin >> a;
        if(a == b){
            out --;
            b++;
        }
    }
    if(out == N) out = -1;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	int n, m, flag = 1;
	char a[51][51], b[51][51];

	scanf("%d%d", &n, &m);
	for(int i=0; i < n; i++)
		scanf("%s", a[i]);
	for(int i=0; i < m; i++)
		scanf("%s", b[i]);

	for(int i=0; i < n-m+1; i++) {
		for(int j=0; j < n-m+1; j++) {
			for(int k=0; k < m; k++) {
				for(int l=0; l < m; l++) {
					if(a[i+k][j+l] != b[k][l])
						flag = 0;
				}
			}
			if(flag) {
				printf("Yes");
				return 0;
			}
			flag = 1;
		}
	}
	printf("No");

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n, k;   cin >> n >> k;
    vector<int>a(n);
    rep(i, n)   cin >> a[i];
    vector<bool>dp(k+1);    //先手が勝つ:true
    for(int i = 1; i <= k; i++){
        if(i < a[0])    continue;
        rep(j, n){
            if(i < a[j])    break;
            if(!dp[i-a[j]]) dp[i] = true;
        }
    }
    if(dp[k]){
        cout << "First" << endl;
    }else{
        cout << "Second" << endl;
    }
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    if(b-a==c-b)cout << "YES";
    else cout << "NO";
}


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


int main() {
    char a;
    cin >> a;
    if (a == 'a' || a == 'i' || a == 'e' || a == 'u' || a == 'o')cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

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

public class Main {

  public static void main(String[] args) {
    // abc173_a();
    // abc173_b();
    abc173_c();
  }

  // int 2147483648 [ 2 * 10(9)]
  // long 9223372036854775808 [ 9 * 10(18)]

  public static void abc173_a() {
    try (Scanner sc = new Scanner(System.in)) {
      int payment = parseI(sc.next());
      int max = 10000;
      int thou = 1000;

      System.out.println((max - payment) % thou);
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  public static void abc173_b() {
    try (Scanner sc = new Scanner(System.in)) {
      int num = parseI(sc.next());

      // AC
      // WA
      // TLE
      // RE x 0
      int[] ansCount = new int[4];
      final String[] err = { "AC", "WA", "TLE", "RE" };
      Arrays.fill(ansCount, 0);

      for (int i = 0; i < num; i++) {
        String ans = sc.next();
        switch (ans) {
          case "AC":
            ansCount[0]++;
            break;
          case "WA":
            ansCount[1]++;
            break;
          case "TLE":
            ansCount[2]++;
            break;
          case "RE":
            ansCount[3]++;
            break;
        }
      }
      int count = 0;
      for (int answer : ansCount) {
        System.out.println(err[count] + " x " + answer);
        count++;
      }
    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  public static void abc173_c() {
    try (Scanner sc = new Scanner(System.in)) {
      int row = parseI(sc.next());
      int column = parseI(sc.next());
      int checkBlackCount = parseI(sc.next());
      int existBlack = 0;
      int ansCount = 0;
      int[][] inputList = new int[row][column];
      String input = "";
      for (int i = 0; i < row; i++) {
        input = sc.next();
        for (int x = 0; x < column; x++) {
          inputList[i][x] =
            parseI(parseS(input.charAt(x)).replace(".", "0").replace("#", "1"));
        }
      }

      for (int i = 0; i < (1 << row); i++) {
        for (int x = 0; x < (1 << column); x++) {

          for (int chRownum = 0; chRownum < row; chRownum++) {
            for (int chColNum = 0; chColNum < column; chColNum++) {
              if (inputList[chRownum][chColNum] == 1
                && ((i >> chRownum) & 1) == 0 && ((x >> chColNum) & 1) == 0) {
                existBlack++;
              }
            }
          }
          if (existBlack == checkBlackCount) ansCount++;
          existBlack = 0;

        }
      }
      System.out.println(ansCount);

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }

  public static int parseI(String value) {
    return Integer.parseInt(value);
  }

  public static double parseD(String value) {
    return Double.parseDouble(value);
  }

  public static <T> String parseS(T value) {
    return String.valueOf(value);
  }
}


Measured memory_bytes: 36216
#include<iostream>
#include<stdio.h>
using namespace std;
//int M=1000000;
int cnt=0;
void insertion(int A[], int N, int g){
	for(int i=g; i<N; i++){
		int v=A[i];
		int j=i-g;
		while(j>=0 && A[j]>v){
			A[j+g]=A[j];
			j-=g;
			cnt++;
		}
		A[j+g]=v;
	}
}

void shell(int array[],int n){
	int m = 0;
	int s = 1;

	while((n/s) > 0){
		s *= 2;
		m++;	//2^(mult-1)?????§?????????????????¨???????¨?
	}

	int G[20];

	for(int k = 0,t = 1; k < m; k++){
		G[k] = n/t;
		t *= 2;
	}

	for(int i = 0; i < m;i++){
		insertion(array,n,G[i]);
	}

	printf("%d\n",m);
	//cout<<m<<endl;
	for(int i = 0; i < m; i++){
		if(i != m-1){
			printf("%d ",G[i]);
		}else{
			printf("%d\n",G[i]);
		}
	}
	printf("%d\n",cnt);
	for(int i = 0; i < n; i++){
		printf("%d\n",array[i]);
	}

}

int main(){
	int N;
	cin>>N;
	int A[N];
	for(int i=0; i<N; i++)	cin>>A[i];
	shell(A, N);
	return 0;
}



Measured memory_bytes: 7036
'''桁dpの典型問題　n以下の非負整数について条件を満たすものの個数を求める
nより小さいことが確定しているかどうかで場合分けをし、遷移を書いて式にすれば良い。'''
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ns()
k = ni()
dp = [[[0]*2 for _ in range(k+1)] for _ in range(len(n)+1)]
dp[0][0][0] = 1
for i in range(len(n)):
    x = int(n[i])
    for j in range(k):
        dp[i+1][j+1][1] += dp[i][j][1]*9
        dp[i+1][j][1] += dp[i][j][1]
        if x > 0:
            dp[i+1][j][1] += dp[i][j][0]
            dp[i+1][j+1][1] += dp[i][j][0]*(x-1)
            dp[i+1][j+1][0] += dp[i][j][0]
        else:
            dp[i+1][j][0] += dp[i][j][0]
    dp[i+1][k][1] += dp[i][k][1]
    dp[i+1][k][x>0] += dp[i][k][0]
    #インデックスjのところが拾いきれていないので拾う
    #iとkはぶつかっていないので普通に二重ループでかける
print(sum(dp[len(n)][k]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
const ll mod = 998244353ll;
// const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    assert(n >= r);
    assert(n >= 0);
    assert(r >= 0);
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,a,b,c,d,e,q;

ll x[100005], y[100005], z[100005];
ll k;

void solve(){
    string s;
    cin >> s;
    if(s == "ABC")p("ARC");
    if(s == "ARC")p("ABC");
    return;
}

int main(){

    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
    if(multicase){
        cin >> q;
    }else{
        q = 1; 
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    // solve();
    return 0;
}
















Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;

 
int main(){
    ll A, B; cin >> A >> B;
    if(A == B) {cout << A << endl; return 0;}
    ll ans = 0;
    if(A % 2 == 1) { ans = A; A++;}
    if(B % 2 == 0) { ans = ans^B; B--;}
    ll rem = B - A + 1;
    ll num1 = rem / 2;
    if(num1 % 2 == 1) ans = ans ^1;
    cout << ans << endl;

    

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args){
		double x1 = scan.nextDouble();
		double y1 = scan.nextDouble();
		
		double x2 = scan.nextDouble();
		double y2 = scan.nextDouble();
//		double x1 = Double.parseDouble(args[0]);
//		double y1 = Double.parseDouble(args[1]);
//
//		double x2 = Double.parseDouble(args[2]);
//		double y2 = Double.parseDouble(args[3]);

		double out = Math.sqrt(Math.pow(Math.abs(x1 - x2), 2)+Math.pow(Math.abs(y1 - y2), 2));
		System.out.println(out);
		//x=root(x2+y2)
	}


}



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

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    int n, x;
    cin >> n >> x;
    vector<int> L(n);
    for(int i = 0; i < n; i++){
        cin >> L.at(i);
    }
    int d = 0;
    int c = 0;
    if(d <= x) c++;
    for(int i = 0; i < n; i++){
        d = d+L.at(i);
        if(d <= x) c++;
    }
    cout << c << endl;
    return 0;
}


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

using namespace std;

#define black 0
#define white 1

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
// #define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)

vector< list<int> > Edges(1e5 + 5);
vector< vector<int> > dp(1e5 + 5, vector<int>(2,-1));

// 0 is black 1 is white. no two adjacent zeroes

int findNoOfWaysToColor(int node, int color, int parent)
{
	if(node<=0)
		return 1;
	if(dp[node][color]!=-1)
		return dp[node][color];
	int ans = 1, v1, v2;
	for(list<int>::iterator i= Edges[node].begin(); i != Edges[node].end(); i++)
	{
		int child = *i;
		if(child != parent && child!=node)
		{
			v1 = findNoOfWaysToColor(child, white, node);
			v2 = 0;
			if(color)
				v2 = findNoOfWaysToColor(child, black, node);
			ans = (ans*((v1+v2)%hell))%hell;
		}
	}
	dp[node][color] = ans;
	return ans;
}



void solve()
{
	int n, i, a, b, startNode = -1;
	cin>>n;
	
	for(i = 0; i < n-1; i++)
	{
		cin>>a>>b;
		if(startNode == -1)
			startNode = a;
			Edges[a].pb(b);
			Edges[b].pb(a);
	}
	cout<<((findNoOfWaysToColor(startNode, white, -1)+findNoOfWaysToColor(startNode, black, -1))%hell)<<endl;
}


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
	tc = 1;
    // cin>>tc;
    while(tc--)
        solve();

    return 0;
}


Measured memory_bytes: 20352
#include <iostream>

int main()
{
        long long a,b,c,k;
        std::cin >> a >> b >> c >> k;

        int xa = std::min(a,k);
        k -= xa;
        int xb = std::min(b,k);
        k -= xb;
        int xc = k;

        std::cout << xa-xc << std::endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b) cout<<(n-2)*(b-a)+1;
    else cout<<0;
	cout<<endl; 
	return false;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
const int maxn=2e5+10;
int n,a[maxn];
ll solve(int t)
{
    ll ret=0;
    for(int i=1;i<=n;i++)
    {
        ret+=1ll*abs(t-a[i]);
    }
    return ret;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        a[i]-=i;
    }
    std::sort(a+1,a+1+n);
    if(n%2==1) printf("%lld\n",solve(a[(n+1)/2]));
    else
    {
        ll ans=0x7fffffffffffffff;
        ans=std::min(ans,solve(a[n/2]));
        ans=std::min(ans,solve(a[n/2+1]));
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 896
/**
 *    author:  ykaka
 *    created: 01.08.2020 20:54:48       
**/
 
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i<(n);++i)
using namespace std;
using ll = long long;
 
int main(){
  double d, t, s;
  cin >> d >> t >> s;
  if(d / s <= t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3728
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;


public class Main {
	
	public static class UnionFind{
		int[] par;
		UnionFind(int n){
			par=new int[n];
			for(int i=0;i<n;i++)par[i]=i;
		}
		public int find(int x){
			if(par[x]==x)return x;
			return par[x]=find(par[x]);
		}
		public Boolean same(int x,int y){
			return find(x)==find(y);
		}
		public void unite(int x,int y){
			if(find(x)==find(y))return;
			par[find(x)]=find(y);
		}
	}
	
	public static class Edge implements Comparable<Edge>{
		int start;
		int end;
		int cost;
		
		public Edge(int start, int end, int cost) {
			super();
			this.start = start;
			this.end = end;
			this.cost = cost;
		}

		@Override
		public int compareTo(Edge o) {
			return this.cost - o.cost;
		}
		
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int nodes, edges;
			
			nodes = sc.nextInt();
			edges = sc.nextInt();
			
			if(nodes == 0 && edges == 0){
				break;
			}
			
			Edge[] array = new Edge[edges];
			for(int i = 0; i < edges; i++){
				array[i] = new Edge(sc.nextInt(), sc.nextInt(), sc.nextInt());
			}
			
			Arrays.sort(array);
			
			int count = 0;
			List<Edge> list = new LinkedList<Edge>();
			UnionFind uf = new UnionFind(nodes);
			for(Edge e : array){
				if(count >= nodes){
					break;
				}
				
				if(!uf.same(e.start, e.end)){
					list.add(e);
					count++;
					uf.unite(e.start, e.end);
				}
			}
			
			int sum = 0;
			for(Edge e : list){
				sum += e.cost;
			}
			
			System.out.println(sum);
		}

	}

}

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

int main() {
  int a, b, c = 0;
  cin >> a >> b;
  if(a > b) {
    c += a;
    a--;
  } else {
    c += b;
    b--;
  }
  if(a > b) {
    c += a;
    a--;
  } else {
    c += b;
    b--;
  }
  cout << c << "\n";
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll x; cin>>x;
    for(ll a=1;a<=5000;a++){
        ll A=a*a*a*a*a;
        ll B=A-x;
        ll l=-5000,r=5000,ce,C;
        while(l!=r){
            ce=r-l;
            ce=l+ce/2;
            C=ce*ce*ce*ce*ce;
            if(C<B) l=ce+1;
            else r=ce;
        }
        if(l*l*l*l*l==B){
            cout<<a<<" "<<l<<endl;
            break;
        }
    }
}

Measured memory_bytes: 3592
import std.stdio, std.string, std.conv, std.algorithm, std.math;

void main()
{
    while(true)
    {
        auto inp = readln.split.map!(to!int);
        if(!inp[0] && !inp[1] && !inp[2]) break;
        real a = inp[0], b = inp[1], c = inp[2];
        real r = min(a * a + b * b, b * b + c * c, c * c + a * a).sqrt; 
        foreach(_; 0 .. readln.chomp.to!int)
        {
            if(readln.chomp.to!int * 2 > r) "OK".writeln;
            else "NA".writeln;
        }
    }
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll gcd(ll a,ll b){
if(a%b==0)return b;
else return gcd(b,a%b);
}

int main(){
ll  n,m;
cin>>n>>m;
string s,t;
cin>>s>>t;
ll kou=gcd(n,m),lon = n*(m/kou);
//vector<char> tmp (lon,'.');
//for(ll i=0;i<n;i++)tmp[i*(lon/n)]=s[i];
ll dn=lon/n,dm=lon/m;
for(ll i=0;i*dm<n&&i*dn<m;i++){
if(s[i*dm]==t[i*dn]){
}
else{
	cout<<-1<<endl;
	return 0;
}
}
cout<<lon<<endl;


}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>

#define pb push_back

using namespace std;

vector<int> adjlist[100010];
int memo[100010];

int dp(int pos) {
	int nxt, ret = 0;
	if (memo[pos] != -1)
		return memo[pos];
	for (int j = 0; j < (int) adjlist[pos].size(); j++) {
		nxt = adjlist[pos][j];
		ret = max(ret, dp(nxt) + 1);
	}
	memo[pos] = ret;
	return ret;
}

int main() {
	int n, m, x, y, ans = 0;
	scanf("%d %d", &n, &m);
	while (m--) {
		scanf("%d %d", &x, &y);
		adjlist[x].pb(y);
	}
	memset(memo, -1, sizeof memo);
	for (int i = 1; i <= n; i++)
		ans = max(ans, dp(i));
	printf("%d\n", ans);
	return 0;
}

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

public class Main {
           public static void main (String args[]){

           BufferedReader reader = new BufferedReader (new InputStreamReader (System.in));
           String line;

           try {
                   line = reader.readLine();
                   int number = Integer.parseInt(line);
                   if (number<1200){
                         System.out.print("ABC");
                  } else {
                        System.out.print("ARC");
                 }
                 }catch (IOException e){
                    System.out.print(e);
                 }catch (NumberFormatException e){
                     System.out.print("数字のみ");
                  }
}
}

Measured memory_bytes: 8148
#include<cstdio>
using namespace std;
int n,a[100010];
int main(){
	scanf("%d",&n);
	int A=0,B=0;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		if(a[i]%4==0){
			++A;
		}
		if(a[i]%2!=0){
			++B;
		}
	}
	if(A+B==n && B<=A+1){
		puts("Yes");
		return 0;
	}
	if(A+B<n && B<=A){
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int ans[200010], visited[200010], dist[200010];
vector<int> graph[200010];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, x, y;
	cin >> n >> x >> y;
	for(int i = 1; i <= n - 1; i++){
		graph[i].pb(i + 1);
		graph[i + 1].pb(i);
	}
	graph[x].pb(y);
	graph[y].pb(x);
	for(int i = 1; i <= n; i++){
		memset(visited, 0, sizeof(visited));
		dist[i] = 0;
		queue<int> pq;
		pq.push(i);
		visited[i] = 1;
		while(pq.size()){
			int x = pq.front();
			pq.pop();
			for(auto to: graph[x]){
				if(!visited[to]){
					dist[to] = dist[x] + 1;
					ans[dist[to]]++;
					visited[to] = 1;
					pq.push(to);
				}
			}
		}
	}
	for(int i = 1; i <= n - 1; i++){
		cout << ans[i] / 2 << '\n';
	}

}

Measured memory_bytes: 6656
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()


prob = 0
for i in range(1, N + 1):
	num = i
	mul = 0
	while num < K:
		num *= 2
		mul += 1
	prob += (1/N)*((1/2)**mul)

print(prob)

Measured memory_bytes: 60140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k, x;
  cin >> k >> x;
  
  vector<int> vec(2*k-1);
  for(int i=0; i<(2*k-1); i++){
    vec.at(i) = x-k+1+i;
  }
  for(int i=0; i<(2*k-1); i++){
    cout << vec.at(i) << ' ';
  }
  cout << endl;
}


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

int main(){
  int n,k,l[100],sum=0;
  cin>>n>>k;
  for(int i=0;i<n;i++) cin>>l[i];
  sort(l,l+n,greater<int>());
  for(int i=0;i<k;i++){
    sum+=l[i];
  }
  cout<<sum;
}


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

int main(){
  int h, w;
  
  while(1){
    std::cin >> h >> w;
    if(h == 0 && w == 0){ break; }
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	std::cout << '#';
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 3088
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    A=list(map(int,input().split()))
    for i in range(N):
        A[i]-=i+1
    A.sort()
    def f(x):
        tmp=0
        for a in A:
            tmp+=abs(a-x)
        return tmp
    print(min(f(A[N//2]),f(A[N//2-1])))
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 81776
def analyze(points, left_static, right_static):
    """
    (x0, +1 or -1) in points
    """

    rightest_neg = -10**9
    leftest_neg = 10**9
    rightest_pos = -10**9
    leftest_pos = 10**9
    for x, d in points:
        if d == 1:
            rightest_pos = max(rightest_pos, x)
            leftest_pos = min(leftest_pos, x)
        else:
            rightest_neg = max(rightest_neg, x)
            leftest_neg = min(leftest_neg, x)


    max_t1 = rightest_neg - right_static
    max_t2 = right_static - rightest_pos
    if max_t1 > max_t2:
        max_t1 = max_t2 = (rightest_neg-rightest_pos)/2
    max_t1 = max(0, max_t1)
    max_t2 = max(0, max_t2)
    max_x0 = max(rightest_pos, rightest_neg, right_static)
    max_x1 = max(rightest_pos + max_t1, rightest_neg - max_t1, right_static)
    def get_xmax(t):
        if t > max_t2:
            return max_x1 + t-max_t2
        elif t > max_t1:
            return max_x1
        else:
            return max_x0 - t

    min_t1 = left_static - leftest_pos
    min_t2 = leftest_neg - left_static
    if min_t1 > min_t2:
        min_t1 = min_t2 = (leftest_neg - leftest_pos)/2
    min_t1 = max(0, min_t1)
    min_t2 = max(0, min_t2)
    min_x0 = min(leftest_pos, leftest_neg, left_static)
    min_x1 = min(leftest_pos + min_t1, leftest_neg - min_t1, left_static)

    def get_xmin(t):
        if t > min_t2:
            return min_x1 - t + min_t2
        elif t > min_t1:
            return min_x1
        else:
            return min_x0 + t

    T = sorted((max_t1, max_t2, min_t1, min_t2))
    D = [get_xmax(t)-get_xmin(t) for t in T]
    return T,D



N = int(input())

conv = {'R':0,'U':1,'L':2,'D':3}
points = [(lambda i: (int(i[0]), int(i[1]), conv[i[2]]))(input().split()) for _ in range(N)]


xt, xd = analyze([(x, 1 if d == 0 else -1) for x,y,d in points if d%2==0],
                    min((x for x,y,d in points if d%2==1), default=10**9),
                    max((x for x,y,d in points if d%2==1), default=-10**9))

yt, yd = analyze([(y, 1 if d == 1 else -1) for x,y,d in points if d%2==1],
                    min((y for x,y,d in points if d%2==0), default=10**9),
                    max((y for x,y,d in points if d%2==0), default=-10**9))

def get_w(t):
    a,b,c,d = xt

    if t < a:
        return -2, xd[0] + 2*a
    elif t < b:
        return -1, xd[0] + a
    elif t < c:
        return 0, xd[1]
    elif t < d:
        return 1, xd[2] - c
    else:
        return 2, xd[3] - 2*d

def get_h(t):
    a,b,c,d = yt

    if t < a:
        return -2, yd[0] + 2*a
    elif t < b:
        return -1, yd[0] + a
    elif t < c:
        return 0, yd[1]
    elif t < d:
        return 1, yd[2] - c
    else:
        return 2, yd[3] - 2*d

T = sorted(xt+yt)

def it():
    ne = iter(T)
    next(ne)
    for a,b in zip(T,ne):
        t = (a+b)/2

        wa, wb = get_w(t)
        ha, hb = get_h(t)
        if wa*ha > 0 and a < -(wb*ha+wa*hb)/(2*wa*ha) < b:
            t = -(wb*ha+wa*hb)/(2*wa*ha)
            yield ((wa*t+wb)*(ha*t+hb), t)
        else:
            yield ((wa*a+wb)*(ha*a+hb), a)
            yield ((wa*b+wb)*(ha*b+hb), b)

print(min(it())[0])

Measured memory_bytes: 21020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(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, Scanner in, PrintWriter out)
        {
            int K = in.nextInt();
            int N = in.nextInt();
            int nums[] = CPUtils.readIntArray(N, in);
            int distance = Integer.MAX_VALUE;
            for (int i = 0; i < nums.length; i++)
            {
                distance = Math.min(distance, getD(i, i + (nums.length - 1), nums, K));
            }
            out.print(distance);
        }

        private int getD(int start, int end, int nums[], int K)
        {
            end = end % nums.length;
            if (nums[end] < nums[start])
            {
                return (K - nums[start] + nums[end]);
            } else
            {
                return nums[end] - nums[start];
            }
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 76940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
const int INF = 1000000009;

char s[100005];
int main(){
	scanf("%s", s);
	int len = strlen(s);
	int cost0 = len;
	int cost1 = len;
	for(int i = 0; i < len; i++){
		int cost = std::max(std::max(len-i-1, 1), std::max(1, i));
		//printf("cost = %d\n", cost);
		if(s[i] == '1'){
			cost1 = std::min(cost1, cost);
		}else{
			cost0 = std::min(cost0, cost);
		}
	}
	printf("%d\n", std::max(cost1, cost0));
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
using namespace std;

int main() {
	int H, W;
	while (1) {
		(void)scanf("%d %d", &H, &W);
		if (!H && !W) break;
		for (int i = 0; i < H; i++) {
			if (i % 2 == 0) {
				for (int i = 0; i < W; i++) {
					if (i % 2 == 0) printf("#");
					else printf(".");
				}
				printf("\n");
			}
			else {
				for (int i = 0; i < W; i++) {
					if (i % 2 == 0) printf(".");
					else printf("#");
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2552
n, k = gets.split(" ").map(&:to_i)
array = [0] * 100001
n.times do |i|
  a, b = gets.split(" ").map(&:to_i)
  array[a] += b
end

ans = nil
array.each_with_index do |x, i|
  b = x
  if k <= b then
    ans = i
    break
  else
    k = k - b
  end
end

puts ans

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

int n, a, b, c;
string s[100001];
char ans[100001];

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

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

    for(int i = 0; i < n; i++) {
        if(s[i] == "AB") {
            if(a == 0 && b == 0) {
                cout << "No" << '\n';
                return 0;
            }
            else if(a == 1 && b == 1 && c == 0 && i != n && s[i + 1] == "AC") {
                b--;
                a++;
                ans[i] = 'A';
            }
            else if(a == 1 && b == 1 && c == 0 && i != n && s[i + 1] == "BC") {
                a--;
                b++;
                ans[i] = 'B';
            }
            else if(a > b) {
                a--;
                b++;
                ans[i] = 'B';
            }
            else {
                a++;
                b--;
                ans[i] = 'A';
            }
        }

        if(s[i] == "AC") {
            if(a == 0 && c == 0) {
                cout << "No" << '\n';
                return 0;
            }
            else if(a == 1 && c == 1 && b == 0 && i != n && s[i + 1] == "AB") {
                c--;
                a++;
                ans[i] = 'A';
            }
            else if(a == 1 && c == 1 && b == 0 && i != n && s[i + 1] == "BC") {
                a--;
                c++;
                ans[i] = 'C';
            }
            else if(a > c) {
                a--;
                c++;
                ans[i] = 'C';
            }
            else {
                a++;
                c--;
                ans[i] = 'A';
            }
        }

        if(s[i] == "BC") {
            if(b == 0 && c == 0) {
                cout << "No" << '\n';
                return 0;
            }
            else if(b == 1 && c == 1 && a == 0 && i != n && s[i + 1] == "AB") {
                c--;
                b++;
                ans[i] = 'B';
            }
            else if(b == 1 && c == 1 && a == 0 && i != n && s[i + 1] == "AC") {
                b--;
                c++;
                ans[i] = 'C';
            }
            else if(b > c) {
                b--;
                c++;
                ans[i] = 'C';
            }
            else {
                b++;
                c--;
                ans[i] = 'B';
            }
        }
    }

    cout << "Yes" << '\n';
    for(int i = 0; i < n; i++)
        cout << ans[i] << '\n';
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

const string pros = "YES";
const string cons = "NO";

ll n;
vl a;
vl b;
ll ans;

int main(){
  cin >> n;
  a = vl(n+1);
  b = vl(n);
  for(ll i = 0;i < n+1;i++) cin >> a[i];
  for(ll i = 0;i < n;i++) cin >> b[i];
  for(ll i = 0;i < n;i++){
    ll x = min(b[i],a[i]);
    b[i] -= x;
    a[i] -= x;
    ans += x;
    x = min(b[i],a[i+1]);
    b[i] -= x;
    a[i+1] -= x;
    ans += x;
  }
  cout << ans << endl;

}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int m = kb.nextInt();
		int count = n * (n - 1) / 2 + m * (m - 1) / 2;
		System.out.println(count);
		kb.close();
	}

}


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

using namespace std;
typedef long long int ll;
typedef tuple<ll,ll,ll> T;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll N, Q;
  cin >> N >> Q;
  vector<T> query;
  rep(i, N){
    ll s, t, x;
    scanf("%lld %lld %lld", &s, &t, &x);
    if(t-x <= 0) continue;
    query.emplace_back(s-x > 0 ? s-x : 0, 0, x);
    query.emplace_back(t-x, 1, x);
  }
  rep(i, Q){
    ll d;
    scanf("%lld", &d);
    query.emplace_back(d, 2, -1);
  }
  sort(query.begin(), query.end());

  multiset<ll> works;
  for(auto qit=query.begin(); qit<query.end(); ++qit){
    ll type, x;
    tie(ignore, type, x) = *qit;
    if(type == 0){
      works.insert(x);
    }
    else if(type == 1){
      works.erase(works.lower_bound(x));
    }
    else{
      auto wit = works.lower_bound(0);
      if(wit == works.end()) cout << -1 << endl;
      else cout << *wit << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 26600