akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, Q, A[100000], X[100000];
ll sum[100001], se[100001], so[100001];

ll solve(ll x) {
  ll l = 1, h = N + 1;
  while (h - l > 1) {
    ll m = (l + h) / 2;
    ll p = (m + 1) / 2;
    (abs(A[N - m] - x) <= abs(A[N - p] - x) ? l : h) = m;
  }
  return (sum[N] - sum[N - (l + 1) / 2]) + (N % 2 == 0 ? so[N - l] : se[N - l]);
}

int main(void) {
  cin >> N >> Q;
  REP(i, 0, N) cin >> A[i];
  REP(i, 0, Q) cin >> X[i];

  REP(i, 0, N) sum[i + 1] = sum[i] + A[i];
  REP(i, 0, N) se[i + 1] = se[i] + (i % 2 == 0 ? A[i] : 0);
  REP(i, 0, N) so[i + 1] = so[i] + (i % 2 == 1 ? A[i] : 0);

  REP(i, 0, Q) cout << solve(X[i]) << endl;
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main(void){
	int a,b,c;
	int sum=0;
	int sum1=0;
	int i=1;
	cin>>a>>b>>c;
	while(1){
		sum+=a;
		sum1+=a;
		if(i%7==0){
			sum1+=b;
		}
		if(sum>=c||sum1>=c)	break;
		i++;
	}
	cout<<i<<endl;
	return 0;
}



Measured memory_bytes: 3108
using System;
using System.Linq;
using System.Numerics;

    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var A = Console.ReadLine().Split(' ').Select(s=>BigInteger.Parse(s))
                .GroupBy(l=>l)
                .Where(g=>g.Count()>1)
                .OrderByDescending(g=>g.Key)
                .ToList();
            var fi = A.FirstOrDefault();
            if(fi==null)
            {
                Console.WriteLine(0);
                return;
            }
            var se = A.Skip(1).FirstOrDefault();
            if (se == null)
            {
                Console.WriteLine(0);
                return;
            }
            if (3 < fi.Count())
            {
                Console.WriteLine(fi.Key * fi.Key);
                return;
            }
            Console.WriteLine(fi.Key * se.Key);
        }
    }

Measured memory_bytes: 37020
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <complex>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int a[50] = {};
    for(int i = 0; i < m; i++){
        int c, r;
        cin >> c >> r;
        a[c]++;
        a[r]++;
    }
    for(int i = 1; i <= n; i++){
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    int a, b, topp, bott;
    scanf("%d %d", &a, &b);

    if(a < b)
    {
        topp = (int)((b + 1) / 0.1);
        bott = (int)(a / 0.08);
    }
    else
    {
        topp = (int)((a + 1) / 0.1);
        bott = (int)(b / 0.08);
    }

    int temp = -1;
    for(int i = bott ; i < topp ; i++)
    {
        if(((int)(i * 0.08) == a) && ((int)(i * 0.1) == b))
        {
            temp = i;
            break;
        }
    }

    printf("%d\n", temp);

    return 0;
}


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

int main(){
    int n,A[1000];
    
    while(1){
        cin >> n;
        if (n==0) break;
        
        for (int i=0; i<n; i++) cin >> A[i];
        int sum=0;
        for (int i=0; i<n; i++) sum += A[i];
        double ave = 1.0*sum/n;
        double bun = 0.0;
        for (int i=0; i<n; i++) bun+=(A[i]-ave)*(A[i]-ave);
        
        printf("%lf\n",sqrt(bun/n));
    }
}


Measured memory_bytes: 3144
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

ans = 0
for i, b in enumerate(B):
    defeated = min(A[i], b)
    A[i] -= defeated; b -= defeated
    ans += defeated
    if b > 0: defeated = min(A[i+1], b); A[i+1] -= defeated; ans += defeated
print(ans)

Measured memory_bytes: 19116
let s = stdin.ReadLine()

let ans = match s with
          |"SUN" -> 7
          |"MON" -> 6
          |"TUE" -> 5
          |"WED" -> 4
          |"THU" -> 3
          |"FRI" -> 2
          |_ -> 1

ans
|> stdout.WriteLine

Measured memory_bytes: 11092
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
tmp = -1
for i in range(N):
    ans += b[a[i] - 1]
    if tmp == a[i]:
        ans += c[tmp - 2]
    tmp = a[i] + 1

