akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

int main()
{
    long long n;
    std::cin >> n;
    
    long long* arr = new long long[n];
    
    for (long long i = 0; i < n; ++i)
    {
        std::string line;
        std::getline(std::cin, line, ' ');
        arr[i] = std::stoll(line);
    }
    
    long long min;
    long long max;
    long long sum = 0;
    for (long long i = 0; i < n; ++i)
    {
        if (i == 0)
            min = max = arr[i];
        else
        {
            if (arr[i] < min)
                min = arr[i];
            if (arr[i] > max)
                max = arr[i];
        }
        
        sum += arr[i];
    }
    
    delete[] arr;
    
    std::cout << min << " " << max << " " << sum << std::endl;
    
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>

using namespace std;
int main() {
  int n, y;
  cin >> n >> y;

  int i, j;
  bool iFlg=false;
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      if(i+j>n)break;
      if(10*i+5*j+(n-(i+j))==y/1000){
        iFlg=true;
        break;
      }
    }
    if(iFlg)break;
  }

  if(iFlg){
    cout << i << " " << j << " " << n-(i+j) << endl;
  } else {
    cout << "-1 -1 -1" << endl;
  }

  return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int P=in(),Q=in(),R=in();
	
	cout << min({P+Q,P+R,Q+R}) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int po[256];

int main(){
  string s;
  cin>>s;
  REP(i,s.size())po[s[i]]++;
  bool flag = true;
  REP(i,256)flag &= po[i]%2==0;
  puts(flag?"Yes":"No");
  return 0;
}


Measured memory_bytes: 256
import Foundation

let X = Int(readLine()!)!

func powFive(_ x: Int) -> Int {
    return x * x * x * x * x
}

outer: for A in -200...200 {
    for B in -200...200 {
        if powFive(A) - powFive(B) == X {
            print(A, B)
            break outer
        }
    }
}


Measured memory_bytes: 13188
<?php
list($r,$c)=explode(' ',trim(fgets(STDIN)),2);

$C=$c+1;
$s=array($C);
for($j=0;$j<$C;$j++)$s[$j]=0;

for($i=0;$i<$r;$i++){
  $D=trim(fgets(STDIN));
  $d=explode(' ',$D,$c);
  $S=0;
  for($j=0;$j<$c;$j++){
    $S+=$d[$j];
    $s[$j]+=$d[$j];
  }
  $s[$c]+=$S;
  echo $D,' ',$S,PHP_EOL;
}

echo implode(' ',$s);
?>

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

using namespace std;

const int MOD = 1e9 + 7;
const int MAXN = 2e5;
vector <int> g[MAXN];

int n, k;

int dfs(int v, int start, int p=-1) {
    int ans = start;
    int cur = k - 1;
    if (v != 1) cur--;
    for (auto u : g[v]) {
        if (u == p) continue;
        ans = (ans * (long long)dfs(u, cur, v)) % MOD;
        cur--;
    }
    return ans;
}

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cout << dfs(1, k);
    return 0;
}


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

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

	vector<int> a(n);
	double s = 0;
	for (int& ai : a) {
		cin >> ai;
		s += double(ai);
	}

	int k = 0;
	double t = s / (4 * double(m));
	for (int ai : a) {
		if (double(ai) >= t) {
			++k;
		}
	}

	cout << (k >= m ? "Yes" : "No");
	
	return 0;
}
	

