akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	string s;
	string t;
	cin >> s >> t;
	
	int a[30] = {0}, b[30] = {0};
	int n = s.size(), m = t.size();
	
	for(int i = 0; i < n; i++)
		a[s[i]-'a']++;
	for(int i = 0; i < m; i++)
		b[t[i]-'a']++;
	
	for(int i = 0; i < 28; i++){
		if(b[i] && (a[i] == 0)){
			cout << -1;
			return 0;
		}
	}
	int dp[n+1][26];
	for(int i = 0; i < 26; i++){
		dp[n][i] = -1;
	}
	for(int i = n-1; i >= 0; i--){
		for(int j = 0; j < 26; j++)
			dp[i][j] = dp[i+1][j];
			
		dp[i][s[i]-'a'] = i;
	}
	int ans = 0, last = -1;
	for(int i = 0; i < m; i++){
		if(dp[last+1][t[i]-'a'] != -1){
			last = dp[last+1][t[i]-'a'];
		}
		else{
			ans += n;
			last = dp[0][t[i]-'a'];
		}
	}
	ans += last+1;
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 20864
#pragma once
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <queue>

using namespace std;

using i8 = char;
using u8 = unsigned char;
using i32 = int;
using u32 = unsigned int;
using i64 = long long int;
using u64 = unsigned long long int;

using pii = pair<i32, i32>;

#define LOOP_TYPE(s, n) decltype((n) - (s))
#define FOR(i, s, n) for (auto i = LOOP_TYPE(s, n)(s); i != LOOP_TYPE(s, n)(n); i++)
#define FORR(i, s, n) for (auto i = LOOP_TYPE(s, n)(n) - 1; i != LOOP_TYPE(s, n)(s) - 1; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FORR(i, 0, n)

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

using graph = map<i32, vector<i32>>;

void dfs(i32 depth, i32 curr, graph& g, vector<i32>& d)
{
	d[curr] = depth;
	for (const auto& next : g[curr]) {
		if (d[next] >= 0) continue;
		dfs(depth + 1, next, g, d);
	}
}

int main() {
  i32 N;
  graph g;
  cin >> N;
  REP(i, N-1) {
    i32 a, b;
    cin >> a >> b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }

  vector<i32> distance_fennec(N + 1, -1);
  dfs(0, 1, g, distance_fennec);

  vector<i32> distance_snuke(N + 1, -1);
  dfs(0, N, g, distance_snuke);

  i32 fennec_visited = 0;
  i32 snuke_visited = 0;
  for (i32 i = 1; i <= N; i++) {
	  if (distance_fennec[i] <= distance_snuke[i]) {
		  fennec_visited++;
	  } else {
		  snuke_visited++;
	  }
  }

  if (fennec_visited <= snuke_visited) {
	  puts("Snuke");
  } else {
	  puts("Fennec");
  }

  return 0;
}


Measured memory_bytes: 21376
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



