akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

H, W = list(map(int, input().split()))
a_table = []

for _ in range(H):
    a_list = list(input())
    a_table.append(a_list)

if a_table[0][0] != "#" or a_table[H - 1][W - 1] != "#":
    is_ok = False
else:
    # 連結箇所のチェック
    section_list = []
    is_ok = True
    for j in range(H):
        exist_section = False
        end_section = False
        start_idx = None
        end_idx = None
        for i in range(W):
            if a_table[j][i] == "#":
                if end_section:
                    # 連結箇所が複数あるのでアウト
                    is_ok = False
                    break
                elif exist_section:
                    # 連続した'#'
                    continue
                else:
                    # 最初の'#'
                    exist_section = True
                    start_idx = i
            else:
                if exist_section and (not end_section):
                    end_section = True
                    end_idx = i - 1
                    section_list.append((start_idx, end_idx))
                else:
                    # 連結部分終了後の'.' または 連結部分開始前の'.'
                    continue

        if exist_section and (not end_section):
            end_idx = W - 1
            section_list.append((start_idx, end_idx))
        elif not exist_section:
            is_ok = False

        if is_ok:
            if j != 0:
                if section_list[-2][1] != section_list[-1][0]:
                    is_ok = False

        if not is_ok:
            break

ans = "Possible" if is_ok else "Impossible"
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int n;
int *an;
int **xs;
int **ys; //1:Honest 0:Unkind -1:Unknown

int verify(int *honests) { 
  //if not truth, return 0. otherwise, return num.
  int i,j;
  
  //printf("veriry ");
  //for(i = 0; i < n; i++) printf("No.%d:%d, ", i, honests[i]);
  //putchar('\n');

  for(i = 0; i < n; i++) {
    if(honests[i] == 0) continue;
    for(j = 0; j < an[i]; j++) {
      //printf("i=%d, j=%d, honests=%d, xs=%d, ys=%d\n",i,j, honests[ xs[i][j]-1 ], xs[i][j]-1, ys[i][j]);
      if(honests[ xs[i][j]-1 ] != ys[i][j]) {
      //  printf("contradiction!\n\n");
        return 0;
      }
    }
  }
  
  int res = 0;
  for(i = 0; i < n; i++) res += honests[i];  
  
  return res;
}

int maxIf_IsHonestOrUnkind(int indexA, int *honests, int honestOrUnkind) {
  int i, num1, num2, res;

  //for(i = 0; i < indexA; i++) printf("  ");
  //printf("maxIf:%d\n", honestOrUnkind);

  int *_honests = malloc(sizeof(int) * n);
  for(i = 0; i < indexA; i++) _honests[i] = honests[i];
  _honests[indexA] = honestOrUnkind;

  if(indexA+1 == n) res = verify(_honests);
  else {
    num1 = maxIf_IsHonestOrUnkind(indexA+1, _honests, 1); //Honest
    num2 = maxIf_IsHonestOrUnkind(indexA+1, _honests, 0); //Unkind
    res = num1>num2 ? num1 : num2;
  }
  
  free(_honests);
  
  return res;
}



