akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b)(fabs((a)-(b))<EPS)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<double, int>P;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator+(Point p) { return Point(x + p.x, y + p.y); }
	Point operator-(Point p) { return Point(x - p.x, y - p.y); }
	Point operator*(double a) { return Point(a*x, a*y); }
	Point operator/(double a) { return Point(x / a, y / a); }

	double norm() { return x*x + y*y; }
	double abs() { return sqrt(norm()); }

	bool operator<(const Point&p)const {
		return x != p.x ? x < p.x : y < p.y;
	}
	bool operator==(const Point&p)const {
		return fabs(x - p.x) < EPS&&fabs(y - p.y) < EPS;
	}
};
typedef Point Vector;
double norm(Vector a) {
	return a.x*a.x + a.y*a.y;
}
double abs(Vector a) {
	return sqrt(norm(a));
}
double getDistance(Point a, Point b) {
	return abs(a - b);
}
class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};
double getDistance(Circle c1, Circle c2) {
	return max(0.0, getDistance(c1.c, c2.c) - c1.r - c2.r);
}
double getDistance(Circle c, Point p) {
	return max(0.0, getDistance(c.c, p) - c.r);
}
double dist[1200][1200];
double d[1200];
Circle c[1200];
int main() {
	double xs, ys, xt, yt; scanf("%lf%lf%lf%lf", &xs, &ys, &xt, &yt);
	int n; scanf("%d", &n);
	rep(i, n) {
		double x, y, r; scanf("%lf%lf%lf", &x, &y, &r);
		c[i] = { { x,y },r };
	}
	c[n] = { {xs,ys} };
	c[n + 1] = { {xt,yt} };
	n += 2;
	rep(i, n)for (int j = i + 1; j < n; j++) {
		dist[i][j] = dist[j][i] = getDistance(c[i], c[j]);
	}
	fill(d, d + n, INFINITY);
	priority_queue<P, vector<P>, greater<P>>que;
	d[n - 2] = 0;
	que.push(P(0, n - 2));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		if (p.first != d[p.second])continue;
		rep(j, n) {
			if (d[j] > p.first + dist[p.second][j]) {
				d[j] = p.first + dist[p.second][j];
				que.push(P(d[j], j));
			}
		}
	}
	printf("%.12lf\n", d[n - 1]);
}

Measured memory_bytes: 13936
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    ll x;
    std::cin >> x;
    if(x <= 6){
        std::cout << 1 << std::endl;
    }else{
        // 1回目で6,2回目で5
        ll cnt = 0;
        ll tmp = x / 11;
        x -= tmp * 11;
        cnt += tmp * 2;
        if(x > 0){
            x -= 6;
            cnt++;
        }
        if(x > 0){
            x -= 5;
            cnt++;
        }
        std::cout << cnt << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
        $in = fgets(STDIN);
        $in_array = explode(" ", trim($in));
        $n = $in_array[0];
        $a = $in_array[1];
        $b = $in_array[2];
        $total = 0;
        
        for($i = 1; $i <= $n; $i++){
            $sum = 0;
            $check_i = $i;
            while($check_i > 0) {
                $sum += $check_i % 10;
                $check_i /= 10;
            }
            
            if($sum >= $a && $sum <= $b){
                $total += $i;
            }
        }

        echo $total;

?>


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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    auto v = vc<tuple<ll, ll, string, ll, string>>(n);

    for (auto&& x: v) {
        cin >> get<0>(x) >> get<1>(x) >> get<2>(x)
            >> get<3>(x) >> get<4>(x);
    }

    sort(ALL(v));

    for (const auto& x : v)
        cout << get<0>(x) << " " << get<1>(x) << " " << get<2>(x)
             << " " << get<3>(x) << " " << get<4>(x) << endl;

    return 0;
}



Measured memory_bytes: 16584
#include<stdio.h>
#include<stdio.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueuetw(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

P dequeuetw(){
P x=Q[head];
head=(head+1)%LEN;
return x;
}

int min(int a, int b){return a<b ? a:b;}

int main(){
  int elapstw = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
    head=1; tail=n+1;

    while(head!=tail){
        u=dequeuetw();
        c=min(q,u.t);
        u.t-=c;
        elapstw+=c;
        if(u.t>0)enqueuetw(u);
        else{
            printf("%s %d\n",u.name, elapstw);
        }
    }
  
  return 0;
}


Measured memory_bytes: 11848
#include<bits/stdc++.h>
using namespace std;
using li = long long int;