int main() {

  long n;
  cin >> n;
  vector<long> s(n);
  cin >> s;

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


  long sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += s[i];
    cerr << s[i]<<endl;
  }


  if (sum % 10 == 0) {
    for (int i = 0; i < n; i++) {
      if ((sum - s[i] ) % 10 != 0) {
        sum = sum - s[i];
        break;
      }


          if (i==n-1){
      sum=0;
      break;
    }
    }
  }

  cout << sum;


}




















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), x.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  int n;
  cin >> n;
  vector<int> a(n), b(n-1);
  REP(i, n-1) cin >> b[i];
  
  a[0] = b[0];
  REP(i, n-1){
    a[i+1] = b[i];
    if(i+1 < n-1 && b[i+1] < b[i]) a[i+1] = b[i+1];
  }

  int ans = 0;
  REP(i, n) ans += a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	int count=0,i;
	for(i=0;i<s.length();i++)
	{
		int temp=s[i]-'0';
		count+=temp;
	}
	if(count%9==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,x,p,now;
  cin >> n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  
  x=1001001001;
  for(p=1;p<=100;p++){
     now=0;
  for(int i=0;i<n;i++){
    now+=(vec.at(i)-p)*(vec.at(i)-p);
  }
    x=min(now,x);
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
  ll S;
  cin >> S;
  
  ll y = (S + 999999999) / 1000000000;
  ll x = 1000000000LL * y - S;
  cout << 0 << " " << 0 << " ";
  cout << 1000000000 << " " << 1 << " ";
  cout << x << " " << y << endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << x;
#define OUTL(x) cout << x << endl;
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(x);
    cout << !x << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;

ll N, C, K, temp, ans = 0;
vector<ll> T;
bool fir = true, go = false;

int main() {
	scanf("%lld%lld%lld", &N, &C, &K);
	REP(i, N) {
		scanf("%lld", &temp);
		T.push_back(temp);
	}
	sort(T.begin(), T.end());
	T.push_back(3000000007);
	ll count = 0;
	temp = T[0] + K;
	REP(i, N + 1) {
		count++;
		//    cout<<"Ti"<<T[i]<<":"<<temp<<endl;
		if (count > C || T[i] > temp) {
			//    cout<<"OK"<<endl;
			temp = T[i] + K;
			ans++;
			count = 1;
		}
		else  if (i == N) { /*ans++;*/ }



	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1400
#pragma once
#include <iostream>
using namespace std;

void	InputTransactionData(int* p_transaction_data, int transacsion_num);
int		CalcMaxProfit(int* p_transaction_data, int transacsion_num);


int main()
{
    int     transaction_num     = 0;
    int*    p_transaction_data  = NULL;
    int     max_profit          = 0;

    // 取引回数を入力する
    //cout << "取引回数を入力してください" << endl;
    cin >> transaction_num;

    // 取引データを入力する配列を用意する
    p_transaction_data = new int[transaction_num];

    // 取引データを入力する
    InputTransactionData(p_transaction_data, transaction_num);

    // 最大利益を計算する
    max_profit = CalcMaxProfit(p_transaction_data, transaction_num);

    // 最大利益を出力する
    //cout << "最大利益を出力する" << endl;
    cout << max_profit << endl;
    
}

void InputTransactionData(int* p_transaction_data, int transacsion_num) {

    // 取引データを入力する
    //cout << "取引データを入力してください" << endl;

    for (int i = 0; i < transacsion_num; i++) {

        cin >> p_transaction_data[i];
    }
}

int CalcMaxProfit(int* p_transaction_data, int transacsion_num) {

    int max_profit              = 0x80000001;
    int profit_tmp              = 0;
    int min_transaction_data    = p_transaction_data[0];

    // 最大利益を計算する
    for (int i = 1; i < transacsion_num; i++) {

        // 利益を計算する
        profit_tmp = p_transaction_data[i] - min_transaction_data;

        // 最大利益を更新する
        if (max_profit < profit_tmp) {

            max_profit = profit_tmp;
        }

        // 取引データの最小値を更新する
        if (min_transaction_data > p_transaction_data[i]) {

            min_transaction_data = p_transaction_data[i];
        }
    }

    return max_profit;
}



Measured memory_bytes: 3876
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProconTemplate
{
    class Doing
    {
        public static void Main(string[] args)
        {
            var partsCount = int.Parse(Console.ReadLine().Split(' ').First());
            var posArray = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToArray();

            // N >= M
            if(partsCount >= posArray.Count())
            {
                Console.WriteLine("0");
                return;
            }

            var moveList = new List<int>();
            for(var index = 0; index < posArray.Count() - 1; index++)
            {
                moveList.Add(posArray[index + 1] - posArray[index]);
            }

            Console.WriteLine(moveList.OrderByDescending(x => x).Skip(partsCount - 1).Sum());
        }
    }
}


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

int main(){
    int n, b, f, r, v;

    cin >> n;

    int count[5][4][11] = {};

    for (int i = 0; i < n; i++){
        cin >> b >> f >> r >> v;
        count[b][f][r] += v; 
    }

    for (int j = 1; j <= 4; j++){
        for (int l = 1; l <= 3; l++){
            for (int m = 1; m <= 10; m++){
                cout << " " << count[j][l][m];
            }
            cout << endl;
        }
        if (j != 4){
            cout << "####################" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3072
#include <cstdio>
#include <vector>
#include <utility>
#include <set>

using namespace std;

int main() {
    while (1) {
        int i;
        int n,m;
        vector<pair<int,int> > target;
        set<pair<int,int> > field;

        scanf("%d", &m);
        if (!m) return 0;

        for (i=0;i<m;i++) {
            int x, y;
            scanf("%d %d", &x, &y);
            target.push_back(make_pair(x,y));
        }

        scanf("%d", &n);
        for (i=0;i<n;i++) {
            int x, y;
            scanf("%d %d", &x, &y);
            field.insert(make_pair(x,y));
        }

        pair<int,int> standard = target[0];
        set<pair<int,int> >::iterator it = field.begin();
        int x_diff;
        int y_diff;
        while (it != field.end()) {
            x_diff = it->first - standard.first;
            y_diff = it->second - standard.second;
            vector<pair<int,int> >::iterator it2 = target.begin();
            bool flag = 1;

            while (it2 != target.end()) {
                if (field.find(make_pair(it2->first + x_diff, it2->second + y_diff)) == field.end()) {
                    flag = 0;
                    break;
                }
                it2++;
            }

            if (flag) break;
            it++;
        }

        printf("%d %d\n", x_diff, y_diff);
    }
}

Measured memory_bytes: 1084
#include <stdio.h>

int main()
{
    long long x;
    scanf("%lld",&x);

    long long ans1 = ((x + 10) / 11 - 1) * 2 + 1;

    if(((x + 10) / 11) * 11 - 5 < x)ans1 ++;
    printf("%lld",ans1);
}

Measured memory_bytes: 128
K = int(input())
A, B = map(int, input().split())
"""
if(B-A+1 >= K):
  print("OK")
else:
  print("NG")
"""
flag = False
for i in range(A, B+1):
  if i%K == 0:
    flag = True
if flag:
  print("OK")
else:
  print("NG")

Measured memory_bytes: 9088
/*总是有超时的错误，找一下原因*/

#include<iostream>
#define N 200000
#define MAX 2000000000
using namespace std;
typedef long long llong;
int A[N];
int L[N/2+2],R[N/2+2];
int n;

llong Merge(int A[],int left,int mid,int right){
    int n1=mid-left,n2=right-mid;
    int i,j;
    llong cnt=0;
    for(i=0;i<n1;i++) L[i]=A[left+i];
    for(i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1]=R[n2]=MAX;
    i=0; j=0;
    for(int k=left;k<right;k++){
        if(L[i]<=R[j]){
            A[k]=L[i++];
        }else{
            A[k]=R[j++];
            cnt+=n1-i;
        }
    }
    return cnt;
}

llong MergeSort(int A[],int left,int right){
    llong v1=0,v2=0,v3=0;
    if(left+1<right){
        int mid=left+(right-left)/2;
        v1=MergeSort(A,left,mid);
        v2=MergeSort(A,mid,right);
        v3=Merge(A,left,mid,right);
    }
    return v1+v2+v3;
}

int main(){
    cin>>n;
    llong ans=0;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    ans=MergeSort(A,0,n);
    cout<<ans<<endl;
}



Measured memory_bytes: 4656
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

ans = 'War'

for z in range(X+1, Y+1):
    if max(x) < z and min(y) >= z:
        ans = 'No War'
        break

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,m,a,ans=0;
    priority_queue<int>q;
    cin>>n>>m;
    while(cin>>a)
        q.push(a);
    for(int i=0;i<m;i++)
        q.push(q.top()/2),q.pop();
    for(int i=0;i<n;i++)
        ans+=q.top(),q.pop();
    cout<<ans<<endl;
}


Measured memory_bytes: 1400
import itertools
from typing import List, Tuple


def main():
    d, g = map(int, input().split())
    v = []
    for _ in range(d):
        p, c = map(int, input().split())
        v.append((p, c))

    print(ag(v, g))


def ag(v: List[Tuple[int, int]], g: int) -> int:
    ret = 10 ** 10
    for comb in itertools.product((False, True), repeat=len(v)):
        cnt, score = 0, 0
        for i, bit in enumerate(comb):
            if bit:
                score += (i + 1) * 100 * v[i][0] + v[i][1]
                cnt += v[i][0]
        if score < g:
            idx = len(v) - list(reversed(comb)).index(False) - 1
            add = ((g - score) + ((idx + 1) * 100) - 1) // ((idx + 1) * 100)
            if add < v[idx][0]:
                cnt += add
            else:
                cnt = 10 ** 10  # impossible
        ret = min(ret, cnt)
    return ret


if __name__ == '__main__':
    main()


Measured memory_bytes: 75576
n = gets.to_i
s = gets.chomp
wc = s[1...n].count(?E)
min = wc
(1...n).each{|i|
    wc += 1 if s[i-1]==?W
    wc -= 1 if s[i]==?E
    min = [min, wc].min
}
p min

Measured memory_bytes: 2436
use proconio::{
    input, 
    fastout,
};

#[fastout]
fn main() {
    input! {
        n: usize,
        d: isize,
        xy: [(isize, isize); n],
    }

    let dd = d * d;

    let mut count = 0;
    for (x, y) in xy {
        if x * x + y * y <= dd {
            count += 1;
        }
    }

    println!("{}", count);
}


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

int main(){
    
    int n;
    cin >> n ;
    vector<int>a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    
    vector<vector<int>>dp(n, vector<int>(2));
    // dp[i][0] --> denotes the max len of the subaary including this i for increasing subaaray
    // dp[i][1] --> denotes the max len of the subaary including this i for decreasing subaarsy
    
    dp[0][0] = 1;
    dp[0][1] = 1;
     //cout << dp[0][0] << " " << dp[0][1] << endl; 
    for(int i = 1; i < n; i++){
        dp[i][0] = dp[i-1][0];
        dp[i][1] = dp[i-1][1];
        bool increasing = false;
        bool decreasing = false;
        if(a[i] >= a[i-1]){
            dp[i][0] += 1;
            //dp[i][1] = 0;
            increasing = true;
        }
        if(a[i] <= a[i-1]){
            dp[i][1] += 1;
            //dp[i][0] = 0;
            decreasing = true;
        }
        
        if(decreasing^increasing){
            if(decreasing)dp[i][0] = 1;
            else dp[i][1] = 1;
        }
        
        //cout << dp[i][0] << " " << dp[i][1] << endl; 
    }
    
    int start_idx = n - 1;
    int result = 0;
    while(start_idx >= 0){
        int optimal_value = max(dp[start_idx][0], dp[start_idx][1]);
        result += 1;
        start_idx -= optimal_value;
        //start_idx += 1;
        //cout << start_idx << endl;
    }
    
    cout << result << endl;


}


Measured memory_bytes: 8988
from operator import itemgetter
N = int(input())
t_list = []
for i in range(N):
  a = list(map(str, input().split()))
  a[1] = int(a[1])
  a.append(i)
  t_list.append(a)
  

t_list = sorted(t_list, key=itemgetter(1), reverse=True)
t_list = sorted(t_list, key=itemgetter(0))
for j in range(N):
  print(t_list[j][2]+1)

Measured memory_bytes: 3064
ininng = int(input())
for i in range(ininng):
  base=[0,0,0]
  out=0
  score=0
  while out<3:
    event=input()
    if event=="HIT":
      if base[2]==1:
          base[2]=0
          score+=1
      if base[1]==1:
          base[2]=1
          base[1]=0
      
      if base[0] ==1:
          base[0]=0
          base[1]=1
        
      base[0]=1
    elif event=="HOMERUN":
      score=score+sum(base)+1
      base=[0,0,0]
    else:
      out+=1
  print(score)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int x,y;
    cin>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    sortD(a);
    sum+=a[0];
    count=1;
    i=1;
    while(count<(n-1))
    {
        sum+=a[i];
        // i++;
        count++;
        if(count==n-1) break;
        sum+=a[i];
        i++;
        count++;
    }
    cout<<sum;
}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


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

char in[1010];

int main() {
    int n;
    string s;
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>in;
        int len = strlen(in);
        int st = 0;
        while(len > 1) {
            int s = in[len-1] + in[len-2] - '0' - '0';
            if(s >= 10) {
                in[len-2] = s/10 + '0';
                in[len-1] = s%10 + '0';
            }else{
                len--;
                in[len-1] = s + '0';
            }
            st++;
        }
        if(st%2) {
            cout<<"Fabre wins."<<endl;
        }else{
            cout<<"Audrey wins."<<endl;
        }
    }
}

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

int main(){
  int A,a,b,c,d;
  cin >> A;
  
  a = A/1000;
  b = (A%1000)/100;
  if (A%1000<100) b=0;
  c = (A%100)/10;
  if (A%100<10) c=0;
  d = A%10;
  
  if (a==b&&b==c)
    cout << "Yes" << endl;
  else if (b==c&&c==d)
    cout << "Yes" << endl;
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
int copmare(const void *a,const void *b){
    if(*(int *)a>*(int *)b){
        return 1;
    }else{
        return -1;
    }
}
int main()
{   int a,b,n,m,k,i,j,x,y,h,w;
    scanf("%d%d%d",&n,&h,&w);
    if(n<h||n<w){
    printf("0");
    return 0;
    }
    printf("%d",(n-w+1)*(n-h+1));

    return 0;
}


Measured memory_bytes: 128
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
#print(a)
x=bisect.bisect_left(a,a[-1]/2)
#print(x)
ans=n-x#そのままの状態で条件を満たす和
if x==0:
    print(ans)
    exit()
i=x-1
j=x
tmp=a[i]
ref=a[x]
SUM=sum(a[:i+1])
#print(SUM)
for k in range(i,-1,-1):
    if k==i:
        if 2*SUM>=a[k+1]:
            ans+=1
        else:
            break
    else:
        SUM-=a[k+1]
        #print(SUM,k,ans)
        if 2*SUM>=a[k+1]:
            ans+=1
        else:
            break
print(ans)

Measured memory_bytes: 20592
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
vector<ll> V[4];
vector<ll> S[4];
ll W;
ll w[110];
ll v[110];
ll K;

int main () {
  cin >> N >> W;
  for (auto i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
  }
  K = w[0];
  for (auto i = 0; i < N; ++i) {
    V[w[i] - K].push_back(v[i]);
  }
  for (auto i = 0; i < 4; ++i) {
    int sum = 0;
    sort(V[i].begin(), V[i].end());
    reverse(V[i].begin(), V[i].end());
    S[i].push_back(0);
    for (auto x : V[i]) {
      sum += x;
      S[i].push_back(sum);
    }
  }
  ll ans = 0;
  for (ll i = 0; i < (ll)S[0].size(); ++i) {
    for (ll j = 0; j < (ll)S[1].size(); ++j) {
      for (ll k = 0; k < (ll)S[2].size(); ++k) {
        ll weight = (i+j+k) * K + j + 2 * k;
        if (W < weight) continue;
        ll l = (W - weight)/(K+3);
        // cerr << i << " " << j << " " << k << " " << l << endl;
        if (l >= (ll)S[3].size()) l = (ll)S[3].size() - 1;
        ans = max(ans, S[0][i] + S[1][j] + S[2][k] + S[3][l]);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n;

int main()
{
    cin >> n;
    if(n>81){
        cout << "No";
        return 0;
    }
    if(n<10){
        cout << "Yes";
        return 0;
    }
    for(int i = 2; i <= 9; i++){
        if(n/i<10&&n%i==0){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	int N;
	cin >> N ;

	vector<int>n(N),res(N);

	fi(N) {
		int t;
		cin >> t;
		
		res[t-1] = i + 1;

	}

	fi(N) {
		cout << res[i] <<" ";
	}


}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {


        
        public static int make2(int a , int b){
            int keta = (b>=10)? 100 : 10;
            return a*keta+b;
        }

        public static int make3(int a, int b, int c) {
            int keta = (c >= 10) ? 100 : 10;
            int keta2 = (b >= 10) ? 100 : 10;
            return a * (keta*keta2) + b * keta + c;
        }
        public static int make4(int a, int b, int c, int d) {
            int keta = (d >= 10) ? 100 : 10;
            int keta2 = (c >= 10) ? 100 : 10;
            int keta3 = (b >= 10) ? 100 : 10;
            return a * (keta * keta2 * keta3) + b * (keta * keta2) + c * keta + d;
        }


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int n = int.Parse(line);
                int k = int.Parse(Console.ReadLine());
                if (n == 0) { break; }
                HashSet<int> hashs = new HashSet<int>();

                int[] cards = new int[n];
                for (int i = 0; i < n; i++) {
                    cards[i] = int.Parse(Console.ReadLine());
                }
                //stored.


                if (k == 2) {
                    for (int i = 0; i < n; i++) {
                        for (int j = 0; j < n; j++) {
                            if (i == j) { continue; }
                            hashs.Add(make2(cards[i],cards[j]));
                        }
                    }
                }
                if (k == 3) {
                    for (int i = 0; i < n; i++) {
                        for (int j = 0; j < n; j++) {
                            if (i == j) { continue; }
                            for (int x = 0; x < n; x++) {
                                if (x == j || x == i) { continue; }
                                hashs.Add(make3(cards[i], cards[j], cards[x]));
                            }
                        }
                    }
                }
                if (k == 4) {
                    for (int i = 0; i < n; i++) {
                        for (int j = 0; j < n; j++) {
                            if (i == j) { continue; }
                            for (int x = 0; x < n; x++) {
                                if (x == j || x == i) { continue; }
                                for (int y = 0; y < n; y++) {
                                    if (y == j || y == i || y==x) { continue; }
                                    hashs.Add(make4(cards[i], cards[j], cards[x],cards[y]));
                                }
                            }
                        }
                    }
                }
                Console.WriteLine(hashs.Count);
            }
            
        }

        
    }

    

    
}

Measured memory_bytes: 6524
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int c[5010], r[5010];

struct edge{int to, cost;};

int n, d[5010];
vector<edge> g[5010];
VI v[5010];

void dijkstra(int s) {
  priority_queue<PII, vector<PII>, greater<PII>> que;
  fill(d, d+n, INF);
  d[s] = 0;
  que.push(PII{0, s});

  while(que.size()) {
    PII p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(edge e: g[v]) {
      if(d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(PII{d[e.to], e.to});
      }
    }
  }
  REP(i, n) if(d[i] <= r[s]) v[s].PB(i);
}

void dijkstra2(int s) {
  priority_queue<PII, vector<PII>, greater<PII>> que;
  fill(d, d+n, INF);
  d[s] = 0;
  que.push(PII{0, s});

  while(que.size()) {
    PII p = que.top(); que.pop();
    int vv = p.second;
    if(d[vv] < p.first) continue;
    for(int i: v[vv]) {
      if(d[i] > d[vv] + c[vv]) {
        d[i] = d[vv] + c[vv];
        que.push(PII{d[i], i});
      }
    }
  }
  cout << d[n-1] << endl;
}

signed main(void)
{
  int k;
  cin >> n >> k;
  REP(i, n) cin >> c[i] >> r[i];
  REP(i, k) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    g[x].PB({y, 1});
    g[y].PB({x, 1});
  }

  REP(i, n) dijkstra(i);
  dijkstra2(0);

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxK = 1e4+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;

vector<int> dx = {0,0,1,-1};
vector<int> dy = {1,-1,0,0};
int H,W;
int sx,sy;
int tx,ty;
char a[1010][1010];
int dis[1010][1010];
struct node
{
	int d;
	int x;
	int y;
	bool operator<(const node& p)const
	{
		return d<p.d;
	}
	bool operator>(const node& p)const
	{
		return d>p.d;
	}
};
int main()
{
	cin>>H>>W;
	cin>>sx>>sy;
	cin>>tx>>ty;
	for(int i=1;i<=H;i++)
	{
		scanf("%s",a[i]+1);
	}
	for(int i=1;i<=H;i++)
	{
		for(int j=1;j<=W;j++)
		{
			dis[i][j] = inf;
		}
	}
	dis[sx][sy] = 0;
	priority_queue<node,vector<node>, greater<node> > Q;
	Q.push(node{0,sx,sy});
	while(!Q.empty())
	{
		node item = Q.top();
		Q.pop();
		int d = item.d;
		int x = item.x;
		int y = item.y;
		for(int i=0;i<4;i++)
		{
			int nx = x + dx[i];
			int ny = y + dy[i];
			if(nx<1 || nx > H || ny<1 || ny > W)continue;
			if(a[nx][ny] == '#')continue;
			if(dis[nx][ny] > d)
			{
				dis[nx][ny] = d;
				Q.push(node{dis[nx][ny],nx,ny});				
			}
		}
		for(int ix=-2;ix<=2;ix++)
		{
			for(int iy=-2;iy<=2;iy++)
			{
				int nx = x + ix;
				int ny = y + iy;
				if(nx<1 || nx > H || ny<1 || ny > W)continue;
				if(a[nx][ny] == '#')continue;
				if(dis[nx][ny] > d+1)
				{
					dis[nx][ny] = d+1;
					Q.push(node{dis[nx][ny],nx,ny});				
				}
			}
		}
	}
	if(dis[tx][ty] != inf)
		cout<<dis[tx][ty]<<endl;
	else
		puts("-1");
	return 0;
}

Measured memory_bytes: 8712
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl


signed main(void){
    int Q;
    cin >> Q;
    
    int now=0,Plus=0;
    int L=0,R=0;
    int Med=0;
    priority_queue<int> QM;//正負反転
    priority_queue<int> Qm;
    REP(j,Q){
        int t,a,b;
        cin >> t;
        if(t==1){
            cin >> a >> b;
            Plus+=b;
            //nowが偶数ならQm-QM=1,奇数なら0だとうれしい
            Qm.push(a);
            L+=a;
            int r=Qm.top();
            Qm.pop();
            L-=r;
            QM.push(-1*r);
            R+=r;
            if(now%2==0){
                r=-1*QM.top();
                QM.pop();
                R-=r;
                Qm.push(r);
                L+=r;
            }
            
            Med=Qm.top();
            
            
            
            now++;
        }else{
            cout << Med << " ";
            int Ans=0;
            //nowが偶数ならL,Rにはnow/2が
            //奇数ならLにはnow+1/2、Rにはnow/2個ある
            if(now%2==0){
                Ans+=(Med*(int)(now/2))-L;
                Ans+=R-(Med*(int)(now/2));
            }else{
                Ans+=(Med*(int)((now+1)/2))-L;
                Ans+=R-(Med*(int)(now/2));
            }
            //cout << L << " " << R << endl;
            cout << Ans+Plus << endl;
        }
        
        
    }
    
    
    

    
    return 0;
}



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

int main() {
    int N;
    string stone1;
    cin >> N >> stone1;

    int cnt1 = 0;
    for (int i = 0; i < N; i++) {
        if (stone1[i] == 'W') cnt1++;
    }
    int cnt2 = N - cnt1;

    string stone2 = stone1;
    sort(stone2.begin(), stone2.end());

    int cnt3 = 0;
    for (int i = 0; i < N; i++) {
        if (stone1[i] != stone2[i]) cnt3++;
    }
    cnt3 /= 2;

    cout << min(min(cnt1, cnt2), cnt3) << endl;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  int sum=0;
  for(int i=N;0<i;i/=10)
    sum+=(i%10);
  if(N%sum==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  
   return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.trim().split("\n");
  var N = parseInt(input[0], 10);
  var S = input[1].split("");
  var now = [];
  var total = 0;

  for (var i = 0; i < 10; i++) {
    var is = String(i);
    if (S.indexOf(is) != -1) {
      now = S.slice(S.indexOf(is) + 1, N);
      if (now.length < 2) continue;
    } else {
      continue;
    }
    for (var j = 0; j < 10; j++) {
      var js = String(j);
      if (now.indexOf(js) != -1) {
        now2 = now.slice(now.indexOf(js) + 1, N);
        if (now.length < 1) continue;
      } else {
        continue;
      }
      for (var k = 0; k < 10; k++) {
        var ks = String(k);
        if (now2.indexOf(ks) != -1) {
          total++;
        } else {
          continue;
        }
      }
    }
  }

  console.log(total);
}

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


Measured memory_bytes: 21064
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long*)a>*(long long *)b)return 1;
    return -1;
}
int MIN(int a,int b){
    return a<b?a:b;
}
int main()
{   int n;
    scanf("%d",&n);
    char s[n][11];
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
    }
    int inner=0;
    for(int i=0;i<n;i++){
        int l=strlen(s[i]);
        for(int j=0;j<l-1;j++){
            if(s[i][j]=='A'&&s[i][j+1]=='B'){
                inner++;
                //printf("inner incre@i%d,j%d",i,j);
            }
        }
    }
    int ht=0,h=0,t=0;
    for(int i=0;i<n;i++){
        int l=strlen(s[i]);
        if(s[i][0]=='B'&&s[i][l-1]=='A'){
            ht++;
        }else if(s[i][0]=='B'){
            h++;
        }else if(s[i][l-1]=='A'){
            t++;
        }
    }
    if(n==1){
        printf("%d",inner);
        return 0;
    }
    
    //printf("inner%d ht%d h%d t%d\n",inner,ht,h,t);
    
    
    long ans=inner;
    while(ht>0&&h>0&&t>0){
        ans+=2;
        ht--;
        t--;
        h--;
    }
    //printf("ht fin%d\n",ans);
    if(ht>0&&(h>0||t>0)){
        ans+=ht;
    }else if(ht==0&&(h>0||t>0)){
        ans+=MIN(h,t);
    }else if(ht>0&&h==0&&t==0&&ans>inner){
        ans+=ht;
    }else if(ht>0&&h==0&&t==0){
        ans+=ht-1;
    }
    
    
    printf("%ld",ans);
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    vector<ll> p(n),q(n);
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    vector<ll> r(n);
    rep(i,n) r[i]=i+1;
    map<vector<ll>,ll> mp;
    ll cnt=1;
    mp[r]=cnt;
    while(next_permutation(all(r))){
        cnt++;
        mp[r]=cnt;
    }
    cout<<abs(mp[p]-mp[q])<<endl;
    return 0;
}

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

int main()
{
    vector<int> a(5);
    rep(i, 0, 5){
        cin >> a[i];
    }
    rep(i, 0, 5){
        if(a[i] == 0){
            cout << i+1 << endl;
        }
    }
    return 0;
}


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

int main() {
  
  int a;
  int b;
  int c;
  cin >> a;
  cin >> b;
  cin >> c;
  
  if ((a == b && b != c)||(b == c && c != a)||(c == a && a != b))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  cin >> n;
  
  vector<int> vec(n);
  for(int k = 0; k < n; k++){
    cin >> a;
    vec.at(k) = a;
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int alicePoint = 0;
  for(int i = 0; i < vec.size(); i += 2){
    alicePoint += vec.at(i);
  }
  int bobPoint = 0;
  for(int i = 1; i < vec.size(); i += 2){
    bobPoint += vec.at(i);
  }
  
  cout << alicePoint -  bobPoint << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <queue>
#include <string>
#include <map>

using namespace std;

bool check(int n){
  return (0 <= n && n < 8);
}

void init(map<string,int> &count){
  const int d[4] = {1,-1,4,-4};
  queue<string> Q;
  string t = "01234567";
  Q.push(t);

  while(!Q.empty()){
    string now = Q.front(); Q.pop();
    int zero = now.find('0');
    int dist = count[now];    

    for(int i = 0 ; i < 4 ; i++){
      int next = zero + d[i];
  
      if(!check(next) || (zero == 3 && d[i] == 1)
	 || (zero == 4 && d[i] == -1)) continue;

	swap(now[zero],now[next]);
	//not visit
	if(!count[now]){ 
	  Q.push(now);
	  if(now != t) count[now] = dist + 1;
	}
	swap(now[zero],now[next]);
    }
  }
}

int main(){
  char in;
  string puzzle;
  map<string,int> count;

  init(count);

  while(cin >> in){
    puzzle = in;

    for(int i = 0 ; i < 7 ; i++){
      cin >> in;
      puzzle += in;
    }

    cout << count[puzzle] << endl;
  }

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;

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

    priority_queue<ll> prices;

    rep(i,n) {
        ll k;
        cin >> k;
        prices.push(k);
    }

    rep(i,m) {
        ll k = prices.top();
        k = k / 2;
        prices.pop();
        prices.push(k);
    }

    ll total = 0;
    rep(i,n) {
        total += prices.top();
        prices.pop();
    }

    cout << total << endl;

}


Measured memory_bytes: 1528
while True:
	n = int(raw_input())
	if n == 0: break
	ls = [map(int, raw_input().split()) for i in range(n)]+[[0]*(n+1)]
	for i in range(n):
		ls[i].append(sum(ls[i]))
	for i in range(n+1):
		for j in range(n):
			ls[n][i] += ls[j][i]
	for row in ls:
		print ''.join(map(lambda x: str(x).rjust(5), row))

Measured memory_bytes: 4228
#include <stdio.h>

int main(void) {
	int  i,j,h,w;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0)break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(i==0||i==h-1||j==0||j==w-1){
					printf("#");
				}else{
					printf(".");
			}
		}
		printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N =  sc.nextInt();
    int biggestans = 0;
    int nextbig = 0;
    int place = 0;
    for(int i=0;i<N;i++){
      int A = sc.nextInt();
      if (A>biggestans){
        nextbig = biggestans;
        biggestans = A;
        place = i;
      }else{
        nextbig = Math.max(nextbig,A);
    }
    }
    for (int j=0;j<N;j++){
      if (j==place){
        System.out.println(nextbig);
      }else{
    System.out.println(biggestans);
      }
    }
  }
}

Measured memory_bytes: 81020
# -*- coding: utf-8 -*-


def solve(h):
    if len(h) == 1:
        return h[0]
    elif len(h) == 0:
        return 0

    r = 0
    m = min(h)
    if m > 0:
        #すべての要素からmを引く
        for i in range(len(h)):
            h[i] -= m
        r += m

    # 0で区切る
    start = 0
    for i in range(len(h)):
        if i < start:
            continue
        if h[i] == 0:
            r += solve(h[start:i])
            start = i + 1
    r += solve(h[start:])
    return r


    start = 0
    r = 0
    for i in range(len(h)):
        if h[i] == 0:
            c = sorted(h[:i], reverse=True)[0]
            return c + solve(h[i:])
    else:
        sorted(h, reverse=True)[0]
    print(i)
    return r

if __name__ == '__main__':
    N = int(input())
    h = list(map(int, input().split()))

    c = solve(h)
    print(c)


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

int main() {
  int N;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    string M;
    cin >> M;
    	if (M == "Y") {
          cout << "Four"<< endl;
        break;
	  }    

    	if(i+1 == N){
    cout << "Three" << endl ;}
    
  }
}

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,m,i;(n=s.nextInt())>0;){Map<Integer,int[]>a=new TreeMap<Integer,int[]>();int[]b=new int[n+1];for(m=s.nextInt(),b[1]=1;m-->0;)a.put(s.nextInt(),new int[]{s.nextInt(),s.nextInt()});for(int[]k:a.values())if(b[k[0]]>0)b[k[1]]=1;for(int c:b)b[0]+=c;System.out.println(b[0]);}}}

