akhauriyash/Code-Regression huggingface dataset:
import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans1 = 0;
        if(a > b){
            ans1 = b;
        } else {
            ans1 = a;
        }
        int ans2 = (a + b) - x;
        if(ans2 < 0){
            ans2 = 0;
        }
        System.out.println(ans1 + " " + ans2);
    }
}


Measured memory_bytes: 22604
#include<bits/stdc++.h>
#define int long long
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define MOD 1000000007
#define float long double
#define pb push_back
#define mp make_pair
#define pp pop_back
#define pi 3.141592653589793238
#define print(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
using namespace std;
bool sortbysec(const pair<int,int> &a,
             const pair<int,int> &b)
{
   return (a.second < b.second);
}
int lcm(int a, int b)  
 {  
    return (a*b)/__gcd(a, b);  
 }  
bool sortinrev(const pair<int,int> &a,  
              const pair<int,int> &b)
{
      return (a.first > b.first);
}
void solve()
{
	string s;
	cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";
}    
signed main()
{
                    // #ifndef ONLINE_JUDGE
                    // freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
                    // #endif 
  int t=1;
 //cin>>t;
  while(t--){
  solve();
}
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
 return 0;
}  

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  if(n==1) pr("Hello World");
  else {
    int x,y;
    cin >> x >> y;
    pr(x+y);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;
    class Program
    {
      static void Main(string[] args){
        var list = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        Array.Sort(list);
        Console.Write(list[0]*list[1] /2);
      }
    }



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

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

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    ll n;
    cin >> n;
    cout << ((n-1)*n)/2;
}

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

const ll MOD=1e9+7;
ll n,a[100010],h[100010]={};

ll ad(ll x,ll y){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y){
  return (x*y)%MOD;
}

ll pwr(ll x,ll y){
  ll pw[32]={},w=1;
  pw[0]=x;
  fr(i,31) pw[i+1]=mlt(pw[i],pw[i]);
  fr(i,32){
    w=mlt(w,1+(y%2)*(pw[i]-1));
    y/=2;
  }
  return w;
}

ll inv(ll x){
  return pwr(x,MOD-2);
}

