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

using namespace std;

typedef long long ll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define mp make_pair
#define pb push_back
#define all(name) (name.begin(), name.end())
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod);
#define mod_in(a) power(a, mod-2)
#define ncr(n, r) ((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod)
#define deb(x) cout << #x << " " << x << endl;

class Dsu {
	vector<int> drr;
	vector<int> size_arr;
	public :
	Dsu (int n) {
		rep(i, 0, n+1){
			drr.pb(i);
			size_arr.pb(1);
		}
	}

	int f_p (int a) {
		return drr[a] == a ? a : f_p(drr[a]);
	}

	ll size (int a) {
		return (ll)size_arr[f_p(a)];
	}

	void uni(int a, int b) {
		int ap = f_p(a);
		int bp = f_p(b);
		if(ap == bp)return;
		if(!(size_arr[ap] > size_arr[bp]))swap(ap,bp);
		drr[bp] = ap;
		size_arr[ap] += size_arr[bp];
	}
};



vector<ll> ft(1, 1LL);
vector<bool> is_prime(1000000, 1);

void sieve();
ll power(ll x, ll y);
int ch(string s, int a){
    int f = 1;
    for(int i = 0; i < a/2; i++){
        if(s[i] != s[a-i-1])return 0;
    }
    return 1;

}
int main()
{
    cout << fixed;
    cout << setprecision(9);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		ll ans = 0, n;
        cin >> n;
        ll arr[2*(int)1e5+10] = {0}, brr[n];
        rep(i, 0, n){
            int a;
            cin >> a;
            brr[i] = a;
            arr[a]++;
        }
        rep(i, 0, 2*(int)1e5+1)ans += (arr[i]*arr[i] - arr[i])/2;
        rep(i, 0, n){
            cout << ans - arr[brr[i]] + 1 << endl;
        }
	}
}
//
//
//
//
//
//important funct
ll power(ll x, ll y) {
    ll res = 1;x %= mod;
    while (y > 0) {
        if (y & 1)res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
void sieve(){
	is_prime[0] = is_prime[1] = 0;
	for(int i = 2; i*i <= 1000000; i++)
		if(is_prime[i])
			repc(j, i*i, 1000000, i)is_prime[j] = 0;
}

Measured memory_bytes: 5888
from collections import defaultdict

def prime(n): #O(√n)で素因数分解結果を返す
    dic = defaultdict(int)
    i=2
    while i*i<=n:
        while n%i==0:
            n//=i
            dic[i]+=1
        i+=1
    if n!=1: dic[n]=1
    return dict(dic)

n=int(input())
dic=defaultdict(int)
for i in range(n):
    temp=prime(i+1)
    for key in temp.keys():
        dic[key]+=temp[key]

ans,mod=1,10**9+7
for val in dic.values():
    ans=ans*(val+1)%mod
print(ans)

Measured memory_bytes: 9184
require 'set'
class ListNode
    def initialize(val)
        @val = val
    end
    def link(v)
        self.next = v
        v.prev = self
    end
    attr_reader :val
    attr_accessor :next, :prev
end
n, m, q = gets.split.map(&:to_i)
nodes = (0..n-1).map {|i| ListNode.new(i)}
nodes.each_cons(2) {|u, v| u.link(v)}
nodes[-1].link(nodes[0])
v = nodes[0]
gets.split.map(&:to_i).each do |a|
    if a.even?
        a.times { v = v.next }
    else
        a.times { v = v.prev }
    end
    u = v.prev
    w = v.next
    u.link(w)
    v = w
end
rest = Set[v.val]
v0 = v
v = v.next
until v == v0
    rest << v.val
    v = v.next
end
gets.split.map(&:to_i).each do |q|
    puts rest.include?(q) ? ?1 : ?0
end


Measured memory_bytes: 28812
#include<stdio.h>

int main()
{
	int l=0;
	char S[15] = {""};
	scanf("%s",S);
	for(int i=0;i<15;i++)
	{
		if (S[i] == '\0')break;
		if (S[i] == 'x')l++;
	}
	printf("%s",(l < 8) ? ("YES") : ("NO"));
	
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int h, w, n;
	cin >> h >> w >> n;
	int grid1[h*w];
	int c = 0;
	REP(i, n){
		int x;
		cin >> x;
		FOR(j, c, c+x) grid1[j] = i+1;
		c += x;
	}
	REP(i, h){
		if(i % 2 == 0){
			REP(j, w){
				cout << grid1[i * w + j];
				if(j != w-1) cout << " ";
			}
		}
		else{
			REP(j, w){
				cout << grid1[(i+1) * w - j - 1];
				if(j != w-1) cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int a, b;
	cin >> a >> b;
	if ((a * b) % 2 == 0) cout << "No\n";
	else cout << "Yes\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n,a,max=0,min=1001;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a;
		if(a > max) max = a;
		if(a < min) min = a;
	}
	cout << max - min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define abs(x) ((x) < 0 ? -(x) : (x))

int main() {
    int n; cin >> n;
    int t, a; cin >> t >> a;
    vector<int> h(n);
    for (auto &hi: h) cin >> hi;
    vector<double> diff(n);
    for (int i = 0; i < n; i++) diff[i] = abs(t - h[i] * 0.006 - a);
    cout << min_element(begin(diff), end(diff)) - begin(diff) + 1 << endl;
    return 0;
}


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

using namespace std;

//kai
int main(void){
  long long N;
  long long counter=0;
  long long tmp,g;

  cin >> N;
  //割り算が一度もない場合N%K=1であればいい
  //これを全探索するとO(N)だが、
  //N-1の約数のうち1でないものを探せばよく、これはO(sqrtN)
  for(long long i=1;i*i<=N-1;i++){
    if((N-1)%i==0){
      if(i != 1){
        counter++;
      }
      if(i != (N-1)/i){
        counter++;
      }
    }
  }
  // for(long long i=1;i<=sqrt(N-1);i++){
  //   if(i==1){
  //     counter++; //N-1の分
  //   }else if((N-1) == i*i){
  //     counter++;
  //     // cout << "first: " << i << endl;
  //   }else if((N-1)%i == 0){
  //     counter+=2;
  //     // cout << "first: " << i << endl;
  //   }
  // }

  //割り算を一度以上する場合
  //そのようなKはNの約数 - O(sqrtN)
  //その後確約数ごとに割りまくって余りを出す
  vector<long long> yakusu;
  for(long long i=1;i*i<=N;i++){
    if(N%i==0){
      if(i!=1){
        yakusu.push_back(i);
      }
      if(i!=N/i){
        yakusu.push_back(N/i);
      }
    }
  }
  // for(long long i=1;i<=sqrt(N);i++){
  //   if(N == i*i) yakusu.push_back(i);
  //   else if(N%i == 0){
  //     yakusu.push_back(i);
  //     yakusu.push_back(N/i);
  //   }
  // }
  for(auto itr=yakusu.begin();itr!=yakusu.end();itr++){
    g=*itr;
    tmp=N/g;
    while(tmp%g==0){
        tmp /= g;
    }
    if(tmp%g==1){
      counter++;
    }
  }

  cout << counter << endl;

  return 0;
}

//TLE
// int main(void){
//   long long N,tmp;
//   long long counter=0;

//   cin >> N;

//   for(long long k=N;k>1;k--){
//     tmp = N;
//     while(tmp>=k){
//       // cout << "tmp%k:" << tmp%k << endl;
//       if(tmp%k==0){
//         tmp /= k;
//         // cout << "tmp:" << tmp << " k:" << k << endl;
//       }
//       else{
//         tmp %= k;
//         break;
//       }
//       // cout << "tmp:" << tmp << " k:" << k << endl;
//     }
//     if(tmp==1) counter++;
//   }

//   cout << counter << endl;

//   return 0;
// }

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first 
#define S second 
#define MAX 10000003 
ll prime[MAX]; 
unordered_map<ll, ll> max_map; 
  
// Function to return a^n 
ll power(ll a, ll n) 
{ 
    if (n == 0) 
        return 1; 
    ll p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 

void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (ll i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (ll j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 

ll lcmModuloM(const ll* ar, ll n) 
{ 
  
    for (ll i = 0; i < n; i++) { 
        ll num = ar[i]; 
        unordered_map<ll, ll> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            ll factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    ll ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.F, it.S)) % mod; 
    } 
  
    return ans; 
} 

ll modpow(ll x,ll y)
{
	ll res=1;
	x=x%mod;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%mod;
		x=(x*x)%mod;
		y>>=1;
	}
	return res;
}

ll modpowinv(ll n)
{
	return modpow(n,mod-2);
}

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

	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	sieve();
	ll l=lcmModuloM(a,n);
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		ans=(ans+modpowinv(a[i]))%mod;
	}
	ans=(ans*l)%mod;
	cout<<ans%mod<<'\n';
	// cout<<lcm(12,8)<<endl;
}


Measured memory_bytes: 78848
#include <iostream>
#include<iomanip>
#include <climits>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;

long long sqrt(int N){
    for(long long i = 0; i < N; i++){
        if(i * i > N){
            return i - 1;
        }
    }
    return -1;
}
int main(){
    long long N;
    cin >> N;

    long long sqrt_N = sqrt(N);
    long long ans = 0;
    for(long long i = sqrt_N + 1; i >= 1; i--){
        if(N % i == 0 && N / i > 1){
            long long m = N / i - 1;
            if(N / m  == N % m){
                ans += m;
            } 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
// driver code 
int main() 
{ 
    int n, q;
    cin >> n >> q;
    int a[n];
    int i;
    for(i=0;i<n;i++)
        cin >> a[i];
    Query queries[q]; 
    for(i=0;i<q;i++)
    {
        int l, r;
        cin >> l >> r;
        l--, r--;
        queries[i].l = l, queries[i].r = r, queries[i].idx = i;
    }
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 

Measured memory_bytes: 19372
#include<iostream>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

// pair 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const pair<T,S>& p){
  cout << "(" << p.first << "," << p.second << ")";
  return os;
}

// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}

int update(int a,int b,set<int>& active,map<int,int>& cnt,vector<int>& cost,int x){
  int w=cost.size()-1;
  if(df){
    print(a,b);
    print("set:",active);
    print("cnt:",cnt);
    print("cost:",cost);
  }
  if(cnt.size()==0) return -1;
  auto itr=active.upper_bound(b);
  if(itr!=active.begin()){
    itr--;
    while((*itr)>=a){
      int cst=cost[*itr];
      cost[*itr]=-1; 
      if((--cnt[cst])==0) cnt.erase(cst);
      cst+=b-(*itr)+1;
      //      if(df)print(cst,b+1,"<?",w);
      if(b+1<w){
        if(df)print(active.count(b+1));
        if(active.count(b+1)==0 or cst<cost[b+1]){
          if(cst<cost[b+1] and (--cnt[cost[b+1]])==0) cnt.erase(cost[b+1]);
          cost[b+1]=cst;
          cnt[cst]++;
          active.insert(b+1);
        }
      }
      itr=active.erase(itr);
      if(itr==active.begin())break;
      itr--;
      if(df)print(*itr);
    }
  }
  if(cnt.size()==0) return -1;
  return (cnt.begin()->first)+x;
}


int main(){
  li h,w; cin >>h >>w;
  
  set<int> active;
  rep(i,w)active.insert(i);
  map<int,int> cnt;
  cnt[0]=w;
  vector<int> cost(w+1,0); // (cost)
  cost[w]=-1;
  rep(i,h){
    int a,b; cin >>a >>b; a--; b--;
    print(update(a,b,active,cnt,cost,i+1));
  }
  
}


Measured memory_bytes: 13484
#include <iostream>
#include <numeric>

typedef long long ll;

using namespace std;

ll gcd(ll x, ll y) {
    if(x<y) return gcd(y,x);
    ll r;
    while(r=x%y) {
        x=y;
        y=r;
    }
    return y;
}

ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    cout << 
    b - b/c - b/d + b/lcm(d,c) - a + a/c + a/d - a/lcm(d,c)
    << endl;

    return 0;
}



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

#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define haha(j,a,n) for(ll j=a;j<n;i++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define sott(a) sort(a.begin(),a.end())
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ios	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(ll a, ll b){if(b==0) return a; else return gcd(b,a%b);}
int main(){
    ios
    ll n; cin>>n;
    vl v(n);
    rep(i,n) cin>>v[i];
    vl dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(v[0]-v[1]);
    haha(i,2,n){
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
 
int main(){
    fast 
    int n;cin>>n;
    ll temp=0;
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        temp=temp^a[i];
    }
    for(int i=0;i<n;i++){
        cout<<(ll)(a[i]^temp)<<" ";
    }
    
    return 0;
}

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

int main() {
  int N, M, count;
  cin >> N >> M;
  vector<vector<int>> vec_in (M, vector<int>(2));//入力配列
  
  //入力
  for (int i=0; i<M; i++) {
    for (int j=0; j<2; j++) {
      cin >> vec_in.at(i).at(j);
    }
  }
  
  //都市番号判定
  for (int i=1; i<N+1; i++) {
    count=0;
    for (int m=0; m<M; m++) {
      for (int n=0; n<2; n++) {
        if (i==vec_in.at(m).at(n)) {
          count++;
        }
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    rep(i,0,n){
        int p;
        cin>>p;
        p--;
        vec[p]=i;
    }
    
    int ans=n;
    int now=1;
    rep(i,0,n-1){
        if(vec[i]>vec[i+1]){
            ans=min(ans,n-now);
            now=1;
        }
        else{
            now++;
        }
    }
    ans=min(ans,n-now);
    cout<<ans<<endl;
}


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

int main()
{
	int N;
	int n;
	int x = 800;
	int y = 200;
	cin >> N;
	n = N / 15;
	if (N >= 15)
		cout << (N*x) - (y*n);
	else
		cout << x*N;
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int x = 0;
	scanf("%d", &x);
	switch(x) {
	case 7:
	case 5:
	case 3:
		printf("YES");
		break;
	default:
		printf("NO");
		break;
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	int n;
	cin>>n;
	vi vec(n);
	rep(i,0,n) cin>>vec[i];
	Sort(vec);
	int ans=0;
	for(int i=0;i<=n-3;i++){
		for(int j=i+1;j<=n-2;j++){
			int sum=vec[i]+vec[j];
			auto it=lower_bound(all(vec),sum);
			int ind=it-vec.begin();
			ans+=(ind-j-1);
		//	cout<<ans<<" ";
		}
	}//cout<<endl;
	cout<<ans;
 
 
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}



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


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

    int dp[50];
    dp[0]=dp[1]=1;
    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    cout << dp[n] << endl;
    
    return 0;
}




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

int main()
{
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    int p[n];
    for (int i = 0; i < n;i++)
    {
        cin >> p[i];
    }
    sort(p, p + n);
    int a = 0;
    for (int i = 0; i < k;i++)
    {
        a += p[i];
    }
    cout << a;
    return 0;
}




Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
using namespace std;

const char ch[6] = {"KIHBR"};
char s[60], ss[60];
bool f[2010];
int cnt, sum;

int main()
{
	scanf("%s", s); int l = strlen(s);
	f['A'] = 1; f['K'] = 1; f['I'] = 1; f['H'] = 1; f['B'] = 1; f['R'] = 1;
	for (int i = 0; i < l; i ++){
		if (!f[s[i]]){
			puts("NO");
			return 0;
		} else {
			if (s[i] == 'A') cnt ++;
			else f[s[i]] = 0, sum ++;
		}
	}
	if (sum < 5 || cnt > 4){
		puts("NO");
		return 0;
	}
	int m = 0;
	for (int i = 0; i < l; i ++){
		if (s[i] == 'A'){
			if (i == 0 || i == l-1) continue;
			if (s[i-1] == 'H' && s[i+1] == 'B') continue;
			if (s[i-1] == 'B' && s[i+1] == 'R') continue;
			puts("NO");
			return 0;
		} else ss[m ++] = s[i];
	}
	ss[m] = '\0';
	if (ss[0] == 'K' && ss[1] == 'I' && ss[2] == 'H' && ss[3] == 'B' && ss[4] == 'R') puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;






void solve(){
    int a, b, k, f = 0;
    cin>>k>>a>>b;
    for(int i = k; i <= b; i+=k){
        if(i >= a && i <= b){f = 1;break;}
    }
    if(f == 1)cout<<"OK\n";
    else cout<<"NG\n";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 1010;
typedef long long ll;
const int mod = 1e9 + 7;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int fac[maxn], ifac[maxn], inv[maxn];
int dp[maxn];
int n, a, b, c, d;
inline int C(int x,int y) {
	return (ll) fac[x] * ifac[x - y] % mod * ifac[y] % mod;
}
std::map<int, int> map[maxn][maxn];
inline int calc(int n,int x,int c) {
	if(!c) return 1;
	if(map[n][x].count(c)) return map[n][x][c];
	return map[n][x][c] = (ll) calc(n - x, x, c - 1) * C(n, x) % mod;
}
int main() {
	fac[0] = ifac[0] = fac[1] = ifac[1] = inv[1] = 1;
	for(int i = 2;i < maxn;++i) {
		inv[i] = ll(mod - mod / i) * inv[mod % i] % mod;
		fac[i] = (ll) fac[i - 1] * i % mod;
		ifac[i] = (ll) ifac[i - 1] * inv[i] % mod;
	}
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> a >> b >> c >> d;
	dp[0] = 1;
	rep(i, a, b) {
		for(int j = n;j >= i * c;--j) {
			for(int k = c;k <= d && i * k <= j;++k) {
				dp[j] = (dp[j] + (ll) dp[j - k * i] * calc(n - j + k * i, i, k) % mod * ifac[k]) % mod;
			}
		}
	}
	cout << dp[n] << '\n';
}


Measured memory_bytes: 202240
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;


void solve(long long N, std::vector<long long> a){
    vector <bool> used(N, false);
    ll pushed=0, cnt=0;
    for (ll i = 0; i < N; i++) {
        cnt++;
        pushed = a[pushed] - 1;
        if(pushed == 1){break;}
        if(used[pushed]==true){cnt=-1;break;}
        used[pushed] = true;
    }
    cout << cnt << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
	int n;
	char s[4000];
	long long int r=0,g=0,b=0,sum,dis=0;
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=0;i<n;i++){
		if(s[i]=='R'){
			r+=1;
		}else if(s[i]=='G'){
			g+=1;
		}else{
			b+=1;
		}
	}
	sum=r*g*b;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			if(s[i]!=s[j]){
				if(2*j-i<n&&s[2*j-i]!=s[j]&&s[2*j-i]!=s[i]){
					dis+=1;
				}
			}
		}
	}
	printf("%lld",sum-dis);
}


Measured memory_bytes: 1736
N, K = map(int, input().split())

MOD = 10 ** 9 + 7

ans = 0
for k in range(K, N + 2):
    first = k * (k - 1) / 2
    final = (N*2-k+1) * k / 2
    add = final - first + 1
    ans = (ans + add) % MOD

print(int(ans))

Measured memory_bytes: 9192
// 解説動画

#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
static const int MOD = 10000007;
static const int MAX = 100005;


int N;
vector<int> S;


void printvec(vector<int> V) {
  rep(i, V.size()) {
    cout << V[i] << " ";
  }
  cout << endl;
}

int main(){
  cin >> N;
  int M = (1 << N );
  vector<int> A(M);
  rep(i,M) cin >> A[i];
  sort(A.begin(), A.end());
  vector<int> s;
  s.push_back(A.back());
  A.back() = -1; // -1 is assgined to used elements
  rep(i,N) {
    vector<int> p = s;
    sort(p.begin(), p.end());
    int ai = M-1;
    while( p.size() > 0 && ai >= 0 ) {
      if (A[ai] == -1) {
        --ai; continue;
      }
      if(A[ai] < p.back()) {
        s.push_back(A[ai]);
        p.pop_back(); // 末尾要素の削除
        A[ai] = -1;
      }
      --ai;
    }
    if (p.size() > 0) { // pの全ての要素に対応するunused elementsが見つからなかった
      puts("No");
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int main(){
  int A[3][3],N,b[N];
  for(int i=0; i<3; i++)
    for(int j=0; j<3; j++) cin>>A[i][j];
  cin>>N;
  for(int r=0; r<N; r++){
    int b;
    cin>>b;
    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        if(A[i][j]==b) A[i][j]=-1;
      }
    }
  }
  for(int i=0;i<3;i++){
    if(A[i][0]+A[i][1]+A[i][2]==-3){
      cout<<"Yes"<<endl;
      return 0;
    }
    if(A[0][i]+A[1][i]+A[2][i]==-3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(A[0][0]+A[1][1]+A[2][2]==-3||A[0][2]+A[1][1]+A[2][0]==-3){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}

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

int main()
{
    std::vector<long long> a(3);
    for (int i = 0; i < 3; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end());

    if (a[0] % 2 && a[1] % 2 && a[2] % 2) {
        std::cout << a[1] * a[0] << std::endl;
    } else {
        std::cout << 0 << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  char s[101];
  cin >> s;
  int a[26]={};
  for(int i=0; i<strlen(s); i++){
    a[s[i]-'a']++;
  }
  for(int i=0; i<26; i++){
    if(a[i]%2!=0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
prev = (0,0)
prev_t = 0
for i in range(N):
    t,x,y= map(int, input().split())
    manhattan = abs(prev[0]-x) + abs(prev[1]-y)
    if manhattan%2 != (t-prev_t)%2:
        print("No")
        exit()
    if manhattan > (t-prev_t):
        print("No")
        exit()
    prev = (x,y)
    prev_t = t
print("Yes")

        

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int value, source_value, count = 0;

		cin >> source_value;
		value = source_value;

		while (value >= 10) {
			count++;

			string str = to_string(value);
			int len = str.size(), max = 0;

			for (int j = 1; j < len; j++) {
				int temp1, temp2;

				temp1 = stoi(str.substr(0, j));
				temp2 = stoi(str.substr(j));

				if (max < temp1 * temp2) {
					max = temp1 * temp2;
				}
			}

			value = max;

			if (value == source_value) {
				cout << -1 << endl;
				goto TO;
			}
		}

		cout << count << endl;
	TO:;
	}

	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  string S;
  cin>>S;
  int a=0,b=0;
  rep(i,S.size()){
    if(S[i]=='A') a++;
    else b++;
  }
  if(a>0&&b>0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int now = -1, cnt = 0;
    int ans = 0;
    sort(all(a));
    rep(i, 0, n){
        if(now == -1){
            now = a[i] + k;
            ans++;
            cnt = 1;
        }else if(a[i] <= now && cnt < c){
            cnt++;
        }else{
            now = a[i] + k;
            ans++;
            cnt = 1;
        }
        // cout << now << " " << cnt << endl;
    }
    o(ans);
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX / 10;
const ll LINF = LLONG_MAX / 10;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n;
	cin >> n;
	int k = 0;
	while (k < n) {
		k += 1000;
	}
	cout << k - n << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>

int main() {
    int h, w;

    std::cin >> h >> w;

    std::vector<std::vector<char> > v(h, std::vector<char>(w));

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            std::cin >> v[i][j];
        }
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i == 0 && j == 0) continue;
            if (v[i][j] == '#') {
                bool in = false, out = false;
                if (!((i > 0 && v[i - 1][j] == '#') && (j > 0 && v[i][j - 1] == '#')) &&
                    !((i > 0 && v[i - 1][j] == '.') && (j > 0 && v[i][j - 1] == '.'))) in = true;
                if (!((i + 1 < h && v[i + 1][j] == '#') && (j + 1 < w && v[i][j + 1] == '#')) &&
                    !((i + 1 < h && v[i + 1][j] == '.') && (j + 1 < w && v[i][j + 1] == '.'))) out = true;

                if (!(in && out)) {
                    std::cout << "Impossible" << std::endl;
                    return 0;
                }
            }
        }
    }

    std::cout << "Possible" << std::endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

int main(){
	int N;
	cin >> N;
	int A[N],B[N],C[N-1];
	REP(i,N)cin>>A[i];
	REP(i,N)cin>>B[i];
	REP(i,N-1)cin>>C[i];
	int ANS=0;
	REP(i,N){
        ANS+=B[A[i]-1];
        if(i!=0&&A[i]==A[i-1]+1)
        	ANS+=C[A[i]-2];
    }
    cout<<ANS<<endl;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int pass = 0;
  int count = 0;
  
  REP(i, n) {
    switch(s[i]) {
      case 'a':
        if (pass < a + b) {
          yes;
          ++pass;
        } else
          no;
        break;
        
      case 'b':
        ++count;
        if (pass < a + b && count <= b) {
          yes;
          ++pass;
        } else
          no;
        break;
        
      default:
        no;
        break;
    }
  }
  
  return 0;
}


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

using namespace std;

int main(){
        int n;
        cin >> n;
        vector<int>a(n);
        double count=0;
        for(int i=0;i<n;i++){
                cin>>a[i];
                if(a[i]%4==0)count++;
                else if(a[i]%2==0)count+=0.5;
        }
        if(n/2<=count)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main()
{
	int N, D;

	cin >> N >> D;

	int ans = ceil((1.f * N) / (D * 2 + 1));

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
//RangeMinimumQuery
//SegTree
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A&lang=jp
// https://www.slideshare.net/iwiwi/ss-3578491 解説
#include<bits/stdc++.h>
#define INF 2147483647
#define MAX_N 100000
#define MAX_Q 100000
using namespace std;

int n, q;
int dat[MAX_N*4];

//すべてのノードをINFで初期化
void init(){
    for(int i = 0; i < 2*n - 1; i++) dat[i] = INF;
}


//a[i] を x に変更
void update(int i, int x){
    i += n - 1;
    dat[i] = x;

    //登りながら探索
    while(i > 0){
        i = (i - 1) / 2;
        dat[i] = min(dat[2*i + 1], dat[2*i + 2]);
    }
}


//区間[a, b)の最小値を返す
int find(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return INF;
    else if(a <= l && r <= b) return dat[k];
    else{
        int vl = find(a, b, k * 2 + 1, l, (l + r)/2);
        int vr = find(a, b, k * 2 + 2, (l + r)/2, r);
        return min(vl, vr);
    }
}

int main(){

    cin >> n >> q;
    
    vector<int> POW(20);
    POW[0] = 1;

    for(int i = 1; i < 20; i++){
        POW[i] = POW[i-1]*2;
    }

    //n以上平方数と置換
    n = *lower_bound(POW.begin(), POW.end(), n);
    init();

    //cout << find(0, n, 0, 0, n) << endl;

    for(int i = 0; i < q; i++){
        int com, x, y; cin >> com >> x >> y;

        if(com == 0) update(x, y);
        else cout << find(x, y + 1, 0, 0, n) << endl;
    }

    
    //cout << find(0, n, 0, 0, n) << endl;
    
    return 0;
}


Measured memory_bytes: 4100
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false
	


bool template_matching(vector<string>& A, vector<string>& B, int i, int j) {
	int N = A.size();
	int M = B.size();

	for (int k = 0; k < M; k++) {
		for (int l = 0; l < M; l++) {
			if (A[k + i][l + j] != B[k][l]) return fake;
		}
	}
	return true;
}

int main() {
	int N, M;
	cin >> N >> M;

	vector<string> A(N), B(M);
	REP(i, N) cin >> A[i];
	REP(i, M) cin >> B[i];

	int d = N - M;
	for (int i = 0; i <= d; i++) {
		for (int j = 0; j <= d; j++) {
			if (template_matching(A, B, i, j)) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int n;

        string num1 = Console.ReadLine();
        n = int.Parse(num1);

        string[] num2 = Console.ReadLine().Split(' ');
        int[] array = new int[n];

        for (int i = n - 1; i >= 0; i--)
        {
            array[i] = int.Parse(num2[i]);
            Console.Write(array[i]);

            if (i == 0)
            {
                break;
            }
            Console.Write(" ");
        }
        Console.WriteLine("");
    }
}


Measured memory_bytes: 9180
#include<stdio.h>

int strlen(char *s)
{
	int j = 0;
	while(s[j] != '\0'){
		j++;
	}
	return j;
}

int main(void)
{
 char s[100000];
 int num=0;
  
  scanf("%s",s);
  num=strlen(s);
  
  int i=0;
  int count = 0;
  char a[2] = {'0','1'};

  
  for(i=0;i<num;i++){
   if(s[i]==a[0] && s[i+1]==a[0]){
     s[i+1]=a[1];
    count++;
   }
   else if(s[i]==a[1] && s[i+1]==a[1]){ 
     s[i+1]=a[0];
    count++;
   }
   
  }
    
    printf("%d",count);

   return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return num
}

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

func getMin(x ...int) int {
	min := math.MaxInt64
	for i := 0; i < len(x); i++ {
		if x[i] < min {
			min = x[i]
		}
	}
	return min
}

func getMax(x ...int) int {
	max := math.MinInt64
	for i := 0; i < len(x); i++ {
		if x[i] > max {
			max = x[i]
		}
	}
	return max
}

func pow(x, pow int) int {
	ans := x
	for i := 1; i < pow; i++ {
		ans = ans * x
	}
	return ans
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	// sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)

	// w := bufio.NewWriter(os.Stdout)
	// defer w.Flush()

	a := nextInt()
	b := nextInt()

	fmt.Println(a * b)
}


Measured memory_bytes: 1756
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))
d = 100000
ans = 0
for k in range(N):
    if abs(A-T+H[k]*0.006) < d:
        d = abs(A-T+H[k]*0.006)
        ans = k+1

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
deque<char>q;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin>>s;
  for(auto k:s){
    q.push_back(k);
  }
  int t;
  int sta=0;
  for(cin>>t;t;t--){
    int T;
    cin>>T;
    if(T==1){
      sta^=1;
    }else{
      char x;
      cin>>T>>x;
      if(T==1){
        if(!sta)q.push_front(x);
        else q.push_back(x);
      }else{
        if(!sta)q.push_back(x);
        else q.push_front(x);
      }
    }
  }
  if(!sta){
    while(!q.empty()){
      cout<<q.front();
      q.pop_front();
    }
  }else{
    while(!q.empty()){
      cout<<q.back();
      q.pop_back();
    }
  }
  return 0;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
//typedef pair<ll, ll> P;
const ll INF=1LL<<60;
ll gcd(ll x,ll y){return y? gcd(y,x%y) :x;}

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

Measured memory_bytes: 5612
#include <stdio.h>
#define MAX 100000

int Partition(int *,int);

int main() {
  int i,n,A[MAX],m;

  scanf("%d",&n);
  for (i = 0; i < n; i++) {
    scanf("%d",&A[i]);
  }
  n--;
  m = paritition(A,n);

  for(i = 0; i < m ; i ++) {
    printf("%d ",A[i]);
  }
  printf("[%d] ",A[m]);

  for(i = m + 1; i < n; i++) {
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n]);

  return 0;
}

int paritition(int *A, int n) {
  int x,i,j,a;
  x = A[n];
  i = 0;
  for(j = 0; j < n; j++) {
    if(A[j] <= x) {
      a = A[i];
      A[i] = A[j];
      A[j] = a;
      i++;
    }
  }
  A[n] = A[i];
  A[i] = x;
  return i;
}

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

int main() {
    long long N;
    cin >> N;
    vector<long long> v(N);
    bool check = false;
    for (int i = 0; i < N; i++) {
        cin >> v[i];
        if (v[0] < 0) check = true;
        if (check) v[i] = -v[i];
    }
    vector<long long> a(N, 0), b(N, 0);
    long long cntA = 0, cntB = 0;
    if (v[0] == 0) {
        a[0] = 1;
        b[0] = -1;
        cntA++;
        cntB++;
    } else {
        a[0] = v[0];
        b[0] = -1;
        cntB += v[0] + 1;
    }
    for (int i = 1; i < N; i++) {
        long long tmp_a = a[i - 1] + v[i];
        if (i % 2 == 0 && tmp_a <= 0) {
            a[i] = 1;
            cntA += abs(tmp_a) + 1LL;
        } else if (i % 2 == 1 && tmp_a >= 0) {
            a[i] = -1;
            cntA += abs(tmp_a) + 1LL;
        } else {
            a[i] = tmp_a;
        }
        long long tmp_b = b[i - 1] + v[i];
        if (i % 2 == 0 && tmp_b >= 0) {
            b[i] = -1;
            cntB += abs(tmp_b) + 1LL;
        } else if (i % 2 == 1 && tmp_b <= 0) {
            b[i] = 1;
            cntB += abs(tmp_b) + 1LL;
        } else {
            b[i] = tmp_b;
        }
    }
    cout << min(cntA, cntB) << endl;
}


Measured memory_bytes: 2688
function Main(N) {
	N = N.split("\n");
	var flag = true;
	var arr = N[1].split(" ").map(Number);
	for(var i=0;i<arr.length;i++){
		if(arr[i]%2==0&&(arr[i]%3!=0&&arr[i]%5!=0)) flag = false
		//console.log((arr[i]%2==0),(arr[i]%3!=0),(arr[i]%5!=0));
	}
	if(flag) console.log("APPROVED");
	else console.log("DENIED")

}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 11468