akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
arr = Array.new(101, 0)
gets.chomp.split.map(&:to_i).each{|x| arr[x] += 1}
99.downto(0){|i| arr[i] += arr[i + 1]}
100.downto(1){|i|
    if arr[i] >= i
        puts i
        break
    end
}


Measured memory_bytes: 6864
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

int h, a;
int main() {
	cin >> h >> a;
	cout << ((h + a - 1) / a) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり整数
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''


X, Y = map(int, input().split())
if X%Y == 0:
    print(-1)
else:
    print(X)

Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n"; }
template<class T> void verr(const vector<T>& v){ for(auto& a : v) cout << a << " "; cout << "\n"; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n"; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n"); if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}


/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double PI = acos(-1);
const double EPS = 1e-7; // 許容誤差^2
const double INF = 1e9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) - (m) < EPS)
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

// 外積　cross(a,b) = |a||b|sinθ
double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

// 点の進行方向
// !!! 誤差に注意 !!! (掛け算したものとかなり小さいものを比べているので)
int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

// 線分と点
bool isecSP(Point a1, Point a2, Point b) {
  return !ccw(a1, a2, b);
}

// 点pの直線aへの射影点を返す
Point proj(Point a1, Point a2, Point p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

double distSP(Point a1, Point a2, Point p) {
  Point r = proj(a1, a2, p);
  if (isecSP(a1, a2, r)) return abs(r-p);
  //= !ccw(a1, a2, r)
  return min(abs(a1-p), abs(a2-p));
}

Point READ(){
    int x,y;
    scanf(" %d %d", &x, &y);
    return Point(x,y);
}

int main(){
    int n[2];
    VP l[2];
    rep(i,2){
        scanf(" %d", &n[i]);

        l[i].pb(Point(0, i*1000));
        rep(j,n[i]) l[i].pb(READ());
        l[i].pb(Point(1000, i*1000));
        n[i] += 2;
    }

    double ans = 10101010;
    rep(i,2){
        rep(j,n[i]-1){
            Point p = l[i][j];
            rep(k,n[!i]-1){
                Point q1 = l[!i][k], q2 = l[!i][k+1];
                ans = min(ans, distSP(q1,q2,p));
            }
        }
    }
    printf("%.10f\n", ans);
    return 0;
}



Measured memory_bytes: 3304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}
	
	return 0;
}
 

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;

int main()
{
	string str;
	while((str = readln()).length != 0)
	{
		int d = str.chomp.to!int;
		int value = 0,s = 0;

		while(value != 600-d)
		{
			value += d;
			int line = value*value;
			s += line * d;
		}
		writeln(s);
	}
	return 0;
}

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

