akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    map<string,int> mp;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;    
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	if (s.length() <= 2)
		cout << s << endl;
	else
	{
		for (int i = s.length() - 1; i >= 0; i--)
			cout << s.at(i);
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s; cin>>s;
	cout<<(s[1] == 'B' ? "ARC" : "ABC");
}

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

bool isPrime(int n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return n!=1;
}

int main() {
	int n, a[10000], sum=0;
	
	cin>>n;
	
	for(int i=0;i<n;i++){
	cin>>a[i];
	if(isPrime(a[i]))
	sum++;
	}
	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3052
#include<stdio.h>
main()
{
    int a,b,x,i,s,c;
    while(scanf("%d %d",&a,&b)==2){
            x=1;
            s=0;
        for(i=1;i<=a;i++){
            scanf("%d",&c);
            s+=c;
            if(s<=b)
                x++;
        }
        printf("%d\n",x);
    }
}


Measured memory_bytes: 128
X = input()

N = len(X)

cnt_S = 0
cnt_T = 0
cnt_delete = 0
for i in range(N):
    if i == 0:
        if X[i] == "S":
            cnt_S += 1
        else:
            cnt_T += 1
    else:
        if X[i-1] == "S" and X[i] == "S":
            cnt_S += 1
        elif X[i-1] == "S" and X[i] == "T":
            cnt_T += 1
        elif X[i-1] == "T" and X[i] == "T":
            cnt_T += 1
        elif X[i-1] == "T" and X[i] == "S":
            tmp = min(cnt_S, cnt_T)
            cnt_delete += tmp*2
            cnt_S -= tmp
            cnt_T = 0
            cnt_S += 1

    if i == N-1:
        tmp = min(cnt_S, cnt_T)
        cnt_delete += tmp*2

print(N - cnt_delete)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int x, ans;
  cin >> x;
  
  cout << (x/500)*1000 + ((x%500)/5)*5 << endl;
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int ketasu = sc.nextInt();
    String secret = sc.next();

    String[] pin = new String[ketasu];

    for(int i = 0; i < ketasu; i++)
      pin[i] = secret.substring(i, i+1);

    int count = 0;

    for(int i = 999; i >= 0; i--){
      String line = String.format("%03d", i);
      int point = 0;
      for(int j = 0; j < pin.length; j++){
        if(pin[j].equals(line.substring(point, point+1))){
          point++;
        }
        if(point == 3){
          count++;
          break;
        }
      }
    }

    System.out.println(count);
  }
}

Measured memory_bytes: 273252
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
LL = inpl()
LL.sort()
ans = 0
for b in range(N):
    bL = LL[b]
    for a in range(b):
        aL = LL[a]
        cLmax = aL+bL
        ans += max(0,bisect.bisect_left(LL,cLmax)-b-1)

print(ans)


Measured memory_bytes: 45144
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    // a-4
    if (b-a > k) {cout << ":(" << endl; return 0;}
    if (c-a > k) {cout << ":(" << endl; return 0;}
    if (d-a > k) {cout << ":(" << endl; return 0;}
    if (e-a > k) {cout << ":(" << endl; return 0;}
    // b-3
    if (c-b > k) {cout << ":(" << endl; return 0;}
    if (d-b > k) {cout << ":(" << endl; return 0;}
    if (e-b > k) {cout << ":(" << endl; return 0;}
    // c-2
    if (d-c > k) {cout << ":(" << endl; return 0;}
    if (e-c > k) {cout << ":(" << endl; return 0;}
    // d-1
    if (e-d > k) {cout << ":(" << endl; return 0;}
    cout << "Yay!" << endl;
    return 0;
}


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


int main(){
  ll a;
  double b;
  cin >> a >> b;
  int c = b * 100 + 0.2;
  ll ans = a * c;
  ans /= 100;
  cout << ans << endl;
}



Measured memory_bytes: 3684
N, M = list(map(int, input().split()))
V = 10 ** 9 + 7
a = [int(input()) for _ in range(M)]
A = set(a)
ANS = [0 for _ in range(100000 + 5)]

