akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main() {
    int N, M; cin >> N >> M;
    int A[N];
    double sum = 0;
    int popular_product = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    for (int i = 0; i < N; i++) {
        if (sum / 4 / M <= A[i]) {
            popular_product += 1;
        }
    }
    if (popular_product >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>


using namespace std;

int main(){
	int N;
	long long W;
	long long w[100];
	long long v[100];

	long long val0[100];
	long long val1[100];
	long long val2[100];
	long long val3[100];
	long long num[4];
	long long max = 0;
	memset(num,0,sizeof(num));

	scanf("%d %lld",&N,&W);

	for(int i=0;i<N;i++){
		scanf("%lld %lld",&w[i],&v[i]);
		long long t = w[i] - w[0];
		switch (t) {
			case 0:
			val0[num[0]] = v[i];
			break;
			case 1:
			val1[num[1]] = v[i];
			break;
			case 2:
			val2[num[2]] = v[i];
			break;
			case 3:
			val3[num[3]] = v[i];
			break;
		}
		num[t]++;
	}

	sort(val0,val0+num[0]);
	reverse(val0,val0+num[0]);

	sort(val1,val1+num[1]);
	reverse(val1,val1+num[1]);

	sort(val2,val2+num[2]);
	reverse(val2,val2+num[2]);

	sort(val3,val3+num[3]);
	reverse(val3,val3+num[3]);


	for(int i=0;i<=num[0];i++){
		for(int j=0;j<=num[1];j++){
			for(int k=0;k<=num[2];k++){
				for(int l=0;l<=num[3];l++){
					long long tmp = 0;
					long long weigh = 0;
					for(int m=0;m<i;m++){
						tmp += val0[m];
						weigh += w[0];
					}
					for(int m=0;m<j;m++){
						tmp += val1[m];
						weigh += w[0]+1;
					}
					for(int m=0;m<k;m++){
						tmp += val2[m];
						weigh += w[0]+2;
					}
					for(int m=0;m<l;m++){
						tmp += val3[m];
						weigh += w[0]+3;
					}
					if(weigh<=W && max<tmp) max = tmp;
				}
			}
		}
	}


	printf("%lld\n",max);

	return 0;
}


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


int main(){
    int A,B;
    cin >> A >> B;
    if(A==1 && B==1) {cout << "Draw" << endl;return 0;}
    else if(A==1) cout << "Alice" << endl;
    else if(B==1) cout << "Bob" << endl;
    else if(A > B) cout << "Alice" << endl;
    else if(B > A) cout << "Bob" << endl;
    else cout << "Draw" << endl;
    return 0;
}

Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
ps = sorted(list(map(int, input().split())), reverse=True)
qs = sorted(list(map(int, input().split())), reverse=True)
rs = sorted(list(map(int, input().split())), reverse=True)

choice_apples = sorted(ps[:x] + qs[:y])
total = 0
j = 0

for i in choice_apples:
    if rs and i < rs[0]:
        total += rs[0]
        del rs[0]
    else:
        total += i

print(total)


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A==B){
    cout << C << endl;
  }
  else if(B==C){
    cout << A << endl;
  }
  else{
    cout << B << endl;
  }
}


Measured memory_bytes: 384
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
long binarySearch(long min, long max, bool delegate(long) f){
	if(!f(min)) return min - 1; if(f(max)) return max;
	long mid; while(max - min > 1){ mid = min + (max - min) / 2; if(f(mid)) min = mid; else max = mid; } return min;
	}

void main(){
	int n = read.to!int;
	long[] as = readln.split.map!(to!long).array;
	
	long[] sums1;
	{
		auto h = heapify(as[0 .. n].map!(x => -x).array);
		long[] sums = [as[0 .. n].reduce!"a + b"()];
		foreach(int i; n .. (n + n)){
			long k = h.front;
			if(k > -as[i]){
				h.removeFront;
				h.insert(-as[i]);
				sums ~= sums[$ - 1] + (k - (-as[i]));
				}
			else sums ~= sums[$ - 1];
			}
		sums1 = sums;
		}
	
	debug sums1.writeln;
	
	long[] sums2;
	{
		auto h = heapify(as[n * 2 .. $]);
		long[] sums = [as[n * 2 .. $].reduce!"a + b"()];
		foreach_reverse(int i; n .. (n + n)){
			long k = h.front;
			if(k > as[i]){
				h.removeFront;
				h.insert(as[i]);
				sums ~= sums[$ - 1] - (k - as[i]);
				}
			else sums ~= sums[$ - 1];
			}
		sums2 = sums;
		}
	
	debug sums2.writeln;
	
	long ans = long.min;
	foreach(int i; 0 .. n + 1){
		if(sums1[i] - sums2[n - i] > ans) ans = sums1[i] - sums2[n - i];
		}
	
	ans.writeln;
	
	}

