akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 200200
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
ll L,n,X[MAX],nX[MAX];
//ll f[MAX][MAX][2],ans;
ll ans,Sl[MAX],Sr[MAX];
ll S1(int l,int r){return Sl[r]-Sl[l-1];}
ll S2(int l,int r){return Sr[r]-Sr[l-1];}
void Calc()
{
	for(int i=1;i<=n/2;++i)
	{
		int L=i,R=i,pos=n-L-R;
		ans=max(ans,S1(pos+1,pos+R)*2+S2(pos+R+2,n)*2+nX[pos+R+1]);
		ans=max(ans,X[pos]+S1(pos+1,pos+R-1)*2+X[pos+R]+S2(pos+R+1,n)*2);
		if(i+i<n)
		{
			L=i+1,R=i,pos=n-L-R;
			ans=max(ans,X[pos]+S1(pos+1,pos+R)*2+S2(pos+R+2,n)*2+nX[pos+R+1]);
			L=i,R=i+1,pos=n-L-R;
			ans=max(ans,S1(pos+1,pos+R-1)*2+X[pos+R]+S2(pos+R+1,n)*2);
		}
	}
}
int main()
{
	L=read();n=read();
	for(int i=1;i<=n;++i)X[i]=read(),nX[i]=L-X[i];
	//memset(f,-63,sizeof(f));f[0][0][0]=f[0][0][1]=0;
	ans=max(ans,max(L-X[1],X[n]));
	/*for(int i=0;i<=n;++i)
		for(int j=0;i+j<=n;++j)
		{
			if(i==0&&j==0)continue;
			if(i)
			{
				f[i][j][0]=max(f[i][j][0],f[i-1][j][0]+X[i]-X[i-1]);
				f[i][j][0]=max(f[i][j][0],f[i-1][j][1]+(L-X[n-j+1])+X[i]);
			}
			if(j)
			{
				f[i][j][1]=max(f[i][j][1],f[i][j-1][1]+X[n-j+2]-X[n-j+1]);
				f[i][j][1]=max(f[i][j][1],f[i][j-1][0]+X[i]+(L-X[n-j+1]));
			}
			if(i+j==n)
			{
				ans=max(ans,f[i][j][0]);
				ans=max(ans,f[i][j][1]);
			}
			}*/
	for(int i=1;i<=n;++i)Sl[i]=Sl[i-1]+X[i];
	for(int i=1;i<=n;++i)Sr[i]=Sr[i-1]+nX[i];
	Calc();
	swap(X,nX);reverse(&X[1],&X[n+1]);reverse(&nX[1],&nX[n+1]);
	for(int i=1;i<=n;++i)Sl[i]=Sl[i-1]+X[i];
	for(int i=1;i<=n;++i)Sr[i]=Sr[i-1]+nX[i];
	Calc();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6528
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int l,r,d;
		cin>>l>>r>>d;
		int ct = 0;
		for(int i=l;i<=r;++i)
		{
			if(i%d==0)
			++ct;
		}
		cout<<ct;
    }
    return 0;
}


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

using namespace std;

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

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

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

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

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

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

int main(){
  int a,b,t;
  cin>>a>>b>>t;
  int c = 0;
  FOR(i,1,t+1)if(i%a==0)c+=b;
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
s = gets.chomp.to_s.split(//)
r = s[0]
cnt = 0
i = 1

while i <= s.size do
  if r.size == 2 || r != s[i]
    r = s[i]
    cnt += 1
    i += 1
  elsif r == s[i]
    r = s[i..i+1]
    cnt += 1
    i += 2
  end
end

puts cnt


Measured memory_bytes: 16764
#include<bits/stdc++.h>
using namespace std;
long long cost[10],n;
map<long long,long long> mp;
long long dfs(long long x)
{
	if(x==0)
		return 0;
	if(mp.count(x))
		return mp[x];
	long long ans=1e18;
	long long temp[6]={x/2,x/2+1,x/3,x/3+1,x/5,x/5+1};
	long long t[6]={2,2,3,3,5,5};
	for(int i=0;i<6;i++)
		if(temp[i]<x)
			ans=min(ans,dfs(temp[i])+(long long)min((double)abs(temp[i]-x)*cost[0],abs(temp[i]*t[i]-x)*(double)cost[0]+cost[t[i]]));
	mp[x]=ans;
	return mp[x];
}
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		mp.clear();
		cin>>n>>cost[2]>>cost[3]>>cost[5]>>cost[0];
		cout<<dfs(n)<<endl;
	}
	return 0;
}

Measured memory_bytes: 4768
#include <string>
#include <iostream>

using namespace std;

int main() {
    string S;
    string T;
    int A;
    int B;
    string U;
    cin >> S >> T >> A >> B >> U;

    if (S == U) {
        A -= 1;
    } else if (T == U) {
        B -= 1;
    }

    cout << A << " " << B << endl;
}

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