Measured memory_bytes: 17000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int MAX = 1e5 + 10;
const double exps = 1e-8;
#define endl '\n'

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }

int main() {
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    ll r = 0, g = 0, b = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') r++;
        if (s[i] == 'G') g++;
        if (s[i] == 'B') b++;
    }
    ll ans = r * g * b;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int k = 2 * j - i;
            if (k < n && s[i] != s[k] && s[i] != s[j] && s[k] != s[j]) ans--;
        }
    }
    cout << ans;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

#define rep(i, n) for(lli i = 0; i < (lli)(n); i++)

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
#define EPS 0.00000000001
lli a;
double b;
lli bn;

int main(void){
    cin >> a >> b;
    bn = (b+EPS)*100;
    cout << a*bn/100 << endl;
    return 0;
}


Measured memory_bytes: 3704
# -*- coding: utf-8 -*-
N = int(input())

if N <=2:
    print(0)
elif N % 3 == 0:
    print(int(N/3))
elif N % 3 == 1:
    print(int((N-1)/3))
elif N % 3 == 2:
    print(int((N-2)/3))


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

int main() {
    int h, w; cin >> h >> w;
    string bar(w + 2, '#');

    cout << bar << "\n";
    for (int i = 0; i < h; i++) {
        string row; cin >> row;
        cout << "#" + row + "#" << "\n";
    }
    cout << bar << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
ll int large=(ll int)1e18;
ll int mod=(ll int)1e9+7;


ll int mod_exp(ll int x,ll int n)
{
    ll int result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n=n/2;
    }
    return result;
}