print(ans)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m,R,ans=INF;
	cin >> n >> m >> R;
	vvll dist(n,vll(n,INF));
	vll r(R);
	rep(i,R){
		cin >> r[i];
		r[i]--;
	}
	sort(all(r));
	rep(i,m){
		ll a,b,c;
		cin >> a >> b >> c;
		a--;
		b--;
		dist[a][b]=c;
		dist[b][a]=c;
	}
	rep(k,n)rep(i,n)rep(j,n)chmin(dist[i][j],dist[i][k]+dist[k][j]);
	do{
		ll tmp=0;
		rep(i,R-1) tmp+=dist[r[i]][r[i+1]];
		chmin(ans,tmp);
	}while(next_permutation(all(r)));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
aaa = list(map(int, input().split()))
dp = [[0] * (n + 1) for _ in range(n + 1)]
for w in range(1, n + 1):
    for l in range(n - w + 1):
        r = l + w
        dpl = -dp[l + 1][r] + aaa[l]
        dpr = -dp[l][r - 1] + aaa[r - 1]
        dp[l][r] = max(dpl, dpr)
print(dp[0][n])


Measured memory_bytes: 113500
n,y=gets.split.map &:to_i
for a in 0..n
    for b in 0..n
        c=n-a-b
        break if c<0
        if 1000*a+5000*b+10000*c==y
            puts "#{c} #{b} #{a}"
            exit
        end
    end
