akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------



int main(){
  int N;
  cin >> N;
  int p[N];
  int q[N];
  int a[N];
  rep(i,N) cin >> p[i];
  rep(i,N) cin >> q[i];
  rep(i,N) a[i] = i+1;
  ll fst = 0;
  ll snd = 0;
  ll cnt = 0;
  do{
    bool f = true;
    rep(i,N){
      if(a[i] != q[i]) f = false;
    }
    if(f) fst = cnt;

    f = true;
    rep(i,N){
      if(a[i] != p[i]) f = false;
    }
    if(f) snd = cnt;
    
    cnt++;
  }while(next_permutation(a,a+N));

  cout << abs(fst - snd) << endl;
  
  return 0;
}




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

int main(){
  int n,a,b;cin>>n>>a>>b;
  int ans=0;
  for(int i=1;i<=n;i++){
    int sum=i/10000+i%10000/1000+i%1000/100+i%100/10+i%10;
    if(a<=sum && sum<=b) ans +=i;
  }
  cout<<ans;
}

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


int triple_gcd(int a, int b, int c){
    return __gcd(__gcd(a,b),c);
}

int main(){
    int N, sum = 0;
    cin >> N;
    for(int a = 1; a <= N; a++){
        for(int b = 1; b <= N; b++){
            for(int c = 1; c <= N; c++){
                sum += triple_gcd(a, b, c);
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
 
using namespace std;
int MOD = 1000000007;

signed main(){
    int n,y;
    cin >> n >> y;
    y /= 1000;
    rep(i,n+1){
        rep(j,n+1){
            if(y-10*i-5*j == n-i-j && n-i-j >= 0 && n-i-j <= n){
                cout << i <<  " " << j <<  " " << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    

    return 0;   
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc085.contest.atcoder.jp/tasks/abc085_c
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10**9+7
ans = [0]*(k+1)
anss = 0
for i in reversed(range(1, k+1)):
  ans[i] = pow(k//i, n, mod)
  for j in range(2, k//i+1):
    ans[i] -= ans[i*j]
  anss += i*ans[i]
  anss %= mod
print(anss)

Measured memory_bytes: 11100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
	ll n; cin >> n;
	ll a, b, c;
	a = b = c = 1;
	while (n--) {
		a = a * 10 % MOD;
		b = b * 9 % MOD;
		c = c * 8 % MOD;
	}
	cout << ((a - 2 * b + c) % MOD + MOD) % MOD << '\n';
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define M 20010
using namespace std;
int h,n,dp[M],mx=-1;
vector<int> a,b;
int main(){
	int i,j,x,y;
	cin>>h>>n;
	for(i=0;i<n;i++)
	{
		cin>>x>>y;
		mx=max(mx,x);
		a.push_back(x);
		b.push_back(y);
	}
	memset(dp,63,sizeof(dp));
	dp[0]=0;
	for(i=1;i<h+mx;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[j]<=i)
			{
				dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
			}
		}
	}
	for(i=h;i<h+mx;i++)
	{
		dp[h+mx]=min(dp[h+mx],dp[i]);
	}
	cout<<dp[h+mx]<<endl;
	return 0;
}

Measured memory_bytes: 384
h = int(input())
heap = list(map(int, input().split()))
 
 
def max_heapify(a, i):
    li, ri = i * 2 + 1, i * 2 + 2
    if li < h:
        largest = li
        if ri < h and a[ri] > a[li]:
            largest = ri
        if a[largest] > a[i]:
            a[i], a[largest] = a[largest], a[i]
            max_heapify(a, largest)
 
 
def build_max_heap(a):
    for i in range((h - 1) // 2, -1, -1):
        max_heapify(a, i)
 
 
build_max_heap(heap)
 
print(' ', end='')
print(*heap)

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

int n;

int main(){
  cin >> n;
  set<int> s;
  rep(i, n){
    int a;
    cin >> a;
    if(s.find(a) == s.end()){ //見つかった
      s.insert(a);
    }else{
      s.erase(a);
    }
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 4864
N = gets.to_i
MOD = 10**9+7
col = {}
dp = [0]*(N+1)
dp[0] = 1
pc = 0
N.times do |i|
  c = gets.to_i
  if c == pc
    dp[i+1] = dp[i]
  else
    if col[c].nil?
      val = 0
      col[c] = 0
    else
      val = col[c]
    end
    dp[i+1] = dp[i] + val
    dp[i+1] %= MOD
    col[c] += dp[i]
    col[c] %= MOD
  end
  pc = c
end
p dp[N]

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

int main(){
    int N;
    cin>>N;
    multiset<int> s;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        s.insert(a);
    }
    int pow2[31];pow2[0]=1;
    for(int i=1;i<31;i++){
        pow2[i]=pow2[i-1]*2;
    }
    int ans=0;
    while(!s.empty()){
        multiset<int>::iterator it=s.end(); it--;
        int X=*it;
        s.erase(it);//自分は削除
        int tmp;
        for(int j=0;j<31;j++){
            if(X<pow2[j]){
                tmp=pow2[j]-X;
                break;
            }
        }
        multiset<int>::iterator it2=s.find(tmp);
        if(it2 != s.end()){//見つかった
            ans++;
            s.erase(it2);//ペアも削除
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ran 200020
#define i64 long long int
int n;
vector<pair<i64,pair<int,int> > > w;
i64 a[ran], d, u[ran], v[ran];
void add_edge(int x,int y){
	w.push_back(make_pair(labs(x-y)*d+a[x]+a[y], make_pair(x,y)));
}
void dfs(int s,int e){
	if(s == e)return;
	int m = (s + e)/2;
	dfs(s, m);
	dfs(m+1, e);
	int A = s, B = e;
	for(int i=s; i<=m; i++)if(u[i] < u[A])A = i;
	for(int i=m+1; i<=e; i++)if(v[i] < v[B])B = i;
	for(int i=s; i<=m; i++)add_edge(B, i);
	for(int i=m+1; i<=e; i++)add_edge(A, i);
}
int ace[ran];
int ancestor(int x){return x-ace[x]?ace[x]=ancestor(ace[x]):x;}
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> d;
	for(int i=0; i<n; i++){
		cin >> a[i];
		u[i] = a[i] - i * d;
		v[i] = a[i] + i * d;
		ace[i] = i;
	}
	dfs(0,n-1);
	sort(w.begin(),w.end());
	i64 res = 0;
	for(auto p : w){
		int x = p.second.first, y = p.second.second;
		x = ancestor(x);
		y = ancestor(y);
		if(x == y)continue;
		ace[x] = y;
		res += p.first;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 73312
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000000000000LL
#define MOD 998244353
#define F first
#define S second
#define exit dskosad
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,k;
ll get_sum(ll l,ll r)
{
    return 1LL*(l+r)*(r-l+1)/2;
}
struct node
{
    int x,y,z;
};
vector<node> ans;
int main()
{
    scanf("%lld%lld",&n,&k);
    if(get_sum(k,k+2*n-1)>get_sum(k+2*n,k+3*n-1)) {puts("-1"); return 0;}
    int x=k,y=2*n,z=k+2*n;
    while(y<=k+2*n-1&&z<=k+3*n-1)
    {
        ans.push_back((node){x,y,z});
        assert(x+y<=z);
        z+=2; x++; y++;
    }
    vector<int> has;
    while(z<=k+3*n-1)
    {
        has.push_back(z);
        z+=2;
    }
    z=k+2*n+1;
    while(z<=k+3*n-1)
    {
        has.push_back(z);
        z+=2;
    }
    sort(has.begin(),has.end());
    y=k+n;
    int now=0;
    while(x<=k+n-1)
    {
        z=has[now];
        ans.push_back((node){x,y,z});
        assert(x+y<=z);
        now++; x++; y++;
    }
    for(auto p:ans) printf("%d %d %d\n",p.x,p.y,p.z);
    return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, k;
    cin >> n >> k;
    vector<double> cumsum(n+1);
    for (int i = 0; i < n; i++) {
        double p;
        cin >> p;
        cumsum[i+1] = cumsum[i] + (1.0+p)/2.0;
    }
    double max_subsum = 0.0;
    for (int i = 0; i < n-k+1; i++) {
        max_subsum = max(cumsum[i+k] - cumsum[i], max_subsum);
    } 
    printf("%f\n", max_subsum);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    ll n, t;
    cin >> n >> t;
    vector<ll> T(n);
    rep (i, n) cin >> T[i];

    ll ans = 0;

    rrep (i, n - 1) {
        ans += min(t, T[i] - T[i - 1]);
    }

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

Measured memory_bytes: 1792
import numpy as np
from time import time
start = time()
def scoring(c,s,t):
    score = 0
    from_last = np.zeros(26)
    for i in range(s.shape[0]):
        from_last = from_last+1
        score += s[i,t[i]-1]
        from_last[t[i]-1] = 0
        score = score - (c*from_last).sum()
    return score


D = int(input())
c = list(map(int,input().split()))
s = np.empty((D,26))
for i in range(D):
    s[i,:] = np.array(list(map(int,input().split())))


t = []
for i in range(D):
    chosen = s[i,:].flatten().argmax()+ 1
    t.append(chosen)


score = scoring(c,s,t)
while time()-start < 1.75:
    i = np.random.randint(D)
    old = t[i]
    t[i] = np.random.randint(1,27)
    new_score = scoring(c,s,t)
    if new_score > score:
        score = new_score
    else:
        t[i] = old

for i in t:
	print(i)


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

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

  ll A; cin >> A;
  ll B; cin >> B;
  ll C; cin >> C;
  ll D; cin >> D;

  ll ans = A * C;
  ans = max(ans, A * D);
  ans = max(ans, B * C);
  ans = max(ans, B * D);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  int x,ans=0;
  for(int i=0;i<N;i++){
    cin>>x;
    ans+=2*min(x,K-x);
  }
  cout<<ans<<endl;
}

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

int h,w,c;
int p[10][10];

int dfs(int y,int x,int prv,int nx){
  p[y][x] = nx;
  int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};
  int res = 0;

  for(int i=0;i<4;i++){
    int ty = y+dy[i], tx = x+dx[i];
    if(ty<0 || tx<0 || h<=ty || w<=tx)continue;
    if(p[ty][tx]==prv)res += dfs(ty,tx,prv,nx);
  }
  return res + 1;
}

int rec(int n){
  if(n==5){
    if(p[0][0]!=c)return 0;
    return dfs(0,0,c,(c+1)%6+1);
  }

  int res = 0;
  int tmp[10][10];

  for(int i=1;i<=6;i++){
    if(p[0][0] == i)continue;
    for(int j=0;j<h;j++)
      for(int k=0;k<w;k++)tmp[j][k] = p[j][k];
    
    dfs(0,0,p[0][0],i);
    
    res = max(res,rec(n+1));

    for(int j=0;j<h;j++)
      for(int k=0;k<w;k++)p[j][k] = tmp[j][k];
  }
  return res;
}

int main(){
  
  while(cin >> h >> w >> c, w||h||c){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> p[i][j];

    cout << rec(0) << endl;
  }
}

Measured memory_bytes: 872
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
//#define mp map<int,int>
//#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int t;
   cin>>t;
   cout<<3*t*t<<endl;


   return 0;
}


Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<cmath>
#include<vector>
#include<assert.h>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int s=0;
	int d=min(b,c);
	s+=2*d;
	b-=d;
	c-=d;
	d=min(a,c);
	s+=d;
	a-=d;
	c-=d;
	if(c)
		s++;
	s+=b;
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 128
import sys

s = sys.stdin.readline().replace('\n','')
q = sys.stdin.readline().replace('\n','')
q = int(q)

flag = 0
prev=""
end=""
for i in range(0,q):
	str = sys.stdin.readline().replace('\n','')
        if( str[0] == '1'):
          flag += 1
        if( str[0] == '2'):
          if( str[2] == '1'):
	    if( flag % 2 == 0):
	      prev = str[4] + prev
	    else:
	      end = end + str[4]
          if( str[2] == '2'):
	    if( flag % 2 == 0):
	      end = end + str[4]
	    else:
	      prev = str[4] + prev

ss = prev + s + end
if( flag % 2 == 1):
  ss = ss[::-1]

print ss
sys.stdout.flush()

Measured memory_bytes: 11452
using System;
class test
{
	static void Main()
	{
		double debt = 100000;
		int n = int.Parse(Console.ReadLine());

		for ( int i = 0; i < n; i++ )
		{
			debt = Math.Ceiling((debt * 1.05) / 1000 ) * 1000;
		}

		Console.WriteLine(debt);
	}
}

Measured memory_bytes: 5616
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
int n,m,pos=0,a;
ll ans=0,t[100000];
int main(){
  cin>>n>>m;
  t[0]=0;
  for(int i=1;i<n;i++){
    cin>>t[i];
    t[i]+=t[i-1];
  }
  pos=0;
  for(int i=0;i<m;i++){
    cin>>a;
    ans+=abs(t[pos]-t[pos+a]);
    ans%=100000;
    pos+=a;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1944
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//const int CM = 130000, CL = 12;
//char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
char cn[2200010], * ci = cn, ct;

const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	ll tmp = *(ll*)ci;

	//うーん
	ll u_n = ((tmp & ma0) ^ ma0);
	if (!u_n) {
		ci += 8;
		while (*ci++ >= '0');
		return 1000000000;
	}
	int dig = 68 - __builtin_ctzll(u_n);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (72 - dig >> 3);
	return tmp;
}

int B[200000];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	fread(cn, 1, 2200000, stdin);
	int N = getint();

	ll kotae = 0;
	rep(i, N) {
		int a = getint();
		if (i + a < N) B[i + a]++;
		if (i - a >= 0) kotae += B[i - a];
	}
	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int prime[N],p;
bool mark[N];

void seive(int n) {
    int i,j,limit=sqrt(n+1);

    mark[1]=true;
    prime[p++]=2;
    for(i=4; i<=n; i+=2)
        mark[i]=true;

    for(i=3; i<=n; i+=2) {
        if(!mark[i]) {
            prime[p++]=i;
            if(i<=limit) {
                for(j=i*i; j<=n; j+=i*2) {
                    mark[j]=true;
                }
            }
        }
    }
}
std::vector<ll> v;
void factorize(ll n) {
    for(int i=0;i<p and prime[i]*1ll*prime[i]<=n; i++) {
        if(n%prime[i]==0) {
            v.push_back((ll)prime[i]);
            while(n%prime[i]==0) {
                n/=prime[i];
            }
        }
    }
    if(n>1) {
        v.push_back((ll)n);
    }
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    seive(N);
    int t=1,te=0;
    // cin>>t;
    while(t--){
        ll x,y;
        cin>>x>>y;

        factorize(x);

        ll res=1ll;
        for(int i=0;i<v.size();i++){
            if(y%v[i]==0){
                ++res;
            }
        }
        printf("%lld\n", res);


        //printf("Case %d: ",++te);
    }
    return 0;
}

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

int main(){
  int t;
  string s;
  cin >> s;
  if(s == "SAT")
    t = 1;
  if(s == "FRI")
    t = 2;
  if(s == "THU")
    t = 3;
  if(s == "WED")
    t = 4;
  if(s == "TUE")
    t = 5;
  if(s == "MON")
    t = 6;
  if(s == "SUN")
    t = 7;
  cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= 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 y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  string s;
  cin>>s;
  s[3]='8';
  cout<< s<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const double PI=3.14159265358979323846;
int main() {
  double r;
  cin >> r;
  printf("%.6lf\n", 2 * r * PI);
  return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
//#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
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; }

using namespace std;

int main(void)
{
    string S, T; cin >> S >> T;
    bool flag = true;
    rep(i, 0, S.size()) {
        if (S[i] != T[i]) {
            flag = false;
            break;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

    int vn = 2;

    vector<int> v(vn,0);

    for(int i = 0; i < vn; i++){
        int tmp;
        cin >> tmp;

        v[i] = tmp;
    }

    int ans;

    if(v[0] < v[1]){
        ans = 0;
    }else ans = 10;

    cout << ans << endl;
    

    return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };


int main() {
	for ( int i = 1; i < 10; i++ ) {
		for ( int j = 1; j < 10; j++ ) {
			//
			printf( "%dx%d=%d\n", i, j, i * j );
		}
	}
	return 0;
}

Measured memory_bytes: 1096
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N,M,V,P,A[100005];
long long int LEFT[100005]={},RIGHT[100005]={};

int main() {
	
	cout << fixed << setprecision(18);
	cin>>N>>M>>V>>P;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	sort(A,A+N,greater<long long int>());
	for(int i=1;i<=N;i++){
		LEFT[i]=LEFT[i-1]+A[i-1];
	}
	for(int i=N-1;i>=0;i--){
		RIGHT[i]=RIGHT[i-1]+A[i];
	}
	long long int girigirinum=A[P-1];

	long long int res=P;
	for(long long int i=P;i<N;i++){
		long long int target=A[i]+M;
		long long int TMP_V=V-(P)-(N-i-1);
		
		if(TMP_V<=0&&target>=girigirinum){res++;}
		else if(target<girigirinum){continue;}
		else{
			long long int SUM=LEFT[i]-LEFT[P-1];
			if(target*(i-P+1)-SUM>=TMP_V*M){
				res++;
			}
			//cout<<"DEBUG "<<i<<" "<<target<<" "<<i-P+1<<" "<<SUM<<" "<<TMP_V<<endl;
		}
		//cout<<"DEBUG "<<target<<" "<<TMP_V<<endl;
	}
	//cout<<girigirinum<<" ";
	cout<<res<<endl;
} 

Measured memory_bytes: 2560
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll n, ans = 0;
	cin >> n;
	vector<ll> p(n);
	rep(i, n) cin >> p.at(i);
	rep(i, n - 2) {
		if ((p.at(i) < p.at(i + 1) && p.at(i + 1) < p.at(i + 2)) || (p.at(i) > p.at(i + 1) && p.at(i + 1) > p.at(i + 2))) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import heapq

X, Y, Z, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
B = [int(x) for x in stdin.readline().rstrip().split()]
C = [int(x) for x in stdin.readline().rstrip().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

heap = []
heapq.heappush(heap, (-(A[0] + B[0] + C[0]), 0, 0, 0))
s = {(0, 0, 0)}
for _ in range(K):
    v, i, j, k = heapq.heappop(heap)
    if i + 1 < X and (i + 1, j, k) not in s:
        s.add((i + 1, j, k))
        heapq.heappush(heap, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
    if j + 1 < Y and (i, j + 1, k) not in s:
        s.add((i, j + 1, k))
        heapq.heappush(heap, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
    if k + 1 < Z and (i, j, k + 1) not in s:
        s.add((i, j, k + 1))
        heapq.heappush(heap, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
    print(-v)


Measured memory_bytes: 58716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		long A = scanner.nextLong();
		long B = scanner.nextLong();
		long K = scanner.nextLong();

		if(K >= A){
			K -= A;
			A = 0;
			if(K >= B){
				B = 0;
			}else{
				B -= K;
			}
		}else{
			A -= K;
		}
		System.out.println(A + " "  + B);
	}
}

Measured memory_bytes: 23764
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a, b) for (ll i = a; i < b; ++i)
#define rrrep(i, a, b) for (ll i = a; i >= b; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


vector<ll> v;
ll N;
ll dp[100001];

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    v.pb(1);
    for (ll i : {6, 9}) {
        v.pb(i);
        rep (k, 100000 - 1) {
            ll tmp = v.back() * i;
            if (tmp > 100000) {
                break;
            }
            v.pb(tmp);
        }
    }
    sort(all(v));
    cin >> N;
    rrep(i, 1, N + 1) {
        ll m = linf;
        for (ll j : v) {
            if (i - j < 0) break;
            m = min(m, 1 + dp[i - j]);
        }
        dp[i] = m;
    }
    cout << dp[N] << endl;
}


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

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

int main() {
    int n; cin >> n;
    int b, cnt = 0, pre_b;
    cin >> b; cnt += b; pre_b = b;
    for(int i=1; i<n-1;  i++){
        cin >> b;
        cnt += min(pre_b, b);
        pre_b = b; 
    }
    cnt += b;

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n, int r) {
//	n = n + r - 1;
//	return nCr(n, r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	double N;
	cin >> N;
	vector<double>vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());
	for (int i = 0; i < N - 1; i++) {
		vec[i + 1] = (vec[i] + vec[i + 1]) / 2;
	}
	cout << vec[N - 1] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int area = a*b;
	int length = 2*(a+b);
	System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 17156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int ans = n;

    int pos = 1;
    while(pos < n)
    {
        while(s[pos-1] == s[pos])
        {
            pos++;
        }
        int m = max(pos, n-pos);
        ans = min(ans, m);
        pos++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	static public void main(String args[]){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		long aa=1L;
		for(int i=0;i<n;i++){
			long a=sc.nextLong();
			if(Math.log10(a)+Math.log10(aa)>18||
			aa*a>1000000000000000000L){
			  
				aa=-1;
			}
			else if(a==0){
				aa*=0;
              System.out.println(0);
              return;
			}
			else if(aa!=-1){
				aa*=a;
			}
		}
		System.out.println(aa);
	}
}



Measured memory_bytes: 59512
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll x;
	cin >> x;

	cout << !x << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n,k,l,r;
  cin >> n >> k >> l >>r;

  ll a[n];
  for(ll i=0;i<n;i++)cin >> a[i];
  vector<vector<ll>> v1(21),v2(21);

  if(n<=20){
    ll s=0;
    for(ll i=0;i<(1<<n);i++){
      if(__builtin_popcount(i)!=k)continue;
      ll c=0;
      for(ll j=0;j<n;j++)if(i & (1<<j))c+=a[j];
      if(c>=l && c<=r)s++;
    }
    cout << s << endl;
  }
  else{
    for(ll i=0;i<(1<<20);i++){
      ll p=__builtin_popcount(i);
      ll c=0;
      for(ll j=0;j<20;j++)if(i & (1<<j))c+=a[j];
      v1[p].push_back(c);
    }
    //cout << 5 << endl;
    for(ll i=0;i<(1<<(n-20));i++){
      ll p=__builtin_popcount(i);
      ll c=0;
      for(ll j=0;j<n-20;j++)if(i & (1<<j))c+=a[j+20];
      v2[p].push_back(c);
      //cout << i << endl;
    }
    //cout << 5 << endl;
    for(ll i=0;i<21;i++)sort(v2[i].begin(),v2[i].end());
    ll s=0;
    //cout << 5 << endl;
    for(ll i=0;i<21;i++){
      if(i>k)continue;
      if(k-i>20)continue;
      for(ll j=0;j<v1[i].size();j++){
        ll b=upper_bound(v2[k-i].begin(),v2[k-i].end(),r-v1[i][j])-lower_bound(v2[k-i].begin(),v2[k-i].end(),l-v1[i][j]);
        if(b>=1)s+=b;
      }
    }
    cout << s << endl;
  }


}


Measured memory_bytes: 23420
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};


int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    bool check = true;
    rep(i,n) {
        if (a[i]%2==0) {
            if (a[i]%3!=0 && a[i]%5!=0) {
                check = false;
                break;
            }
        }
    }
    if (check) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}    

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  long int N;
  std::cin >> N;

  long int min_count;
  for (long int i = 1; i <= sqrt(N); i++) {
    if (N%i == 0) {
      min_count = i + (N/i) - 2;
    }
  }
  cout << min_count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=305;
int a[maxn];
int dp[maxn][maxn]={};
const int inf=1e18;
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;++i){
        cin>>a[i];
    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j)
            dp[i][j]=inf;
    }
    for(int i=1;i<=n;++i){
        dp[i][1]=a[i];
    }
    for(int i=1;i<=n;++i){
        for(int j=2;j<=n;++j){
            for(int k=1;k<=i-1;++k){
                dp[i][j]=min(dp[i][j],dp[k][j-1]+max(0ll,a[i]-a[k]));
            }
        }
    }
    int mi=inf;
    for(int i=1;i<=n;++i){
        mi=min(mi,dp[i][n-k]);
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif
const int MAXN=1000000;

int main(){
  fastIO();
  vector<vector<int>>prime(MAXN+5);
  for(int i=2;i<=MAXN;i++){
    for(int j=i;j<=MAXN;j+=i){
      prime[j].push_back(i);
    }
  }
  int n,val,g=0;
  cin>>n;
  map<int,int>rep;
  bool pairwise=true,setwise=false;
  for(int i=0;i<n;i++){
    cin>>val;
    g=__gcd(g,val);
    for(int j=0;j<prime[val].size()&&pairwise;j++){
      if(rep[prime[val][j]]>0)pairwise=false;
      rep[prime[val][j]]++;
    }
  }
  setwise=(g==1);
  if(pairwise){
    cout<<"pairwise coprime"<<endl;
  }else if(setwise){
    cout<<"setwise coprime"<<endl;
  }else{
    cout<<"not coprime"<<endl;
  }
  return 0;
}


Measured memory_bytes: 117252
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

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

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


int main()
{
  ll n;
  cin>>n;
  if(n%10==9||n>=90){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            int D = in.nextInt();
            System.out.println(Math.max(A * B, C * D));
        }
    }
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			if (vs[0] + vs[1] + vs[2] >= 22) {
				Console.WriteLine("bust");
			} else {
				Console.WriteLine("win");
			}



			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
const ll INF = 1ll<<60;
const ll Max = 2500;
vector<vector<ll>> dp(50,vector<ll>(Max+1,(1ll<<60)));
//2020-07-03 05:32:32
//writer SakaTaku
//Dijkstra法   O(|E|log|V|)
struct Edge {ll to; ll cost; ll fare;};
typedef pair<ll, ll> P;
typedef pair<P, ll> Pl;
ll V;
vector<ll> C, D;
struct Dijkstra {
   int V;
   vector<vector<Edge>> G;
   Dijkstra(ll V):V(V),G(V){}
   void add(ll v, ll w, ll cost, ll fare){
      Edge e;
      e.to = w; e.cost = cost; e.fare = fare;
      G[v].push_back(e);
   }
   ll inf = (1ll<<60);
   vector<ll> d;
   void solve(int s){
      priority_queue<Pl, vector<Pl>, greater<Pl>> pq;
      d = vector<ll>(V,inf);
      dp[0][s] = 0;
      pq.push({{0,s},0});
      while (!pq.empty()){
         Pl p = pq.top(); pq.pop();
         ll next = p.second;
         ll nows = p.first.second;
         ll nowcost = p.first.first;
         for (auto &&e : G[next]){
            if (e.fare <= nows){
               if (dp[e.to][nows-e.fare] > nowcost+e.cost){
                  dp[e.to][nows-e.fare] = nowcost+e.cost;
                  pq.push({{nowcost+e.cost,nows-e.fare},e.to});
               }
            }
         }
         if (dp[next][min(Max,nows+C[p.second])] > nowcost + D[next]){
            dp[p.second][min(Max,nows+C[p.second])]=p.first.first + D[p.second];
            pq.push({{p.first.first+D[p.second],min(Max,nows+C[p.second])},p.second});
         }
      }
   }
}; 
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll n, m, s; cin >> n >> m >> s;
   s = min(s, Max);
   Dijkstra di(n);
   rep(i,m){
      ll u, v, a, b; 
      cin >> u >> v >> a >> b;
      u--;v--;
      di.add(u, v, b, a);
      di.add(v, u, b, a);
   }
   rep(i,n){
      ll c, d; cin >> c >> d;
      C.push_back(c); D.push_back(d);
   }
   di.solve(s);
   for (int i = 1; i < n; i++){
      ll ans = INF;
      for (int j = 0; j < 2501; j++)
         ans = min(ans, dp[i][j]);
      cout << ans << "\n";
   }
}

Measured memory_bytes: 7228
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x=0,ma=0,n;
	char id;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>id;
		if(id=='I'){
			x++;
		}
		else{
			x--;
		}
		ma=max(x,ma);
	}
	cout<<ma<<endl;
}

Measured memory_bytes: 256
from itertools import *
n=int(input())
sumA=[0]+list(accumulate(map(int,input().split())))
def check(l,m,r):
    if m==r:return False
    tmp=sumA[r]+sumA[l]
    return abs(tmp-sumA[m+1]*2)<abs(tmp-sumA[m]*2)
res=float('inf')
li,ri=1,3
for mid in range(2,n-1):
    while check(0,li,mid):li+=1
    while check(mid,ri,n):ri+=1
    x=sorted([sumA[li],sumA[mid]-sumA[li],sumA[ri]-sumA[mid],sumA[n]-sumA[ri]])
    tmp=x[3]-x[0]
    if tmp<res:res=tmp
print(res)

Measured memory_bytes: 25972
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
int main() {
    ll N;
    cin >> N;

    vector<ll> scores(N);
    ll sum = 0;
    for (ll i = 0; i < N; ++i) {
        cin >> scores[i];
        sum += scores[i];
    }

    sort(scores.begin(), scores.end());
    if (sum % 10 == 0) {
        for (ll i = 0; i < N; ++i) {
            if (scores[i] % 10 != 0) {
                sum -= scores[i];
                break;
            }
        }
    }

    if (sum % 10 != 0) {
        cout << sum << "\n";
    } else {
        cout << 0 << "\n";
    }

    return 0;
}

Measured memory_bytes: 3600
import math
N, D = map(int, input().split())

X_list = list(list(map(int, input().split())) for _ in range(N))

# print(X_list)

ans = 0
for i in range(N-1):
    for j in range(N-i-1):
        double_s = 0
        S = 0
        for k in range(D):
            double_s += (X_list[i][k] - X_list[j+i+1][k]) ** 2

        S = math.sqrt(double_s)
        # print('SSSSS:', S)
        if(abs(S - int(S)) == 0):
            ans += 1


# S = math.sqrt(2**2)
# v = S - int(S)
# print(S - int(S))
# if(v > 0):
#     print('sss')

print(ans)


Measured memory_bytes: 3064