ll int mod_inverse(ll int a)
{
    return mod_exp(a,mod-2);
}



int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll int T,i,j,ij;
T=1;
//cin>>T;
while(T--)
{
   ll int n,val;
   cin>>n>>val;
   rep(i,0,n+1)
   if(2*i+(4*(n-i))==val)
   {
     cout<<"Yes"<<endl;
     return 0;
   }

   cout<<"No"<<endl;

}
return 0;
}










Measured memory_bytes: 3652
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for _a in range(a+1):
        for _b in range(b+1):
                for _c in range(c+1):
                        if 500*_a + 100*_b + 50*_c == x:
                                ans += 1
print(ans)

Measured memory_bytes: 39536
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int n, u, k, v, c;
	cin >> n;
	vector<vector<pair<int, int>>> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> u >> k;
		for (int j = 0; j < k; ++j) {
			cin >> v >> c;
			a[u].emplace_back(v, c);
		}
	}
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> b;
	b.emplace(0, 0);
	vector<bool> d(n);
	vector<int> e(n, INT_MAX);
	e[0] = 0;
	while (!b.empty()) {
		pair<int, int> f = b.top();
		b.pop();
		d[f.second] = true;
		for (int i = 0; i < a[f.second].size(); ++i) {
			if (!d[a[f.second][i].first]) {
				if (a[f.second][i].second + e[f.second] < e[a[f.second][i].first]) {
					e[a[f.second][i].first] = a[f.second][i].second + e[f.second];
					b.emplace(e[a[f.second][i].first], a[f.second][i].first);
				}
			}
		}
	}
	for (int i = 0; i < n; ++i) cout << i << ' ' << e[i] << endl;
}


