akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int Maxn = 1005;

int n, D;
int cnt[Maxn][Maxn];
int B[Maxn][Maxn];

void Add(int X1, int X2, int Y1, int Y2, int val)
{
    if (X1 > X2) {
        Add(X1, D - 1, Y1, Y2, val);
        Add(0, X2, Y1, Y2, val);
        return;
    }
    if (Y1 > Y2) {
        Add(X1, X2, Y1, D - 1, val);
        Add(X1, X2, 0, Y2, val);
        return;
    }
    B[X1][Y1] += val;
    B[X2 + 1][Y1] -= val;
    B[X1][Y2 + 1] -= val;
    B[X2 + 1][Y2 + 1] += val;
}

bool Check(int k)
{
    int t = k / D;
    ll got = ll(t) * (t);
    int k2 = k % D;
    fill((int*)B, (int*)B + Maxn * Maxn, 0);
    for (int i = 0; i < D; i++)
        for (int j = 0; j < D; j++)
            if (cnt[i][j] <= got) Add(0, D - 1, 0, D - 1, 1);
            else {
                if (k2 == 0) return false;
                int lft = cnt[i][j] - got;
                int begi = (i - k2 + 1 + D) % D;
                int begj = (j - k2 + 1 + D) % D;
                if (lft <= t) {
                    Add(begi, i, 0, D - 1, 1);
                    Add(0, D - 1, begj, j, 1);
                    Add(begi, i, begj, j, -1);
                } else if (lft <= 2 * t + 1)
                    Add(begi, i, begj, j, 1);
                else return false;
            }
    for (int i = 0; i < D; i++)
        for (int j = 0; j < D; j++) {
            if (i > 0) B[i][j] += B[i - 1][j];
            if (j > 0) B[i][j] += B[i][j - 1];
            if (i > 0 && j > 0) B[i][j] -= B[i - 1][j - 1];
            if (B[i][j] >= D * D) return true;
        }
    return false;
}

int main()
{
    scanf("%d %d", &n, &D);
    for (int i = 0; i < n; i++) {
        int x, y; scanf("%d %d", &x, &y);
        cnt[x % D][y % D]++;
    }
    int lef = 0, rig = 1000000007;
    while (lef <= rig) {
        int mid = lef + rig >> 1;
        if (Check(mid)) rig = mid - 1;
        else lef = mid + 1;
    }
    printf("%d\n", rig);
    return 0;
}


Measured memory_bytes: 8064
// https://atcoder.jp/contests/dp/tasks/dp_i
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define EPS (1e-7)
#define INF (1e9)
#define MODI (1000000007)

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// dp[i][j] : コインをi枚使い、j枚が表である確率
// double dp[3001][3001];
double dpA[3001], dpB[3001];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    // 入力、DP後、DP前
    vector<double> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    dpB[0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            // i-1回目で表の枚数がj-1で、i回目が表
            // i-1回目で表の枚数がjで、i回目が裏
            dpA[j] = dpB[j - 1] * p[i - 1] + dpB[j] * (1.0 - p[i - 1]);
        }
        swap(dpA, dpB);
    }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++) {
        ans += dpB[i];
    }
    printf("%0.10f\n", ans);

    return 0;
}

Measured memory_bytes: 384
from collections import deque
K=int(input())

d=[1000000 for x in range(K+1)]
d[1]=1

def bfs(K):
  q=deque()
  q.append(1)
  while q:
    nx=q.popleft()
    if d[(nx*10)%K]>d[nx]:
      d[(nx*10)%K]=d[nx]
      q.appendleft((nx*10)%K)
    if d[(nx+1)%K]>d[nx]+1:
      d[(nx+1)%K]=d[nx]+1
      q.append((nx+1)%K)
  return d[0]

print(bfs(K))

Measured memory_bytes: 6084
#include<bits/stdc++.h>
using namespace std;
string s;
int n;
int main(){
  cin>>s;n=s.size();
  int l=0,r=n-1,ans=0;
  while(l<r){
    ans+=(s[l]!=s[r]);
    l++,r--;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i=0; i<n; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i=0; i<k; i++) ans += p[i];
    cout << ans << endl;
}


Measured memory_bytes: 3196
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int q = sc.nextInt();
		for(int i=0;i<q;i++){
			int c = sc.nextInt();
			int a = sc.nextInt();
			int n = sc.nextInt();
			int min = Math.min(Math.min(c,a),n);
			int team = min;
			c -= min;
			a -= min;
			min = Math.min(a,c/2);
			team += min;
			c -= min*2;
			team += c/3;
			System.out.println(team);
		}
	}
}

