akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int N = in();
  Int res = 0;
  map<Int, int> cnt;
  cnt[0] = 1;

  Int s = 0;
  for (int i = 0; i < N; ++i) {
    s += in();
    if (cnt.count(s)) {
      res += cnt[s];
    }
    ++cnt[s];
  }
  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<cstdio>
#include<vector>
#include<utility>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<limits>
#include <bitset>      


#define LL long long
#define f first
#define s second
#define pb push_back
#define mp make_pair


using namespace std;

LL dp[100005][5];
int v[100005][5];
 

int main(){

    int n;
    cin >> n;

    memset(dp, 0, sizeof dp);

    for(int i = 1; i <= n; i++)
    for(int j = 1; j <= 3; j++) 
            cin >> v[i][j];

    LL ans = 0;

    for(int i = 1; i <= n; i++){
           for(int j = 1; j <= 3; j++){
                 for(int l = 1; (l <= 3); l++){
                      if((l != j))
                       dp[i][j] = max(dp[i][j], dp[i-1][l] + v[i][j]);
                    }
                 ans = max(ans, dp[i][j]);
               }
        }
    

    cout << ans;
    

    return 0;

}


Measured memory_bytes: 6144
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



ll K;

int main () {
  cin >> K;

  ll s = K / 50L;
  int a = K % 50L;

  ll tmp = 49 + s;

  cout << "50\n";

  if (a == 0) {
    Rep(i, 49) {
      cout << tmp << " ";
    }
    cout << tmp << "\n";
  } else {
    ll r = tmp + 51LL - a;
    ll l = tmp - a;
    Rep(i, 50-a) {
      cout << l << " ";
    }
    Rep(i, a-1) {
      cout << r << " ";
    }
    cout << r << "\n";
  }
}

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

int main(){
	int n, k;
	int cnt = 0;
	cin >> n;
	cin >> k;
	vector<int> h(n);

	for(int i=0; i<n; i++){
		cin >> h[i];
		if(h[i] >= k){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define max(x, y) ((x) > (y) ? (x) : (y))

int n[101], mx = 0;

int main(){
  int i;
  while(scanf("%d", &i) != EOF){
    n[i]++;
    mx = max(mx, n[i]);
  }
  for(i = 1;i <= 100;i++){
    if(n[i] == mx)
      printf("%d\n",i);
  }
  return 0;
}

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

#define PB push_back
#define ld long double
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin(), (x).end()
#define ios ios_base::sync_with_stdio(0);
#define sz(s) (int)(s).size()
#define open(name) \
freopen(name".in", "r", stdin); \
freopen (name".out", "w", stdout);

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

const int N = 2e5 + 7;;
const int INF = 1e9 + 7;
const int logg = 20;
const double PI = 3.14;

using namespace std;

char a[1007][1007];
long long dp[1007][1007];

void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= m; j ++) {
            cin >> a[i][j];
        }
    }
    dp[0][1] = 1;
    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= m; j ++) {
            if (a[i][j] == '.') {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) %INF;
            }
            //cout << dp[i][j] << ' ';
        }
        //cout << '\n';
    }
    cout << dp[n][m];
}
int main() {
    ios;
    solve();
}


Measured memory_bytes: 12440
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)((x).size()))
//
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

ll dp[32];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, k;
  cin >> n >> k;
  vll a(n), b(n);
  rep(i, n){
    cin >> a[i] >> b[i];
  }
  if(k){
    ll ans = 0;
    rep(i, 32){
      if((k >> i) & 1){
        ll p = ((k >> i) << i) - 1;
        ll tmp = 0;
        rep(j, n){
          if((a[j] & ~p) == 0){
            tmp += b[j];
          }
        }
        chmax(ans, tmp);
      }else{
        ll p = k;
        ll tmp = 0;
        rep(j, n){
          if((a[j] & ~p) == 0){
            tmp += b[j];
          }
        }
        chmax(ans, tmp);
      }
    }
    print(ans);
  }else{
    ll ans = 0;
    rep(i, n){
      if(!a[i]) ans += b[i];
    }
    print(ans);
  }
}


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

#define all(x)  x.begin(), x.end()
#define pii     pair<int, int>