int N;
int A[100010];
int Mountain[100010];
int x1 = 0;

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){ 
      cin >> A[i];
      if(i & 1) x1 += A[i];
      else x1 -= A[i];
    }

    Mountain[1] = x1;

    li neighbour = Mountain[1] / 2;
    cout << Mountain[1] << endl;
    for(int i = 1; i <= N-1; i++){
        Mountain[i+1] = 2 * (A[i] - neighbour);
        cout << Mountain[i+1] << endl;
        neighbour = Mountain[i+1] / 2;
    }
    return 0;
}

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin >> n;
	double ans = n / 1.08;
	ll r = ceil(ans);
	if (floor(r * 1.08) != n)
		cout << ":(";
	else
		cout << r;
	return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define present(container, element) (container.find(element) != container.end())
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cpresent(container, element) (find(all(container),element) != container.end())
#define all(c) c.begin(), c.end()
#define mod 1000000007 
#define MOD 998244353
#define PI 3.141592654
typedef long long ll;
using namespace std;
int main(){
  ss
  ll a,ans=0,b,c=1;
  cin>>a>>b;
  while(c<b){
  	c+=a;
  	c--;
  	ans++;
  	if(c>=b) break;
  }
  cout<<ans;
return 0; 

}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, d, x, a;
int ans;
int main() {
	cin >> n >> d >> x;
	REP(i, n) {
		cin >> a;
		x += (d +a- 1) / a;
	}
	cout << x<< endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
from heapq import heappop, heappush

# A* algorithm (Dijikstraの応用)
# Dijikstra: actual cost の順
# A*: score( actual_cost + heuristic_cost) の順(scoreが同じ場合はactual_costの順)
# ただしA* algorithm は hueristic_costが計算できるのが前提。また、全頂点への始点からの距離を求めるならDijikstraを使う。今回はstart, endが決まっているのでA*を使った。
def main():
    H, W = map(int, sys.stdin.readline().split())

    grid = np.array([list(sys.stdin.readline().rstrip()) for _ in range(H)], dtype='U')
    grid = np.pad(grid, 1, mode='constant')
    # atcoderではnp.pad() のargにconstant_valuesを指定できないみたい

    
    i = j = 1             # start
    c = 0                 # actual_cost
    h = (H - 1) + (W - 1) # heuristic_cost 
    s = c + h             # score
    q = []                # status: open
    heappush(q, (s, c, i, j))
    visited = set()       # status: closed
    
    # 今回は最短距離を求めれば良いので必要ないが、最短経路を求める場合にはparent_nodeの記録が必要なので一応parentも記録しておく
    parent = [[None] * (W + 1) for _ in range(H+1)]

    can_go = False
    while q:
        s, c, i, j = heappop(q)
        if (i, j) in visited:
            continue
        visited.add((i, j))
        if c == s: # h == 0 ならそこがgoal
            can_go = True
            break
        for dy, dx in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
            y = i + dy
            x = j + dx
            if grid[y][x] == '.' and not (y, x) in visited:
                parent[y][x] = (i, j)
                h = (H - y) + (W - x)
                s = h + c + 1
                heappush(q, (s, c+1, y, x))
 
    if can_go:
        ans = np.sum(grid == '.') - (c + 1)
    else:
        ans = -1
    print(ans)

    
    # 経路も求める場合はこんな感じ
    # i, j = H, W
    # res = [(H, W)]
    # while parent[i][j]:
    #     i, j = parent[i][j]
    #     res.append((i, j))
    # res = list(reversed(res))
    # print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 12628
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
P gre(P x, P y) {
	if (x.first > y.first)return x;
	if (x.first == y.first&&x.second < y.second)return x;
	return y;
}
bool sor(P x, P y) {
	if (x.first > y.first)return true;
	if (x.first == y.first&&x.second < y.second)return true;
	return false;
}
int main() {
	int n;
	while (cin >> n, n) {
		P dp[101][50000];
		int cost[101] = {};
		rep(i, n) {
			cin >> cost[i];
		}
		rep(i, 101) {
			rep(j, 50000) {
				dp[i][j] = { -1,-1 };
			}
		}
		dp[0][0] = { 0,0 };
		rep(i, n) {
			rep(j, 50000) {
				if (dp[i][j].first == -1)continue;
				dp[i + 1][j] = gre(dp[i+1][j], dp[i][j]);
				if (cost[i] % 1000 == 0) {
					if (j >= 500) {
						P res;
						res = { dp[i][j].first + 1,dp[i][j].second+cost[i] };
						dp[i+1][j - 500] = gre(dp[i+1][j - 500], res);
					}
				}
				else if (j < cost[i] % 1000||cost[i]>500) {
					if (1000 - cost[i] % 1000 + j >= 500) {
						P res;
						res = { dp[i][j].first + 1,dp[i][j].second + cost[i] };
						dp[i + 1][500 - cost[i] % 1000 + j] = gre(dp[i + 1][500 - cost[i] % 1000 + j], res);
					}
					else {
						P res;
						res = { dp[i][j].first,dp[i][j].second + cost[i] };
						dp[i + 1][1000 - cost[i] % 1000 + j] = gre(dp[i + 1][1000 - cost[i] % 1000 + j], res);
					}
				}
				else {
					if (1000 - cost[i] % 1000 >= 500) {
						P res;
						res = { dp[i][j].first + 1,dp[i][j].second + cost[i] };
						dp[i + 1][500 - cost[i] % 1000+j] = gre(dp[i + 1][500 - cost[i] % 1000+j],res);
					}
					else {
						P res;
						res = { dp[i][j].first,dp[i][j].second + cost[i] };
						dp[i + 1][1000 - cost[i] % 1000 + j] = gre(dp[i + 1][1000 - cost[i] % 1000 + j], res);
					}
				}
			}
		}
		sort(dp[n], dp[n] + 50000, sor);
		cout << dp[n][0].first << " " << dp[n][0].second << endl;
	}
	return 0;
}


Measured memory_bytes: 42524
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;
  int month=int(s[5]-'0')*10+int(s[6]-'0');
  if(month<=4)cout<<"Heisei"<<endl;
  else cout<<"TBD"<<endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val k = sc.nextInt()
  val p = (1..n).map { sc.nextInt() }

  val sort = p.sorted()
  var ans = 0
  for (i in 0 until k) {
    ans += sort[i]
  }

  println(ans)
}




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