Measured memory_bytes: 256
#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>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int m,f;
  while (scanf("%d %d\n",&m,&f)!=EOF) {
    if (m*f%2==0) {
      printf("Even\n");
    }else{
      printf("Odd\n");
    }
  }

  return 0;
}


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

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  bool ans = true;
  if(s.at(0) != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  int count = 0;
  int index = 0;
  for(int i = 2; i < s.size() - 1; i++){
    if(s.at(i) == 'C'){
      count++;
      index = i;
    }
  }
  if(count != 1){
    cout << "WA" << endl;
    return 0;
  }
  for(int i = 1; i < s.size(); i++){
    if(i != index){
      if( s.at(i) >= 'a' && s.at(i) <= 'z'){

      }else{
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<ll> a;
    ll b;
    rep(i,n){
        cin >> b;
        a.push_back(b);
    }
    SORT(a);
    ll ans = 0;
    rep(i,k) ans += a[i];
    PRINT(ans);
}


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

int main() {
	int n, m;
	cin>>n>>m;
	int sum =0;
	for (int i=0 ;i<m; i++) {
		int t;
		cin>>t;
		sum+=t;
	}
	if(sum > n) {
		cout << -1;
	} else {
		cout << n-sum;
	}
	return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<string.h>
#define FR(N) for(int i = 0;i < N;i++)
#define PR(N) printf("%s\n",N);
int main(void){
  int n,k;
  scanf("%d %d",&n,&k);
  char s[n + 1];
  scanf("%s",&s);
  s[k - 1] += 32;
  PR(s);
  return 0;
}

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

int main() {

	int N, H[100] = {0};
	int cnt = 0, high = 0;
	
	cin >> N;
	
	for(int i = 0; i < N; i++){
		cin >> H[i];
	}
	
	cnt++;
	high = H[0];

	for(int i = 1; i < N; i++){
		if(high <= H[i]){
			high = H[i];
			cnt++;
		}
	}
	
	cout << cnt << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};



int32_t main()
{

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


int n;
cin>>n;

int sum=0;
vector<int>cnt(200005);
for(int i=0;i<n;i++)
{
    int x;
     cin>>x;
     cnt[x]++;
     sum+=x;
}

int q;
cin>>q;
while(q--)
{
    int b,c;
    cin>>b>>c;
    sum+=cnt[b]*(c-b);
    cnt[c]+=cnt[b];
    cnt[b]=0;
    cout<<sum<<"\n";
}



}

Measured memory_bytes: 4776
import numpy as np
import math
import itertools

def distance(a, b):
    return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)

def mkdistancelist(N):
    List = list(map(str, [i for i in range(N)]))
    return list(itertools.combinations(List, 2))

def mkmap(N):
    placelist = []
    for i in range(N):
        place = list(map(int, input().split()))
        placelist.append(place)
    return placelist

def caldis(N):
    pairs = mkdistancelist(N)
    placelist = mkmap(N)
    dic = {}
    for pair in pairs:
        label = "".join(pair)
        dic[label] = distance(placelist[int(pair[0])], placelist[int(pair[1])])
    return dic

def mkwayslist(N):
    List = list(map(str, [i for i in range(N)]))
    return list(itertools.permutations(List, N))
            
def mknumdic(ways):
    numdic = {}
    for way in ways:
        for l in range(N-1):    
            tup = sorted((way[l], way[l+1]))
            tup = tup[0] + tup[1]
            if numdic.get(tup) == None:
                numdic[tup] = 1
            else:
                numdic[tup] = numdic[tup] + 1
    return numdic


N = int(input())
dic = caldis(N)
ways = mkwayslist(N)
numdic = mknumdic(ways)

av = np.average(np.array(list(dic.values())))
ans = av * (N-1)
print(ans)


Measured memory_bytes: 18868
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int m, f, r;
	while (cin >> m >> f >> r) {
		if (m == -1 && f == -1 && r == -1)
			break;
		if (m == -1 || f == -1)
			cout << "F" << endl;
		else if (m + f >= 80)
			cout << "A" << endl;
		else if (m + f >= 65)
			cout << "B" << endl;
		else if (m + f >= 50 || r >= 50)
			cout << "C" << endl;
		else if (m + f >= 30)
			cout << "D" << endl;
		else
			cout << "F" << endl;
	}
}



Measured memory_bytes: 3156
object Main extends App {
  import scala.io.StdIn._
  val n = readInt()
  val nums = readLine().trim.split(' ').map(_.toInt)
  val sorted = nums.sorted
  println(
    if (nums.zip(sorted).count{case (a, b) => a != b} <= 2) "YES" else "NO"
  )
}

Measured memory_bytes: 27332
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


A, B, M = MI()
A = LMI()
B = LMI()

minA = min(A)
minB = min(B)
ans = minA + minB
for _ in range(M):
    x, y, c = MI()
    ans = min(ans, A[x - 1] + B[y - 1] - c)
print(ans)

Measured memory_bytes: 64800
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int h, w;
    while (cin >> h >> w, h || w)
    {
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
                cout << '#';
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
#include<utility>

using namespace std;

typedef struct node_T
{
        vector<int> neighbor;
        int score;
}node;

int getLeaf(int n, node* tree);
void removeNode(int a, int b, node* tree);

int main(){
        int n;
        cin >> n;
        node* tree = new node[n];
        for(int i=0;i<n-1;i++){
                int a,b;
                cin >> a >> b;
                tree[a-1].neighbor.push_back(b-1);
                tree[b-1].neighbor.push_back(a-1);
        }

        int* label = new int[n];
        for(int i=0;i<n;i++){
                int c;
                cin >> c;
                label[i] = c;
        }

        sort(label, label + n);

        long sum=0;
        int l, nei;
        for(int i=0;i<n-1;i++){
                l = getLeaf(n, tree);
                nei = tree[l].neighbor[0];
                removeNode(l, nei, tree);
                tree[l].score = label[i];
                sum += label[i];
        }

        tree[nei].score = label[n-1];

        cout << sum << endl;
        for(int i=0;i<n;i++){
                cout << tree[i].score << " ";
        }
        cout << endl;
}


int getLeaf(int n, node* tree)
{
        for(int i=0;i<n;i++){
                if(tree[i].neighbor.size() == 1){
                        return i;
                }
        }

        return -1;
}


void removeNode(int a, int b, node* tree)
{
        int size = tree[a].neighbor.size();
        if(size > 1){
                for(int i=0;i<tree[a].neighbor.size();i++){
                        if(tree[a].neighbor[i] == b){
                                swap(tree[a].neighbor[i], tree[a].neighbor[size-1]);
                        }
                }
        }
        tree[a].neighbor.pop_back();
        size = tree[b].neighbor.size();
        if(size > 1){
                for(int i=0;i<tree[b].neighbor.size();i++){
                        if(tree[b].neighbor[i] == a){
                                swap(tree[b].neighbor[i], tree[b].neighbor[size-1]);
                        }
                }
        }
        tree[b].neighbor.pop_back();

}

Measured memory_bytes: 1024
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n';
#define no cout<<"No"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  t,i,x,j,k,a,b,c,ans=0;
    cin>>a>>b>>c;
    if(a+b>=c)
    {
        ans=b+c;
    }
    else
    {

        ans=2*min(b,c);
        c=max(0LL,c-b);
   // cout<<ans<<" "<<c<<endl;
        ans+=min(c,a);
   // cout<<ans<<endl;
        c-=min(c,a);
   // cout<<ans<<" "<<c<<endl;
        if(c>0) ans++;
    }

    cout<<ans<<endl;

    return 0;
}





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

typedef long long ll;

int main(){
        int a,b;
        cin>>a>>b;
        int A,B;
        A=max(a,b),B=min(a,b);
        for(int i=0;i<A;i++){
                cout<<B;
        }
        cout<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i,N) cin >> D[i];
    if(24 <= N) cout << 0 << endl;
    else if(12 <= N){
        vector<int> d(13,0);
        rep(i,N) d[D[i]]++;
        d[0] += 2;
        bool flag = true;
        rep(i,12){
            if(d[i] > 2){
                flag = false;
                break;
            }
        }
        if(flag) cout << 1 << endl;
        else cout << 0 << endl;
    }
    else{
        int ans = 0;
        rep(bit, 1 << N){
            vector<int> zikan;
            zikan.push_back(0);
            rep(j,N){
                if(D[j] == 12 or D[j] == 0) zikan.push_back(D[j]);
                else{
                    if(bit >> j & 1) zikan.push_back(D[j]);
                    else zikan.push_back(24-D[j]);
                }
            }
            sort(zikan.begin(), zikan.end());
            int res = 100;
            rep(i,N) res = min(res, zikan[i+1]-zikan[i]);
            res = min(res, 24-zikan[N]);
            ans = max(ans, res);
        }
        cout << ans << endl;
    }
}   


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int	main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> b(n);
	for (int i = 0; i < n; i++) cin >> b[i];
	int index = -1;
	int max_cnt = 0;
	int cnt = 0;
	int pre = 0;
	int pre_index = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == b[i])
		{
			if (pre == a[i]) cnt++;
			else
			{
				if (cnt > max_cnt) index = pre_index, max_cnt = cnt;
				cnt = 1;
				pre = a[i];
				pre_index = i;
			}
		}
	}
	if (cnt > max_cnt) index = pre_index;
	if (index == -1)
	{
		cout << "Yes" << endl;
		for (int i = 0; i < n; i++)
		{
			cout << b[i];
			if (i != n - 1) cout << " ";
			else cout << endl;
		}
		return (0);
	}
	int counter = 0;
	for (int j = 1; j < n; j++)
	{
		if (a[index] != b[(index + j) % n])
		{
			bool flag = true;
			for (int k = 0; k < n; k++) flag &= (a[k] != b[(k + j) % n]);
			if (flag)
			{
				cout << "Yes" << endl;
				for (int k = 0; k < n; k++)
				{
					cout << b[(k + j) % n];
					if (k != n - 1) cout << " ";
					else cout << endl;
				}
				return (0);
			}
			counter++;
			if (counter > 1000) break ;
		}
	}
	cout << "No" << endl;
	return (0);
}

