akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll n;
  std::vector< int > a;
  std::vector< int >::iterator it;
  ll all_distance = 0;
  
  std::cin >> n;
  a.push_back(0);
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    std::cin >> tmp;
    a.push_back(tmp);
  }
  a.push_back(0);

  // calc all_distance
  {
    std::vector< int >::iterator pre;    
    it = a.begin();
    pre = it;
    it++;
    for (; it != a.end(); it++) {
      all_distance += std::fabs(*it - *pre);
      pre = it;
    }
  }
  
  for (int i = 1; i <= n; i++) {
    ll ans = 0;
    ans = all_distance - std::fabs(a[i] - a[i-1]) - std::fabs(a[i+1] - a[i]) + std::fabs(a[i+1] - a[i-1]);
    std::cout << ans << std::endl;
  }  
  
  return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  	int n;	cin >> n;	
	vector<int> d(n); rep(i,n) cin >> d.at(i);
  	int sm = 0;
  	
  	rep(i,n){
    	rep(j,n){
        	if(i != j){
            	sm += d.at(i)*d.at(j);
            }
        }
    }
  	
  	cout << sm/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(i, n) mp[a[i]]++;
    vi ans;
    int cnt = 0;
    for (auto p : mp) {
        ans.push_back(p.se);
        cnt++;
    }
    sort(ans.begin(), ans.end());
    int res = 0;
    if (cnt > k) {
        rep(i, cnt - k) {
            res += ans[i];
        }
    } 
    cout << res << endl;
    
}

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