char a[1000][10];
int n[1000], x=1;

int main(){
    int N, m;
    char s[1000][11], t[1000][11];
    scanf("%d", &N);
    scanf("%s", a[0]);
    n[0]++;
    for(int i = 1; i < N; i++){
        scanf("%s", s[i]);
        bool used = false;
        for(int j = 0; j < x; j++){
            if(!strcmp(s[i], a[j])){
                used = true;
                n[j]++;
            }
        }
        if(!used){
            strcpy(a[x], s[i]);
            n[x]++;
            x++;
        }
    }
    scanf("%d", &m);
    for(int i = 0; i < m; i++){
        scanf("%s", s[i]);
        bool used = false;
        for(int j = 0; j < x; j++){
            if(!strcmp(s[i], a[j])){
                used = true;
                n[j]--;
            }
        }
        if(!used){
            strcpy(a[x], s[i]);
            n[x]--;
            x++;
        }
    }
    int mmax=0;
    for(int i = 0; i < x; i++){
        mmax=max(mmax, n[i]);
    }
    printf("%d\n", mmax);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool flag;
unsigned long long a1,a2,a3,m1,m2,m3;
unsigned long long x,y,z,ans,calc,cnt1,cnt2,cnt3;

unsigned long long  gcd(unsigned long long a,unsigned long long b){
	unsigned long long result =a;
	unsigned long long k=0;
	unsigned long long n=b;
	do{
		k=result %n;
		result=n;
		n=k;
	}while(k!=0);
	return result;
}
int main(){
	while(cin >> a1 >>m1 >>a2 >>m2 >>a3 >>m3){
		if(!(a1||m1||a2||m2||a3||m3))break;
		x=y=z=1;
		cnt1=cnt2=cnt3=0;
		while(1){
			cnt1++;
			x=(a1%m1)*(x%m1)%m1;
			if(x==1)break;
		}
		while(1){
			cnt2++;
			y=(a2%m2)*(y%m2)%m2;
			if(y==1)break;
		}
		while(1){
			cnt3++;
			z=(a3%m3)*(z%m3)%m3;
			if(z==1)break;
		}
		calc=cnt1/gcd(cnt1,cnt2)*cnt2;
		ans=cnt3/gcd(calc,cnt3)*calc;
		cout << ans<<endl;
	}
	return 0;
}

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

#define ll long long
#define pb push_back

const int maxn = 2e3 + 20;

int a[maxn] , mn[maxn];

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

	int n , x;
	cin >> n >> x;

	memset(mn , 63 , sizeof mn);
	for(int i = 0; i < n; i++)
		cin >> a[i];

	ll res = 1e18;
	for(int t = 0; t < n; t++)
	{
		ll sum = 0;
		for(int i = 0; i < n; i++)
			mn[i] = min(mn[i] , a[(i - t + n) % n]) , sum += mn[i];

		res = min(res , sum + 1LL * t * x);
	}

	cout << res << endl;
}
















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

int main(){
    int n;
    cin >> n;
    int t = 0, s = 0;
    for(int i = 0; i < n; i++){
        string T, S;
        cin >> T >> S;
        //辞書順で大きいものの判別
        if(T > S) t += 3;
        else if(T < S) s += 3;
        else{
            t++;
            s++;
        }
    }
    cout << t << ' ' << s << endl;
    return 0;
}


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

#define INF 1e9
using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()


template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

typedef long long ll;