vector<int> g[101010];
int dist[101010];
int ans[101010];

void dfs1(int v, int prev) {
        for (auto u : g[v]) if (u != prev) {
                dfs1(u, v);
                dist[v] = max(dist[v], dist[u] + 1);
        }
}

void dfs2(int v, int ma, int prev) {
        vector<pii> children;
        children.emplace_back(0, -1);
        for (auto u : g[v]) {
                if (u == prev) children.emplace_back(ma + 1, u);
                else children.emplace_back(dist[u] + 1, u);
        }
        sort(all(children), greater<pii>());
        ans[v] = children[0].first;
        for (auto u : g[v]) if (u != prev) dfs2(u, children[u == children[0].second ? 1 : 0].first, v);
}

int main() {
        int n;
        cin >> n;
        for (int i = 0; i < n - 1; i ++) {
                int a, b;
                cin >> a >> b;
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        dfs1(0, -1);
        dfs2(0, 0, -1);
        for (int i = 0; i < n; i ++) cout << (n - 1) * 2 - ans[i] << endl;
        return 0;
}

Measured memory_bytes: 26616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int k = sc.nextInt();
		int[] d = new int[k];
		int[] dis = new int[10];
		for(int i = 0 ; i < k ; i++) {
			d[i] = sc.nextInt();
			dis[d[i]]++;
		}
		for(int i = a ; i <= 10 * a ; i++) {
			int temp = i;
			int cnt = 0;
			while(temp > 0) {
				boolean match = false;
				for(int j = 0 ; j < k ; j++) {
					if(dis[temp % 10] == 1) {
						match = true;
					}
				}
				if(match) cnt++;
				temp /= 10;
			}
			if(cnt == 0) {
				System.out.println(i);
				return;
			}
		}
	}
}

Measured memory_bytes: 23764
#include<algorithm>
#include<cmath>
#include<deque>
#include<iomanip>
#include<iostream>
#include<list>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<string>
#include<vector>

#include<map>
#include<set>
#define rep0_n(i,n) for(int i=0; i<n; i++)
#define rep1_n(i, n) for(int i=1; i<n+1; i++)
#define reps_n(i, s, n) for(int i=s; i<n; i++)
typedef long long ll;
using namespace std;