ANS[0] = 1
for i in range(N):
    ANS[i] %= V
    if not i + 1 in A:
        ANS[i + 1] += ANS[i]
        ANS[i + 1] %= V
    if not i + 2 in A:
        ANS[i + 2] += ANS[i]
        ANS[i + 2] %= V
print(ANS[N] % V)


Measured memory_bytes: 13216
import sys
input = sys.stdin.readline

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

N, M, K = map(int, input().split())
par = [-1 for i in range(N)]
rank = [0] * N
frendCnt = [0] * N
bloc = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    frendCnt[a] += 1
    frendCnt[b] += 1
    unite(a, b)

for i in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    bloc[c].append(d)
    bloc[d].append(c)

for i in range(N):
    ans = size(i) - frendCnt[i] - 1
    for j in bloc[i]:
      if same(i, j):
           ans -= 1
    print(ans, end=' ')

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

int main(){
	int n,x,y,b,p;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x>>y>>b>>p;
		if(b>=5&&p>=2) cout<<x*0.8*b+y*0.8*p<<endl;
		else if(b>=5){
			if(x*b+y*p>x*0.8*b+y*0.8*2) cout<<x*0.8*b+y*0.8*2<<endl;
			else cout<<x*b+y*p<<endl;
		}
		else if(p>=2){
			if(x*b+y*p>x*0.8*5+y*0.8*p) cout<<x*0.8*5+y*0.8*p<<endl;
			else cout<<x*b+y*p<<endl;
		}
		else{
			if(x*b+y*p>x*0.8*5+y*0.8*2) cout<<x*0.8*5+y*0.8*2<<endl;
			else cout<<x*b+y*p<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3276
//                      Aman Raj  - AmanRaj1608
#include<bits/stdc++.h>
using namespace std;
#define ll                        long long
#define vi                        vector<ll int>
#define pb                        emplace_back
#define rep(i,a,b)                for(int i = a; i<b; ++i)
#define rrep(i,a,b)               for(int i = a; i>=b; --i)
#define p(a)                      cout << a << "\n";
#define p2(a,b)                   cout << a << " " << b << "\n";
#define fast_io                   ios_base::sync_with_stdio(false);cin.tie(NULL);
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://

const ll int MOD = 1000000007;

int32_t main() {
	fast_io;
    ll tt = 1;
	// cin >> tt;
    while(tt--) {
		ll int n,m;
		cin >> n >> m;
		char arr[n][m];
		rep(i,0,n) rep(j,0,m)	cin >> arr[i][j];

		ll dp[n][m] = {0};

		bool flag = true;
		dp[0][0] = 0;
		rep(i,1,n)	{
			if(arr[i][0]=='.' && flag)	dp[i][0] = 1;
			else { dp[i][0] = 0; flag = false;}
		}
		flag = true;
		rep(i,1,m) {
			if(arr[0][i]=='.' && flag)	dp[0][i] = 1;
			else { dp[0][i] = 0; flag = false;}
		}

		rep(i,1,n) {
			rep(j,1,m) {
				if(arr[i][j]=='#')
					continue;
				dp[i][j] = (dp[i-1][j]%MOD + dp[i][j-1]%MOD)%MOD;
			}
		}
		p(dp[n-1][m-1])
		// rep(i,0,n) {rep(j,0,m)	cout << dp[i][j] << " "; cout << "\n";}
    }
    return 0;
}
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://


Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  vector<int> count(5);
  for(int i = 0;i < n;i++){
    string s;
    cin >> s;
    char c = s[0];
    if(c == 'M')count[0]++;
    if(c == 'A')count[1]++;
    if(c == 'R')count[2]++;
    if(c == 'C')count[3]++;
    if(c == 'H')count[4]++;
  }
  vector<int> a;
  vector<int> b;
  vector<int> c;
  a = {0,0,0,0,0,0,1,1,1,2};
  b = {1,1,1,2,2,3,2,2,3,4};
  c = {2,3,4,3,4,4,3,4,4,3};
  ll res = 0;
  for(int i = 0;i < a.size();i++){
    res += (ll)count[a[i]] * count[b[i]] * count[c[i]];
  }
  cout << res << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> ca(N);
  for (int i = 0; i < N ; i++){
    cin >> ca.at(i);
    
  }
  
  for (int i = 0; i < N - 1; i++){
    bool flg = false;
    for ( int j = 0; j < N - 1 - i ; j++){
      if (ca.at(j) < ca.at(j+1)){
        int temp;
        temp = ca.at(j+1);
        ca.at(j+1) = ca.at(j);
        ca.at(j) = temp;
        flg = true;
      }
    }
    if (flg == false) break;
  }  
  
  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N ; i++){
    if ( i % 2 == 0) alice += ca.at(i);
    else bob += ca.at(i);
    }
  
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

string sl;
vector<int> l;
ll dp[100010][2];

int main() {
    cin >> sl;
    rep(i,sl.size()) l.push_back(sl[i]-'0');
    dp[0][0] = 1;
    rep(i,l.size()) rep(j,2) {
        // 0,0
        if (l[i] == 0) (dp[i+1][j] += dp[i][j]) %= MOD;
        else (dp[i+1][1] += dp[i][j]) %= MOD;
        // 1,0
        if (l[i] == 1) (dp[i+1][j] += 2*dp[i][j]) %= MOD;
        else if (j == 1) (dp[i+1][j] += 2*dp[i][j]) %= MOD;
    }
    ll ans = 0;
    rep(i,2) ans += dp[l.size()][i];
    cout << ans%MOD << endl;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  string ans="";
  rep(i,0,tx-sx) ans+='R';
  rep(i,0,ty-sy) ans+='U';
  rep(i,0,tx-sx) ans+='L';
  rep(i,0,ty-sy+1) ans+='D';
  rep(i,0,tx-sx+1) ans+='R';
  rep(i,0,ty-sy+1) ans+='U';
  ans+='L';
  ans+='U';
  rep(i,0,tx-sx+1) ans+='L';
  rep(i,0,ty-sy+1) ans+='D';
  ans+='R';
  cout<<ans<<endl;
}









Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--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())