int main() {
    int N = 0;
    cin >> N;
    int L[N];
    REP(i, N) {
        cin >> L[i];
    }
    sort(L, L + N);
    // 選択した二本は組み合わせなので重複しない。　よって、「選択した二本は(どっちがどっちか知らんけど)三角形の棒の中で最も長い二本」
    // とすれば三本の混合は起きなくなる。
    // 例えば 2,3,4は三角形の組み合わせだが、 2,3がForで決まってからの4と 3,2がForで決まってからの4は組み合わせにより重複しないが、
    // 3,4が決まってからの2と重複してしまう。
    // これを回避するために「選択した二本は(どっちがどっちか知らんけど)三角形の棒の中で最も長い二本」という制約を設けている。
    // この思考が出来るようにしたい前もハマったような・・・
    // REPで回しているインデックスの指す値,forで回しているインデックスの指す値をa,b (a>=b)とする。
    // とすると、 三角形の条件より、 max(b-a,a-b) < c < a+b が成立。
    // ここから条件を満たす棒の数を二分探索で求められる。
    // さらに c < b <= a が成立するため、  c < a+bは考えなくてよい。
    //
    int score = 0;
    REP(i, N) {
        for (int j = i + 1; j < N; ++j) {
            int a, b;
            a = L[i];
            b = L[j];
            if (a < b) swap(a, b);

            if ((a - b) >= b) continue;
            // bの立ち位置の確認
            // int *pos = lower_bound(L, L + N, b);
            // int last_index = (int) (pos - L);
            int *pos = upper_bound(L, L + N, max(b - a, a - b));
            int first_index = (int) (pos - L) - 1;
            int w = i - first_index - 1;
            score += w;
        }
    }

    cout << score << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
number1 = [2,4,5,7,9]
number2 = [3]
number3 = [0,1,6,8]
if N % 10 in number1:
    print('hon')
elif N % 10 in number2:
    print('bon')
elif N % 10 in number3:
    print('pon')

Measured memory_bytes: 61856
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		ArrayList<String> list = new ArrayList<String>();
		list.add("SUN"); list.add("MON"); list.add("TUE");
		list.add("WED"); list.add("THU"); list.add("FRI");
		list.add("SAT");
		System.out.println(7-list.lastIndexOf(sc.next()));
		sc.close();
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstring>
#include<string>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

const db PI = acos(-1);
db A, B, H, M;

int main() {
	
	// freopen("in.in", "r", stdin);
	scanf("%lf%lf%lf%lf", &A, &B, &H, &M);
	db agh = PI / 6 * H + PI / (6 * 60) * M, agm = 2 * PI / 60 * M;
	db agdis = fabs(agh - agm);
	if (agdis > PI) agdis = 2 * PI - agdis;
	db dis = sqrt(A * A + B * B - 2 * A * B * cos(agdis));
	printf("%.20lf\n", dis);

	return 0;
}		

Measured memory_bytes: 3640
n = int(input())
s = [input() for i in range(n)]
ans = [0] * 4
j = ["AC","WA","TLE","RE"]
for i in range(n):
    if s[i] == "AC":
        ans[0] += 1
    elif s[i] == "WA":
        ans[1] += 1
    elif s[i] == "TLE":
        ans[2] += 1
    else:
        ans[3] += 1
for i in range(4):
    print(j[i]+" x "+str(ans[i]))


Measured memory_bytes: 82600
#include<stdio.h>
#include<stdlib.h>
#define LEN 100000

struct mission
{
    char name[10];
    int time;
};
typedef struct mission mission;

int head ,tail;
mission Q[LEN];

int isEmpty()
{
    return head == tail;
}
int isFull()
{
    return head == (tail + 1)%LEN;//isFull
}
void enqueue(mission x)
{
    if (isFull())
        printf("Wrong!!No More");
    else
    {
     Q[tail] = x;
    tail = (tail + 1) % LEN;
    }
}
mission dequeue()
{
    if (isEmpty())
        printf("Wrong!!Already Empty");
    mission x = Q[head];
    head = (head + 1) % LEN;
    return x;
}
//返回最小值
int min(int a,int b)
{
    return a < b ? a : b;
}
int main()
{
    int elaps = 0,c;
    int m,n,i;
    mission u;
    scanf("%d %d",&m,&n);
    //按顺序将所有任务添加至队列
    for(i = 1;i <= m;i++)
    {
        scanf("%s%d",Q[i].name,&Q[i].time);
    }
    head = 1,tail = m+1;
    //模拟
    while(!isEmpty())
    {
        u = dequeue();
        c = min(n,u.time);//执行时间片q或所需时间u.t的处理
        u.time -= c;//计算剩余的所需时间
        elaps += c;//计算已经过的时间
        if(u.time > 0)//如果处理尚未结束则重新添加至队列
        {
            enqueue(u);
        }
        else
        {
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}




Measured memory_bytes: 3244
def main():
    x = int(input())
    if x <=599:
        print("8")
    elif x <= 799:
        print("7")
    elif x <= 999:
        print("6")
    elif x <= 1199:
        print("5")
    elif x<=1399:
        print("4")
    elif x<=1599:
        print("3")
    elif x<=1799:
        print("2")
    else:
        print("1")
main()


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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    int ans = 0;
    for (int i = 0; i < n;) {
        int j = i + 1;
        bool de = false, in = false;
        ans++;
        while (j < n) {
            if (a[j] > a[j - 1]) {
                if (de) break;
                in = true;
            } else if (a[j] < a[j - 1]) {
                if (in) break;
                de = true;
            }
            j++;
        }
        i = j;
    }
    cout << ans << endl;
    return 0;
}

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

/*
  let's try computer shogi!!!
  全探索で良い気がする
 */

int main(){
  int A,B,C,D,E,F;
  double maxp = -1.0; //最大濃度
  int maxw = 0; //最大水
  int maxs = 0; //最大砂糖
  cin>>A>>B>>C>>D>>E>>F;
  for(int i=0; i*A*100<=F;++i){
    for(int j=0; i*A*100+j*B*100<=F;++j){
      if(i==0 && j==0){continue;}
      int sugmax = min(F-i*A*100-j*B*100 , i*A*E+j*B*E);
      cerr<<sugmax<<"(sugmax)"<<endl;
      // sugmax以内で最大の砂糖の組み合わせを検索する
      for(int k=0;k*C<=sugmax;++k){
	int l = (sugmax - k*C) / D;
	double p = double(k*C+l*D) / double(i*A*100+j*B*100);
	if(p>maxp){
	  maxp = p;
	  maxw = i*A*100+j*B*100;
	  maxs = k*C+l*D;
	  cerr<<"update "<<p<<"(p),"<<maxw<<"(maxw),"<<maxs<<"(maxs),"<<i<<","<<j<<","<<k<<","<<l<<"(ijkl)"<<endl;
	}
      }
    }
  }
  cout<<maxw+maxs<<" "<<maxs<<endl;

  return 0;
  
}

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

using namespace std;

#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define REV(i,j,k) for(int i=j;i>=k;i--)
#define inf         freopen("in.txt", "r", stdin)
#define outf        freopen("out.txt", "w", stdout)
#define LL           long long
#define lnd (idx<<1)
#define rnd ((idx<<1)+1)
#define PB push_back
#define MAX 100010

int M;
LL tree[4*MAX];

void update(int idx,int b,int e,int p,int v)
{
    if(p < b || p > e) return;
    if(b == e)
    {
        tree[idx] = v;
        return;
    }

    int m = (b + e)>>1;
    update(lnd, b, m, p, v);
    update(rnd, m + 1, e, p, v);

    tree[idx] = (tree[lnd] * tree[rnd]) % M;
}

LL query(int idx,int b,int e,int l,int r)
{
    if(r < b || e < l) return 1;
    if(l <= b && e <= r) return tree[idx];

    int m = (b + e)>>1;
    return (query(lnd, b, m, l, r) * query(rnd, m + 1, e, l, r)) % M;
}

vector<int> mat[MAX];
LL dp[MAX];
int id, gigi[MAX], lf[MAX], rg[MAX];

int dfs(int p,int pa)
{
    lf[p] = id + 1;
    dp[p] = 1; id += (mat[p].size() - (p != pa));
    int c = id; rg[p] = id;

    for(auto x : mat[p])
    {
        if(x == pa) continue;
        gigi[x] = c--;

        dfs(x, p);
        dp[p] *= (dp[x] + 1); dp[p] %= M;
    }
}

LL prin[MAX];
void dfs2(int p,int pa)
{
    LL pVal = query(1, 0, MAX-1, gigi[pa], gigi[pa]);

    prin[p] = query(1, 0, MAX - 1, lf[p], rg[p]);
    if(p != pa) prin[p] = (prin[p] * pVal) % M;


    for(auto x : mat[p])
    {
        if(pa == x) continue;

        update(1, 0, MAX-1, gigi[x], 1);

        LL newVal = query(1, 0, MAX-1, lf[p], rg[p]);
        if(p != pa) newVal = (newVal * pVal) % M;

        update(1, 0, MAX-1, gigi[p], newVal + 1);

        dfs2(x, p);

        update(1, 0, MAX-1, gigi[x], dp[x] + 1);
        update(1, 0, MAX-1, gigi[p], dp[p] + 1);
    }
}

int main(void)
{
	ios::sync_with_stdio(false);
	//inf;

    int n, v, u;

	cin >> n >> M;
	FOR(i,1,n-1)
	{
	    cin >> u >> v;
	    mat[u].PB( v ); mat[v].PB( u );
	}

    dfs(1, 1);
	FOR(i,1,n) update(1, 0, MAX-1, gigi[i], dp[i] + 1);
	dfs2(1, 1);

	FOR(i,1,n) cout << prin[i] << endl;


	return 0;
}



Measured memory_bytes: 18176
from sys import stdin
N, C, K = [int(_) for _ in stdin.readline().rstrip().split()]
T = sorted([int(stdin.readline().rstrip()) for _ in range(N)])
i, ans = 0, 0
while i < N:
    ans += 1
    start = i
    while (i < N and T[i] - T[start] <= K and i - start < C):
        i += 1
print(ans)

Measured memory_bytes: 45660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<P> p, q;
    int sum = 0;
    bool ok = true;
    rep(i, n) {
        // a : 最下点　b : 増減
        int a = 0, b = 0;
        string s;
        cin >> s;
        rep(i, size(s)) {
            if(s[i] == '(') b++;
            else b--;
            chmin(a, b);
        }
        sum += b;
        if(b > 0) p.push_back(P(a, b));
        else q.push_back(P(a-b, -b)); 
    }
    if(sum != 0) ok = false;
    sort(rall(p));
    sort(rall(q));
    {
        int cnt = 0;
        rep(i, size(p)) {
            if(cnt + p[i].first < 0) ok = false;
            cnt += p[i].second;
        }
    }
    {
        int cnt = 0;
        rep(i, size(q)) {
            if(cnt + q[i].first < 0) ok = false;
            cnt += q[i].second;
        }
    }
    if(ok) Yes(); else No();
}

Measured memory_bytes: 11276
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int INF = 1000000000; // 10^9

int main() {
    int N; cin >> N;
    int V[N];
    rep(i, 0, N) cin >> V[i];
    sort(V, V+N);
    double start = V[0];
    rep(i, 1, N) start = (start + V[i]) / 2;
    cout << fixed << setprecision(5) << start << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		boolean first = true;
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			if (first) first = false;
			else
			{
				System.out.println();
			}
			String team[] = new String[n];
			int point[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				team[i] = sc.next();
				point[i] = sc.nextInt() * 3 + sc.nextInt() * 0 + sc.nextInt();
			}
			for (int i = n * 3; i >= 0; i--)
			{
				for (int j = 0; j < n; j++)
				{
					if (i == point[j])
					{
						System.out.printf("%s,%d\n", team[j], i);
					}
				}
			}
		}
	}
}