/*
7
1 1 3 4 4 4 5
1 1 2 4 4 4 5
*/

Measured memory_bytes: 4848
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    if(x-r >= 0 && y-r >= 0 && y+r<=h && x+r<=w)
        cout<< "Yes" << endl;
    else
        cout<< "No" << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#define pub push_back
#define pii pair<int, int>
#define fst first
#define snd second
#define mkp make_pair
using namespace std;
 
const int LG = 20;
const int MN = -1e9;
int mx = 0, crfinvl = 0, n, m, seg[1 << LG] = {}, lazy[1 << LG] = {};
vector<pii> interval;
 
inline void prop(int idx, int L, int R)
{
	if (lazy[idx])
	{
		seg[idx] -= lazy[idx];
		if (L < R)
		{
			lazy[2 * idx] += lazy[idx];
			lazy[2 * idx + 1] += lazy[idx];
		}
		lazy[idx] = 0;
	}
}
 
void build(int idx, int L, int R)
{
	if (L < R)
	{
		int M = (L + R) >> 1;
		build(2 * idx, L, M);
		build(2 * idx + 1, M + 1, R);
		seg[idx] = max(seg[2 * idx], seg[2 * idx + 1]);
	}
	else {seg[idx] = L;}
}
 
void upd(int idx, int L, int R, int x)
{
	prop(idx, L, R);
	if (x <= R)
	{
		if (x <= L)
		{
			lazy[idx]++;
			prop(idx, L, R);
		}
		else
		{
			int M = (L + R) >> 1;
			upd(2 * idx, L, M, x);
			upd(2 * idx + 1, M + 1, R, x);
			seg[idx] = max(seg[2 * idx], seg[2 * idx + 1]);
		}
	}
	//cout<<"UPD "<<idx<<" "<<L<<" "<<R<<" "<<seg[idx]<<"\n";
}
 
