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

string concat(int a, int b, int c, int d) {
    return to_string(a) + " " + to_string(b) + " " + to_string(c) + " " + to_string(d);
}

int main() {
    int h, w;
    cin >> h >> w;
    int m[h][w];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> m[i][j];
        }
    }

    vector<string> v;
    for(int i = 0; i < h; i++) {
        if (i % 2 == 0) {
            for(int j = 0; j < w; j++) {
                if (j < w - 1) {
                    if (m[i][j] % 2 == 1) {
                        m[i][j+1]++;
                        v.push_back(concat(i+1, j+1, i+1, j+2));
                    }
                } else if (i < h - 1) {
                    if (m[i][j] % 2 == 1) {
                        m[i+1][j]++;
                        v.push_back(concat(i+1, j+1, i+2, j+1));
                    }
                }
            }
        } else {
            for(int j = w - 1; j >= 0; j--) {
                if (j > 0) {
                    if (m[i][j] % 2 == 1) {
                        m[i][j-1]++;
                        v.push_back(concat(i+1, j+1, i+1, j));
                    }
                } else if (i < h - 1) {
                    if (m[i][j] % 2 == 1) {
                        m[i+1][j]++;
                        v.push_back(concat(i+1, j+1, i+2, j+1));
                    }
                }
            }
        }
    }

    cout << v.size() << endl;
    for (const auto& a : v) {
        cout << a << endl;
    }
}


Measured memory_bytes: 11892
/*
 Read problem and understand it 100%
 Make observation
 SOLVE THE PROBLEM
*/
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pii pair<int, int>
#define int long long
#define szof(s) (int)s.size()
#define all(s) (int)s.begin(), s.end()
using namespace std;
 
const int N = (int)1e6 + 5;
const int INF = (int)1e9 + 9;
const int MOD = (int)1e9 + 7;
 
int a[N];

main() {
	int n, ans = 1;
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	
	for (int i = 1; i <= n; i++) {
		int res = 1;
		while (i < n && a[i] >= a[i + 1]) {
			i++, res++;
		}
		ans = max(ans, res);
	}
	
	cout << ans - 1;
}


Measured memory_bytes: 1152
//abc178_c.cpp
//Sun Sep 13 20:42:16 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll nin = 1;
	ll eig = 1;
	ll ten = 1;
	rep(i,n){
		ten = ten*10%MOD;
		nin = nin*9%MOD;
		eig = eig*8%MOD;
	}
	ll ans = ((ten+MOD-nin)*2)%MOD;
	ll tmp = (ten+MOD-eig)%MOD;
	ans = (ans+MOD-tmp)%MOD;
	cout << ans << endl;
//	printf("%.4f\n",ans);
}


Measured memory_bytes: 3632
n = int(input())
p = list(map(int, input().split()))
c = []
for i in range(n):
  c.append(i+1)
  
d = 0
for i in range(n):
  if p[i] != c[i]:
    d += 1

if d == 0 or d == 2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int a,b,c,d,e,f;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    int x;
    x=a+b*5+c*10+d*50+e*100+f*500;
    if(x>=1000)printf("1\n");
    else printf("0\n");
    
}


Measured memory_bytes: 2704
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool com(ld a,ld b){
	return (fabsl(a - b) <= LDBL_EPSILON * fmaxl(1.L, fmaxl(fabsl(a), fabsl(b))));
}