Measured memory_bytes: 12000
ABK = list(map(int,input().split()))
A=ABK[0]
B=ABK[1]
K=ABK[2]
kobaisu=[]
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        kobaisu.append(i)
print(kobaisu[-K])


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

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

int main()
{
    ll n;
    cin >> n;
    vector<ll > v;
    map<ll,ll> m;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        if(m[x]==0) v.pb(x);
        m[x]++;
    }
    sort(all(v));
    reverse(all(v));
    vector<ll> ans;
    for(ll i = 0; i < v.size(); i++)
    {
        if(ans.size() >= 2) break;
        ll x = v[i];
        if(m[x] >= 4)
        {

            ans.pb(x);
            ans.pb(x);
        }
        else if(m[x] >= 2 && m[x] <= 3) ans.pb(x);
    }
    if(ans.size() >= 2) cout << ans[0]*ans[1];
    else cout << 0;
}


Measured memory_bytes: 7284
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define rep(i,s,t) for(register int i=s;i<=t;++i)
const int N=2e5+11;
int ans;
char s[N],c;
int st[N];
int cnt;
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	rep(i,1,n){
		if(s[i]=='1'){
			if(cnt){
				if(c=='0')
					--cnt,++ans;
				else 
					++cnt;
			}
			else
				++cnt,c=s[i];
		}
		else{
			if(cnt){
				if(c=='1')
					--cnt,++ans;
				else 
					++cnt;
			}
			else
				++cnt,c=s[i];
		}
	}
	printf("%d\n",ans+ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s;cin>>s;
    string::size_type pos = s.find(",");
    while(pos != string::npos){
        s.replace(pos, 1, " ");
        pos = s.find(",", pos + 1);
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//n!
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
}
 
// 繰り返し二乗法 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
 
//nCr O(r) nがでかくても安心
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    //a=n!/(n-r)!=n~n-r+1までの総積->O(r)
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    //b=inv(r!)
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
 
ll inv_mod(ll n){
    // フェルマーの小定理
    return pow_mod(n,mod-2);
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,a,b;cin>>n>>a>>b;
    ll ans=pow_mod(2,n);
    ans--;
    if(ans<0) ans+=mod;
    ans-=combination_mod(n,a);
    if(ans<0) ans+=mod;
    ans-=combination_mod(n,b);
    if(ans<0) ans+=mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define p2d(v,n,m) rep(i,n){rep(j,m){pk(v[i][j]);}p("");}
#define fi first
#define se second
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll a[100001],b[100001],c[100001],d,n,m,x,y,z,h,w,k,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;
P pa;


struct UnionFind {
  VL data;
  UnionFind(int size) : data(size, -1) { }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(int x) {
    return -data[root(x)];
  }
  ll num_root(ll size){
    VL roots;
    rep(i,size)roots.pb(root(i));
    sort(all(roots));
    roots.erase(unique(all(roots)),roots.end());
    return roots.size();
  }
};

int main(void){
    cin>>n>>m>>k;
    UnionFind uf(n);
    vector<VL> B(n);
    rep(i,m){
        cin>>x>>y;
        x--; y--;
        uf.unite(x,y);
        B[x].pb(y);
        B[y].pb(x);
    }
    rep(i,k){
        cin>>x>>y;
        x--; y--;
        B[x].pb(y);
        B[y].pb(x);
    }
    rep(i,n){
        tmp=uf.size(i)-1;
        for(auto x: B[i]){
            if(uf.root(i)==uf.root(x))tmp--;
        }
        ps(tmp);
        if(i<n-1){
            ps(" ");
        }
        else{
            p("");
        }
    }
    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  int N;
  ll D;
  cin >> N >> D;
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    ll x, y;
    cin >> x >> y;
    ll kj = (x * x) + (y * y);
    if (kj <= D * D) ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3672
while gets
  w=$_.to_f
  case
  when w<=48 then puts "light fly"
  when w<=51 then puts "fly"
  when w<=54 then puts "bantam"
  when w<=57 then puts "feather"
  when w<=60 then puts "light"
  when w<=64 then puts "light welter"
  when w<=69 then puts "welter"
  when w<=75 then puts "light middle"
  when w<=81 then puts "middle"
  when w<=91 then puts "light heavy"
  when 91<w then puts "heavy"
  end
end

Measured memory_bytes: 8632
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

inline int isPrime(ll n){
  for(ll i = 2; i*i <= n; i++) if(n % i == 0) return 0;
  return 1;
}

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int q; cin >> q;
  vi ans(101010);
  rep(i,101010){
    if(i%2 == 1) ans[i] += (isPrime(i)+isPrime((i+1)/2))/2;
    ans[i+1] += ans[i];
  }
  rep(i,q){
    int l,r; cin >> l >> r;
    cout << ans[r]-ans[max(l-1,1)] << endl;
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3696
package main

import (
	"fmt"
	"math"
)

func main() {
	var n,m,x int
	fmt.Scan(&n,&m,&x)
	var a,b int
	for i:=0; i<m; i++{
		var tmp int
		fmt.Scan(&tmp)
		if tmp>x {
			a++
		} else {
			b++
		}
	}
	fmt.Println(math.Min(float64(a),float64(b)))

}

Measured memory_bytes: 512
#include <stdio.h>
int main()
{
    double L[10];
    double V1, V2;
    double meet_pos;
    double railway_lenth;
    int cnt1, cnt2;
    int output[50];
    
    cnt2 = 0;
    while(scanf("%lf,", &L[0]) != EOF){
    	for(cnt1 = 1; cnt1 < 10; cnt1++)
			scanf("%lf,", &L[cnt1]);
		scanf("%lf,%lf", &V1, &V2);
    	
    	railway_lenth = 0;
    	for(cnt1 = 0; cnt1 < 10; cnt1++)
			railway_lenth += L[cnt1];
    	meet_pos = railway_lenth * V1 / (V1 + V2);
    	
    	cnt1 = 0;
    	railway_lenth = 0;
    	while(railway_lenth < meet_pos)
			railway_lenth += L[cnt1++];
    	output[cnt2++] = cnt1;
    }
    
    for(cnt1 = 0; cnt1 < cnt2; cnt1++)
    {
		printf("%d\n", output[cnt1]);
	}
	
    return 0;
} 

Measured memory_bytes: 624
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

typedef vector< vector<int> > Graph;
pii dfs(Graph &g, vector<int> &color, int v, int c){
	color[v] = c;
	pii res(c==1, c==-1);
	FOR(it, g[v]){
		if(color[*it] == c) return pii(-1, -1);
		pii ret(0, 0);
		if(!color[*it] && (ret = dfs(g, color, *it, -c)).first < 0) return pii(-1, -1);
		res.first += ret.first;
		res.second += ret.second;
	}
	return res;
}

vector<pii> isBipartite(Graph &g){
	int n = g.size();
	vector<int> color(n);
	vector<pii> knap;
	REP(i, n){
		pii ret(0, 0);
		if(!color[i] && (ret = dfs(g, color, i, 1)).first < 0) return vector<pii>();
		if(ret.first || ret.second){
			knap.push_back(ret);
		}
	}
	return knap;
}

ll n, m;

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	Graph g(n);
	REP(i, m){
		int u, v;
		cin >> u >> v;u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans;
	vector<pii> knap = isBipartite(g);
	if(knap.empty()) cout << -1 << endl;
	else{
		vi dp(n+1);
		dp[0] = 1;
		int sum = 0;
		REP(i, knap.size()){
			RREP(j, sum+1){
				int t = dp[j];
				dp[j] = 0;
				dp[j+knap[i].first] |= t;
				dp[j+knap[i].second] |= t;
			}
			sum += max(knap[i].first, knap[i].second);
		}
		ll ans = 0;
		REP(i, sum+1) if(dp[i]) ans = max(ans, (ll)(i)*(n-i));
		cout << ans - m << endl;
	}
	return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;

const int len = 2e5+5;
int arr[len], cnt[len], dp[len];

int main(){
    int n, ans = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &arr[i]);

    for (int i = 1; i <= n; i++){
        dp[i] = cnt[arr[i]-1]+1;
        ans = max(ans, dp[i]);
        cnt[arr[i]] = dp[i];
    }

    printf("%d\n", n-ans);
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< int, i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dij geo2

signed main()
{
    int2(n, x);

    if (n == 2 && x == 2) {
        cout << "Yes" << endl << 1 << endl << 2 << endl << 3 << endl;
        return 0;
    }
    n = n * 2 - 1;
    if (x == 1 || x == n) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    vb used(n+1, false);
    vi ans(n, 0);
    if (x != 2) {
        for (int i = x-2; i < x+2; i++) {
            used[i] = true;
        }
        //used[x] = used[x-1] = used[x-2] = used[x+1] = true;
        int ptr = 1;
        rep(i, n / 2-1) {
            while (used[ptr]) ptr++;
            std::cout << ptr++ << std::endl;
        }
        cout << x-1 << endl << x << endl << x+1 << endl << x-2 << endl;
        while (ptr <= n) {
            while (ptr <= n && used[ptr]) ptr++;
            if (ptr > n) break;
            std::cout << ptr++ << std::endl;
        }
    } else {
        for (int i = x-1; i < x+3; i++) {
            used[i] = true;
        }
        //used[x] = used[x-1] = used[x+2] = used[x+1] = true;

        int ptr = 1;
        rep(i, n / 2-1) {
            while (used[ptr]) ptr++;
            std::cout << ptr++ << std::endl;
        }
        cout << x+1 << endl << x << endl << x-1 << endl << x+2 << endl;
        while (ptr <= n) {
            while (ptr <= n && used[ptr]) ptr++;
            if (ptr > n) break;
            std::cout << ptr++ << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3072
// Cursor jump numbers
// main @ 39
// global @ 35
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

ll nc2(ll n) {
  if(n < 2) return 0;
  return (n*n - n)/2;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> plc(1, 0);
  vector<int> hash(n+1, 0);
  for(int i=1; i<=n; i++) {
    int tp;
    cin >> tp;
    plc.push_back(tp);
    hash[tp]++;
  }
  ll prd = 0;
  for(int i=1; i<=n;i++) {
    prd = prd + nc2(hash[i]);
  }
  for(int i=1; i<=n; i++) {
    if(hash[plc[i]] < 2) cout << prd << '\n';
    else {
      cout << prd  + nc2(hash[plc[i]] - 1) -  nc2(hash[plc[i]]) << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 4340
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
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;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll A = input();
  ll B = input();
  ll C = input();
  ll D = input();
  
  while(1){
    C -= B;
    if(C <= 0){
      output("Yes");
      break;
    }
    A -= D;
    if(A <= 0){
      output("No");
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <set>
#include <cmath>
#include <limits>
#include <map>

#include <numeric>
#include <type_traits>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> hs(n+1);
  for (int i=1; i<=n; ++i) {
    cin >> hs[i];
  }

  map<int, vector<int>> routes;
  for (int i=0; i<m; ++i) {
    int a,b;
    cin >> a >> b;
    routes[a].push_back(b);
    routes[b].push_back(a);
  }

  set<int> ans;
  for (int i=1; i<=n; ++i) {
    int h = hs[i];
    bool check = true;
    for (int j=0; j<routes[i].size(); ++j) {
      // cout << " h " << h << " " << hs[routes[i][j]] << endl;
      if (h <= hs[routes[i][j]] ) check = false;
    }
    // cout << "check" << i << " " << check << endl; 
    if (check == true) ans.insert(i);
  }
  cout << ans.size() << endl;

  

  return 0;
}

Measured memory_bytes: 17596
# coding: utf-8

from statistics import mean

N=int(input())
A=list(map(int,input().split()))
a1=int(mean(A))
a2=a1+1
ans=10**9

tmp=0
for i in range(N):
    tmp+=(A[i]-a1)**2
ans=min(ans,tmp)

tmp=0
for i in range(N):
    tmp+=(A[i]-a2)**2
ans=min(ans,tmp)

print(ans)

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

int main()
{
    int a, b, c, d, e;
    int na, nb, nc;

    while( cin >> a >> b >> c >> d >> e )
    {
        if( a + b + c + d + e == 0 )
            break;

        cin >> na >> nb >> nc;

        int sum = a * na + b * nb + c * nc;

        if( na + nb + nc < d )
            cout << min( sum, d * e ) << endl;
        else
        {
            if( nc >= d )
                cout << e * nc + a * na + b * nb << endl;
            else if( nb + nc >= d )
                cout << min( sum, e * d + a * na + b * ( nb + nc - d ) ) << endl;
            else
                cout << min( sum, e * d + a * ( na + nb + nc - d ) ) << endl;
        }
    }

    return 0;
}


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

using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

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

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int64 N;
  cin >> N;
  vector< int64 > X(N), Y(N);
  vector< char > D(N);
  for(int i = 0; i < N; i++) cin >> X[i] >> Y[i] >> D[i];
  double l = 0, r = 1e18;

  long double ret = 1e18;
  {
    long double a = 1e18, b = 1e18, c = -1e18, d = -1e18;
    for(int i = 0; i < N; i++) {
      double x = X[i], y = Y[i];
      chmin(a, x);
      chmin(b, y);
      chmax(c, x);
      chmax(d, y);
    }
    chmin(ret, (c - a) * (d - b));
  }

  auto check = [&](long double v) {
    long double a = 1e18, b = 1e18, c = -1e18, d = -1e18;
    for(int i = 0; i < N; i++) {
      long double x = X[i], y = Y[i];
      if(D[i] == 'R') x += v;
      else if(D[i] == 'L') x -= v;
      else if(D[i] == 'U') y += v;
      else y -= v;
      chmin(a, x);
      chmin(b, y);
      chmax(c, x);
      chmax(d, y);
    }
    return (c - a) * (d - b);
  };
  for(int i = 0; i < 300; i++) {
    double p = (l * 2 + r) / 3;
    double q = (l + 2 * r) / 3;
    if(check(p) < check(q)) r = q;
    else l = p;
  }
  cout << min(ret, check(l)) << endl;
}



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

int m, n;
int ans[150];

int dp[2050][2050]; // S?????????????????£??????

using Set = bitset<12>;

int rec(int asked, int answer){ // ??????????????????aked???answer??¨??????????????????
    int &res = dp[asked][answer];
    if(res != -1) return res;
    res = m;

    {
        int cnt = 0;
        for(int i = 0; i < n; ++i){
            if((ans[i] & asked) == answer){
                ++cnt;
            }
        }
        if(cnt <= 1) return res = 0;
    }

    for(int i = 0; i < m; ++i){
        if(asked >> i & 1) continue;
        int cnt[2] = {};
        for(int j = 0; j < n; ++j){
            if((ans[j] & asked) == answer){
                ++cnt[ans[i] >> j & 1];
            }
        }
        // if(cnt[0] == 0 || cnt[1] == 0) continue;
        int tmp = 0;
        for(int j = 0; j < 2; ++j){
            tmp = max(tmp, 1 + rec(asked | 1<<i, answer | (j << i)));
        }
        res = min(res, tmp);
    }
    return res;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    while(cin >> m >> n && m){
        for(int i = 0; i < n; ++i){
            char buf[100];
            cin >> buf;
            ans[i] = 0;
            for(int j = 0; j < m; ++j){
                if(buf[j]-'0') ans[i] |= 1 << j;
            }
        }
        memset(dp,-1,sizeof(dp));
        cout << rec(0,0) << endl;
        // cout << "=================" << endl;
    }
}

Measured memory_bytes: 19516
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int,int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x){
  return x * x;
}
ll mod = 1e9 + 7;

signed main (){
  int N;cin >> N;
  vint a(N);
  int A =0;
  rep(i,N){
 cin >> a.at(i);
  A ^= a.at(i);
  }
    
  rep(i,N){
int ans = A ^ a.at(i);
if(i == N -1){
cout << ans << endl;
}else{
cout << ans << " ";
}
  }
  return 0;
}


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



class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray();
        this.Height = inpt[0];
        this.Width = inpt[1];

        this.SetMap();

        for(int i=0; i<this.Height; i++) {
            string row = Reader.ReadLine();
            for(int j=0; j<this.Width; j++) {
                if(row[j] == '#') {
                    this.RedMap[i,j] = true;
                    this.BlueMap[i,j] = true;
                }
            }
        }

        this.PrintMap(this.RedMap);
        Console.WriteLine(string.Empty);
        this.PrintMap(this.BlueMap);

    }

    private void PrintMap(bool[,] map) {
        StringBuilder str = new StringBuilder();
        for(int i=0; i<map.GetLength(0); i++) {
            for(int j=0; j<map.GetLength(1); j++) {
                if(map[i,j]) {
                    str.Append('#');
                } else {
                    str.Append('.');
                }
            }
            str.AppendLine(string.Empty);
        }
        Console.Write(str.ToString());
    }

    private void SetMap() {
        this.BlueMap = new bool[this.Height, this.Width];
        this.RedMap = new bool[this.Height, this.Width];

        for(int i=0; i<this.Height; i++) {
            for(int j=0; j<this.Width; j++) {
                if(i%2 == 0) {
                    if(j<this.Width - 1) {
                        this.BlueMap[i,j] = true;
                    }
                } else if(j==0) {
                    this.BlueMap[i,j] = true;
                }
                if(i%2 != 0 && j > 0) {
                    this.RedMap[i,j] = true;
                } else if(j == this.Width - 1) {
                    this.RedMap[i,j] = true;
                }
            }
        }
    }

    private bool[,] BlueMap;
    private bool[,] RedMap;

    private int Height;
    private int Width;


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

5 5
.....
.#.#.
.....
.#.#.
.....

";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 6744
n, a, b, c, d = map(int, input().split())
s = input()

a = a-1
b = b-1
c = c-1
d = d-1

for i in range(a+1, d):
    if s[i-1] == '#' and s[i] == '#':
        print('No')
        exit()

if c < d:
    print('Yes')
    exit()

for i in range(b, d+1):
    if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
        print('Yes')
        exit()
print('No')


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

template <class T>
using V = vector<T>;

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for(int i=m; i<n; i++)

int main(){
    int N;
    cin >> N;
    V<int> P(N);
    rep(i, N) cin >> P.at(i);
    int min = 200000;
    int cnt = 0;
    rep(i, N){
        if(min >= P.at(i)){
            min = P.at(i);
            cnt++;
        } 
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4016