int main() {
	int c11, c12, c13, c21, c22, c23, c31, c32, c33;
	cin >> c11 >> c12 >> c13;
	cin >> c21 >> c22 >> c23;
	cin >> c31 >> c32 >> c33;
	if (!(c21 - c11 == c22 - c12 && c22 - c12 == c23 - c13)) {
		cout << "No" << endl;
		return 0;
	}
	else {
		if (!(c31 - c11 == c32 - c12 && c32 - c12 == c33 - c13)) {
			cout << "No" << endl;
			return 0;
		}
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
ll mod = 1e9 + 7;
ll dp[1002][1002] = {0};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s[1002];
    int n, i, j, h, w;
    cin >> h >> w;
    for(i = 0; i < h; i++) {
        cin >> s[i];
    }
    for(i = 1; i < w; i++) {
        if(s[0][i] == '.') {
            dp[0][i] = 1;
        }
        else {
            break;
        }
    }
    for(i = 1; i < h; i++) {
        if(s[i][0] == '.') {
            dp[i][0] = 1;
        }
        else {
            break;
        }
    }
    for(i = 1; i < h; i++) {
        for(j = 1; j < w; j++) {
            if(s[i][j] != '#') {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                dp[i][j] %= mod;
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
    return 0;
}

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

    #define int long long
    #define ci(m)     for(int i=0;i<m;i++)
    #define cj(m)     for(int j=0;j<m;j++)
    #define ck(m)     for(int k=0;k<m;k++)
    #define gcd            __gcd
    #define endl           "\n"
    #define pb             emplace_back
    #define setbits(x)     __builtin_popcountll(x)
    #define zrobits(x)     __builtin_ctzll(x)
    #define mod            1000000007
    #define mod2           998244353
    #define maxe           *max_element
    #define mine           *min_element
    #define inf            1e18
    #define deci(x, y)      fixed<<setprecision(y)<<x
    #define w(t)           int t; cin>>t; while(t--)
    #define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
    #define PI             3.141592653589793238
    using namespace std;

    int32_t main() {
        nitin;
        int k;
        cin>>k;
        int n;
        cin>>n;
        int ans=0;
        vector<int>v(n);
        for(auto &c:v) cin>>c;
        for(int i=1;i<n;i++)
        ans=max(ans,v[i]-v[i-1]);
        ans=max(ans,(k-(v[n-1]-v[0])));
        cout<<k-ans<<endl;
        return 0;
    }

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

int main(){
  int x;
  cin >> x;
  int ans = 1;
  for (int i = 1; i < x; i++) {
    for (int j = 2; j < 10; j++) {
      int tmp = pow(i, j) + 0.5;
      if (tmp <= x) {
        ans = max(tmp, ans);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<unordered_map>
#include<bits/stdc++.h>
using namespace std;
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	{
	   int x;
	   cin>>x;
	   
	   if(x==1)  cout<<0<<endl;
	   else cout<<1<<endl;
	   
	}
	   
	   
	return 0;
}

Measured memory_bytes: 3604
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n = int(input())
en = 0
c = float(0.0)
for i in range(n):
    a, b= map(str, input().split())
    if b == "JPY":
        en += int(a)
    else:
        c += float(a)
ans = en
ans += c * 380000.0
print(ans)





Measured memory_bytes: 7880
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;


int main(){
    vector<int> v;
    int a;
    for(int i = 0; i < 4; i++){
        cin >> a;
        v.push_back(a);
    }
    
    sort(v.begin(), v.end());
    
    do{
        for(int i = 0; i < 4; i++){
            if(1000*v[0] + 100*v[1] + 10*v[2] + v[3] == 1974){
                cout << "YES" << endl;
                return 0;
            }
        }
    }while(next_permutation(v.begin(), v.end()));
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

vector<int> d[26];
int main(){
    int N;
    cin>>N;
    
    string S;
    cin>>S;
    for(int i=0;i<N;i++){
        d[S.at(i)-'a'].push_back(i);
    }

    int NG=1+(N/2), OK=0;
    while(NG>OK+1){
        bool kari=false;
        int MID=(NG+OK)/2;
        for(int i=0;i<26;i++){
            int M=d[i].size();
            if(M>1){
                vector<pair<string,int>> x;
                for(int j=0;j<M;j++) {
                    int k=d[i].at(j);
                    if(k+MID<=N) x.push_back(make_pair(S.substr(k,MID),k));
                }
                if(x.size()>1){
                    sort(x.begin(),x.end());
                    for(int j=0;j<x.size();j++){
                        if(j==x.size()-1) break;
                        if(x.at(j).first==x.at(j+1).first) {
                            int l=x.at(j).second;
                            while(x.at(j).first==x.at(j+1).first){
                                j++;
                                if(j==x.size()-1) break;
                            }
                            int r=x.at(j).second;
                            if(r-l>=MID) kari=true;
                        }
                        if(j==x.size()-1) break;
                    }
                    
                }
            }
            if(kari) break;
        }
        if(kari) OK=MID;
        else NG=MID;
    }

    cout<<OK<<endl;
}

Measured memory_bytes: 6604
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int A, B, AB, O;
	A = B = AB = O = 0;
	char type[8];
	int no;
	while (scanf("%d,%s", &no, type) != EOF) {
//		cout << no << " " << type << endl;
		if (type[0] == 'A' && type[1] == 'B')
			AB++;
		else if (type[0] == 'A')
			A++;
		else if (type[0] == 'B')
			B++;
		else if (type[0] == 'O')
			O++;
	}
	cout << A << endl;
	cout << B << endl;
	cout << AB << endl;
	cout << O << endl;
	return 0;
}

Measured memory_bytes: 1208
N = int(input())
L = list(map(int,input().split()))

ans = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1, N):
      if L[i]!=L[j] and L[j]!= L[k] and L[k]!=L[i]: 
        a,b,c = L[i], L[j], L[k]
        flg = False
        if abs(a-b) < c < a+b:
          flg = True
        elif abs(b-c) < a < b+c:
          flg = True
        elif abs(c-a) < b < c+a:
          flg = True

        if flg: ans += 1

print(ans)

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

int main() {
  int N,L;
  cin>> N >> L ;
  
  vector<string> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  sort(vec.begin(),vec.end());
       
  string a;
  for(int i=0; i<N;i++){
    a+=vec.at(i);
  }
  
  cout << a <<endl;
    
    


    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;
int n, arr[1000000];

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> arr[i];
	}
	bool a = true, b = true;
	int count[1000001] = {};
	for(int i = 0; i < n; ++i){
		int num = arr[i];
		for(int j = 2; j*j <= num; ++j){
			if(num % j == 0){
				count[j]++;
				while(num % j == 0)
					num /= j;
			}
		}
		if(num > 1)
			count[num]++;
	}

	for(int i = 0; i < 1000001; ++i){
		if(count[i] > 1)
			a = false;
		if(count[i] == n)
			b = false;
	}

	if(a){
		cout << "pairwise coprime";
	}
	else if(!a && b){
		cout << "setwise coprime";
	}
	else{
		cout << "not coprime";
	}

	return 0;
}

Measured memory_bytes: 11356
List=list(input())
ylist=List[:4]
mlist=List[5:7]
dlist=List[8:]
y=int("".join(ylist))
m=int("".join(mlist))
d=int("".join(dlist))
if m<=3:
  print("Heisei")
elif m==4 and d<=30:
  print("Heisei")
else:print("TBD")


Measured memory_bytes: 3060
n=gets.to_i

arr=gets.split.map(&:to_i)


arr2=[0]

i=1
save=1
now=arr[0]
(n-1).times{
    
    if arr[i]==now
        save+=1
        
    else
        arr2<<save
        save=1
    
        now=arr[i]
    
    
    end
    
   i+=1 
    
}




    arr2<<n-arr2.inject(:+)


ans=0
ll=arr2.length


k=0
ll.times{
   ans+=(arr2[k])/2 
    
   k+=1
}


p ans









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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int INF = 1e9;

int main(void){


	int N; cin >> N;
	vector<int> A(N);

	REP(i,N){ 
		int a; cin >> a;
		A[i] = a - (i+1);
	}

	SORT(A);
	ll ans = 0;

	int b = A[N/2];
	REP(i,N){
		ans += abs(A[i] - b);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N,D,X,A;
    cin>>N>>D>>X;
    int count=0;
    while(cin>>A){
    int i=0;
    while((i*A+1)<=D){count++;i++;}
    }
    cout<<X+count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <climits>
using namespace std;
 
class Node
{
    public:
        int id, x, y;
};
 
bool xsort(Node a, Node b)
{
    return a.x < b.x ? true : false;
}
bool ysort(Node a, Node b)
{
    return a.y < b.y ? true : false;
}
 
void build_table(vector<Node>& nodes, vector<vector<pair<int, int> > >& cost)
{
    vector<Node> sorted(nodes);
    sort(sorted.begin(), sorted.end(), xsort);
    for (auto itr = sorted.begin(); itr != sorted.end(); ++itr) {
        if (itr != sorted.begin())
            cost.at(itr->id).push_back(make_pair(itr->x - (itr - 1)->x, (itr - 1)->id));
        if ((itr + 1) != sorted.end())
            cost.at(itr->id).push_back(make_pair((itr + 1)->x - itr->x, (itr + 1)->id));
    }
    sort(sorted.begin(), sorted.end(), ysort);
    for (auto itr = sorted.begin(); itr != sorted.end(); ++itr) {
        if (itr != sorted.begin())
            cost.at(itr->id).push_back(make_pair(itr->y - (itr - 1)->y, (itr - 1)->id));
        if ((itr + 1) != sorted.end())
            cost.at(itr->id).push_back(make_pair((itr + 1)->y - itr->y, (itr + 1)->id));
    }
}

bool on[1000000];
 
unsigned long long prim(vector<vector<pair<int, int> > >& cost)
{
    unsigned long long sum = 0;
    //bool on[cost.size()];
    for (int i = 0; i < cost.size(); i++) {
        on[i] = false;
    }
    // pair<cost, node>
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > PQ;
    PQ.push(make_pair(0, 0));
    while (!PQ.empty()) {
        pair<int, int> edge = PQ.top();
        PQ.pop();
	if(edge.second >= cost.size()){
		return -1;
	}
        if (on[edge.second]) continue;
        on[edge.second] = true;
        sum += edge.first;
        for (auto itr = cost[edge.second].begin(); itr != cost[edge.second].end(); ++itr) {
            if (on[itr->second]) continue;
            PQ.push(*itr);
        }
    }
    return sum;
}
 
int main()
{
    int n;
    cin >> n;
 
    vector<Node> nodes;
    // pair<cost, dst>
    vector<vector<pair<int, int> > > cost(n);
    Node node;
    for (int i = 0; i < n; i++) {
        node.id = i;
        cin >> node.x >> node.y;
        nodes.push_back(node);
    }
    build_table(nodes, cost);
    cout << prim(cost) << endl;
    return 0;
}


Measured memory_bytes: 11360
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == -1)
      break;

    double x = 1;
    double y = 0;
    for (int i = 0; i < n - 1; ++i) {
      double dx = -y / sqrt(x * x + y * y);
      double dy = (sqrt(x * x + y * y) + y * dx) / x;
      x += dx;
      y += dy;
    }

    cout << x << endl;
    cout << y << endl;
  }
}


Measured memory_bytes: 3248
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int N, T, A;
  cin >> N >> T >> A;
  int ans = 0;
  double nearest = 300000;
  for (int i = 1; i <= N; i++) {
    int H;
    cin >> H;
    if (abs(A-(T-H*0.006)) < nearest) {
      ans = i;
      nearest = abs(A-(T-H*0.006));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*

????????? ????????°???????????°??????????????? ????????????
?????´???????????§?????§????????°???????????°???????????????????????¬??????????????¨?????????????????????
?????????????????§????????????????????????????????????????????????????????£??????????????????????????????
??????????????????????????????

???????§??????????????§£?????????????????°??¨???????????????????????????????????????????¬????????????????
?????\?????????????????????????????¢????¨???????????????¨??????????????????

???????????????????????£?§£??????????????????????????????????????\?????§???????????????????????\?????????
?????¨??????????????????????????§??????????????????????????????????????¢??¨?????????

??????
????????????????????£?§£?????????????????°??¨???????????????????????????????????????????????????????????¢
????¨??????????????????°????????????????????????

??\???
??\????????\????????¢?????§??????????????????

N
p1 p2 ??? pN

??????????????????????????£?§£?????????????????° N(1???N???100)?????????????????????
??????????????£?§£???????????????????????? pi(1???pi???100)?????????????????????

??????
????????????????????¢???????????????????????????

*/

#include <stdio.h>

#define NUM 100

int main( void )
{
	int n;						// ??????????????£?§£?????????????????° N(1???N???100)
	int d[ 100 ];				// ??£?§£???????????????????????? pi(1???pi???100)
	int i, j, w;
	int t = 0;

	scanf( "%d ", &n );

	// n ?????°?????????????????\?????????
	for ( i = 0 ; i < n ; i++) {
		scanf("%d ", &d[ i ] );
	}

	// ?????????????????????????????????
	for ( i = 0 ; i < n - 1 ; i++) {
		for ( j = i + 1 ; j < n ; j++) {
			if ( d[ i ] < d [ j ] ) {
				w = d[ i ];
				d[ i ] = d[ j ];
				d[ j ] = w;
			}
		}
	}

	t = 0;						// ??¨???????????????????????? 0	
	for ( i = n - 1 ; i >= 0 ; i-- ) {
//		printf( "%d:%2d\n", i, d[ i ] );

		/*
		 * ???????????????????????????????????????????¢??????????
		 * ????????\???????????????????????°???????????°?????§???????????°???
		 * ???????????????????????°????????°??¨?????????
		 */
		if ( d[ i ] >= i + 1 ) {
			t = i + 1;
			break;
		}
	}

	printf( "%d\n", t );

	return 0;
}

Measured memory_bytes: 600
using System;
using static System.Console;
public class Hello{
    public static void Main(){
        string[] a = ReadLine().Split(' ');
        int x = int.Parse(a[0]);
        int y = int.Parse(a[1]);
//        int z = int.Parse(a[2]);
        if((x+y)%2==1){
            WriteLine((x+y)/2+1);
        }else{
            WriteLine((x+y)/2);
        }
    }
}


Measured memory_bytes: 13140
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

N, K = MULTIPLE_INT_MAP()
trees = [int(input()) for _ in range(N)]
trees.sort()
ans = float('inf')

for i in range(0, N-K+1):
    ans = min(ans, trees[i+K-1] - trees[i])
    if ans == 0:
        break

print(ans)

Measured memory_bytes: 7384
#include<stdio.h>
#include<math.h>
int main()
{
    long long int a,b,n,c;
    scanf("%lld",&n);
    for(a=sqrt(n);a>0;a--)
    {
        if(n%a==0)
        {
            b=n/a;
            break;
        }
    }
    printf("%lld",a+b-2);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}

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

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n; ll m;
    cin >> n >> m;
    vector<ll> a(n);
    for(int i=0;i<n;++i) cin >> a[i];

    ll l = a[0]/2;
    for(int i=1;i<n;++i) {
        l = lcm(l, a[i]/2);
    }

    for(int i=0;i<n;++i) {
        if((l / (a[i]/2)) % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = (m / l + 1) / 2;

    cout << ans << endl;
}


Measured memory_bytes: 1024
from numpy.linalg import det
from numpy.linalg import solve
import numpy as np
import math


def find_cross_point(x1, y1, x2, y2, x3, y3):
    A = np.array([[x2-x1, y2-y1], [x3-x2, y3-y2]])
    B = np.array([(x2**2+y2**2-x1**2-y1**2)/2, (x3**2+y3**2-x2**2-y2**2)/2])
    if det(A) == 0:
        return (float("inf"), float("inf"))
    C = solve(A, B)
    return C


N = int(input())
ans = 10**10
plots = []


for i in range(N):
    x, y = map(int, input().split())
    plots.append((x, y))


# 2点の間が直線になる時
for i in range(N):
    for j in range(i+1, N):
        sub = 0
        m_x, m_y = (plots[i][0]+plots[j][0])/2, (plots[i][1]+plots[j][1])/2
        for k in range(N):
            sub = max(sub, math.hypot(m_x-plots[k][0], m_y-plots[k][1]))
        ans = min(ans, sub)


# 3点を円が通る時
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            sub = 0
            x1, y1 = plots[i]
            x2, y2 = plots[j]
            x3, y3 = plots[k]
            m_x, m_y = find_cross_point(x1, y1, x2, y2, x3, y3)
            for p in range(N):
                sub = max(sub, math.hypot(m_x-plots[p][0], m_y-plots[p][1]))
            ans = min(ans, sub)
print(ans)


Measured memory_bytes: 27528
#include <bits/stdc++.h>
using namespace std;
int main() {
	multiset<int> ms;
	int n;
	scanf("%d", &n);
	for (int i = 0; i < 3 * n; ++ i) {
		int x;
		scanf("%d", &x);
		ms.insert(x);
	}
	long long ans = 0;
	for (int i = 0; i < n; ++ i) {
		ms.erase(-- ms.end());
		ans += *-- ms.end();
		ms.erase(-- ms.end());
		ms.erase(ms.begin());
	}
	cout << ans << endl;
}



Measured memory_bytes: 14336
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */


  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9+7;


  int main()
  {
      int a,b,c;
      cin>>a>>b>>c;
      int d=a+b+c;
      if(d>=22)
        cout<<"bust";
      else
        cout<<"win";
      return 0;
  }


Measured memory_bytes: 256
n = int(input())
nums = list(map(int, input().split()))
mod = 10**9 + 7

if n % 2 == 0:
  if len(set(nums)) == n // 2:
    print(2**(n//2) % mod)
  else:
    print(0)
else:
  if len(set(nums))== n // 2 + 1 and nums.count(0) == 1:
    print(2**(n//2) % mod)
  else:
    print(0)

Measured memory_bytes: 13880
/*  Author : Alpha_The_Coder
    Created on 26/09/2020      */
#include <bits/stdc++.h>
using namespace std;
#define iamalpha ios_base::sync_with_stdio(false);cin.tie(NULL);
#define loop(a,n) for(int i=a;i<n;i++)
#define nloop(a,n) for(int j=a;j<n;j++)
#define lli long long int
lli mod=1000000007;
void solve();

int main()
{
    iamalpha;
    int t=1;
    while(t--)
    {
        solve();
    }
}

void solve()
{
    string s="ACL";
    int k;
    cin>>k;
    loop(0,k)
    cout<<s;
}


// Solely contributed by Subhojeet Sahoo aka Alpha


Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	float a,b,c,d,e,f,x,y;
	
	while(scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF){
		y = (c*d - f*a) / (b*d - e*a);
		x = (c - b*y) / a;
		
		printf("%.3f %.3f\n", x, y);
	}
	
	return(0);
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  cin >> s;
  int flag = 0;
  for(int i = 0; i < 3; i++){
  if(s[i]==s[i+1]){
  	flag = 1;
    break;
  }  
  }

      if(flag)
      cout << "Bad"<<'\n';
    else
      cout << "Good\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
//Write a program which finds the greatest common divisor of two natural numbers a and b
//For integers x and y, if x ≥ y, then gcd(x, y) = gcd(y, x%y)
int main()
{
    int a, b;
    scanf("%d %d",&a,&b);
    if(a<b){
        int temp = a;
        a = b;
        b = temp;
    }
    while(a%b!=0){
        int temp = a;
        a = b;
        b = temp%b;
    }
    printf("%d\n",b);
    return 0;
}


Measured memory_bytes: 2752
from collections import deque
n,q = map(int, input().split())
A = []

for i in range(n):
    A.append(deque())
for i in range(q):
    a = input().split()
    t = int(a[1])
    
    if a[0] == '0':
        A[t].append(a[2])
    elif a[0] == '1':
        print(*A[t])
    else:
        A[t].clear()


Measured memory_bytes: 42832
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <unistd.h>
 
int main() {
  int N;
  std::cin >> N;
 
  std::vector<std::uint64_t> X; // NonSorted
  std::vector<std::uint64_t> Xs; // Sorted
  X.resize(N);
  Xs.resize(N);
 
  for(auto&& Xi : Xs)
    std::cin >> Xi;
  
  std::copy(std::cbegin(Xs), std::cend(Xs), std::begin(X));
  std::sort(std::begin(Xs), std::end(Xs));
  
  const std::uint64_t Mf = Xs[N / 2 - 1];
  const std::uint64_t Ms = Xs[N / 2];
  
  for(auto const& Xi : X){
    if(Xi <= Mf) std::cout << Ms << std::endl;
    else if(Xi >= Ms) std::cout << Mf << std::endl;
  }
}

Measured memory_bytes: 5376
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}
map<int,int> mp;
signed main(){
    int n;
    cin >> n;
    int nans = 0;
    REP(i,n){
        int a1;
        cin >>a1;
        mp[a1] ++;
        nans += a1;
    }
    int q;
    cin >>q;
    REP(i,q){
        int b1,c1;
        cin >> b1 >> c1;
        int nnn = mp[b1];
        mp[b1] = 0;
        mp[c1] += nnn;
        nans += (c1-b1) * nnn;
        cout << nans << endl;
    }




    return 0;
}

Measured memory_bytes: 9460
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// -------------------------------------------------------------------------------------

int main() {
  vector<ll> cnt;
  cnt.assign(1e5+10, 0);

  ll n, k;
  cin >> n >> k;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    cnt[a] += b;
  }

  ll tmp_k = 0;
  rep(i, 1e5+1) {
    tmp_k += cnt[i];

    if(tmp_k >= k) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#define TRUE 1
#define FALSE 0
int main(){
  int n,i,j,in,cards[4][13];
  char c;
  for(i=0; i<4; i++) for(j=0; j<13; j++) cards[i][j] = FALSE;
  std::cin >> n;
  for(i=0; i<n; i++){
    std::cin >> c >> in;
    switch(c){
      case 'S':
      cards[0][in-1] = TRUE;
      break;
      case 'H':
      cards[1][in-1] = TRUE;
      break;
      case 'C':
      cards[2][in-1] = TRUE;
      break;
      case 'D':
      cards[3][in-1] = TRUE;
      default:
      break;
    }
  }
  for(i=0; i<4; i++) for(j=0; j<13; j++){
    if(!cards[i][j]){
      switch(i){
        case 0:
        std::cout << "S ";
        break;
        case 1:
        std::cout << "H ";
        break;
        case 2:
        std::cout << "C ";
        break;
        case 3:
        std::cout << "D ";
        break;
        default:
        break;
      }
      std::cout << j + 1 << std::endl << std::flush;
    }
  }
  // for(i=0; i<4; i++){
  //   for(j=0; j<13; j++) std::cout << cards[i][j];
  //   std::cout << "\n";
  // }
  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <iostream>
#include <vector>
using namespace std;
string add(string a,string b){

  int numa[1001] = {0},numb[1001] = {0};

  for(int i = a.size()-1 ; i >= 0 ; i-- )numa[a.size()-i-1] = a[i]-'0';
  for(int i = b.size()-1 ; i >= 0 ; i-- )numb[b.size()-i-1] = b[i]-'0';

  vector<int> renum(1001);

  fill(renum.begin(),renum.end(),0);
  int mxsize = max(a.size(),b.size());

  for(int i = 0 ; i < mxsize ; i++ ){
    renum[i+1] = (renum[i] + numa[i] + numb[i])/10;
    renum[i] = (renum[i] + numa[i] + numb[i])%10;
  }

  string srenum = "";
  for(int i = mxsize ; i >= 0 ; i-- ){
    if(i == mxsize && renum[i] == 0)continue;
    srenum += renum[i]+'0';
  }
  return srenum;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    string a,b;
    cin >> a >> b;
    a = add(a,b);
    if(a.size() > 80)cout << "overflow" << endl;
    else cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define int long long int
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    //cout<<"I must do it...Yeahhh";
    
    int tt=1;
    //cin>>tt;
    for(int kk=0;kk<tt;kk++)
    {
        int n,m,sum=0,x=0,y;
        cin>>n>>m;
        int a[n];
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        y=sum/(4*m);
        if(sum%(4*m)!=0)
            y++;

        for(int i=0;i<n;i++)
            if(a[i]>=y)
                x++;

        if(x>=m)
            cout<<"Yes";
        else
            cout<<"No";

        //cout<<"Case #"<<kk+1<<": "<<trace<<' '<<r<<' '<<c<<'\n';
    }
    //cerr<<"[Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s]\n";
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
s = list(map(int,input().split()))
t = list(map(int,input().split()))
dp = [[0 for _ in range(m+1)] for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 1
for j in range(m+1):
    dp[0][j] = 1
mod = 10**9 + 7
for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] = (dp[i][j+1]+dp[i+1][j])%mod
        else:
            dp[i + 1][j + 1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j]+mod) % mod
print(dp[n][m])

Measured memory_bytes: 74204
#include <iostream>
#include <vector>
#include <set>
using namespace std;

const int MAXN = 2000 + 5;
const int MOD = 1e9 + 7;

int N, M, K;
int DP[MAXN * 2][MAXN * 2];
int answer;

inline bool check(int _k, int _n, int _m)
{
	if(!_k)
		return false;
	if(_n > N || _m > M)
		return false;
	if((N - _n) % (K - 1) != 0)
		return false;
	if((M - _m) % (K - 1) != 0)
		return false;
	return true;
}

int main()
{
	cin >> N >> M >> K;

	DP[0][0] = 1;
	for(int i = 0; i < N + M; i += (K - 1))
		for(int j = 0; j <= M; j++)
			for(int k = 0; k < K; k++)
			{
				if(check(k, i - j + k, j + K - k))
					answer = (answer + DP[i][j]) % MOD;
				if(i < N + M - 1)
					DP[i + K - 1][j + k] = (DP[i + K - 1][j + k] + DP[i][j]) % MOD;
			}

	cout << answer << endl ;

	return 0;
}


Measured memory_bytes: 62080
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>


using namespace std;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

int main(){
    int n,m,q;
    cin >> n >> m >> q;
    int train[501][501] = {};
    int cum[501][501] = {};

    int m1,m2;
    for(int i=0; i<m; i++){
        cin >> m1 >> m2;
        train[m1][m2]++;
    }

    for(int i=1; i<n+1; i++){
        for(int j=1; j<n+1; j++){
            cum[i][j] = cum[i][j-1] + train[i][j];
        }
    }

    int a,b;
    int answer;

    for(int i=0; i<q; i++){
        answer = 0;
        cin >> a >> b;
        for(int j=a; j<=b; j++){
            answer += cum[j][b]- cum[j][a-1];
        }
        cout << answer << endl;
    }
    return 0;
}


Measured memory_bytes: 2944
#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 n,m;
int x[125252], y[125252];
int cnt[125252];
bool po[125252];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    scanf("%d%d",x+i,y+i);
    x[i]--;
    y[i]--;
  }
  REP(i,n){
    cnt[i] = 1;
  }
  po[0] = true;
  REP(i,m){
    int xx=x[i],yy=y[i];
    if(po[xx]){
      po[yy] = true;
      if(cnt[xx]==1){
        po[xx] = false;
      }
    }
    cnt[xx]--;
    cnt[yy]++;
  }
  int ans = 0;
  REP(i,n)ans += po[i];
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1536
'use strict'

function Main(input) {
  const data = input.trim()
  const array = data.split('\n')
  const N = parseInt(array[0])
  const list = array[1].split(' ').map(s => parseInt(s))

  if (N === 1) {
    console.log(0)
    return
  }

  let count = 0;
  let current = 1;
  for(let i = 0; i < N; ++i) {
    const n = list[i]
    if (n === current) {
      current++
    } else {
      count++;
    }
  }
  
  if (count === N) {
    console.log(-1)
  } else {
    console.log(count)
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using ll=long long; 

void solve(){
	string s;
	cin>>s;
	if(s[0]=='A'&&*(s.end()-1)<='z'&&*(s.end()-1)>='a'&&s[1]>='a'&&s[1]<='z'){
		bool flag=false;
		for(int i=2; i<int(s.size()); i++){
			if(!flag&&s[i]=='C'){
				flag=true;
			}
			else if(flag&&s[i]=='C'){
				cout<<"WA"<<endl;
				return;
			}
			else if(s[i]>'z'&&s[i]<'a'){
				cout<<"WA"<<endl;
				return;
			}
		}
		if(!flag){
			cout<<"WA"<<endl;
			return;
		}
	}else{
		cout<<"WA"<<endl;
		return;
	}
	cout<<"AC"<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

// 追加クエリの直線の傾きが単調減少の場合
template<class T>
class ConvexHullTrick {
public:
    ConvexHullTrick(int n) :n(0), A(n), B(n) {}
    // add y=ax+b
    void addLine(T a, T b) {
        while (n >= 2 && check(a, b)) --n;
        A[n] = a; B[n] = b; ++n;
    }
    // min(a[i]*x+b)
    T query(T x) {
        int l = -1, r = n - 1;
        while (r - l > 1) {
            int mid = (r + l) / 2;
            if (f(mid, x) >= f(mid + 1, x)) l = mid;
            else r = mid;
        }
        return f(r, x);
    }
    T f(int k, T x) {
        return A[k] * x + B[k];
    }
private:
    bool check(T a, T b) {
        return (B[n - 2] - B[n - 1]) * (a - A[n - 1]) >= (B[n - 1] - b) * (A[n - 1] - A[n - 2]);
    }
    int n;
    std::vector<T> A, B;
};

int n;
ll c;
ll h[200005];
ll dp[200005];
void solve() {
    cin >> n >> c;
    rep(i, n) cin >> h[i];

    ConvexHullTrick<ll> cht(n);
    cht.addLine(-2 * h[0], pow2(h[0]));
    reps(i, n - 1) {
        auto v = cht.query(h[i]);
        dp[i] = v + pow2(h[i]) + c;
        cht.addLine(-2 * h[i], pow2(h[i]) + dp[i]);
    }
    cout << dp[n - 1] << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

public class Main {
	private Scanner in = new Scanner(System.in);
	
	private Main() {
		int n = in.nextInt();
		int numOfBall = 10;
		
		for(int i=0;i<n;i++) {
			ArrayList<Integer> dataset = new ArrayList<Integer>();	
			for(int j=0;j<numOfBall;j++) {
				 dataset.add(in.nextInt());
			}
			int[] cylinders = new int[2]; //筒(の最後の要素)
			System.out.println(solve(dataset, cylinders));
		}
		
	}
	
	private String solve(ArrayList<Integer> data,int[] cylinders) {
		if(data.isEmpty())
			return "YES";
		
		int head = data.remove(0);
		if(head > cylinders[0]) {
			cylinders[0] = head;
		} else if(head > cylinders[1]) {
			cylinders[1] = head;
		} else {
			return "NO";
		}
		return solve(data,cylinders);
	}

	public static void main(String[] args) {
		new Main();
	}

}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 080_arc_a / Link: https://abc069.contest.atcoder.jp/tasks/arc080_a?lang=en  ----- */
/* ------問題------

長さ N の数列 a=(a1,a2,…,aN) があります。 各 ai は正の整数です。
すぬけ君の目標は、a の要素を自由に並べ替え、次の条件が成り立つようにすることです。
各 1≤i≤N−1 について、ai と ai+1 の積は 4 の倍数である。
すぬけ君が目標を達成できるか判定してください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VL a(N);
	int cnt4 = 0;
	int cnt2 = 0;
	FOR(i, 0, N) {
		cin >> a[i];
		if (a[i] % 4 == 0) {
			cnt4++;
		}
		else if (a[i] % 2 == 0) {
			cnt2++;
		}
	}
	int f = 0;
	if (cnt4 * 2 + 1 >= N) {
		f = 1;
	}
	else if (cnt4 * 2 + cnt2  >= N) {
		f = 1;
	}


		string s[2] = { "No","Yes" };
	cout << s[f] << "\n";

	return 0;
}


Measured memory_bytes: 1024
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
m = max(1, min(a))
M = max(a)
ans=[]
for x in range(m,M):
    ans.append(c[x-1]+c[x]+c[x+1])
if m >= M:
    ans.append(n)
print(max(ans))

Measured memory_bytes: 14564
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
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 (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, Q; cin >> N >> Q;
    string str; cin >> str;

    // 累積和
    vector<int> s(N+1, 0);
    for (int i = 0; i < N; ++i) {
        if (i+1 < N && str[i] == 'A' && str[i+1] == 'C') s[i+1] = s[i] + 1;
        else s[i+1] = s[i];
    }

    // クエリ
    for (int q = 0; q < Q; ++q) {
        int l, r; cin >> l >> r;
        --l, --r; // 0-indexed にする
        cout << s[r] - s[l] << endl;
    }
}



Measured memory_bytes: 1488
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return

    // a値とその個数のmapにする
    // この時点で、a = 個数 のものは除外しておく
    val aMap: Map<Long, Long> = readLine()
        ?.split(" ")
        ?.map { it.toLong() }
        ?.groupBy { it }
        ?.mapValues { it.value.size.toLong() }
        ?.filter { it.key != it.value }
        ?: return

    // a値の個数がa以下の場合には、aはすべて削除する必要がある
    val less: Long = aMap
        .filter { it.key > it.value }
        .values
        .sum()

    // a値の個数がa以上の場合には、(個数-a）個を削除する必要がある
    val more: Long = aMap
        .filter { it.key < it.value }
        .map { it.value - it.key }
        .sum()

    println(less + more)
}

Measured memory_bytes: 84444