akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

X = int(input())

n = X // 100
d = X % 100

cnt = 0
if 0 <= d <= 5:
    cnt = 1
elif 6 <= d <= 10:
    cnt = 2
elif 11 <= d <= 15:
    cnt = 3
elif 16 <= d <= 20:
    cnt = 4
elif 21 <= d <= 25:
    cnt = 5
elif 26 <= d <= 30:
    cnt = 6
elif 31 <= d <= 35:
    cnt = 7
elif 36 <= d <= 40:
    cnt = 8
elif 41 <= d <= 45:
    cnt = 9
elif 46 <= d <= 50:
    cnt = 10
elif 51 <= d <= 55:
    cnt = 11
elif 56 <= d <= 60:
    cnt = 12
elif 61 <= d <= 65:
    cnt = 13
elif 66 <= d <= 70:
    cnt = 14
elif 71 <= d <= 75:
    cnt = 15
elif 76 <= d <= 80:
    cnt = 16
elif 81 <= d <= 85:
    cnt = 17
elif 86 <= d <= 90:
    cnt = 18
elif 91 <= d <= 95:
    cnt = 19
elif 96 <= d <= 99:
    cnt = 20


if cnt > n:
    print(0)
else:
    print(1)


Measured memory_bytes: 3064
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
const ll BIGMOD = 1e9 + 7;
using namespace std;

int main() {
  int n;
  string str;
  scanf("%d", &n);
  cin >> str;
  ll sum = 0;
  ll r = 0, g = 0, b = 0;
  for (int i = 0; i < n; ++i) {
    if (str[i] == 'R')
      r += 1;
    else if (str[i] == 'G')
      g += 1;
    else
      b += 1;
  }

  for (int i = 0; i < n - 2; ++i) {
    for (int j = 1;; ++j) {
      int jj = i + j;
      int kk = i + 2 * (jj - i);
      if (i + j * 2 >= n) break;
      // cout << i << " " << jj << " " << kk << endl;
      if (str[i] != str[jj] && str[jj] != str[kk] && str[kk] != str[i]) {
        sum += 1;
      }
    }
  }
  sum = -1 * sum + r * g * b;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)

typedef pair<int,int> Node; // v,com
typedef pair<int,Node> P;  // dp[Node],Node
typedef P Edge;           // int,Node

struct pair_hash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);
        return h1^(h2<<15);
    }
};

priority_queue<P,vector<P>,greater<P>> qu;
unordered_map<Node,vector<Edge>,pair_hash> g;
unordered_map<Node,int,pair_hash> dp;

int N,M;

void dijkstra(Node start){
    qu.push({dp[start]=0,start});
    while(qu.size()){
        P pr=qu.top(); qu.pop();
        Node v = pr.second;
        if(v==make_pair(N-1,-1))return;
        if(dp[v] < pr.first)continue;

        for(Edge e:g[v]){
            Node to = e.second;
            int cost = e.first;
            if(dp.count(to)==0 || dp[to] > dp[v]+cost){
                dp[to] = dp[v]+cost;
                qu.push({dp[to],to});
            }
        }
    }
}


int main(void){
    cin>>N>>M;
    rep(i,M){
        int p,q,c;
        scanf("%d %d %d",&p,&q,&c);
        p--,q--;
        if(g.count({p,c})==0){
            g[{p,c}].push_back({0,{p,-1}});
            g[{p,-1}].push_back({1,{p,c}});
        }
        if(g.count({q,c})==0){
            g[{q,c}].push_back({0,{q,-1}});
            g[{q,-1}].push_back({1,{q,c}});
        }
        g[{p,c}].push_back({0,{q,c}});
        g[{q,c}].push_back({0,{p,c}});
    }
    dijkstra({0,-1});
    cout<<(dp.count({N-1,-1}) ? dp[{N-1,-1}] : -1)<<endl;
    return 0;
}


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