Measured memory_bytes: 20704
n,k=map(int,input().split())
def ans():
  m=n
  if k>((n-1)*(n-2)//2):
    print(-1)
    return
  else:
    c=(n-1)*(n-2)//2-k
    a=[]
    for i in range(2,n+1):
      a.append([1,i])
    if c>0:
      for i in range(2,n+1):
        for j in range(i+1,n+1):
          a.append([i,j])
          c-=1
          if c==0:
            break
        if c==0:
          break
    print(len(a))
    for i in range(len(a)):
      print(a[i][0],a[i][1])
ans()

Measured memory_bytes: 4120
# coding: utf-8
# Your code here!

import itertools

a, b = map(int, input().rstrip().split())
l = [a, b, a-1, b-1]
comb = list(itertools.combinations(l, 2))
sum_comb = list(map(sum, comb))
out = max(sum_comb)
print(out)

Measured memory_bytes: 3060
from itertools import combinations

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

def f(a, b, c):
    return len(set([a, b, c])) == 3 and a+b>c and b+c>a and c+a>b

ans = 0
for a, b, c in combinations(L, 3):
    if f(a, b, c):
        ans += 1
print(ans)

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

int main()
{
    int rankCount[31]={0};
    int number[100],score[100],count=0;
    while(scanf("%d,%d",&number[count],&score[count]),number[count] || score[count]){
        rankCount[score[count]]++;
        count++;
    }

    int n;
    while(cin>>n){
        int rank=0;
        for(int i=0; i<count; i++){
            if(number[i]==n){
                for(int j=30; j>score[i]; j--){
                    if(rankCount[j]>0){
                        rank++;
                    }
                }
                rank++;
                break;
            }
        }
        cout<<rank<<endl;
    }
    return 0;
}

Measured memory_bytes: 1244
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vector<int> a(MAX), b(MAX);
    for (int i = 0; i < n / 2; i++) {
        int x, y; cin >> x >> y; x--, y--;
        a[x]++, b[y]++;
    }
    int ma = max_element(begin(a), end(a)) - begin(a);
    int mb = max_element(begin(b), end(b)) - begin(b);
    if (ma != mb) {
        cout << n - a[ma] - b[mb] << endl;
    } else {
        int a0 = a[ma]; a[ma] = 0;
        int b0 = b[mb]; b[mb] = 0;
        int a1 = *max_element(begin(a), end(a));
        int b1 = *max_element(begin(b), end(b));
        cout << n - max(a0 + b1, a1 + b0) << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

//for (auto& e : array) 
//cout << count << endl;



signed main()
{
    ll X;
    cin >> X;

    ll count = 0;
    ll money = 100;
    while(money < X){
        ++count;
        money *= 1.01;
    }
    cout << count << endl;

}



Measured memory_bytes: 3632
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp*/
#include <iostream>
#include <map>
#include <queue>

using namespace std;

struct process{
    string name;
    int time;
};

int main(){
    int n,q;
    int time=0;
    queue<struct process> tasks;

    cin>>n;
    cin>>q;
    for(int i=0;i<n;i++){
        struct process p;
        cin>>p.name;
        cin>>p.time;
        tasks.push(p);
    }
    while(!tasks.empty()){
        struct process p=tasks.front();
        p.time-=q;
        tasks.pop();
        if(p.time>0){
            tasks.push(p);
            time+=q;
        }else{
            time+=q+p.time;
            cout<<p.name<<" "<<time<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4404
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <ctime>
#include <cassert>
#include <queue>
#include <deque>
#include <stack>
#include <memory.h>
#include <bitset>
#include <cstring>
#include <assert.h>
#include <random>

using namespace std;

#pragma comment(linker, "/STACK:64000000")

#define ll long long
#define mp make_pair

const double pi = 3.14159265358979323846;
const double eps = 1e-6;
const ll maxn = 2001;
const ll inf = 1000000007;
const ll mod = 1000000007;

ll n, a[maxn], x, b[maxn][maxn];

int main() {
	
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		b[i][0] = a[i];
		int k = 0;
		int j = i - 1;
		if (j < 0)
			j = n - 1;
		while (j != i) {
			k++;
			b[i][k] = min(a[j], b[i][k - 1]);
			j--;
			if (j < 0)
				j = n - 1;
		}
	}
	ll ans = -1;
	for (int i = 0; i < n; i++) {
		ll sum = x * i;
		for (int j = 0; j < n; j++) {
			sum += b[j][i];
		}
		if (sum < ans || ans == -1)
			ans = sum;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
#include <math.h>//pow(x,y)=x^y
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(i,n) for (int i=0; i <(n);i++)
#define ll long long
using namespace std;

int main() {
double B;
ll A;
int C;
cin>>A>>B;
C = round(B*100);

ll R;
R = A*C/100;
if(A==0 || B==0){
cout << 0 << endl;
}else{
  cout << R << endl;
}

}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::string s, t;
    std::cin >> s >> t;

    std::vector<int> pos[26];
    for (int i = 0; i < s.size(); i++) pos[s[i] - 'a'].push_back(i);

    i64 ret = 0;
    int p = -1;
    for (auto c : t) {
        auto &v = pos[c - 'a'];
        auto it = std::upper_bound(v.begin(), v.end(), p);
        if (it == v.end()) {
            if (v.empty()) {
                std::cout << -1 << std::endl;
                return 0;
            }
            ret += s.size() - p + v.front();
            p = v.front();
        } else {
            ret += *it - p;
            p = *it;
        }
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1216
s = list(input())
t = list(input())
s = [ord(i) for i in s]
t = [ord(i) for i in t]
s_new = sorted(s)
t_new = sorted(t,reverse=True)
flag = False
for i in range(len(s)):
    if len(t) == i:
        break
        
        
    if s_new[i] < t_new[i]:
        flag = True
        break
        
    elif s_new[i] > t_new[i]:
        break
        
    if i == len(s)-1:
        if i < len(t)-1:
            flag = True
        
print('Yes' if flag ==True else 'No')


Measured memory_bytes: 38256
x,k,d=list(map(int,input().split()))
flag=0
if(x<0):
    flag=1
    x=abs(x)
if(x-k*d<0):
    t=(x//d)
    if(t&1==k&1):
        print(abs(x-t*d))
    else:
        print(abs(x-(t+1)*d))
else:
    print(abs(x-k*d))

Measured memory_bytes: 9120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{
    class Program
    {
        static void Main(string[] args)
        {
            var o = Console.ReadLine();
            var e = Console.ReadLine();
            var s = "";
            for(int i = 0; i < e.Length; i++)
            {
                s += o[i].ToString() + e[i].ToString();
            }
            if(o.Length != e.Length)
            {
                s += o[o.Length - 1];
            }
            Console.WriteLine(s);
        }
    }
}


Measured memory_bytes: 13140
n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    if abs((x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3)) < 1e-10: print("YES")
    else: print("NO")


Measured memory_bytes: 5604
#include "bits/stdc++.h"
using namespace std;

const int N=2e5+20;

int n,a[N];
priority_queue <pair <int,int>> pq;
long long ans;

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

	sort(a,a+n);
	pq.push({a[n-2],a[n-1]});
	pq.push({a[n-2],a[n-1]});
	ans+=a[n-1];

	for(int i=n-3;i>=0;i--)
	{
		auto p=pq.top();
		pq.pop();

		ans+=p.first;
		pq.push({a[i],p.first});
		pq.push({a[i],p.second});
	}
	printf("%lld",ans);
}

Measured memory_bytes: 6180
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
  int N,sum=0;
  cin >>N;

  for(int i=1;i<=N;i++){
    sum+=i;
  }

  cout << sum <<endl;


  return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, c;
  cin >> a >> b >> c;

  string ans;
  ll c1 = abs(a - b);
  ll c2 = abs(a - c);
  if (c1 > c2) ans = "B";
  else
    ans = "A";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//ll GCD(ll x,ll y){
//    if(y == 0) return x;
//    else return GCD(y,x%y);
//}
const int MOD = 1000000007;


int main() {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    ll cnt = 0;
    cnt = min(a,k);
    k-=cnt;
    ans += cnt * 1;
    if(k == 0){
        cout << ans << endl;
        return 0;
    }
    cnt = min(b,k);
    k -= cnt;
    ans += cnt * 0;
    if(k == 0){
           cout << ans << endl;
           return 0;
    }
    cnt = min(c,k);
    k -= cnt;
    ans += cnt * -1;
    cout << ans << endl;
}




Measured memory_bytes: 3632
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int, input().split())) for _ in range(m)]

sorted_ab=sorted(bc, reverse=True, key=lambda x: x[1])
new_ab=[]
ans=[]

for i in range(m):
    if len(new_ab)<=n:
        tmp_l=[sorted_ab[i][1]]*sorted_ab[i][0]
        new_ab+=tmp_l
    else:
        break

final_list=a+new_ab
final_list.sort(reverse=True)

print(sum(final_list[:n]))


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

void f(int ct, string s, int n) {
  if (ct == 0) {
    cout << s << endl;
    return;
  }
  for(int i=0; i<n+2; i++){
    string tmp=s;
    tmp.push_back('a'+i);
    f(ct-1, tmp, max(n, i));
  }
}

int main() {
  int n;
  cin >> n;
  f(n - 1, "a", 0);
  return 0;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T x; cin >> x; return x; }

class polygon {
private:
	vector<pair<int, int>>vertex;
public:
	static const int on_vertex = 0;
	static const int on_side = 1;
	static const int inside = 2;
	static const int outside = 3;
	polygon(int n) {
		vertex.reserve(n);
	}
	void push_back(int x, int y) {
		vertex.push_back(make_pair(x, y));
	}
	int contains(int x, int y) {
		int ret = 0;
		int num = vertex.size();
		REP(i, num) {
			if (make_pair(x, y) == vertex[i]) {
				return on_vertex;
			} else {
				int x0 = vertex[i].first, y0 = vertex[i].second, x1 = vertex[(i + 1) % num].first, y1 = vertex[(i + 1) % num].second;
				if (y0 != y1) {
					double cross_x = (double)((x0 * y1 - x1 * y0) + (x1 - x0) * y) / (y1 - y0);
					if (min(y0, y1) <= y && y < max(y0, y1)) {
						if (abs(cross_x - x) < EPS) {
							return on_side;
						} else if (cross_x > x) {
							++ret;
						}
					}
				} else {
					if (y0 == y && (x0 < x && x < x1 || x1 < x && x < x0)) {
						return on_side;
					}
				}
			}
		}
		return ret % 2 == 1 ? inside : outside;
	}
};
signed main() {
	int n = in();
	polygon pol(n);
	REP(i, n) {
		int x = in(), y = in();
		pol.push_back(x, y);
	}
	int q = in();
	REP(i, q) {
		int x = in(), y = in();
		switch (pol.contains(x, y)) {
		case polygon::outside:
			cout << 0 << endl;
			break;
		case polygon::on_vertex:
		case polygon::on_side:
			cout << 1 << endl;
			break;
		case polygon::inside:
			cout << 2 << endl;
			break;
		}
	}
}


Measured memory_bytes: 3072
#include <cstdio>
#include <cmath>
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
int main( void ){
	int n;
	if (!scanf( "%d", &n )){
		return -1;
	}
	printf("%d\n", n*n);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include <queue>
#include<algorithm>
#include <bitset>
#include <math.h>
#include <numeric>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;
#define INF 10000000000000


inline ll Upstair(ll n){
	ll rt;
	if(n==1) return 1;
	return n*Upstair(n-1);
}

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

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};

template<class T>
class Vec3
{
	public:
		T act[3];
};

int Stair( int now, vector<ll> &H )
{
	if( H[now] >= H[now+1] ){}
	
}

int main(void) {
	
	ll N,M;
	inp(N);
	inp(M);
	priority_queue<ll> A;
	rep(i,N){
		ll a;
		inp(a);
		A.push(a);
	}
	rep(m,M){
		ll max = A.top(); A.pop();
		A.push(max/2);
	}
	ll sum =0;
	rep(i,N){
		sum += A.top();A.pop();
	}
	out(sum);
}

Measured memory_bytes: 1400
import static java.math.BigDecimal.ROUND_HALF_DOWN;

import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] v = new int[n];
    for (int i = 0; i < n; i++) {
      v[i] = Integer.parseInt(sc.next());
    }
    pw.println(
      IntStream.of(v).sorted().mapToObj(vi -> BigDecimal.valueOf(vi)).
        reduce(
          (va, vb) -> va.add(vb).divide(BigDecimal.valueOf(2), 10, ROUND_HALF_DOWN)
        ).get().doubleValue()
    );
  }
}


Measured memory_bytes: 31056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define N 1000000007
#define INF (1ll<<60) - 1
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
ll seive[10000005];
ll val[10000005],dp[10000005];
void seiv(){
	for(int i =2; i<10000001; i++){
		if(!seive[i]){
			val[i]=2;
			for(int j = 2*i ; j< 10000001; j+=i){
				seive[j] = 1;
			    ll x = i;
			    ll temp = 0;
			    while(j%x == 0){
			    	temp++;
			    	x = x*i;
				}
				val[j] *= (temp+1);
			}
		}
	}
	dp[1] = 1;
	rep(i,2,10000000){
	   dp[i] =dp[i-1] + i*val[i];
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,l,h,x,k,y,q,n,m,z;
    rep(i,1,10000000) val[i] =1ll;
    seiv();
    cin>>n;
    cout<<dp[n];
}

Measured memory_bytes: 237968
#include <bits/stdc++.h>
using namespace std ;
///OK @Tanvir
/*******
BETTER APPROACH:

1. SORTING KORE ADJACENT ELEMENT CHECK
2. std::set (distinct element) check

*/
#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<int, pii>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair


#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

const int mod = 1e9 + 7;

int ADD(int a, int b, int m = mod) {
    int s = a;
    s += b;
    if( s >= m )
      s -= m;
    return s;
}

int MUL(int a, int b, int m = mod) {
    return (1LL * a * b % m);
}

int power(int a, int b, int m = mod) {
    int res = 1;
    while( b ) {
        if( b & 1 ) {
            res = 1LL * res * a % m;
        }
        a = 1LL * a * a % m;
        b /= 2;
    }
    return res;
}


const int maxn = 1e9 + 1;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int val;
    set<int> s;
    ///int arr[n];
    for(int i=0; i<n; i++){
        cin>>val;
        s.insert(val);
    }
    ///cout<<s.size()<<"\n";
    cout<<((s.size()==n)? "YES": "NO")<<"\n";





    return 0;

}


/******
First ACCEPTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
bool cnt[maxn];


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout.tie(0);
    bool hobe = true;

    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        int val;
        cin>>val;
        if(cnt[val]) hobe= false;

        cnt[val]= true;

    }
    if(hobe) cout<<"YES\n";
    else cout<<"NO\n";


    return 0;
}

*/
/**********************************************************************************

6
4 1 3 1 6 2

5
2 6 1 4 5



*************************************************************************************/


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	string s;int ans=0,x=0;
	cin>>s;
	for (int i=0;i<3;i++){
		if (s[i]=='S'){
			ans=max(ans,x);
			x=0;
		}
		else
			x++;
	}
	ans=max(ans,x);
	cout<<ans;
	re 0;
}