end
puts "-1 -1 -1"

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  srand((unsigned)time(NULL));
  int D;
  cin >> D;
  int c[26];
  int las[26];
  int choose[D];
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
    las[i] = 0;
  }
  int s[D][26];
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  
  for (int i = 1; i <= D; i++) {
    int score[26];
    for (int j = 0; j < 26; j++) {
      score[j] = 0;
      score[j] += s[i-1][j];
      for (int k = 0; k < 26; k++) {
        if (j != k) {
          score[j] -= c[k] * (i - las[k]);
        }
      }
    }
    int chose = -1;
    int max_score = -99999999;
    for (int j = 0; j < 26; j++) {
      if (score[j] > max_score) {
        chose = j;
        max_score = score[j];
      }
    }
    las[chose] = i;
    choose[i-1] = chose + 1;
  }
  int ans = 0;
  for (int i = 1; i <= D; i++) {
    int scor = 0;
    scor += s[i-1][choose[i-1] - 1];
    for (int j = 0; j < 26; j++) {
      if (choose[i-1] - 1 != j) {
        scor -= c[j] * (i - las[j]);
      }
    }
    las[choose[i-1] - 1] = i;
    ans += scor;
    
  }
  for (int i = 0; i < 8000000; i++) {
    int d,q;
    d = rand() % D;
    q = rand() % 26;
    d++; q++;
    int oldchosen = choose[d-1];
    int diff = 0;
    diff -= s[d-1][choose[d-1]-1];
    diff += s[d-1][q-1];
    int p = choose[d-1];
    int nextp = D+1;
    int prevp = 0;
    int nextq = D+1;
    int prevq = 0;
    for (int i = d; i < D; i++) {
      if (choose[i] == p) {
        nextp = i+1;
        break;
      }
    }
    for (int i = d; i < D; i++) {
      if (choose[i] == q) {
        nextq = i+1;
        break;
      }
    }
    for (int i = d-2; i >= 0; i--) {
      if (choose[i] == p) {
        prevp = i+1;
        break;
      }
    }
    for (int i = d-2; i >= 0; i--) {
      if (choose[i] == q) {
        prevq = i+1;
        break;
      }
    }
    diff -= (d - prevp) * (nextp - d) * (c[p-1]);
    diff += (d - prevq) * (nextq - d) * (c[q-1]);
    if (diff > 0) {
      choose[d-1] = q; 
    } else {
      choose[d-1] = oldchosen;
    }
  }

  for (int i = 0; i < D; i++) {
    cout << choose[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
int main()
{
    char a[4],b[4],c[4];
    scanf("%s %s %s",a,b,c);
//    d[0]=a[0];
//    d[1]=b[1];
//    d[2]=c[2];
    printf("%c%c%c\n",a[0],b[1],c[2]);

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;

int main(){
/*??¢??????????????¨40????????????
	string in[100],n;
	int i = 1,stop = 0,si;
	while(stop == 0){
		cin >> n;
		if(n == "#"){stop = 1;}else{in[i] = n;i++;}						
	}
	string ans[i];
	for(int ii = 1;i > ii;ii++){
		ans[ii] = "A";
		si = in[ii].size();
		for(int iii = 0;si > iii;iii++){
			string c = in[ii].substr(iii,1);
			      if(ans[ii] == "A"){
				if(c == "1"){
					ans[ii] = "Y";
				}else if(c == "0"){
					ans[ii] = "X";
				}
			}else if(ans[ii] == "X"){
				if(c == "1"){
					ans[ii] = "Z";
				}else if(c == "0"){
					ans[ii] = "No";
				}
			}else if(ans[ii] == "Y"){
				if(c == "1"){
					ans[ii] = "No";
				}else if(c == "0"){
					ans[ii] = "X";
				}
			}else if(ans[ii] == "Z"){
				if(c == "1"){
					ans[ii] = "B";
				}else if(c == "0"){
					ans[ii] = "W";
				}
			}else if(ans[ii] == "W"){
				if(c == "1"){
					ans[ii] = "Y";
				}else if(c == "0"){
					ans[ii] = "B";
				}
			}else if(ans[ii] == "B"){
				if(c == "1"){
					ans[ii] = "X";
				}else if(c == "0"){
					ans[ii] = "Y";
				}
			}	
			if(iii == si - 1 and ans[ii] == "B"){ans[ii] = "Yes";}
			if(iii == si - 1){
				if(ans[ii] != "Yes"){ans[ii] = "No";}
				cout << ans[ii] << endl;
			}											
		}
	}*/
	/*	int	X,Y[3],P,ANS[2];
		cin >> X >> Y[1] >> Y[2] >> Y[3] >> P;
		ANS[1] = P * X;
		cout << "[AiUEO]" << P << " " << X << endl;
		if(P > Y[2]){
			ANS[2] = Y[1] + ( Y[3] * ( P - Y[2] ) );
		}else{
			ANS[2] = Y[1];
		}
		if(ANS[1] > ANS[2]){
			cout << ANS[2] << endl;
			cout << ANS[1] << endl;
		}else{
			cout << ANS[2] << endl;
		}*/
//
    int num, top;
    int train[1024];
    int i;

    top = 0;

    while (scanf("%d", &num) != EOF){
        if (num == 0){
            printf("%d\n", train[top - 1]);
            train[top - 1] = 0;
            top--;
        }
        else { 
            train[top] = num;
            top++;
        }
    }

}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(void){
    int n;
    double s[1000];
    int i;

    for(;;){
        scanf("%d", &n);
        if(n == 0) break;

        double sum = 0;
        for(i = 0; i < n; i++){
            scanf("%lf", &s[i]);
            sum += s[i];
        }

        double m = sum / n;
        double SUM = 0;
        for(i = 0; i < n; i++)
           SUM += (double) pow(s[i] - m, 2);
        
        double a = sqrt(SUM / n);

        printf("%.8f\n", a); 
    }

    return 0;
}


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

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a > b){
       swap(a,b);
        if(b > c)
          swap(b,c);
    }
    else if(b > c)
           swap(b,c);
    if(a > b)
      swap(a,b);
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3112
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int main() {
    int n;
    cin >> n;
    vector<long> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    vector<vector<long>> dp(n, vector<long>(2, 0));
    dp[0][0] = a[0];
    dp[0][1] = -a[0];
    for(int i=1; i<n; i++) {
        dp[i][0] = max( dp[i-1][0] + a[i], dp[i-1][1] - a[i] );
        dp[i][1] = max( dp[i-1][0] - a[i], dp[i-1][1] + a[i] );
    }
    cout << dp[n-1][0] << endl;

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 6528
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int i,n[9][2],a,b;
	char str[9][16];
	for(i=0;i<9;i++){
		cin>>str[i];
		cin>>a;
		cin>>b;
		n[i][0]=a+b;
		n[i][1]=a*200+b*300;
	}
	for(i=0;i<9;i++){
		printf("%s %d %d\n",str[i],n[i][0],n[i][1]);
	}
	return 0;
}

Measured memory_bytes: 3132
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:i32 = read();
    let p:i32 = read();

    let cnt:i32 = a*3+p;
    println!("{}", cnt/2);
}


Measured memory_bytes: 4352
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	          string x,p;
	          cin >> x;

	          p=x;
	          reverse(p.begin(),p.end());

	          if(p==x) cout << "Yes" << endl;
	          else cout << "No" << endl;

	          return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void makegraph(int x,vector<vec> &v){rep(i,x-1){int a=in(),b=in();v[a].pb(b);v[b].pb(a);}}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=924844033;
#define N 355050

ll n,m,k;

main(){
    n=in();
    int x=in();
    double d=(double)n/(double)x;
    printf("%.10f",d);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>

using namespace std;

struct vertex { double x, y; };
double rad = M_PI / 3.0;

void kock(int d, vertex p1, vertex p2)
{
	if (d == 0)
		return;

	vertex s, t, u;
	s.x = (2 * p1.x + 1 * p2.x) / 3;
	s.y = (2 * p1.y + 1 * p2.y) / 3;
	t.x = (1 * p1.x + 2 * p2.x) / 3;
	t.y = (1 * p1.y + 2 * p2.y) / 3;
	u.x = (t.x - s.x) * cos(rad) - (t.y - s.y) * sin(rad) + s.x;
	u.y = (t.x - s.x) * sin(rad) + (t.y - s.y) * cos(rad) + s.y;

	kock(d - 1, p1, s);
	cout << s.x << " " << s.y << endl;
	kock(d - 1, s, u);
	cout << u.x << " " << u.y << endl;
	kock(d - 1, u, t);
	cout << t.x << " " << t.y << endl;
	kock(d - 1, t, p2);
}

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

	int n;
	cin >> n;

	vertex p1, p2;
	p1.x = 0.0, p1.y = 0.0;
	p2.x = 100.0, p2.y = 0.0;

	cout << p1.x << " " << p1.y << endl;
	kock(n, p1, p2);
	cout << p2.x << " " << p2.y << endl;

	return 0;
}

Measured memory_bytes: 1288
H, W, D = map(int, input().split())

x_axis = [0]*(H*W)
y_axis = [0]*(H*W)

for i in range(H):
  A = list(map(lambda x: int(x)-1, input().split()))
  for j in range(W):
    x_axis[A[j]] = j
    y_axis[A[j]] = i

def dis(a, b):
  return abs(x_axis[a]-x_axis[b]) + abs(y_axis[a]-y_axis[b])

magic = [[0] for _ in range(D)]

for i in range(D):
  temp = i
  while temp < H*W-D:
    magic[i].append(magic[i][-1] + dis(temp, temp+D))
    temp += D

Q = int(input())
for _ in range(Q):
  L, R = map(lambda x: int(x)-1, input().split())
  L, d = divmod(L, D)
  R //= D
  print(magic[d][R] - magic[d][L])

Measured memory_bytes: 18592
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	//for(int i=0;i<N;i++) {}
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int N=sc.nextInt();
		
		int v[]=new int[N];
		int vv[]=new int[N];
		for(int i=0;i<N;i++) {
			v[i]=sc.nextInt();
			if(i-v[i]>=0) {
				vv[i-v[i]]++;
			}
		}
		long ans=0;
		for(int i=0;i<N;i++) {
			
			if(i+v[i]>=N)continue;
			ans+=vv[i+v[i]];
			
			
			
		}p(ans);
		
		
		
		
		
		
		
	}
	

	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 61168