Measured memory_bytes: 18476
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define INF 1000000007
using P = pair<int, int>;
using ll = long long;
int main(){
    int h,w;
    cin>>h>>w;
    char s[50][50];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    bool ans=true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                bool k=false;
                if(i>0&&s[i-1][j]=='#')k=true;
                if(i<h-1&&s[i+1][j]=='#')k=true;
                if(j>0&&s[i][j-1]=='#')k=true;
                if(j<w-1&&s[i][j+1]=='#')k=true;
                if(k==false){
                    ans=false;
                    break;
                }
            }
        }
        if(ans==false)break;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;

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

int main(){
  double W,H,w,h,x,y;
  cin>>W>>H>>w>>h>>x>>y;
  cout<<fixed<<setprecision(10)<<(min(H/2,y+h/2)+(y-h/2))/(min(W/2,x+w/2)+(x-w/2))<<endl;
}



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

int main()
{
    ll N; cin >> N;
    vector<ll> a(N, 0);
    ll sum = 0;
    rep(i,N) {
        ll t; cin >> t;
        a[i] = t;
        sum += t;
    }
    cout << sum - N << endl;


    

}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] house = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);

            int start = house.Max();
            int end = house.Min();

            Console.WriteLine(start - end);
        }
    }
}


Measured memory_bytes: 11220
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    sort(all(L));

    ll res = 0;
    for (int a = 0; a < N; a++) {
        for (int b = a + 1; b < N; b++) {
            ll left = b + 1;
            ll right = lower_bound(all(L), L[a] + L[b]) - L.begin();
            if (right > left)
                res += (right - left);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int main(){
  int i;
  rd(N);
  for(i=(0);i<(N+1);i++){
    if(i * 108 / 100 == N){
      wt_L(i);
      wt_L('\n');
      return 0;
    }
  }
  wt_L(":(");
  wt_L('\n');
  return 0;
}
// cLay varsion 20191227-1

// --- original code ---
// int N;
// {
//   rd(N);
//   rep(i,N+1) if(i * 108 / 100 == N) wt(i), return 0;
//   wt(":(");
// }


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

N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
count = 0
B = [A[0]]
for i in range(N-1):
    a = A[i+1]+count
    C = []
    for b in B:
        x = (b-a)//(N+1)
        C.append(x)
    s = sum(C)
    count += s
    new_B = []
    for i, b in enumerate(B):
        new_B.append(b+s-(N+1)*C[i])
    new_B.append(a+s)
    B = new_B

delta = max(min(B) - N, 0)
count += delta*N
for i in range(N):
    B[i] -= delta

while max(B) > N-1:
    tmp = -1
    for i in range(N):
        if B[i] > tmp:
            tmp = B[i]
            ind = i
    for i in range(N):
        if i == ind:
            B[i] -= N
        else:
            B[i] += 1
    count += 1

print(count)


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	A := make([]int, N+1)
	B := make([]int, N)

	sum := 0
	for i := 0; i < N+1; i++ {
		A[i] = nextInt()
		sum += A[i]
	}

	for i := 0; i < N; i++ {
		B[i] = nextInt()
	}

	// sum := make([]int, N+2)
	// sum[0] = 0

	// for i := 0; i < N+1; i++ {
	// 	sum[i+1] = sum[i] + A[i]
	// }

	// ans := sum[len(sum)-1]

	// fmt.Println(sum)

	for i := 0; i < N; i++ {
		if A[i]-B[i] < 0 {
			B[i] = B[i] - A[i]
			A[i] = 0

			if A[i+1]-B[i] < 0 {
				B[i] = B[i] - A[i+1]
				A[i+1] = 0
			} else {
				A[i+1] -= B[i]
				B[i] = 0
			}

		} else {
			A[i] -= B[i]
			B[i] = 0

		}
	}
	sum2 := 0
	for i := 0; i < N+1; i++ {
		// fmt.Println(A[i])
		sum2 += A[i]
	}
	// fmt.Println(A)
	fmt.Println(sum - sum2)
}


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

using namespace std;
vector<int> h;

int solve(int c,int l,int r){

    if(l == r){
        return h[l] - c;
    }

    int tmpl = l;
    int tmpr = r;

    for(int i = l; i < r + 1; i++){
        if(h[i] != c){
            tmpl = i;
            break;
        }else if(i == r){
            return 0;
        }
    }

    for(int i = tmpl; i < r + 1; i++){
        if(h[i] == c){
            tmpr = i - 1;
            break;
        }
    }

    if(tmpr == r) return solve(c + 1, tmpl, tmpr) + 1;
    return solve(c + 1, tmpl, tmpr) + 1 + solve(c, tmpr + 1, r);

}
 
int main(){

    int n;
    cin >> n;


    for(int i = 0; i < n; i++){
        int hi;
        cin >> hi;
        h.push_back(hi); 
    }

    cout << solve(0,0, n - 1) << endl;
 
    return 0;
}

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

using i64 = long long int;

const int INF = 1e9;

struct Edge{
    int from, to, cost;
};

struct Node{
    int n, cost, ticket;
    bool operator<(const Node &obj)const{
        return cost > obj.cost;
    }
};

int mini[2][102];

int main(){
    int n, m;
    while(cin >> n >> m, n != 0){
        vector<Edge> graph[102];
        for(int i=0;i<m;++i){
            int a, b, c;
            cin >> a >> b >> c;
            graph[a].push_back((Edge){a, b, c});
            graph[b].push_back((Edge){b, a, c});
        }

        for(int i=0;i<2;++i){
            for(int j=1;j<=n;++j)
                mini[i][j] = INF;
        }
        mini[0][1] = 0;
        priority_queue<Node> que;
        que.push((Node){1, 0, 0});
        while(!que.empty()){
            Node curr = que.top(); que.pop();
            if(curr.n == n){
                cout << curr.cost << endl;
                break;
            }
            for(auto e : graph[curr.n]){
                int newcost = curr.cost + e.cost;
                if(newcost < mini[curr.ticket][e.to]){
                    mini[curr.ticket][e.to] = newcost;
                    que.push((Node){e.to, newcost, curr.ticket});
                }
                if(curr.ticket == 0){
                    for(auto ee : graph[e.to]){
                        if(curr.cost < mini[1][ee.to]){
                            mini[1][ee.to] = curr.cost;
                            que.push((Node){ee.to, curr.cost, 1});
                        }
                    }
                }
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3172
a,b=map(int,input().split())
num_list=[str(i) for i in range(10)]
s=input()
if s[a]=="-":
    s=s[:a]+s[a+1:]
    for i in range(len(s)):
        if s[i] not in num_list:
            print("No")
            exit()
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    char a[h][w], b[h][w], c[h][w];
    rep(i, h)rep(j, w) a[i][j] = b[i][j] = '.';
    rep(i, h) a[i][0] = b[i][w-1] = '#';
    rep(i, h)For(j, 1, w-1) (i%2==0 ? a[i][j] : b[i][j]) = '#';

    rep(i, h)rep(j, w){
        scanf(" %c", &c[i][j]);
        if(c[i][j] == '#') a[i][j] = b[i][j] = '#';
    }

    rep(i, h){
        rep(j, w) printf("%c", a[i][j]);
        printf("\n");
    }
    printf("\n");
    rep(i, h){
        rep(j, w) printf("%c", b[i][j]);
        printf("\n");
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <unordered_map>

#define div 1000000000+7

using ll = long long;
using namespace std;

void solve() {
    char c[2][3];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 3; j++){
            if(c[i][j] != c[1-i][2-j]){
                cout << "NO" << endl;
                return;
            }
        }
    }
    cout << "YES" << endl;
}

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

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<tuple>
#include<vector>
#include<iostream>
#define repeat(i,n)for(int i=0;(i)<int(n);++(i))
#define repeat_reverse(i,n)for(int i=(n)-1;(i)>=0;--(i))
#define whole(x)begin(x),end(x)
//long long　をllで表す
using ll=long long;
using namespace std;
/*
inline:オーバーヘッドをなくす目的で行われる。
	   オーバーヘッド：間接的な負荷やコストを表す
	   　　　　　　　　　プログラミングにおけるオーバーヘッドはその処理の本質ではない
				　演算によって増えた計算量を指す。
template<T>:変数の型をテンプレート宣言したもの呼び出した変数の型で計算する型を決める
ついでに、オーバーロード:同じ名前を持つ引数の型が異なる関数を呼び分けることが出来る機能
				
*/	
template<class T>inline void setmin(T&a,T const & b){a=min(a,b);}
constexpr ll inf=ll(1e18)+9;
int main(){
	int n;scanf("%d",&n);
	vector<pair<int,int>>hps(n);
	repeat(i,n){
		int h,p;scanf("%d%d",&h,&p);
		hps[i]={h,p};
	}
	sort(whole(hps),[&](pair<int,int>hp1,pair<int,int>hp2){
		return hp1.first+hp1.second<hp2.first+hp2.second;
	});
	vector<ll>dp(n+1,inf);
	dp[0]=0;
	for(auto hp:hps){
		int h,p;tie(h,p)=hp;
		repeat_reverse(j,n){
			if(dp[j]<=h){
				setmin(dp[j+1],dp[j]+p);
			}
		}
	}
	int result=0;
	repeat(i,n+1){
		if(dp[i]<inf){
			result=i;
		}
	}
	printf("%d\n",result);
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()

{
	int n,i=1,s=0;
	scanf("%d",&n);

	while (i<=n)
	{
		if ((i>0 && i < 10)||(i>99 && i < 1000)||(i>9999 && i < 100000))
			s++;
            i++;
	}
	printf("%d\n",s);
	return 0;
}


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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    vector<int>sunuke(n);

    rep(i,k){
        int d;
        cin>>d;
        rep(j,d){
            int a;
            cin>>a;
            sunuke[a-1]++;
        }
    }

    int ans=0;
    rep2(i,0,n-1)if(sunuke[i]==0)ans++;

    cout<<ans<<endl;
}



Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a, b, c = map(int, input().split())

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

if (c % gcd(a, b)) == 0:
    print('YES')
else:
    print('NO')


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

int main(){
  int t;
  cin >> t;
  while(t--){
    int x,y,w,h;
    cin >> x >> y >> w >> h;
    
    int n;
    cin >> n;
    int cnt = 0;
    for(int i=0;i<n;i++){
      int a,b;
      cin >> a >> b;
      if(x<=a && a<=x+w && y<=b && b<=y+h)cnt++;
    }

    cout << cnt << endl;
  }
}

Measured memory_bytes: 1160
N=int(input())
nums = [int(i) for i in input().split()]

def gcd(x, y):
    if x < y:
        x = x ^ y
        y = x ^ y
        x = x ^ y
    div = x % y
    while div != 0:
        x = y
        y = div
        div = x % y
    return y

memo = {}
memo[(0, 1)] = nums[0]
memo[(N-1, N)] = nums[N-1]

for i in range(2, N+1):
    memo[(0, i)] = gcd(memo[(0, i - 1)], nums[i-1])

for i in reversed(range(0, N-1)):
    memo[(i, N)] = gcd(memo[(i + 1, N)], nums[i])

res = 1
for i in range(1, N-1):
    res = max(res, gcd(memo[(0, i)], memo[(i+1, N)]))

res = max(res, memo[(0, N-1)])
res = max(res, memo[(1, N)])

print(res)


Measured memory_bytes: 86764
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

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

vector<int> input;
vector<int> answer(3, -1);

void dfs(vector<int> &A){
    if(A.size() == 3){
        int ans = input[0];
        REP(i,3){
            if(A[i] == 0){
                ans += input[i+1];
            } else{
                ans -= input[i+1];
            }
        }

        if(ans == 7){
            REP(i,3){
                answer[i] = A[i];
            }
        }
        return;
    }
    

    for(int bit = 0; bit <= 1; bit++){
        A.push_back(bit);
        dfs(A);
        A.pop_back();
    }
}

void solve_079c(){
    int num;
    cin >> num;
    input.resize(4);
    input[0] = (num / 1000);
    input[1] = ((num - input[0] * 1000) / 100);
    input[2] = ((num - input[0] * 1000 - input[1] * 100) / 10);
    input[3] = (num % 10);

    vector<int> tmp;
    dfs(tmp);

    REP(i,3){
        cout << input[i];
        if(answer[i] == 0) cout << "+";
        else cout << "-";
    }
    cout << input[3] << "=7";
}

int main(void){
    solve_079c();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=998244353;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res%mod;}
long modInverse(long a) {return powmod(a, mod-2);}



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

    string s;
    cin>>s;
    if(s[4]==s[5] && s[2]==s[3])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
    }


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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)
#define FORR(i,a,b) for (int i = a; i <= b; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

typedef pair<string, string> ss;

int n;
string s;
ll res = 0;

map<ss, int> mp;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> s;

	for (int i = 0; i < (1 << n); i++) {
		string a, b;

		for (int j = 0; j < n; j++)
			if (i & (1 << j)) a.pb(s[j]);
			else b.pb(s[j]);

		mp[ss(a, b)]++;
	}

	for (int i = 0; i < (1 << n); i++) {
		string a, b;

		for (int j = 0; j < n; j++)
			if (i & (1 << j)) a.pb(s[j+n]);
			else b.pb(s[j+n]);

		reverse(ALL(a));
		reverse(ALL(b));

		res += mp[ss(a, b)];
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 87040
#include<bits/stdc++.h>
using namespace std;
int a,l;
string s[105];
int main(){
	scanf("%d%d",&a,&l);
	for(int i=1;i<a+1;i++){
		cin>>s[i];
	}
	sort(s+1,s+a+1);
	for(int i=1;i<a+1;i++){
		cout<<s[i];
	}
	return 0;
}

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

int main() {

  int heya[8] = { 0, 1, 2, 3, 5, 7, 8, 9 };

  while( true ) {

    long long int input;

    cin >> input;

    if ( input == 0 ) break;

    long long int ans = 0;

    for( long long int i = 1; input > 0; i *= 10 ) {

      ans += heya[ input % 8 ] * i;

      input /= 8;

    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    for (int i = 0; i < n; ++ i) {
        long long m1=a+c*i-d*(n-1-i);
        long long m2=a+d*i-c*(n-1-i);
        if (m1<=b&&b<=m2) {
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, std::vector<long long> A){
    sort(ALL(A));
    vll S(N+1, 0);
    REP(i, N){
        S[i+1] = S[i]+A[i];
    }
    ll cnt = 1;
    for(ll i= N-1; i>0; i--){
        if(S[i]*2>=A[i]){
            cnt++;
        }
        else{
            break;
        }
    }
    cout << cnt <<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
/*  EX4-1
    kosaq       */

#include <stdio.h>
#include <math.h>

int main(void){
    double n_tree;//N本の林檎の木をn_treeで定義
    double d_range;//一人は、D本先までを監視できるのでDをd_rangeで定義
    double one_observe;//一人が監視できる林檎の木の数
    int people_number;//N本の林檎の木を監視するために必要な人数の最小値

    scanf("%lf %lf", &n_tree, &d_range);//NとDを入力

    one_observe = d_range * 2 + 1;//一人が監視できる林檎の木の数
    people_number = ceil(n_tree / one_observe);//N本の林檎の木を監視するために必要な人数の最小値は(n_tree / one_observ)eの小数値を切り上げた整数
    printf("%d\n", people_number);//N本の林檎の木を監視するために必要な人数の最小値を出力
    
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ull unsigned long long
# define ll long long
# define mod 1000000007LL 
using namespace std;
bool visited[1000000]={0};
ll ans;
ll c;
void dfs(vector<vector<ll>>&ans,ll n,ll pos)
{
    if(visited[pos])
    return;
    visited[pos]=1;
    c++;
    for(auto i=ans[pos].begin();i!=ans[pos].end();i++)
    {
        if(ans[pos].size()==0)
        return;
        if(visited[*i])
        continue;
        dfs(ans,n,*i);

    }
}
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    if(m==0)
    {
        cout<<1;
        return 0;
    }
    vector<vector<ll>>adj(n+1);
    ll a,b;
    while(m--)
    {
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        dfs(adj,n,i);
        ans=max(ans,c);
        c=0;
    }
    cout<<ans;
    
    
    return 0;
}

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

namespace contest_Csharp
{
    class Program
    {


        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                var vals = Console.ReadLine().Split(' ').
                    Select(x => int.Parse(x)).ToList();

                var R = vals[0];
                var G = vals[1];
                var B = vals[2];
                var K = int.Parse(Console.ReadLine());

                var cnt = 0;
                while (G >= B)
                {
                    cnt++;
                    B *= 2;
                }
                while (R>=G || G >= B)
                {
                    cnt++;
                    G *= 2;
                    while (G >= B)
                    {
                        cnt++;
                        B *= 2;
                    }

                }
                var ans = cnt <= K ? "Yes" : "No";
                Console.WriteLine(ans);







                Console.Out.Flush();
            }




        }
    }
}




Measured memory_bytes: 28244
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d,n;
vector<ll>v;
map<ll,ll>m;
string s[3],s2;
void input(){
    cin>>s[0]>>s[1]>>s[2];
}
void src(){
    cout<<((s[0].back()==s[1].front() and s[1].back()==s[2].front() ) ?"YES":"NO");
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)2
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 3005
#define mxnn 2000005
int dp[mxn][mxn];
int32_t main(){
sp;
string a,b;
cin >>a >>b;
int n = a.size();
int m = b.size();
a = " "+a;
b = " "+b;
for(int i = 1;i<=n;i++){
    for(int j = 1;j<=m;j++){
        if(a[i]==b[j]) dp[i][j] = dp[i-1][j-1]+1;
        else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
    }
}
string ans;
int x = n,y = m;
while(ans.size() != dp[n][m]){
    if(a[x] == b[y]){
        ans.pb(a[x]);
        x--;
        y--;
    }
    else{
        if(dp[x-1][y] > dp[x][y-1]) x--;
        else y--;
    }
}
reverse(ans.begin(),ans.end());
cout<<ans;
return 0;
}


Measured memory_bytes: 70656
n=int(input())
a=0
b=0
ab=0
x=0
for i in range(n):
  s=input()
  l=len(s)-1
  if s[0]=='B':
    if s[l]=='A':
      ab+=1
    else:
      b+=1
  elif s[l]=='A':
    a+=1
  x+=s.count('AB')
if ab>0:
  x+=ab-1
  x+=(a>0)+(b>0)
  a-=1;b-=1
a=max(0,a);b=max(0,b)
x+=min(a,b)
print(x)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    string s;
    int K;
    cin >> s;
    cin >> K;

    set<string> sse;
    for (int k = 1; k <= K; ++k)
    {
        rep (pos, s.size() - k + 1)
        {
            sse.insert(s.substr(pos, k));;
        }
    }

    rep (i, K - 1) sse.erase(sse.begin());

    cout << *sse.begin() << "\n";
    return 0;
}



Measured memory_bytes: 1664
import math
import itertools
import statistics
#n = int(input())
s=input()
a = int(s[0])*10+int(s[1])
b = int(s[2])*10+int(s[3])
# yymm yy>12 and 12>=mm>=1
# mmyy 1<=mm<=12 and yy > 12
# doble 1<=yy<=12 and  1<=mm<=12
# na mm=0 and yy?12
if 0<a<13 and 0<b<13:
    print("AMBIGUOUS")
elif a > 12 and 0<b<13:
    print("YYMM")
elif 0<a<13 and b > 13:
    print("MMYY")
else:
    if 0<a<13 and b==0:
        print("MMYY")
    elif a==0 and 0<b<13:
        print("YYMM")
    else:   
        print("NA")


Measured memory_bytes: 5148
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename Monoid>
class SegmentTree{
private:
    using F = function<Monoid(Monoid,Monoid)>;
    int sz;
    vector<Monoid> seg;
    const F op;//演算
    const Monoid e;//単位元
public:
    SegmentTree(int n,const F op,const Monoid &e):op(op),e(e){
        sz = 1;
        while(sz<n) sz <<= 1;
        seg.assign(2*sz,e);
    }
    //代入
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
    //前計算(?)
    void build(){
        for(int i=sz-1;i>0;i--){
            seg[i] = op(seg[2*i],seg[2*i+1]);
        }
    }
    void update(int k,const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k>>=1){
            seg[k] = op(seg[2*k],seg[2*k+1]);
        }
    }
    Monoid query(int l,int r){
        Monoid L = e,R = e;
        for(l+=sz,r+=sz;l<r;l>>=1,r>>=1){
            if(l&1) L = op(L,seg[l++]);
            if(r&1) R = op(seg[--r],R);
        }
        return op(L,R);
    }
    Monoid operator[](const int &k)const{
        return seg[k+sz];
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    const int inf = 1e9;
    string S;
    cin >> S;
    vec<int> dp(N+1,inf);
    dp[N] = 0;
    SegmentTree<int> seg(N+1,[](int a,int b){return min(a,b);},inf);
    seg.set(N,0);
    seg.build();
    for(int i=N-1;i>=0;i--){
        if(S[i]=='1') continue;
        dp[i] = seg.query(i+1,min(N+1,i+M+1))+1;
        seg.update(i,dp[i]);
    }
    int res = dp[0];
    if(res>=inf){
        cout << -1 << endl;
        return 0;
    }
//    for(int i=0;i<=N;i++) cerr << dp[i] << (i!=N? " ":"\n");
    vec<int> ans;
    int now = 0;
    while(now!=N){
        int l = now,r = N;
        while(l+1<r){
            int m = (l+r)/2;
            if(seg.query(now+1,m+1)>res-1) l = m;
            else r = m;
        }
        ans.push_back(r-now);
        now = r;
        res--;
    }
    int n = ans.size();
    for(int i=0;i<n;i++) cout << ans[i] << (i!=n-1? " ":"\n");
}

Measured memory_bytes: 2552
#include <algorithm>
#include <array>
#include <cassert>
#include <chrono>
#include <iostream>
#include <random>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int64_t INF64 = int64_t(2e18) + 5;

int64_t N, A, B, C, D;
unordered_map<int64_t, int64_t> save;
set<int64_t> divisions;

int64_t evaluate(int a, int b, int c) {
    int64_t n = N;
    while (a-- > 0) n /= 2;
    while (b-- > 0) n /= 3;
    while (c-- > 0) n /= 5;
    return n;
}

int64_t closest(int64_t n) {
    int64_t dist = INF64;
    auto it = divisions.lower_bound(n);

    if (it != divisions.end())
        dist = min(dist, *it - n);

    if (it != divisions.begin()) {
        it--;
        dist = min(dist, n - *it);
    }

    return dist;
}

const int CUTOFF = 10;

int64_t solve(int64_t n) {
    if (n == 0)
        return 0;

    if (n == 1)
        return D;

    if (closest(n) > CUTOFF)
        return INF64;

    if (save.find(n) != save.end())
        return save[n];

    int64_t ans = (long double) D * n < INF64 ? D * n : INF64;

    ans = min(ans, n % 2 * D + A + solve(n / 2));
    ans = min(ans, n % 3 * D + B + solve(n / 3));
    ans = min(ans, n % 5 * D + C + solve(n / 5));

    if (n > 2) ans = min(ans, (2 - n % 2) * D + A + solve(n / 2 + 1));
    ans = min(ans, (3 - n % 3) * D + B + solve(n / 3 + 1));
    ans = min(ans, (5 - n % 5) * D + C + solve(n / 5 + 1));

    return save[n] = ans;
}

void run_case() {
    cin >> N >> A >> B >> C >> D;
    save.clear();
    divisions.clear();

    for (int a = 0; a <= 60; a++)
        for (int b = 0; b <= 40; b++)
            for (int c = 0; c <= 30; c++)
                divisions.insert(evaluate(a, b, c));

    cout << solve(N) << '\n';
}

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int tests;
    cin >> tests;

    while (tests-- > 0)
        run_case();
}


Measured memory_bytes: 4572
//abc044_b.cpp
//Sun Oct 21 10:56:07 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	unordered_map<char, int> mp;

	for (int i=0;i<w.size();i++){
		mp[w[i]]++;
	}

	int flag = 0;
	for (auto itr = mp.begin(); itr != mp.end(); ++itr){
		if (itr->second%2 == 1){
			flag = 1;
		}
	}

	if (flag == 0){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
ac, wa, tle, re = 0, 0, 0, 0
for _ in range(n):
    s = input()
    if s=="AC":
        ac+=1
    elif s=="WA":
        wa+=1
    elif s=="TLE":
        tle+=1
    else:
        re+=1
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

Measured memory_bytes: 69884
import sys
N,M=map(int,raw_input().split())
a=[]
for i in range(M):
	x,y,z=map(int,raw_input().split())
	a.append((x,y,-1*z))

#print a

#distance
x=[ float("inf") for _ in range(N+1)]
#Set start point value to zero. 
x[1]=0


#Bellman-Ford
for h in range(N):
	for fr,to,cost in a:
		x[to]=min(x[to],x[fr]+cost)


#Judge inf
for h in range(N):
	for fr,to,cost in a:
		if x[to]>x[fr]+cost:
			x[to]=min(x[to],x[fr]+cost)			
			if to==N:
				print "inf"
				sys.exit()
			
print -1*x[N]




Measured memory_bytes: 2936
n = int(input())
ans = 0
for num in range(1, n+1):
    if num%2 == 0:
        continue
    ls = []
    for i in range(1, num+1):
        if num%i == 0:
            ls.append(i)
    if len(ls) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  vi a(5);
  rep(i,5){
    cin>>a[i];
  }
  int k;
  cin>>k;
  bool flag=true;
  rep(i,5){
    rep(j,5){
      flag&=(abs(a[i]-a[j])<=k);
    }
  }

  if(flag){
    cout<<"Yay!"<<endl;
  }else{
    cout<<":("<<endl;
  }


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	int a, b; cin >> a >> b;
	string s; cin >> s;
	bool flag = true;
	for (int i = 0; i < a; ++i) {
		flag &= s[i] != '-';
	}
	flag &= s[a] == '-';
	for (int i = a + 1; i < a + b + 1; ++i) {
		flag &= s[i] != '-';
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}

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

int main(){
    int n ;
    cin >> n ;
    vector<int> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    vector<int> b(n,0) ;
    int p = n ;
    int r = 1 ;
    while (p > 0)
    {
        
            int count = 0 ;
            int i = 0 ;
            while (p*(i+1) <= n)
            {
                
                if (b.at((i+1) * p - 1) == 1)
                {
                    count ++ ;
                }
                i++ ;
            }
            if (a.at(p-1) != count % 2)
                {
                    b.at(p-1) = 1 ;
                }
            p -- ;
    }
    int num =0 ;
    vector<int> c ;
    for (int i = 0; i < n; i++)
    {
        num += b.at(i) ;

        if(b.at(i) == 1)
        {
        c.push_back(i+1) ; 
        }
    }
    cout << num << endl ;
    if (num != 0)
    {
        for (int i = 0; i < (c.size() - 1) ; i++)
        {
            cout << c.at(i) << " " ;
        }
        cout << c.at(c.size() - 1) << endl ;
    
    }
    
    

}

Measured memory_bytes: 3064
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int inputCount = inpt[0];
        int total = inpt[1];

        int min = int.MaxValue;
        int subTotal = 0;

        for (int i = 0; i < inputCount; i++) {
            int tmp = int.Parse(Reader.ReadLine());
            subTotal += tmp;
            min = Math.Min(min, tmp);
        }

        int ans = inputCount;
        int add = (total - subTotal) / min;
        ans += add;
        Console.WriteLine(ans);

    }





    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"




5 3000
150
130
150
130
110



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


int main(){
    ll n,k; cin >> n >> k;
    
    map<ll,ll> m;
    
    rep(i,n){
        int x,y; cin >> x >> y;//scanf("%d %d",&x,&y);//
        m[x] += y;
    }
    
    
    ll ans = 0;
    int i = 1;
    while(1){
        ans += m[i];
        if(ans>=k){
            cout << i << endl;
            break;
        }
        i++;
    }
    
    /*
    for(ll ans = 1 ; ans<=100000 ; ans++){
        if(k <= m[ans]){
            cout << ans << endl;
            break;
        }
        
        k -= m[ans];
    }
     */
}














Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,m;
    cin>>n>>m;
    map<pair<ll,ll>,vector<pair<pair<ll,ll>,ll> > > v;  // adjList
    map<ii, int> visited;
    map<ii, ll>  distance;

    for(ll i=0;i<m;i++){
        ll p,q,c;
        cin>>p>>q>>c;
        v[mp(p,c)].pb(mp(mp(q,c),0));
        v[mp(q,c)].pb(mp(mp(p,c),0));
        v[mp(p,c)].pb(mp(mp(p,0),0));
        v[mp(p,0)].pb(mp(mp(p,c),1));
        v[mp(q,c)].pb(mp(mp(q,0),0));
        v[mp(q,0)].pb(mp(mp(q,c),1));

        visited[mp(p,c)]=0;
        visited[mp(q,c)]=0;
        visited[mp(p,0)]=0;
        visited[mp(p,0)]=0;

        distance[mp(p,0)]=1e17;
        distance[mp(p,c)]=1e17;
        distance[mp(q,c)]=1e17;
        distance[mp(q,0)]=1e17;
    }

    priority_queue< pair<ll,ii> , vector<pair<ll,ii> >, greater<pair<ll,ii> > > pq;

    distance[mp(1,0)]=0;
    pq.push(mp(0,mp(1,0)));

    while(!pq.empty()){
        ll u=pq.top().se.fi;  //station
        ll t=pq.top().se.se;  //platform
        pq.pop();
        if(visited[mp(u,t)]!=0)
            continue;
        visited[mp(u,t)]=1;
        for(ll i=0;i<v[mp(u,t)].size();i++){
            ll station   = v[mp(u,t)][i].fi.fi;
            ll platform  = v[mp(u,t)][i].fi.se;
            ll dis =  v[mp(u,t)][i].se;

            if(distance[mp(station,platform)]>distance[mp(u,t)]+dis){
                distance[mp(station,platform)]=distance[mp(u,t)]+dis;
                pq.push(mp(distance[mp(station,platform)],mp(station,platform)));
            }
        }
    }
    if(visited[{n,0}]!=0)
        cout<<distance[{n,0}];
    else
        cout<<-1;
    return 0;
}


Measured memory_bytes: 145524
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright  : @Huki_Hara
# Created    : 2015-03-16

def ch(l):
    for i in range(len(l) // 2):
        if l[i] != l[-i-1]:
            return False
    return True

s = 0
while True:
    try:
        l = input()
    except:
        break

    if ch(l):
        s += 1
print(s)

Measured memory_bytes: 6720
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		ll n;
		cin>>n;
		if(n==0) break;
		vector<ll> s(n);
		REP(i,n) cin>>s[i];
		sort(ALL(s));
		ll sum=accumulate(ALL(s),0);
		sum-=s[0]+s[n-1];
		cout<<sum/(n-2)<<endl;
	}
}



Measured memory_bytes: 3160