akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll h,n;
    cin>>h>>n;
    vector<pair<ll,ll>>p(n);
    rep(0,i,n){
        cin>>p[i].first>>p[i].second;
    }
    ll dp[h+1];
    rep(0,i,h+1)dp[i]=(ll)1e9;
    dp[0]=0;
    rep(0,i,h){
        rep(0,j,n){
            ll a=p[j].first,b=p[j].second,x=min(i+a,(ll)h);
            dp[x]=min(dp[x],dp[i]+b);
        }
    }
    cout<<dp[h]<<endl;
}


Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        System.out.println(Math.max(c - (a-b), 0));
    }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	string c; cin >> c;
	vector<int> cnt(N);
	for(int i = 0; i < N; i++) {
		if(i == 0 && c[0] == 'R') cnt[0]++;
		else if(c[i] == 'R') cnt[i] = cnt[i - 1] + 1;
		else cnt[i] = cnt[i - 1];
	}
	int cnt1 = 0;
	for(int i = cnt[N - 1]; i < N; i++) if(c[i] == 'R') cnt1++;
	int cnt2 = cnt[N - 1];
	if(cnt[0] == 'R') cnt2--;
	int ans = min(cnt1, cnt2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4460
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  string board[305];
  for (int i = 0; i < n; i++) {
    cin >> board[i];
  }

  int count = 0;
  for (int i = 0; i < n; i++) {
    int a = 0;
    int b = i;
    char new_grid[305][305];
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
	new_grid[(j + a) % n][(k + b) % n] = board[j][k];
      }
    }

    bool ok = true;
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
	if (new_grid[j][k] != new_grid[k][j]) {
	  ok = false;
	  break;
	}
      }
      if (!ok) break;
    }
    if (ok) count++;
  }
  
  cout << count * n;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int x=0;
	string X;

	cin>>X;
	REP(i,(int)X.length()) x+=(X[i]-'0');
	if(stoi(X)%x==0) print("Yes");
	else print("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
        return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
        return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
    for (const T &x : s)
        out << x << ' ';
    return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl "\n"
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    ll n;
    cin>>n;
    vi a(n);
    cin>>a;
    vi ma(a);
    for(ll i=1;i<n;i++)
        ma[i]=max(ma[i],ma[i-1]);
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ans+=ma[i]-a[i];
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 6356
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

const i32 mod = 1000000007;

i32 comb (i32 n, i32 k) {
  if (!(0 <= k && k <= n)) return 0;
  i32 a = 1;
  i32 b = 1;
  for (i32 i = 1; i <= k; ++i) {
    a = (i64) a * (n + 1 - i) % mod;
    b = (i64) b * i % mod;
  }
  while (b > 1) {
    a = (i64) a * (mod - mod / b) % mod;
    b = mod % b;
  }
  return a;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 ans = comb (k, n);
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long A, B, M;
    cin >> A >> B >> M;
    vector<long long> a(A), b(B);
    REP(i, A) cin >> a[i];
    REP(i, B) cin >> b[i];
    long long ans = 1LL<<60;
    REP(i, M){
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans, a[x]+b[y]-c);
    }
    long long hoge = *min_element(a.begin(), a.end());
    long long fuga = *min_element(b.begin(), b.end());
    ans = min(ans, hoge+fuga);
    cout << ans << endl;
    return 0;
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K <= A) {
    cout << K << endl;
  } else if (K <= A + B) {
    cout << A << endl;
  } else {
    cout << A - (K - (A + B)) << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

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

    int n, k;
    cin >> n >> k;
    set<int> st;
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int s;
            cin >> s;
            st.insert(s);
        }
    }
    cout << n - st.size() << '\n';

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 3624
from sys import stdin
from collections import deque

n = int(stdin.readline().rstrip())
lst = deque()
for _ in range(n):
    q = stdin.readline().rstrip().split()
    if q[0] == "insert":
        lst.appendleft(int(q[1]))
    elif q[0] == "delete":
        try:
            lst.remove(int(q[1]))
        except:
            pass
    elif q[0] == "deleteFirst":
        lst.popleft()
    elif q[0] == "deleteLast":
        lst.pop()