int main(){
  cin>>n;
  fr(i,n) cin>>a[i];
  fr(i,n) h[i+1]=ad(h[i],inv(i+1));
  ll ans=0;
  fr(i,n) ans=ad(ans,mlt(ad(h[i+1],h[n-i]-1),a[i]));
  fr(i,n) ans=mlt(ans,i+1);
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>

#include<bits/stdc++.h>

using namespace std;


int main(){
  int ii,jj,kk;
  
  set<int> s;
  int q,c,x;

  cin >> q;
  set<int>::iterator it;
  for(ii=0;ii<q;ii++){
    cin >> c >> x;
    if(c == 0){
      s.insert(x);
      cout << s.size() << endl;
    }
    else if(c == 2){
      s.erase(x);
    }
    else{
      it = s.find(x);
      if(it != s.end()){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 12428
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
//constexpr int MOD = /**/ 1000000007; //*/ 998244353;
constexpr int MOD = 104857601;
////////////////


void solve(){
  ini(N,M);
  vl a(N); in(a);
  map<int,vi> m;
  m[0].pb(0);
  ll cur = 0;
  rep(i,N){
    cur = (cur + a[i] + M - 1) % M;
    m[cur].pb(i+1);
  }
  ll ans = 0;
  each(x , m){
    #define v x.se
    trc(v);
    rep(i , sz(v)){
      auto it = lower_bound(all(v) , v[i] + M);
      ans += (it-v.begin())-1-i;
      trc(i,ans);
    }
  }

  out(ans);

}


Measured memory_bytes: 23680
#include <cstdio>
typedef long long ll;
inline int rd(){
    int x=0,p=1;
    char a=getchar();
    while((a<48||a>57)&&a!='-')a=getchar();
    if(a=='-')p=-p,a=getchar();
    while(a>47&&a<58)x=(x<<1)+(x<<3)+(a&15),a=getchar();
    return x*p;
}
int n;
int main(){
	n=rd()%10;
	if(n==2||n==4||n==5||n==7||n==9)puts("hon");
	else if(n==0||n==1||n==6||n==8)puts("pon");
	else puts("bon");
    return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    long long X;
    cin>>X;
    //Xがn番目の三角数だったら、nが答え
    //n番目の三角数<X<n+1番目の三角数の時、n+1が答えになる
    //∵n+1番目のジャンプで飛び越えてしまうならば、飛び越えてしまう距離Yは、n+1>Yであるので
    //i=Yの時だけ何もしなければn+1回目で丁度行けるはず
    //n回目で絶対に到達できない∧n+1回目で到達できるのでこれが最短
    //i=1から足していって、Xを超えた時のnの値が答え
    //nはたかだか100000(∵三角数はO(n^2))
    int ans=0;
    rep(i,100000){
        X=X-i;
        if(X<=0){
            ans=i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int solve(float x){
  if(1.1<=x) return 0;
  if(0.6<=x) return 1;
  if(0.2<=x) return 2;
  return 3;
}

int main(void){
  float x,y;
  int i,rst[4][2];

  memset(rst,0,sizeof(rst));
  while(scanf("%f%f",&x,&y) != EOF){
    rst[solve(x)][0]++;
    rst[solve(y)][1]++;
  }
  for(i=0;i<4;i++){
    printf("%d %d\n",rst[i][0],rst[i][1]);
  }

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int cnt=0;
		for(int a=0;a<10;a++)
		for(int b=0;b<10;b++)
		for(int c=0;c<10;c++)
		for(int d=0;d<10;d++)
		if(n==a+b+c+d)cnt++;
		cout<<cnt<<endl;
	}

}

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

int main() {
	ios_base::sync_with_stdio( false );

	int x, y;
	cin >> x >> y;

	uint32_t a = y - x;
	uint32_t b = 1 + y + x;
	uint32_t c = -y - x + 1;
	uint32_t d = -y + x + 2;

	cout << min( { a,b,c,d } ) << endl;

	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> q(n);

	rep(i, n) cin >> p.at(i);
	rep(i, n) cin >> q.at(i);

	vector<int> a(n);
	rep(i, n) a.at(i) = i+1;

	map<vector<int>, int> mp;

	do{
		mp[a] = mp.size();
	}while(next_permutation(a.begin(), a.end()));

	int ans = abs(mp[p] - mp[q]); 
	cout << ans << endl;
}

Measured memory_bytes: 5248
import java.io.IOException;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[][] mat = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				mat[i][j] = in.nextInt();
			}
		}

		Set<Integer> x = new HashSet<>();
		Set<Integer> y = new HashSet<>();
		for (int i = 1; i < n; i++) {
			y.add(i);
		}
		int totalCost = 0;
		boolean[] visit = new boolean[n];


		x.add(0);
		visit[0] = true;

		// yが空になるまで処理をする
		while (!y.isEmpty()) {
			int min = Integer.MAX_VALUE;
			int v = -1;
			for (Integer from : x) {
				for (int to = 0; to < n; to++) {
					if (mat[from][to] != -1 && !visit[to] && mat[from][to] < min) {
						min = mat[from][to];
						v = to;
					}
				}
			}
			visit[v] = true;
			x.add(v);
			y.remove(v);
			totalCost += min;
		}

		System.out.println(totalCost);

	}

}



Measured memory_bytes: 39748
import sys

n, *h = map(int, sys.stdin.read().split())

def main():
    cnt = 0

    for _ in range(max(h)):
        prev_0 = True
        for i in range(n):
            if h[i] > 0:
                h[i] -= 1
                if prev_0:
                    cnt += 1
                    prev_0 = False
            else:
                prev_0 = True
    
    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N;
    cin >> N;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
using 		namespace __gnu_pbds; 
using 		namespace std;
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopitr(vec) for(auto it=vec.begin();it!=vec.end();it++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	v(pi) vector<ll>pi
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	vp(pi) vector<pair<ll,ll>>pi
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	mi(lol) map<ll,ll>lol
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(30)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())


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

//code start from here 

int main() {
	fast;
	double d;
	cin>>d;
	roundoff;
	cout<<pi*2*d<<Endl;
	return 0;
}

//ends here 

Measured memory_bytes: 3800
#include<iostream>
#include<string>
#include<set>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  set<string> s;
  rep(i, 0, n){
    string a;
    cin >> a;
    s.insert(a);
  }
  
  cout << s.size();
}

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

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

    string che[4] = {"AC", "WA", "TLE", "RE"};
    int cou[4];
    for(int i= 0; i < 4; i++){
        cou[i] = 0;
    }

    for(int i = 0; i < n; i++){
        string k;
        cin >> k;
        for(int j = 0; j < 4; j++){
            if(k == che[j]){
                cou[j]++;
                break;
            }
        }
    }

    cout << "AC x " << cou[0] << endl;
    cout << "WA x " << cou[1] << endl;
    cout << "TLE x " << cou[2] << endl;
    cout << "RE x " << cou[3] << endl;

}

Measured memory_bytes: 3628
import time

S = input()[::-1]
keywords = ["dream", "dreamer", "erase", "eraser"]
keywords = [x[::-1] for x in keywords]
# start_time = time.time()
start = 0
while True:
    flag = False
    end = None
    for key in keywords:
        key_len = len(key)
        end = start + key_len
        if S[start:end] == key:
            flag = True
            break

    start = end

    if not flag:
        print("NO")
        exit()

    if flag and start == len(S):
        print("YES")
        exit()




Measured memory_bytes: 3184
import sys

S = input()
S = S[::-1]
temp = ''

for a in S:
    temp += a
    # dream,dreamer
    if temp == "maerd" or temp == "remaerd" or temp == "esare" or temp == "resare":
        temp = ""
    if len(temp)>7:
        print("NO")
        sys.exit()
print("YES")


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W; j++){
                    if(i % 2 == 0){
                        if(j % 2 == 0){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }else{
                        if(j % 2 == 0){
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                        }
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 35060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

namespace Solver {

    int N, M, A;
    vector<int> H, P, Q;
    inline bool Read() {
        cin >> N >> M >> A;
        if (N == 0) return false;
        H.resize(M);
        P.resize(M);
        Q.resize(M);
        for (int i = 0; i < M; i++) cin >> H[i] >> P[i] >> Q[i];
        return true;
    }

    inline void Work() {
        for (int h = 1000; h > 0; h--) {
            for (int i = 0; i < H.size(); i++) {
                if (h == H[i]) {
                    if (A == P[i]) {
                        A = Q[i];
                    } else if (A == Q[i]) {
                        A = P[i];
                    }
                }
            }
        }

        cout << A << endl;
    }

    inline void Solve() {
        while (Read()) Work();
    }
}

int main() {
    Solver::Solve();
}

Measured memory_bytes: 1220
def main():
    n = int(input())
    com = 0

    for _ in range(n):
        d1, d2 = map(int, input().split())

        if d1 == d2:
            com += 1
        else:
            com = 0

        if com == 3:
            print('Yes')
            return

    print('No')


if __name__ == '__main__':
    main()


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	int h, w;
	cin >> h >> w >> n;
	int a[n];
	rep(i,n) cin >> a[i];

	int nowcolor = 1 ;
	int num = a[nowcolor - 1];

	vector<vector<int>> ans(h,vector<int>(w));
	for(int i = 0 ; i < h ; i ++ ){
		for(int j = 0 ; j < w ; j++){
			int yoko = j ;
			if(i%2==1) yoko = w - 1 - j;
			ans[i][yoko] = nowcolor;
			num -- ;
			if(num == 0){
				nowcolor ++ ;
				num = a[nowcolor - 1];
			}
		}
	}
	for(int i = 0 ; i < h ; i ++ ){
		for(int j = 0 ; j < w ; j++){
			cout <<ans[i][j];
			if(j!=w-1) cout <<" " ;
		}
		cout << endl ;
	}
}


Measured memory_bytes: 384
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int w, a, b, ans = 0;
	scanf("%d%d%d", &w, &a, &b);
	while (true) {
		if (a + w >= b && b + w >= a) break;
		if (a + w < b)--b;
		else ++b;
		++ans;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b;
  cin>>a>>b;
  long long pre=0;
  if(a==b)
  {
    cout<<a<<endl;
    return 0;
  }
  long long c=a;
  while((c^(c+1))!=1L && c<b)
  {
    pre^=c;
    c++;
  }
  if(c!=b)
  {
    long long d=(b-c)%4;
    if(d==0)pre^=b;
    else if(d==1)pre^=1;
    else if(d==2)pre^=(b+1);
    else pre^=0;
  }
  cout<<pre<<endl;
  
  return 0;
}
    

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
ll a,b;
ll check(ll x){
  ll tmp = x - (a%x);
  tmp %= x;
  if( tmp < (b-a+1)) return max((b-a - tmp)/x,0LL) + 1LL;
  else return 0;
}

long long gcd( long long m, long long n ){
    if ( n == 0) return m;
    return gcd(n,m%n);
  }//最大公約数

  long long lcm( long long m, long long n ){
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//最小公倍数

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll c,d;

  cin >> a >> b >> c >> d;
  ll ans = 0;
  ans += check(c);

  ans += check(d);

  ans -= check(lcm(c,d));

  cout << max((b-a+1LL) - ans,0LL) <<endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  cout << (regex_match(s, regex("(dream(er)?|eraser?)+")) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 40960
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if n == 2:
        print(max(a), min(a))
    else:
        ma = max(a)
        sa = sorted([(i, abs(ma // 2 - a[i]))
                     for i in range(n)], key=lambda x: x[1])
        print(ma, a[sa[0][0]])


main()


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

int main() {
    int N,A,B;
    cin >> N >> A >> B;

    int count=0;
    
    for(int j=0;j<N;j++){
        int s=j+1;
        int T=0;
        for(int i=0;i<5;i++){
            int q=pow(10,i+1);
            int a=s%q;
            int b=a/pow(10,i);
            T+=b;
            s=s-b*pow(10,i);
        }
        if(A<=T && T<=B){
            count= count+j+1;
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 256
--[[
ABCACCBABCBCAABCB
[1] ABCACCBABCBCABCAB
[2] ABCACCBABCBCBCAAB
[5] ABCACCBBCBCBCAAAB
[6] BCAACCBBCBCBCAAAB

AAABCBC

BCBCAAA

]]
local s = io.read()
local n = #s
local sub = ""
local state = 1
local alen = 0
local ret = 0
for i = 1, n do
  sub = s:sub(i, i)
  if state == 1 then
    if sub == "A" then
      alen = alen + 1
    elseif sub == "B" then
      state = 2
    else
      alen = 0
    end
  elseif state == 2 then
    if sub == "C" then
      ret = ret + alen
    elseif sub == "A" then
      alen = 1
    else
      alen = 0
    end
    state = 1
  end
end
print(ret)


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

int main() {
  int N;
  cin>>N;
  vector<int> arr(3);
  string ans[N];
  for(int i=0;i<N;++i){
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr.begin(), arr.end());
    if(arr[0]*arr[0]+arr[1]*arr[1]==arr[2]*arr[2]) ans[i] = "YES";
    else ans[i] = "NO";
  }
  for(int i=0;i<N;++i) cout<<ans[i]<<endl;
}



Measured memory_bytes: 3244
import math
a, b, deg = map(float, input().split())
rad = math.radians(deg)
area = 0.5 * a * b * math.sin(rad)
c = math.sqrt(a*a + b*b - 2*a*b*math.cos(rad))
h = area*2 / a;

print(area, a+b+c, h)


Measured memory_bytes: 5692
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 3005;
double a[N];
double f[N][N];


int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
    int n;
    std::cin >> n;
    rep(i, 1, n + 1) {
        std::cin >> a[i];
    }
    f[0][0] = 1.0;
    rep(i, 1, n + 1) {
        rep(j, 0, n) {
            f[i][j + 1] += f[i - 1][j] * a[i];
            f[i][j] += (1.0 - a[i]) * f[i - 1][j];
        }
    }
    double ans = 0.0;
    rep(i, n / 2 + 1, n + 1) {
        ans += f[n][i];
    }
    std::cout << std::
    fixed << std::setprecision(10) << ans << std::endl;
}

Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int main()
{
	std::string s;

	std::cin >> s;

	std::cout << s[0] << s.length() - 2 << s.back() << std::endl;


	return 0;
}


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

int main() {
    string n;
    cin >> n;

    
    int b=0;
    b = n.size() - 1;

    string a;
    a = n.at(b);

    if(a=="3")
    {
        cout << "bon" << endl;
    }
    else if(a=="0" || a=="1" || a=="6" || a=="8")
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }
    
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
typedef vector<ll> VL;

vector<VL> sk;
ll W, kjw;
vector<int> ct(4,0);
ll rec(int idx){
	if(idx>=4){
		//for(auto x :ct) printf("%d ",x); printf(":");
		ll cw = 0, cv= 0; 
		rep(i, 4){
			cw += (kjw + i)* ct[i];
			cv += ct[i]<1? 0: sk[i][ct[i]-1];
		}
		if(cw > W) return 0;
		return cv;
	}
	ll rt =0;
	rep(i, sz(sk[idx])+1){
		ct[idx]=i;
		rt = max(rt, rec(idx+1));
	}
	return rt;
}

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int N; 
	cin >>N >>W;
	vector<ll> w(N), v(N);
	rep(i, N) cin >>w[i] >>v[i];
	
	kjw = *min_element(all(w));
	
	sk.resize(4);
	rep(i, N) sk[w[i] -kjw].emplace_back(v[i]);
	rep(i, 4) sort(sk[i].rbegin(), sk[i].rend());
	rep(i, 4) rep2(j, 1 ,sz(sk[i])) sk[i][j] += sk[i][j-1];

	cout << rec(0) <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
	char line[128];
	fgets(line, 128, stdin);
	int num = atoi(line);
	switch(num % 10) {
		case 3:
			printf("bon\n");
			break;
		case 0: case 1: case 6: case 8:
			printf("pon\n");
			break;
		default:
			printf("hon\n");
	}
    return EXIT_SUCCESS;
}



Measured memory_bytes: 2024
from sys import stdin
def input():
    return stdin.readline().strip()

def main():
    h, w, d = map(int, input().split())

    x = [0] * (h*w)
    y = x.copy()
    for i in range(h):
        a = list(map(int, input().split()))
        for j in range(w):
            x[a[j] - 1] = i
            y[a[j] - 1] = j

    # 累積和
    cost = [[0] for _ in range(d)]
    for i in range(d, h*w):
        cost[i%d].append(cost[i%d][-1] + abs(x[i]-x[i-d]) + abs(y[i]-y[i-d]))

    ans = []
    q = int(input())
    for _ in range(q):
        l, r = map(int, input().split())
        l -= 1
        r -= 1
        ans.append(cost[r%d][r//d] - cost[l%d][l//d])

    for i in ans:
        print(i)

main()

Measured memory_bytes: 19340
// AOJ 1230 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1230)
#include<cstdio>
#include<cstring>
#define rep(i,a) for(int i=0;i<(a);++i)
#define clr(a,v) memset((a),(v),sizeof(a))

const int MAX_N = 10, MAX_S = 1<<13;

int n, S, M[2*MAX_N];
int dp[2*MAX_N][MAX_S+1];

bool rec( int i, int j )
{
	if( j <= 1 )
		return false;

	int &ret = dp[i][j];

	if( ~ret )
		return ret;

	rep( k, M[i] ) if( j-k-1 >= 1 ) if( !rec( (i+1)%(n<<1), j-k-1 ) )
		return ret = true;

	return ret = false;
}

int main()
{
	while( scanf( "%d", &n ), n )
	{
		scanf( "%d", &S );
		rep( i, n<<1 )
			scanf( "%d", M+i );

		clr( dp, -1 );
		printf( "%d\n", rec( 0, S ) );
	}

	return 0;
}

Measured memory_bytes: 1912
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1e14+100 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

const int MAX = 2000000 ;

//宣言するときはstaticをつけて静的変数にするかグローバル変数として宣言
class SGT{
public :
	int n ;
//	d変数は単位元、計算の邪魔をしない値に設定する、INFや0など
	ll d = INF ;
	ll num[MAX] ;

	void init(vector<ll> &a){
		n = 1 ;
		while(a.size()>n) n *= 2 ;
		for(int i=0;i<n;i++){
			if(i<a.size()) num[n-1+i] = a.at(i) ;
			else num[n-1+i] = d ;
		}
		for(int i=n-2;i>=0;i--){
			num[i] = min(num[i*2+1],num[i*2+2]) ;
		}
	}

//	内容次第でwhile内の計算式を書き換える
	void update(int i,ll a){
		i += n-1 ;
		num[i] = a ;
		while(i>0){
			i = (i-1)/2 ;
			num[i] = min(num[i*2+1],num[i*2+2]) ;
		}
	}

	ll query(int a,int b,int l,int r,int now){
		if(r<=a||b<=l) return d ;
		if(a<=l&&r<=b) return num[now] ;
		ll r1 = query(a,b,l,(l+r)/2,now*2+1) ;
		ll r2 = query(a,b,(l+r)/2,r,now*2+2) ;
		return min(r1,r2) ;
	}
};

int main(){
	ll n,m ;
	cin >> n >> m ;
	vector<pair<pair<ll,ll>,ll>> q(m) ;
	for(int i=0;i<m;i++){
		ll l,r,c ;
		cin >> l >> r >> c ;
		l-- ; r-- ;
		q.at(i).first.first = r ;
		q.at(i).first.second = l ;
		q.at(i).second = c ;
	}
	sort(all(q)) ;
	static SGT sgt ;
	vll def(n,INF) ;
	def.at(0) = 0 ;
//	for(int i=0;i<n;i++) cout << def.at(i) << endl ;
	sgt.init(def) ;
	int pos = 0 ;
	for(int i=1;i<n;i++){
		ll mn = INF ;
		while(pos<m&&q.at(pos).first.first==i){
			mn = min(mn,sgt.query(q.at(pos).first.second,q.at(pos).first.first+1,0,sgt.n,0)+q.at(pos).second) ;
			pos++ ;
		}
//		cout << sgt.num[i+sgt.n-1] ;
		sgt.update(i,mn) ;
//		cout << " " << mn << endl ;
	}
	cout << (sgt.num[n-1+sgt.n-1]==INF?-1:sgt.num[n-1+sgt.n-1]) << endl ;
//	for(int i=0;i<n;i++) cout << sgt.num[i+sgt.n-1] << endl ;
//	cout << INF << endl ;
}


Measured memory_bytes: 8312
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    BC = [()] * M
    for i in range(M):
        b, c = map(int, input().split())
        BC[i] = (b, c)

    BC.sort(key=lambda x: x[1], reverse=True)

    am = []
    for bc in BC:
        b, c = bc[0], bc[1]
        if len(am) + b <= N:
            am += [c] * b
        else:
            am += [c] * (N - len(am))

        if len(am) == N:
            break

    A += am
    A.sort(reverse=True)
    ans = sum(A[:N])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 23732
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
  // cin>>t;
    while(t--)
    {  
        int n;double m;
       cin>>n>>m;
       int a[n];
       double sum=0;
       for(int i=0;i<n;i++)
       {
           cin>>a[i];
           sum+=a[i];
       }
       int x=0;
       for(int i=0;i<n;i++)
       {
           if(sum/(4*m)<=a[i])
           {
              x++;
           }
       }
       if(x>=m)
       cout<<"Yes";
       else
       cout<<"No";
    }
}
    
// 🍪 🍪 🍪


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    vector<ll> dp(N,0);
    dp[0] = 1000;
    for (int i = 1;i < N;++i) {
        dp[i] = dp[i - 1];
        rep(j,i) {
            ll c = dp[j]/A[j],m = dp[j]%A[j];
            dp[i] = max(dp[i],c*A[i] + m);
        }
    }
    cout << dp[N - 1] << '\n';
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  if (n == 0)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const long double eps = 1e-10;
//const double PI = M_PI; 
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/* Coding Space. */
// レベルLの下からのxに何個あるのか
ll f(ll n, ll x){
  //cerr << n << " " << x << endl;
  if(n == 0)  return (x <= 0)?0:1;
  if(pow(2, n+2, LLINF)/2 - 1 == x){return 1 + f(n-1,x-2);}
  else if(pow(2, n+2, LLINF)/2 - 1 > x){return f(n-1,x-1);}
  else if(pow(2, n+2, LLINF)/2 - 1 < x){return 1 + (pow(2, n, LLINF) - 1) + f(n-1, x - (pow(2, n + 1, LLINF) - 3) - 2);}
  return -LLINF;
}
int main(){
  ll n,x; cin >> n >> x;
  cout << f(n,x) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < 3; i++){
  if(S[i] == '1'){
  count += 1;
  }
  }
  cout << count;
}


Measured memory_bytes: 256
#!/usr/bin/env perl

use strict;
use warnings;

my $count = <STDIN>;
chomp($count);

my $found = 0;

for ( my $i = 1; $i <= $count; $i++ ) {
  my $result = <STDIN>; chomp($result);
  my ($A, $B) = split qr(\s+), $result;


  if ( $A != $B ) {
    $found = 0;
    next;
  }

  $found++;

  if ( $found >= 3 ) {
    last;
  }
}

print ((($found >= 3) ? "Yes" : "No"), "\n");

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

int main() {
  int n;
  cin >> n;
  if(n == 25) cout << "Christmas" << endl;
  if(n == 24) cout << "Christmas Eve" << endl;
  if(n == 23) cout << "Christmas Eve Eve" << endl;
  if(n == 22) cout << "Christmas Eve Eve Eve" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
  int N,sum=0;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;i<N-1;i++){
    sum=sum+a[i];
  }
  if(a[N-1]>=sum){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1
#define MOD(x, m) ((x) % (m) + (m)) % (m)

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

template <typename T>
void join(vector<T>& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    ll a, b, c, d, e;
    cin >> a>>b>>c>>d>>e;
    if (a == 0) {
        cout << "1\n";
    } else if (b == 0) {
        cout << "2\n";
    } else if (c == 0) {
        cout << "3\n";
    } else if (d == 0) {
        cout << "4\n";
    } else if (e == 0) {
        cout << "5\n";
    }

    cout << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }

    return 0;
}

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

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

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main(){
	
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int cnt = 0;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				int ans = 500 * i + 100 * j + 50 * k;
				if (x == ans)cnt++;
			}
		}
	}

	pr(cnt);


	return 0;
}

Measured memory_bytes: 256
import math
N=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if N==1:
    print(0)
else:
    arr=factorization(N)
    count=0
    for i in range(len(arr)):
        c=math.floor((-1+math.sqrt(1+8*arr[i][1]))/2)
        count+=c
    print(count)

Measured memory_bytes: 9392
from collections import deque

class Node:
  def __init__(self,l,r,p):
    self.l=l
    self.r=r
    self.p=p

n=int(input())
#T=[Node(-1,-1,-1)]*n
T=[Node(-1,-1,-1) for _ in range(n)]
for _ in range(n):
  i,l,r=map(int,input().split())
  T[i].l=l
  T[i].r=r
  if l!=-1:
    T[l].p=i
  if r!=-1:
    T[r].p=i

#for i in range(n):
#  print("debug:",T[i].p)

H=[-1]*n
def setHeight(u):
  h1=0
  h2=0
  if T[u].r!=-1:
    h1=setHeight(T[u].r)+1
  if T[u].l!=-1:
    h2=setHeight(T[u].l)+1
  H[u]=max(h1,h2)
  return H[u]

D=[-1]*n
def setDepth(u,d):
  if u==-1: return
  D[u]=d
  setDepth(T[u].r,d+1)
  setDepth(T[u].l,d+1)

def getSubling(u):
  if T[u].p==-1:
    return -1
  if T[T[u].p].l!=u and T[T[u].p].l!=-1:
    return T[T[u].p].l
  if T[T[u].p].r!=u and T[T[u].p].r!=-1:
    return T[T[u].p].r
  return -1



root=-1
for i in range(n):
  if T[i].p==-1:
    root=i
    break

setHeight(root)
setDepth(root,0)

#d=deque()
#d.append(T[root].left)
#d.append(T[root].right)
#while len(d)>0:
#  tmp=d.popleft()
#  d.append(tmp.left)
#  d.append(tmp.right)

#node id: parent = p, siling = s, degree = deg, depth = dep, height = h, type
for i in range(n):
  node=T[i]
  deg=0
  if node.l!=-1:
    deg+=1
  if node.r!=-1:
    deg+=1
  s=getSubling(i)
  t='root' if i==root else 'leaf' if deg==0 else 'internal node'
  print('node ',i,': parent = ',node.p,', sibling = ',s,', degree = ',deg,', depth = ',D[i],', height = ',H[i],', ',t,sep='')



Measured memory_bytes: 6068
#include "iostream"
#include "vector"
#include "algorithm"
#include "numeric"

typedef struct{
	int a;
	int b;
}inp;

int main() {
	int n, m, num = 0;
	std::cin >> n;
	std::cin >> m;

	std::vector<int>v(n);
	std::iota(v.begin(), v.end(), 1);

	std::vector<inp>x(m);

	for (int i = 0; i < m; ++i) {
		std::cin >> x[i].a;
		std::cin >> x[i].b;
	}

	bool ex, ex_tmp;
	do {
		if (v[0] == 1) {
			for (int i = 0; i < n - 1; ++i) {
				ex_tmp = false;
				for (int j = 0; j < m; ++j) {
					if ((x[j].a == v[i] && x[j].b == v[i + 1]) || (x[j].a == v[i + 1] && x[j].b == v[i])) {
						ex_tmp = true;
						break;
					}
				}
				if (ex_tmp == false) {
					ex = false;
					break;
				}
			}
			if (ex_tmp == true) {
				num++;
				ex = true;
			}
		}
		else ex = false;

	} while (std::next_permutation(v.begin(), v.end()));

	std::cout << num << std::endl;
}

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

int main(){
  
  int n, a;
  set <int> s;
  cin >> n;
  for(int i = 0; i < n; ++i){
    	cin >> a;
    	s.insert(a);
  }
  cout << ((int)s.size() == n ? "YES\n" : "NO\n");
}

Measured memory_bytes: 9600
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#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 <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c < 22 ? "win" : "bust") << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
n=int(input())
xa=0
bx=0
ba=0
ans=0
for i in range(n):
    l=list(input())
    for j in range(len(l)-1):
        if l[j]=='A' and l[j+1]=='B':
            ans += 1
    if l[0]=='B':
        if l[len(l)-1]=='A':
            ba += 1
        else:
            bx += 1
    elif l[len(l)-1]=='A':
        xa += 1
if ba>0:
    ans += ba-1
    if xa>0:
        ans += 1
        xa -= 1
    if bx>0:
        ans += 1
        bx -= 1
ans += min(xa,bx)
print(ans)

Measured memory_bytes: 3064
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = list(map(int, input().split()))

r += p[-x:]
r += q[-y:]
print(sum(sorted(r)[-(x+y):]))


Measured memory_bytes: 22832
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define int long long
#define INF 1<<40
#define N 100
using namespace std;
signed main() {
	int n, k; cin >> n >> k;
	double p[200000];
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
		p[i] = (p[i] + 1) / 2 ;
	}
	double sum = 0, maxv = 0;
	for (int i = 0; i < k - 1; ++i) sum += p[i];
	for (int i = k-1; i < n; ++i) {
		sum += p[i];
		maxv = max(maxv, sum);
		sum -= p[i - k+1];
	}
	printf("%.10f\n", maxv);
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a,b;
		a=sc.nextInt();
		b=sc.nextInt();
		System.out.println((a*b)+" "+(2*a+2*b));
		sc.close();
 }
}


Measured memory_bytes: 26156
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
int a[N+1];
int maxL[N+1];
int maxR[N+1];
a[0]=0;
maxL[1]=0;
maxR[N]=0;
for(int i=1; i<=N ; i++){
    cin>>a[i];
}
for(int i=2 ; i<=N ; i++){
    maxL[i]=max(maxL[i-1] , a[i-1] );
}
for(int i=N-1 ; i>=1 ; i--){
    maxR[i]=max(maxR[i+1] , a[i+1] );
}
for(int i=1;i<=N ;i++){
    cout<<max(maxL[i], maxR[i] )<<endl;
}
  return 0;
}


Measured memory_bytes: 3968