Measured memory_bytes: 3552
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
void func(int);
int main(void)
{
	int m,n,i,nn,p,a[32],j;
	long long x,b[32];
	scanf("%d %d",&m,&n);
	j=0;
	nn=n;
	p=1;
	while(nn>=p)	{
		a[j]=p;
		p=p+p;
		j++;
	}
//	for(i=0;i<j;i++)	printf("%d ",a[i]);
	b[0]=m;
	for(i=1;i<j;i++)	{
		b[i]=b[i-1]*b[i-1];
		b[i]%=1000000007;
	}
	x=1;
	for(i=j-1;i>=0;i--)	{
		if(nn>=a[i])	{
			x*=b[i];
			x%=1000000007;
			nn-=a[i];
		}
	}
	printf("%lld\n",x);
	return 0;
}


Measured memory_bytes: 2708
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using lint = long long;
using P = pair<int, int>;

// int A, F, H, I, J, K, L, M, N, S, T, U;
lint F, H, I, J, K, L, M, N, S, T, U;
//string S;
lint ans = 0;

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

	cin >> N >> K;
	vector<lint> enemies(N);
	rep (i, N) {
		cin >> enemies[i];
	}

	sort(enemies.begin(), enemies.end());
	rep (i, N - K) {
		ans += enemies[i];
	}

	cout << ans << endl;
	return 0;
}

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