print(*lst)


Measured memory_bytes: 45940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<29;

int par[MAX],size[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
    }
}

int root(int a){
    if(par[a]==a) return a;
    else return par[a]=root(par[a]);
}

void unite(int a,int b){
    if(root(a)!=root(b)){
        size[root(a)]+=size[root(b)];
        par[root(b)]=root(a);
    }
}

void shrink(int a,int b){
    if(root(a)!=root(b)){
        par[root(b)]=root(a);
    }
}

bool check(int a,int b){
    return root(a)==root(b);
}

struct edge{
    int from;
    int to;
    ll dis;
};

bool compare(edge a,edge b){
    return a.dis<b.dis;
}

int main(){
    
    int N,M,K;cin>>N>>M>>K;
    init(N+3);
    
    vector<int> color(N);
    vector<vector<int>> wh(K+1);
    vector<edge> G(M);
    for(int i=0;i<N;i++){
        cin>>color[i];
        wh[color[i]].push_back(i);
    }
    
    for(int i=1;i<=K;i++){
        for(int j=1;j<wh[i].size();j++){
            shrink(wh[i][0],wh[i][j]);
        }
    }
    
    ll ans=0;
    for(int i=0;i<M;i++){
        int a,b;ll c;cin>>a>>b>>c;
        a--;b--;
        G[i]={a,b,c};
    }
    
    sort(all(G),compare);
    
    int cnt=0;
    
    if(K==1){
        cout<<0<<endl;
        return 0;
    }
    
    for(int i=0;i<M;i++){
        int a=G[i].from,b=G[i].to;
        ll c=G[i].dis;
        
        if(check(a,b)) continue;
        
        unite(a,b);
        ans+=c;
        cnt++;
        
        if(cnt==K-1) break;
    }
    
    if(cnt==K-1) cout<<ans<<endl;
    else cout<<-1<<endl;
    
}




Measured memory_bytes: 8448
{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Array
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = do
  [n] <- readInts
  readInts >>= output . solve n

solve :: Int -> [Int] -> [Int]
solve n = elems . accumArray (+) 0 (1,n) . flip zip (repeat 1)

output :: _ -> IO ()
output = mapM_ print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

Measured memory_bytes: 9508
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int h, w;
	cin >> h >> w;
	int human[h][w];
	REP(i, h) REP(j, w) cin >> human[i][j];

	int min = INF;

	REP(i, h){
		REP(j, w){
			int sum = 0;
			REP(k, h){
				REP(l, w){
					if (abs(i-k) < abs(j-l)){
						sum += abs(i-k) * human[k][l];
					}
					else sum += abs(j-l) * human[k][l];
				}
			}
			if (min > sum) min = sum;
		}
	}

	cout << min << endl;

}



Measured memory_bytes: 3100
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 500000 + 9;
ll a,b,c,d,ans;
 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        cin>>a>>b>>c>>d;

        ans = -4e18;

        ans=max(ans,a*c);
        ans=max(ans,a*d);
        ans=max(ans,b*c);
        ans=max(ans,b*d);

        cout<<ans<<endl;



return 0;
}


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