int n, l[11];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i) cin >> l[i];
	sort(l, l+n);
	int s = 0;
	for(int i=0; i<n-1; ++i) s += l[i];
	cout << (s > l[n-1] ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,x,y;
long long ans;
int main()
{
    cin>>n>>k>>x>>y;
    for(int i=1;i<=n;i++)
    {
        if(i>k)
          ans+=y;
        else
          ans+=x;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pll pair<ll, ll>
#pragma GCC optimize ("O3")
using namespace std;
int main () {
    #ifdef LOCAL
        freopen ("input.txt", "r", stdin);
        freopen ("output.txt", "w", stdout);
        freopen ("error.txt", "w", stderr);
    #else
        ios::sync_with_stdio(false);
        cin.tie (NULL);
    #endif
    int n; cin>>n;
    double sum=0;
    while (n--) {
        double a; cin>>a;
        sum+=1/a;
    }
    cout<<fixed<<setprecision(10)<<1/sum;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[test]
fn test() {
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
    token.parse().ok().expect("failed to parse token")
}

fn resistors_in_parallel(n: usize, a: Vec<f32>) -> f32 {
    let mut calc: f32 = 0.0;    

    for i in 0..n {
        calc = calc + a[i].recip();
    }
    let ans: f32 = calc.recip();
    ans
}

fn main() {
    let n: usize = read();
    let mut a = Vec::new();
    for _i in 0..n {
        a.push(read::<f32>());
    }
    println!("{}", resistors_in_parallel(n, a));

}



Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val (k, n) = readLine()!!.split(" ").map { it.toInt() }
    val ll = readLine()!!.split(" ").map{it.toInt()}.toList()
    var dl = mutableListOf<Int>()
    for(i in 0 until ll.size - 1){
        dl.add(ll[i + 1]  - ll[i])
    }
    dl.add(k - ll.last() + ll.first() )
    val a = dl.reduce{l,r -> r + l} - dl.max()!!
    println(a)
}


Measured memory_bytes: 83068
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


main(){
  int n;
  while(cin>>n,n){
    double x[n],y[n];

    rep(i,n)cin>>x[i]>>y[i];

    int ans=1;

    rep(i,n){
      rep(j,i){
	double sx,sy;
	double tx=x[i]-x[j],ty=y[i]-y[j];
	double len=sqrt(tx*tx+ty*ty);
	if(len>2)continue;
	len=sqrt(1-len*len/4);
	double theta=atan2(ty,tx)+M_PI/2;
	int tans=0;
	sx=(x[i]+x[j])/2+cos(theta)*len;
	sy=(y[i]+y[j])/2+sin(theta)*len;
	rep(k,n){
	  tx=sx-x[k];
	  ty=sy-y[k];
	  if(tx*tx+ty*ty<=1+EPS)++tans;
	}
	ans=max(ans,tans);
	tans=0;
	sx=(x[i]+x[j])/2-cos(theta)*len;
	sy=(y[i]+y[j])/2-sin(theta)*len;
	rep(k,n){
	  tx=sx-x[k];
	  ty=sy-y[k];
	  if(tx*tx+ty*ty<=1+EPS)++tans;
	}
	ans=max(ans,tans);
      }
    }
    cout<<ans<<endl;
  }
}

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

int main(){
  int h,w;

  while(1){
    cin >> h >> w;
    if(!h && !w)break;
    
    vector<string> grid;
    for(int i=0;i<h;i++){
      string tmp;
      cin >> tmp;
      grid.push_back(tmp);
    }

    int ans = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(grid[i][j] == '.'){
	  int x = w;
	  int tmp = 0;
	  for(int k=i;k<h;k++){
	    if(grid[k][j]=='*')break;
	    int l;
	    for(l=j;l<x;l++){
	      if(grid[k][l]=='*'){
		x = min(x,l);
		break;
	      }
	    }
	    tmp = max(tmp,(x-j)*(k-i+1));
	  }
	  ans = max(ans,tmp);
	}
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1192
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const int N = 310;
int dp[N][N][N];

void chmax(int &a, int b) { a = max(a, b); }

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int k;
  cin >> s >> k;
  int n = s.length();
  REP(i, 0, n) {
    dp[i][i + 1][0] = 1;
  }
  REP(u, 2, n + 1) {
    REP(i, 0, n - u + 1) {
      REP(l, 0, k + 1) {
        int j = i + u;
        int tmp = 0;
        chmax(tmp, dp[i][j - 1][l]);
        chmax(tmp, dp[i + 1][j][l]);
        if (s[i] == s[j - 1]) {
          chmax(tmp, dp[i + 1][j - 1][l] + 2);
        }
        if (l >= 1) {
          chmax(tmp, dp[i + 1][j - 1][l - 1] + 2);
        }
        dp[i][j][l] = tmp;
      }
    }
  }
  int ma = 0;
  REP(i, 0, k + 1) chmax(ma, dp[0][n][i]);
  cout << ma << endl;
}


Measured memory_bytes: 112896
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

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

  ll ans = -1;
  for(int msk = 0;msk < (1 << n);++msk){
    ll cur = 1;
    for(int i = 0;i < n;++i)
      if(msk & (1 << i)) cur <<= 1;
      else cur += k;
    if(ans == -1) ans = cur;
    relaxMin(ans, cur);
  }

  cout << ans << '\n';

  return 0;
}


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

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	
	int n,m;
	cin>>n>>m;

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

	vector<pair<int,int> > v;
	vector<pair<int,int> > :: iterator it;

	int temp = m;
	while(temp--){
		int x,y;
		cin>>x>>y;
		v.push_back(make_pair(x,y));
		v.push_back(make_pair(y,x));
	}

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

	// for(it=v.begin();it!=v.end();++it){
	// 	cout<<it->first<<" "<<it->second<<endl;
	// }

	int arr[n+1];

	for(i=1;i<=n;i++)
	arr[i] = 1;
	
	int curr = 1;

	it = v.begin();

	while(it != v.end()){
		int ch = 1;
		while(it != v.end() && it->first == curr){
			if(h[curr] <= h[it->second]){
				ch = 0;
				break;
			}
			it++;
		}
		
		if(ch == 1){
			//arr[curr] = 1;
			curr++;
		}
		if(ch == 0){
			arr[curr] = 0;
			curr++;
			while(it != v.end() && it->first < curr)
			it++;
			
		}
		if(it == v.end())
		break;
		
	}
	int ans = 0;

	for(i=1;i<=n;i++){
		//cout<<arr[i]<<" ";
		if(arr[i] == 1)
		ans++;
	}
	// cout<<endl;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5724
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
#define FOR(i, n) for(ll i = 0; i < n; i++)
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);    
    cin.tie(0);
    ll N, W;
    cin >> N >> W;
    ll weight[N + 1], cost[N + 1];
    memset(weight, 0, sizeof(weight));
    memset(cost, 0, sizeof(cost));
    for(ll i = 1; i <= N; i++)
        cin >> weight[i] >> cost[i]; // (weight, value)
    ll dp[N + 1][W + 1];
    memset(dp, 0, sizeof(dp));
    for(ll item = 1; item <= N; item++)
        for(ll w = 1; w <= W; w++){
            if(w >= weight[item]) 
                dp[item][w] = max(dp[item - 1][w - weight[item]] + cost[item], dp[item - 1][w]);
            else dp[item][w] = max(dp[item][w - 1], dp[item - 1][w]);
        }
    cout << dp[N][W] << "\n";
}

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

int n;
vector<lint> a;

bool isValid(lint m) {
    lint count = 0;
    for (int i = 0; i < n; i++) {
        lint b = max(0LL, a[i] + m - (n - 1));
        count += (b + n) / (n + 1);
    }
    return count <= m;
}

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    lint ok = LLONG_MAX / 2, no = -1;
    while (abs(ok - no) > 1) {
        lint mid = (ok + no) / 2;
        (isValid(mid) ? ok : no) = mid;
    }
    for (lint i = max(0LL, ok - 1000000); i < ok + 1000000; i++) {
        if (isValid(i)) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    
    //input
    int n, i, j, k, v;
    cin >> n;
    int a[n];
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    
     for(k=0;k<n;k++){
            cout << a[k];
            if(k!=n-1){
                cout << " ";
            }
        }
        cout << endl;
    //equation
    for(i=1;i<n;i++){
        v = a[i];
        j = i-1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        
        for(k=0;k<n;k++){
            cout << a[k];
            if(k!=n-1){
                cout << " ";
            }
        }
        cout << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
 
using namespace std;
 
int main()
{
    long long n,k;
    long long i,j;
    long long ans;
    while (scanf("%lld%lld",&n,&k)!=EOF)
    {
        ans=0;
        for (i=1;i<=n-k;i++)
        {
            j=i+k;
            ans+=(n/j)*i;
            if(n%j-k>=0)
                ans+=n%j-k+1;
        }
        if (k==0)
            ans=n*n;
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 256
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	n=n%10;
	if(n==2 || n==4 || n==5 || n==7 || n==9)cout << "hon";
	if(n==0 || n==1 || n==6 || n==8)cout << "pon";
	if(n==3)cout << "bon";

	return 0;
}  


Measured memory_bytes: 3648
from _collections import deque


h,w=map(int,input().split())
cx,cy=map(int,input().split())
dx,dy=map(int,input().split())
s=[[] for _ in range(h+2)]
for i in range(h):
    x=list(input())
    x.insert(0,"#")
    x.append("#")
    s[i+1]=x
s[0]=s[-1]=["#"]*(w+2)




dep=[[10**10]*(w+2) for _ in range(h+2)]
dep[cx][cy]=0
data=deque([[cx,cy]])
while len(data)>0:
    xy=data.popleft()
    x,y=xy[0],xy[1]

    if s[x-1][y]=="." and dep[x-1][y]>dep[x][y]:
        dep[x-1][y]=dep[x][y]
        data.appendleft([x-1,y])
    if s[x+1][y] == "." and dep[x+1][y] > dep[x][y]:
        dep[x+1][y] = dep[x][y]
        data.appendleft([x + 1,y])
    if s[x][y-1] == "." and dep[x][y-1] > dep[x][y]:
        dep[x][y-1] = dep[x][y]
        data.appendleft([x,y-1])
    if s[x][y+1] == "." and dep[x][y+1] > dep[x][y]:
        dep[x][y+1] = dep[x][y]
        data.appendleft([x,y+1])

    for i in range(5):
        for j in range(5):
            if 0<=x-2+i<=h+1 and 0<=y-2+j<=w+1 and s[x-2+i][y-2+j]=="." and dep[x-2+i][y-2+j]>dep[x][y]+1:
                dep[x-2+i][y-2+j]=dep[x][y]+1
                data.append([x-2+i,y-2+j])

print(dep[dx][dy] if dep[dx][dy]<10**10 else -1)





Measured memory_bytes: 142228
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n, k; cin >> n >> k; std::vector<i64> vec, a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n - 1; i++) vec.push_back(a[i + 1] - (a[i] + 1));
	sort(begin(vec), end(vec)); reverse(begin(vec), end(vec));
	
	cout << (a.back() - a[0] + 1) - std::accumulate(begin(vec), begin(vec) + k - 1, 0LL) << endl;
	return 0;
}



Measured memory_bytes: 4684
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,l = LI()
    a = [l+i for i in range(n)]
    s = sum(a)

    if 0 in a:
        return s

    if a[0] < 0:
        return s - a[-1]

    return s - a[0]


print(main())



Measured memory_bytes: 5720
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int n;
    cin>>n;
    vi as(n);
    cin>>as;

    int m = 0;
    int ans = 0;
    rep(i, n) {
        if (as[i] > m) m = as[i];
        ans += as[i];
    }
    cout<<ans - m / 2<<endl;
}

Measured memory_bytes: 256
N, K = input().split()
P = [input().split() for i in range(2 * int(K))]
result = []
counter = 0
m = 0
for p in P:
    if m % 2 ==0:
        pass
    else:
        for i in p:
            result.append(int(i))
    m +=1

result =set(result)

for n in range(int(N)+1):
    if n ==0:
        pass
    elif n in result:
        pass
    else:
        counter +=1
print(str(counter))


Measured memory_bytes: 9524
/*********************************************************************************
*   Falling down is an accident, Staying down is a choice.                       *
**********************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define ll long long int
#define pb push_back
#define fi first
#define se second
const ll inf = 1e9+7; 
const ll modc = 998244353;
void solve();int main(){FastIO;solve();return 0;}
/*********************************************************************************/
void solve()
{
    int x,n;cin>>x>>n;
    set<int> s;
    for(int i=0;i<n;i++)
    {
        int temp;cin>>temp;
        s.insert(temp);
    }

    int ans;
    int mindiff = inf;
    for(int i=-150;i<=150;i++)
    {
        if(s.find(i)==s.end())
        {
            if(abs(i-x) < mindiff)
            {
                mindiff = abs(i-x);
                ans = i;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
using System;
using System.Linq;
class P{
  static void Main(){
    int n=int.Parse(Console.ReadLine());
    var s=Console.ReadLine().Split().Select(long.Parse).ToArray();
    long x=s.First(),y=s.Sum()-x,c=Math.Abs(x-y);
    for(int i=1;i<n-1;i++){
      c=Math.Min(Math.Abs((x+=s[i])-(y-=s[i])),c);
      if(c==0)break;
    }
    Console.WriteLine(c);
  }
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, y;
  int b[55], t[55];
  double r[55];
  double cnt[55];
  int maxi;

  cin >> n;
  while(n != 0){
    cin >> y;

    maxi = 0;
    for(int i = 0;i < n;i++){
      cin >> b[i] >> r[i] >> t[i];
    }

    for(int i = 0;i < n;i++){
      if(t[i] == 1){
	cnt[i] = 1.0 + y * (r[i] / 100.0);
      }else{
	cnt[i] = pow(1.0 + (r[i] / 100.0), y);
      }
    }
    
    for(int i = 1;i < n;i++){
      if(cnt[maxi] < cnt[i]){
	maxi = i;
      }
    }
    cout << b[maxi] << endl;
    cin >> n;
  }
	  	   
  return 0;
}




Measured memory_bytes: 3276
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int n;
cin >> n;
map<int, ll> f;
for(int x = 1; x <= 100; ++x) {
    for(int y = 1; y <= 100; ++y){
        for(int z = 1; z <= 100; ++z){
            int d = x*x + y*y + z*z + x*y + y*z + z*x;
            f[d]++;
        }
    }
}
for(int i = 1; i <= n; ++i) {
    cout << f[i] << endl;
}
return 0;
}

Measured memory_bytes: 5988
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N, K = map(int, readline().split())
    R, S, P = map(int, readline().split())
    T = readline().rstrip().decode()
    ans = 0

    def getPoint(letter):
        if letter == 'r':
            return P
        if letter == 's':
            return R
        if letter == 'p':
            return S

    for i in range(K):
        seq = T[i::K] + 'o'
        
        cnt = 0
        nowLetter = seq[0] 
        for j in seq:
            if j != nowLetter:
                #精算をする
                ans += ((cnt+1)//2)*getPoint(nowLetter)
                cnt = 0
            cnt += 1
            nowLetter = j
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 43632
#include<stdio.h>

int main(void){
    int N, M;
    scanf("%d %d",&N, &M);
    double A[N], number = 0,Sum = 0;
    for(int i = 0; i < N; i++){
        scanf("%lf",&A[i]);
        Sum += A[i];
    }
    for(int j= 0; j < N; j++){
        if(A[j] >= Sum /(4*M)){
            number++;
        }
    }
    if(number >= M){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

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

int main(void)
{
	int i, l;
	char str[21];
	
	scanf("%s", str);
	l=strlen(str);
	for(i=0; i<l; i++)
		printf("%c", str[l-i-1]);
	putchar('\n');
	
	return 0;
}


Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(long long i = 0; i < (long long)(n); i++)
#define ALL(x) (x).begin(),(x).end()

void solve(long long N, long long M, std::vector<long long> A){
  cout << max(-1ll, (N - accumulate(ALL(A), 0ll))) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> A(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <array>
#include <vector>
#include <map>
#include <utility>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <string>
#include <limits.h>
#include <algorithm>

using namespace std;


int main(){
    
    
    vector<int> a;
    
    int c;
    
    cin >> c;
    
    for (int i =0 ; i < c*3; i++) {
        int cc;
        cin >> cc;
        a.push_back(cc);
    }
    
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    long long  sum = 0;
    for (int i = 0; i < c ; i++) {
        sum += a[2*i+1];
    }
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 2420
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>


using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
//using mint = modint998244353;
//using mint = modint1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  
  ll ans=0;
  rep(i,N){
    for(int j=i+1;j<N;j++){
      chmax(ans,abs(A[i]-A[j]));
    }
  }
  
  cout<<ans<<'\n';
  
  return 0;
}


Measured memory_bytes: 3596
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn comb(x: i64, y: i64) -> i64 {
    let mut sum = 1;
    for i in 0 .. y {
        sum *= x - i;
        sum /= i + 1;
    }
    sum
}

fn calc(v: &[i64], sum: i64, den: i64, len: usize) -> i64 {
    assert!(len >= 1);
    let mut tsum = 0;
    for i in 0 .. len {
        tsum += v[i];
    }
    if tsum * den != sum * (len as i64) { return 0; }
    let n = v.len();
    let mut cnt = 0;
    let mut picked = 0;
    for i in 0 .. n {
        if v[i] == v[len - 1] {
            cnt += 1;
            if i < len {
                picked += 1;
            }
        }
    }
    comb(cnt, picked)
}

fn solve() {
    let n = get();
    let a = get();
    let b: usize = get();
    let mut v: Vec<i64> = (0 .. n).map(|_| get()).collect();
    v.sort();
    v.reverse();
    let mut sum = 0;
    for i in 0 .. a {
        sum += v[i];
    }
    println!("{}", sum as f64 / a as f64);
    // select #ways to pick goods of the minimum value
    let mut tot: i64 = 0;
    for i in a .. b + 1 {
        tot += calc(&v, sum, a as i64, i);
    }
    println!("{}", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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


using namespace std;
int main(){

 long long n,x;
 map<long long,long long>mp;

 cin>>n;

 for(long long  i=0;i<n;i++){
        cin>>x;
    mp[x]++;
 }

 int j=0,ans=0;
 for(map<long long,long long >::iterator it = mp.begin();it!= mp.end();it++)
 {
    if(it->first != it->second &&  it->second > it->first)
        ans += abs(it->second - it->first);
    else if(it->second < it->first)
        ans += it->second;
 }

 cout<<ans<<endl;

return 0;
}



Measured memory_bytes: 6272
// inputに入力データ全体が入る
function Main(input) {
  	
  	const reverse = (s) => {
      return s.split("").reverse().join("");
    };
  	
  	var WORDS = ["dream", "dreamer", "erase", "eraser"].map(reverse);
  	var S = reverse(input.split("\n")[0]);
  	var S_org = reverse(input.split("\n")[0]);
  	var word = "";
  	var T = ""; // 結果
  	var length = 0;
  	
  	// 一文字ずつ追加していきWORDSに一致するものがあるかどうか判定する
    // 見つかったらカウンタをリセットする、文字列も削る
  while(S.length>5){
      	word += S[length];
    	/*
    	console.log("length!!!!"+length);
        console.log("word!!!!!"+word);
        */
    
    	var result = -1;
    	var idx = 0;
    	// 文字が含まれるか検索
    	for(var i=0; i<WORDS.length; i++){
          // 一致する文字があるかどうか確かめる
          idx = word.indexOf(WORDS[i]);
          // 無かったら次へ
          if(idx == -1){
          	continue; 
          }
          //console.log(word.slice(idx)+" vs "+WORDS[i]);
          // 余分な文字を削除し完全一致するか判定
          if(word.slice(idx) === WORDS[i]){
		  	result = i;
            /*
            console.log("idx!!!"+idx);
            console.log("slice!!!"+word.slice(idx));
            console.log(word.length-idx+" vs "+WORDS[i].length);
            console.log(word);
            console.log("result!!!!!"+WORDS[result]);
            */
          }
        }
      	//var result = WORDS.indexOf(word); // 一致するものがあるか検索
      	// 一致したものがあるとき
      	if(result != -1){
        	T += WORDS[result];  // 前に文字列を追加
          	S = S.slice(length);// 追加した文字までを削除する
          	//console.log("T:"+T+" vs "+S+":S");
          	word = ""   // 文字のリセット
          	length = 0; // カウントのリセット
        }
      	length += 1;
	}
  
  	// SとTが一致するとき
  	if(S_org == T){
      console.log("YES");
    // しないとき
    }else{
      console.log("NO");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22332
#include<cstdio>
#define ture 1
#define false 0
using namespace std;

int s[10],l[10],r[10];

bool slove(int i,int j,int k){

for(int i=1;i<10;i++)
{
    if(s[i]<l[j]&&s[i]<r[k]){
        return false;
    }
    if(s[i]>l[j]&&s[i]<r[k]){
        l[j+1]=s[i];
        j++;
    }
    if(s[i]<l[j]&&s[i]>r[k]){
        r[k+1]=s[i];
        k++;
    }
    else{
    if(s[i]-1==l[j]){
        l[j+1]=s[i];
        j++;
    }
    else if(s[i]-1==r[k+1]){
        r[k+1]=s[i];
        k++;
    }
    else if((s[i]-l[j])<(s[i]-r[k])){
        l[j+1]=s[i];
        j++;
    }
    else {
        r[k+1]=s[i];
        k++;
    }
    }
}
return true;
}







    /*
        if(k==10)
        return ture;
        if(l[i]>s[k]&&r[j]>s[k])
        return false;
        l[i+1]=s[k];
        r[j+1]=s[k];
        if(slove(i,j+1,k+1)&&r[j]<s[k])
            {
                l[i+1]=0;
                return ture;
            }
            else if(slove(i+1,j,k+1)&&l[i]<s[k])
            {
                r[j+1]=0;
                return ture;
            }
            else
                return false;*/


int main()
{
    int N;
    scanf("%d",&N);
    while(N--)
    {
        for(int i=0;i<10;i++)
            {
                scanf("%d",&s[i]);
                l[i]=0;
                r[i]=0;
            }
            l[0]=s[0];
        if(slove(0,0,1))
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}



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

char f[1000][1000];
int d[1000][1000];

int main() {
    int H, W, K;
    cin >> H >> W >> K;

    int sx,sy;
    rep(i, H) rep(j, W) {
        cin >> f[i][j];
        d[i][j] = 1e8;
        if (f[i][j] == 'S') sy=i, sx=j;
    }

    d[sy][sx] = 0;
    queue< pair<int, int> > que;
    que.push({ sy, sx });

    const int dx[] = { 1, 0, -1, 0 };
    const int dy[] = { 0, 1, 0, -1 };
    while (que.size()) {
        pair<int, int> p = que.front();
        que.pop();

        if (d[p.first][p.second] >= K) {
            continue;
        }

        rep(dd, 4) {
            int py = p.first + dy[dd];
            int px = p.second + dx[dd];
            if (0 <= py && py < H && 0 <= px && px < W && f[py][px] == '.' && d[py][px] == 1e8) {
                d[py][px] = d[p.first][p.second] + 1;
                que.push({ py, px });
            }
        }
    }

    int ans=1e8;
    rep(y, H) rep(x, W) {
        if (d[y][x] != 1e8) {
            int Y = min(y, H-y-1);
            int X = min(x, W-x-1);
            ans = min(ans, min(Y/K+bool(Y%K), X/K+bool(X%K)));
        }
    }

    cout << ans+1 << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;


int main(void) {

  int n;
  cin >> n;
  string s;
  cin >> s;
  int a = 0;
  int cnt = 0;
  for(int i=0; i<n; i++){
    if( s[i] == '(' ) a--;
    else a++;
    cnt = max(a, cnt);
  }
  s = string(cnt, '(') + s;
  // cerr << cnt << endl;
  // cerr << s << endl;

  a = 0;
  cnt = 0;
  for(int i=0; i<s.size(); i++){
    if( s[i] == '(' ) a++;
    else a--;
    // cnt = max(a, cnt);
  }
  // cerr << a << endl;
  s += string(a, ')');
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
int x[3], y[3];
double len(int i, int j){
  return sqrt(double(x[i]-x[j])*(x[i]-x[j])+double(y[i]-y[j])*(y[i]-y[j]));
}

int main(int argc, char const* argv[])
{
  rep(i, 3){
    cin >> x[i] >> y[i];
  }
  double l = len(0, 1) + len(1, 2) + len(2, 0);
  double s = abs(double(x[1]-x[0])*(y[2]-y[0]) - double(x[2]-x[0])*(y[1]-y[0]));
  double r = s / l;
  double k = max(len(0, 1), max(len(1, 2), len(2, 0)));
  cout << setprecision(12);
  cout << k / (2. + k / r) << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
	class Program4
	{
		static void Main(string[] args)
		{
			var nk = Console.ReadLine().Split(' ');
			var s = Console.ReadLine();

			List<KeyValuePair<int, int>> numlist = new List<KeyValuePair<int, int>>();

			int k = int.Parse(nk[1]);
			int addk = 0;
			int max = 0;
			int ans = 0;
			int num = 0;
			for (int i = 0; i < s.Length; i++)
			{
				num++;
				bool b = true;
				if (s[i].Equals('1'))
				{
					b = true;
				}
				else
				{
					b = false;
				}

				if (i + 1 < s.Length && s[i].Equals(s[i + 1]))
				{
					continue;
				}

				// これは1が続いた
				if (b)
				{
					numlist.Add(new KeyValuePair<int, int>(1, num));
					ans += num;
					if (ans > max)
					{
						max = ans;
					}
				}
				// ここは0が続いた
				else
				{
					// 0が続いた場合はkを使って裏返す
					if (addk < k)
					{
						addk++;
						numlist.Add(new KeyValuePair<int, int>(0, num));
						ans += num;
						if (ans > max)
						{
							max = ans;
						}
					}
					else
					{
						numlist.Add(new KeyValuePair<int, int>(0, num));
						ans += num;

						// 既にk回裏返している場合はnumlistから0を削除する必要がある
						if (numlist[0].Key == 0)
						{
							ans -= numlist[0].Value;
							numlist.RemoveAt(0);
						}
						else
						{
							ans -= numlist[0].Value;
							ans -= numlist[1].Value;
							numlist.RemoveAt(0);
							numlist.RemoveAt(0);
						}

						if (ans > max)
						{
							max = ans;
						}
					}
				}

				num = 0;
			}

			Console.Write(max.ToString() + "\n");
			//Console.ReadLine();
		}
	}
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L.at(i);
  sort(L.rbegin(), L.rend());
  cout << accumulate(L.begin(), L.begin() + K, 0L) << "\n";
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll=long long;using ull=unsigned ll;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
#define d(n) cerr<<#n":"<<n<<endl;
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
#define cut(n, Min, Max) max(min(n,Max),Min)
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

bool narande(ll a, ll b, ll c){
    return (a<b && b<c)||(a>b && b>c);
}

ll get_cost(ll x, ll a, ll b){
    if(narande(a,x,b)){
        return abs(x-a)+abs(x-b)+min(abs(x-a),abs(x-b));
    }
    return max(abs(x-a),abs(x-b));
}

int main(){
    /*
    ll x,a,b;
    cin>>x>>a>>b;
    cout<<get_cost(x,a,b)<<endl;
    return 0;
    /*/
    int a,b,q;
    cin>>a>>b>>q;
    vl s(a);
    vl t(b);
    cin>>s>>t;
    ll mi;
    ll ss[3],tt[3];
    REP(i,q){
        ll x;
        cin>>x;
        mi=LINF;
        auto si=lower_bound(all(s), x);
        auto ti=lower_bound(all(t), x);
        ll ssa,ssb,tta,ttb;
        ss[0]=(si!=s.begin())?*(si-1):LINF;
        ss[1]=(si!=s.end())?*si:LINF;
        ss[2]=(si+1!=s.end())?*(si+1):LINF;
        
        tt[0]=(ti!=t.begin())?*(ti-1):LINF;
        tt[1]=(ti!=t.end())?*ti:LINF;
        tt[2]=(ti+1!=t.end())?*(ti+1):LINF;
        d(ss[0]);d(ss[1]);d(ss[2]);d(tt[0]);d(tt[1]);d(tt[2]);
        REP(ssi,3){
            REP(tti,3){
                chmin(mi,get_cost(x, ss[ssi], tt[tti]));
            }
        }
        cout<<mi<<endl;
    }
    return 0;
    //*/
}


Measured memory_bytes: 2944
function main(arg){
	arg = arg.trim().split(' ');
  	var a = arg[0], b = arg[1], c = arg[2];
  	a = c-(a-b);
  	if(a<0) {
    	a = 0;
    }
  	console.log(a);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
Sa=input()
Sb=input()
Sc=input()

Sa_cnt=len(Sa)
Sb_cnt=len(Sb)
Sc_cnt=len(Sc)
A,B,C=0,0,0
turn='a'
ans=''
while(True):
    if turn=='a':
        if Sa_cnt==0:
            ans='A'
            break
        turn=Sa[A]
        A+=1
        Sa_cnt-=1
    elif turn=='b':
        if Sb_cnt==0:
            ans='B'
            break
        turn=Sb[B]
        B+=1
        Sb_cnt-=1
    else:
        if Sc_cnt==0:
            ans='C'
            break
        turn=Sc[C]
        C+=1
        Sc_cnt-=1

print(ans)
    

Measured memory_bytes: 8968
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{
    public static void main(String[] args) throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());
        int m = Integer.parseInt(tokenizer.nextToken());

        Pair[] studant = new Pair[n];
        Pair[] checkPoint = new Pair[m];

        for (int i = 0; i < n; i++) {
            tokenizer = new StringTokenizer(input.readLine());
            studant[i] = new Pair(Integer.parseInt(tokenizer.nextToken()), Integer.parseInt(tokenizer.nextToken()));
        }

        for (int i = 0; i < m; i++) {
            tokenizer = new StringTokenizer(input.readLine());
            checkPoint[i] = new Pair(Integer.parseInt(tokenizer.nextToken()), Integer.parseInt(tokenizer.nextToken()));
        }
        int x;
        Pair out;
        int index;
        StringBuilder output = new StringBuilder();
        for (int i = 0; i < n; i++) {
            x = Integer.MAX_VALUE;
            out = null;
            index = 0;
            for (int j = 0; j < m; j++) {
                int dis = studant[i].getDistance(checkPoint[j]);
                if (dis < x) {
                    x = dis;
                    out = checkPoint[j];
                    index = j + 1;
                } else if (dis == x && checkPoint[j].iAmSmaller(out)) {
                    x = dis;
                    out = checkPoint[j];
                    index = j + 1;
                }
            }
            output.append(index).append("\n");
        }
        System.out.print(output);
    }


    static class Pair {
        int x;
        int y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public boolean iAmSmaller(Pair p) {
            if (p == null)
                return true;

            if (this.x < p.x) {
                return true;
            } else if (this.x > p.x) {
                return false;
            } else if (this.y < p.y) {
                return true;
            } else {
                return false;
            }
        }

        public int getDistance(Pair p) {
            return Math.abs(p.x - this.x) + Math.abs(this.y - p.y);
        }

    }
}


Measured memory_bytes: 21332
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    int N;
    cin >> N;
    int x, y, z;
    x = y = z = 0;
    REP(i, 0, N) {
        int tmp;
        cin >> tmp;
        if (tmp % 2 == 0) {
            if (tmp % 4 == 0)x++;
            else z = 1;
        } else {
            y++;
        }
    }
    z += y;
    if (z <= x + 1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		var s = new SortedSet<int>();
		for (var i = 0; i < I[2]; i++)
		{
			var x = I[0] + i;
			if (x <= I[1]) s.Add(x);
			x = I[1] - i;
			if (x >= I[0]) s.Add(x);
		}
		foreach (var x in s) WriteLine(x);
	}
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
char s[110];
int n,pos,maxn;
int main()
{
    cin>>n>>s;
    for(int i=0;i<n;++i)
    {
        if(s[i]=='I')
		++pos;
        else
		--pos;
        maxn=max(maxn,pos);
    }
    cout<<maxn<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <list>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    char lastchar = 127;
    stack<char> sl;
    for (int i = 0; i < N; i++)
    {
        if (S[i] != lastchar)
        {
            lastchar = S[i];
            bool flag = false;
            int ss = sl.size();
            for (int j = 0; j < ss; j++)
            {
                char c = sl.top();
                if (c == lastchar)
                {
                    sl.pop();
                    flag = true;
                    continue;
                }
                break;
            }
            sl.push(S[i]);
        }
    }
    cout << sl.size() << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/



int main()
{
	int a, b;
	double S;
	
	cin >> a >> b;
	S = a * b / 3.305785;
	cout << fixed << setprecision(6);
	cout << S << endl;
	
	return 0;
}

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

int main() {
	int c1, c5, c10, c50, c100, c500, sum;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;

	sum += c1 * 1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500;

	if (sum >= 1000)
		cout << 1 << endl;
	else
		cout << 0 << endl;
}

Measured memory_bytes: 1160