typedef long long ll;
//loop
#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--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    int a,b,c;
    cin>>a>>b>>c;
    if (c >= a && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


Measured memory_bytes: 256
use std::cmp::min;
use std::io;
use std::io::prelude::*;
use std::iter::repeat;

fn main() {
    let mut stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_to_string(&mut buf);
    let mut iter = buf.split_whitespace();

    loop {
        let a: usize = iter.next().unwrap().parse().unwrap();
        let b: usize = iter.next().unwrap().parse().unwrap();
        if (a, b) == (0, 0) {
            break;
        }
        let n: usize = iter.next().unwrap().parse().unwrap();
        let c: Vec<(usize, usize)> = (0..n)
            .map(|_| {
                (
                    iter.next().unwrap().parse().unwrap(),
                    iter.next().unwrap().parse().unwrap(),
                )
            })
            .collect();

        let mut path: Vec<Vec<u64>> = repeat(repeat(0).take(b + 1).collect())
            .take(a + 1)
            .collect();
        path[1][1] = 1;

        for d in 3..(a + b + 1) {
            for x in 1..min(d, a + 1) {
                let y = d - x;
                if y > b || c.contains(&(x, y)) {
                    continue;
                }
                path[x][y] = path[x-1][y] + path[x][y-1];
            }
        }

        println!("{}", path[a][b]);
    }
}



Measured memory_bytes: 5024
N = int(input())
A = list(map(int,input().split(" ")))
mod = 10**9+7

fact = 1
for i in range(2,N+1):
    fact *= i
    fact %= mod

rev = [ (pow((i),mod-2,mod)*fact)%mod for i in range(1,N+1) ]
for i in range(N-1):
    rev[i+1] += rev[i]
    rev[i+1] %= mod

ans = 0
for i in range(N):
    ans += A[i] * (rev[i] + rev[N-1-i] - rev[0]) % mod
    ans %= mod

print(ans)



Measured memory_bytes: 63636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> k(n,vector<int>(n,-1));
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    k[a][b]=1;
    k[b][a]=1;
  }
  int u[n-1];
  int ans=0;
  rep(i,n-1)u[i]=1+i;
  do{
    if(k[0][u[0]]==-1)continue;
    int y=0;
    rep(i,n-2)if(k[u[i]][u[i+1]]==-1)y++;
    if(y==0)ans++;
  }while(next_permutation(u,u+n-1));
  cout << ans << endl;
}   


Measured memory_bytes: 256
x,k,d=map(int,input().split())
x=abs(x)
if x>k*d:
  ans=x-k*d
else:
  n=x//d
  if (k-n)%2==0:
    ans=x-n*d
  else:
    ans=abs(x-(n+1)*d)
print(ans)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define nl '\n'
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define dcit cin.sync_with_stdio(0);cin.tie(0);
#define frp(x, y) freopen(x, "r", stdin);freopen(y, "w", stdout);
typedef pair<int, int> pii;
typedef long long ll;

#ifdef LOCAL_PROJECT

#define gc getchar()
#define pc(x) putchar(x)

#endif
#ifndef LOCAL_PROJECT

#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)

#endif

template<typename T> void scani(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printi(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
string nextstring() { string r; register char c=gc;while(c==32||c==10) c = gc;while(!(c==32||c==10)) { r += c;c = gc; }return r; }
char nextgetchar(){ register char c = gc; while(c==32 || c==10) c = gc; return c;}

void prints(string k){ for (int i = 0; i < k.length(); i++)pc(k[i]); }
void scani() {}

template<typename First, typename ... Ints>
void scani(First &arg, Ints&... rest) { scani(arg);scani(rest...); }

int N, a, b, c, oa, ob, oc;
int main(){
    scani(N);
    for (int i = 0, ia, ib, ic; i < N; i++) {
        scani(ia, ib, ic);
        a = max(ob+ia, oc+ia);
        b = max(oa+ib, oc+ib);
        c = max(oa+ic, ob+ic);
        oa = a;
        ob = b;
        oc = c;
    }
    printi(max({oa, ob, oc}));
    return 0;
}

Measured memory_bytes: 256
s = input()

num_a = num_b = num_c = 0

for st in s:
    if st == "a":
        num_a += 1
    elif st == "b":
        num_b += 1
    elif st == "c":
        num_c += 1

if max(num_a, num_b, num_c) - min(num_a, num_b, num_c) <= 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 8956
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long [] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var x = inputLongArray[0];
            var k = inputLongArray[1];
            var d = inputLongArray[2];

            x = Math.Abs(x);
            var a = x / d;

            if (a >= k) x -= k * d;
            else if ((k - a) % 2 == 0) x -= a * d;
            else x -= (a + 1) * d;

            Console.WriteLine(Math.Abs(x));
        }
    }
}