int main()
{
  int vowel['a' + 26] = {};
  vowel['a'] = 1;
  vowel['e'] = 1;
  vowel['i'] = 1;
  vowel['o'] = 1;
  vowel['u'] = 1;
  char c;
  cin >> c;
  cout << ((1 == vowel[c]) ? "vowel" : "consonant");
  return 0;
}


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

int main() {
  int n;
  cin >> n ;
  string ans;
  ans = "No";
  for(int ichi = 1; ichi<10; ichi++){
    for(int ni =1; ni<10; ni++){
      if(ichi*ni == n) ans = "Yes";
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    count = 0
    res = False
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            count += 1
            if count >= 3:
                res = True
        else:
            count = 0
    if res:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 62428
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
const int maxn=100010;
typedef struct p
{
	int par,vis;
}p;
p s[maxn];

void init(int n){
	for(int i=1;i<=n;i++){
		s[i].par=i;
		s[i].vis=0;
	}
}
int main()
{
	int n,q;
	while(cin>>n>>q)
	{
		if(n+q==0)  break;
		init(n);
		s[1].vis=1;
		for(int i=2;i<=n;i++){
			int x;
			scanf("%d",&x);
			s[i].par=x;
		}
		getchar();
		long long sum=0;
		while(q--){
			char sh;
			int a;
			scanf("%c%d%*c",&sh,&a);
			if(sh=='M'){
				s[a].vis=1;
			}else{
				if(s[a].vis==1){
					sum+=a;
				}else{
					while(true){
						if(s[a].vis==1){
							sum+=a;  break;
						}else{
							a=s[a].par;
						}
					}
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 4012
package main

import (
	"fmt"
)

func main() {
	var n, c int
	fmt.Scan(&n, &c)
	x := make([]int, n)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i], &v[i])
	}
	fmt.Printf("%d\n", findMaxCalorie(c, x, v))
}

func findMaxCalorie(c int, x, v []int) int {
	ls, ld := findLeftSafePoints(x, v)
	rs, rd := findRightSafePoints(c, x, v)
	lMax := calcLeftMaxCalorie(c, ls, rd)
	rMax := calcRightMaxCalorie(c, rs, ld)
	if rMax > lMax {
		return rMax
	}
	return lMax
}

func calcLeftMaxCalorie(c int, singlePoses, doublePoses []gain) (max int) {
	var curSingleIdx, curDoubleIdx, curCal int
	for i := 0; i < len(doublePoses); i++ {
		curCal += doublePoses[i].totalGain
	}
	max = curCal
	curDoubleIdx = len(doublePoses)
	for singleSafePontsNum := 1; singleSafePontsNum <= len(singlePoses); singleSafePontsNum++ {
		for i := curSingleIdx; i < singleSafePontsNum; i++ {
			curCal += singlePoses[i].totalGain
			curSingleIdx = i
		}
		curSinglePos := singlePoses[curSingleIdx].pos
		for i := curDoubleIdx - 1; i > -1 && doublePoses[i].pos <= curSinglePos; i-- {
			curCal -= doublePoses[i].totalGain
			curDoubleIdx = i
		}
		curSingleIdx++
		if curCal > max {
			max = curCal
		}
	}
	return
}

func calcRightMaxCalorie(c int, singlePoses, doublePoses []gain) (max int) {
	var curSingleIdx, curDoubleIdx, curCal int
	for i := 0; i < len(doublePoses); i++ {
		curCal += doublePoses[i].totalGain
	}
	max = curCal
	curDoubleIdx = len(doublePoses)
	for singleSafePontsNum := 1; singleSafePontsNum <= len(singlePoses); singleSafePontsNum++ {
		for i := curSingleIdx; i < singleSafePontsNum; i++ {
			curCal += singlePoses[i].totalGain
			curSingleIdx = i
		}
		curSinglePos := singlePoses[curSingleIdx].pos
		for i := curDoubleIdx - 1; i > -1 && doublePoses[i].pos >= curSinglePos; i-- {
			curCal -= doublePoses[i].totalGain
			curDoubleIdx = i
		}
		curSingleIdx++
		if curCal > max {
			max = curCal
		}
	}
	return
}

type gain struct {
	pos       int
	totalGain int
}

func findLeftSafePoints(x, v []int) (singles, doubles []gain) {
	sCur, dCur := 0, 0
	sCalorie, dCalorie := 0, 0
	for i := range x {
		if sGain := sCalorie + v[i] - (x[i] - sCur); sGain > 0 {
			sCur = x[i]
			singles = append(singles, gain{
				pos:       x[i],
				totalGain: sGain,
			})
			sCalorie = 0
		} else {
			sCalorie += v[i]
		}
		if dGain := dCalorie + v[i] - 2*(x[i]-dCur); dGain > 0 {
			dCur = x[i]
			doubles = append(doubles, gain{
				pos:       x[i],
				totalGain: dGain,
			})
			dCalorie = 0
		} else {
			dCalorie += v[i]
		}
	}
	return
}
func findRightSafePoints(c int, x, v []int) (singles, doubles []gain) {
	// TODO
	sCur, dCur := c, c
	sCalorie, dCalorie := 0, 0
	for i := len(x); i > 0; i-- {
		if sGain := sCalorie + v[i-1] - (sCur - x[i-1]); sGain > 0 {
			singles = append(singles, gain{
				pos:       x[i-1],
				totalGain: sGain,
			})
			sCur = x[i-1]
			sCalorie = 0
		} else {
			sCalorie += v[i-1]
		}
		if dGain := dCalorie + v[i-1] - 2*(dCur-x[i-1]); dGain > 0 {
			dCur = x[i-1]
			doubles = append(doubles, gain{
				pos:       x[i-1],
				totalGain: dGain,
			})
			dCalorie = 0
		} else {
			dCalorie += v[i-1]
		}
	}
	return
}


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

int main() {
  int N;
  cin >> N;
  vector<int>P(N);
  vector<int>Q(N);
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> Q.at(i);
  }
  int a = 0, b = 0;
  for (int i = 0; i <= N - 1; i++) {
    int num = 1;
    for (int j = 1; j <= N - 1 - i; j++) {
      num *= j;
    }
    int num2 = 0;
    for (int j = i; j <= N - 1; j++) {
      if (P.at(i) > P.at(j)) {
        num2++;
      }
    }
    a += num2 * num;
  }
  a++;
  for (int i = 0; i <= N - 1; i++) {
    int num = 1;
    for (int j = 1; j <= N - 1 - i; j++) {
      num *= j;
    }
    int num2 = 0;
    for (int j = i; j <= N - 1; j++) {
      if (Q.at(i) > Q.at(j)) {
        num2++;
      }
    }
    b += num2 * num;
  }
  b++;
  if (a < b) {
    cout << b - a;
  }
  else {
    cout << a - b;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long A, B, C;
  cin >> A >> B >> C;

  long sum = A + B + C;

  if (sum % 2 > 0) {
    cout << 0 << endl;
    return;
  }

  for (long i = 0; i < 1000000l; i++) {
    if (A % 2 == 1 or B % 2 == 1 or C % 2 == 1) {
      cout << i << endl;
      return;
    }
    A = (sum - A) / 2;
    B = (sum - B) / 2;
    C = (sum - C) / 2;
  }

  cout << -1 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
int N,M,L;
struct node
{   double t,p;
}per[101][51];
long long c[51][51]={0};
void prepare()
{   c[0][0]=1;c[1][0]=1;
    for(int i=1;i<51;i++)
    for(int j=0;j<51;j++)
    {   if(j==0) c[i][j]=1;
        else c[i][j]=c[i-1][j]+c[i-1][j-1];
    }
}
int main()
{   int T;
    prepare();
    cin>>N>>M>>L;
    for(int i=0;i<N;i++)
    {   double p,t,v;
        cin>>p>>t>>v;p*=0.01;
        per[i][0].t=L/v;
        per[i][0].p=pow(1-p,M);
        for(int j=1;j<=M;j++)
        {   per[i][j].p=c[M][j]*pow(1-p,M-j)*pow(p,j);
            per[i][j].t=per[i][j-1].t+t;
        }
    }
//    for(int i=0;i<N;i++){
//    for(int j=0;j<=M;j++)
//    {   cout<<per[i][j].t<<'('<<per[i][j].p<<')'<<' ';
//
//    }puts("");}
    for(int i=0;i<N;i++)
    {   double s=0;
        for(int j=0;j<=M;j++)
        {   double tt=per[i][j].p;
            for(int k=0;k<N;k++)
            if(k!=i)
            {   double ts=0;
                for(int t=M;t>=0 && per[k][t].t>per[i][j].t;t--)
                {   ts+=per[k][t].p;
                }
                tt*=ts;
               // cout<<ts<<endl;
            }
            s+=tt;
        }
        printf("%.8lf\n",s);
    }
}

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

int keta(int x){
  int sum=0;
  while(x>0){
    x/=10;
    sum++;
  }
  return sum;
}

int main() {
  int n,ans=0;
  cin >> n;
  
  for(int i=1;i<=n;i++){
    if(i%2==0)	continue;
    int count=0;
    for(int j=1;j<=i;j++){
      if(i%j==0)	count++;
    }
    if(count==8)	ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int maxLevel;
vector<int> dp;
int dfs(int i,vector<vector<int>> &graph,vector<bool> &vis){
    if(dp[i]!=-1)return dp[i];
    vis[i]=true;
    dp[i]=0;
    for(int node:graph[i]){
        
            dp[i]= max(dp[i],dfs(node,graph,vis)+1);
        
    }
    return dp[i];
    
}

int main(){
    int n,e;
    cin>>n>>e;
    vector<vector<int>> graph(n);
    dp.clear();
    dp.resize(n,-1);
    int a,b;
    for(int i=0;i<e;i++){
        cin>>a>>b;
        a--,b--;
        graph[a].push_back(b);
    }
    vector<bool> vis(n);
    maxLevel=0;
    for(int i=0;i<n;i++){
        if(!vis[i]){
            maxLevel=max(maxLevel,dfs(i,graph,vis));
        }
    }
    cout<<maxLevel<<endl;
}

Measured memory_bytes: 11856
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

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

int SumDigitValues(int x)
{
	int sum = 0;
	while (x)
	{
		sum += x % 10;
		x = x / 10;
	}

	return sum;
}

int Factorial(int n)
{
	if (n < 0) return 0;
	if (n == 0) return 1;
	return n * Factorial(n - 1);
}

int factorial(int n)
{
	if (n > 1)
	{
		return n * factorial(n - 1);
	}
	else
	{
		return 1;
	}
}

int main()
{
	int a, b;
	cin >> a >> b;

	priority_queue<int> nums;
	nums.push(a + b);
	nums.push(a - b);
	nums.push(a * b);
	cout << nums.top() << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).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 (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    int sum = 0;
    rep (i, n)sum += a[i];
    if (h <= sum) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef struct {
    int x; int y; int h;
}D;
int main() {
    int n; cin >> n;
    vector<D> vc(n);
    int si = 0;
    int cnt = 0;
    rep(i, n) {
        int x,y,h; cin >> x >> y >> h;
        vc[i].x = x; vc[i].y = y; vc[i].h = h;
        if(vc[i].h > 0) si = i, cnt++;
    }
    if(cnt == 1) {
        printf("%d %d %d\n",vc[si].x,vc[si].y,vc[si].h);
        return 0;
    }
    int cx = 0, cy = 0;
    bool flag;
    int tmpH;
    rep(i,101) {
        rep(j, 101) {
            flag = true;
            tmpH = vc[si].h + abs(vc[si].x-i) + abs(vc[si].y - j);
            rep(k, n) {
                if(vc[k].h == 0) continue;
                if(tmpH != vc[k].h + abs(vc[k].x-i) + abs(vc[k].y-j))
                    flag = false;
                if(!flag) break;
            }
            if(flag) {
                cx = i;
                cy = j;
                break;
            }
        }
        if(flag) break;
    }
    printf("%d %d %d\n",cx,cy,tmpH);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    while (1) {
        int a, b; cin >> a >> b;
        if (a + b == 0) {
            break;
        }
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                if (i == 0 || j == 0 || i == a-1 || j == b-1)
                    cout << '#';
                else 
                    cout << '.';
            }
            cout << '\n';
        }
        cout << '\n';
    }
}



Measured memory_bytes: 3084
import cmath
import math

N = int(input())
pc = []
for i in range(N):
  x, y = map(int, input().split())
  c = x + y*1j
  p = cmath.phase(c)
  pc.append([p, c])
pc = sorted(pc, key=lambda x: x[0])

ps = [pc[i][0] for i in range(N)]
cs = [pc[i][1] for i in range(N)]

def L(i, j, N):
  if i<j:
    return list(range(i, j))
  else:
    return list(range(0, j)) + list(range(i+1, N))

s = 0
m = 0

for start in range(N):
  for end in range(N):
    s = 0
    #print(start,end,N,L(start,end,N))
    for k in L(start,end,N):
      s += cs[k]
    m = max(m, abs(s))
s = 0
for k in range(N):
  s += cs[k]
  m = max(m, abs(s))
print(m)


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001
const ll mod = 1e9+7;


int main() {
    int n, h[MAXN];
    cin >> n;
    for(int i=0; i<n; ++i) {
        cin >> h[i];
    }
    
    int ans = true;
    for(int i=n-1; i>0; --i) {
        if ( h[i] < h[i-1] ) {
            --h[i-1];
            if (h[i] < h[i-1]) {
                ans = false;
                break;
            }
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  vi a(3);
  in(a[0], a[1], a[2]);
  sort(all(a));
  if (a[0] != 5 || a[1] != 5 || a[2] != 7) {
    print("NO");
  } else {
    print("YES");
  }
}


Measured memory_bytes: 256
N,M = list(map(int, input().split()))
flag = []
ans = []
for i in range(N):
  flag.append(0)
  ans.append(0)
minusflag = 0
for i in range(M):
  s,c = list(map(int, input().split()))
  if(flag[s-1]==0):
    ans[s-1] = c
    flag[s-1] = 1
  elif(flag[s-1]==1 and ans[s-1]==c):
    flag[s-1] = 1
  else:
    minusflag = 1#指示にかぶりがあるとき-1を出力
    break
strans = ""
if(N!=1 and flag[0]==1 and ans[0]==0):#1桁目を0にせよと指示されていたとき-1を出力
  minusflag = 1
elif((N==2 or N==3) and (flag[0]==0 and ans[0]==0) ):#1桁目の指示がないとき1にする
  #1桁のときは指示がなくても0が答えとなる
  ans[0] = 1

for i in range(N):
  strans += str(ans[i])

if(minusflag==1):
  print(-1)
else:
  print(strans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
using namespace std;
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; }

typedef pair<int,int> pint;
struct edge{int to,cost;};
const int INF=1e18;

vector<int> dijkstra(vector<vector<edge>> &G,int s)
{
    int N=G.size();
    vector<int> dist(N,INF);
    dist[s]=0;
    priority_queue<pint,vector<pint>,greater<pint>> Q;
    Q.push({0,s});

    vector<bool> finished(N);
    while(!Q.empty()){
        int v=Q.top().second; 
        Q.pop();
        if(finished[v]) continue;
        finished[v]=true;
        for(edge e:G[v]){
            if(chmin(dist[e.to],dist[v]+e.cost)){
                Q.push({dist[e.to],e.to});
            }
        }
    }
    return dist;
}

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

    int N,M,s; cin>>N>>M>>s;
    vector<vector<edge>> G(N);
    for(int i=0;i<M;i++){
        int a,b,c; cin>>a>>b>>c;
        G[a].push_back({b,c});
    }
    vector<int> dist=dijkstra(G,s);
    for(int i=0;i<N;i++){
        if(dist[i]==INF) cout<<"INF"<<endl;
        else cout<<dist[i]<<endl;
    }
    return 0;
}


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

int main () {
  //atualizar at
  string in;
  int ans = 0;
  cin >> in;
  auto it = find(in.begin(), in.end(), 'A');
  // auto at = rfind(in.rbegin(), in.rend(), 'Z');
  // in.rfind('Z');

  auto ati = in.rfind('Z');
  auto iti = it - in.begin();
  while (iti != ati) {
    ++iti;
    ans++;
  }
  cout << ans + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N , L;
	cin >> N>>L; 
	int ans = 0;
	int tmp =1000000;
	int minmemo = 100000;
	for (int n = 0;n<N;++n) {
		ans += L + n;
		if (abs(tmp) > abs(L+n)) {
			tmp = L + n;
		}
	}
	ans -= tmp;

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author cplayer
 */
public class Main {
    public static void main (String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABiscuitGenerator solver = new ABiscuitGenerator();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABiscuitGenerator {
        public void solve (int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
            a = c / a;
            out.println(b * a);
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader (InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        private String next () {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt () {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

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

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    int n;
    cin>>n;
    ll answer=1;
    ll m=1000000000000000000LL;
    bool zero=false;
    for(int i=0; i<n; i++){
        ll a;
        cin>>a;
        if(a==0) zero=true;
        if(m/answer<a){
            answer=-1;
        }
        if(answer!=-1){
            answer*=a;
        }
    }
    if(zero) cout<<"0";
    else cout<<answer;

    return 0;
}


Measured memory_bytes: 3656