int qry(int idx, int L, int R, int l, int r)
{
	prop(idx, L, R);
	if (l <= r)
	{
		//cout<<"QRY "<<L<<" "<<R<<" "<<l<<" "<<r<<"\n";
		if (l == L && r == R) {return seg[idx];}
		int M = (L + R) >> 1;
		return max(qry(2 * idx, L, M, l, min(r, M)),qry(2 * idx + 1, M + 1, R, max(l, M + 1), r));
	}
	return MN;
}
 
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	mx = max(0, n - m);
	for (int i = 0; i < n; i++)
	{
		pii a; cin >> a.fst >> a.snd;
		a.fst++; a.snd--;
		if (a.fst <= a.snd) {interval.pub(a);}
	}
	build(1, 1, m + 1);
	sort(interval.begin(), interval.end());
	int j = 0;
	for (int i = 1; i <= m; i++)
	{
		crfinvl = max(crfinvl, i);
		for (; j < interval.size() && interval[j].fst <= i; j++)
		{
			//cout<<"Insert Interval : "<<interval[j].fst<<" "<<interval[j].snd<<"\n";
			upd(1, 1, m + 1, interval[j].snd + 1);
			crfinvl = max(crfinvl, interval[j].snd);
			//cout<<"After Update : "<<seg[1]<<"\n";
		}
		//cout<<qry(1, 1, m + 1, i, crfinvl) + j - i - m + 1<<"\n";
		mx = max(mx, qry(1, 1, m + 1, i, crfinvl) + j - i - m + 1); 
	}
	cout << mx << "\n";
	return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> wsum(n+1);
    wsum[0] = 0;
    int w;
    rep(i,n){
        cin >> w;
        wsum[i+1] += wsum[i] + w;
    }
    int ans = 1e8;
    for(int i = 1; i < n; i++){
        if(ans > abs(wsum[n] - 2*wsum[i])) ans = abs(wsum[n] - 2*wsum[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N, K, C;
	string S;
	cin >> N >> K >> C >> S;
	vector<int> L, R;
	int l = 0, r = N - 1;
	REP(cnt, K) {
		while (S[l] == 'x') ++l;
		L.push_back(l);
		l += C + 1;
		while (S[r] == 'x') --r;
		R.push_back(r);
		r -= C + 1;
	}
	REV(R);
	REP(i, K) {
		if (L[i] == R[i]) cout << L[i] + 1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> s[i][j];
    }
  }
  vector<vector<bool>> M(H + 2, vector<bool>(W + 2, 0));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (i % 4 == 0 && j % 4 == 0 && s[i][j] == '6'){
        M[i + 1][j + 1] = true;
      }
      if (i % 4 == 2 && j % 4 == 2 && s[i][j] == '6'){
        M[i + 1][j + 1] = true;
      }
      if (i % 4 == 0 && j % 4 == 2 && s[i][j] == '1'){
        M[i + 1][j + 1] = true;
      }
      if (i % 4 == 2 && j % 4 == 0 && s[i][j] == '1'){
        M[i + 1][j + 1] = true;
      }
      if (i % 4 == 1 && j % 2 == 0 && s[i][j] == '2'){
        M[i + 1][j + 1] = true;
      }
      if (i % 4 == 3 && j % 2 == 0 && s[i][j] == '5'){
        M[i + 1][j + 1] = true;
      }
      if (i % 2 == 0 && j % 4 == 1 && s[i][j] == '3'){
        M[i + 1][j + 1] = true;
      }
      if (i % 2 == 0 && j % 4 == 3 && s[i][j] == '4'){
        M[i + 1][j + 1] = true;
      }
    }
  }
  if (debug){
    for (int i = 0; i < H + 2; i++){
      for (int j = 0; j < W + 2; j++){
        cout << M[i][j];
      }
      cout << endl;
    }
  }
  queue<pair<int, int>> Q;
  Q.push(make_pair(1, 1));
  vector<vector<bool>> U(H + 2, vector<bool>(W + 2, false));
  U[1][1] = true;
  while (!Q.empty()){
    int y = Q.front().first;
    int x = Q.front().second;
    if (debug){
      cout << "y=" << y <<",x=" << x << endl;
    }
    Q.pop();
    if (M[y + 1][x] && !U[y + 1][x]){
      Q.push(make_pair(y + 1, x));
      U[y + 1][x] = true;
    }
    if (M[y - 1][x] && !U[y - 1][x]){
      Q.push(make_pair(y - 1, x));
      U[y - 1][x] = true;
    }
    if (M[y][x + 1] && !U[y][x + 1]){
      Q.push(make_pair(y, x + 1));
      U[y][x + 1] = true;
    }
    if (M[y][x - 1] && !U[y][x - 1]){
      Q.push(make_pair(y, x - 1));
      U[y][x - 1] = true;
    }
  }
  if (U[H][W]){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

public class Main {

	public static void main(String[] args) 
	{
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int p = sc.nextInt();
		
		StringBuilder[] sb = new StringBuilder[n];
		int size[] = new int[n];
		
		for(int i = 0; i < n; i++)
		{
			sb[i] = new StringBuilder();
		}
		
		for(int i = 0; i < p; i++)
		{
			int com = sc.nextInt();
			if(com == 0)
			{
				int id = sc.nextInt();
				int item = sc.nextInt();
				
				if(size[id] > 0)sb[id].append(" ");
				sb[id].append(item);
				size[id]++;
			}
			else if(com == 1)
			{
				int id = sc.nextInt();
				System.out.println(sb[id]);
			}
			else if(com == 2)
			{
				int id = sc.nextInt();
				size[id] = 0;
				sb[id] = new StringBuilder();
			}
		}
		
		
	}
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 

}



Measured memory_bytes: 114324
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	string tmp = "CODEFESTIVAL2016";
	int cnt = 0;
	for(int i = 0;i < s.size();i++){
		if(s[i] != tmp[i])cnt++;
	}
	cout << cnt << endl;

}