Measured memory_bytes: 28248
/*                                  deepyadav442 --> :     c++14     <--                                */
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
/*                                           input                    */
#define si(i) scanf("%d",&i)
#define ss(s) scanf("%s",s)
#define sii(i,j) scanf("%d%d",&i,&j)
#define siii(i) scanf("%lld",&i)
/*                                           output                   */
#define pi(i) printf("%d",i)
#define pii(i,j) printf("%d%d",i,j)
#define piii(i) printf("%lld",i)
#define space printf(" ")
#define newline printf("\n")
/*                                          loops &stls                      */
#define loop(i,s,n) for(i=s;i<n;i++)
#define looprev(i,s,n) for(i=s;i>=n;i--)
#define itervec vector<int>::iterator itv
#define iterrev vector<int>::reverse_iterator it
#define itermap map<string,int>::iterator itm
#define pb(S) push_back(S)
#define mp(i,j) make_pair(i,j)
#define f first
#define s second
#define MAX(a,b) 	(a>b) ? (a) : (b)
#define MIN(a,b) 	(a<b) ? (a) : (b)
using namespace std;
int main()
{
    string s;
    cin>>s;
    int len2;
    int start,end;
    int length=s.length()-1;
    while(1)
    {
        if(length&1){
            length--;
            continue;
        }
        else
        {
            len2=length/2;
            start=0;
            end=length;
            int flag=0;
            for(int i=start,j=len2;i<len2&&j<end;i++,j++)
            {
                if(s[i]!=s[j])
                {
                    flag=1;
                    break;
                }
            }
            if(flag==0)
            {
                cout<<length<<endl;
                break;
            }
            else
            {
                length--;
            }
        }
    }
    space;
    return 0;
}

/*   fast input output
inline ll input() //for input integers call it long long int n=input();
{
    ll n=0;
    char ch=getchar_unlocked();
    while( ch < '0' || ch > '9' )
    {
        ch=getchar_unlocked();
    }
    while( ch >= '0' && ch <= '9' )
    {
        n = (n<<3)+(n<<1) + ch-'0', ch=getchar_unlocked();
    }
    return n;
}
inline void output(ll n)     //for output call output(count) and then for space use put('\n');
{
    char b[35];
    ll i=0;
    do
    {
        b[i++]=n%10+48;
        n=n/10;
    }while(n!=0);
    --i;
    while(i>=0)
    putchar_unlocked(b[i--]);
}
inline void faststring(char *str)  //for entering a string use faststring(p);
{
    register char c = 0;
    register long long i = 0;
    while (c < 33)
    c = getchar_unlocked();
    while (c != '\n')
    {
        str[i] = c;
        c = getchar_unlocked();
        ++i;
    }
    str[i] = '\0';
}


*/


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

#define REP(i,N) for(int (i)=0;(i)<(N);(i)++)
constexpr int dh[6] = { 1,1,1,0,-1,0 };
constexpr int dw[6] = { -1,0,1,1,0,-1 };

constexpr int dh2[6] = { 0,1,0,-1,-1,-1 };
constexpr int dw2[6] = { -1,0,1,1,0,-1 };

int H, W, Q;
vector<string> F;
vector<pair<int, int>> xy;

bool isin(int h, int w) {
	return 0 <= h && h < H && 0 <= w && w < W;
}

void rotate(int h, int w) {
	REP(dir, 6) {
		int nh = h + (w % 2 == 1 ? dh : dh2)[dir];
		int nw = w + (w % 2 == 1 ? dw : dw2)[dir];
		if (!isin(nh, nw))return;
	}
	REP(dir, 5) {
		int nh = h + (w % 2 == 1 ? dh : dh2)[dir];
		int nw = w + (w % 2 == 1 ? dw : dw2)[dir];
		int nnh = h + (w % 2 == 1 ? dh : dh2)[dir + 1];
		int nnw = w + (w % 2 == 1 ? dw : dw2)[dir + 1];
		swap(F[nh][nw], F[nnh][nnw]);
	}
}

bool can_fall(int h, int w) {
	if (h == H - 1)return false;//下端
	REP(dir, 3) {
		int nh = h + (w % 2 == 1 ? dh : dh2)[dir];
		int nw = w + (w % 2 == 1 ? dw : dw2)[dir];
		if (!isin(nh, nw))continue;
		if (F[nh][nw] != '.')return false;
	}
	return true;
}