console.log((args=>{
  const [[N],A] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0));
  if ( N === 0 ) return A[0] === 1 ? '1' : '-1';
  const a = [1-A[0]];
  for ( let i = 1; i < N; i++ ) a.push(a[i-1] * 2 - A[i]);
  a.push(0);
  let n = BigInt(A[N]);
  for ( let i = N-1; i >= 0; i-- ) {
    const c = a[i+1] + A[i+1];
    if ( a[i] > c ) a[i] = c;
    else if ( a[i] * 2 < c ) return '-1';
    n += BigInt(a[i] + A[i]);
  }
  return `${n}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 45092
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    while(1){
        int w, h; cin>>w>>h;
        if(w == 0) return 0;

        int sx, sy, gx, gy; cin>>sx>>sy>>gx>>gy;
        sx--, sy--, gx--, gy--;

        int n; cin>>n;
        vector<vector<int>> board(h, vector<int>(w, 0));
        while(n--){
            int c, d, x, y; cin>>c>>d>>x>>y;
            x--, y--;
            if(d == 0){
                for(int i=y; i<=y+1; i++){
                    for(int j=x; j<=x+3; j++){
                        board[i][j] = c;
                    }
                }
            }
            else{
                for(int i=y; i<=y+3; i++){
                    for(int j=x; j<=x+1; j++){
                        board[i][j] = c;
                    }
                }
            }
        }

        queue<P> que;
        que.push(P(sy, sx));
        int color = board[sy][sx];
        board[sy][sx] = 0;
        if(color == 0){
            cout << "NG" << endl;
            continue;
        }

        while(que.size()){
            int cy, cx;
            tie(cy, cx) = que.front();
            que.pop();

            if(cy == gy && cx == gx){
                cout << "OK" << endl;
                goto END;
            }    

            for(int i=0; i<4; i++){
                int ny = cy + dy[i];
                int nx = cx + dx[i];

                if(0 <= ny && ny < h && 0 <= nx && nx < w){
                    if(board[ny][nx] == color){
                        board[ny][nx] = 0;
                        que.push(P(ny, nx));
                    }
                }
            }
        }

        cout << "NG" << endl;
        END:;
    }
}


Measured memory_bytes: 3144
import sys

input_ = [ord(_) for _ in sys.stdin.readlines()[0].strip()]
alphabets = [i + 96 for i in range(1, 27)]
for c in input_:
  if c in alphabets:
    alphabets.remove(c)

res = sorted(alphabets)
if len(res) > 0:
  print(chr(res[0]))
else:
  print('None')

Measured memory_bytes: 4084
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 1000005
#define PP pair<pair<ll,ll>,pair<pair<ll,ll>,ll>>
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	// cases
	{
		char c;
		cin >> c;
		if (isupper(c))
			cout << "A\n";
		else
			cout << "a\n";

	}


// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}

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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> V(N);
    for (int i = 0; i < N; ++i){
        cin >> V[i];
    }

    long long ans = 0;
    for(int p = 0; p <= min(K, N); p++){
        for(int q = 0; p + q <= min(K, N); q++){
            vector<long long> w;
            long long a = 0;
            for(int i = 0; i < p; i++){
                w.push_back(V[i]);
                a += V[i];
            }
            for(int i = 0; i < q; i++){
                w.push_back(V[N-1-i]);
                a += V[N-1-i];
            }

            sort(w.begin(), w.end());

            for(int i = 0; i < min(K-p-q, (int)w.size()); i++){
                if(w[i] < 0){
                    a -= w[i];
                }
            }
            ans = max(ans, a);
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) {cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl;}

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}
bool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}};
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,TRI<S,T,U>&t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    int n, d, x;
    scanf("%d%d%d", &n, &d, &x);
    double a = d, b = x, ans = 0;
    for(int i = n; i >= 1; --i){
        ans += a + (i - 0.5) * b;
        a = (double)(i + 1) * a / i + 5.0 * b / (2.0 * i);
        b *= (1.0 + 2.0 / i);
    }
    printf("%.12lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
//lcm:最小公倍数、gcd:最大公約数
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back 
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

ll n,k;
//string s;
signed main(){
	acc_io;
	//ll n;
	cin>>n>>k;
	vl d(k);
	rep(i,0,k) cin>>d[i];
	int ans=n;
	string pr;
	vl p(4);
	while(1){
RETRY:
		pr=to_string(ans);
		rep(i,0,pr.size()){
			rep(j,0,k){
				if((ll)(pr[i]-'0')==d[j]){
					ans++;
					goto RETRY;
				}
			}
		}
		break;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
N,D=map(int,input().split())
P=[]
for i in range(N) :
    x,y=map(int,input().split())
    p=x**2+y**2
    P.append(p)


ans=0
for i in P :
    if i<=D**2 :
        ans+=1
    else :
        continue

print(ans)



Measured memory_bytes: 20136
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	cin >> a;
	int l = 0, r = 1000000000;
	while(l+1 < r){
		int now = (r+l)/2;
		int cut = 0;
		REP(i, n){
			cut += (a[i] + now - 1) / now - 1;
		}
		if(cut <= k) r= now;
		else l = now;
	}
	cout << r << endl;
}

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

int main(void)

{
  int a , b , c , d;

  scanf("%d %d %d %d11\n",&a,&b,&c,&d);
  
  if(abs(a-c) <= d || abs(a-b) <= d && abs(c-b) <= d)
  {
  	printf("Yes\n");
  } else {
  	printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
import math

menu =[]
for i in range(5):
    menu.append(int(input()))

#全部繰り上げて足す。そこから末尾が一番小さい数と10の差の絶対値を引く。

time = 0
for i in range(5):
    time = time + 10*math.ceil(menu[i]/10)
    menu[i] = menu[i]%10

nonzeromenu = [i for i in menu if i != 0]
nonzeromenu.sort()

if nonzeromenu:
    print(time -10 +nonzeromenu[0])
else:
    print(time)

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int cnt[100005];
// y, p, i
vector<pair<int , pair<int, int> > > vpp;
string res[100005];

string pad(int p, int year){
  string ps = to_string(p);
  string sy = to_string(year);
  string res="";
  for(int i=0;i<(6-ps.size());i++)res+='0';
  res += ps;
  for(int i=0;i<(6-sy.size());i++)res+='0';
  res+=sy;
  return res;
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    int p,y;cin>>p>>y;
    vpp.push_back({y, {p, i} });
  }
  sort(vpp.begin(), vpp.end());

  for(int i=0;i<m;i++){
    auto value = vpp[i];
    auto p = value.second.first;
    auto j = value.second.second;
    ++cnt[p];
    res[j] = pad(p, cnt[p]);
  }

  for(int i=0;i<m;i++){
    cout<<res[i]<<endl;
  }

  return 0;
}


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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int bitleft(int *p, int x, int len){
  if (p[0] >= x)
    return 0;
  int l = 0;
  int r = len;
  while (r - l > 1){
    int mid = (l+r)/2;
    if (p[mid] < x)
      l = mid;
    else
      r = mid;
  }
  return r;
}

int main(){
  int n;
  int a[200002];
  int b[200002];
  int ans = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  for(int i = 0; i < n; i++){
    scanf("%d", &b[i]);
  }
  for(int k = 0; k < 29; k++){
    int ar[200002];
    int br[200002];
    for(int i = 0; i < n; i++){
      ar[i] = a[i] & ((1 << (k+1)) - 1);
      br[i] = b[i] & ((1 << (k+1)) - 1);
    }
    qsort(br, n, sizeof(int), asc);
    int one = 0;
    for(int i = 0; i < n; i++){
      int l[4];
      for(int j = 1; j < 5; j++){
        l[j-1] = bitleft(br, (j << k) - ar[i], n);
      }
      one += l[3] + l[1] - l[2] - l[0];
    }
    ans += (one & 1) << k;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 4024
from collections import deque
def main(): 
    n = int(input())
    dq = deque([])
    dq.append([0])
    for _ in range(n-1):
        l = len(dq)
        for __ in range(l):
            s = dq.popleft()
            ls = len(set(s))
            for i in range(ls+1):
                dq.append(s+[i])
    
    for s in dq:
        s = list(map(lambda x: chr(x+ord("a")),s))
        print("".join(s))
main()

Measured memory_bytes: 26476
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC152A
{
	class Program
	{
		static void Main(string[] args)
		{
			int N, M;

			var word = Console.ReadLine().Split(' ');
			N = int.Parse(word[0]);
			M = int.Parse(word[1]);
			if (N == M)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
N = int(input())
a = [int(input())-1 for i in range(N)]

hist = set()
next_i = 0
ans = 0
for i in range(N):
    ans += 1
    hist.add(next_i)
    next_i = a[next_i]
    if next_i == 1:
        break
    elif next_i in hist:
        ans = -1
        break

print(ans)

Measured memory_bytes: 13200
n, x, y = map(int, input().split())


min_dist = [0] * n

for i in range(n):
    for j in range(i+1,n):
        dist = min(abs(j-i), abs(j-(y-1)) + 1 +abs((x-1)-i))
        min_dist[dist] += 1

for i in range(1,n):
    print(min_dist[i])


Measured memory_bytes: 3444
import sys
import queue
input = sys.stdin.readline
N, Q = map(int, input().split())

tree = [[] for i in range(N+1)]
values = [0] * (N+1)
visit = [False]*(N+1)
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

for _ in range(Q):
    p, x = map(int, input().split())
    values[p] += x


q = [1]
visit[1] = True
while q:
    now = q.pop()
    for next in tree[now]:
        if not visit[next]:
            values[next] += values[now]
            visit[next] = True
            q.append(next)

print(" ".join(map(str, values[1:])))


Measured memory_bytes: 67780
import collections
 
#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s
 
#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
def main():
    n, k = map(int, input().split())
    print(k*(k-1)**(n-1))
 
if __name__=='__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> l;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        l.push_back(tmp);
    }

    sort(l.begin(),l.end());

    int a,b;
    long long int sum = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            /*
            a = l[i];
            b = l[j];
            int low,high;
            low = j+1;
            high = n-1;
            while(high-low>=1){
                int mid = (low+high)/2;
                if(l[mid] >= a+b){
                    high = mid;
                }else{
                    low = mid;
                }
            }
            if(a+b < l[high])
                sum += high - j;
            cout<< "low:"<<low<<" high:"<<high<<endl;
            cout<<"a:"<<a<<" b:"<<b<<" c:"<<l[high]<<endl;
            cout<<"sum:"<<sum<<endl;
            */
            a=l[i];
            b=l[j];
            int r = lower_bound(l.begin(),l.end(),a+b) - l.begin();
            int left = j+1;
            sum += max(0,r-left);
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    H = list(map(int, input().split()))

    tree = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    res = 0
    for i in range(n):
        A = H[i]
        if len(tree[i]) >= 1:
            for j in tree[i]:
                B = H[j]
                if A <= B:
                    break
            else:
                res += 1
        else:
            res += 1

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 92988
#include <algorithm>
#include <cstdio>
#include <vector>
#define pb push_back
#define MOD 924844033
#define GEN 5
typedef long long ll;
inline int sum(int x, int y)
{
	x += y;
	if (x >= MOD)
		x -= MOD;
	return x;
}
inline int sub(int x, int y)
{
	x -= y;
	if (x < 0)
		x += MOD;
	return x;
}
inline int quick_pow(int a, int n)
{
	int res = 1;
	while (n)
	{
		if (n & 1)
			res = (ll)res * a % MOD;
		a = (ll)a * a % MOD;
		n >>= 1;
	}
	return res;
}
int alpha[2][800005], poly_rev[800005], poly_ntt_lst = -1;
inline void poly_ntt_init(int n)
{
	if (poly_ntt_lst == n)
		return;
	poly_ntt_lst = n;
	alpha[0][0] = alpha[1][0] = 1;
	alpha[0][1] = quick_pow(GEN, (MOD - 1) / n);
	alpha[1][1] = quick_pow(alpha[0][1], MOD - 2);
	for (int i = 2; i <= n; i++)
	{
		for (int x = 0; x < 2; x++)
			alpha[x][i] = (ll)alpha[x][i - 1] * alpha[x][1] % MOD;
	}
	for (int i = 1, j = n >> 1; i + 1 < n; i++)
	{
		poly_rev[i] = j;
		int k = n >> 1;
		while (j & k)
		{
			j ^= k;
			k >>= 1;
		}
		j |= k;
	}
}
inline void poly_ntt(int *a, int n, bool f)
{
	poly_ntt_init(n);
	for (int i = 1; i + 1 < n; i++)
	{
		if (i < poly_rev[i])
			std::swap(a[i], a[poly_rev[i]]);
	}
	for (int i = 1; i < n; i <<= 1)
	{
		for (int j = 0, off = n / (i << 1); j < n; j += i << 1)
		{
			for (int k = j, cur = 0; k < j + i; k++, cur += off)
			{
				int x = (ll)a[k + i] * alpha[f][cur] % MOD;
				a[k + i] = sub(a[k], x);
				a[k] = sum(a[k], x);
			}
		}
	}
	if (f)
	{
		int x = quick_pow(n, MOD - 2);
		for (int i = 0; i < n; i++)
			a[i] = (ll)a[i] * x % MOD;
	}
}
inline void poly_mul(int *a, int *b, int n)
{
	int len = 1;
	while (len >> 1 <= n)
		len <<= 1;
	poly_ntt(a, len, false);
	poly_ntt(b, len, false);
	for (int i = 0; i < len; i++)
		a[i] = (ll)a[i] * b[i] % MOD;
	poly_ntt(a, len, true);
}
int sz[200005], F[800005], G[800005];
ll fact[200005], inv[200005];
std::vector<int> adj[200005];
void dfs(int u, int fa = -1)
{
	sz[u] = 1;
	for (int v : adj[u])
	{
		if (v == fa)
			continue;
		dfs(v, u);
		sz[u] += sz[v];
	}
}
int main()
{
	int n;
	scanf("%d", &n);
	fact[0] = 1;
	for (int i = 1; i <= n; i++)
		fact[i] = fact[i - 1] * i % MOD;
	inv[n] = quick_pow(fact[n], MOD - 2);
	for (int i = n; i; i--)
		inv[i - 1] = inv[i] * i % MOD;
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		adj[--u].pb(--v);
		adj[v].pb(u);
	}
	dfs(0);
	for (int i = 0; i < n; i++)
	{
		F[sz[i]]--;
		F[n - sz[i]]--;
	}
	F[n] = n;
	for (int i = 0; i <= n; i++)
		F[i] = (F[i] + MOD) * fact[i] % MOD;
	for (int i = 0; i <= n; i++)
		G[i] = inv[n - i];
//	for (int i = 0; i <= n; i++)
//		printf("%d%c", F[i], " \n"[i == n]);
//	for (int i = 0; i <= n; i++)
//		printf("%d%c", G[i], " \n"[i == n]);
	poly_mul(F, G, n + 1);
//	for (int i = 0; i <= n << 1; i++)
//		printf("%d%c", F[i], " \n"[i == n << 1]);
	for (int i = 1; i <= n; i++)
		printf("%lld\n", F[n + i] * inv[i] % MOD);
	return 0;
}


Measured memory_bytes: 42112
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
mem = [[None]*w for _ in range(h)]
def next(r, c):
    if r==h-1 and c==w-1:
        return 0 if s[0][0]=='.' else 1
    if mem[r][c] is not None:
        return mem[r][c]
    tmp = 10000
    if c<w-1:
        if s[r][c]=='.' and s[r][c+1]=='#':
            tmp = next(r, c+1) + 1
        else:
            tmp = next(r, c+1)
    if r<h-1:
        if s[r][c]=='.' and s[r+1][c]=='#':
            tmp = min(next(r+1, c) + 1, tmp)
        else:
            tmp = min(next(r+1, c), tmp)
    mem[r][c] = tmp
    return tmp
print(next(0, 0))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {


		public static void main(String[] args) {

			Scanner scan = new Scanner(System.in);
			int N = scan.nextInt();


			if(N ==0 ) {
				System.out.println(1);
			}
			else {
				System.out.println(0);
			}
			scan.close();
		}

}


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

int main(void) {
  int n;
  cin >> n;
  vector<string> ss(n);
  for (string &s : ss) cin >> s;

  vector<int> cs(26, 999);
  for (string &s : ss) {
    vector<int> tcs(26, 0);
    for (const char &c : s) {
      tcs[c - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
      cs[i] = min(cs[i], tcs[i]);
    }
  }

  string result = "";
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < cs[i]; j++) {
      result += ('a' + i);
    }
  }

  std::cout << result << endl;
  return 0;
}

Measured memory_bytes: 3596
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int I,O,T,J,L,S,Z;
int ans;
main()
{
	re(I),re(O),re(T),re(J),re(L),re(S),re(Z);
	if(J && L && I && (J&1)+(L&1)+(I&1)>=2)ans+=3,--J,--L,--I;
	ans+=O;
	ans+=J/2*2;J%=2;
	ans+=L/2*2;L%=2;
	ans+=I/2*2;I%=2;
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
from sys import stdin
import math
a, b = [int(x) for x in stdin.readline().rstrip().split()]
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
g = gcd(a,b)
answer = factorize(g)
answer = list(set(answer))
print(len(answer) + 1)
            

Measured memory_bytes: 38384
c=[]
for _ in range(3):
    c.append(list(map(int,input().split())))

a=[-1,-1,-1]
b=[-1,-1,-1]
N=min(c[0])
ans='No'
for i in range(N+1):
    a[0]=i
    b[0]=c[0][0]-a[0]
    b[1]=c[0][1]-a[0]
    b[2]=c[0][2]-a[0]
    a[1]=c[1][0]-b[0]
    a[2]=c[2][0]-b[0]

    flag=1
    for j in range(3):
        for k in range(3):
            if c[j][k]!=a[j]+b[k]:
                flag=0
    if flag==1:
        ans='Yes'
        break
print(ans)

Measured memory_bytes: 3064
from collections import*
d=defaultdict(int)
n,k,*t=map(int,open(0).read().split())
for a,b in zip(*[iter(t)]*2):d[a]+=b
d=d.items()
m=sum(y for x,y in d if k|x==k)
*k,=bin(k)[2:]
i=-1
for _ in range(k.count('1')):
  t=k[:]
  i=t.index('1',i+1)
  t[i]='0'
  for j in range(i+1,len(t)):t[j]='1'
  t=int(''.join(t),2)
  m=max(m,sum(y for x,y in d if t|x==t))
print(m)

Measured memory_bytes: 27020
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    string S;
    cin >> S;
    ll A=0,AB=0,ABC=0,D=1;
    ll n=S.size();
    for(ll i=0;i<n;i++){
        if(S[i]=='?'){
            ABC=(ABC*3+AB)%MOD;
            AB=(AB*3+A)%MOD;
            A=(A*3+D)%MOD;
            D=(D*3)%MOD;
        }
        else if(S[i]=='A'){
            A=(A+D)%MOD;
        }
        else if(S[i]=='B'){
            AB=(AB+A)%MOD;
        }
        else if(S[i]=='C'){
            ABC=(ABC+AB)%MOD;
        }
    }
    print(ABC)
    return 0;
}

Measured memory_bytes: 512