int main() {
	string s;
    getline(cin,s);
    for(int i=0;i<s.size();i++){
        if(s[i]>='a'&&s[i]<='z'){
            s[i]+='A'-'a';
        }
    }
    cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1172
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
add = 0
for i in range(len(a)-1):
    if a[i] == a[i+1]-1:
        add += c[a[i]-1]
print(sum(b)+add)


Measured memory_bytes: 38384
import sys,itertools
input=sys.stdin.readline
INF=float('inf')
n,m,r=map(int,input().split())
R=list(map(int,input().split()))
distance=[[INF]*n for _ in range(n)]
for _ in range(m):
   a,b,c=map(int,input().split())
   distance[a-1][b-1]=c
   distance[b-1][a-1]=c

for i in range(n):
   for j in range(n):
       for k in range(n):
           distance[j][k]=min(distance[j][k],distance[j][i]+distance[i][k])

ans=INF
for p in itertools.permutations(R):
   cnt=0
   for q in range(r-1):
      cnt+=distance[p[q]-1][p[q+1]-1]
   ans=min(ans,cnt)

print(ans)

Measured memory_bytes: 68572
//😄😄😄😄😄😄😄😄😄😄😄😄😄
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define For(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"

int main() {
	int x, n; cin >> x >> n;
	vi v(n);
	For(i, 0, n) {cin >> v[i];}
	int diff = 0;
	while (1) {
		int a = x - diff;
		int b = x + diff;
		if (count(v.begin(), v.end(), a) < 1) {

			cout << a << endl;
			return 0;
		}
		else if (count(v.begin(), v.end(), b) < 1) {
			cout << b << endl;
			return 0;
		}
		diff++;
	}
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  ll ans = 0;
  ll n,k;cin>>n>>k;
  while(n > 0){
    n /= k;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=210000;
const int inf=0x3f3f3f3f;

int n,w,tot;
ll f[Maxn],v;

signed main() {
//	freopen("test.in","r",stdin);
	read(n,tot);
	for(int i=1;i<=n;i++) {
		read(w,v);
		for(int j=tot;j>=w;j--) f[j]=max(f[j],f[j-w]+v);
	}
	printf("%lld\n",f[tot]);
	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }eni(!=) cerr  << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
} sim dor(rge<c> d) { *this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
#define err(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll=long long;
using vi=vector<int>;



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

    int n , k;
    scanf("%d%d", &n, &k);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d", &x);
        cnt += (x >= k);
    }
    printf("%d\n", cnt);


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000009
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
using namespace std;
int main()
{
	
	ll a;
	long double b;
	cin>>a>>b;
	b*=a;
	ll ans=trunc(b);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
    	String s2 = sc.next();
    	int cnt1 = sc.nextInt();
    	int cnt2 = sc.nextInt();
    	String s3 = sc.next();
    	sc.close();
    	if(s.equals(s3)){
    		cnt1--;
    	}else{
    		cnt2--;
    	}
    	System.out.println(cnt1 + " " + cnt2);
    }
}

Measured memory_bytes: 23892
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let s: String = input();
    let s: Vec<char> = s.chars().collect();
    let mut count_east = vec![0; n];
    let mut count_west = vec![0; n];
    for i in 1..n {
        if s[i-1] == 'W' {
            count_west[i] = count_west[i - 1] + 1;
        } else {
            count_west[i] = count_west[i - 1];
        }
    }
    for i in (0..n-1).rev() {
        if s[i+1] == 'E' {
            count_east[i] = count_east[i + 1] + 1;
        } else {
            count_east[i] = count_east[i + 1];
        }
    }
    // println!("{:?}", count_east);
    // println!("{:?}", count_west);
    let mut ans = std::u64::MAX;
    for i in 0..n {
        ans = min(ans, count_west[i] + count_east[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 14588
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		ArrayList<P> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(new P(in.nextLong(), in.nextInt()));
		}
		Collections.sort(list);
		long ret = 0;
		for (P p : list) {
			if (m > p.b) {
				m -= p.b;
				ret += p.a * p.b;
			} else {
				ret += p.a * m;
				break;
			}
		}
		System.out.println(ret);
	}

	static class P implements Comparable<P> {
		long a;
		int b;

		P(long a , int b) {
			this.a = a;
			this.b = b;
		}

		@Override
		public int compareTo(P o) {
			long d = this.a - o.a;
			if (d > 0) {
				return 1;
			} else if (d == 0) {
				return 0;
			}  else {
				return -1;
			}
		}
	}
}


Measured memory_bytes: 65136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    const double pi = acos(-1);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double now = h * 60 + m;

    double angleA = fmod(now / (12.0 * 60), 1.0);
    angleA *= pi * 2.;
    double angleB = fmod(m / 60, 1.0);
    angleB *= pi * 2.;
    double ax = a * cos(angleA), ay = a * sin(angleA);
    double bx = b * cos(angleB), by = b * sin(angleB);
    double dx = (bx - ax), dy = (by - ay);
    dx *= dx;
    dy *= dy;

    double dist = sqrt(dx + dy);

    cout << fixed << setprecision(15) << dist << endl;

    return 0;
}

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

using namespace std;
typedef double scalar;
class point{
	public:
	scalar x;
	scalar y;
	void print(){
		cout << x << " " << y; 
	}
	scalar norm2(void){
		return x * x + y * y;
	}
	scalar norm(void){
		return sqrt(norm2());
	}
	point operator =(point a){
		this->x = a.x;
		this->y = a.y;
		return *this;
	}
	point operator +(point a){
		point r;
		r.x = this->x + a.x;
		r.y = this->y + a.y;
		return r;
	}
	point operator -(point a){
		point r;
		r.x = this->x - a.x;
		r.y = this->y - a.y;
		return r;
	}
};

point operator *(scalar t, point a){
	point r;
	r.x = t * a.x; 
	r.y = t * a.y; 
	return r;
}

void projection(point p, point q, point r, point &x){
	point qp = q - p;
	point pr = p - r;
	scalar k = (qp.x * pr.x + qp.y * pr.y)/qp.norm2();
	x = p - (k * qp);
	
}

int main(){
	point p1, p2, p, x;
	int q;
	cout.precision(20);
	cin >> p1.x >> p1.y >> p2.x >> p2.y;
	cin >> q;
	for(int i = 0;i < q;i++){
		cin >> p.x >> p.y;
		projection(p1, p2, p, x);
		x.print();
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1296
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cmath>
using namespace std;
#define lgx cerr<<"------------"<< endl;
#define debug(x) cerr<< #x << "=" << x << endl;

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << s1[0] << s2[1] << s3[2] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <limits>
#include <type_traits>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main()
{
	int N, K;
	string s;

	cin >> N >> s >> K;

	char c = s[K - 1];

	for (size_t i = 0; i < s.length(); i++)
	{
		if (s[i] != c)
		{
			cout << '*';
		}
		else
		{
			cout << c;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef vector<int> poly;
#define pb push_back
const int rlen=1<<18|1,inf=0x3f3f3f3f;
const ll Inf=1e18;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline ll readl() {
  ll ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline int Read(char*s) {
  int tp=0;
  char ch=gc();
  while(!isdigit(ch)&&!isalpha(ch)) ch=gc();
  while(isdigit(ch)||isalpha(ch)) s[++tp]=ch,ch=gc();
  return tp;
}
namespace modular {
  const int mod=998244353;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
  inline int sqr(int a) { return mul(a,a); }
  inline int cub(int a) { return (ll)a*a%mod*a%mod; }
}
using namespace modular;
template<typename T> inline void ckmax(T&a,T b) { a<b?a=b:0; }
template<typename T> inline void ckmin(T&a,T b) { a>b?a=b:0; }
template<typename T> inline T gcd(T a,T b) { T t;while(b)t=a,a=b,b=t-t/a*a;return a; }
template<typename T> inline T Abs(T x) { return x<0?-x:x; }
const int N=405;
int n,m,f[N][N];
char s[N][N];
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  scanf("%d%d",&n,&m);
  for(ri i=1;i<=n;++i) scanf("%s",s[i]+1);
  memset(f,0x3f,sizeof(f));
  f[1][1]=s[1][1]=='#';
  for(ri i=1;i<=n;++i) for(ri j=1;j<=m;++j) if(i+j!=2) {
    if(s[i][j]=='#') f[i][j]=1+min(f[i-1][j]-(s[i-1][j]=='#'),f[i][j-1]-(s[i][j-1]=='#'));
    else f[i][j]=min(f[i-1][j],f[i][j-1]);
  }
  cout<<f[n][m];
  return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int A = sc.nextInt();
		final int C = 500;
		sc.close();
		
		int n = N%C; // 0 <= n <= 499
		if(A >= n) System.out.println("Yes");
		else System.out.println("No");
	}

}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
 
const int N = 3e2+7;
const long long INF = 1e18;
 
int n, k;
int h[N];
long long res = INF;
long long dp[N][N];
 
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> h[i];
 
    for (int i = 0; i <= n+1; ++i)
        for (int j = 0; j <= n+1; ++j)
            dp[i][j] = INF;
    dp[0][0] = 0;
 
    for (int i = 1; i <= n+1; ++i) {
        for (int j = 0; j < i && j <= k; ++j) {
            for (int k = 0; k <= j && i-k-1 >= 0; ++k) {
                dp[i][j] = min(dp[i][j], dp[i-k-1][j-k]+max(0, h[i]-h[i-k-1]));
            }
            if (i == n+1) res = min(res, dp[i][j]);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>

//入力
#define in(N) cin >> N
#define in2(N,M) in(N) >> M
#define in3(N,M,K) in2(N,M) >> K
#define in4(N,M,K,L) in3(N,M,K) >> L
//出力
#define out(ans) cout << (ans) << endl
#define out2(a,b) cout << (a) << " " << (b) << endl
#define out3(a,b,c) cout << (a) << " " << (b) << " " << (c) << endl
#define outf(ans) cout << fixed << setprecision(6) << (ans) << endl

#define rep(i,n) for(int i=0; i<n; i++) //n回ループ
#define all(v) v.begin(), v.end() //vectorの全体を指定
#define sort_g(A,T) sort(all(A),greater<T>()) //降順ソート

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vstr;
const ll mod=1e9+7;

int main(){
	ll N,K;
	in2(N,K);

	ll a= N % K;
	ll b= abs(a-K);

	out(min(a,b));

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ a, b, h, m ] :: [Double] <- map fromIntegral <$> readInts
	let
		theta1 = ( h / 12 + m / 60 / 12 ) * 2 * pi
		theta2 =  m / 60 * 2 * pi
		theta = theta1 - theta2
	printf "%.12f\n" $ sqrt ( a ^ 2 + b ^ 2 - 2 * a * b * cos theta )

Measured memory_bytes: 4520
import fractions
from functools import reduce

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
a = list(map(int,input().split()))
lcm = lcm_list(a)
d = [0]*n

for i in range(n):
    d[i] = lcm//a[i]

print(lcm/sum(d))

Measured memory_bytes: 5048
#include <iostream>
#include <cstdio>
#include <algorithm>

int main() {
  int i;
  int height[10];
  for(i = 0; i < 10; i++) {
    scanf("%d", height+i);
  }
  std::sort(height, height+10);

  printf("%d\n%d\n%d\n", height[9], height[8], height[7]);

  return 0;
}

Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, mn = 1000;
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 2; i++)
	{
		a = abs(((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0')) - 753);
		mn = min(mn, a);
	}
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    int N, shifted;
    int mod = 1e9+7;
    ll dp[105][69];
    cin>>N;
    MEMSET(dp, 0);
    rep(i, N){
    	/*rep(i, N){
    		rep(j, 64) cout << dp[i][j] <<" ";
    		cout << endl;
    	}
    	cout << endl;*/


    	if(i<2) continue;
    	if(i==2){
    		rep(j, 64){
    			//cout <<i <<" " << j << endl;
    			if(j == 11 || j==14 || j==35) continue;
    			else dp[i][j] = 1/*, cout<<"added at " <<i <<" : " << j << endl*/;
    		}

    		/*rep(i, N){
    			rep(j, 64) cout << dp[i][j] <<" ";
    			cout << endl;
    		}
    		cout << endl;*/

    		continue;
    	}
    	rep(j, 64){
    		shifted = (j*4)%64;
    		rep(k, 4){
    			if(shifted == 11 || shifted==14 || shifted==35){ 
    				shifted++;
    				continue;
    			}
    			if((j==6 || j==9 || j==10) && k==3) continue;
    			//cout << i << " : " << j << " Passed"<<endl;
    			dp[i][shifted] = (dp[i-1][j]+dp[i][shifted])%mod;
    			shifted++;
    		}
    	}
    }
    /*rep(i, N){
    		rep(j, 64) cout << dp[i][j] <<" ";
    		cout << endl;
    	}
    	cout << endl;*/

    ll count = 0;
    rep(j, 64){
    	count = (count+dp[N-1][j])%mod;
    }
    cout << count <<endl;
    return 0;
}

Measured memory_bytes: 384
n, m =  map(int, input().split())
e = [int(input()) for i in range(m)]
used = [False]*n
e.reverse()
ans = []
for x in e:
    if not used[x-1]:
        ans.append(x)
        used[x-1] = True
for i in range(n):
    if not used[i]:
        ans.append(i+1)
for x in ans:
    print(x)


Measured memory_bytes: 19336
x=[]
while True:
    n=int(input())
    if n==0:
        break
    else:
        for i in range(n):
            s=int(input())
            x.append(s)
        S1=sum(x)-max(x)-min(x)
        S2=n-2
        print(int(S1/S2))
        x.clear()


Measured memory_bytes: 5596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n; cin >> n;
  string s; cin >> s;
  int k; cin >> k;

  string ans = "";
  for (int i = 0; i < n; i++) {
    if (s[i] == s[k - 1]) ans += s[i];
    else ans += '*';
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
#define rrep(i, beg, end) for (int i = (beg); i >= (end); i--)
#define sp(i) setprecision(i) << fixed
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 30;
ull p_hash(ull x, ull y) { return (x + y) * (x + y + 1) / 2 + y; } //NxN->N
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int f[1000][2000];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int s;
    cin >> s;

    f[1][1] = f[1][2] = 0;
    f[1][3] = 1;
    for (int i = 1; i <= s / 3; i++)
        for (int j = 3; j <= s; j++)
        {
            if (i == 1 && j >= 3)
                f[i][j] = 1;
            if (j - 3 >= 3 && i > 1)
                f[i][j] = (f[i][j] + f[i - 1][j - 3] + f[i][j - 1]) % mod;
        }

    int ans = 0;
    for (int i = 1; i <= s / 3; i++)
        ans = (ans + f[i][s]) % mod;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8784
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int x,i;
	cin>>x;
	i=x;
	for(int Miyamae=1;Miyamae<3;Miyamae++){
		x=x*i;
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 1160
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
        k: usize,
    };
    let mut t = vec![];
    let mut c = k;
    for &s_i in s.iter() {
        let d = s_i as usize - 'a' as usize; // 'a': 0, 'b': 1, 'c': 2, 'z': 25
        if d == 0 {
            t.push(s_i);
        } else {
            t.push(if 26 <= c + d {
                c -= 26 - d;
                'a'
            } else {
                s_i
            });
        }
    }
    if c > 0 {
        let n = t.len();
        let s_n = t[n - 1];
        let d = s_n as usize - 'a' as usize;
        t[n - 1] = (((d + c) % 26) as u8 + 'a' as u8) as char;
    }
    println!("{}", t.iter().collect::<String>());
}


Measured memory_bytes: 3020
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		Scanner scan = new Scanner(System.in);
		StringBuilder SA = new StringBuilder();
		StringBuilder SB = new StringBuilder();
		StringBuilder SC = new StringBuilder();
		
		String A = scan.next();
		String B = scan.next();
		String C = scan.next();
		
		
		SA.append(A);
		SB.append(B);
		SC.append(C);
		
		String turn = "A";
		int end = 0;
		String Winner= "o";
		
		
		do{
			switch(turn){
			case "A":
				
				if(SA.toString().equals("")){
					Winner = "A";
					end=1;
					
				}else
				if(SA.toString().substring(0, 1).equals("a")){//文字列一番目を切り取りそれがaか判別
					turn = "A";
					SA.delete(0, 1);
					
				}else if(SA.toString().substring(0, 1).equals("b")){
					turn = "B";

					SA.delete(0, 1);

				}else if(SA.toString().substring(0, 1).equals("c")){
					turn = "C";

					SA.delete(0, 1);

				}
				break;
				
			case "B":
				if(SB.toString().equals("")){
					Winner = "B";
					end=1;
					
				}else
				if(SB.toString().substring(0, 1).equals("a")){
					turn = "A";
					SB.delete(0, 1);
					
				}else if(SB.toString().substring(0, 1).equals("b")){
					turn = "B";

					SB.delete(0, 1);

				}else if(SB.toString().substring(0, 1).equals("c")){
					turn = "C";

					SB.delete(0, 1);

				}
				break;
			case "C":
				if(SC.toString().equals("")){
					Winner = "C";
					end=1;
					
				}else
				if(SC.toString().substring(0, 1).equals("a")){
					turn = "A";
					SC.delete(0, 1);
					
				}else if(SC.toString().substring(0, 1).equals("b")){
					turn = "B";

					SC.delete(0, 1);

				}else if(SC.toString().substring(0, 1).equals("c")){
					turn = "C";

					SC.delete(0, 1);

				}
				break;
			
			}
			
			
			
			
		}while(end==0);
		
		
		
		
		
		System.out.println(Winner);
		
		
		
		
		
		
	}

}

Measured memory_bytes: 23508
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
from itertools import accumulate
from bisect import bisect_right
cum = list(accumulate(As))

ans = 10**18
for i in range(1, N-2):
    c = cum[i]
    l_target = c/2
    r_target = (cum[-1]+c)/2
    l_idx = bisect_right(cum, l_target)
    r_idx = bisect_right(cum, r_target)
    if abs(l_target-cum[l_idx])<=abs(l_target-cum[l_idx-1]):
        first = cum[l_idx]
    else:
        first = cum[l_idx-1]
    second = c-first
    if abs(r_target-cum[r_idx])<=abs(r_target-cum[r_idx-1]):
        third = cum[r_idx]-c
        forth = cum[-1]-cum[r_idx]
    else:
        third = cum[r_idx-1]-c
        forth = cum[-1]-cum[r_idx-1]
    lis = [first, second, third, forth]
    ans = min(ans, max(lis)-min(lis))
print(ans)

Measured memory_bytes: 95420
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  bool prime[1000005];
  for(int i=0;i<1000005;++i) prime[i] = true;
  prime[0] = false;
  prime[1] = false;
  vector<ll> primearr;
  for(int i=2;i<1000005;++i) {
    if(prime[i]) {primearr.push_back(i);
      for(int j=2;i*j<1000005;++j) {
        prime[i*j] = false;
      }
    }
  }
  int N;
  cin>>N;
  ll A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  map<int, int> amap;
  vector<ll> arr1;
  bool pairwise = true;
  ll tmp;
  for(int i=0;i<N;++i) {
    tmp = A[i];
    for(ll j=0;primearr[j]*primearr[j]<=tmp;++j) {
      if(tmp%primearr[j]==0) {
        if(amap[primearr[j]]>0) pairwise = false;
        if(i==0) arr1.push_back(primearr[j]);
        amap[primearr[j]]++;
      }
      while(tmp%primearr[j]==0) tmp /= primearr[j];
    }
    if(tmp>1) {
      if(amap[tmp]>0) pairwise = false;
      if(i==0) arr1.push_back(tmp);
      amap[tmp]++;
    }
  }
  if(pairwise) {
    cout<<"pairwise coprime"<<endl;
    return 0;
  }
  for(int i=1;i<N;++i) {
    vector<ll> arr2;
    for(int j=0;j<arr1.size();++j) {
      if(A[i]%arr1[j]==0) {
        arr2.push_back(arr1[j]);
      }
    }
    arr1 = arr2;
  }
  if(arr1.size()!=0) cout<<"not coprime"<<endl;
  else cout<<"setwise coprime"<<endl;
}


Measured memory_bytes: 16192
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S = sc.next();

        System.out.println(solve(S));
    }

    private static long solve(String S) {
        long sum = 0;

        long top = 0;
        for (int i=0; i<S.length();) {
            char ch = S.charAt(i);
            long count = 1;

            for (int j=i+1; j<S.length(); j++) {
                if (S.charAt(i) == S.charAt(j)) count++;
                else break;
            }

            if (ch == '<') {
                sum += (count+1) * (0 + count) / 2;
                top = count;
                // System.err.println("<: sum += " + (count * (count+1) / 2));
            } else {
                sum += (count+1) * (0 + count) / 2;
                if (top < count) {
                    sum -= top;
                } else {
                    sum -= count;
                }
                // System.err.println(">: sum += " + (count * (count+1) / 2) + " - " + Math.min(top, count));
            }

            i += count;
        }

        return sum;
    }
}

Measured memory_bytes: 28512
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	int sum = 0;
	if (a < b)
		sum = b--;
	else
		sum = a--;
	if (a < b)
		sum += b--;
	else
		sum += a--;
	printf("%d", sum);

	return 0;
}

Measured memory_bytes: 640
map_list = [list(map(int,input().split())) for x in range(3)]
 
n = int(input())
for i in range(n):
  a = int(input())
  for i in range(3):
    for j in range(3):
      if map_list[i][j] == a:
        map_list[i][j] = 0

ans = "No"
for k in range(3):
  if map_list[0][k] == map_list[1][k] == map_list[2][k] or \
     map_list[k][0] == map_list[k][1] == map_list[k][2]:
      ans = "Yes"
      break
  if map_list[0][0] == map_list[1][1] == map_list[2][2] or \
	 map_list[0][2] == map_list[1][1] == map_list[2][0]:
      ans = "Yes"
print(ans)

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    string S;
    int MARCH[5] = {0};

    for (int i = 0; i < N; i++) {
        cin >> S;
        switch(S[0]) {
            case 'M':
                MARCH[0]++;
                break;
            case 'A':
                MARCH[1]++;
                break;
            case 'R':
                MARCH[2]++;
                break;
            case 'C':
                MARCH[3]++;
                break;
            case 'H':
                MARCH[4]++;
                break;
        }
    }

    long count = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                // cout << i << j << k << endl;
                count += (long)MARCH[i] * MARCH[j] * MARCH[k];
            }
        }
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
d, n = (int(i) for i in input().split())
if d == 0:
    if n != 100:
        print(n)
    else:
        print(n+1)