int main(){
  int k,x;
  cin >> k >> x;
  for(int i = x-k+1; i < x+k; i++){
    cout << i << " ";
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
int i,j,k,u,n,v;
int p[100][100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        for (j=0;j<n;j++){
            p[i][j]  = 0;
}
}  
 for(i=0;i<n;i++) {
        scanf("%d %d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d",&v);
            p[u-1][v-1]  = 1;
 }
    }
     
     
for(i=0;i<n;i++){
for(j=0;j<n;j++){

printf("%d",p[i][j]);
  
          if (j != n-1) printf(" ");   
 }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// 条件を見落としていませんか？
int main () {
    string N;
    cin >> N;
    ll ans = 0;
    for (auto x: N) ans += x-'0';
    cout << max((N[0]-'0'-1)+(ll)(N.size()-1)*9, ans) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug(){cerr<<endl;}
	template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
	template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "

const ll INF = 1e18;
const int MAX_COINS = 150*50;
const int MAXN = 55;

struct Edge {
    int to;
    ll time, cost;
};

struct State {
    int city, coins;
    bool operator < (const State& rhs) const {
        return city < rhs.city;
    }
};

vector<Edge> g[MAXN];
ll dist[MAXN][MAX_COINS];
ll coins[MAXN], wait[MAXN];


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

    // (city, number of coins)
    int n, m, s;
    cin >> n >> m >> s;
    for(int i = 0; i < m; i++) {
        int u, v, cost, time;
        cin >> u >> v >> cost >> time;
        u--, v--;
        g[u].push_back({v, time, cost});
        g[v].push_back({u, time, cost});
    }
    for(int i = 0; i < n; i++) {
        cin >> coins[i] >> wait[i];
    }
    for(int i = 0; i < MAXN; i++) {
        for(int j = 0; j < MAX_COINS; j++) {
            dist[i][j] = INF;
        }
    }
    s = min(s, MAX_COINS-1);
    dist[0][s] = 0;
    priority_queue<pair<ll, State>, vector<pair<ll, State>>, greater<pair<ll, State>>> pq;
    pq.push({0, {0, s}});
    while(!pq.empty()) {
        ll d = pq.top().first;
        State u = pq.top().second; pq.pop();
        debug() nav(u.city) nav(u.coins);;
        if(d > dist[u.city][u.coins]) continue;
        int city = u.city;
        if(u.coins + coins[city] < MAX_COINS) {
            int new_coins = u.coins + coins[u.city];
            ll new_d = d + wait[u.city];
            if(new_d < dist[u.city][new_coins]) {
                dist[u.city][new_coins] = new_d;
                pq.push({new_d, {u.city, new_coins}});
            }
        }
        for(Edge e : g[city]) {
            debug() nav(e.cost);
            if(u.coins >= e.cost) {
                ll new_d = d + e.time;
                int new_coins = u.coins - e.cost;
                if(dist[e.to][new_coins] > new_d) {
                    dist[e.to][new_coins] = new_d;
                    pq.push({new_d, {e.to, new_coins}});
                }
            }
        }
    }
    for(int i = 1; i < n; i++) {
        ll ans = INF;
        for(int j = 0; j < MAX_COINS; j++) {
            ans = min(ans, dist[i][j]);
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 10596
import collections
import numpy as np

# リストarrからx個の同じ長さの列を取り出す時の最大の長さ
# 発想: x個取り出す時、ある文字をx個より多く取り出して列に含むことはない
#       一方ある文字をその文字がある数よりも取り出して使うこともできない
#       つまり、min(arr.count(a), x)で、x個の同じ長さの列に使えるaの数がわかる
#       さらに、sum(min(arr.count(a),x))で、x個の同じ長さの列に使える文字の数がわかる
#       よって、sum(min(arr.count(a),x))//xで、x個の同じ長さの列の長さがわかる
#       発展的に、longest(arr,x)までの計算状況からlongest(arr,x+1)が計算できる
# def longest(arr, x):    # legacy
#     return sum(min(arr.count(a), x) for a in arr) // x


n = int(input())
a = list(map(int, input().split()))

counter = collections.Counter(a)        #O(n)
nums = list(counter.values())           #O(n)
num_counter = collections.Counter(nums) #O(n)
lastest_add = np.count_nonzero(nums)    #O(n)
building, longests = [0], [0]
for i in range(1, n+1):                 #O(n)
    appended = building[-1] + lastest_add   #O(1)
    building.append(appended)               #O(1)
    longests.append(appended // i)          #O(1)
    lastest_add -= num_counter[i]           #O(1)


lastest_longest = 0
k_most = []
for i, x in enumerate(reversed(longests)):
    while x > lastest_longest:
        lastest_longest += 1
        k_most.append(n-i)

k_most.extend([0]*(n-len(k_most)))      # zero padding

for longests_num in k_most:
    print(longests_num)

# print('----------------')
# for k in range(1, n+1):
#     maxindexes = list(i for i, x in enumerate(longests) if x >= k)
#     if maxindexes:
#         print(maxindexes[-1])
#     else:
#         print(0)


Measured memory_bytes: 59540
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
	int n;
	cin>>n;
	if(n>=400 && n<=599){
		cout<<8<<endl;
	}
else	if(n>=600 && n<=799){
		cout<<7<<endl;
	}
	else if(n>=800 && n<=999){
		cout<<6<<endl;
	}
else	if(n>=1000 && n<=1199){
		cout<<5<<endl;
	}
	else	if(n>=1200 && n<=1399){
		cout<<4<<endl;
	}
	else	if(n>=1400 && n<=1599){
		cout<<3<<endl;
	}
else	if(n>=1600 && n<=1799){
		cout<<2<<endl;
	}
	else	if(n>=1800 && n<=1999){
		cout<<1<<endl;
	}
	return 0;
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int a,b,c;
cin >> a >> b >> c;
if(b - a == c - b) cout << "YES" << endl;
else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ) {
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ) {
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 9592
n, m = map(int, input().split())
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = map(int, input().split())
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

print('\n'.join(buf))


Measured memory_bytes: 46884
//Granding
//??????
#include<stdio.h>


int main(void){
    int m, f, r;
    int i;
    int sum = 0;
    while(1){
        scanf("%d", &m);
        scanf("%d", &f);
        scanf("%d", &r);
        
        if(m == -1 && f == -1 && r == -1) break;
        sum = m+f;
        if(m == -1 || f == -1) printf("F\n");
        else if(80 <= sum)  printf("A\n");
        else if(65 <= sum)  printf("B\n");
        else if(50 <= sum)  printf("C\n");
        else if(30 <= sum)  {
            if(50 <= r) printf("C\n");
            else printf("D\n");
        }
        else    printf("F\n");
    }
    
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
int main()
{
  ll N,H;
  cin>>N>>H;
  vector<ll> A(N);
  vector<ll> B(N);
  rep(i,N){
    cin>>A.at(i)>>B.at(i);
  }
  ll sum=0;
  ll Z=0;
  sort(A.begin(),A.end(),greater<ll>());
  sort(B.begin(),B.end(),greater<ll>());
  ll ans=(H-1)/A.at(0)+1;
  rep(i,N){
    sum+=B.at(i);
    if(H>sum)ans=min(ans,(H-sum-1)/A.at(0)+2+i);
    else ans=min(ans,i+1);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=2e5+100;
ll n, arr[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; ++i)
        cin>>arr[i];
    ll sum=0;
    vector<int>v;
    for(int i=1; i<=n; i++)
    {
        v.pb(arr[i]-i);
        sum+=abs(arr[i]-i);
    }
    sort(all(v));
    ll val=v[n/2];
    ll res=0;
    for(int i=1; i<=n; i++)
        res+=abs(arr[i]-(val+i));
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 2936
def main():
    N = int(input())
    A = list(map(int, input().split()))

    h = A[0]
    ans = 0

    for i in A:
        if i < h:
            ans += h - i
        elif h < i:
            h = i

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32236
fun main(args: Array<String>) {

    readInts().sortedDescending().let {
        println(it[0] * Math.pow(2.toDouble(), readInt().toDouble()).toInt() + it[1] + it[2])
    }
}

fun readInt(): Int = readLine()!!.toInt()
fun readInts(): List<Int> = readLine()!!.split(" ").map { it.toInt() }

Measured memory_bytes: 37856
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
//#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

ll 
power(ll x, ll y, ll m = MOD) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2ll, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

int
main()
{

  int N, K; cin >> N >> K;
  vector<ll> divises(K + 1);
  ll ans = 0;
  for(ll i = K; i >= 1; --i){
    ll num = K / i;
    ll add = power(num, N);
    if(i <= K / 2){
      ll tmp = i + i;
      while(tmp <= K){
        add =(add - divises[tmp] + MOD) % MOD;
        tmp += i;
      }
    }
    divises[i] = add;
    ans = (ans + divises[i] * i) % MOD;
  }
  ans = (ans + MOD) % MOD;
  cout << ans << endl;

}


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

using namespace std;



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

	int n, m;
	cin >> n >> m;

	vector<int> a(n);

	int total = 0;

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

	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		if (4 * m * a[i] < total)
			continue;
		++cnt;
	}

	cout << (cnt >= m ? "Yes" : "No") << '\n';

	return 0;	
}

Measured memory_bytes: 256
N,M,X = map(int,input().split())
CA=[list(map(int,input().split())) for _ in range(N)]
#print(CA)
cost_0 = 10000000
b = f"0{N}b"
for i in range(2**N):
    i_bit = str(format(i,b))
    #print(i_bit)
    Ans = [0]*(M+1)
    for j in range(N):
        if i_bit[j] == "1":
            Ans = [p+ca for p,ca in zip(Ans,CA[j])]
    if min(Ans[1:])>=X:
        cost = Ans[0]
    else:
        cost = cost_0
    cost_0 = min(cost_0,cost)
if cost_0 != 10000000:
    print(cost_0)
else:
    print(-1)

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

int main() {
 int n;
 cin >> n;
 string s;
 bool a = false;
 for(int i = 0;i < n;++i){
   cin >> s;
   if(s == "Y"){
     a = true;
     break;
   }
 }
 if(a == true) cout << "Four" << endl;
 else cout << "Three" << endl;
}

  

  


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e18
#define ss second
#define ff first

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int mod=1e9+7;
//const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e5+10;
int par[up];

int find(int x)
{
    if(par[x]==x)
        return x;
    else
        return par[x]=par[find(par[x])];
}

// int merge(int u,int v)
// {
//     int x=find(u);
//     int y=find(v);
//     if(x!=y)
//     {
//         if(size[x]<=size[y])
//         {
//             par[x]=y;
//         }
//     }
// }

int n,k,a;
int s[up];

void solve()
{
    int a,b;
    cin>>a>>b;
    cout<<(a*b)<<endl;
}

int32_t main()
{
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}



Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;

    if ((4 * x - y) % 2 == 0) {
        int a = (4 * x - y) / 2;
        if (0 <= a) {
            int b = x - a;
            if (0 <= b) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>

using namespace std;

int main()
{
	int n, i, c = 0;
	char s[100002] = {}, t[50002] = {};

	scanf("%s", &s[0]);

	for (i = 0; s[i] != '\0'; i += 2) {
		t[c] = s[i];
		c++;
	}

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

	return 0;
}

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

using namespace std;

int main(void) {
    int n, a, b;
    while (cin >> n, n) {
        int pa = 0, pb = 0;
        for (int i = 0; i < n; i++) {
            cin >> a >> b;
            if (a > b) pa += a + b;
            else if (a < b) pb += a + b;
            else {
                pa += a;
                pb += b;
            }
        }
        cout << pa << " " << pb << endl;
    }

    return 0;
}


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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (auto& e : a) cin >> e;
	int num = 1;
	for (int i = 0; i < n; ++i)
		if (a[i] == num) ++num;
	int ans = n - num + 1;
	cout << (ans == n ? -1 : ans) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(a+b,min(a+c,b+c))<<endl;
  return 0;
}



Measured memory_bytes: 256
from itertools import combinations
from bisect import bisect_left

N = int(input())
*L, = map(int, input().split())
L = sorted(L)
ans = 0
for i, j in combinations(range(N), 2): # i < j
    idx = bisect_left(L, L[i] + L[j])
    ans += idx - j - 1
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<math.h>
#include<string>
#include<iomanip>
using namespace std;


int main(void){
	int face_val[6];
	int face_num[6] = { 0, 1, 2, 3, 4, 5 };
	int tmp[6];
	int i, j;

	string direction;

	for (i = 0; i < 6; i++){
		cin >> face_val[i];
	}

	cin >> direction;


	for (i = 0; i < direction.length(); i++){
		for (j = 0; j < 6; j++){
			tmp[j] = face_num[j];
		}

		switch (direction[i]){

		case 'N':
			face_num[0] = tmp[1];
			face_num[1] = tmp[5];
			face_num[5] = tmp[4];
			face_num[4] = tmp[0];
			break;
		case 'E':
			face_num[0] = tmp[3];
			face_num[3] = tmp[5];
			face_num[5] = tmp[2];
			face_num[2] = tmp[0];
			break;
		case 'W':
			face_num[0] = tmp[2];
			face_num[2] = tmp[5];
			face_num[5] = tmp[3];
			face_num[3] = tmp[0];
			break;
		case 'S':
			face_num[0] = tmp[4];
			face_num[4] = tmp[5];
			face_num[5] = tmp[1];
			face_num[1] = tmp[0];
			break;
		default:
			break;



		}


	}


	cout << face_val[face_num[0]] << endl;

}


Measured memory_bytes: 3204
m, k = io.read("*n", "*n")
if m == 0 then
  print(k == 0 and "0 0" or -1)
elseif m == 1 then
  print(k == 0 and "0 1 1 0" or -1)
else
  local tot = (1 << m) - 1
  if tot < k then
    print(-1)
  else
    local ary = {}
    for i = 0, tot do
      if i ~= k then
        table.insert(ary, i)
      end
    end
    table.insert(ary, k)
    for i = tot, 0, -1 do
      if i ~= k then
        table.insert(ary, i)
      end
    end
    table.insert(ary, k)
    print(table.concat(ary, " "))
  end
end


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

int main() {
  int N;
  cin>>N;
  vector<pair<ll,ll>> pairs(N);
  for (int i(0);i<N;i++){
    ll a,b;
    cin>>a>>b;
    pairs[i] = make_pair(b,a);
  }
  sort(pairs.begin(), pairs.end());
  ll now(0);
  for (int i(0);i<N;i++){
    now+=pairs[i].second;
    if (now > pairs[i].first){
      cout << "No"<<endl;
      return 0;
    }
  }
  cout << "Yes"<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define matr vector<vector<int> > 
 
#define all(x) x.begin(), x.end()
 
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
int n; 
string s; 
                
void mult(int &a, int b) {
    a *= b; 
    a %= mod;
}

int cnt[3]; 
vector<int> ms;

void solve() { 
    cin >> n >> s;    
    n *= 3; 
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') ms.pb(0);
        if (s[i] == 'G') ms.pb(1); 
        if (s[i] == 'B') ms.pb(2); 
    }
    int ans = 1;
    int a = 0, b = 0, c = 0;
    int pairs = 0, free = 0; 
    for (int i = 0; i < n; ++i) {
        if (ms[i] == 0) {
            ++a; 
            if (a > 0 && b > 0 && c > 0) {
                --a, --b, --c; 
                mult(ans, pairs); 
                --pairs; 
                continue; 
            }
            if (a <= b || a <= c) {
                ++pairs; 
                mult(ans, free); 
                --free;             
            } else {
                ++free; 
            }
        } else if (ms[i] == 1) {
            ++b; 
            if (a > 0 && b > 0 && c > 0) {
                --a, --b, --c; 
                mult(ans, pairs); 
                --pairs; 
                continue; 
            }
            if (b <= a || b <= c) {
                ++pairs; 
                mult(ans, free); 
                --free;             
            } else {
                ++free; 
            }        
        } else {
            ++c; 
            if (a > 0 && b > 0 && c > 0) {
                --a, --b, --c; 
                mult(ans, pairs); 
                --pairs; 
                continue; 
            }
            if (c <= a || c <= b) {
                ++pairs; 
                mult(ans, free); 
                --free;             
            } else {
                ++free; 
            }            
        }
    }
    for (int i = 1; i <= n / 3; ++i) {
        mult(ans, i);         
    }
    cout << ans; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 6792
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    qu = []

    for s in S:
        if len(qu) > 0 and s == 'B':
            qu.pop()
        elif s != 'B':
            qu.append(s)
    print(''.join(qu))


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

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

    if (a < b) {
        if (a + w >= b) cout << 0 << endl;
        else cout << b - (a + w) << endl;
    } else {
        if (b + w >= a) cout << 0 << endl;
        else cout << a - (b + w) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/abc092_2nd/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int N;
vector<int> J;
ll acc[100100] = {0};
void solve() {
  cin >> N;
  J.push_back(0);
  int j;
  loop(n,0,N) {
    cin >> j;
    J.push_back(j);
  }
  J.push_back(0);
  N+=2;
  loop(n,1,N) {
    acc[n] = acc[n-1] + abs(J[n]-J[n-1]);
  }
  //     n
  // 0 3 5 -1 0
  loop(n,1,N-1) {
    cout << acc[n-1] + abs(J[n-1]-J[n+1]) + (acc[N-1]-acc[n+1]) << endl;
  }
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    string s, t; 
    cin >> s; 
    cin >> t; 
    string result = "";
    for (int i = 0; i < n; i++){
        result += s[i];
        result += t[i];
    }
    
    cout << result << "\n";
    


}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL x;

int main() {
	cin >> x;
	
	cout << static_cast<LL>(ceil(sqrt(1 + 8 * x))) / 2 << endl;
	
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if sum(a) == x:
    print(N)
else:
    c = 0
    for i in a:
        if i > x:
            break
        x -= i
        c += 1
    if c == N:
        print(c - 1)
    else:
        print(c)

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

int main(){
	int n,m;
  	cin>>n>>m;
  	int a = 0;
  	int ans = -1;
  	for(int i=0;i<m;i++){
    	int tmp;
      	cin>>tmp;
      	a += tmp;
    }
  	if(n<a)cout<<ans<<endl;
  	else cout<<(n-a)<<endl;
}

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

using namespace std;

string let = "RYGB";

int main() {
  int h, w, d;
  cin >> h >> w >> d;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int x = ((i + j) % (2 * d) + (2 * d)) % (2 * d) / d;
      int y = ((i - j) % (2 * d) + (2 * d)) % (2 * d) / d;
      putchar(let[2 * x + y]);
    }
    putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 512
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll n,k;
vector<ll> w;

bool judge(ll A){
    ll sum=0;
    ll count=1;
    for(int i=0;i<n;i++){
        if(w[i]>A){return false;}
        sum+=w[i];
        if(sum>A){sum=w[i]; count++;}
    }
    return count<=k;
}



int main(){
    cin>>n>>k;
    w.resize(n);
    for(int i=0;i<n;i++){cin>>w[i];}
    ll l=1,r=1e15;
    while(r-l>3){
        ll m=l+(r-l)/2;
        if(judge(m)){r=m;}
        else{l=m+1;}
    }
    for(ll i=l;i<=r;i++){
        if(judge(i)){cout<<i<<endl; return 0;}
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll t[1000000];
string s[10000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
bool f[14];
bool one(){
	ll minnum=7;
	ll maxnum=7;
	ll num=0;
	while(true){
		if(minnum==1)return true;
		if(maxnum==13)return false;
		if(num%2==0){
			if(f[minnum-1]){
				minnum--;
			}else if(f[maxnum+1]){
				maxnum++;
			}
		}else{
			if(!f[maxnum+1]){
				maxnum++;
			}else if(!f[minnum-1]){
				minnum--;
			}
		}
		num++;
	}
}
bool thirteen(){
	ll minnum=7;
	ll maxnum=7;
	ll num=1;
	while(true){
		if(minnum==1)return false;
		if(maxnum==13)return true;
		if(num%2==0){
			if(!f[minnum-1]){
				minnum--;
			}else if(!f[maxnum+1]){
				maxnum++;
			}
		}else{
			if(f[maxnum+1]){
				maxnum++;
			}else if(f[minnum-1]){
				minnum--;
			}
		}
		num++;
	}
}
int main() {
	cin>>N;
	rep(i,0,N){
		rep(j,0,14){
			f[j]=false;
		}
		rep(j,0,6){
			ll num;
			cin>>num;
			f[num]=true;
		}
		rep(j,1,14){
		}
		if(f[1] && f[13]){
			cout<<"no"<<endl;
		}else if(!f[1] && !f[13]){
			cout<<"yes"<<endl;
		}else{
			if(f[1]){
				if(one()){
					cout<<"yes"<<endl;
				}else{
					cout<<"no"<<endl;
				}
			}else{
				if(thirteen()){
					cout<<"yes"<<endl;
				}else{
					cout<<"no"<<endl;
				}
			}
		}
	}
	return 0;
}


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

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

  int s = (n/1000)%1000;
  int h = (n/100)%10;
  int t = (n/10)%10;
  int o = n%10;

  if ((s == h && h == t) || (h == t && t == o)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <math.h>
using namespace std;

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

typedef long long ll;


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

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

  int boss[n-1];
  vector<int> workers(n);
  rep(i, n-1) {
      cin >> boss[i];
      workers[boss[i]-1] += 1;
  }
  rep(i, n) {
    cout << workers[i] << endl;
  }
  return 0;
}

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

using namespace std;

string s[333];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	int o = 0, p = 1;
	for (int i = 0; i < n * 2 - 1; i++) {
		bool f = false;
		for (int j = 0; j <= n * 2; j += p) {
			for (int k = (i + o + j) % 2; k < n; k += 2) {
				if (s[(i + o + k + j) / 2 % n][((i - o - k - j) / 2 + n * 3) % n] != s[((i + o - k + j) / 2 + n) % n][((i - o + k - j) / 2 + n * 3) % n])
					goto pnz;
			}
			if (f) {
				p = j;
				break;
			}
			else {
				o = (o + j) % (n * 2);
				f = true;
			}
		pnz:;
		}
		if (!f) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << n * n / p << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void){
    int N,T,i,x=1001;
    int c[256],t[256];

    scanf("%d %d",&N,&T);

    for(i=0;i<N;i++){
        scanf("%d %d",&c[i],&t[i]);
    }

    for(i=0;i<N;i++){
        if(t[i]<=T){
            if(x>c[i]){
            x=c[i];
            }
        }
    }
  if(x==1001){
	printf("TLE");
  }else{
        printf("%d",x);
  }
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    int a, b, t;
    cin >> a >> b >> t;

    cout << (t / a) * b << endl;

    
    return 0;
}


Measured memory_bytes: 256
x,y,a,b,c = list(map(int, input().split()))

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p_rev = sorted(p, reverse=True)
q_rev = sorted(q, reverse=True)
pq_rev = sorted(p_rev[:x] + q_rev[:y] , reverse=True)

total = sum(sorted(pq_rev + r, reverse=True)[:x+y])
print(total)

Measured memory_bytes: 25008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int MOD = 1000000007; 

int main() {
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  for(ll i = K; i <= N + 1; i++) {
    ans += - i * i + (1 + N) * i + 1;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
	"math"
)

func main() {
	n := scInt()
	hlist := ints(n)
	dp := make([]int, n)
	dp[0] = 0
	dp[1] = abs(hlist[0] - hlist[1])

	for i := 1; i < n-1; i++ {
		diff1 := abs(hlist[i+1]-hlist[i]) + dp[i]
		diff2 := abs(hlist[i+1]-hlist[i-1]) + dp[i-1]
		dp[i+1] = min(diff1, diff2)
	}
	fmt.Println(dp[n-1])
}

func scStr() string {
	var s string
	fmt.Scan(&s)
	return s
}

func scInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func scInt2() (int, int) {
	var x, y int
	fmt.Scan(&x, &y)
	return x, y
}

func scInt3() (int, int, int) {
	var x, y, z int
	fmt.Scan(&x, &y, &z)
	return x, y, z
}

func ints(n int) (slice []int) {
	slice = make([]int, n)
	for i := range slice {
		fmt.Scan(&slice[i])
	}
	return slice
}

func sum(slice []int) (sum int) {
	sum = 0
	for i := range slice {
		sum += slice[i]
	}
	return
}

func unique(strs []string) (unique []string) {
	m := map[string]bool{}
	for _, v := range strs {
		if !m[v] {
			m[v] = true
			unique = append(unique, v)
		}
	}
	return unique
}

func min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func powi(x, pow int) int {
	return int(math.Pow(float64(x), float64(pow)))
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 6312
#include "bits/stdc++.h"

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    int N3 = 3 * N;
    vector<ll> A(N3);
    for(int i = 0; i < N3; i++) cin >> A[i];
    sort(all(A));
    ll sum = 0;
    for(int i = N; i < N3; i += 2) sum += A[i];
    cout << sum << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<vector<bool>> shops(n, vector<bool>(10));

    rep(i, n) {
        rep(j, 10) {
            char c;
            cin >> c;

            shops[i][j] = c == '1';
        }
    }

    vector<vector<ll>> benefit(n, vector<ll>(11));
    rep(i, n) rep(j, 11) cin >> benefit[i][j];
    ll ans = -INF;
    rep(i, 1 << 10) {
        if (i == 0) continue;
        vector<bool> open(10, false);
        rep(j, 10) open[j] = (i >> j) & 1;

        ll now = 0;
        rep(j, n) {
            int c = 0;
            rep(k, 10) if (open[k] && shops[j][k]) c++;
            now += benefit[j][c];
        }
        cmax(ans, now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace	std;

int main() {
  bool ok = false;
  int K, A, B; cin>>K>>A>>B;
  for(int i = A; i <= B; i++) {
    if(i % K ==	0) {
      ok = true; break;
    }
  }
  cout << (ok ?	"OK" : "NG") <<	endl;
  return 0;
}



Measured memory_bytes: 3092