akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  if (A+B>C+D) {
    cout << "Left" << endl;
  }
  
  else if (A+B<C+D) {
    cout << "Right" << endl;
  }
  
  else{
    cout << "Balanced" << endl;
  }
}

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

int main() {
  int n;
  long long s = 0;
  cin >> n;
  for(int i = 1; i <= n; i++){
  	if(i%3 != 0 && i%5 != 0){
    	s += i; 
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int n, M = 1e9 + 7;
    cin >> n;

    vector<vector<int>> a(n, vector<int>(n));

    for (auto& i : a)
        for (auto& j : i) cin >> j;

    vector<int> dp(1 << n), p2(n + 1), cnt(1 << n);
    for (int i = 0; i <= n; ++i) p2[i] = 1 << i;
    dp[0] = 1;

    queue<int> q;
    q.push(0);

    while (!q.empty()) {
        int msk = q.front(), i = cnt[msk];
        q.pop();

        if (i == n) break;
        if (!dp[msk]) continue;

        for (int j = 0; j < n; ++j) {
            if (a[i][j] && !(msk & p2[j])) {
                q.push(msk | p2[j]);
                cnt[msk | p2[j]] = cnt[msk] + 1;
                dp[msk | p2[j]] = (dp[msk | p2[j]] + dp[msk]) % M;
            }
        }
        dp[msk] = 0;
    }
    cout << dp[p2[n] - 1] << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;


int main() {
    int n, m;

    cin >> n >> m;

    vector<int> as(m,0);

    rep(i, n) {
        int k ;
        cin >> k;
        rep(j, k) {
            int a;
            cin >> a;
            a --;
            as[a]++;
        }
    }

    int ans = 0;
    for (int k : as) {
        if (k == n) {
            ans++;
        }
    }
    cout << ans << endl;

}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back


ll modpow(ll a, ll n, ll m)
{
    if(n == 0) return 1;
    ll t = modpow(a, n >> 1, m);
    t = t * t % m;
    if(n & 1) t = t * a % m;
    return t; 
}

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

    vec inv(200010, 0);
    inv[1] = 1;
    REP(i,2,200010) inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;

    ll nCa = 1, nCb = 1, c;
    REP(i,1,a+1) nCa = (nCa * (n-i+1) % MOD) * inv[i] % MOD;
    REP(i,1,b+1) nCb = (nCb * (n-i+1) % MOD) * inv[i] % MOD;
    c = modpow(2, n, MOD) - 1- nCa - nCb;
    c = (c >= 0) ? c % MOD : (c % MOD + MOD) % MOD;
    PR(c); 

    return 0;
}

/*

nC1 + ... + nCn - nCa - nCb
= 2^n - 1 - nCa - nCb

*/

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
    {
    	cin.tie(0);
        ios::sync_with_stdio(0);
    	int n;
    	cin>>n;
    	int a[n];
    	for (int i = 1; i <= n; ++i)
    	{
    		cin>>a[i];
    	}
        int cnt=0;
        for (int i = 1; i <= n; ++i)
        {
        if(a[i]==i){
            swap(a[i],a[i+1]);
            cnt++; }
        }
        cout<<cnt;
    	return 0;
    }


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

using lint = long long;

void bool_elimination(std::vector<lint>& mat) {
    int n = mat.size();

    for (int l = 0; l < n; ++l) {
        {
            auto& v = *std::max_element(mat.begin() + l, mat.end());
            std::swap(v, mat[l]);
        }

        const auto& v = mat[l];
        for (int i = l + 1; i < n; ++i) {
            auto u = mat[i];
            u ^= v;
            if (u < mat[i]) std::swap(u, mat[i]);
        }
    }
}

bool independent(std::vector<lint> bs, lint v) {
    bs.push_back(v);
    bool_elimination(bs);
    return bs.back() != 0;
}

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

    std::vector<lint> xs(n);
    for (auto& x : xs) std::cin >> x;
    std::string s;
    std::cin >> s;

    std::reverse(xs.begin(), xs.end());
    std::reverse(s.begin(), s.end());

    std::vector<lint> bs;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '0') {
            if (independent(bs, xs[i])) bs.push_back(xs[i]);
        } else {
            if (independent(bs, xs[i])) {
                std::cout << "1\n";
                return;
            }
        }
    }

    std::cout << "0\n";
}

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

    int q;
    std::cin >> q;
    while (q--) solve();

    return 0;
}


Measured memory_bytes: 3588
import sys
import math


N=int(input())
A=list(map(int,input().split()))

R=list(A)

nodes=0
log2=math.log(2)