bool fall() {
	bool res = false;
	for (int h = H - 1; h >= 0; h--)REP(t, 2)REP(w, W) {
		if (w % 2 == t)continue; // ずれによる段数を考慮
		int nh = h;
		int nw = w;
		while (can_fall(nh, nw)) {
			swap(F[nh][nw], F[nh + 1][nw]);
			nh++;
			res = true;
		}
	}
	return res;
}

vector<pair<int, int>> feed(
	const int sh,
	const int sw,
	const char color,
	vector<vector<bool>>& see
) {
	vector<pair<int, int>> cands;
	queue<pair<int, int>> q;
	q.push({ sh,sw });
	see[sh][sw] = true;
	cands.push_back({ sh,sw });
	while (!q.empty()) {
		auto now = q.front(); q.pop();
		REP(dir, 6) {
			int w = now.second;
			int nh = now.first + (w % 2 == 1 ? dh : dh2)[dir];
			int nw = now.second + (w % 2 == 1 ? dw : dw2)[dir];
			if (!isin(nh, nw))continue;
			if (see[nh][nw])continue;
			if (F[nh][nw] == color) {
				see[nh][nw] = true;
				cands.push_back({ nh,nw });
				q.push({ nh,nw });
			}
		}
	}
	return cands;
}

bool erase() {
	bool res = false;
	vector<vector<bool>> see(H, vector<bool>(W, false));
	REP(h, H)REP(w, W)if (F[h][w] != '.' && !see[h][w]) {
		auto cands = feed(h, w, F[h][w], see);
		if (cands.size() < 3)continue;
		for (auto cand : cands)F[cand.first][cand.second] = '.';
		res = true;
	}
	return res;
}

void debug() {
	cout << "-----------------" << endl;
	for (auto row : F)cout << row << endl;
	cout << "-----------------" << endl;
}

void combo() {
	while (true) {
		if (!erase())break;
		//debug();
		if (!fall())break;
		//debug();
	}
}

int main() {
	cin >> H >> W;
	F.resize(H);
	REP(i, H)cin >> F[i];
	cin >> Q;
	REP(i, Q) {
		int x, y;
		cin >> x >> y;
		xy.push_back({ x,y });
	}
	//debug();
	combo();
	//debug();
	for (auto p : xy) {
		rotate(H - 1 - p.second, p.first);
		//debug();
		fall();
		//debug();
		combo();
		//debug();
	}
	for (auto row : F)cout << row << endl;
	return 0;
}


Measured memory_bytes: 3240
#include <stdio.h>

int main() {
  int N,M;
  scanf("%d %d",&N,&M);
  int A[M];
  for(int i=0;i<M;i++) {
    scanf("%d",&A[i]);
  }
  for(int i=0;i<M;i++) {
    N-=A[i];
  }
  if(N<0) {
    printf("%d",-1);
  }else {
    printf("%d",N);
  }
  return 0;
}

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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 1e5+5;

