akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    Vec v(5);
    cin>>v[0]>>v[1]>>v[2]>>v[3]>>v[4]>>k;
    bool can = true;
    rep(j,5)rep(i,j){
        if(abs(v[i]-v[j])>k){
          can = false;
        }
    }
    if(can){
        cout<<"Yay!"<<endl;

    }else{
        cout<<":("<<endl;
    }
    return  0;
}


Measured memory_bytes: 768
#include <stdio.h>
int main(void){
    // Your code here!
    int a, b, c, d, e, f, g, h, i;
    scanf("%d", &a);
    b = 10000000000;
    c = 0;
    for(i = 0; i < a; i++){
        scanf("%d", &d);
        if(b > d){
            b = d;
        }
        if(c < d){
            c = d;
        }
    }
    printf("%d", c - b);
   
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    int N;
    cin >> N;
    int NN = N * (N - 1) / 2;
    vector<vector<int>> V(NN);
    set<int> begins;
    map<int, int> m;
    int iter = 0;
    REP(i, N) REP(j, N){
        if (i < j) m[i * N + j] = iter++; 
    }
    int tmp, tmp1;
    vector<int> ine(NN, 0);
    REP(i, N) {
        REP(j, N - 1){
            cin >> tmp;
            tmp--;
            tmp = i < tmp ? (i * N + tmp) : (tmp * N + i);
            tmp = m[tmp];
            //cout << tmp << endl;
            if (j != 0) {
                V[tmp1].push_back(tmp);
                ine[tmp]++;
                //cout << tmp1 << " " << tmp << endl;
            }
        tmp1 = tmp;
        }
    }
    //for(auto tmp : m) cout << tmp.first << " " << tmp.second << endl;
    vector<int> st, t_list;
    REP(i, NN) if(ine[i] == 0) st.push_back(i);
    while(st.size() > 0){
        vector<int> st1;
        for(auto tmp : st){
            t_list.push_back(tmp);
            for (auto hoge : V[tmp]) {
                ine[hoge]--;
                if (ine[hoge] == 0) st1.push_back(hoge);
            }
        ine[tmp] = -1;
        }
        st = st1;
    }
    //for(auto tmp : t_list) cout << tmp << " ";
    if (t_list.size() != N * (N  - 1) / 2){
        cout << -1 << endl;
        return 0;
    }
    int mm = 0;
    vector<int> len(NN, 1);
    REP(i, NN){
        int iter = t_list[i];
        for(auto tmp : V[iter]){
            //cout << iter << " " << tmp << endl;
            len[tmp] = max(len[tmp], len[iter] + 1);
            mm = max(len[tmp], mm);
            //cout << tmp << " " << len[tmp] << endl;

        }
    }
    cout << mm << endl;

    return 0;
}


Measured memory_bytes: 56944
dp={"TTT"=>1}
gets.to_i.times do
  nex=Hash.new{|h,k|h[k]=0}
  dp.each do |k,v|
    "AGCT".chars do |c|
      s=k+c
      nex[s[1..-1]]+=v unless s.match(/AGC|GAC|ACG|A.GC|AG.C/)
    end
  end
  dp=nex
end
p dp.values.inject(:+)%(10**9+7)

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return true;}return false;}

int N;
long long W,weight[110],value[110];
long long dp[110][100100] = {0};

void input(){
  cin >> N >> W;
  for(int i=0;i<N;i++){
    cin >> weight[i] >> value[i];
  }
}

void solve(){
  for(int i=0;i<N;i++){
    for(int sum_w=0;sum_w<=W;sum_w++){
      if(sum_w>=weight[i]){
	chmax(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i]);
      }
      chmax(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }
}

int main(){
  input();
  solve();
  cout << dp[N][W] << endl;
  return 0;
}



Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  
  vector<int> X(N);
  vector<int> Y(N);
  for( int i = 0; i < N; i++ ){
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }
  
  sort(Y.begin(), Y.end());
  for( int i = 0; i < N; i++ ){
    if( X.at(i) <= Y.at(N/2-1) ){
      cout << Y.at(N/2) << endl;
    }else{
      cout << Y.at(N/2-1) << endl;
    }
  }
}

Measured memory_bytes: 5376
x = [int(input()) for _ in range(5)]
ran = [i for i in range(10,131,10)]
res = []

for q in x:
  low = 200
  for p in ran:
    if low>p-q and p-q>=0:
      low = p-q
  else:
    res.append(low)
res.sort()
res.pop(-1)
print(sum(x)+sum(res))