if A[0]>0 and N>0:
    nodes = -1
    print(nodes)
    sys.exit(0)

elif A[0]==1 and N==0:
    nodes = 1
    print(nodes)
    sys.exit(0)

else:
    nodes = 1
    R[N]=0
    R[0]=1
    if math.log(A[N])>N*log2:
        nodes = -1
        print(nodes)
        sys.exit(0)
    
    for i in range(N-1,0,-1):
        if A[i] > 0 and (math.log(A[i]) > float(i)*log2):
            nodes = -1
            print(nodes)
            sys.exit(0)

        if N>30:
            R[i]=R[i+1]+A[i+1]
        else:
            R[i]=min(2**i-A[i], R[i+1]+A[i+1])
    # print(R)    

    nodes=1
    for i in range(1,N+1):
        if A[i] <= 2*R[i-1]:
            if i<N:
                R[i] = min(R[i], 2*R[i-1]-A[i])
            else:
                R[N] = 0
            nodes += (R[i]+A[i])
        else:
            nodes = -1
            print(nodes)
            sys.exit(0)

    # print(R)    
    print(nodes)
    


Measured memory_bytes: 20180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int k,x;cin>>k>>x;
    for(ll i=x-k+1;i<x+k;i++){
        cout<<i<<(i==x+k+1 ? '\n':' ');
    }
}

Measured memory_bytes: 256
using System;

namespace AtCoderABC135
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            ans += N;
            ans += M;

            if (ans % 2 != 0)
                Console.WriteLine("IMPOSSIBLE");

            else
            {
                ans = ans / 2;

                Console.WriteLine(ans.ToString());
            }
        }
    }
}



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

double threshold(double a, double b, double r) {
  return (a*tan(M_PI*r/180)/b < 1) ?
      a*a*b -a*a*a*tan(M_PI*r/180)/2 :
      a*b*b/tan(M_PI*r/180)/2;
}
int main() {
  int a, b, x;
  cin >> a >> b >> x;
  double l = 0.0;
  double r = 90.0;
  while(true) {
    double angle = (l+r)/2;
    if(threshold(a,b,angle) < x) {
      r = angle;
    }
    else {
      l = angle;
    }
    if(r-l < 0.000001) {
      cout << setprecision(10) << fixed << l << endl;
      break;
    }
  }
  return 0;
}


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

using namespace std;

int X;

int gcd(int x, int y) {
	if (!y) return x;
	return gcd(y, x%y);
}

int main() {
	scanf("%d", &X);
	printf("%d\n", 360/gcd(360, X));
	return 0;
}

Measured memory_bytes: 3796
#include <stdio.h>
int main(void)
{
	int X,Y,Z,n,m;
	while(scanf("%d %d %d",&X,&Y,&Z)!=EOF)
	{
		n=X/(Y+Z);
		if(X-(Y+Z)*n<Z)
			n--;	
		printf("%d\n",n);
	}
}

Measured memory_bytes: 128
l = input().split(" ")
n = int(l[0])
k = int(l[1])
s = input()

nums = []
now = 1
count = 0
# まずは1-0-1-0の各回数を取る
for i in range(n):
    if s[i] == str(now):
        count = count + 1
    else:
        nums.append(count)
        now = 1 - now
        count = 1

if count != 0:
    nums.append(count)

# ラストは1
if len(nums) % 2 == 0:
    nums.append(0)

add = 2 * k + 1

sums = list((0, ))
for i in range(len(nums)):
    sums.append(sums[i] + nums[i])

ans = 0
# 偶数だけ
for i in range(len(nums))[::2]:
    left = i
    right = min(i + add, len(nums))
    tmp = sums[right] - sums[left]

    ans = max(tmp, ans)
print(ans)


Measured memory_bytes: 7932
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v, id;
} list;

typedef struct {
	int key, id;
} data;
 
typedef struct {
	data obj[100001];
	int size;
} min_heap;
 