elif d == 1:
    if n != 100:
        print(100*n)
    else:
        print(100*(n+1))
elif d == 2:
    if n != 100:
        print(10000*n)
    else:
        print(10000*(n+1))

Measured memory_bytes: 38384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//u.p が存在しないとき、その接点はroot
//u.l が存在しないとき、その接点はleaf
//u.r が存在しないとき、その接点は最も右の子
type Node struct {
	p int
	l int //左の子
	r int //右の兄弟
}

// func getDepth(T []Node, i int) int {
// 	d := 0
// 	for T[i].p != nil {
// 		d++
// 		i = T[i].p
// 	}
// 	return d
// }

// 再帰的に深さを求める
func rec(u, p int) {
	D[u] = p
	if T[u].r != NIL {
		rec(T[u].r, p) // 右の兄弟に同じ深さを設定
	}
	if T[u].l != NIL {
		rec(T[u].l, p+1) // 最も左の子に自分の深さ+1を設定
	}
}

func PrintNode(u int) {
	fmt.Printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u])

	if T[u].p == NIL {
		fmt.Printf("root, ")
	} else if T[u].l == NIL {
		fmt.Printf("leaf, ")
	} else {
		fmt.Printf("internal node, ")
	}

	fmt.Printf("[")
	for c := T[u].l; c != NIL; c = T[c].r {
		fmt.Printf("%d", c)
		if T[c].r != NIL {
			fmt.Printf(", ")
		}
	}
	fmt.Printf("]\n")
}

const MAX_NODES_NUM = 200000
const NIL = -1

var T [MAX_NODES_NUM + 5]Node
var D [MAX_NODES_NUM + 5]int

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	for i := 0; i < n; i++ {
		T[i].p, T[i].l, T[i].r = NIL, NIL, NIL
	}

	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		children := make([]int, k)
		l := NIL
		for j := 0; j < k; j++ {
			children[j] = nextInt()
			if j == 0 {
				T[u].l = children[j]
			} else {
				T[l].r = children[j]
			}
			l = children[j]
			T[children[j]].p = u
		}
	}

	root := NIL
	for i := 0; i < n; i++ {
		if T[i].p == NIL {
			root = i
			break
		}
	}

	//深さを再起的に求める
	rec(root, 0)

	for i := 0; i < n; i++ {
		PrintNode(i)
	}

}



Measured memory_bytes: 16716