Measured memory_bytes: 3064
let () =
    let n = Scanf.scanf "%d\n" (fun x -> x) in
    for i = 1 to n do
        let x1, y1, x2, y2, x3, y3 = Scanf.scanf "%f %f %f %f %f %f\n" (fun x1 y1 x2 y2 x3 y3 -> x1, y1, x2, y2, x3, y3) in
        let a = ((x2-.x1)**2.0 +. (y2-.y1)**2.0)**0.5 in
        let b = ((x3-.x2)**2.0 +. (y3-.y2)**2.0)**0.5 in
        let c = ((x1-.x3)**2.0 +. (y1-.y3)**2.0)**0.5 in

        let a1 = 2.0*.(x2 -. x1) in
        let b1 = 2.0*.(y2 -. y1) in
        let c1 = x1**2.0 -. x2**2.0 +. y1**2.0 -. y2**2.0 in
        let a2 = 2.0*.(x3 -. x1) in
        let b2 = 2.0*.(y3 -. y1) in
        let c2 = x1**2.0 -. x3**2.0 +. y1**2.0 -. y3**2.0 in

        let x = (b1*.c2 -. b2*.c1) /. (a1*.b2 -. a2*.b1) in
        let y = (c1*.a2 -. c2*.a1) /. (a1*.b2 -. a2*.b1) in
        let r = (a*.b*.c) /. (((a+.b+.c)*.(b+.c-.a)*.(c+.a-.b)*.(a+.b-.c))**0.5) in

        Printf.printf "%.3f %.3f %.3f\n" x y r
    done

Measured memory_bytes: 2420
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[20];

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int n=a+b;
	for(int i=0;i<(1<<n);i++){
		if(__builtin_popcount(i)!=b)continue;
		for(int j=0;j<n;j++)if(i&(1<<j))str[n-1-j]='B';else str[n-1-j]='A';
		bool ok=true;
		int A=0;
		int B=0;
		for(int j=0;j<n;j++){
			if(str[j]=='A')A++;
			else B++;
			if(j==n-1)break;
			if(min(A,B)<4&&max(A,B)==5)ok=false;
		}
		if(ok)printf("%s\n",str);
	}
}

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

ll gcd(ll a, ll b) {
    if (b < a) swap(a, b);
    ll r = a % b;
    while (r) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

void factoring(ll n, map<ll, int> &pfac) {
    ll upper = (ll)sqrt(n);
    for (ll i = 2; i <= upper; i++) {
        while (n % i == 0) {
            n /= i;
            pfac[i]++;
        }
    }
    if (n > 1) pfac[n]++;
}

int main() {
    ll a, b, g;
    map<ll, int> mp;
    cin >> a >> b;
    g = gcd(a, b);
    factoring(g, mp);
    cout << mp.size() + 1 << endl;
    return 0;
}

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

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  if (H>=W) {
    if (N%H==0) {
      cout << N/H << endl;
    }
    else {
      cout << 1+(N-(N%H))/H << endl;
    }
  }
  else {
    if (N%W==0) {
      cout << N/W << endl;
    }
    else {
      cout << 1+(N-(N%W))/W << endl;
    }
  }
}

Measured memory_bytes: 3580
N,L=map(int, raw_input().split())

AJI=[ L+i-1 for i in range(1,N+1) ]
total=sum(AJI)

sa_min=float("inf")
for x in AJI:
	sa_min=min(sa_min, abs(x))

if sa_min in AJI:
	print total-sa_min
else:
	print total+sa_min


Measured memory_bytes: 28012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;

int main(){
    ll n, m = 3501;
    cin >> n;
    for(int i = 1; i < m ; i++){
        for(int j = 1; j < m; j++){
            ll x = 4 * i * j - n * i - n * j;
            if(x <= 0) continue;
            ll y = n * i * j;
            if(y % x == 0 && y / x < m) {
                cout << i << " " << j << " " << y / x << endl;
                return 0;
            }
        }
    }
}


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

int main() {
    ll N;
    cin >> N;
    ll res=0;
    map<string,int> S;
    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        S[s]=1;
    }
    cout<<(int)S.size();
    return 0;
}

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