Measured memory_bytes: 7752
#include <iostream>
#include <vector>
#include <algorithm>

bool less_mod10(int left, int right)
{
    if ( (left-right) % 10 != 0) return left%10 < right%10;
    else return left < right;
}

int main()
{
    std::vector<int> V, W;
    V.resize(5);
    W.resize(5);
    for (auto& it : V) {std::cin >> it;}
    std::sort(V.begin(), V.end(), less_mod10);
    bool min = true;

    int sum = 0;
    for (int i=0; i<5; ++i) 
    {
        sum += V[i];
        if (V[i]%10 != 0 && min) {min = false;}
        else if (V[i]%10 != 0) {sum += (10 - V[i]%10);}
    }

    std::cout << sum << std::endl;
    
    return 0;
}

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

#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=100+5;
int a[N*2];

int main()
{
	//freopen("1.in","r",stdin);
	int n;
	cin>>n;
	rep(i,1,n*2)cin>>a[i];
	sort(a+1,a+n*2+1);
	int ans=0;
	for(int i=1;i<=n*2;i+=2)ans+=a[i];
	cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
 int main(void)
 {
     char S[100],T[100];
     int N,i;

     scanf("%d",&N);
     scanf("%s%s",S,T);

     for(i=0;i<N;i++)
       printf("%c%c",S[i],T[i]);

     printf("\n");

     return 0;
 }


Measured memory_bytes: 128