Measured memory_bytes: 256
import math

a,b,h,m=map(int,input().split())

hc=360/12*h+30/60*m #時針の角度
mc=360/60*m #分針の角度
hm=abs(hc-mc) #時針と分針の角度の差
if hm > 180:
    hm=360-hm

mcos=math.cos(math.radians(hm))
c=a**2+b**2-(2*a*b*mcos) #余剰定理

print(math.sqrt(c))

Measured memory_bytes: 9376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int r,c,num;
  cin>>r>>c;
  vector<vector<int> > vec(r+1, vector<int>(c+1));
  rep(i,r){
    rep(j,c){
      cin >> num;
      vec.at(i).at(j) = num;
      vec.at(i).at(c) += num;
      vec.at(r).at(j) += num;
      vec.at(r).at(c) += num;
    }
  }
  rep(i,r+1){
    rep(j,c+1){
      if (j != c) printf("%d ",vec.at(i).at(j));
      else {printf("%d\n",vec.at(i).at(j));}
    }
  }
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#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)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

int main() {
  ll k;
  cin >> k;
  priority_queue<ll, vector<ll>, greater<ll>> que;
  rep(i, 9) que.push(i + 1);
  rep(i, k - 1) {
    ll x = que.top();
    que.pop();
    if (x % 10 != 0) que.push(x * 10 - 1 + x % 10);
    que.push(10 * x + x % 10);
    if (x % 10 != 9) que.push(x * 10 + 1 + x % 10);
  }
  cout << que.top() << endl;
  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int count = 0, ans = 0;;
  for(char a: S) {
    if(a == 'A') count++;
    else if(a == 'T') count++;
    else if(a == 'G') count++;
    else if(a == 'C') count++;
    else count = 0;
    ans = max(count, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
char graph[10][10];
int n,m;
int row[10];
memset(row,0,sizeof row);
cin>>n>>m;
getchar();
for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        cin>>graph[i][j];
        if(graph[i][j]=='#')row[i]++;
    }
    getchar();
}
int ck=0;
int j=0,i=0;
while(i<n){
        int cnt=0;
    while(j<m){
        if(graph[i][j]=='.')
            break;
        if(graph[i][j]=='#')
        cnt++;
        j++;
    }
    j--;
//cout<<cnt<<" "<<row[i]<<""<<j<<endl;
if(cnt!=row[i])
    {
        ck=1;
        break;
    }
i++;
}
    if(ck)
        printf("Impossible\n");
    else
        printf("Possible\n");
}


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