#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
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = int_fast64_t;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    if (n == 1) {
        cout << a[0] << endl;
        return;
    }
    cout << a[n-1];
    for (int i = n - 3; i >= 0; i-=2) cout << " " << a[i];
    for (int i = n%2; i < n; i+=2) cout << " " << a[i];
    cout << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 2944
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
using namespace std;
int main(){ 
  string str;
  cin >>str;
  if(str[2]==str[3]&&str[4]==str[5]){
    cout <<"Yes"<<endl;
  }else{
    cout <<"No"<<endl;
  }
}
  

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

int main() {
	int n, x; cin >> n >> x;
	vector<int>a(n); for (auto&& i : a)cin >> i;
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (x >= a[i]) {
			x -= a[i]; ans++;
		}
	}
	if (x > 0&&ans==n) {
		ans--;
	}
	cout << ans << endl;

	return 0;
}

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

using ld = long double;
const ld eps = 1e-8, pi = acos(-1.0);

bool eq(ld a, ld b) {
	return abs(a - b) < eps;
}

using Point = complex<ld>;
int main()
{
	int N;
	ld xa, ya, ra, xb, yb, rb;
	cin >> N;
	while (N--) {
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		ld dis = abs(Point(xa, ya) - Point(xb, yb));
		if (dis + rb < ra - eps) {
			cout << 2 << endl;
		}
		else if (dis + ra < rb - eps) {
			cout << -2 << endl;
		}
		else if (dis > ra + rb + eps) {
			cout << 0 << endl;
		}
		else {
			cout << 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3208
n = int(input())
x = list( map(int,input().split()) )

#print(max(x),min(x))

min_hp = 1000000000000000
for p in range(min(x),max(x)+1):
    hp = 0
    for i in x:
        hp +=(i-p)**2
        # print(p,i,hp)
    if min_hp > hp:
        min_hp = hp

print(min_hp)

Measured memory_bytes: 3060
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  xs <- inpi toDbl
  mapM_ print $ solve xs

solve :: [Double] -> [Int]
solve xs = map height xs

height :: Double -> Int
height x = 1 + (ceiling $ x * x / 98.0)

toDbl :: String -> Double
toDbl s = read s

inpi :: (String -> a) -> IO [a]
inpi f = map f . lines <$> getContents

Measured memory_bytes: 3896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int k_cnt = 0, s_cnt = 0, answer;
		while(a > 0) {
			a = a - c;
			k_cnt = k_cnt + 1;
		}
		while(b > 0) {
			b = b - d;
			s_cnt = s_cnt + 1;
		}
		if(k_cnt > s_cnt) {
			answer = l - k_cnt;
		} else {
			answer = l - s_cnt;
		}
		System.out.println(answer);
	}

}

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>n;
    int b[n-1]; rep(i,0,n-2) cin>>b[i];
    int a[n]; ans=b[0]+b[n-2];
    rep(i,1,n-2) ans+=min(b[i],b[i-1]);
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
def main():
    S = [input() for i in range(3)]
    p = 0
    while len(S[p]) > 0:
        nxt = S[p][0]
        S[p] = S[p][1:]
        p = ord(nxt) - ord('a')
    print(chr(ord('A')+p))


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a>b)
    return gcd(b,a);
  if(a==0)
    return b;
  return gcd(b%a,a);
}
int main(){
  int n;
  cin>>n;
  int g=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    g=gcd(g,a);
  }
  cout<<g<<endl;
}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int Q;
	
	cin >> Q;
	
	int l, r, count[100001] = {};
	bool check[100001];
	
	for(int i=2; i<=100000; i++){
		if(!check[i]){
			for(int j=i+i; j<=100000; j+=i)
				check[j] = true;
		}
	}
	
	for(int i=3; i<=100000; i+=2)
		if(!check[i] && !check[(i+1)/2])
			count[i]++;
	
	for(int i=3; i<=100000; i++)
		count[i] += count[i-1];
	
	for(int i=0; i<Q; i++){
		cin >> l >> r;
		cout << count[r] - count[l-1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()
const int inf = 1 << 28;

template<typename T> inline void chmin(T& t, T f){if(t > f)t = f;}

void preproc(vector<string>& names){
    vector<string> res;
    rep(i, (int)names.size()){
        bool ok = true;
        rep(j, (int)names.size())if(i != j){
            ok &= names[j].find(names[i]) == string::npos;
        }
        if(ok)res.push_back(names[i]);
    }
    names.swap(res);
}

int solve(vector<string>& names){
    preproc(names);
    int n = (int)names.size();
    vector<vector<int> > costs(n, vector<int>(n));
    rep(i, n)rep(j, n){
        costs[i][j] = (int)(names[j].size());
        for(int k=min(names[i].size(), names[j].size()); k>=0; --k){
            if(names[i].substr(names[i].size() - k) != names[j].substr(0, k))continue;
            costs[i][j] -= k;
            break;
        }
    }
    vector<vector<int> > dp(1<<n, vector<int>(n, inf));
    rep(i, n)dp[1<<i][i] = (int)names[i].size();
    rep(S, 1<<n){
        rep(i, n)if(dp[S][i] < inf){
            rep(j, n)if(!(S >> j & 1)){
                chmin(dp[S|1<<j][j], dp[S][i] + costs[i][j]);
            }
        }
    }
    return *min_element(all(dp[(1<<n)-1]));
}

int main(){
    for(int n; cin >> n, n;){
        vector<string> names(n);
        rep(i, n)cin >> names[i];
        cout << solve(names) << '\n';
    }
    return 0;
}

Measured memory_bytes: 2588
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){

    unsigned short *A, *B;
    int C[VMAX+1];
    int i,j,n,k=0;

    scanf("%d",&n);
    A = malloc(sizeof(short)*n+1);
    B = malloc(sizeof(short)*n+1);

    for(i=1;i<=n;i++)
    {
        scanf("%hd",&A[i]);
        if(k<A[i]) k=A[i];
    }
    
    for (i = 0; i <= k; i++)
    {
        C[i] = 0;
    }

    for (j = 1; j <= n; j++)
    {
        C[A[j]]++;
    }

    for (i = 1; i <= k; i++)
    {
        C[i] = C[i] + C[i - 1];
    }

    for (j = n; j >= 1; j--)
    {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for(i=1;i<=n;i++)
    {
        if(i>1)printf(" ");
        printf("%d",B[i]);
    }
        printf("\n");
    return 0;
}




Measured memory_bytes: 9556
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  int sum = 0;
  int cnt = 1;
  for (int i = 0; i < N; i++) {
    sum += L[i];
    if (sum <= X)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int Q; cin >> Q;
  pqdesc<int> mins;
  pqasc<int> maxs;
  i64 ans = 0;
  rep(_, Q) {
    int q; cin >> q;
    if (q == 1) {
      int a, b; cin >> a >> b;
      ans += b;
      mins.push(a), maxs.push(a);
      int mi = mins.top(), ma = maxs.top();
      if (mi > ma) {
        mins.pop(), maxs.pop();
        mins.push(ma), maxs.push(mi);
        ans += mi - ma;
      }
    } else {
      cout << mins.top() << " " << ans << '\n';
    }
  }
}


Measured memory_bytes: 3828
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=1e5+10;
char s[N];
int main() {
    R(s);
    int n=strlen(s);
    int ans=0;
    REP(i,n) if ( s[i]!=s[i+1] ) ans++;
    W(ans-1);
    return 0;
}


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

int main() {
    int bloodType[4] = {};
    int i;
    char ch[3];
    while (scanf("%d,%s", &i, ch) != EOF) {
        switch (ch[0]) {
        case 'A':
            if (ch[1] == 'B')
                bloodType[2]++;
            else
                bloodType[0]++;
            break;
        case 'B':
            bloodType[1]++;
            break;
        case 'O':
            bloodType[3]++;
            break;
        }
    }
    for (int j = 0; j < 4; j++) {
        cout << bloodType[j] << endl;
    }
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int cnt = 0;
            int cur = 1;
            while (cur < B) {
                cur = cur - 1 + A;
                cnt++;
            }
            out.println(cnt);
        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    
    set<ll> st;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    
    out(st.size());
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100010
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int X[N],A[N],n; ll S;
int main()
{
	n=read(); for(int i=1;i<=n;i++)
		X[i]=read(),S+=X[i];
	for(int i=1;i<=n;i++)
		A[i]=(X[(i+1)%n==0? n:(i+1)%n]-X[i]);
	if(S%(1ll*n*(n+1)/2)){puts("NO"); return 0;}
	int T=S/(1ll*n*(n+1)/2),ret=0;
	for(int i=1;i<=n;i++)
	{
		int gs=(T-A[i]);
		if(gs<0||gs%n)
		{
			puts("NO");
			return 0;
		}
		ret+=gs/n;
	}
	if(ret!=T) puts("NO");
	else puts("YES");
	return 0 ;
}

Measured memory_bytes: 1024
N,K = (int(i) for i in input().split())
n = [i for i in range(1,N+1)]
ans = []
for i in range(len(n)-K+1):
    tmp = []
    for j in range(K):
        tmp.append(n[j+i])
    ans.append(tmp)
print(len(ans))


Measured memory_bytes: 2940
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
   
    int a,b;
    cin>>a>>b;
    int ans=a+b;
    
    if(ans>=24){
        ans-=24;
    }
    
    cout<<ans<<endl;
    
    return 0;
}






Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  string s;
  cin >> s;
  if(s[0] == '1')
    cout << '9';
  else
    cout << '1';
  if(s[1] == '1')
    cout << '9';
  else
    cout << '1';
  if(s[2] == '1')
    cout << '9';
  else
    cout << '1';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>
 
using namespace std;
typedef long long ll;


ll ans,mx,mn,sum;
int main(){
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	if(n < k) cout<< n*x;
	else{
		ans = k*x;
		sum = (n-k)*y;
		cout<<ans+sum<<endl;
	}
}

Measured memory_bytes: 256
//ABC 176 D--Wizard in Maze 
//题目地址：https://atcoder.jp/contests/abc176/tasks/abc176_d
//题解地址：https://atcoder.jp/contests/abc176/editorial/79
 
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
const ll INF = 1LL << 60;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
    ll h,w,cx,cy,dx,dy;
    cin >> h >> w >> cx >> cy >> dx >> dy;
    cx--;
    cy--;
    dx--;
    dy--;
    string s[h];
    for (ll i=0;i<h;i++)cin >> s[i];
    deque<P> que;

    que.push_back(P(cx,cy));
    bool visited[h][w];
    ll d[h][w];
    for (ll i=0;i<h;i++){
        fill(visited[i],visited[i]+w,false);
        fill(d[i],d[i]+w,INF);
    }
    d[cx][cy]=0;
    visited[cx][cy]=true;

    while(!que.empty()){
        P p=que.front();
        ll X=p.first,Y=p.second;
        if (X==dx and Y==dy){
            cout << d[X][Y] << endl;
            return 0;
        }
        visited[X][Y]=true;
        que.pop_front();
        for (ll i=-2;i<3;i++){
            for (ll j=-2;j<3;j++){
                ll x=X+i,y=Y+j;
                if (x<h && x>=0 && y<w && y>=0 && s[x][y]=='.'){
                    if (visited[x][y])continue;
                    if (abs(i)+abs(j)<2){
                        que.push_front(P(x,y));
                        d[x][y]=d[X][Y];
                        visited[i][j]=true;//????I am in trouble.
                    }else{
                        if (d[X][Y]+1<d[x][y]){
                            d[x][y]=d[X][Y]+1;
                            que.push_back(P(x,y));
                        }
                    }
                }
            }
        }

    }
    cout<<"-1"<<endl;
    return 0;
}



Measured memory_bytes: 14440
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
#define LL long long
#define LD long double
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pii pair<int,int>
#define pli pair<LL,int>
#define pil pair<int,LL>
#define pll pair<LL,LL>
#define ff first
#define ss second
#define pb push_back
#define BTW(x,a,b) ((a) <= (x) && (x) <= (b))
#define _eq(a,b) (fabs((a)-(b)) < EPS)
#define _lt(a,b) (fabs((a)-(b)) > EPS && a < b)
#define _gt(a,b) (fabs((a)-(b)) > EPS && a > b)
#define _lte(a,b) !_gt(a,b)
#define _gte(a,b) !_lt(a,b)
const vector<pii> XY = {pii(0,-1),pii(0,1),pii(-1,0),pii(1,0)};
const LD EPS = 1e-8;
const LD PI = acos(-1.0L);
const LL INFLL =  4e18;
const int INF  =  2e9;
const int MOD  =  1e9 + 7;
//#define int long long

// read / write
template<typename T> void read(T& t) { cin >> t; }
template<typename T, typename ... U> void read(T& t, U& ... u) { read(t); read(u ...); }
template<typename T> void write(T t) { cout << t; }
template<typename T, typename ... U> void write(T t, U ... u) { write(t); write(u ...); }



// ------------------------------------------------- Vs
const int LOGN    =  16              + 1;
const int MAXN1   =  3e5            + 3;
const int MAXN2   =  8            + 3;
// ------------------------------------------------- Fs
int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); write(fixed, setprecision(12));
    int n,k; read(n,k);
    write(n-k+1,"\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();		// imp ques dgt.
	map<int,int> m; // simple implementation think^100
	int x;
	cin>>x;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		m[a[i]]++;
	}
	int ans;
	int mini=INT_MAX;
	for(int i=0;i<=101;i++)
	{
		if(mini>abs(x-i) && m.find(i)==m.end())
		{
			mini=abs(x-i);
			ans=i;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long ll;
const int mod= 1e+9+7;

int main() {
    int N;cin>>N;
    vector<ll>h(N);
    rep(i,N)cin>>h[i];
    int ans =0;
    rep(i,N-1){
        int cnt=0;
        while(h[i]>=h[i+1]){
            cnt++;
            i++;
            if(i==N-1)break;
        }
        ans =max(ans,cnt);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,m,p,f[310][310][310];
//f[i][j][k]:we've finished constructing the first i sequences, now we're going to add the number j into the i+1-th sqeuence, and there're k places to add j into
int main(){
	scanf("%d%d%d",&n,&m,&p),f[0][1][0]=1;
	for(int i=0;i<=n;i++)for(int j=1;j<=m;j++)for(int k=i;k>=0;k--){
		if(k)(f[i][j][k-1]+=f[i][j][k])%=p;//we decide not to add j to the k-th place, so we could add it to the (k-1)-th place.
		else(f[i][j+1][i]+=f[i][j][k])%=p;//we have tried every place j could be added to, now it's time to try j+1, which could be added into any place
		(f[i+1][j][k]+=1ll*f[i][j][k]*(k+1)%p)%=p;//we decide to add j to the k-th place, and there are (k+1) places for us to add (including the last one)
	}
	printf("%d\n",f[n][m+1][n]);//all n sequences've been constructed, and all number've been tried
	return 0;
}

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

int main(){
    string a, b = "YAKI";
    cin >> a;
    if(a[0] == b[0] &&a[1] == b[1] &&a[2] == b[2] &&a[3] == b[3])cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]

check=a[0]
ans=0
if check<=0:
    ans=abs(check)+1
    check=1

for i in range(1,n):
    check2=check+a[i]
    if i%2==0:
        if check2<=0:
            ans+=(abs(check2)+1)
            check=1
        else:
            check=check2
            
    else:
        if check2>=0:
            ans+=(abs(check2)+1)
            check=-1
        else:
            check=check2

            
check=a[0]
ans2=0
if check>=0:
    ans2=abs(check)+1
    check=-1

for i in range(1,n):
    check2=check+a[i]
    if i%2!=0:
        if check2<=0:
            ans2+=(abs(check2)+1)
            check=1
        else:
            check=check2
            
    else:
        if check2>=0:
            ans2+=(abs(check2)+1)
            check=-1
        else:
            check=check2
print(min(ans,ans2))
    

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.a = sc.nextInt();
			o.b = sc.nextInt();
			arr[i] = o;
		}
		sc.close();

		Arrays.sort(arr, (o1, o2) -> o1.b - o2.b);
		long now = 0;
		for (Obj o : arr) {
			now += o.a;
			if (now > o.b) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}

	static class Obj {
		int a, b;
	}
}


Measured memory_bytes: 103116
#include <stdio.h>

int main(){
	int s;
	int num=0;
	int dig=0;
	int sum=0;
	scanf("%d",&s);
	num = s;
	while(num){
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
 	}
	if( s%sum == 0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}



Measured memory_bytes: 128
n = int(input())
xa, bx, bxa = 0, 0, 0
ans = 0
for _ in range(n):
	s = input()
	for i in range(len(s)-1):
		if s[i] == "A" and s[i+1] == "B":
			ans += 1
	if s[0] == "B":
		if s[-1] == "A":
			bxa += 1
		else:
			bx += 1
	elif s[-1] == "A":
		xa += 1

if xa == bx:
	if xa == 0:
		print(ans+max(0, bxa-1))
	else:
		print(ans+xa+bxa)
else:
	print(ans+bxa+min(xa, bx))

Measured memory_bytes: 3064
// Problem : M - Candies
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_m
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
#define INF 0x3f3f3f3f3f3f3f3fLL
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 2000 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
int n, k, a[101], mem[101][100005],dp[101][100005];
map<int, int>mp;
int solve(int i = 0, int rem = k) {
	if (!rem)return 1;
	if (i == n)
	{
		return rem == 0;
	}
	int& ret = mem[i][rem];
	if (~ret)return ret;
	ret = 0;
	for (int ch = 0; ch <= min(rem, a[i]); ch++) {
		ret += solve(i + 1, rem - ch) % mod;
		ret %= mod;
	}
	return ret;
}
int main()
{
	Ma7moud_7amdy;
//	Open_Sesame;
	//clr(mem, -1);
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
//	cout << solve() << endl;

	//baseCase
	for (int i = 0; i <= n; i++) {
		dp[i][0] = 1;
	}

	//itteration
	for (int i = n - 1; i >= 0;i--) {
		//perfixSum
		for (int rem = 1; rem <= k; rem++) {
			dp[i+1][rem] +=dp[i+1][rem-1]%mod;
			dp[i+1][rem]%=mod;
		}
		for (int rem = 0; rem <=k; rem++) {
			int& ret = dp[i][rem];
			ret = 0;
			/*for (int ch = 0; ch <= min(rem, a[i]); ch++) {
				ret += dp[i + 1][rem - ch];
				ret %= mod;
			}*/
			ret += ((dp[i + 1][rem] - dp[i + 1][rem - min(rem, a[i])-1])%mod+mod)%mod;
			ret%=mod;
		}
	}
	cout << dp[0][k] << endl;
}


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

int main(void){
  int n; cin >> n;
  int p[n];
  rep(i,n) cin >> p[i];
  int min = p[0];
  int ans = 1;
  for(int i = 1; i < n; i++){
    if(p[i] <= min){
      min = p[i];
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int N;
    int i,j,flag;
    cin >> N;
    int h[N];
    for(i=0;i<N;i++){
      cin >> h[i];
    }
    flag=0;
    ll cnt=0;
    for(j=100;j>0;j--){
      flag=0;
      for(i=0;i<N;i++){
          if(h[i]>=j){
            if(flag==0){
              cnt++;
            }
            flag = 1;
          }else{
            flag = 0;
          }
      }
    }
    cout << cnt;
    return 0;
}


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

int main () {
	
	int n=0, k=0;
	string s="";

	cin >> n >> k >> s;

	k--;
	s[k] -= 'A';
	s[k] += 'a';

	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
      	String s = input.nextLine();
      	int c = 0;
        for (int i = 0; i < s.length(); i++)
        	if (s.charAt(i) == 'A')
              c++;
      	if (c == 0 || c == 3)
          System.out.println("No");
      	else
          System.out.println("Yes");
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 9999999999;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	

	ll p,q,r;
	cin >> p >> q >> r;
	ll ans = LLONG_MAX;
	ll arr[4];
	arr[0] = p;
	arr[1] = q;
	arr[2] = r;
	for(int i  = 0;i<=2;i++)
	{
		for(int j = 0;j<=2;j++)
		{
			for(int k = 0;k<=2;k++)
			{
				if(k==i||k==j||i==j||i==k) continue;
				ans=min(ans,arr[i]+arr[j]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}
	


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数list 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

int main() {
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    char t = 'a';
    ll tmp = 0;
    vector<ll> v;
    rep(i, n){
        if (i==0 || t == s[i]) tmp++;
        else {
            
            v.push_back(tmp);
            tmp = 1;
        }
        t = s[i];
        if(i == n - 1) {v.push_back(tmp);break;}
    }
    ll sum = accumulate(v.begin(), v.end(), 0) - v.size();
    if (v.size() >= 2*k + 1)
    {
        sum+=2*k;
    }
    else{
        sum=n-1;
    }
    

    pr(sum);
}


Measured memory_bytes: 1528
from heapq import heappush, heappop
N, M, s = map(int, input().split())
Adj = [[] for i in range(N)]

for i in range(M):
    ui, vi, ci = map(int, input().split())
    Adj[ui].append((vi, ci))

d = [float("inf")] * N
d[s] = 0
pq = [(0, s)]
fixed = 0

while pq:
    di, v = heappop(pq)

    if di > d[v]:
        continue

    for u, c in Adj[v]:
        if d[v] + c < d[u]:
            d[u] = d[v] + c
            heappush(pq, (d[u], u))

    fixed += 1

    if fixed == N - 1:
        break

for di in d:
    print(di if di != float("inf") else 'INF')
 

Measured memory_bytes: 89288
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int d = Integer.parseInt(sc.next());

        String result = "Christmas";
        for (int i = 0; i < 25 - d; i++) {
            result += " Eve";
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 19796