bool solve(){
	ll n;cin>>n;
	ld num=1;
	__int128_t ans=1;
	ll an=1;
	bool iszero=false;
	bool isOK=true;
	rep(i,n){
		__int128_t num=pow(10,18);
		ll a;cin>>a;
		__int128_t b=a;
		if(b==0)iszero=true;
		if(ans*b>num){
			isOK=false;
		}
		ans*=b;
		an*=a;
	}
	if(iszero)cout<<0<<endl;
	else if(isOK)cout<<an<<endl;
	else 
	cout<<-1<<endl;
	return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
vector<int> prime,Max,cnt,idx;
int par[1000001]={0,1,};
int arr[10001];
const ll M = 1000000007;
int main(){
	for(ll i = 2;i<=1000000;i++){
		if(par[i]) continue;
		prime.push_back(i);
		for(ll j = i;j<=1000000;j+=i) par[j]=prime.size();
	}
	int N;scanf("%d",&N);
	Max.resize(prime.size());
	
	for(int i=0;i<N;i++){
		scanf("%d",arr+i);
		cnt.resize(prime.size());
		int t = arr[i];
		while(t>1){
			int x = par[t]-1;
			cnt[x]++;
			Max[x]=max(Max[x],cnt[x]);
			t/=prime[x];
		}
		cnt.clear();
	}
	for(int i=0;i<prime.size();i++) if(Max[i]) idx.push_back(i);
	ll ans = 0;
	for(int i=0;i<N;i++){
		int t = arr[i];
		ll x = 1;
		for(int j : idx){
			int count=0;
			while(t%prime[j]==0){
				t/=prime[j];
				count++;
			}
			for(int k=0;k<Max[j]-count;k++) x=(x*prime[j])%M;
		}
		ans=(ans+x)%M;
		
	}
	printf("%lld",ans);
	
}

Measured memory_bytes: 5240
from sys import stdin, stdout  

K, N = [int(c) for c in input().split()]
A = [int(c) for c in input().split()]
dist=[]
for i in range(0,N-1):
    dist.append(A[i+1]-A[i])
dist.append(abs(A[0]-A[-1]+K))

m=max(dist)
for idx,val in enumerate(dist):
    if(val==m):
        dist[idx]=0
        break
print(sum(dist))

Measured memory_bytes: 26444
/*
**   Contest : Educational DP Contest
**   Problem : D - Knapsack 1
**
**    Author : Dhiraj Govindvira
**      Date : 05-Jun-2020 ~ Friday
**      Time : 02:59:49 PM
*/

#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    ll n, w;
    cin>>n>>w;

    vector<pair<ll,ll>> ks(n);
    cin>>ks;

    vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));

    // dp[i][j] = ith item, j weight
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=w; j++)
        {
            ll W = ks[i-1].first;
            ll V = ks[i-1].second;

            if(j >= W) {
                dp[i][j] = max(V + dp[i-1][j-W], dp[i-1][j]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    for(auto x : dp) d(x);
    cout<<dp[n][w]<<endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    loop(Case,1,t+1)
    {
        cerr<<"Case #"<<Case<<'\n';
        solve(Case);
    }
    return 0;
}

Measured memory_bytes: 80256
# ABC086 C

def main():
    n = int(input())
    
    res = 'Yes'

    for i in range(n):
        t, x, y = map(int, input().split())
        
        if i != 0:
            t, x, y = t - t_prev, x - x_prev, y - y_prev

        if abs(x) + abs(y) > t:
            res = 'No'
            break
        elif (not t%2 and (x+y)%2) or (t%2 and not ((x+y)%2)):
            res = 'No'
            break
        
        t_prev, x_prev, y_prev = t, x, y
    
    print(res)

if __name__ == '__main__':
    main()

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

void north();
void south();
void west();
void east();
void right();
void left();

int top, bot, n, s, w, e, times, total, stock;
string inst;

int main() {
	while (cin >> times, times) {
		top = 1;
		bot = 6;
		n = 5;
		s = 2;
		w = 4;
		e = 3;
		total = 1; //initialize

		rep(i, times) {
			cin >> inst;
			if (inst == "North") north();
			if (inst == "South") south();
			if (inst == "West") west();
			if (inst == "East") east();
			if (inst == "Right") right();
			if (inst == "Left") left();
			total += top;
		}

		cout << total << endl;
	}

	return 0;
}

void north() {
	stock = top;
	top = s;
	s = bot;
	bot = n;
	n = stock;
	return;
}

void south() {
	stock = top;
	top = n;
	n = bot;
	bot = s;
	s = stock;
	return;
}

void west() {
	stock = top;
	top = e;
	e = bot;
	bot = w;
	w = stock;
	return;
}

void east() {
	stock = top;
	top = w;
	w = bot;
	bot = e;
	e = stock;
	return;
}

void right() {
	stock = n;
	n = w;
	w = s;
	s = e;
	e = stock;
	return;
}

void left() {
	stock = n;
	n = e;
	e = s;
	s = w;
	w = stock;
	return;
}

Measured memory_bytes: 3128
n,k,s=map(int,input().split())
for i in range(k):
  print(s,end=" ")
  if i==k-1:
    if n==k:
      print()
if s!=10**9: 
  for i in range(n-k):
    print(s+1,end=" ")
    if i==n-k-1:
      print()
else:
  for i in range(n-k):
    print(1,end=" ")
    if i==n-k-1:
      print()

Measured memory_bytes: 4212
#include <iostream>

using namespace std;

int main(){
	int A[100],N,i,v,j,k;

	cin >> N;
	
	for(i=0;i<N;i++){
		cin >> A[i];
	}

	for(k=0;k<N-1;k++){
			cout << A[k] << " " ;
		}
			cout << A[N-1] <<endl;
	
	for(i=1;i<N;i++){
		v = A[i];
		j = i-1;

		while(j >= 0 && A[j]>v){
			A[j+1]=A[j];
			j--;
			A[j+1] =v;
		}

		for(k=0;k<N-1;k++){
			cout << A[k] << " " ;
		}
			cout << A[N-1] <<endl;
	}

	return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-3;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

long double Lagrange_interpolation(vector<long double> xi,vector<long double> fi,long double x){
	int n=xi.size()-1;
	long double f=0.0;
	for(int i=0;i<=n;++i){
		long double li=1.0;
		for(int j=0;j<=n;++j){
			if(i==j) continue;
			li*=(x-xi[j])/(xi[i]-xi[j]);
		}
		f+=fi[i]*li;
	}
	return f;
}

int main(void){
	int d;
	while(cin >> d){
		if(d==0) break;

		bool ok[8]={false};
		vector<long double> di(d+3);
		for(int i=0;i<=d+2;++i) cin >> di[i];

		for(int i=0;i<=d+2;++i){
			for(int j=i+1;j<=d+2;++j){
				vector<long double> xi;
				vector<long double> fi;
				for(int k=0;k<=d+2;++k){
					if(k==i||k==j) continue;
					xi.pb(k);
					fi.pb(di[k]);
				}
				long double vi=Lagrange_interpolation(xi,fi,i);
				long double vj=Lagrange_interpolation(xi,fi,j);
				if(abs(vi-di[i])<eps) ok[i]|=true;
				if(abs(vj-di[j])<eps) ok[j]|=true;
			}
		}
		for(int i=0;i<=d+2;++i) if(!ok[i]) cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
using namespace std;
vector<int> adjlist[100005];
int mx[100005];
int ans = 0;
int n,k;
void dfs(int u){
    mx[u] = 0;
    for (auto v : adjlist[u]){
        dfs(v);
        if (mx[v] == k && u != 1){
            ans++;
        }
        else{
            mx[u] = max(mx[u],mx[v]);
        }
    }
    mx[u]++;
}
int main(){
    scanf("%d%d",&n,&k);
    for (int i = 1,x; i <= n; i++){
        scanf("%d",&x);
        if (i == 1){
            if (x != 1){
                ans++;
            }
        }
        else adjlist[x].push_back(i);
    }
    dfs(1);
    printf("%d",ans);
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, ans;

int main(){
	set<int> s;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> m;
		set<int>::iterator ite;;
		ite = s.find(m);
		if(ite == s.end()){
			s.insert(m); ans++;
		}else{
			s.erase(m); ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
for(;;){
	int x,y;
	cin>>x>>y;
	if(x==y && x==0){break;}
	else if(x>y){swap(x,y);}
	cout<<x<<" "<<y<<endl;
	}
return 0;
}


Measured memory_bytes: 2996
def is_prime(num):
    for i in range(2, num):
        if num % i == 0:
            return False

    return True

def main():
    x = int(input())
    while True:
        if is_prime(x):
            print(x)
            break

        x += 1

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mo 998244353ll
#define N 500010
int jc[N],ij[N],n,k,ans;
int qp(int x,int y){
	int r=1;
	for(;y;y>>=1,x=x*x%mo)
		if(y&1)r=r*x%mo;
	return r;
}
int c(int y,int x){
	if(x>y||x<0)return 0;
	return jc[y]*ij[x]%mo*ij[y-x]%mo;
}
signed main(){
	cin>>n>>k;
	jc[0]=1;
	for(int i=1;i<N;i++)
		jc[i]=jc[i-1]*i%mo;
	ij[N-1]=qp(jc[N-1],mo-2);
	for(int i=N-2;~i;i--)
		ij[i]=ij[i+1]*(i+1)%mo;
	for(int i=n;i<=k;i++)
		if(i>=k-i){
			if(i==k-i)ans=(c(k-1,i)-c(k-1,i*2-n+1)+mo)%mo;
			else ans=(ans+(c(k,i)-c(k,i*2-n+1))+mo)%mo;
		}
	cout<<ans;
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>
#include <iomanip>

using namespace std;

int main() {
	int n, s;
	cin >> n >> s;
	vector<int> a(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int sum = 0, j = 0, ans = 1<<21;
	for (int i = 0; i < n; i++)
	{
		while(sum + a[j] < s && j < n) {
			sum += a[j];
			j++;
		}
		if(j != n) {
			ans = min(ans, j - i + 1);
		}
		if(i == j) {
			j++;
		} else {
			sum -= a[i];
		}
	}
	if(ans == 1<<21) {
		ans = 0;
	}
	cout << ans << endl;
}



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

int main(){
    int N;
    cin >> N;
    vector<double> vec(N);
    for(int i = 0;i < N;i++){
        cin >> vec.at(i);
    }
    while(vec.size() > 1){
    
    sort(vec.begin(),vec.end());

    vec.push_back((vec.at(0)+vec.at(1))/2.0);
    vec.erase(vec.begin() + 0);
    vec.erase(vec.begin() + 0);
    
    if(vec.size() == 1){
        break;
    }
    
    
    }
    cout << vec.at(0) << endl;
    

    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()   
#define trav(a, x) for(auto& a : x)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}
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 x;
    cin>>x;
    int n;
    cin>>n;
    set<int> a;
    forn(i,n)
    {
        int p;
        cin>>p;
        a.insert(p);
    }
    int diff=INF;
    int ans=-1;
    for(int i=0;i<=101;i++)
    {
        if(a.find(i)==a.end() and diff>abs(i-x))
        {
            diff=abs(i-x);
            ans=i;
        }
    }
    cout<<ans<<endl;
}
int main()
{
    sws
    // tcase{
        solve();
    // }
    return 0;
}


Measured memory_bytes: 3660
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    k = N.bit_length()

    if 1<<(k-1) == N:
        print('No')
        exit()
    print('Yes')
    if N == 3:
        for i in range(1, 6):
            print(i, i+1)
        exit()

    N0 = 1<<(k-1)
    e = [(N0-1, N+1)]
    for i in range(1, N0-1):
        e.append((i, i+1))
        e.append((i+N, i+1+N))

    if N%2 == 0:
        v = N ^ N0
        e.append((N, v))
        e.append((N*2, N0))
        for i in range(N0, N):
            if i % 2 == 0:
                e.append((i, v))
                e.append((i + N, i+N+1))
            else:
                e.append((i, i - 1))
                e.append((i + N, v + 1))
    else:
        for i in range(N0, N + 1):
            if i % 2 == 0:
                e.append((i, 2))
                e.append((i + N, i + 1 + N))
            else:
                e.append((i, i - 1))
                e.append((i + N, 3 + N))
    for edge in e:
        print(*edge)


if __name__ == '__main__':
    main()


Measured memory_bytes: 60712
#include <stdio.h>

int	D, G;
int	p[11] = {0};
int	c[11] = {0};

void	culc_min(int state[11], int score, int *num, int temp)
{
	int	i, j;
	int	now_score;
	int	now_num;

	if (score >= G)
	{
		if (temp < *num)
		{
			*num = temp;
		}
		return ;
	}
	for (i = 0; i < D; i++)
	{
		if (state[i] == 1)
			continue ;
		state[i]++;
		now_score = score;
		now_num = temp;
		for (j = 0; j < p[i] - 1; j++)
		{
			now_score += (i + 1) * 100;
			now_num++;
			if (now_score >= G)
			{
				culc_min(state, now_score, num, now_num);
			}
		}
		now_score += (i + 1) * 100 + c[i];
		now_num++;
		culc_min(state, now_score, num, now_num);
		state[i]--;
	}
}

int		main(void)
{
	int	state[11] = {0};
	int	score = 0;
	int	num = 10000;
	int	i;

	//入力
	scanf("%d%d", &D, &G);
	for (i = 0; i < D; i++)
	{
		scanf("%d%d", &p[i], &c[i]);
	}
	//処理
	culc_min(state, score, &num, 0);
	printf("%d\n", num);
	return (0);
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <climits>

using namespace std;

int main(){
    int n; cin >> n;
    string s1, s2; cin >> s1 >> s2;
    s1.erase(unique(s1.begin(), s1.end()), s1.end());
    s2.erase(unique(s2.begin(), s2.end()), s2.end());
    vector<bool> s;
    for(int i=0; i<s1.size(); ++i){
        s.push_back(s1[i]==s2[i]);
    }
    cout << endl;
    long long ans=s[0] ? 3 : 6;
    for(int i=1; i<s.size(); ++i){
        int t;
        if(!s[i-1] && s[i]) t=1;
        else if(!s[i-1] && !s[i]) t=3;
        else t=2;
        ans=ans*t%1000000007;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef pair<int,int> pint;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+10;

int N;
int a;
map<int,int>mp;

int main() {
	cin>>N;
	Rep(i,N){cin>>a;
	mp[a]++;
	}
	int ans=0;
	Rep(i,100010){
		int p = mp[i]+mp[i+1]+mp[i+2];
		if(p>ans) ans=p;
	}
	cout<<ans<<endl;
	

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
const int  Inv2 = (MOD+1)/2;

     signed main(){
   int n;
   cin>>n;
   set<int> s;
   int a;
   for(int i=0;i<n;i++){
           cin>>a;
           if(s.find(a)!=s.end())s.erase(a);
           else s.insert(a);
   }
 cout<<s.size()<<endl;
   }
         


        


Measured memory_bytes: 4864
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<vector>
#include<cstdlib>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	long long  n,x;
	scanf("%lld %lld",&n,&x);
	vector<ll>a;
	
	for(ll i=0;i<n;i++){
		ll t;
		scanf("%lld",&t);
		a.push_back(t);
	}
	ll ans=__gcd(abs(a[0]-x),abs(a[1]-x));
	for(ll i=1;i<a.size();i++){
	   if(ans>( __gcd(abs(a[i-1]-x),abs(a[i]-x) ) ) )
	   	ans=__gcd(abs(a[i-1]-x),abs(a[i]-x) ) ;
	}
	if(n==1)
		ans=abs(x-a[0]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int s(ll x)
{
	int ret = 0;
	while(x) { ret += x % 10; x /= 10;}
	return ret;
}
vector<ll> ans = {1, 2, 3, 4, 5, 6, 7, 8};
int main()
{
	
	int K;
	scanf("%d", &K);
	
	for(int k = 1; k <= 13; ++k)
	{
		int prel = max(0, k - 2);
		int prer = k * 10 - 2;
		for(int pre = prel; pre <= prer; ++pre)
		{
			ll cur = pre;
			for(int i = 0; i < k; ++i)
				cur = cur * 10 + 9;
			ans.push_back(cur);
		}
	}
	for(int i = 0; i < ans.size(); ++i)
	{
		bool flag = 1;
		for(int j = i + 1; j < ans.size(); ++j)
			if(1.0 * ans[i] / s(ans[i]) > 1.0 * ans[j] / s(ans[j]))
			{
				flag = 0;
				break;
			}
		if(flag)
		{
			cout << ans[i] << endl;
			--K;
			if(!K)
				return 0;
		}
	}
	return 0;
}

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

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

    int n, k;
    cin >> n >> k;

    vector<llint> scores(n);
    rep(i, n) cin >> scores.at(i);

    //
    // 1 2 3 4 5 6
    // -----
    //   -----
    // 範囲 K の先頭と末尾だけ比較すれば、大小が分かる
    // はず？
    for (int i = 0; i < n - k; i++) {
        if (scores.at(i) < scores.at(i + k))
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}



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

using namespace std;
int N;
int n[210];
int d[210];
int t[210][2];
int input(){
	cin >> N;
	for(int i = 0; i < N-1;i++){
		 cin >> n[i] >> d[i];
	}
	return (N!=0);
}

void solve(){
	t[0][0] = 0;
	t[0][1] = 0;

	int max_x = 0;
	int max_y = 0;
	int min_x = 0;
	int min_y = 0;
	int a;
	for(int i = 0;i < N-1;i++){
		int x;
		int y;
		a = n[i];
		if(d[i] == 0){ 
			x = t[a][0] - 1;
			y = t[a][1];
		}
		else if(d[i] == 1){
			x = t[a][0];
			y = t[a][1] - 1;
		}
		else if(d[i] == 2){
			x = t[a][0] + 1;
			y = t[a][1];
		}
		else if(d[i] == 3){
			x = t[a][0];
			y = t[a][1] + 1;
		}
		max_x = max(max_x, x);
		max_y = max(max_y, y);
		min_x = min(min_x, x);
		min_y = min(min_y, y);
		t[i+1][0] = x;
		t[i+1][1] = y;
		//cout << x << y << endl;
	}

//	int ans = (max_x - min_x + 1) * (max_y - min_y + 1);
 	//cout << ans << endl;
//	cout << max_x << ' ' << min_x << ' ' << max_y << ' ' << min_y << endl;
	cout << (max_x - min_x + 1) << ' ' << (max_y - min_y + 1) << endl;
}


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



Measured memory_bytes: 3100
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// LCM : find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a / GCD(a, b) * b

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()

	a := make([]int, N+1)
	for i := 1; i <= N; i++ {
		x := i
		cnt := 0
		for x < K {
			x *= 2
			cnt++
		}
		a[i] = cnt
	}
	p := 0.0
	for i := 1; i <= N; i++ {
		p += math.Pow(0.5, float64(a[i]))
	}
	// out(a)
	// fmt.Printf("%13.13f\n", p)
	ans := p / float64(N)
	fmt.Printf("%13.13f\n", ans)
}


Measured memory_bytes: 1408
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
constexpr ll mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    int n=100;cin>>n;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    sort(all(l));

    int cnt=0;
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = i+1; j < n; j++)
        {
            for (size_t k = j+1; k < n; k++)
            {
                if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i] && l[i] + l[j] > l[k]){
                    ++cnt;
                    // cout<<i+1<<' '<<j+1<<' '<<k+1<<endl;
                }
            }
            
        }
        
    }
    cout<<cnt<<endl;
    
}


Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
import collections

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c=collections.Counter(A)

pairCounter=0

beki=29
nibeki=2**beki

for i in range(N):
  target = A[i]
  if c[target] < 1:
    continue
  c[target]-= 1

  while (nibeki > target):
    beki-=1
    nibeki=2**beki

  pair = nibeki * 2 - target
  if pair in c.keys() and c[pair] > 0:
    c[pair]-= 1
    pairCounter+=1

print(pairCounter)

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

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
inline int sgn(double a, double b = 0) { return a < b - EPS ? -1 : a > b + EPS ? 1 : 0; }

P readP() {
    double x, y;
    cin >> x >> y;
    return P(x, y);
}

void printPoint(P p) {
    cout << fixed << setprecision(10) << p.real() << " " << p.imag() << endl;
}

double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

P projection(P p, P a, P b) {
    p -= a; b -= a;
    return dot(p, b) * b / abs(b) / abs(b) + a;
}

P reflection(P p, P a, P b) {
    P t = projection(p, a, b);
    return 2. * t - p;
}

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

    P a = readP(), b = readP();
    int n;
    cin >> n;
    rep(i, n) {
        P p = readP();
        printPoint(reflection(p, a, b));
    }
}

Measured memory_bytes: 3340
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    string s;
    getline(cin,s);
    cout<<(char)(s[0]-32);
    for(int i=0; i<=s.length(); i++)
    {
        if(s[i]==' ')
            cout<<(char)(s[i+1]-32);
    }
}


Measured memory_bytes: 256
import numpy as np

ll=list(map(int,input().split()))
case=np.array(list(map(int,input().split())))

case[::-1].sort()

total=np.sum(case)
line=total/4/ll[1]

target=case[ll[1]-1]

if target >= line:
    print('Yes')

else:
    print('No')

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

const ll MOD = 998244353;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, s;
	cin >> n >> s;

	vl a(n);
	FOR(i,0,n) cin >> a[i];

	vl dp(s+1);
	dp[0] = 1;

	FOR(i,0,n) {
		vl ndp = dp;
		FOR(j,0,s+1) ndp[j] = 2*ndp[j] % MOD;
		FOR(j,a[i],s+1) ndp[j] = (ndp[j] + dp[j-a[i]]) % MOD;
		dp = ndp;
	}
	cout << dp[s] << endl;
}



Measured memory_bytes: 3704
#include <stdio.h>

int main(void)
{
  int m = 0;
  int f = 0;
  int r = 0;
  int result = 0;

  while(1){
    scanf("%d %d %d", &m, &f, &r);

    if(m == -1 && f == -1 && r == -1)
      break;

    if(m == -1 || f == -1)
      result = 1;
    else if(m + f >= 80)
      result = 2;
    else if(m + f >= 65)
      result = 3;
    else if(m + f >= 50)
      result = 4;
    else if(m + f >= 30 && r >= 50)
      result = 4;
    else if(m + f >= 30)
      result = 5;
    else
      result = 1;
    
    switch (result) {
    case 1 : printf("F\n");  break;
    case 2 : printf("A\n");  break;
    case 3 : printf("B\n");  break;
    case 4 : printf("C\n");  break;
    case 5 : printf("D\n");  break;
    }
  }
  return 0;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> P(N);
  rep(i, N) cin >> P[i];

  int ascend = 1;
  set<int> hist;
  hist.emplace(P[0]);
  for (int i = 1; i < K; ++i) {
    hist.emplace(P[i]);
    ascend = (P[i - 1] < P[i]) ? ascend + 1 : 1;
  }

  int answer = 1;
  bool unsort0 = (ascend == K);
  bool unsort1 = false;
  for (int i = K; i < N; ++i) {
    bool not_change = ((P[i - K] == *hist.begin()) && (*hist.rbegin() < P[i]));
    hist.erase(P[i - K]);
    hist.emplace(P[i]);

    ascend = (P[i - 1] < P[i]) ? ascend + 1 : 1;
    if (K <= ascend)
      unsort1 = true;
    else if (!not_change)
      answer++;
  }

  if (!unsort0 && unsort1) answer++;
  cout << answer << endl;
  return 0;
}

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

void output_array(int arr[], int arr_len)
{
  cout << arr[0];
  for (int i = 1; i < arr_len; ++i)
  {
    cout << ' ' << arr[i];
  }
  cout << endl;
}

int bubble_sort(int arr[], int arr_len)
{
  // Check if there are reversed elements
  bool rev_flag = true;
  int sort_count = 0;

  for (int i = 0; i < arr_len; ++i)
  {
    rev_flag = false;

    // Check un-ordered area sequentially
    for (int j = arr_len - 1; j > i; --j)
    {
      // If a reversed is found, then
      //  - flag ON
      //  - swap the elements
      //  - increment the counter
      if (arr[j - 1] > arr[j])
      {
        rev_flag = true;
        swap(arr[j - 1], arr[j]);
        ++sort_count;
      }
    }

    // If there is no reversed element, then leave the loop
    if (!rev_flag)
    {
      break;
    }
  }

  return sort_count;
}

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

  int arr[100];
  int arr_elm;
  for (int i = 0; i < n; ++i)
  {
    cin >> arr_elm;
    arr[i] = arr_elm;
  }

  int count = bubble_sort(arr, n);
  output_array(arr, n);
  cout << count << endl;

  return 0;
}



Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

ll a[10][10];

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n), odd(n, 0), even(n, 0);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		if (i) odd[i] = odd[i - 1], even[i] = even[i - 1];
		if (i % 2 == 0) even[i] += a[i];
		if (i % 2 == 1) odd[i] += a[i];
	}
	sum /= 2;
	for (int i = 0; i < n; i++) {
		ll ans = sum;
		if (i % 2 == 1) {
			if (i) ans -= odd[i - 1];
			ans -= even[n - 1] - even[i];
		} else {
			if (i) ans -= even[i - 1];
			ans -= odd[n - 1] - odd[i];
		}
		if (i) cout << " ";
		cout << ans * 2;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3712
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int p, q, r;
	cin >> p >> q >> r;
	int maxi = max(max(p, q), r);
	cout << p + q + r - maxi << endl;


	return 0;
}



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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;

    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int round=1;

    while(a>0&&c>0) {
        if(round%2==1) {
            c-=b;
        }
        else {
            a-=d;
        }
        round++;
    }

    if(c<=0) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }


}




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