// 
int main() {
    string S;
    cin >> S;
    if (S == "RRR") {
        cout << 3;
        return 0;
    }
    if (S == "RRS" || S == "SRR") {
        cout << 2;
        return 0;
    }
    if (S[0] == 'R' || S[1] == 'R'|| S[2] == 'R') {
        cout << 1;
        return 0;
    }
    cout << 0;
}


Measured memory_bytes: 3592
a=int(input())
b=int(input())
c=int(input())
x=int(input())
s=[]
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            s.append(500*i+100*j+50*k)
print(s.count(x))  

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi a(n);
  int su = 0;
  REP(i, n) {
    cin >> a[i];
    su += a[i];
  }

  su = su / 2 + su % 2;

  const int sz = 2000 * 2000 + 1;
  bitset<sz> dp;
  dp[0] = 1;
  REP(i, n) {
    dp |= (dp<<a[i]);
  }

  int ans = 0;
  FOR(i, su, sz+1) {
    if(dp[i]) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;

}
























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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(N, 0);
    rep(i, N){
        int a;
        cin >> a;
        A[a]++;
    }

    if(N % 2 ==0){
        bool flag = true;
        for(int i = 1; i < N; i += 2){
            if(A[i] != 2){
                flag = false;
                break;
            }
        }
        if(flag){
            ll ans = 1;
            rep(i, N / 2){
                ans = ans * 2 % INF;
            }
            cout << ans << endl;
        }
        else cout << 0 << endl;
    }
    else{
        bool flag = true;
        if(A[0] != 1) flag = false;

        for(int i = 2; i < N; i += 2){
            if(A[i] != 2){
                flag = false;
                break;
            }
        }

        if(flag){
            ll ans = 1;
            rep(i, N / 2){
                ans = ans * 2 % INF;
            }
            cout << ans << endl;
        }
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  string n_origin = n;

  reverse(n.begin(), n.end());
  if (n == n_origin){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
let i=readLine()!.characters.split(" ").map{Int(String($0))!},m=1000000007
func f(x:Int)->Int{return (1...x).reduce(1){$0*$1%m}}
print(f(i[0])*f(i[1])*max(2-abs(i[0]-i[1]),0)%m)

Measured memory_bytes: 4208
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
using namespace std;

// s.....0=�{�� 1=����
int n, m, s = 0, c = 0;
char u[256][11] = {}, t[256][11] = {};

int check(int a, int b);

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", &u[i]);
	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%s", &t[i]);
	}

	for (int i = 0; i < m; i++) {
		c = 0;

		for (int j = 0; j < n; j++) {
			if (check(j,i)) {
				c = 1;
				if (s == 0) {
					printf("Opened by %s\n", t[i]);
					s = 1;
					break;
				}
				if (s == 1) {
					printf("Closed by %s\n", t[i]);
					s = 0;
					break;
				}
			}
		}

		if (c == 0) {
			printf("Unknown %s\n", t[i]);
		}
	}
	return 0;
}