int main() {
   
  scanf("%d", &n);
  an = malloc(sizeof(int) * n);
  xs = malloc(sizeof(int*) * n);
  ys = malloc(sizeof(int*) * n);;
  int i,j;
  for(i = 0; i < n; i++) {
    scanf("%d", &an[i]);
    xs[i] = malloc(sizeof(int) * an[i]);
    ys[i] = malloc(sizeof(int) * an[i]);    
    for(j = 0; j < an[i]; j++) scanf("%d %d", &xs[i][j], &ys[i][j]);    
  }
  //printf("n=%d\n", n);
  //for(i = 0; i < n; i++) {
  //  printf("a[%d]=%d\n", i, an[i]);
  //  for(j = 0; j < an[i]; j++) printf("xs[%d][%d]=%d, ys[%d][%d]=%d\n", i,j, xs[i][j], i, j, ys[i][j]);
  //}
  //putchar('\n');
  
  int *honests = malloc(sizeof(int) * n);  
  for(i = 0; i < n; i++) honests[i] = -1;
  int num1, num2;
  num1 = maxIf_IsHonestOrUnkind(0, honests, 1);
  num2 = maxIf_IsHonestOrUnkind(0, honests, 0);
  free(honests);

  
  printf("%d", num1>num2 ? num1 : num2);  
  
  for(i = 0; i < n; i++) {free(xs[i]); free(ys[i]);}
  free(xs); free(ys);
  free(an);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

ll N, K;
static vector<ll> A, F;

bool can_clear(ll maxim){
    ll count=0;
    rep(i, N){
        ll d=(F[i]*A[i])-maxim-1;
        ll nec;
        if(d<0) nec=0;
        else nec=d/F[i]+1;
        count+=nec;
    }
    if(count>K) return false;
    else return true;
}

int main(void){
    cin>>N>>K;
    ll A_in, F_in;
    rep(i, N){
        cin>>A_in;
        A.push_back(A_in);
    }
    rep(i, N){
        cin>>F_in;
        F.push_back(F_in);
    }
    sort(all(A));
    sort(all(F), greater<ll>());
    ll left=0, right=1000000000001;
    ll ans;
    while(true){
        //cout<<left<<" " <<right<<endl;
        if(left+1==right){
          if(can_clear(left)) ans=left;
          else  ans=right;
          break;
        }
        ll nibutan=(left+right)/2;
        bool can_do_it=can_clear(nibutan);
        if(can_do_it) right = nibutan;
        else left = nibutan;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    std::string S, T;
    cin >> S >> T;

    const ll N = S.size();

    std::multimap<char, char> ms;
    std::multimap<char, char> mt;

    decltype(ms)::iterator it;
    for (ll i = 0; i < N; ++i) {
        it = ms.find(S[i]);
        if (it == ms.cend()) {
            ms.emplace(S[i], T[i]);
        } else {
            if (it->second != T[i]) {
                cout << "No" << endl;
                return 0;
            }
        }

        it = mt.find(T[i]);
        if (it == mt.cend()) {
            mt.emplace(T[i], S[i]);
        } else {
            if (it->second != S[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n, d; cin >> n >> d;
    vector<ll> x(n), y(n);
    ll cnt = 0;
    for(ll i=0; i<n; ++i){
        cin >> x[i] >> y[i];
        if(x[i]*x[i]+y[i]*y[i]<=d*d){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//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; }

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  // c[0]: z[i], c[1]: y[i], c[2]: x[i]
  vi c(3);

  ll sum = 1;
  rep(i,n) {
    ll cnt = 0, id = -1;
    if (a[i] == c[0]) { cnt++; id = 0; }
    if (a[i] == c[1]) { cnt++; id = 1; }
    if (a[i] == c[2]) { cnt++; id = 2; }
    if (id == -1) {
      cout << 0 << endl;
      return 0;
    }
    sum *= cnt; c[id]++;
    sum %= mod;
    //printf("i: %d, id: %d, cnt: %d, c[0]: %d, c[1]: %d, c[2]: %d\n", i, id, cnt, c[0], c[1], c[2]);
  }
  cout << sum << endl;  
  return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll gcd(ll a, ll b) {
	if (b == 0) 
		return a;
	else 
		return gcd(b, a % b);
}
bool solveSmart(ll A, ll B, ll C, ll D) {
	ll d = D % B;

	ll hi = 0;

	
	if (D < B) {
		hi = C + 1; // NO
	} else if (B > A) {
		hi = C + 1; // NO
	} else if (d == 0) { // now actual cases
		hi = A % B;
	} else {
		d = gcd(B, d);
		hi = B + (A % d - d);
	}

	if (hi <= C) {
		return true;
	} else {
		return false;
	}
}

bool solveDumb(ll A, ll B, ll C, ll D) {
	for (int i = 0; i < 1000; ++i) {
		A -= B;
		if (A < 0) return false;
		if (A <= C) A += D;
	}
	return true;
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T; cin >> T;
	F0R(i, T) {
		ll A, B, C, D; cin >> A >> B >> C >> D;
		print(solveSmart(A, B, C, D) ? "Yes" : "No");
	}
}

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

#define INF (1e9)

using namespace std;

int main() {
    char S[100000] = {0};
    int cnt0 = 0;
    int cnt1 = 0;

    cin >> S;

    for (int i = 0; S[i] != 0; i++) {
        if(i % 2 == 0){
            if(S[i] == '0') cnt0++;
            if(S[i] == '1') cnt1++;
        }else{
            if(S[i] == '0') cnt1++;
            if(S[i] == '1') cnt0++;
        }
    }

    printf("%d\n", min(cnt0, cnt1));
}


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

template <typename T>
int maximum(vector<T> A){
    int m = -1;
    for (T a : A) if (a > m) m = a;
    return m;
}

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    vector<int> D = {A,B,C};
    int max_value = maximum(D);
    cout << (A + B + C + 9 * max_value) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 4;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    if (x >= 0){
        ll num = x / d;
        if (k <= num){
            cout << x - (d * k) << endl;
            return 0;
        } 
        k -= num;
        x -= d * num;
        if (k % 2 == 0) cout << abs(x) << endl;
        else cout << abs(x-d) << endl;
        return 0;
    }else{
        ll num = abs(x / d);
        if (k <= num){
            cout << abs(x + (d * k)) << endl;
            return 0;
        }
        k -= num;
        x += d * num;
        if (k % 2 == 0) cout << abs(x) << endl;
        else cout << abs(x + d) << endl;
        return 0;
    }
}

Measured memory_bytes: 3628
s = raw_input()

for i in range(8):
	r = s[0]
	for j in range(3):
		if i >> j & 1:
			r += '+'
		else:
			r += '-'
		r += s[j + 1]
	if eval(r) == 7:
		print r + '=7'
		exit()


Measured memory_bytes: 2568
n =int(input())
a =list(map(int, input().split()))

a_min = min(a)


for i in range(100):
    z = i + a_min
    hp = 0
    for x in a:
        hp += (x - z) ** 2
    if i == 0:
        ans = hp
    if ans > hp:
        ans = hp

print(ans)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

#define all(v) 			((v).begin()), ((v).end())
#define sz(v) 			((int)((v).size()))
#define endl			"\n"
#define MOD             1000000007

typedef long long ll;

void File()
{
	//freopen("output.txt", "w", stdout);
	freopen("coffee.in", "r", stdin);
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
}
const double pi = 2 * acos(0.0);
const int nn = 1e5 + 5;
const int oo = 0x3f3f3f3f;

int main()
{
	fast();
	int n, k;
	cin >> n >> k;
	int arr[nn];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	sort(arr, arr + n);
	int mn = oo;
	for (int i = 0; i <= n - k; i++)
	{
		mn = min(mn, arr[i + (k - 1)] - arr[i]);
	}
	cout << mn << endl;
#if _DEBUG
	system("pause");
#endif
	return 0;
}

Measured memory_bytes: 640
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
res = 0
for i in range(n//2):
    if s[i] != s[n-i-1]:
        res += 1
print(res)

Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    int s[n];
    int score = 0;
    priority_queue<int, vector<int>, greater<int>> pq;
    rep(i, n) {
        cin >> s[i];
        score += s[i];
        if (s[i] % 10 != 0) pq.push(s[i]);
    }
    if (score % 10 == 0) {
        if (pq.empty()) {
            score = 0;
        } else {
            score -= pq.top();
            pq.pop();
        }
    }
    cout << score << endl;
}

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

namespace ITP1_8_C
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<char, int> dic = new Dictionary<char, int>();

            for (var i = 97; i < 123; i++) dic.Add((char)i, 0);

            string input = Console.In.ReadToEnd();

            foreach(var c in input.Select(c => char.ToLower(c)))
                if (dic.ContainsKey(c)) dic[c]++;

            foreach (var alphabet in dic) Console.WriteLine(alphabet.Key + " : " + alphabet.Value);
        }
    }
}

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

int main()
{
    int n;
    while(cin>>n){
        int count=0;
        for(int a=0; a<=9; a++)
            for(int b=0; b<=9; b++)
                for(int c=0; c<=9; c++)
                    for(int d=0; d<=9; d++)
                        if(a+b+c+d == n) count++;
                   
        cout << count << endl;
    }
                 
    return 0;
}

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

int N, K;
int a[200100];
vector<int> vals;
map<int, int> idx;
int bit[200100];
 
int acc(int i) {
    int s = 0;
    while (i>0) {
        s += bit[i];
        i -= i&(-i);
    }
    return s;
}
 
void add(int i, int x) {
    i++;
    while (i<=N+10) {
        bit[i] += x;
        i += i&(-i);
    }
}

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> K;
    rep(i, N) cin >> a[i];
    int s = 0;
    vals.pb(0);
    rep(i, N) {
        s += a[i];
        vals.pb(s-K*(i+1));
    }
    sort(vals.begin(), vals.end());
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    rep(i, vals.size()) idx[vals[i]] = i;
    
    int ans = 0;
    s = 0;
    add(idx[0], 1);
    rep(i, N) {
        s += a[i];
        ans += acc(idx[s-K*(i+1)]+1);
        //cout << s-K*i << endl;
        //cout << acc(idx[s-K*(i+1)]+1) << endl;
        add(idx[s-K*(i+1)], 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 17904
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
double dp[30001][2001];
double prob(double p[],ll n,ll heads)
{
    if(heads==0)
    {
        return 1;
    }
    if(n==0)
    {
        return 0;
    }
    if(dp[n][heads]>(-0.9))
        return dp[n][heads];
    dp[n][heads]=p[n]*prob(p,n-1,heads-1)+(1-p[n])*prob(p,n-1,heads);
    return dp[n][heads];
}
int main()
{
    ll n;
    cin>>n;
    double p[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(ll i=0;i<=3000;i++)
    {
        for(ll j=0;j<=2000;j++)
        {
            dp[i][j]=-1;
        }
    }
    double d=prob(p,n,(n+1)/2);
    cout<<fixed<<setprecision(10)<<d<<endl;
    return 0;
}


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

int main() {
    string S;
    cin >> S;

    string T;

    if (S == "Sunny") {
        T = "Cloudy"s;
    }
    else if (S == "Cloudy") {
        T = "Rainy"s;
    }
    else {
        T = "Sunny"s;
    }

    cout << T << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, n) for(long long (i) = (a); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define GET(v) cin >> (v)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main()
{
    string s;
    cin >> s;
   
    ll black = 0;
    vector<ll> bdx;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'B') {
            black++;
            bdx.PB(i);
        }
    }
    
    ll cnt = 0;
    while(s[s.size() - 1 - cnt] == 'B') {
        cnt++;
    }
    
    ll ans = 0;
    for(int i = bdx.size() - cnt - 1; i >= 0; i--) {
        ans += s.size() - cnt - bdx[i] - 1;
        cnt++;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 2680
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=1e9+7;
//
int main(){
	int n;
	int a[100000];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int l=1,r=n-1;
	int hoge=a[l]+a[r]-a[0];
	while(l+1!=r){
		l++;
		r--;
		hoge=a[l]+a[r]-hoge;
	}
	int b[100000];
	b[r]=hoge;
	for(int i=r-1;i>=0;i--){
		b[i]=a[i]-b[i+1]/2;
		b[i]*=2;
	}
	for(int i=r+1;i<n;i++){
		b[i]=a[i-1]-b[i-1]/2;
		b[i]*=2;
	}
	for(int i=0;i<n;i++){
		cout<<b[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int a, b, k;
    vector<int> v;

    cin >> a >> b >> k;

    for (int i = 1; i < 200; i++) {
        if (a%i == 0 && b%i == 0) {
            v.push_back(i);
        }
    }

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    cout << v[k-1] << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int x;

	cin>>x;

	cout<<YN(x==3||x==5||x==7)<<endl;
}


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

#define int long long
#define INF 9223372036854775807
#define M_PI 3.14159265358979323846
#define double long double

int mod = INF;

int fastPow(int b, int e){int r = 1;while(e){if(e%2 == 1){r*=b;r%=mod;}b*=b;b%=mod;e/=2;}return r;}
int pgcd(int a, int b){ if(a%b == 0) return b; else return pgcd(b, a%b);}
int sign(int a){if(a < 0){ return -1;}if(a == 0) {return 0;}if(a > 0) {return 1;}}
bool isPrime(int a){if(a == 1) {return false;}int f = sqrt(a);for(int i = 2; i<=f; i++){if(a%i == 0){return false;}}return true;}
int toInt(string s){int tot = 0;for(int i = s.size()-1; i >= 0; i--){tot+=((s[i]-'0')%mod)*fastPow(10,i);tot%=mod;}return tot;}
string toString(int a){string s = "";while(a){s = (char)('0'+a%10) + s;a/=10;}return s;}

int n;
vector<int> v;

vector<int> memo(100009);

int dp(int index){
    if(index == n-1) return 0;
    if(memo[index] != -1) return memo[index];
    if(index+2 == n){
        return memo[index] = dp(index+1)+abs(v[index+1]-v[index]);
    }else{
        return memo[index] = min(dp(index+1)+abs(v[index+1]-v[index]), dp(index+2)+abs(v[index+2]-v[index]));
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    v.resize(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    fill(memo.begin(), memo.end(), -1);
    cout << dp(0) << endl;
}


Measured memory_bytes: 4224
#!/usr/bin/env python3.8.3
# -*- coding: utf-8 -*-


def main():
    X = int(input())
    if X < 600:
        ans = 8
    elif X < 800:
        ans = 7
    elif X < 1000:
        ans = 6
    elif X < 1200:
        ans = 5
    elif X < 1400:
        ans = 4
    elif X < 1600:
        ans = 3
    elif X < 1800:
        ans = 2
    else:
        ans = 1

    print(ans)


if __name__ == "__main__":
    main()


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

typedef struct timesurpiror
{
	int starttime;
	int deadtime;
};

int main()
{



	
	
	int n;
	cin>>n;
	int *a=new int[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int a1count=0,a2count=0,a4count=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]%4==0)
			a4count++;
		else if(a[i]%2==0)
			a2count++;
		else
			a1count++;
	}
	if(a1count<=a4count+1&&a2count==0)
		cout<<"Yes";
	else if(a4count>=a1count&&a2count>0)
		cout<<"Yes";
	else
		cout<<"No";
 	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////
struct edge{ll from,to,cost;};


int main(){
    ll n,m;cin>>n>>m;
    edge e[m];
    rep(i,0,m-1)cin>>e[i].from>>e[i].to>>e[i].cost;
    ll dp[n+1];
    rep(i,1,n)dp[i]=-inf;
    dp[1]=0;
    bool update;
    bool n_update;
    ll c=0;
    while(true){
        update=false;
        n_update=false;
        c++;
        rep(i,0,m-1){
            if(dp[e[i].from]!=-inf && dp[e[i].to]<dp[e[i].from]+e[i].cost){
                update=true;
                dp[e[i].to]=dp[e[i].from]+e[i].cost;
                if(e[i].to==n)n_update=true;
                if(c>=n+2 && e[i].to==n){
                    cout<<"inf"<<endl;
                    return 0;
                }
            }
        }
        if(!update)break;
        if(c>=n+2 && !n_update)break;
    }
    //rep(i,1,n)cout<<dp[i]<<endl;
    cout<<dp[n]<<endl;
    
    return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
input = Array.new(N) { gets.chomp.chars }
input.each_cons(2) do |a, b|
  if input.count(a) > 1
    puts 'No'
    exit
  end
  unless a[-1] == b[0]
    puts 'No'
    exit
  end
end
puts 'Yes'


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int n,k;
vector<int> G[2100];

int dfs(int to,int from,int k,int depth=0){
	int cnt=0;
	if(depth>=k)cnt++;
	for(auto d:G[to]){
		if(d==from)continue;
		cnt+=dfs(d,to,k,depth+1);
	}
	return cnt;
}

int main(){
	cin >> n >> k;
	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);
	}
	int ans=n;
    if(k%2==0){
	    for(int i=0;i<n;i++){
		    int cnt=0;
		    for(int t:G[i]){
			    cnt+=dfs(t,i,k/2);
		    }
    	ans=min(ans,cnt);
    	}
    }
    else{
    	for(int i=0;i<n;i++){
    		for(int t:G[i]){
    			int cnt=dfs(t,i,(k+1)/2)+dfs(i,t,(k+1)/2);
    			ans=min(ans,cnt);
    		}
	    }
    }
	cout << ans << endl;
}

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

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

  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end(), greater<int>());

  int alice = 0;
  int bob = 0;

  rep(i, n) {
    if (i % 2 == 0)
      alice += a[i];
    else
      bob += a[i];
  }

  cout << alice - bob << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d;	cin >> a >> b >> c >> d;
  long long numc=b/c-(a-1)/c;
  long long numd=b/d-(a-1)/d;
  long long numcd=b/(c/__gcd(c,d)*d)-(a-1)/(c/__gcd(c,d)*d);
  cout << b-(a-1)-(numc+numd-numcd);
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

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

    vector<int> nums(n);
    rep(i, n) cin >> nums[i];

    vector<int> num_list;
    rep(i, n){
        if(count(all(num_list), nums[i]) == 0){
            num_list.push_back(nums[i]);
        }
    }

    cout << num_list.size() << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int h1,h2;
	int k1,k2;
	int a,b,c,d;
	int Hsum,Ksum;
	
	cin>>h1>>h2;
	cin>>k1>>k2;
	cin>>a>>b>>c>>d;
	
	Hsum=(h1*a)+(h2*b)+(h1/10*c)+(h2/20*d);
	Ksum=(k1*a)+(k2*b)+(k1/10*c)+(k2/20*d);
	
	if(Hsum>Ksum) cout<<"hiroshi"<<endl;
	else if(Hsum<Ksum) cout<<"kenjiro"<<endl;
	else cout<<"even"<<endl;
	
	return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 989381
#define maxn 500010
#define inf (1<<30)
int a[maxn],b[maxn];
ll s1[maxn],s2[maxn];
int main(){
	int n;
	in(n);
	FOR(i,1,n)a[read()]++;
	int num=0;
	FOR(i,1,n)
		if(a[i])
			b[++num]=a[i];
	sort(b+1,b+num+1);	
	FOR(i,1,num){
		s1[b[i]]++;
		s2[b[i]]+=b[i];	
	}
	FORD(i,n,1)s1[i]+=s1[i+1];
	FOR(i,1,n)s2[i]+=s2[i-1];
	int ans=n;
	FOR(i,1,n){
		while(1){
			int x=s1[ans];
			if(s2[ans-1]>=1ll*ans*(i-x))break;
			else ans--;
		}
		out(ans);
	}
}
//sum>=(c-x)*s

Measured memory_bytes: 11776
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    lst = LI()
    cnt = 1
    ans = 0

    for brock in lst:
        if brock == cnt:
            cnt += 1
        else:
            ans += 1

    if cnt != 1:
        print(ans)
    else:
        print(-1)
    
main()


Measured memory_bytes: 101620
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] list = new int[N];
		for(int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
		}

		Arrays.sort(list);

		int sum = 0;

		for(int i = 0; i < N - 2; i++) {
			for(int j = i + 1; j < N - 1; j++) {
				for(int k = j + 1; k < N; k++) {
					if(list[k] >= list[i] + list[j]) {
						break;
					}
					sum++;
				}
			}
		}
		System.out.println(sum);
		sc.close();
	}
}


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

using namespace std;

int a[100010];

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,c,k;scanf("%d%d%d",&n,&c,&k);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int x=1,ans=0;
	while (x<=n)
	{
		int y=x;
		while (y<=n&&a[y]-a[x]<=k&&y-x<c) y++;
		x=y;ans++;
	}
	printf("%d\n",ans);
	return 0;
}


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

int main() {
    string N;
    cin >> N;
    if((N.at(0) == N.at(1) && N.at(1) == N.at(2)) || (N.at(1) == N.at(2) && N.at(2) == N.at(3))){
        cout << "Yes" <<endl;
    }
    else cout << "No" <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {
			// TODO Auto-generated method stub
			try (Scanner sc = new Scanner(System.in)) {
				long a = sc.nextLong();
				long b = sc.nextLong();
				long c = sc.nextLong();
				long d = sc.nextLong();

				long ans = Math.max(a*c, b*d);
				ans = Math.max(ans, a*d);
				ans = Math.max(ans, b*c);

				
				System.out.println(String.valueOf(ans));

			} catch (Exception e) {
				// TODO: handle exception
			}
		}
}

Measured memory_bytes: 35912
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[51][51][2501],N,K,MOD=1e9+7;
int main(void){
    cin>>N>>K;
    dp[0][0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=K;k++){
                if(dp[i][j][k]!=0){
                    dp[i+1][j][k+2*j]=(dp[i+1][j][k+2*j]+dp[i][j][k])%MOD;
                    if(j>0)dp[i+1][j-1][k+2*j]=(dp[i+1][j-1][k+2*j]+dp[i][j][k]*j*j)%MOD;
                    dp[i+1][j+1][k+2*j]=(dp[i+1][j+1][k+2*j]+dp[i][j][k])%MOD;
                    dp[i+1][j][k+2*j]=(dp[i+1][j][k+2*j]+dp[i][j][k]*j)%MOD;
                    dp[i+1][j][k+2*j]=(dp[i+1][j][k+2*j]+dp[i][j][k]*j)%MOD;
                }
            }
        }
    }
    cout<<dp[N][0][K]<<endl;
}


Measured memory_bytes: 48512
#include <iostream>                                                                                                                                                                                         
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;

    if(a * b % 2 == 0){ 
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }   
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define INF (1<<21)
using namespace std;

int main(){
  int i,j,k,n,m,s,g1,g2,d[101][101],ans;
  while(cin >> n >> m >> s >> g1 >> g2 && n && m && s && g1 && g2){

    for(i=0;i<=n;i++){
      for(j=0;j<=n;j++){
	if(i == j) d[i][j] = 0;
	else d[i][j] = INF;
      }
    }

    for(j=0;j<m;j++){
      int a,b,cost;
      cin >> a >> b >> cost;
      d[a][b] = cost;
    }

    for(k=0;k<=n;k++){
      for(i=0;i<=n;i++){
	for(j=0;j<=n;j++){
	  if(d[i][k] >= INF || d[k][j] >= INF) continue;
	  d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
	}
      }
    }

   int ans = INF;
   for(i=1;i<=n;i++){
       ans = min(ans,d[s][i]+d[i][g1]+d[i][g2]);
   }

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    vector<int> v;
    v.push_back(a % b);
    int i = 2;
    while(true)
    {
        v.push_back(a * i % b);
        i++;
        if(v.at(0) == v.at(v.size() - 1))
        {
            break;
        }
    }
    for(int i = 0;i < v.size();i++)
    {
        if(v.at(i) == c)
        {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";

    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<P>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

vector<ll> dist; 
vector<bool> seen;  // 訪問済みの点
bool flag = true;

// BFSのための再帰関数
void dfs(const Graph &G, ll v, ll d) {
    seen[v] = true;
    dist[v] = d;

    for (auto next_v : G[v]) { 
        if(seen[next_v.first]){
            if(d+next_v.second != dist[next_v.first]){
                flag = false;
            }
            continue;
        } 
        dfs(G, next_v.first, d+next_v.second); // 再帰的に値を追加していく
    }
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    Graph G(N);

    // 確保した配列の初期化
    seen.assign(N, false);
    dist.assign(N, INF);

    REP(i, M){
        ll L, R, D;
        cin >> L >> R >> D;
        L--;
        R--;

        P p;
        p.first = R;
        p.second = D;
        G[L].push_back(p);

        p.first = L;
        p.second = -1*D;
        G[R].push_back(p);
    }
    // cout << "aaa" << endl;
    REP(i, N){
        if(!seen[i]){
            dfs(G, i, 0);
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

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

    long long count=0;
    int x = a[0], ok=0;
    for(int j=1; j<n; j++) {
        if(x&a[j]) {
            break;
        }
        x ^= a[j];
        ok = j;
    }

    for(int i=1; i<n; i++) {
        x ^= a[i-1];
        count += ok-i+2;
        for(int j=ok+1; j<n; j++) {
            if(x&a[j]) {
                break;
            }
            x ^= a[j];
            ok = j;
        }
    }
    count += ok-n+2;

    cout<<count<<endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
const int INF = 1e9;
 
int main(){
    int N;
    cin >> N;
    vector<int> x(N),y(N),h(N);
    int si = -1;
    rep(i,N){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]>0)si = i;
    }
 
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            bool ok = true;
            int ht = abs(x[si]-j)+abs(y[si]-i)+h[si];
            for(int k = 0; k < N; k++){
                if(!ok)break;
                if(h[k] != max(ht-abs(x[k]-j)-abs(y[k]-i),0))ok = false;
            }
            if(ok){
                printf("%d %d %d\n",j,i,ht);
                return 0;
            }
        }
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

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


int i,j;

int main(void){
    
    string o,e;
    cin>>o>>e;
    string ans;
    FOR(i,o.length()){
        ans+=o[i];
        if(e[i]!=NULL)ans+=e[i];
    }
    cout<<ans;
    
    
    
    return 0;
    
}


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

using namespace std;

int main() {
long long   a,b,c,d,x,y,product;
    cin >> a >> b >> c >>d ;
long long max1,max2;
  max1=max(a*c,a*d);
  max2=max(b*c,b*d);
  product=max(max1,max2);
 cout << product << endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  bool ok = false;
  for (int i = 0; i < n; i++) {
    long long upl = c * i + b - a;
    long long upr = d * i + b - a;
    long long dwl = c * (n - i - 1);
    long long dwr = d * (n - i - 1);
    if (!(upl > dwr || upr < dwl))
      ok = true;
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[1010][1010];
int n,m,a,b;
int main(){
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)s[i][j]='.';
	if(n&1)for(int i=1;i<m&&a;i+=2)s[n][i]='<',s[n][i+1]='>',a--;
	if(m&1)for(int i=1;i<n&&b;i+=2)s[i][m]='^',s[i+1][m]='v',b--;
	for(int i=1;i<n;i+=2)
		for(int j=1;j<m;j+=2){
			if(a>=2){
				a-=2;
				s[i][j]='<',s[i][j+1]='>';
				s[i+1][j]='<',s[i+1][j+1]='>';
			} else if(b>=2){
				b-=2;
				s[i][j]='^',s[i][j+1]='^';
				s[i+1][j]='v',s[i+1][j+1]='v';
			} else if(a&&b&&i==n-2&&j==m-2){
				a--,b--;
				s[i][j]='<',s[i][j+1]='>',s[i][j+2]='^';
				s[i+1][j]='^',s[i+1][j+2]='v';
				s[i+2][j]='v',s[i+2][j+1]='<',s[i+2][j+2]='>';
			} else if(a){
				a--;
				s[i][j]='<',s[i][j+1]='>';
			} else if(b){
				b--;
				s[i][j]='^',s[i+1][j]='v';
			}
		}
	if(a||b)return puts("NO"),0;
	puts("YES");
	for(int i=1;i<=n;++i)puts(s[i]+1);
}

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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vii a(n);
    rep(i,n){
        ll temp;
        cin>>temp;
        a[i] = {temp, i+1};
    }
    sort(a.begin(), a.end());
    for(auto x : a){
        cout<<x.Y<<" ";
    }
    cout<<endl;

    timer();
    return 0;
}


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

int main(void)
{
	int N, M, X;
	cin >> N >> M >> X;
	int* A = new int[M];
	int c1 = 0, c2 = 0;
	for (int i = 0; i < M; ++i) {
		cin >> A[i];
		if (A[i] < X)	++c1;
		else if (A[i] > X)	++c2;
	}

	cout << min(c1, c2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        ll n;cin>>n;
	ll ans=0,a[n+2];
	rep(i,1,n+1)
	cin>>a[i];
	rep(i,1,n+1)
	{
		rep(j,i+1,n+1)
		ans+=(a[i]*a[j]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include<iomanip>

using namespace std;

int main()
{
    int l;
    cin >> l;
    double ans = (double) l*l*l/27;
    cout << fixed;
    cout << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  int n;
  double d;
  cin >> n;
  cin >> d;

  int ans = 0;

  rep(i, n) {
    double x, y;
    cin >> x >> y;

    double dist = sqrt(x * x + y * y);
    if (dist <=d) {
      ans++;
    }
  }

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

Measured memory_bytes: 3840
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int n, A, B, C;
struct point {
    int x, y;
    bool operator<(const point &p)const{
        return x<p.x;
    }
}w[101000];
priority_queue<int>PQ;
long long S, M, V[101000], rr = -1e18;
int main(){
    int i;
    scanf("%d%d%d",&A,&B,&C);
    n = A+B+C;
    for(i=1;i<=n;i++){
        int a, b, c;
        scanf("%d%d%d",&a,&b,&c);
        S += a;
        w[i].x = b-a, w[i].y = c-a;
    }
    sort(w+1,w+n+1);
    long long s1 = 0;
    for(i=n;i>n-B-C;i--){
        s1 += w[i].x;
        PQ.push(w[i].y-w[i].x);
        if(i<=n-B){
            s1 += PQ.top();
            PQ.pop();
        }
        if(i<=n-B+1) V[i] = s1;
    }
    while(!PQ.empty())PQ.pop();
    s1 = 0;
    for(i=1;i<=n-B+1;i++){
        PQ.push(w[i].y);
        if(i>n-B-C){
            rr = max(rr, V[i] + s1);
            s1 += PQ.top();
            PQ.pop();
        }
    }
    printf("%lld\n",rr+S);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
  vector<int>parent,sizes;
  UnionFind(int n):parent(n),sizes(n,1){
    for(int i=0;i<n;++i)parent[i]=i;
  }
  int find(int x){
    return x==parent[x]?x:parent[x]=find(parent[x]);
  }
  void unite(int x,int y){
    if((x=find(x))==(y=find(y)))return;
    if(sizes[x]>sizes[y])swap(x,y);
    parent[y]=x;
    sizes[x]+=sizes[y];
    sizes[y]=0;
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  int size(int x){
    return sizes[find(x)];
  }
};
main(){
  int n,m,a,b,x=0,y=0;
  cin>>n>>m;
  UnionFind UF(n);
  for(int i=0;i++<m;UF.unite(--a,--b))cin>>a>>b;
  for(int i=0;i<n;++i)UF.sizes[i]>1?x++:UF.sizes[i]-1?:y++;
  cout<<abs(x-y)<<endl;
}

Measured memory_bytes: 3124
# include<stdio.h>

void trace(int A[], int N) {
  int i;
  for ( i = 0; i < N; i++) {
    if (i > 0) printf(" "); // 2つ目の要素の前には空白
    printf("%d",A[i]);
  }
  printf("\n");
}

/* 挿入ソート */
void insertionSort(int A[], int N) {
  int j,v;
  for (int i = 1; i < N; i++) {
    v = A[i]; // pivot
    j = i - 1;
    while (j>=0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A, N);
  }
}

int main(void) {
  int N,i,j;
  int A[100];
  scanf("%d\n", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  trace(A, N);
  insertionSort(A,N);
  return 0;
}



Measured memory_bytes: 2056
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

char s[99];
int main(){
	int n;
	scanf("%d",&n);
	puts("0");fflush(0);
	scanf("%s",s);
	if(*s=='V')return 0;
	
	char pre=*s;
	ll l=0,r=n;//(l,r)をにぶたん　preはlの席
	while(1){
		ll m=(l+r)/2;
		printf("%lld\n",m);fflush(0);
		scanf("%s",s);
		if(*s=='V')return 0;
		if(((m-l)%2)^(pre==*s)){
			l=m;
			pre=*s;
		}else{
			r=m;
		}
	}
	return 0;
}

Measured memory_bytes: 760