int main(){
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  int ans = 0;
  rep(i,n){
    if(i < k){
      ans += x;
    }
    else{
      ans += y;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll a[2][200010] = {0};

int main(){
    int n;
    cin >> n;
    rep(i,n){
        int h;
        cin >> h;
        ll high, low;
        high = i+h;
        low = i-h;
        if(high < n){
            a[0][high] += 1;
        }
        if(0 <= low){
            a[1][low] += 1;
        }
    }
    ll ans = 0;
    rep(i,n){
        // printf("%d %d\n", a[0][i], a[1][i]);
        if(a[0][i] > 0 && a[1][i] > 0) ans += a[0][i] * a[1][i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using piii = pair<ll,pii>;

ll solve() {
    ll H, W, K;
    ll x1, y1, x2, y2;
    cin >> H >> W >> K;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    vector<string> C(H);
    for ( int i = 0; i < H; i++ ) {
        cin >> C[i];
    }
    ll INF = 1LL<<60;
    vector<vector<ll>> d(H, vector<ll>(W,INF));
    pii st(x1,y1), ed(x2,y2);

    vector<int> dx = {0, 1, 0, -1}, dy = {1, 0, -1, 0};
    priority_queue<pair<ll, pii>, vector<pair<ll, pii>>, greater<>> q;
    d[st.first][st.second] = 0;
    q.push(piii(0LL, st));
    while ( !q.empty() ) {
        auto p = q.top();
        ll c = p.first;
        int px = p.second.first, py = p.second.second;
        q.pop();
        if ( d[px][py] < c ) continue;
        for ( int ii = 0; ii < 4; ii++ ) {
            int x = px, y = py;
            for ( int j = 0; j < K; j++ ) {
                x += dx[ii], y += dy[ii];
                if ( x < 0 || x >= H || y < 0 || y >= W ) break;
                if ( C[x][y] == '@' )  break;
                if ( d[x][y] <= d[px][py] ) break;
                if ( d[x][y] > d[px][py] + 1 ) {
                    d[x][y] = d[px][py] + 1;
                    q.push(piii(d[x][y], pii(x,y)));
                }
            }
        }
    }




    ll ans = d[x2][y2];
    if ( ans == INF ) return -1;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

long long int A, a, n, m, y, s;
int N, M;
string str_1, str_2, str_3;


long long int gcd(int m, int n){
	while (true) {
		if (m%n == 0)return n;
		m %= n;
		if (n%m == 0)return m;
		n %= m;
	}
	return 0;
}



int main() {
	cin >> n >> m;
	cin >> str_1 >> str_2;

	y = gcd(n, m);
	N = n / y;
	M = m / y;
	for (int i = 0; i < y; i++) {
		if (str_1[i*N] != str_2[i*M]) {
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << n * M << '\n';
	return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    int i;
    for(i = 0; i < n/2; i++){
        if(s.at(i) != s.at(n/2 + i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string;



void main()
{
    auto nt = readln.split.map!(to!int);
    auto n = nt[0];
    auto t = nt[1];
    auto as = readln.split.to!(long[]);

    long max = 0;
    foreach_reverse (ref a; as) {
        auto tmp = a;
        a = max - a;
        if (tmp > max) max = tmp;
    }

    as.sort!"a > b";
    auto top = as[0];
    int cnt;
    foreach (a; as) {
        if (a == top)
            ++cnt;
        else
            break;
    }
    writeln(cnt);
}

Measured memory_bytes: 4532
n=int(input())
l1=[[[0 for i in range(10)]for j in range (3)]for k in range(4)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    l1[b-1][f-1][r-1]=v+l1[b-1][f-1][r-1]
#リストに入れる
    
for x in range(4):
    y=0
    for y in range(3):
        bf=l1[x][y]
        print(" "+" ".join(map(str, bf)))
        y=y+1
    if x<3:
        print("#"*20)    
        x=x+1
    else:
        break
#出力


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

using namespace std;

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

    int n;

    cin>>n;

    if(n%10==7 || (n/10)%10==7 || (n/100)%10==7)
        cout<<"Yes\n";
    else
        cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    val k = sc.nextInt()
    val h = Array(n) { sc.nextLong() }
    println(h.sortedDescending().drop(k).sum())
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 75688
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int a,b; cin>>a>>b;
    string s,t;
    rep(i,b) s.push_back('0'+a);
    rep(i,a) t.push_back('0'+b);

    if (s < t) cout << s << '\n';
    else cout << t << '\n';
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		N int
	)

	fmt.Scan(&N)

	var denominator float64
	var one float64 = 1
	for i := 0; i < N; i++ {
		var A float64
		fmt.Scan(&A)
		denominator += one / A
	}

	fmt.Println(one / denominator)
}


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

string list[32];
int res=0;
int sa[1000];

int main(){
	long long int sum=0;
	int n;
	int a[10000];
	int max=0,min=10000;
	cin >> n;
	if(n>=1){
		cin >> a[0];
		max=min=sum=a[0];
	}
	for(int i=1;i<n;i++){
		cin >> a[i];
		if(max<a[i]) max=a[i];
		if(min>a[i]) min=a[i];
		sum+=a[i];
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int x;
	cin>>x;
	x = x%10;

	switch(x){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			cout<<"hon"<<endl;
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			cout<<"pon"<<endl;
			break;
		case 3:
			cout<<"bon"<<endl;
			break;
	}
	return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 10000007 //10^9+7

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

  ll sum = 0;
  FOR(i, 1, n){
    if(i%3!=0 && i%5!=0) sum+= i;
  }
  cout<<sum<<endl;
  return 0;

}

Measured memory_bytes: 3644