int check(int a, int b) {
	for (int i = 0; i < 10; i++) {
		if (u[a][i] != t[b][i])
			return 0;
	}
	return 1;
}


Measured memory_bytes: 3232
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a,b=gets.chomp.split
aa=a*b.to_i
bb=b*a.to_i
puts min(aa,bb)

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> pro(n);
    for (int i=0; i<n; ++i) {
        cin >> pro.at(i).first >> pro.at(i).second;
        ++pro.at(i).second;
    }

    int maxl1 = 0, maxl2 = 0, minr1 = INF+1, minr2 = INF+1;
    for (auto p : pro) {
        int l = p.first, r = p.second;
        if (l > maxl1) maxl2 = maxl1, maxl1 = l;
        else if (l > maxl2) maxl2 = l;
        if (r < minr1) minr2 = minr1, minr1 = r;
        else if (r < minr2) minr2 = r;
    }
    int res = 0;
    for (auto p : pro) {
        int l = p.first, r = p.second;
        int maxl = maxl1 == l ? maxl2 : maxl1;
        int minr = minr1 == r ? minr2 : minr1;
        chmax(res, r - l + max(0, minr - maxl));
    }
    sort(pro.begin(), pro.end());
    vector<int> dp(n-1);
    int l = 0, r = INF+1;
    for (int i=0; i<n-1; ++i) {
        chmax(l, pro.at(i).first);
        chmin(r, pro.at(i).second);
        dp.at(i) += r - l;
    }
    l = 0, r = INF+1;
    for (int i=n-1; i>0; --i) {
        chmax(l, pro.at(i).first);
        chmin(r, pro.at(i).second);
        dp.at(i-1) += r - l;
    }
    for (auto x : dp) chmax(res, x);
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() {
    int  R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for (int r = 0; r <= N/R; r++) {
        for (int g = 0; g <= N/G; g++) {
            if (r*R+g*G<=N && (N-(r*R+g*G))%B == 0) ans ++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int count = 0;
  string s,t;
  cin >> s >> t;
  int len = s.size();
  for ( int i = 0 ; i < len ; i++ ) {
    if (s.at(i)!=t.at(i)) {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int gcd(int a,int b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

int main(){
  int n;
  cin >> n;
  vector<int> d(1000001,1);
  for(int i=2;i<1000001;i++){
    int j = i;
    while(j<1000001){
      if(d[j] == 1) d[j] = i;
      j += i;
    }
  }
  map<int,int> mp;
  int allgcd = 0;
  rep(i,n){
    int a;
    cin >> a;
    if(i == 0) allgcd = a;
    else allgcd = gcd(allgcd,a);
    set<int> st;
    while(a > 1){
      st.insert(d[a]);
      a /= d[a];
    }
    for(int s : st){
      mp[s] ++;
    }
  }
  bool fail = 0;
  for(auto p : mp){
    if(p.second > 1) fail = 1;
  }
  if(!fail)cout << "pairwise coprime" << endl;
  else if(allgcd == 1) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
}


Measured memory_bytes: 10896
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

ll a[101010], c[101010], ql[101010], qr[101010];

ll mod_pow(ll p) {
    if(p < 0) return 0;
    ll ret = 1, x = 3;
    while(p) {
        if(p & 1) ret = (ret * x) % MOD;
        x = (x * x) % MOD;
        p >>= 1;
    }
    return ret;
}


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    ll ans = 0;
    for(int i=0; i < s.size()-1;++i) {
        if(s[i]=='A') {
            a[i+1] = a[i] + 1;
            ql[i+1] = ql[i];
        } else if(s[i]=='?') {
            a[i+1] = a[i];
            ql[i+1] = ql[i] + 1;
        } else {
            a[i+1] = a[i];
            ql[i+1] = ql[i];
        }
    }
    for(int i=s.size()-1; i >= 0; --i) {
        if(s[i]=='C') {
            c[i-1] = c[i] + 1;
            qr[i-1] = qr[i];
        } else if(s[i]=='?') {
            c[i-1] = c[i];
            qr[i-1] = qr[i] + 1;
        } else {
            c[i-1] = c[i];
            qr[i-1] = qr[i];
        }
    }

    for(int i=0; i < s.size(); ++i) {
        if(s[i]=='?' || s[i]=='B') {
            ans = (ans + a[i] * c[i] % MOD * mod_pow(ql[i] + qr[i]) % MOD) % MOD;
            
            ans = (ans + ql[i] * qr[i] % MOD * mod_pow(ql[i] + qr[i] - 2) % MOD) % MOD;

            ans = (ans + a[i] * qr[i] % MOD * mod_pow(ql[i] + qr[i] - 1) % MOD) % MOD;

            ans = (ans + ql[i] * c[i] % MOD * mod_pow(ql[i] + qr[i] - 1) % MOD) % MOD;
        }
    }

    cout << ans << '\n';
    return 0;
}

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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int a, b, c;
        cin >> a >> b >> c;
        if (a + b + c >= 22) {
            cout << "bust" << endl;
        } else {
            cout << "win" << endl;
        }
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  int sum=0;
  int max=0;
  for(int i=0;i<n;i++){
    cin >> p[i];
    sum += p[i];
    if(max<p[i]){
      max=p[i];
    }
  }
  cout << sum-max/2 << "\n";
  
 

  return 0;
}



Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n; readV(n);
  string[] w; readC(n, w);

  auto h = [w[0]: true];
  foreach (i; 1..n) {
    if (w[i][0] != w[i-1][$-1] || w[i] in h) {
      writeln("No");
      return;
    }
    h[w[i]] = true;
  }

  writeln("Yes");
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = saori.saori_hayami();
		}
		int ans = 0;
		for(int i = 0;i < n;i++){
			while(a[i] % 2 == 0){
				ans++;
				a[i] /= 2;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22456
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;

ll ans, mx, mn, flag, sum, cnt;

int main(){
	string s;
	cin>>s;
	for(ll i=0; i<4; i++) {
		if(s[i]=='+') ans++;
		else ans--;
	}
	cout<<ans;
}


Measured memory_bytes: 256
f=n=0
while 1:
 a=input()
 if a.isdigit():
  if n==1:s=s[int(a):]
  n=1
 else:
  if f==1:print(s[:l])
  if'-'==a:break
  f=1
  n=0
  l=len(a)
  s=a*100

Measured memory_bytes: 5620