int main()
{
  while(true)
  {
    int h,w;
    cin>>h>>w;
    if(h==0 && w==0) break;
    for (int i = 0; i < h; ++i)
    {
      for (int i = 0; i < w; ++i)
      {
        cout<<"#";
      }
      cout<<endl;
    }
    cout<<endl;
  }  
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  if(s.at(0)!= s.at(1) && s.at(1)!=s.at(2) && s.at(2)!=s.at(3))
    cout << "Good" << endl;
  else
    cout << "Bad" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int H, W, N;
  while(cin >> H >> W >> N){
    int ans = H + W;

    FORE(i,0,H){
      FORE(j,0,W){
        int s = H * W - (H-i) * (W-j);
        if(s >= N) chmin(ans, i + j);
      }
    }


    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (int)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife
	
	int n;
	cin >> n;
	cout << ((n/1000+1)*1000-n)%1000;

	return 0;
}


Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int[] B = new int[N];
            for (int i = 0; i < N - 1; i++) {
                B[i] = Integer.parseInt(in.next());
            }
            long ans = 0;
            ans = B[0];
            for (int i = 1; i <= N - 2; i++) {
                ans += Math.min(B[i - 1], B[i]);
            }
            ans += B[N - 2];

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
typedef long long ll;
const int mod = 1e9 + 7;
inline void reduce(int & x) {
	x += x >> 31 & mod;
}
const int maxn = 21;
int n, m, k;
int f[maxn][1 << maxn];
int dp[1 << maxn];
std::vector<std::pair<int, int>> v[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> k;
	-- n;
	rep(i, 1, k) {
		int a, b, c;
		cin >> a >> b >> c;
		v[a].emplace_back(n - b, c);
	}
	dp[0] = 1;
	for(int i = 1;i <= m;++i) {
		memset(f, 0, sizeof f);
		for(int j = 0;j < 1 << n;++j) {
			f[n][j] = dp[j];
		}
		for(int j = n - 1;j >= 0;--j) {
			for(int k = 0;k < 1 << n;++k) {
				reduce(f[j][k] += f[j + 1][k] - mod);
				if((k >> j & 1) == 0) {
					int s0 = k & (1 << j) - 1;
					reduce(f[j][k ^ 1 << j ^ (s0 ? 1 << std::__lg(s0) : 0)] += f[j + 1][k] - mod);
				}
			}
		}
		for(int j = 0;j < 1 << n;++j) {
			dp[j] = f[0][j];
			for(std::pair<int, int> k : v[i]) {
				if((j >> k.first & 1) != k.second) {
					dp[j] = 0;
				}
			}
		}
	}
	int ans = 0;
	for(int j = 0;j < 1 << n;++j) {
		reduce(ans += dp[j] - mod);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 176384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll a, b, n; cin >> a >> b >> n;
	ll x = min(n, b-1);
	print(a*x/b-a*(x/b))
	
	return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  int n;
  cin >> n;
  vector<int>a(n),b(n);
  ll ans = 0;
  rep(i,n)cin >> a[i];
  rep(i,n)cin >> b[i];
  rep(i,n){
    if(a[i] < b[i])ans += (b[i] - a[i]) / 2;
    else ans -= a[i] - b[i];
  }
  if(ans >= 0)puts("Yes");
  else puts("No");
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
}

Measured memory_bytes: 384
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//long long A,B;
bool ok(long long key,long long index,vector<long long> &retu){
    if(retu.at(index) > key) return true;
    else if(retu.at(index) <= key) return false;
}
long long binary_search(long long key,long long size,vector<long long> &retu){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        bool hantei = ok(key,mid,retu);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

//leftは条件を満たさない最大の値、rightは条件を満たす最小の値になっている

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N,M,K;cin >> N >> M >> K;
    vector<long long> A(N),B(M);
    for(int i = 0;i<N;i++) cin >> A.at(i);
    for(int i = 0;i<M;i++) cin >> B.at(i);
    //半分全列挙
    long long now = 0;
    vector<long long> ruiA(N+1),ruiB(M+1);
    for(int i = 0;i<N;i++){
        ruiA.at(i+1) = ruiA.at(i)+A.at(i);
    }
    for(int i = 0;i<M;i++){
        ruiB.at(i+1) = ruiB.at(i)+B.at(i);
    }
    //Aの読み方を全列挙
    long long ans = 0;
    for(long long i = 0;i<N+1;i++){
        now = ruiA.at(i);
        long long remain = K-now;
        if(remain < 0) continue;
        long long index = binary_search(remain,M+1,ruiB);
        ans = max(ans,index+i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    cin >> n;
    vector<int> h(n+1);
    for(int i=1; i<=n; i++){
        cin >> h[i];
    }
    int dp[n+1];
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for(int i=3; i<=n; i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>

int bubbleSort(int A[], int N){
    int i, j, count=0;
    for(i=0; i<N; i++){
        for(j=N-1; j>=i+1; j--){
            if(A[j] < A[j-1]){
                std::swap(A[j], A[j-1]);
                count++;
            }  
        }
    }
    return count;
}
/*
int bubbleSort(int A[], int N){
    int i, j, count=0;
    bool flag = 1;
    for(i=0; flag; i++){
        flag = 0;
        for(j=N-1; j>=i+1; j--){
           if(A[j] < A[j-1]){
                std::swap(A[j], A[j-1]);
                count++;
                flag = 1;
           }
        }
    }
    return count;
}
*/
int main(){
    int i, N, A[100], count;
    scanf("%d", &N);
    for(i=0; i<N; i++) scanf("%d", &A[i]);

    count = bubbleSort(A, N);

    for(i=0; i<N; i++){
        if(i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  int count = 0;
  while(b>=a){
    if (c <= count) break;
    count++;
    b -= a;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
function main() {
  input.forEach(function(n) {
    if(n.trim() === '') return;
    n = parseFloat(n);
    console.log(s(n));
  });
}

function s(n) {
  var
  i, x = 10,
  a = [n];
  for(i = 2; i <= 10; i++) {
    if(i % 2 === 0) {
      a[a.length] = a[a.length - 1] * 2;
    }else{
      a[a.length] = a[a.length - 1] / 3;
    }
  }
  return a.reduce(function(a, b){
    return a + b;
  });
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

int s[100005];

int main() {
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++) {
    int x;
    scanf("%d",&x);
    s[x]++;
    s[x+1]++;
    s[x+2]++;
  }
  int ans = 0;
  for(int i=0;i<=100005;i++) {
    if(s[i]>ans) ans = s[i];
  }
  printf("%d\n",ans);

}


Measured memory_bytes: 640
import sys
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
a = [int(x) for x in input().split()]

dp=[]
for i in range(n):
	dp.append([0]*n)
for i in range(n):
    dp[i][i] = a[i]

for i in range(n - 2, -1, -1):
    for j in range(i + 1, n):
        dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])

print(dp[0][n - 1])

Measured memory_bytes: 111964
N = int(input())
A = list(map(int, input().split()))

A = [a - (i + 1) for i, a in enumerate(A)]
A.sort()

b1, b2 = A[N // 2], A[N // 2 - 1]
tmp1, tmp2 = 0, 0

for a in A:
  tmp1 += abs(a - b1)
  tmp2 += abs(a - b2)
  
print(min(tmp1, tmp2))

Measured memory_bytes: 25196
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <set>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <iomanip>
#include <utility>

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int n, m;
ll pref[100010], a[100010], ans;
map <int, int> pr;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("river.in", "r", stdin);
	//freopen("river.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		a[i] %= m;
		pref[i] = (pref[i - 1] + a[i]) % m;
	}
	for (int i = 1; i <= n; i++)
	{
		ans += (pref[i] == 0);
		ans += pr[pref[i]];
		pr[pref[i]]++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4736
#include<iostream>

int main() {
	int R, G, B, N;
	std::cin >> R >> G >> B >> N;
	int r = N / R, g = N / G, b = N / B;
	int count = 0;
	for (int i = 0; i <= r; i++) {
		for (int j = 0; j <= g; j++) {
			int a = N - i * R - j * G;
			if(a % B == 0 && a >= 0){
				count += 1;
			}
		}
		 
	}
	std::cout << count;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)

signed main(){
  int N, Q;
  cin >> N;
  int c[1000], ary[1000];
  for (int i = 0; i < 1000; i++) ary[i] = 0;
  for (int i = 0; i < N; i++) cin >> c[i];
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int t, x, d ;
    cin >> t >> x >> d;
    if (t == 1) {
      ary[x-1] += d;
    } else {
      ary[x-1] -= d;
    }
    if (ary[x-1] > c[x-1] || ary[x-1] < 0) {
      cout << x << endl;
      for (int j = 1; j < Q-i; j++) {
	int hoge,huga,hugo;
	cin>>hoge>>huga>>hugo;
      }
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}




Measured memory_bytes: 3124
#include <iostream>
using namespace std;
int euclidean_gcd(int a, int b) {
    if(a < b) return euclidean_gcd(b, a);
    int r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main(void){
    
    int i,j,n,k;
    long long ans;
    
    cin >> k;
    
    ans= 0; 
    
    for(i=1; i <= k; i++){
        
        for(j=1; j <= k; j++){
            
            for(n=1;n <= k; n++){
                
                if(i == j && j== n){
                    
                    //cout << i <<endl;
                    
                    ans = ans + i;
                }else{
                    //cout << euclidean_gcd(i,euclidean_gcd(j,n)) << endl;
                    ans = ans + euclidean_gcd(i,euclidean_gcd(j,n));
                }
                
            }
        
        }
        
    }
    
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;



int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    ll sum=0, min=INF;
    int i;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        sum +=tmp;
        if(tmp%10) min=MIN(min,tmp);
    }
    if(sum%10==0) {
        if(min==INF) printf("0\n");
        else printf("%lld\n", sum-min);
    }
    else {
        printf("%lld\n", sum);
    }


    return 0;
}




Measured memory_bytes: 128
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, K;
  cin >> N >> K;
  // const int64_t L = static_cast<int64_t>(T.length());
  int64_t t = N / K;
  int64_t result = t * t * t;
  if (K % 2 == 0) {
    t = (N + K / 2) / K;
    result += t * t * t;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main {
    public static void main(String args[])
    {
        Scanner s = new Scanner(System.in);
        int n=s.nextInt();
        int b=s.nextInt();
        int ans = n+b;
        int ans1 = n+n-1;
        int ans2 = b+b-1;
        System.out.println(Math.max(ans,Math.max(ans1,ans2)));
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n;
    cin >> n;
    if(n<10) cout << n << endl;
    else if(n<100) cout << 9 << endl;
    else if(n<1000) cout << n-90 << endl;
    else if(n<10000) cout << 909 << endl;
    else if(n<100000)cout << n-9090 << endl;
    else cout << 90909 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#define pie 3.1416
using namespace std;
int main()
{
    long long int t,n,a,b,x,y,m,i,j,k,l,cnt,flag,flag1;
    double r,ans;
    cin>>r;
    ans=2*pie*r;
    cout<<fixed<<setprecision(2)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3764
n = int(input())
a = list(map(int, input().split()))
sa = sum(a)

b = [1]
f = True
for i in range(n+1):
    sa -= a[i]
    d = min(sa, (b[i] - a[i]) * 2)
    if d < 0:
        f = False
        break
    b.append(d)

print(sum(b) if f else -1)


Measured memory_bytes: 20140
x = gets.to_i                                                                   

def count(x, times)
  [6, 5].each do |i|
    x -= i
    times += 1
    break if x <= 0
  end
  return times
end

times = 0
if x <= 11
  times = count(x, times)
else
  values = x.divmod(11)
  times = values[0] * 2
  times = count(values[1], times) if values[1] > 0
end
p times

Measured memory_bytes: 1788
N = int(input())
ans = [0]*N
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            kotae = x**2+y**2+z**2+x*y+y*z+z*x
            if kotae <= N:
                ans[kotae-1] += 1
for i in range(N):
    print(ans[i])

Measured memory_bytes: 9368
#include <stdio.h>

int main() {
  char s[11];
  scanf("%s", s);

  int idx = 0;
  for(int i = 0; s[i] != '\0'; i++) {
    if(s[i] == '0') s[idx++] = '0';
    else if(s[i] == '1') s[idx++] = '1';
    else if(s[i] == 'B' && idx > 0) idx--;
  }

  for(int i = 0; i < idx; i++) {
    printf("%c", s[i]);
  }
  return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int LIMIT = (int) 1e6;

void solve() {
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> cnt;
    fori (i, 0, n) {
        cin >> v[i];
        cnt[v[i]]++;
    }
    vector<bool> good(LIMIT + 1, true);
    for (auto &each : cnt) {
        int x = each.first;
        for (int i = 2 * x; i <= LIMIT; i += x) {
            good[i] = false;
        }
    }
    int ans = 0;
    fori (i, 0, n) {
        bool ok = cnt[v[i]] == 1 && good[v[i]];
        ans += ok;
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 13712
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	long long int num[51] = {};
	for (int i = 1; i <= 50; i++) {
		num[i] = 50 - i;
		num[i] += N / 50;
	}
	N %= 50;
	cout << "50\n";
	for (int i = 1; i <= N; i++)num[i]++;
	for (int i = 1; i <= 50; i++) {
		if (i > 1)cout << " ";
		cout << num[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=21;
int a[MAXN];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,i,ans=0,b;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
	{
		cin>>b;
		ans+=max(0,a[i]-b);
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
import sys

n, m = map(int, sys.stdin.readline().split())
*h, = map(int, sys.stdin.readline().split())

surround = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1; b -= 1
    surround[a].append(h[b])
    surround[b].append(h[a])

def main():
    cnt = 0
    for i in range(n):
        try:
            if h[i] > max(surround[i]):
                cnt += 1
        except:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
  main()

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

int main() {
  int N;
  int count = 0;
  int next = 1;
  cin >> N;
  vector<int> a(N);

  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    if (a.at(i) != next) {
      count++;
    } else {
      next++;
    }
  }
  
  if (next == 1) {
    cout << -1 << endl;
  } else {
    cout << count << endl;
  }

}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
  	s[i]+=n;
    if((s[i])>90) s[i]=s[i]-90+64;
  }
cout<<s;
}


Measured memory_bytes: 384
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
class node{
public:
	node* left;
	node* right;
	int num;//num==modなら葉
	node(void){num=mod;left=nullptr;right=nullptr;}
	void insert(int in){
		if(num==mod){num=in;left=new node();right=new node();}
		else if(in<num){left->insert(in);}
		else{right->insert(in);}
	}
	bool find(int in){
		if(num==mod){return false;}
		else if(num==in){return true;}
		else if(in<num){return left->find(in);}
		else{return right->find(in);}
	}
	void inprint(void){
		if(num==mod){return;}
		left->inprint();
		cout<<" "<<num;
		right->inprint();
	}
	void preprint(void){
		if(num==mod){return;}
		cout<<" "<<num;
		left->preprint();
		right->preprint();
	}
};
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin>>n;
	node ki;
	while(n--){
		string str;cin>>str;
		if(str=="insert"){
			int x;cin>>x;
			ki.insert(x);
		}else if(str=="find"){
			int x;cin>>x;
			cout<<(ki.find(x)?"yes":"no")<<endl;
		}else if(str=="print"){
			ki.inprint();cout<<endl;
			ki.preprint();cout<<endl;
		}
		
	}
	return 0;
}




Measured memory_bytes: 28156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	string s;
	cin>>n>>s;
	if(s.size()<=n){
		cout <<s;
	}
	else{
		for(ll i=0;i<n;i++){
			cout << s[i];
		}
		cout << "...";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3628
n, k = map(int, input().split())
MOD = 10**9+7

def prepare(n, MOD):
    facts = [1]*(n+1)
    for i in range(1, n+1):
        facts[i] = facts[i-1]*i%MOD
    invs = [1]*(n+1)
    _invs = [1]*(n+1)
    invs[n] = pow(facts[n], MOD-2, MOD)
    for i in range(0, n)[::-1]:
        invs[i] = invs[i+1] * (i+1) % MOD
    return facts, invs

ans = 0
facts, invs = prepare(n, MOD)

for i in range(1+min(n-1, k)):
    ans += facts[n]*invs[i]*invs[n-i]*facts[n-1]*invs[n-i-1]*invs[i]
    ans %= MOD

print(ans)


Measured memory_bytes: 20340
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

L, R, d= map(int,input().split())
ans = 0
s = d
while True:
    if(L <= s <= R):
        ans+=1
    s += d
    if(R<s):
        break


print(ans)


Measured memory_bytes: 68660
#include<stdio.h>

int binarySearch(int A[],int n,int key){
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid])return 1;
    if(key>A[mid])left=mid+1;
    if(key<A[mid])right=mid;
    }
  return 0;
}



int main(){
  int n,S[100000],q,T,i,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T);
    if(binarySearch(S,n,T)==1)sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2128
h,w,n=map(int,input().split());I=[list(map(int,input().split()))for i in[0]*n]
from itertools import product as p;from collections import Counter as c;ans=[0]*9;o=(h-2)*(w-2)
for k,v in c(c([(a-x)*w+b-y for x,y in p(range(3),repeat=2) for a,b in I if h-1>a-x>0<b-y<w-1]).values()).items():ans[k-1]=v;o-=v
print(o,*ans,sep='\n')

Measured memory_bytes: 125828
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll x, y, z, k;
ll a[1000], b[1000], c[1000];
ll f(ll xx, ll yy, ll zz){
    return xx*y*z+yy*z+zz;
}
int main(void){
    cin>>x>>y>>z>>k;
    for(int i=0;i<x;i++){
        cin>>a[i];
    }
    for(int i=0;i<y;i++){
        cin>>b[i];
    }
    for(int i=0;i<z;i++){
        cin>>c[i];
    }
    sort(a, a+x, greater<ll>());
    sort(b, b+y, greater<ll>());
    sort(c, c+z, greater<ll>());
    priority_queue<P> q;
    set<ll> s;
    vector<ll> v;
    q.push(P(a[0]+b[0]+c[0], 0));
    s.insert(0);
    v.push_back(a[0]+b[0]+c[0]);
    for(int i=0;i<k;i++){
        P p=q.top();
        q.pop();
        ll xx=p.second/(y*z);
        ll yy=(p.second%(y*z))/z;
        ll zz=p.second%z;
        if(xx+1<x){
            if(s.find(f(xx+1, yy, zz))==s.end()){
                q.push(P(a[xx+1]+b[yy]+c[zz], f(xx+1, yy, zz)));
                s.insert(f(xx+1, yy, zz));
                v.push_back(a[xx+1]+b[yy]+c[zz]);
            }
        }
        if(yy+1<y){
            if(s.find(f(xx, yy+1, zz))==s.end()){
                q.push(P(a[xx]+b[yy+1]+c[zz], f(xx, yy+1, zz)));
                s.insert(f(xx, yy+1, zz));
                v.push_back(a[xx]+b[yy+1]+c[zz]);
            }
        }
        if(zz+1<z){
            if(s.find(f(xx, yy, zz+1))==s.end()){
                q.push(P(a[xx]+b[yy]+c[zz+1], f(xx, yy, zz+1)));
                s.insert(f(xx, yy, zz+1));
                v.push_back(a[xx]+b[yy]+c[zz+1]);
            }
        }
    }
    sort(v.begin(), v.end(), greater<ll>());
    for(int i=0;i<k;i++){
        cout<<v[i]<<endl;
    }
}


Measured memory_bytes: 768
from collections import deque
n = int(input())
nums = []
ans = deque()
for i in range(n):
    nums.append(int(input()))
if n == 2:
    print(abs(nums[0]-nums[1]))
elif n == 3:
    nums.sort
    print(max(abs(nums[0]-nums[1])+abs(nums[1]-nums[2]),abs(nums[0]-nums[2])+abs(nums[0]-nums[1]),abs(nums[2]-nums[1])+abs(nums[2]-nums[0])))
else:
    nums.sort()
    nums = deque(nums)
    a = nums.popleft()
    ans.append(a)
    b = nums.pop()
    ans.append(b)
    c = nums.popleft()
    ans.append(c)
    anser = abs(a-b) + abs(b-c)
    while len(nums) != 0:
        imin = nums[0]
        imax = nums[-1]
        amin = ans[0]
        amax = ans[-1]
        do = (abs(imin-amin),abs(imin-amax),abs(imax-amin),abs(imax-amax))
        domax = max(do)
        doindex = do.index(domax)
        if doindex == 0:
            nums.popleft()
            ans.appendleft(imin)
        elif doindex == 1:
            nums.popleft()
            ans.append(imin)
        elif doindex == 2:
            nums.pop()
            ans.appendleft(imax)
        else:
            nums.pop()
            ans.append(imax) 
        anser += domax
    print(anser)


Measured memory_bytes: 8072
s = input()
S = s.count("S")
E = s.count("E")
N = s.count("N")
W = s.count("W")
if (N==0 and S != 0) or (S==0 and N != 0):
    print("No")
elif (E==0 and W != 0) or (W==0 and E != 0):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 38384
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(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))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

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

    vector<int> d(n);
    REP(i, n)
        cin >> d[i];
    sort(d.begin(), d.end());
    int x1 = d[n/2-1], x2 = d[n/2];

    cout << x2 - x1 << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N, M; {int[] a = in.ii(); N = a[0]; M = a[1];}
        MyGraph graph = new MyGraph(N, M);
        int[] parent = graph.bfs(1);
        StringBuilder ans = new StringBuilder("Yes\n");
        for (int i = 2; i < parent.length; i++) {
            if (parent[i] == 0) {
                out.println("No");
                return;
            }
            ans.append(parent[i]).append('\n');   
        }
        out.print(ans);
    }

    static class MyGraph{
        int V; // 頂点数
        int E; // 辺数
        ArrayList<Integer>[] T; // 連結関数
        final static int INF = Integer.MAX_VALUE;

        MyGraph(int V, int E){
            this.V = V;
            this.E = E;
            T = new ArrayList[V+1];
            for(int i = 1; i <= V; i++){
                T[i] = new ArrayList<>();
            }
            for(int i = 0; i < E; i++){
                int u, v; {int[] a = in.ii(); u = a[0]; v = a[1];}
                T[u].add(v);
                T[v].add(u);
            }
        }

        int[] bfs(int s){
            int[] parent = new int[V+1];
            LinkedList<Integer> A = new LinkedList<>();
            HashSet<Integer> B = new HashSet<>();
            A.add(s);
            while(!A.isEmpty()){
                int v = A.pollFirst();
                for(int u : T[v]){
                    if(!B.contains(u)){
                        A.addLast(u);    
                        B.add(u);
                        parent[u] = v;
                    }
                }
            }
            return parent;
        }
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 71000
import sys
#区間をN-1個決め、その両端をゴールとして一番遠い点を原点まで選んで距離を求め、最後に最大を出す
def 解():
    L,N=[int(_) for _ in input().split()]
    aX=[int(_) for _ in sys.stdin.readlines()]
    iMax = max(aX[0],L-aX[0],aX[-1],L-aX[-1])
    #accX = [0]*(N+1)
    accX={}
    accX[-1]=0
    accX[0]=aX[0]
    for i in range(1,N):
        accX[i]=accX[i-1]+aX[i]
    dMemo = {}
    def getAccX(iS,iE):
        if (iS,iE) in dMemo:
            return dMemo[(iS,iE)]
        else:
            r = accX[iE]-accX[iS]
            dMemo[(iS,iE)] = r
            return r
    if 1 < N:
        for i in range(N-1):
            lN = min(i,N-i-1)
            rN = min(i+1,N-i-1)
            #R1 = aX[i]+ 2*sum(aX[i-lN:i]) + 2*(rN*L-(sum(aX[i+1:i+rN+1])))
            #R1 = aX[i]+ 2*(accX[i-1]-accX[i-lN-1]) + 2*(rN*L-(accX[i+rN]-accX[i]))
            R1 = aX[i]+ 2*(getAccX(i-lN-1,i-1)) + 2*(rN*L-(getAccX(i,i+rN)))
            i += 1
            lN = min(i,N-i)
            rN = min(i,N-i-1)
            #R2 = (L- aX[i])+ 2*sum(aX[i-lN:i]) + 2*(rN*L-(sum(aX[i+1:i+rN+1])))
            #R2 = (L- aX[i])+ 2*(accX[i-1]-accX[i-lN-1]) + 2*(rN*L-(accX[i+rN]-accX[i]))
            R2 = (L- aX[i])+ 2*(getAccX(i-lN-1,i-1)) + 2*(rN*L-getAccX(i,i+rN))

            iMax = max(R1,R2,iMax)
    print(iMax)
解()


Measured memory_bytes: 154252
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll h, w;
  cin >> h >> w;
  
  string s;

  for (int i = 0; i < w + 2; i++){
    cout << "#";
  }
  cout << endl;

  for (int i = 0; i < h; i++){
    cin >> s;
    cout << "#" + s + "#" << endl;
  }

  for (int i = 0; i < w + 2; i++){
    cout << "#";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb(x) push_back(x)

ll power(int x, unsigned int y){
    ll res = 1;
    while(y > 0){
        if(y & 1) res = res * x;
        y >>= 1;
        x *= x;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;

    if(n % 10 == 3){
        cout << "bon";
    }else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
        cout << "pon";
    }else cout << "hon";
}

int main(){

    // #ifndef ONLINE_JUDGE
    // freopen("/ATOMCODES/input.txt", "r", stdin);
    // freopen("/ATOMCODES/output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)


// 素集合データ構造
struct UnionFind
{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }

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

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sizes[find(x)];
  }
};


const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  long long n;cin>>n;
  long long ans=0;
  for(int i=1;i<n;i++){
    if(3*i>n){
      break;
    }
    ans+=COM(n-3*i+i-1, i-1);
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 15172
n,k = list(map(int, input().split()))
h = []
for i in range(n):
  h.append(int(input()))
h = sorted(h)
m = []
for i in range(n):
  if i+k-1 < n:
    m.append(abs(h[i+k-1]-h[i]))
  else:
    break
print(min(m))

Measured memory_bytes: 10844
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define SZ(x) ((int)(x).size())
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 19, maxS = 513, mod = 998244353;
const long long INF = 1000000000000000000ll;

bool is(char* t, int n)
{
	FOR(i, 0, n)
		if (t[i] != t[n-1-i])
			return false;
	return true;
}

char T[maxN];

void solve()
{
	scanf ("%s", T);
	int n = strlen(T);
	printf("%s\n", is(T, n) and is(T, n/2) and is(T+n/2+1, n/2) ? "Yes" : "No");
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


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


int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	string a;
	cin >> a;
	if(a.find("7")!=string::npos){
		cout <<"Yes"<<endl;
	}else{
		cout <<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int diff = 1000;
	for (int i = 0; i < s.length() - 2; i++) {
		int num = (int)(s[i] - '0')*100 + (int)(s[i+1] - '0') * 10 + (int)(s[i+2] - '0');
		diff = min(diff, abs(753 - num));
	}
	cout << diff << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <ctype.h>
using namespace std;
int main(void){
int N,A,B;
cin>>N>>A>>B;
int ans=0;
for(int i=1;i<=N;i++){
    int a,b,c,d,e;
    a=i/10000;
    b=(i-a*10000)/1000;
    c=(i-a*10000-b*1000)/100;
    d=(i-a*10000-b*1000-c*100)/10;
    e=i%10;
    int sum=a+b+c+d+e;
    if(A<=sum&&sum<=B) ans=ans+i;
}
cout<<ans;
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
	int x,y,t,n=0,i;
	for(;;){
		scanf("%d %d",&x,&y);
		if((x==0&&y==0)||n>3000) break;
		else if(x>=0&&x<=10000&&y>=0&&y<=10000){
			if(x<y) printf("%d %d\n",x,y);
			else printf("%d %d\n",y,x);
		}
	}
	return 0;
}


Measured memory_bytes: 1928
#include <stdio.h>

int gcd(int,int);

int main()
{
  int x,y;

  scanf("%d %d",&x,&y);
  printf("%d\n",gcd(x,y));

  return 0;
}

int gcd(int x,int y)
{
  int t,r;
  if(x<y){
    
    t = x;
    x = y;
    y = t;
  }
  while(y>0){
    r = x % y;
    x = y;
    y = r;
  
  }
  

    return x;
}
    

  



Measured memory_bytes: 2080
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int MAXN = 123456;
int dp[MAXN], h[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        scanf("%d", &h[i]);
        dp[i] = (int)1e9;
    }
    dp[1] = 0;
    for (int i = 1; i <= N; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    printf("%d\n", dp[N]);
    return 0;
}


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


int main()
{
  int n;
  std::cin >> n;
  std::vector<int> ps;
  for(int i=0; i<n; i++)
  {
    int p;
    std::cin >> p;
    ps.push_back(p);
  }

  int count = 0;
  for(int i=1; i<ps.size()-1; i++)
  {
    if(
      (ps[i] < ps[i-1] && ps[i+1] < ps[i] ) ||
      (ps[i-1] < ps[i] && ps[i] < ps[i+1] ) )
    {
      count++;
    }
  }

  std::cout << count;
}


Measured memory_bytes: 256