int main() {
  string s;
  string t;
  vector<int> kouho;
  vector<int> kouho2;
  vector<string> res;
  cin >> s >> t;
  if(t.size() > s.size()){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  rep(i,s.size()-t.size() + 1){
    if(s[i] == t[0] || s[i] == '?'){
        kouho.push_back(i);
    }
  }
  rep(i, kouho.size()){
    rep(j,t.size()){
      if(s[kouho[i] + j] == t[j] || s[kouho[i] + j] == '?'){
        if(j == t.size() -1){
          kouho2.push_back(kouho[i]);
        }
      }else {
        break;
      }
    }
  }
  if(kouho2.size() == 0){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  rep(i, kouho2.size()){
    string tmp = s;
    for (int j = 0; j < t.size(); j++){
      tmp[kouho2[i] + j] = t[j];
    }
    rep(i,tmp.size()){
      if(tmp[i] == '?') tmp[i] = 'a';
    }
    res.push_back(tmp);
  }
  sort(res.begin(), res.end());
  cout << res[0] << endl;
}

Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())
max_set = [0, 0, 0]

max_a = f // (a*100)
for i in range(max_a + 1):
  max_b = (f- i*a*100) // (b*100)
  for j in range(max_b + 1):
    water = i*a*100 + j*b*100
    if water == 0:
      continue
    suger = min(e * (water /100), f - water)
    max_c = int(suger // c)
    for k in range(max_c + 1):
      l = (suger - k * c) // d
      if (k*c + l*d) / water > (e / 100):
        continue
      if max_set[0] < (k*c + l*d) / water:
        max_set[0] = (k*c + l*d) / water
        max_set[1] = int((k*c + l*d) + water)
        max_set[2] = int((k*c + l*d))

if max_set[0] == 0 and max_set[1] == 0:
  print(100*a, 0)
else:
  print("{} {}".format(max_set[1], max_set[2]))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<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 yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n, d; cin >> n >> d;
    d = d * 2 + 1;
    cout << (n + d - 1) / d << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

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

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int>G[10010];
vector<int>c(10010,0);
int num[10010];
bool used[10010];
int now_c=0;
int dfs(int s){
    if(used[s]){
        return 0;
    }else{
        used[s]=true;
    }

    num[s]=c[now_c];
    now_c++;

    for(int i=0; i<G[s].size(); i++){
        dfs(G[s][i]);
    }
    return 0;
}

int d[100010];
int main() {
    int N,M; cin >> N >> M;
    vector<int>a(M);

    map<int,bool>mp;
    rep(i,M){
        int s; cin >> s;
        a[i]=s;
        mp[s] = true;
    }
    d[0]=1;
    d[1] = mp[1] ? 0 : 1;
    for(int i=2; i<=N; i++){
        if(mp[i]){
            d[i]=0;
        }else{
            d[i]=(d[i-1]+d[i-2])%MOD;
        }
    }
    cout<< d[N] << endl;
    return 0;
}


Measured memory_bytes: 6016
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

vector<vector<int>> g(100005);
vector<bool> visited(100005);

int maxcol = 1;
map<int, pair<int, int>> BAN;
map<pair<int, int>, int> ans;
map<pair<int, int>, bool> used;

void bfs(int s) {
	queue<int> Q;
	Q.push(s);
	while (!Q.empty()) {
		int v = Q.front(); Q.pop();
		int col = 1;
		visited[v] = true;
		for (int to: g[v]) {
			if (visited[to]) continue;
			while (used[make_pair(v, col)]) col++;
			ans[make_pair(min(v, to), max(v, to))] = col;
			used[make_pair(v, col)] = true;
			used[make_pair(to, col)] = true;
			Q.push(to);
		}
	}
}



int main() {
	int n;
	cin >> n;
	int a[n - 1], b[n - 1];
	rep (i, n - 1) cin >> a[i] >> b[i];
	rep (i, n - 1) {
		a[i]--; b[i]--;
		g[a[i]].pb(b[i]);
		g[b[i]].pb(a[i]);
		BAN[i] = make_pair(min(a[i], b[i]), max(a[i], b[i]));
	}


	bfs(0);

	int m = -1;

	rep (i, n - 1) {
		chmax(m, ans[make_pair(BAN[i].fi, BAN[i].se)]);
	}
	cout << m << endl;
	rep (i, n - 1) cout << ans[make_pair(BAN[i].fi, BAN[i].se)] << endl;
	return 0;
}

Measured memory_bytes: 31872
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		long n = sc.nextLong();
		long m = sc.nextLong();
		long rev = n * m;
		
		if (n == 1 && m == 1) {
			out.println(rev);
		} else if (n == 1 || m == 1) {
			out.println(rev - 2);
		} else {
			out.println(rev - ( n * 2 + m * 2 - 4));
		}
		
		out.close();
	}

	static boolean prime(int n) {
		boolean flag = true;
		int max = (int)Math.sqrt(n);
		for (int i = 2; i <= max; i++) {
			if (n % i == 0) {
				flag = false;
				break;
			}
		}
		if (n == 1) flag = false;
		return flag;
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}



Measured memory_bytes: 21204
#include<iostream>
#include<vector>

using namespace std;
vector<int> data;
int main(void){
  int n;
  cin >> n;
  data = vector<int>(n);
  for(int i=0;i<n;i++){
    cin >> data[i];
  }
  int ans = 1;

  for(int i=1;i<n;i++){
    bool flag = false;
    for(int j=0;j<i;j++){
      if(data[j] <= data[i]){
        flag = true;
      }else{
        flag = false;
        break;
      }
    }
    if(flag){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<string> s(n);
  int inner = 0, enda = 0, beginb = 0, both = 0;
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
    for (int j = 0; j < s.at(i).size() - 1; j++) {
      if (s.at(i).at(j) == 'A' && s.at(i).at(j + 1) == 'B') inner++;
    }
    if (s.at(i).front() == 'B' && s.at(i).back() == 'A') both++;
    else if (s.at(i).front() == 'B') beginb++;
    else if (s.at(i).back() == 'A') enda++;
  }
  
  int joint = 0;
  if (both == 0) joint = min(beginb, enda);
  else {
    if (beginb > 0 && enda > 0) joint = both + 1 + min(beginb - 1, enda - 1);
    else if (beginb == 0 && enda == 0) joint = both - 1;
    else joint = both;
  }
  
  cout << inner + joint << '\n';
}

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

int main(){
    int N, count = 0;
    cin >> N;
    while( N != 1 ){
        if( N % 3 == 1 ){
            N = (N + 2) / 3;
        }else if( N % 3 == 2 ){
            N = (N + 1) / 3;
        }else{
            N /= 3;
        }
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	vector<int>a(in());
	REPC(&i, a)i = in();
	REP(i, in())
	{
		int b = in(), e = in();
		reverse(a.begin() + b, a.begin() + e);
	}
	REP(i, a.size())
	{
		if (i != 0)cout << ' ';
		cout << a[i];
	}
	cout << endl;
}


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

int main(){
	char c;
	int a,b,n;
	int ab[5][14];
	for(int i=0;i<5;i++){
		for(int j=1;j<14;j++){
			ab[i][j]=0;
		}
	}
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> c >> b;
		if(c=='S'){
			a=1;
		}
		if(c=='H'){
			a=2;
		}
		if(c=='C'){
			a=3;
		}
		if(c=='D'){
			a=4;
		}
		ab[a][b]=1;
	}
	for(int i=1;i<5;i++){
		for(int j=1;j<14;j++){
			if(ab[i][j]==0){
				if(i==1){
					cout << 'S' << " " << j;
				}
				if(i==2){
					cout << 'H' << " " << j;
				}
				if(i==3){
					cout << 'C' << " " << j;
				}
				if(i==4){
					cout << 'D' << " " << j;
				}
				cout <<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1160
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
N=II()
A=LI()
SA=sum(A)
Q=II()
queries=[]
for i in range(Q):
  b,c=MI()
  queries.append((b,c))
cnt={}
for a in A:
  if a not in cnt:
    cnt[a]=0
  cnt[a]+=1
for b,c in queries:
  if b in cnt:
    SA-=cnt[b]*b
    SA+=cnt[b]*c
    if c not in cnt:
      cnt[c]=0
    cnt[c]+=cnt[b]
    cnt[b]=0
  print(SA)
  

Measured memory_bytes: 94152
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N int
  NextInt(&N)
  P := make(map[int]int)
  for p := 2; p * p <= N; p++ {
    if N % p > 0 { continue }
    P[p] = 0
    for N % p == 0 {
      N /= p
      P[p]++
    }
  }
  if N > 1 { P[N] = 1 }
  ans := 0
  for _, v := range P {
    cnt := 1
    for cnt * (cnt + 1) / 2 <= v { cnt++ }
    ans += cnt - 1
  }
  Write(ans)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 1832
#include <stdio.h>
int main(void)
{
	int i,n,x[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&x[i]);
	for(i=(n-1);i>=0;i--){
		printf("%d",x[i]);
		if(i==0) break;
		printf(" ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
string a;
int main()
{
	cin>>a;
	for(int i=0; i<a.size(); i++)
	{
		if(a[i]=='e')
		{
			if(a[i+1]=='r'&&a[i+2]=='a'&&a[i+3]=='s')
			{
				if(a[i+4]=='e'&&a[i+5]=='r')
				i+=5;
				else
				i+=4;
			}
		}
		else
		if(a[i]=='d')
		{
			 if(a[i+1]=='r'&&a[i+2]=='e'&&a[i+3]=='a'&&a[i+4]=='m')
			 {
			 	if(a[i+5]=='e'&&a[i+6]=='r'&&a[i+7]=='a'&&a[i+8]=='s'&&a[i+9]=='e')
                i+=4;
                if(a[i+5]=='e'&&a[i+6]=='r')i+=6;
                else i+=4;
			 }
		}
		else
		{cout<<"NO";return 0;}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

//ll n;
ll ans;
string s;
signed main(){
	acc_io;
	cin>>s;
	int n=s.size();
	string num;
	ans=0;
	if(n==1){
		cout<<stoll(s)<<endl;
		return 0;
	}
	
	rep(i,0,2<<(n-2)){
		num=s[0];
		rep(j,0,n-1){
			if((i>>j)&1){
//				cout<<":"<<i<<" "<<" "<<num<<" "<<endl;
				ans+=stoll(num);
				num=s.at(j+1);
			}
			else{
				num+=s.at(j+1);
			}
		}
//		cout<<i<<" "<<" "<<num<<" "<<endl;
		ans+=stoll(num);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int T;
  cin>>T;
  while(T--){
  int h,m;
  scanf("%d:%d",&h,&m);
  double A=360*(h/12.0)+30*(m/60.0);
  double B=360*(m/60.0);
  double r=min(abs(A-B),360-abs(A-B));
  
  if(r<30)cout<<"alert"<<endl;
  else if(r<90)cout<<"warning"<<endl;
  else cout<<"safe"<<endl;
  
  }
  return 0;
}

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 50

long long f( long long b, long long n )
{
	long long res = 0;
	while( n ) {
		res += n % b;
		n /= b;
	}
	return res;
}

int main() {
	long long n, s;

	cin >> n >> s;

	long long ans = n + 1;
	if( n != s ) {
		int flag = 0;
		for( long long b = 2; b*b <= n; b++ ) {
			if( f( b, n ) == s ) {
				ans = b;
				flag = 1;
				break;
			}
		}
		if( flag == 0 ) {
			ans = INF;
			for( long long p = 1; p*p < n; p++ ) {
				long long b = (n - s) / p + 1;
				if( b < 2 ) {
					continue;
				}
				if( f( b, n ) == s ) {
					ans = min( ans, b );
				}
			}
			if( ans == INF ) {
				ans = -1;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// Problem A

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <stack>

#define MAXN 1000
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long int ll;
typedef pair<int, int> ii;

int T;
char a[1000];

int main() {
  cin >> a;
  int n = strlen(a)-1;
  if (a[n] == '3') cout << "bon\n";
  else if (a[n] == '0' || a[n] == '1' || a[n] == '6' || a[n] == '8') cout << "pon\n";
  else cout << "hon\n";
  
  return 0;
}


Measured memory_bytes: 3632
using System;

namespace ALDS_3_Queue
{
    
    class Program
    {
        class Process
        {
            public string name;
            public int time;
        }


        static void Main(string[] args)
        {            
            string[] input = getsplit();
            int n = getint(input[0]);
            int q = getint(input[1]);
            Queue<Process> Q = new Queue<Process>();

            for (int i = 0; i < n; i++)
            {
                string[] data = getsplit();
                Process D = new Process();
                D.name = data[0];
                D.time = getint(data[1]);
                Q.enqueue(D);
            }

            int nowtime = 0;

            while (n > 0)
            {
                Process W = Q.dequeue();
                if (W.time <= q)
                {
                    nowtime += W.time;
                    Console.WriteLine(W.name+" "+nowtime);
                    n--;
                }
                else
                {
                    nowtime += q;
                    W.time -= q;
                    Q.enqueue(W);                  
                }
            }
        }


        public static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        public static int getint(string a)
        {
            
            if (a == null || a.Length == 0)
            {
                int x = int.Parse(Console.ReadLine());
                return x;
            }
            else
            {
                int x = int.Parse(a);
                return x;
            }
        }


        //?????§????????????????£?(where??????)
        //static??????????????¨static??????????????¢???????????§????????? 
        class Queue<T>
        {
             T[] Q;
             int head;
             int tail;
             int MAX = 100000;

            public Queue()
            {
                Q = new T[MAX];
                initialize();
            }

            void initialize()
            {
                head = 0;
                tail = 0;
            }
             bool isEmpty() { return head == tail;}

             bool isFull(){return head == (tail + 1) % MAX;}

            public void enqueue(T x)
            {
                if (isFull())
                {
                    Console.WriteLine("?????\?????????????????????" +
                        "enqueue???????????????");
                }
                Q[tail] = x;

                if (tail + 1 == MAX) tail = 0;
                
                else tail++;               
            }

            public T dequeue()
            {
                if (isEmpty())
                {
                    Console.WriteLine("?????\??????????????????" +
                        "dequeue???????????????");
                }

                T x = Q[head];

                if (head + 1 == MAX)head = 0;
                
                else head++;
                
                return x;
            }
        }
    }
}

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

using namespace std;

#define MAX 5010
typedef pair<int,int> pii;

int s[MAX][MAX];

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(n),y(n);
    vector<int> X,Y;
    for(int i = 0 ; i < n ; i++){
        cin >> x[i] >> y[i];
        X.push_back(x[i]);
        Y.push_back(y[i]);
    }
    X.push_back(INT_MIN);
    Y.push_back(INT_MIN);
    
    sort(X.begin(),X.end());
    X.erase(unique(X.begin(),X.end()),X.end());
    sort(Y.begin(),Y.end());
    Y.erase(unique(Y.begin(),Y.end()),Y.end());
    for(int i = 0 ; i < n ; i++){
        int px = lower_bound(X.begin(),X.end(),x[i]) - X.begin();
        int py = lower_bound(Y.begin(),Y.end(),y[i]) - Y.begin();
        s[px][py]++;
    }
    for(int i = 1 ; i < MAX ; i++){
        for(int j = 1 ; j < MAX ; j++){
            s[i][j] += s[i-1][j]+s[i][j-1]-s[i-1][j-1];
        }
    }
    while(m--){
        int x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        x1 = lower_bound(X.begin(),X.end(),x1) - X.begin();
        y1 = lower_bound(Y.begin(),Y.end(),y1) - Y.begin();
        x2 = upper_bound(X.begin(),X.end(),x2) - X.begin() - 1;
        y2 = upper_bound(Y.begin(),Y.end(),y2) - Y.begin() - 1;
        cout << s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1] << endl;
    }
    return 0;
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var R = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray()[0];
            Console.WriteLine(Math.PI * 2 * R);
        }
    }
}

Measured memory_bytes: 19792
// Toll Gates

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    if (a <= x && x <= a+b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = (int)s.size();
    int ans = n;
    for(int i=1;i<n;++i){
        if(s[i-1]!=s[i]){
            ans = min(ans, max(i,n-i));
        }
    }
    cout << ans << endl;

    return 0;
}

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

int must(int i, int j){
    if(i==1) return 0;
    else if(i==j) return i-1;
    else return must(i-1, j-2);
}
int main() {
	int K, T; cin >> K >> T;
	int a=0, b;
	for(int i=0; i<T; ++i){
	    cin >> b;
	    if(a<b) a=b;
	}
	cout << must(a, K) << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ab = []
for _ in range(n):
    tmp = [int(x) for x in input().split()]
    ab.append(tmp)

AB = sorted(ab, key=lambda x: x[1])
ans = "Yes"
time = 0

for x in AB:
    time += x[0]
    if time > x[1]:
        ans = "No"
        break

print(ans)


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int h,w;cin>>h>>w;
	vector<vector<char>>a(h,vector<char>(w));
	rep(i,h){
		rep(j,w){
            cin>>a[i][j];
        }
	}
	rep(i,h){
		bool b=true;
		rep(j,w){
			if(a[i][j]=='#'){
				b=false;
                break;
			}
		}
		if(b){
			rep(j,w){
				a[i][j]='0';
			}
		}
	}
	rep(i,w){
		bool b=true;
		rep(j,h){
			if(a[j][i]=='#'){
				b=false;
                break;
			}
		}
		if(b){
			rep(j,h){
				a[j][i]='0';
			}
		}
	}
	rep(i,h){
        string s="";
        rep(j,w){
            if(a[i][j]!='0'){
                s.PB(a[i][j]);
            }
        }
        if(!s.empty()){
            cout<<s<<endl;
        }
    }
}

Measured memory_bytes: 256
def inpl(): return [int(i) for i in input().split()]
import numpy as np

N, K = inpl()
H = np.zeros((K,K), dtype = np.int32)
for _ in range(N):
    x, y, c = input().split() 
    x = int(x)
    y = int(y)
    t = c == 'B'
    x %= 2*K
    y %= 2*K
    if x >= K:
        x -= K
        t = not t
    if y >= K:
        y -= K
        t = not t
    if t:
        H[x][y] += 1
        continue
    H[x][y] -= 1

H = H.cumsum(axis=0)
H = H.cumsum(axis=1)

checkH = H[K-1][K-1] + 2*H
for i in range(K):
            checkH[i] -= H[i][K-1]
            checkH.T[i] -= H.T[i][K-1]

Hans = (N - checkH[K-1][K-1])//2 + checkH

print(max(np.amax(Hans), N-np.amin(Hans)))

Measured memory_bytes: 35900
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * Created by ??\??? on 2016/12/7.
 */
public class Main {
    static int si(String s){
        return Integer.parseInt(s);
    }
    static void run(String[] args) throws Exception{
        BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
        int T = si(scan.readLine());
        String[] lines1 = scan.readLine().split(" ");
        int Q = si(scan.readLine());
        String[] lines2 = scan.readLine().split(" ");
        int num = 0;
        for(String s : lines2){
            for(String ss : lines1){
                if(si(s)==si(ss)){
                    num++;
                    break;
                }
            }
        }
        System.out.println(num);
    }
    public static void main(String[] args) throws Exception{
        run(args);
    }
}

Measured memory_bytes: 27460
#include<iostream>
#include<string>
#include <algorithm>
#include<iomanip>
#include<vector>
#include<cmath>

using std::cin; using std::string;
using std::cout; using std::endl;
#define rep(X,Y) for(int (X)=0;(X)<(Y);++(X))
#define rept(X,Y,Z) for(int (X)=(Y);(X)<(Z);++(X))
#define repr(X,Y) for(int (X)=(Y);(X)>=0;--(X))
const double pi=3.141592653589793283462;

int main(){
	int p[3],j[2];
	rep(i,3){
		cin>>p[i];
		}
    rep(i,2){
		cin>>j[i];
		}
	std::sort(p,p+3);
	std::sort(j,j+2);
	cout<<p[0]+j[0]-50<<endl;
}

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

using namespace std;

int main()
{
   int n;
   cin>>n;
   string s;
   cin>>s;
   int ans=n;
   for(char ch='a';ch<='z';ch++)
   {
       int cnt=0;
       for(int i=0;i<n;i++)
       {
          if(s[i]==ch)++cnt;
          else        cnt=0;

          if(cnt>=2){cnt-=1;--ans;}
       }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 512
import sys

data = sys.stdin.readlines()

n, k = list(map(int, data[0].split()))
h = list(map(int, data[1].split()))

dp = [-1] * n
dp[0] = 0

for i in range(1, min(n, k)):
    dp[i] = min([dp[j] + abs(h[i]-h[j]) for j in range(i)])

for i in range(k, n):
    dp[i] = min([dp[i-j] + abs(h[i]-h[i-j]) for j in range(1, k+1)])

print(dp[n-1])

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define b begin()
#define e end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	(n+m<24)?cout<<n+m<<endl:cout<<(n+m)-24<<endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
const ll MAX_S_LEN=1e5,MOD=1e9+7;

string S;

ll dp[MAX_S_LEN+1][3];

int main(){
	cin>>S;
	ll p=1;
	REP(i,S.length()){
		REP(j,3) dp[i+1][j]=dp[i][j];
		if (S[i]=='?'){
			REP(j,3){
				dp[i+1][j]*=3;
				dp[i+1][j]%=MOD;
			}
		}
		if (S[i]=='A' || S[i]=='?'){
			dp[i+1][0]+=p;
			dp[i+1][0]%=MOD;
		}
		if (S[i]=='B' || S[i]=='?'){
			dp[i+1][1]+=dp[i][0];
			dp[i+1][1]%=MOD;
		}
		if (S[i]=='C' || S[i]=='?'){
			dp[i+1][2]+=dp[i][1];
			dp[i+1][2]%=MOD;
		}
		if (S[i]=='?'){
			p*=3;
			p%=MOD;
		}
	}
	cout<<dp[S.length()][2]<<endl;
	return 0;
}

Measured memory_bytes: 2816
#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 <regex>
#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()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#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 ld = long double;
using P = pair<ll,ll>;

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

void solve() {
  ll n; cin >> n;
  outl(n * (n - 1) / 2);
}

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

  solve();
}


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

int main()
{
    double n,k,x,y;
    cin >> n >>k>>x>>y;
    cout<<(n*k)/2<<endl;
    if(x==n/2&&y==k/2) cout<<1<<endl;
    else cout<<0<<endl;
    
    return 0;
}


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

public class Main {
	static final int INF = 1000000000;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		Node[] inn = new Node[101];
		int[][] dp = new int[101][101];
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int l = sc.nextInt();
			if(n == 0 && m == 0 & l == 0){
				break;
			}
			for(int i = 1; i <= n; i++){
				inn[i] = new Node(i);
			}
			Node start = inn[1];
			Node goal = inn[n];
			for(int i = 0; i < m; i++){
				int a = sc.nextInt();
				int b = sc.nextInt();
				int d = sc.nextInt();
				int e = sc.nextInt();
				
				inn[a].edges.add(new Edge(e, d, inn[b]));
				inn[b].edges.add(new Edge(e, d, inn[a]));
			}
			boolean[] flg = new boolean[n + 1];
			for(int i = 0; i <= n; i++){
				flg[i] = false;
			}
			for(int i = 1; i <= n; i++){
				for(int j = 0; j <= l; j++){
					dp[i][j] = INF;
				}
			}
			PriorityQueue<Node> q = new PriorityQueue<Node>();
			int len = 0;
			dp[1][0] = 0;
			q.add(inn[1]);
			while(!q.isEmpty()){
				Node node = q.poll();
				len = node.c;
				for(Edge e : node.edges){
					// ???????????£????????????
					if(len + e.d <= l){ // ?????¨??????????????????
						// ?????¨?????£?????´???????\???????????????°????°???????????????????
						if(dp[e.t.n][len + e.d] > dp[node.n][len]){
							Node nnode = new Node(e.t.n);
							nnode.edges = e.t.edges;
							nnode.c = len + e.d;
							q.add(nnode);
							dp[e.t.n][len + e.d] = dp[node.n][len] ;
						}
					}
					// ????????£???????????????
					// ?????¨??????????????´???????\???????????????°????????????
					if(dp[e.t.n][len] > dp[node.n][len] + e.e){
						Node nnode = new Node(e.t.n);
						nnode.edges = e.t.edges;
						nnode.c = len;
						q.add(nnode);
						dp[e.t.n][len] = dp[node.n][len] + e.e;
					}
				}
			}
			
			int min = INF;
			for(int i = 0; i <= l; i++){
				min = Math.min(min, dp[n][i]);
			}
			System.out.println(min);
//			System.out.println(func(start, l, goal, flg));
			
		}
		
		
		sc.close();
	}
	static int func(Node node, int cap, Node goal, boolean[] flg){
		int res = 1000000000;
		if(node.equals(goal)){
			return 0;
		}
		for(Edge e : node.edges){
			if(!flg[e.t.n]){
				if(e.d > cap){
					flg[node.n] = true;
					res = Math.min(res, func(e.t, cap, goal, flg) + e.e);
					flg[node.n] = false;
				}else{
					flg[node.n] = true;
					res = Math.min(res, Math.min(func(e.t, cap - e.d, goal, flg), func(e.t, cap, goal, flg) + e.e));
					flg[node.n] = false;
				}
			}
		}
		
		return res;
	}

}
class Node implements Comparable<Node>{
	int n;
	int c;
	LinkedList<Edge> edges;
	Node(int number){
		edges = new LinkedList<Edge>();
		n = number;
		c = 0;
	}
	@Override
	public int compareTo(Node o) {
		// TODO Auto-generated method stub
		return n - o.n;
	}
}
class Edge{
	boolean flg;
	int e;
	int d;
	Node t;
	Edge(int enemy, int dist, Node to){
		e = enemy;
		d = dist;
		t = to;
		flg = false;
	}
}

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

using namespace std;


int main(){
    int num_query;
    int command,val;
    char key[20];

    scanf("%d",&num_query);
    map<string,int> map_array;

    for(int i = 0;i < num_query;i++){
        scanf("%d %s",&command,key);
        if(command == 0){
            scanf("%d",&val);
            if(map_array.find(key) != map_array.end()) map_array[key] = val;
            else map_array.insert(make_pair(key,val));
        }else if(command == 1){
            printf("%d\n",map_array[key]);
        }
    }

    return 0;   
}


Measured memory_bytes: 26040