void push(data x, min_heap* h)
{
	int i = ++(h->size), j = i >> 1;
	data tmp;
	h->obj[i] = x;
	while (j > 0) {
		if (h->obj[i].key < h->obj[j].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, M, D[100001], u, w;
	list *adj[100001] = {}, e[400001], *p;
	data d;
	min_heap h;
	h.size = 0;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) {
		scanf("%d", &(D[i]));
		d.key = D[i];
		d.id = i;
		push(d, &h);
	}
	for (i = 0; i < M; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].id = i;
		e[i*2+1].id = i;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	
	char c[100001];
	int flag[100001] = {}, weight[200001], q[100001], head, tail;
	for (i = 0; i < M; i++) weight[i] = 1000000000;
	while (h.size > 0) {
		d = pop(&h);
		if (flag[d.id] != 0) continue;
		flag[d.id] = 1;
		c[d.id-1] = 'B';
		q[0] = d.id;
		for (head = 0, tail = 1; head < tail; head++) {
			u = q[head];
			for (p = adj[u]; p != NULL; p = p->next) {
				w = p->v;
				if (flag[w] == 0 && D[w] >= D[u]) {
					flag[w] = 1;
					q[tail++] = w;
					c[w-1] = (c[u-1] == 'B')? 'W': 'B';
					weight[p->id] = D[w];
				}
			}
		}
		for (p = adj[d.id]; p != NULL; p = p->next) if (D[p->v] == D[d.id]) break;
		if (p == NULL) break;
	}
	if (h.size > 0) printf("-1\n");
	else {
		c[N] = 0;
		printf("%s\n", c);
		for (i = 0; i < M; i++) printf("%d\n", weight[i]);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 12396
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int r = 0,b = 0;
    char s;
    for(int i = 0;i < N;i++) {
        cin >> s;
        if(s == 'R') r++;
        else b++;
    }
    if(r > b) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main()
{
	char temp;
	int r,c;
	cin>>r>>c;
	long long int grid[r][c]={},dp[r][c]={};
	dp[0][0]=1;
	
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
		{
			cin>>temp;
			grid[i][j]=((temp=='.')?1:0);
			if(!i&&j)dp[0][j]=grid[0][j]&dp[0][j-1];
			else if(i&&!j)dp[i][0]=grid[i][0]&dp[i-1][0];	
		}
	}
	
	for(int i=1;i<r;i++)
	{
		for(int j=1;j<c;j++)
		{
			dp[i][j]=((grid[i][j])?dp[i-1][j]+dp[i][j-1]:0)%1000000007;
		}
	}
	
	/*for(int i=0;i<r;i++)
	{
		for(int j=0;j<c;j++)
			cout<<dp[i][j]<<" ";
		cout<<endl;
	}*/
	cout<<dp[r-1][c-1]<<"\n";
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int h, w;
string s[110];
int main(void){
	cin >> h >> w;
	rep(i, h) cin >> s[i];
	string d;
	rep(i, w + 2) d += '#';
	cout << d << endl;
	rep(i, h){
		string k = '#' + s[i] + '#';
		cout << k << endl;
	}
	cout << d << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define DEBUG(x) cerr << #x << ": " << x << "\n"

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B;
    cin >> A >> B;
    cout << (A % 2 == 0 || B % 2 == 0 ? "No" : "Yes") << endl;
    return 0;
}


Measured memory_bytes: 256
// AOJ 0520: Lightest Mobile
// 2017.10.28 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int p, q, r, b; } T;
T t[102];
char f[102];

int gcd(int a, int b)
{
	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

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

int calc(int i)
{
	int w, wr, wb;
	wr = (t[i].r > 0) ? calc(t[i].r) : 1;
	wb = (t[i].b > 0) ? calc(t[i].b) : 1;
	w = lcm(t[i].p * wr, t[i].q * wb);
	return w/t[i].p + w/t[i].q;
}

int main()
{
	int n, i;

	while (scanf("%d", &n) && n > 0) {
		memset(f, 0, sizeof(f));
		for (i = 1; i <= n; i++) {
			scanf("%d%d%d%d", &t[i].p, &t[i].q, &t[i].r, &t[i].b);
			if (t[i].r > 0) f[t[i].r] = i;
			if (t[i].b > 0) f[t[i].b] = i;
		}
		for (i = 1; f[i]; i++);
		printf("%d\n", calc(i));
	}
	return 0;
}

Measured memory_bytes: 1752
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
    a = ab[i][0]
    b = ab[i][1]
    ab[i][0]  = b
    ab[i][1] = a
ab.sort()
ok = True
time = 0
for i in range(n):
    cost = ab[i][1]
    due = ab[i][0]
    if time+cost > due:
        ok = False 
        break
    time += cost
if ok:print('Yes')
else:print('No')

Measured memory_bytes: 81168
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

void ABC081A (const unsigned int const * given_data)
{
	// local variables for this function
	int          retval_scanf;
	unsigned int iter;
	unsigned int num_marbles;

	// STEP.01
	// find the number of squares on which Sunuke will place a marble
	num_marbles = 0;

	for (iter = *given_data; iter > 0; iter /= 10)
	{
		num_marbles += iter % 10;
	}

	// STEP.03
	// print the answer of this task to the standard output
	printf( "%d\n", num_marbles );

	// STEP.END
	return;
}

int main (void)
{
	// variables for this function
	unsigned int given_data;
	int          retval_scanf;

	// STEP.01
	// read out the given string
	retval_scanf = scanf("%d", &given_data);

	// STEP.02
	// calculate & output the answer
	ABC081A(&given_data);

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iomanip>
#include <cstring>
#include <cassert>
#include <functional>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>

using namespace std;

int N;
#define MV 10
#define INF 0x7F7F7F7F
int G[MV][MV];
bool input() {
    scanf("%d", &N);
    if (N == 0) return false;
    memset(G, 0x7F, sizeof(G));
    for (int i = 0; i < N; i++) {
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        G[a][b] = G[b][a] = c;
        G[a][a] = 0;
        G[b][b] = 0;
    }
    return true;
}

void solve() {
    for (int k = 0; k < MV; k++) {
        for (int i = 0; i < MV; i++) {
            for (int j = 0; j < MV; j++) {
                if (G[i][k] == INF || G[k][j] == INF) continue;
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
#ifdef DEBUG
    for (int i = 0; i < MV; i++) {
        for (int j = 0; j < MV; j++) {
            if (G[i][j] == INF) {
                cout << setw(5) << "x";
            } else {
                cout << setw(5) << G[i][j];
            }
        }
        cout << endl;
    }
#endif
    int index = 0, min1 = INF; 
    for (int i = 0; i < MV; i++) {
        if (G[i][i] == INF) break;
        int total = 0;
        for (int j = 0; j < MV; j++) {
            if (G[i][j] == INF) break;
            total += G[i][j];
        }
        if (total < min1) {
            index = i;
            min1 = total;
        }
    }
    printf("%d %d\n", index, min1);
}

int main() {
    while (input()) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1188
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		println(new StringBuffer(sc.nextLine()).reverse().toString());
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 11000
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] aryA = new long[N+1];
        long[] aryB = new long[N];
        for (int i = 0; i < N+1; i++) {
            long a = Long.parseLong(sc.next());
            aryA[i] = a;
        }
        for (int i = 0; i < N; i++) {
            long a = Long.parseLong(sc.next());
            aryB[i] = a;
        }
        long cnt = 0L;
        for (int i = 0; i < N; i++) {
            long enemyCnt = 0L;
            enemyCnt = (aryA[i] + aryA[i+1]) - aryB[i];
            if (enemyCnt < 0) {
                cnt += aryA[i] + aryA[i+1];
            } else {
                cnt += aryB[i];
            }
            if (aryA[i] < aryB[i]) {
                long sabun = Math.abs(aryA[i] - aryB[i]);
                long after = aryA[i+1] - sabun;
                if (after < 0) {
                    aryA[i + 1] = 0;
                } else {
                    aryA[i + 1] = after;
                }
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 49232
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var ans = getAns(s);
        Console.WriteLine(ans);
    }
    static int getAns(string s)
    {
        var count = 0;
        var sL = s.Length;
        if (int.Parse(s) % 2 == 0) count++;
        for (int i = 1; i < sL; i++)
        {
            var t1 = int.Parse(s.Substring(0, i));
            var tw = s.Substring(i);
            if (tw[0] == '0') continue;
            var t2 = int.Parse(tw);
            if (t2 < t1) break;
            if ((t1 + t2) % 2 == 0) count++;
        }
        return count;
    }
}



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

int main(){
  int n;
  cin >> n;
  map<int, int> a;
  for(int i=1; i<=n; i++){
    int input;
    cin >> input;
    a[input] = i;
  }
  for(auto const& entry: a){
    cout << entry.second << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 5504
import math


def calc(t):
    t = math.radians(t)
    if a * math.tan(t) <= b:
        return a * a * b - a * a * a * math.tan(t) / 2
    else:
        return b * b / math.tan(t) * a / 2


a, b, x = map(int, input().split(" "))
n_max = 90
n_min = 0
for _ in range(100000):
    n_mid = n_min + (n_max - n_min) / 2
    if calc(n_mid) < x:
        n_max, n_min = n_mid, n_min
    else:
        n_max, n_min = n_max, n_mid
print(n_mid)

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

int main() {
    //
    long long num;
    long long tmp;
    long long cnt = 0;
    map<long long, long long> m;

    cin >> num;

    for (long long i = 0; i < num; i++) {
        cin >> tmp;
        m[tmp]++;
    }

    for (auto itr : m) {
        if (itr.first > itr.second) cnt += itr.second;
        else cnt += abs(itr.first - itr.second);
      }

    cout << cnt;
    //
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL dp[SIZE];

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

    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    vector<int> v;
    for(int i = 0; i < N; ++i) {
        if(s[i] != t[i]) {
            v.pb(1);
            ++i;
        } else {
            v.pb(0);
        }
    }

    if(v[0] == 0) dp[0] = 3;
    else dp[0] = 6;
    for(int i = 1; i < v.size(); ++i) {
        if(v[i - 1] == 0) {
            if(v[i] == 0) dp[i] = dp[i - 1] * 2 % MOD;
            else dp[i] = dp[i - 1] * 2 % MOD;
        } else {
            if(v[i] == 0) dp[i] = dp[i - 1];
            else dp[i] = dp[i - 1] * 3 % MOD;
        }
    }
    cout << dp[v.size() - 1] << endl;
    return 0;
}



Measured memory_bytes: 3616
import bisect
n = int(input())
a = list(map(int,input().split()))

a.sort()

if a[-1] <= 0:
    print(2*a[-1]-sum(a))
    p = a[-1]
    for i in range(1,n):
        print(p,a[n-1-i])
        p -= a[n-1-i]
    exit()

#k回マイナスを使う
k = bisect.bisect_right(a,0)
if k == 0:
    print(sum(a)-2*a[0])
    p = a[0]
    for i in range(1,n-1):
        print(p,a[i])
        p -= a[i]
    print(a[-1],p)
    exit()

res = 0
for i in range(k):
    res -= a[i]
for i in range(k,n):
    res += a[i]
print(res)
p = a[0]
for i in range(k,n-1):
    print(p,a[i])
    p -= a[i]
print(a[-1],p)
p = a[-1]-p

for i in range(1,k):
    print(p,a[i])
    p -= a[i]


Measured memory_bytes: 59404
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
#define CEIL(A,B) ((A)+(B)-1)/(B)
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll H, W, K;
ll dp[101][8];


int main() {
    fastio();
    cin >> H >> W >> K;
    if(W == 1) {
        cout << "1\n"; 
        return 0; 
    }
    REP(i, H+1) REP(j, W) dp[i][j] = 0;
    dp[0][0] = 1;
    vector<ll> A;
    REP(i, 1 << (W-1)) {
        bool valid = true;
        REP(j, W - 2) {
            if(((i >> j) & 3) == 3) {
                valid = false;
                break;
            }
        }
        if(valid) A.push_back(i);
    }
    // priv(A);
    REP(i, H) {
        REP(j, W) {
            for(auto p : A) {
                if (j >= 1 && ((p >> (j - 1)) & 1)) {
                    dp[i + 1][j - 1] += dp[i][j];
                    dp[i + 1][j - 1] %= MOD;
                    
                } else if (j <= W - 2 && ((p >> j) & 1)) {
                    dp[i + 1][j + 1] += dp[i][j];
                    dp[i + 1][j + 1] %= MOD;
                    
                } else {
                    dp[i + 1][j] += dp[i][j];
                    dp[i + 1][j] %= MOD;
                }
            }
        }
        
    }
    // REP(i, H+1) {
    //     REP(j, W) {
    //         cerr << dp[i][j] << " ";
    //     }
    //     cerr << "\n";
    // }
    cout << dp[H][K-1] << endl;
	return 0;
}

Measured memory_bytes: 256
s_list = list(input())
n = len(s_list)
dic = {"A", "C", "G", "T"}
ans = 0
tmp_ans = 0
for i in range(n):
    for j in range(i, n):
        if s_list[j] in dic:
            tmp_ans += 1
        else:
            ans = max(ans, tmp_ans)
            tmp_ans = 0
        if j == n - 1:
            ans = max(ans, tmp_ans)
            tmp_ans = 0
ans = max(ans, tmp_ans)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<ll> h(n);
    for(auto &x:h)cin >> x;

    bool ans=true;
    for(int i=n-1;i>0;i--){
        if(h[i]>=h[i-1]){
            continue;
        }else if(h[i]==h[i-1]-1){
            h[i-1]--;
        }else{
            ans=false;
            break;
        }
    }

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

    return 0;
}


Measured memory_bytes: 4060
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var A = intShift();
  var B = intShift();
  var K = intShift();
  
  var a = B - A + 1;
  
  if(K * 2 > a){
  	return Array.from({length:a},(a,b)=>A+b).join(BKRT);
  }else{
  	return [].concat(
    	Array.from({length:K},(a,b)=>A+b),
    	Array.from({length:K},(a,b)=>B-b).reverse()
    ).join(BKRT)
  }
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
4 9 2
`);

Measured memory_bytes: 11468
def main():
    n = int(input())
    s = input()
    if n % 2 == 1:
        return False
    
    i = n // 2
    if s[:i] == s[i:]:
        return True
    else:
        return False


if __name__ == "__main__":
    if main():
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

void yes(){
	cout << "Yes" << endl;
	exit(0);
}

int main(){

	fastio;
	int tab[3][3],mark[128];
	REP(i,0,3) REP(j,0,3) cin >> tab[i][j];
	fill(mark,0);
	int n,x;
	cin >> n;
	REP(i,0,n){
		cin >> x;
		mark[x] = 1;
	}

	REP(i,0,3){
		bool ok = true;
		REP(j,0,3) ok = ok && mark[tab[i][j]];
		if(ok) yes();
	}
	REP(j,0,3){
		bool ok = true;
		REP(i,0,3) ok = ok && mark[tab[i][j]];
		if(ok) yes();
	}
	bool ok = true;
	REP(i,0,3) ok = ok && mark[tab[i][i]];
	if(ok) yes();
	ok = true;
	REP(i,0,3) ok = ok && mark[tab[i][2-i]];
	if(ok) yes();

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;

 

ll int power(ll int x, ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

void computeLPSArray(string pat, int M, int* lps) 
{ 
    // length of the previous longest prefix suffix 
    int len = 0; 
  
    lps[0] = 0; // lps[0] is always 0 
  
    // the loop calculates lps[i] for i = 1 to M-1 
    int i = 1; 
    while (i < M) { 
        if (pat[i] == pat[len]) { 
            len++; 
            lps[i] = len; 
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            // This is tricky. Consider the example. 
            // AAACAAAA and i = 7. The idea is similar 
            // to search step. 
            if (len != 0) { 
                len = lps[len - 1]; 
  
                // Also, note that we do not increment 
                // i here 
            } 
            else // if (len == 0) 
            { 
                lps[i] = 0; 
                i++; 
            } 
        } 
    } 
}


int main()
{
  fastio();

 
ll int T;
T=1;
while(T--)
{	
ll int h1,m1,h2,m2,k;
cin>>h1>>m1>>h2>>m2>>k;
ll int ans= (h2-h1)*60 + m2-m1 -k;
cout<<ans<<endl;

}
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

const int MOD = 1e9+7;

inline void add(int& lhs, int rhs)
{
    lhs = (lhs + rhs) % MOD;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    V<V<int>> dp(n+1, V<int>(n+1, 0));
    dp[1][1] = 1;
    for (int i = 2; i <= n; ++i) {
        V<int> pre(i+1, 0);
        for (int j = 1; j <= i; ++j) {
            add(pre[j], pre[j-1]+dp[i-1][j]);
        }
        for (int j = 1; j <= i; ++j) {
            if (s[i-2] == '<') {
                add(dp[i][j], pre[j-1]);
            }
            else {
                add(dp[i][j], pre[i]-pre[j-1]);
            }
            // for (int k = 1; k <= i; ++k) {
            //     int v = j + (j >= k);
            //     if ((s[i-2] == '>' and v > k) or (s[i-2] == '<' and v < k)) {
            //         add(dp[i][k], dp[i-1][j]);
            //     }
            // }
        }
    }
    int ans = 0;
    for (int k = 1; k <= n; ++k) {
        add(ans, dp[n][k]);
    }
    cout << (ans%MOD+MOD)%MOD << endl;
}


Measured memory_bytes: 35584
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;


#[fastout]
fn main() {
    input! {
    n: u8,
    s: Chars
    }
    for c in s {
        print!("{}", ((c as u8 - 65u8 + n) % 26u8 + 65) as char)
    }
}


Measured memory_bytes: 2200
#include <stdio.h>
#include <string.h>

char s[105][15];
char t[105][15];

int main(){

	int i,j;

	int N,M;

	scanf("%d",&N);

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

	scanf("%d",&M);

	for(i=0;i<M;i++){
	scanf("%s",&t[i]);
	}

	int score=-10000;


	for(i=0;i<N;i++){
	int cnt=0;
	for(j=0;j<N;j++){
	int check=strcmp(s[i], s[j] );
	if(check==0){
	cnt++;
	}
	}

	for(j=0;j<M;j++){
	int check=strcmp(s[i], t[j] );
	if(check==0){
	cnt--;
	}
	}

	if(score<cnt){
	score=cnt;
	}

	}

	if(score<=0){
	printf("0\n");
	}
	else{
	printf("%d\n",score);
	}

return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,int> mp;
    rep(i,n){
        mp[i+a[i]]++;
    }
    ll ans = 0;
    rep(i,n){
        ans += mp[i-a[i]];
    }
    cout << ans << endl;
}   

Measured memory_bytes: 20972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,a,b,c;
    string str;
    cin>>str;
    c=str.size();
    if(str[c-1]=='s')
        cout<<str<<"es"<<endl;
    else
        cout<<str<<"s"<<endl;

    return 0;
}


Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            int X = sc.nextInt();
            int sum = 0;
            List<Integer> al = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                int m = sc.nextInt();
                al.add(m);
                sum += m;
            }
            X -= sum;

            Collections.sort(al);

            int ans = N;

            while (X > 0) {
                if ( X >= al.get(0) ) {
                    X -= al.get(0);
                    ans++;
                } else {
                    break;
                }
            }
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21972
#include<stdio.h>
int main(void){
        int w,h,x,y,r;
	scanf("%d %d %d %d %d\n",&w,&h,&x,&y,&r);
	if(x-r<0 || y-r<0 || x+r>w || y+r>h){
          printf("No\n");
        }
        else{
         printf("Yes\n");
        }
	
	
	return 0;
}

Measured memory_bytes: 1816
#include <iostream>
#include <algorithm>
#include <array>
#define INFTY 10000
#define int long long
using namespace std;
int n;
int x[101];

signed main() {
    int mid = 0;
    int ans = 10000000000000;
    int sum = 0;
    cin >> n;
    for(int i = 0; i < 101; i ++){
        x[i] = INFTY;
    }
    for(int i = 0; i < n; i ++){
        cin >> x[i];
    }
    sort(x,x+n);

    for(int i = x[0]; i <= x[n-1]; i ++){
        sum = 0;
        for(int t = 0; t < n; t ++){
            sum += (x[t] - i)*(x[t] - i);
        }
        if(sum < ans) ans = sum;

    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3592
H,W=map(int, input().split())
a=[list(map(int,input().split())) for i in range(H)]

mr=[]
md=[]
for h in range(H):
    for w in range(W):
        if a[h][w]%2!=0 and w<W-1:
            mr.append((h,w))
            a[h][w+1]+=1
    if a[h][w]%2!=0 and h<H-1:
        md.append((h,w))
        a[h+1][w]+=1
print(len(mr)+len(md))
for i in range(len(mr)):
    print(mr[i][0]+1,mr[i][1]+1,mr[i][0]+1,mr[i][1]+2)
for i in range(len(md)):
    print(md[i][0]+1,md[i][1]+1,md[i][0]+2,md[i][1]+1)


Measured memory_bytes: 19560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[MAXn];
int main(){
    IOS();
    int n;
    cin >> n;
    REP (i,n) cin >> d[i];
    if (d[0] != 0) return cout << -1 << endl,0;
    REP1 (i,n-1) if (d[i-1] < d[i]-1) return cout << -1 << endl,0;
    ll ans = 0;
    for (int i=n-1;i>=0;i--) {
        int idx = i;
        while (idx > 0 && d[idx] > d[idx-1]) idx--;
        ans += d[i];
        i = idx;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4440
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(read())
for i in range(1, 3500):
    for h in range(1, 3500):
        check = 4 * i * h - n * (i + h)
        if check > 0:
            v = n * i * h / check
            if v.is_integer():
                print(i, h, int(v))
                exit()


Measured memory_bytes: 42140
#include <stdio.h>
long long a, b, c, k;
int main() {
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
	if (k <= a) {
		printf("%lld\n", k);
		return 0;
	}
	if (k <= a + b) {
		printf("%lld\n", a);
		return 0;
	}
	printf("%lld\n", a - (k - a - b));
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>

using namespace std;



int main()
{
	long n, m;
	cin >> n >> m;
	priority_queue<long> q;

	for (long i = 0; i < n; i++)
	{
		long in;
		cin >> in;
		q.push(in);
	}

	for (long i = 0; i < m; i++)
	{
		long p = q.top();
		q.pop();
		q.push(p / 2);
	}

	long long result = 0;

	while (!q.empty())
	{
		result += q.top();
		q.pop();
	}

	printf("%lld", result);

	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    ll n,k;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }
    vector<int>ord(n,-1);
    ord[0] = 0;
    int now = 0;
    int cycle = 0;
    for(int i = 1;i<=n;i++) {
        now = a[now];
        if(i==k) {
            cout << now + 1 << endl;
            return 0;
        }
        if(ord[now] == -1) {
            ord[now] = i;
        } else {
            cycle = i - ord[now];
            break;
        }
    }
    // cout << now << endl;
    k -= ord[now];
    // cout << ord[now] << endl;
    k %= cycle;
    for(int i = 0;i<k;i++) {
        now = a[now];
    }
    cout << now +1 << endl;
}
    




Measured memory_bytes: 4836
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int a,b,c,i;
	cin>>a>>b>>c;
	for(i=1;i<10000;i++){
		if(a*i%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	// Shojin
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long plusMax = 0;
			long plusMin = Long.MAX_VALUE;
			long minusMax = 0;
			long minusMin = Long.MAX_VALUE;
			for (int i = 0; i < n; i++) {
				long x = sc.nextLong();
				long y = sc.nextLong();
				plusMax = Math.max(plusMax, x + y);
				plusMin = Math.min(plusMin, x + y);
				minusMax = Math.max(minusMax, y - x);
				minusMin = Math.min(minusMin, y - x);
			}
			System.out.println(Math.max(plusMax - plusMin, minusMax - minusMin));
		}
	}
}

Measured memory_bytes: 59404
#include <iostream>
using namespace std;
int main(){
    int a,b,c,temp;
    cin >> a >> b >> c;
    if(a > b){
        temp = b;
        b = a;
        a = temp;
    }
    if(b > c){
        temp = c;
        c = b;
        b = temp;
    }
    if(a > b){
        temp = b;
        b = a;
        a = temp;
    }
    cout << a << " " << b << " " << c << "\n";
    return 0;
}



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

const int INF = 1000000000;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0 && m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

		int k;
		cin >> k;
		int p[k],q[k],r[k];
		for(int i=0; i<k; i++){
			cin >> p[i] >> q[i] >> r[i];
		}

		for(int k=0; k<m; k++){
			for(int i=0; i<m; i++){
				for(int j=0; j<m; j++){
					if(C[i][j]>C[i][k]+C[k][j]){
						C[i][j] = C[i][k]+C[k][j];
					}
					if(T[i][j]>T[i][k]+T[k][j]){
						T[i][j] = T[i][k]+T[k][j];
					}
				}
			}
		}

		for(int i=0; i<k; i++){
			int s=p[i]-1; int g=q[i]-1;
			if(r[i]==0){
				cout<<C[s][g]<<endl;
			}
			else{
				cout<<T[s][g]<<endl;
			}
		}

	}

	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
struct point{
	int x;
	int y;
};
const int MAX = 10000000;
int h,w,n,c[1001][1001];
char board[1002][1002],tboard[1002][1002];
int bfs(int y,int x){
	int dx[] = {0,-1,1,0},dy[] = {-1,0,0,1},tx,ty,t = 1,min = 0;
	queue<point> que;
	point p,tp;
	c[y][x] = 0; 
	p.x = x;
	p.y = y;
	que.push(p);
	while(!que.empty()){
		p = que.front();
		que.pop();
		for(int i = 0;i < 4;++i){
			tx = p.x + dx[i];
			ty = p.y + dy[i];
			tp.x = tx;
			tp.y = ty;
			if(board[ty][tx] == '\0') continue;
			if(board[ty][tx] != '.' && board[ty][tx] != 'X'){	
				if(board[ty][tx] - '0' == t){	
					min += c[p.y][p.x] + 1;
					if(board[ty][tx] - '0' == n){
						return min;
					}
					for(int j = 1;j <= h;++j){
						for(int k = 1;k <= w;++k){
							c[j][k] = MAX;
						}
					}
					++t;
					while(!que.empty()){
						que.pop();
					}
					c[ty][tx] = 0;
					que.push(tp);
					break;
				}
				else {
					c[ty][tx] = c[p.y][p.x] + 1;
					que.push(tp);
				}
			}
			if(board[ty][tx] == '.' && c[ty][tx] == MAX){
				c[ty][tx] = c[p.y][p.x] + 1;
				que.push(tp);
			}	
		}
	}
	return 0;
}
int main(){
	int x,y;
	string str;
	memset(board,'0',sizeof(char));
	for(int i = 0;i < 1001;++i){
		for(int j = 0;j < 1001;++j){
			c[i][j] = MAX;
		}
	}
	cin >> h >> w >> n;
	for(int i = 0;i < h;++i){
		cin >> str;
		for(int j = 0;j < w;++j){
			board[i+1][j+1] = tboard[i+1][j+1] = str[j];
			if(str[j] == 'S'){
				x = j + 1;
				y = i + 1;
			}
		}
	}
	cout << bfs(y,x) << endl;
	return 0;
}

Measured memory_bytes: 6764