int n,k;
ll h[N],dp[N];


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>h[i];

    for(int i=2;i<=n;i++)dp[i]=1LL*N*N;

    for(int i=2;i<=n;i++){
        for(int j=max(1,i-k);j<i;j++){
            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }

    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1792
oni = list(map(int,input().split()))
child =list(map(int,input().split()))
time = int(input())

if oni[0]<child[0]:
    oni_kyori = oni[0]+oni[1]*time
    child_kyori = child[0]+child[1]*time

    if oni_kyori<child_kyori:
        print('NO')
    else:
        print('YES')
else:
    oni_kyori = oni[0]-oni[1]*time
    child_kyori = child[0]-child[1]*time

    if oni_kyori>child_kyori:
        print('NO')
    else:
        print('YES')

Measured memory_bytes: 9208
using System;
using System.Linq;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var B = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long ans = 0;
            for (long i = 0; i < B.Count(); i++)
            {
                long d = Math.Min(A[i], B[i]);

                ans += d;


                A[i] -= d;


                B[i] -= d;


                d = Math.Min(A[i + 1], B[i]);


                ans += d;


                A[i + 1] -= d;


               B[i] -= d;

            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 36020
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1e9+7;
const int INF=1001001001;

int main() {
  int64_t x,y;
  cin>>x>>y;
  if(x%y==0){cout<<-1<<endl;}
  else {
    cout<<x<<endl;
  }
  return 0;  
}

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

int Arr_Sort_rev( const void* A , const void* B )
{
    return *((const int*)B) - *((const int*)A) ;
}

int main()
{
    int mass = 0 ;
    int card = 0 ;
    int win[1001] = {0} ;
    int lose[1001] = {0} ;
    int Count = 0 ;
    int cost = 0 ;

    cin >> mass >> card ;
    for ( int i = 0 ; i < card ; i++ )
    {
        cin >> win[i] >> lose[i] ;
    }

    qsort( win , 1001 , sizeof(win[0]) , Arr_Sort_rev ) ;
    sort( lose , lose+card ) ;
    for ( int i = 0 ; i < card ; i++ )
    {
        if ( win[i] < mass )
        {
            while( win[i] < mass )
            {
                win[i]++ ;
                cost++ ;
            }
            Count++ ;
        }
        else Count++ ;
        if ( Count >= card-1 ) break ;
    }

    cout << cost << endl ;

    return 0 ;
}

Measured memory_bytes: 3308
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
 
template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
typedef __int128 u;

u sum[2333333], ans[233333];

int main(void) {
  srand(time(NULL));
  long long _K;
  cin >> _K;
  u K = _K;
  u len = 700;
  sum[1] = 1;
  for (int i = 2; i <= len; i ++) {
    sum[i] = 1;
    for (int k = i; k <= i + 6; k ++)
      sum[i] *= k;
    sum[i] /= (u)5040;
    if (sum[i] > K) {
      len = i - 1;
      break;
    }
  }
  // for (int i = 1; i <= len; i ++)
  //   cerr << (unsigned long long) sum[i] << " "; cerr << "\n";
  u pos = len;
  // cerr << (long long) u << "\n";
  while (K) {
    if (sum[pos] > K) {
      -- pos;
      continue;
    }
    // cout << (int) pos << "\n";
    u t = K / sum[pos];
    ans[pos] = t;
    K %= sum[pos];
  }
  for (int i = 1; i <= len; i ++) {
    cout << "FESTIVA";
    re0 (_, ans[i]) cout<<"L";
  }
  cout << "\n";
}


Measured memory_bytes: 2432
/*
***************************************************************************
 name  : ITP1_08_D.cpp
 title : Ring
 make  : 2018/08/29 tanabe
***************************************************************************
*/

// Library
#include <iostream>  // standard input output object
#include <cstring>   // character functions

main(void){
  std::string s; // text
  std::string p; // pattern
  int i;         // index

  std::cin >> s; // input "s"
  std::cin >> p; // input "p"

  s += s; // Append s after s

  if(s.find(p) == -1){
    std::cout << "No" << std::endl; // output "No"
  }
  else{
    std::cout << "Yes" << std::endl; // output "Yes"
  }

}



Measured memory_bytes: 3236
n, k, q = map(int, input().split())
a_array = [int(input()) for x in range(q)]

cnt = [0 for x in range(n+1)]
for i in a_array:
    cnt[i] += 1

for ans in cnt[1:]:
    if k-(q-ans) > 0:
        print("Yes")
    else:
        print("No")


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

int main(){
  int q;
  cin>>q;
  long long int lp=0;
  long long int rp=0;
  for(int i=0;i<q;i++){
    long long int p,n;
    char c;
    cin>>p>>c>>n;
    if(c=='(') lp+=n;
    else rp+=n;
    cout<<(lp==rp ? "Yes": "No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 3076
def bubbleSort(C, N):
    for i in range(0, N):
        for j in range(N-1, i, -1):
            if C[j][1]<C[j-1][1]:
                C[j], C[j-1] = C[j-1], C[j]
    return C
 
def selectionSort(C, N):
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if C[j][1] < C[minj][1]:
                minj = j
        C[i], C[minj] = C[minj], C[i]
    return C
 
def check(C0, C1):
    for i in range(N):
        for j in range(i+1, N):
            for a in range(N):
                for b in range(a+1, N):
                    if C0[i][1] == C0[j][1] and C0[i] == C1[b] and C0[j] == C1[a]:
                        return False
    return True
 
def toStr(a):
    return str(a[0])+str(a[1])
 
N = int(input())
src = [(str(char[0]), int(char[1])) for char in input().split()]
 
out_1 = bubbleSort(src[:], N)
out_2 = selectionSort(src[:], N)
# &は2進数
# リストは参照渡し
for out in [out_1, out_2]:
    ans = map(toStr, out)
    print(*ans)
    if check(src, out):
        print('Stable')
    else:
        print('Not stable')


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s;
    int n;
    cin >> s >> n;
    int N = s.size();
    int ans = 0;
    rep(i, n) {
        string t; cin >> t;
        bool found = false;
        t += t;
        rep(i, 20-N) if(t.substr(i, N) == s) found = true;
        if(found) ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3132
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    int d,j,k,l,o,min;
    public void solve() {
        Scanner sc = new Scanner(System.in);
        int date[] =new int[2];
        for(d=0;d<2;d++) {
            date[d] = sc.nextInt();
        }
        int[] dat=new int[date[0]];
        for(int o=0;o<date[0];o++) {
            dat[o]=sc.nextInt();
        }
        Arrays.sort(dat);
        for(int o=0;o<date[1];o++) {
            min=min+dat[o];

        }
        System.out.println(min);
    }
    public static void main(String[] args) {
        new Main().solve();

    }
}


Measured memory_bytes: 38436
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B,C,D;
  cin >> N >> A >> B >> C >> D;
  string S;
  cin >> S;
  bool exist = true;
  
  if(C < D){
    for(int i=A-1; i<=C-2; i++){
       if(S.at(i) == '#' && S.at(i+1) == '#'){
         exist = false;
         break;
       }
    }
    for(int i=B-1; i<=D-2; i++){
       if(S.at(i) == '#' && S.at(i+1) == '#'){
         exist = false;
         break;
       }
    }
    if(exist){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    bool change = false;
    for(int i=A-1; i<=C-2; i++){
       if(S.at(i) == '#' && S.at(i+1) == '#'){
         exist = false;
         break;
       }
    }
    for(int i=B-2; i<=D-2; i++){
       if(S.at(i) == '#' && S.at(i+1) == '#'){
         exist = false;
         break;
       }
      if(S.at(i) == '.' && S.at(i+1) == '.' && S.at(i+2) == '.'){
        change = true;
      }
    }
    if(exist && change){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
const int INF=1<<30;
using namespace std;
typedef pair<int,int> pr;
typedef vector<int> vi;
char word[100001];
vi edge[100001];
int V,E,a,b;
void search(int num){
	if(num==V)
	return ;
	if(word[num]=='?'){
	bool used[27]={};
	REP(i,edge[num].size())
	if(word[edge[num][i]] !='?')
	used[word[edge[num][i]]-'a']=true;
	REP(i,26)
	if(!used[i]){
		word[num]=i+'a';
		break;
	}
	}
	cout << word[num];
	search(num+1);
	return ;
}
int main() {
	cin >> V >> E;
	REP(i,V)
	cin >> word[i];
	REP(j,E){
	cin >> a >> b;
	edge[a].push_back(b);
	edge[b].push_back(a);
	}
	search(0);
	cout << endl;
	// your code goes here
	return 0;
}


Measured memory_bytes: 8076
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B;
  cin>>A>>B;
  if(A<=8 && B<=8){
    cout<<"Yay!"<<endl;
  }else{
    cout<<":("<<endl;
  }
}


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

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    int h[n];
    int sum=0;
    for(int i=0;i<n;i++){
    	cin>>h[i];
    }
    sort(h,h+n,greater<int>());
    for(int i=k;i<n;i++){
    	sum+=h[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <iomanip>
#include <iostream>
#include <vector>    
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    ll n;
    string s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    cin >> n >> s;
    ll num = 0;
    for (ll i = 0; i < n;i++)
    {
        if(s[i]=='R')
            r.push_back(i+1);
        if(s[i]=='G')
            g.push_back(i+1);
        if(s[i]=='B')
            b.push_back(i+1);
    }
    for(auto i:r)
        for(auto j:g)
            for(auto k:b)
            {
                if(2*j==i+k)
                    continue;
                if(2*k==i+j)
                    continue;
                if(2*i==j+k)
                    continue;
                num++;
            }
    cout << num;
    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
  reverse(x.begin(),x.end());
  int a=0;
  int b=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      a+=x[i];
    }
    else{
      b+=x[i];
    }
  }
  cout<<a-b<<endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>v;
    while(n>0){
        int rem=n%10;
        n=n/10;
        v.push_back(rem);
    }
    if(v[0]==v[2])cout<<"Yes";
    else cout<<"No";
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    int n; cin >> n;
    V<ll> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    ll cnt = 0;
    for(int i = n - 1; i >= 0; i--){
        if((cnt + a[i]) % b[i] != 0){
            ll x = (cnt + a[i]) / b[i];
            ll y = (x + 1) * b[i] - (a[i] + cnt);
            cnt += y;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 4796
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;

const ll INF = LONG_LONG_MAX;


double f(const vector<double> &t,const vector<double> v,int i,double x){
    double ret = 0;
    if(x < t[i]){
        ret = v[i]+(t[i]-x);
    }else if(x > t[i+1]){
        ret = v[i] + (x- t[i+1]);
    }else{
        ret = v[i];
    }
    return ret;
}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N;
    cin >> N;
    vector<double> t(N+4,0);
    repeat(i, N){
        double time;
        cin >> time;
        t[i+2] = t[i+1] + time;
    }
    t[N+2] = t[N+1];
    vector<double> v(N+2,0);
    repeat(i, N){
        cin >> v[i+1];
    }
    double ans = 0;
    double left=0,right=0;
    repeat(j, 2*t[N+2]){
        right = INF;
        double x = (double)(j+1)/2;
        repeat(i, N+2){
            right = min(right,f(t,v,i,x));
        }
        ans += (left+right)/4;
        left = right;
    }
    printf("%.4lf\n",ans);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    char S[3];
    scanf("%s", S);

    for(int i = 1; i < 3; i++) {
        if(S[i] != S[i - 1]) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

    return 0;
}

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

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();

            char[] cs = s.
            ToCharArray();

            cs[3] = '8';

            Console.WriteLine(cs);

            Console.ReadKey();
        }
    }
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  ll n; cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
    a[i]-=(i+1);
  }
  vsort(a);
  int center=a[(n-1)/2];
  ll ans=0;
  rep(i,n){
    ans+=(ll)abs(a[i]-center);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    vector<int> num(5);
    rep(i,5) cin >> num[i];
    rep(i,5){
        if(num[i] == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3588
#include <stdio.h>

int main(void)
{
	int a,b,c,tmp;
	scanf("%d %d %d",&a,&b,&c);
	
	if (a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if (b > c){
		tmp = b, b = c, c = tmp;
		if (a > b) 
			tmp = a, a = b, b = tmp;
	}
	
	printf("%d %d %d\n",a,b,c);
	return 0;
}


Measured memory_bytes: 2100
#include<stdio.h>

int n,i,a,b,f,x,y,z;

int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d",&a);
		b=f=0;x=y=1;
		for(i=1;i<10;i++){
			scanf("%d",&z);
			if(a>z && b>z)f=1;
			else if(a<z && b<z){
				if(a>b)a=z;
				else b=z;
			}else{
				if(a>b)b=z;
				else a=z;
			}
		}
		printf("%s\n",(f==0)?("YES"):("NO"));
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  V a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<bool> b(n, false);
  int x = 1;
  int cnt = 1;
  while (1) {
    if (b[x-1]) {
      cnt = -1;
      break; 
    }
    if (a[x-1] == 2) break;
    cnt++;
    b[x-1] = true;
    x = a[x-1];
  }
  dump(cnt);
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int jikan, hun, byou, time;

	scanf("%d", &time);

	jikan = time % 86400 / 3600;
	hun = time % 3600 / 60;
	byou = time % 3600 % 60;

	printf("%d:%d:%d\n", jikan, hun, byou);


	return 0;
}

Measured memory_bytes: 592
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int N=0;
int main(int argc, char const *argv[])
{
    cin>>N;
    std::vector<int> p(N);
    for(int i=0;i<p.size();i++){
    cin>>p[i];
    }
    int max = *std::max_element(p.begin(), p.end());
    int value=0;
    for(int i=0;i<p.size();i++){
        value+=p[i];
    }
    value=value-max/2;
    cout<<value<<endl;
    /* code */
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll int n;
    cin>>n;
    ll int a[n];
    for(ll int i=0;i<n;i++)
        cin>>a[i];
     ll int b[n];
     for(ll int i=0;i<n;i++)
                b[i]=a[i];
     sort(b,b+n,greater<ll int>());
     ll int maxi=b[0];
     ll int sec_maxi=b[1];

     for(ll int i=0;i<n;i++)
     {
         if(a[i]==maxi)
            cout<<sec_maxi<<endl;
         else
            cout<<maxi<<endl;
     }

return 0;
}








Measured memory_bytes: 4736
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <stack>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int>P(N);
	for (int i = 0; i < N; i++) {
		cin >> P.at(i);
	}
	int ans = 0;
	for (int i = 1; i < N - 1; i++) {
		if ((P.at(i - 1) > P.at(i) && P.at(i) > P.at(i + 1)) || (P.at(i - 1) < P.at(i) && P.at(i) < P.at(i + 1))) ans++;
	}
	cout << ans << endl;
}

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




namespace ConsoleApplication1 {

    

    class ClassMain {

        //[n+1 , n+1]
        static int[,] path = new int[0, 0];
        
        
        static int dijik(int n , int start, int end) {
            int[] cost = Enumerable.Repeat(int.MaxValue, n + 1).ToArray();
            bool[] visited = new bool[n + 1];
            cost[start] = 0;

            while (true) {
                //min cost check. 
                int selected = -1;
                int minCos = int.MaxValue;
                for (int i = 1; i <= n; i++) {
                    if (visited[i]) { continue; }
                    if (minCos > cost[i]) { selected = i; minCos = cost[i]; }
                }
                if (selected == -1 || selected ==end) { break; }
                visited[selected]=true;

                //cost reload
                for (int i = 1; i <= n; i++) {
                    if (path[selected, i] >= 0) {
                        cost[i] = Math.Min(cost[i], cost[selected] + path[selected, i]);
                    }
                }
            }
            return cost[end];
        }


        public static void Main(String[] args) {
           string line;
           while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                //int n = ints[0];
                int n = int.Parse(line);                
                if (n == 0) { break; }
               path=new int[n+1,n+1];
               for (int i = 0; i < n + 1; i++) for (int j = 0; j < n + 1; j++) {
                   path[i, j] = -1;    
               }
                int m = int.Parse(Console.ReadLine());
                for (int i = 0; i < m; i++) {
                    int[] ints = Console.ReadLine().Split(',').Select(int.Parse).ToArray();
                    path[ints[0], ints[1]] = ints[2];
                    path[ints[1], ints[0]] = ints[3];
                }

                int[] ints2 = Console.ReadLine().Split(',').Select(int.Parse).ToArray();
                int ikicost = dijik(n, ints2[0], ints2[1]);
                int kaericost = dijik(n, ints2[1], ints2[0]); 
               
               Console.WriteLine(ints2[2]-ints2[3]-ikicost-kaericost);
               break;
            }
        }

    }

    


}

Measured memory_bytes: 5944
N=int(input())
A=sorted([int(i) for i in input().split()])
S=[0 for i in range(N)]
S[0]=A[0]
for i in range(N-1):
    S[i+1]=A[i+1]+S[i]
ans=1
for i in range(N-1)[::-1]:
    if 2*S[i]>=A[i+1]:
        ans+=1
    else:
        break
print(ans)


Measured memory_bytes: 14304