akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





// editorialみた

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    cin >> n;
    int f = 0, t = 0, o = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (a % 4 == 0) f++;
        else if (a % 2 == 0) t++;
        else o++;
    }
    if (t) { o++; n -= t - 1; }
    vector<int> ans(n, 1);
    for (int i = 1; i < n; i += 2) if (f) { f--; ans[i] = 4; }
    // rep(i, n) cout << ans[i] << " "; cout << endl;
    
    rep(i, n - 1) if (ans[i] * ans[i + 1] % 4 != 0) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    
}


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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

lint n, k;
vector<lint> a(1, 0), zip;
map<lint, lint> unzip;

lint bit[202020];
lint sum(int i) {
	i++;
	lint s = 0;
	while (i > 0) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, int x) {
	i++;
	while (i <= n + 1) {
		bit[i] += x;
		i += i & -i;
	}
}

int main() {
	cin >> n >> k;
	rep(i, n) a.pb(in() - k);

	for (int i = 1; i <= n; ++i) {
		a[i] += a[i - 1];
	}

	for (int i = 0; i <= n; ++i) {
		zip.pb(a[i]);
	}

	sort(all(zip));
	zip.erase(unique(all(zip)), zip.end());
	for (int i = 0; i < zip.size(); ++i) {
		unzip[zip[i]] = i;
	}
	for (int i = 0; i <= n; ++i) {
		a[i] = unzip[a[i]];
	}

	lint ans = 0;
	for (int i = 0; i <= n; ++i) {
		ans += sum(a[i]);
		add(a[i], 1);
	}

	//print(zip);
	//print(a);

	cout << ans << endl;
}


Measured memory_bytes: 17392
#d=日数, c=満足低下度, s=満足上昇度, t=コンテストの日程 
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(d)]
sa = []
for i in s:
  y = [k-l for (k,l) in zip(i, c)]
  sa.append(y)
t_lst1 = []
t_lst2 = []
res1 = 0
res2 = 0
last1 = [0 for i in range(26)]
last2 = [0 for i in range(26)]
#old = t[dq[j][0] - 1]
#t[dq[0] - 1] = dq[1]


for day in range(d):
  t = s[day].index(max(s[day])) + 1
  m = s[day].index(max(s[day]))
  res1 += max(s[day])
  last1[m] = day + 1
  t_lst1.append(t)
  combined1 = [x * (day + 1 - y) for (x, y) in zip(c, last1)]
  res1 -= sum(combined1)
  #t[dq[j][0] - 1] = old
  #print(t)

for day in range(d):
  t = sa[day].index(max(sa[day])) + 1
  m = sa[day].index(max(sa[day]))
  res2 += s[day][m]
  last2[m] = day + 1
  t_lst2.append(t)
  combined2 = [x * (day + 1 - y) for (x, y) in zip(c, last2)]
  res2 -= sum(combined2)
  #t[dq[j][0] - 1] = old
  #print(t)
  
for day in range(d):
  old = t_lst1[day]
  t_lst1[day] = t_lst2[day]
  old_res = res1
  res1 = res1 - s[day][old-1] + s[day][t_lst1[day]-1]
  if old_res>=res1:
    res1 = old_res
    t_lst1[day] = old
  
for i in t_lst1:
  print(i)

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

# define ll long long
ll mod=pow(10,9)+7;

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

    int n,cnt=0;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
        if(i%2==0 && ar[i]%2==1)
            cnt++;
    }
    cout<<cnt<<endl;
}


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

int main() {
  std::string S, T;
  std::cin >> S >> T;

  std::vector<std::string> restored;
  restored.reserve(S.size()-T.size()+1);

  for (int i=0; i<S.size()-T.size()+1; i++) {
    bool match = true;
    for (int j=0; j<T.size(); j++) {
      char s = S[S.size()-T.size()-i+j];
      if (s == '?') continue;
      if (s != T[j]) {
        match = false;
        break;
      }
    }
    if (match) {
      std::string R = S;
      for (int j=0; j<T.size(); j++) {
        R[R.size()-T.size()-i+j] = T[j];
      }
      for (int i=0; i<R.size(); i++) {
        if (R[i]=='?') R[i] = 'a';
      }
      restored.push_back(R);
    }
  }

  if (restored.size() > 0) {
    std::sort(restored.begin(), restored.end());
    std::cout << restored[0] << std::endl;
  } else {
    std::cout << "UNRESTORABLE" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int n;
    cin >> n;
    int sb = (n % 2 == 0) ? n + 1 : n;
    vi a, b;
    for (int i = 1; i < n + 1; i++)
    {
        for (int j = i + 1; j < n + 1; j++)
        {
            if (i + j != sb)
            {
                a.push_back(i);
                b.push_back(j);
            }
        }
    }
    cout << a.size() << endl;
    for (size_t i = 0; i < a.size(); i++)
    {
        cout << a[i] << " " << b[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), now = 0, count = 0;
                        int ans = -1;
                        for(int i = 0; i < 600; i++){
                                if(now <= c && c <= now + a){
                                        ans = count*60 + c;
                                        break;
                                }
                                now += a;
                                if(now >= 60){
                                        count++;
                                        now %= 60;
                                        if(0 <= c && c <= now){
                                                ans = count*60 + c;
                                                break;
                                        }
                                }
                                now += b;
                                if(now >= 60){
                                        count++;
                                        now %= 60;
                                }
                        }
                        System.out.println(ans);
                }
        }
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> flg(1000, true);
    int s, c;
    rep(i, m) {
        cin >> s >> c;
        rep(j, 1000) {
            if((j / (int)pow(10, n - s)) % 10 == c) {
                continue;
            } else {
                flg[j] = false;
            }
        }
    }

    for(int i = (int)pow(10, n - 1) - (n == 1); i < (int)pow(10, n); i++) {
        if(flg[i]) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
N,X,Y=map(int,input().split())

ans=[0]*N

for i in range(1,N):
    for j in range(i+1,N+1):
        ans[min(abs(j-i),abs(X-i)+abs(Y-j)+1)]+=1

for i in range(1,N):
    print(ans[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int n,a[200010];
vector<P> vec;

bool inc(int x,int b){
	int sum = x;
	while(!vec.empty() && vec.back().first == b - 1){
		sum--;
		vec.pop_back();
	}
	if(vec.empty()) return false;
	if(vec.back().first != 0 || vec.back().second == 1) vec.back().first++;
	else{
		vec.back().second--;
		vec.emplace_back(1,1);
	}
	if(x != sum) vec.emplace_back(0,x - sum);
	return true;
}

bool isOK(int b){
	vec.clear();
	for(int i = 0;i < n;i++){
		if(a[i] == a[i + 1]){
			if(!inc(a[i + 1],b)) return false;
		}else if(a[i] < a[i + 1]){
			vec.emplace_back(0,a[i + 1] - a[i]);
		}else{
			int sum = a[i];
			while(sum > a[i + 1]){
				sum -= vec.back().second;
				vec.pop_back();
			}
			if(a[i + 1] != sum) vec.emplace_back(0,a[i + 1] - sum);
			if(!inc(a[i + 1],b)) return false;
		}
	}
	return true;
}

signed main(){
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i + 1];
	int ng = 0,ok = n;
	while(ok - ng > 1){
		int mid = (ok + ng) / 2;
		if(isOK(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}


Measured memory_bytes: 7408
import java.util.*;
public class Main {
    public static void main(String[] args ){
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        long ans = 0;
        for(int i = 1;i<=n;i++){
            for(int j = 1;j<=n/i;j++)ans+=i*j;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35704
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]

    member public __.Tuple2List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]]
    
    member public __.Tuple3List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]]

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()
    let a = scanner.NextI32()
    let b = scanner.NextI32()
    if a > b then (a, b) else (b, a)
    |> (fun (x, y) -> for _ in 0..x-1 do printf "%i" y)

    0


Measured memory_bytes: 11992
import java.util.*;

public class Main{
    final int INF = 1000000007;
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long[] a = new long[n];
        long sum = 0;
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
            sum += a[i];
        }
        long out = 0;
        for(int i = 0; i < n - 1; i++){
            sum -= a[i];
            out += a[i] * (sum % INF);
            if(out > INF) out %= INF;
        }
        System.out.println(out);
        scan.close();
    }

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


Measured memory_bytes: 61416
a, b, c = map(int, input().split())
if a+b+c ==17:
    if a ==5 and b ==7:
        print("YES")
    elif a ==7 and b ==5:
        print("YES")
    elif a ==5 and b ==5:
        print("YES")
    else: 
        print("NO")
else:
    print("NO")

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

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


void solve()
{
    int N; cin >> N;
    vector<char> S(N+1); REP1(i, N) cin >> S[i];

    vi cw(N+1, 0); 
    vi ce(N+1, 0);
    int w = 0;
    int e = 0;
    REP1(i, N)
    {
        if(S[i] == 'W') w++;
        else e++;
        cw[i] = w;
        ce[i] = e;
    }

    int ans = INF;
    REP1(i, N)
    {
        int count = cw[i-1] + (ce[N] - ce[i]);
        ans = min(ans, count);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;

    int ans = t.size();

    for (int i = 0; i <= s.size() - t.size(); i++) {
        int dif = 0;
        for (int j = 0; j < t.size(); j++) {
            if (t[j] != s[i+j]) {
                dif++;
            }
        }
        ans = min(ans, dif);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
    int n,x; cin>>n>>x;
    int l[n];rep(i,n) cin>>l[i];
    int d=0,cnt=1;
    for(int i=0;i<n;i++){
        d=d+l[i];
        if(d<=x) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int x[100100], y[100100];
    int cnt[100100];
    bool f[100100];

    for (int i = 0;i < n;i++)
    {
        cnt[i] = 1;
        if (i == 0)f[i] = 1;
        else f[i] = 0;
    }

    for (int i = 0;i < m;i++)
    {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
        cnt[x[i]]--;
        cnt[y[i]]++;
        if (f[x[i]])
        {
            f[y[i]]=1;
        }
        if (cnt[x[i]] == 0)
        {
            f[x[i]]=0;
        }
    }

    int ans = 0;
    for (int i = 0;i < n;i++)
    {
        if (cnt[i] > 0&&f[i])
        {
            ans ++;
        }
    }
    cout << ans << endl;

}

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

int main(){
	int a,N,P,K;
	cin>>N;
	int*X=new int[N];
	for(a=0;a<N;a++){
		cin>>K>>P;
		X[a]=K%P;
		if(X[a]==0){
			X[a]=P;
		}	
	}
	for(a=0;a<N;a++){
		cout<<X[a]<<endl;
	}
	
		  
    return 0;
}

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

struct interval {
  ll left, right;
  interval(ll x, ll y) : left(x), right(y) { }
};

bool compare_f(const interval& x, const interval& y) {
  return x.left < y.left;
}

ll count_interval(const vector<interval>& vec){
  ll result=0;
  ll pre_left = min((ll)-8e18, vec.front().left-10);
  for(auto& v:vec){
    result += max((ll)0LL, v.right - max(v.left-1LL, pre_left));
    pre_left = max(v.right, pre_left);
  }
  return result;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll N,X,D;
  cin >> N >> X >> D;
  ll sum=0;
  if(D==0){
    if(X==0){
      cout << 1 << endl;
      return 0;
      }
    else{
      cout << N+1 << endl;
      return 0;
    } 
  }
  if(N==1){
    cout << 2 << endl;
    return 0;
  }
  if(D<0){
    D = -D;
    X = -X;
  }
  map<ll,vector<interval> > m;
  for(ll k=0;k<=N;k++){
    ll mod = (k*X%D+D)%D;
    ll Imin = k*(k-1)/2+(k*X-mod)/D;
    ll Imax = (2*N-k-1)*k/2+(k*X-mod)/D;
    // m[mod].push_back(interval(Imin,Imax));
    // m.emplace(i,j) をつかうと、クラス・構造体を省略できる。特に vector 
    m[mod].emplace_back(Imin,Imax);
  }
  for(auto d:m){
    vector<interval> v = d.second;
    if(v.empty()) continue;
    sort(v.begin(),v.end(),compare_f);
    sum += count_interval(v);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 22144
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
#from collections import deque
#from collections import defaultdict
# from collections import Counter
#from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n,*p=map(int,read().split())
	H=[0,0,n+1,n+1]
	pidx=[0]*(n+1)
	for i in range(n):
		pidx[p[i]]=i+1
	
	pidx.reverse()
	
	
	ans=0
	for i in pidx:
		I=bisect.bisect_left(H,i)
		ans+=p[i-1]*((H[I-1]-H[I-2])*(H[I]-i)+(H[I+1]-H[I])*(i-H[I-1]))
		H.insert(I,i)
	print(ans)
	
	
if __name__ == "__main__":
		main()


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<string> a(h);
  for(int i=0;i<h;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<h+2;i++){
    if(i==0||i==h+1){
      for(int j=0;j<w+2;j++){
        cout << "#";
      }
      cout << endl;
    }
    else{
      cout << "#" << a.at(i-1) << "#" << endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int N; cin>> N;
    int A[105];
    int Sum = 0;
    rep(i,N){
        cin >> A[i];
        Sum += A[i];
    }
    int delta = 1001001001;
    int ans  = 0;
    rep(i,N){
        if(abs(N*A[i] - Sum) < delta){
            ans = i;
            delta = abs(N*A[i] - Sum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
#include<cstdio>
#include<algorithm>
using namespace std;
int n,i,j;
char s[1005][1005];
int main()
{
	scanf("%d",&n);
	if(n==2)
	{
		printf("-1");
		return 0;
	}
	for(i=1;i<=n;++i)
			for(j=1;j<=n;++j)
				s[i][j]='.';
	if(n==3)
	{
		for(i=1;i<=n;i+=3)
			s[i][i]=s[i][i+1]='a',s[i][i+2]=s[i+1][i+2]='b',s[i+2][i+2]=s[i+2][i+1]='c',s[i+1][i]=s[i+2][i]='d';
		for(i=1;i<=n;++i)
			puts(s[i]+1);
		return 0;
	}
	if(n%4==0)
	{
		for(i=0;i<n;i+=4)
		{
			s[i+1][i+1]=s[i+1][i+2]='a',s[i+2][i+1]=s[i+2][i+2]='b',s[i+1][i+3]=s[i+2][i+3]='c',s[i+1][i+4]=s[i+2][i+4]='d';
			s[i+3][i+1]=s[i+4][i+1]='e',s[i+3][i+2]=s[i+4][i+2]='f',s[i+3][i+3]=s[i+3][i+4]='g',s[i+4][i+3]=s[i+4][i+4]='h';
		}
		for(i=1;i<=n;++i)
			puts(s[i]+1);
		return 0;
	}
	if(n%4==1)
	{
	s[1][1]=s[1][2]='a',s[1][3]=s[1][4]='b',s[1][5]=s[2][5]='c',s[3][5]=s[4][5]='d',s[5][5]=s[5][4]='e';
	s[5][3]=s[5][2]='f',s[5][1]=s[4][1]='g',s[3][1]=s[2][1]='h',s[2][2]=s[2][3]='w',s[3][4]=s[4][4]='u';
	for(i=5;i<n;i+=4)
		{
			s[i+1][i+1]=s[i+1][i+2]='a',s[i+2][i+1]=s[i+2][i+2]='b',s[i+1][i+3]=s[i+2][i+3]='c',s[i+1][i+4]=s[i+2][i+4]='d';
			s[i+3][i+1]=s[i+4][i+1]='e',s[i+3][i+2]=s[i+4][i+2]='f',s[i+3][i+3]=s[i+3][i+4]='g',s[i+4][i+3]=s[i+4][i+4]='h';
		}	for(i=1;i<=n;++i)
		puts(s[i]+1);
	return 0;
	}
	if(n%4==2)
	{
		s[1][1]=s[1][2]='a',s[1][3]=s[1][4]='b',s[1][5]=s[1][6]='c',s[2][1]=s[3][1]='d',s[4][1]=s[5][1]='e';
		s[2][2]=s[2][3]='f',s[3][4]=s[4][4]='g',s[2][6]=s[3][6]='h',s[4][5]=s[4][6]='i',s[5][4]=s[6][4]='u',s[5][5]=s[6][5]='v',s[6][2]=s[6][3]='z';
		for(i=6;i<n;i+=4)
		{
			s[i+1][i+1]=s[i+1][i+2]='a',s[i+2][i+1]=s[i+2][i+2]='b',s[i+1][i+3]=s[i+2][i+3]='c',s[i+1][i+4]=s[i+2][i+4]='d';
			s[i+3][i+1]=s[i+4][i+1]='e',s[i+3][i+2]=s[i+4][i+2]='f',s[i+3][i+3]=s[i+3][i+4]='g',s[i+4][i+3]=s[i+4][i+4]='h';
		}
		for(i=1;i<=n;++i)
		puts(s[i]+1);
	return 0;
	}
	s[1][1]=s[1][2]='a',s[1][3]=s[1][4]='b',s[1][5]=s[1][6]='c',s[2][7]=s[3][7]='d',s[4][7]=s[5][7]='e',s[6][7]=s[7][7]='f';
	s[2][1]=s[2][2]='i',s[5][1]=s[5][2]='j',s[2][4]=s[2][5]='k',s[5][4]=s[5][5]='l';
	s[3][3]=s[4][3]='u',s[6][3]=s[7][3]='v',s[3][6]=s[4][6]='x',s[6][6]=s[7][6]='y';
	for(i=7;i<n;i+=4)
		{
			s[i+1][i+1]=s[i+1][i+2]='a',s[i+2][i+1]=s[i+2][i+2]='b',s[i+1][i+3]=s[i+2][i+3]='c',s[i+1][i+4]=s[i+2][i+4]='d';
			s[i+3][i+1]=s[i+4][i+1]='e',s[i+3][i+2]=s[i+4][i+2]='f',s[i+3][i+3]=s[i+3][i+4]='g',s[i+4][i+3]=s[i+4][i+4]='h';
		}
		for(i=1;i<=n;++i)
		puts(s[i]+1);
	return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean ch = true;
		for(; N > 0; N--) {
			int a = sc.nextInt();
			if(a%2 == 0) {
				if((a%3 != 0)&&(a%5 != 0)) {
					ch = false;
					break;
				}
			}
		}
		if(ch)System.out.println("APPROVED");
		else System.out.println("DENIED");
	}
}

Measured memory_bytes: 22740
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef pair<int, P> Tri;
const int NN=10000;
const int MM=20000;
int N,M;
P dist[NN];
vector<Tri> to[NN];

void exec()
{
	for(int i=0;i<N;i++){
		if(to[i].size()>100){
			vector<Tri> tmp;
			to[i].swap(tmp);
		}
		else
		{
			to[i].clear();
		}
	}
	scanf("%d %d",&N,&M);
	if(N==0&&M==0){
		exit(0);
	}
	for(int i=1;i<N;i++){
		dist[i]=P(INT_MAX,INT_MAX);
	}

	for(int i=0;i<M;i++){
		int u,v,d,c;
		scanf("%d %d %d %d",&u,&v,&d,&c);
		u--;
		v--;
		to[u].push_back(Tri(v,P(d,c)));
		to[v].push_back(Tri(u,P(d,c)));
	}

	priority_queue<Tri, vector<Tri>, greater<Tri> > pq;
	pq.push(Tri(0,P(0,0)));
	while(pq.size()){
		Tri t=pq.top();
		pq.pop();
		int i=t.first;
		int d=t.second.first;
		if(dist[i]<t.second)
		{
			continue;
		}
		for(int j=0;j<to[i].size();j++){
			Tri tt=to[i][j];
			int nex=tt.first;
			P v=P(d+tt.second.first, tt.second.second);
			if(v<dist[nex]){
				dist[nex]=v;
				pq.push(Tri(nex,v));
			}
		}
	}

	int ret=0;
	for(int i=1;i<N;i++){
		ret+=dist[i].second;
	}
	printf("%d\n",ret);
}
int main() {
	while(true){
		exec();
	}
}

Measured memory_bytes: 4088
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAX =2000000;
const int INFTY = 1<<30;

int H,A[MAX+1];

void maxHeapify(int i){
int l,r,largest;
l = 2*i;
r = 2*i+1;
if(l<=H&&A[l]>A[i])largest = l;
else largest = i;
if(r<=H&&A[r]>A[largest])largest = r;
if(largest !=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
}
}

int extract(){
int maxv;
if(H<1)return -INFTY;
maxv = A[1];
A[1] = A[H--];
maxHeapify(1);
return maxv;
}

void increaseKey(int i,int key){
if(key<A[i])return;
A[i] = key;
while(i>1&&A[i/2]<A[i]){
    swap(A[i],A[i/2]);
    i = i/2;
}
}

void insert(int key){
H++;
A[H] = -INFTY;
increaseKey(H,key);
}

int main(){
    int key;
    char com[10];
    while(1){
        scanf("%s",com);
        if(com[0]=='e'&&com[1]=='n')break;
        if(com[0]=='i'){
            scanf("%d",&key);
            insert(key);
        }else{
        printf("%d\n",extract());
        }
    }
return 0;
}



Measured memory_bytes: 6536
#include <bits/stdc++.h>
using namespace std;
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;

// 二分探索（改）
// judge を満たすような下限を求める
// left:[X] 定義域の下限
// right:[X] 定義域の上限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離

template <typename X>
X BinSearch(X left, X right, function<bool(X)> judge, bool lower = true, X eps = 1) {
    while (right - left > eps) {
        X mid = (right + left) / 2;
        if (judge(mid) == lower) {
            right = mid;
        } else {
            left = mid;
        }
    }
    return lower ? right : left;
}

int main() {
    int N;
    cin >> N;
    vector<i64> A[3], S[3];
    for(int i = 0; i < 3; i++) {
        A[i] = vector<i64>(N);
        for(auto &x : A[i]) {
            cin >> x;
        }
        sort(WHOLE(A[i]));
    }
    S[0] = vector<i64>(N);
    for(int j = 0; j < N; j++) {
        S[0][j] = j + 1;
    }
    for(int i = 0; i < 2; i++) {
        S[i + 1] = vector<i64>(N, 0);
        for(int j = 0; j < N; j++) {
            int K = BinSearch<int>(-1, N, [&](int k) -> bool {
                return A[i][k] < A[i + 1][j];
            }, false);
            S[i + 1][j] = K < 0 ? 0 : S[i][K];
            if(j) {
                S[i + 1][j] += S[i + 1][j - 1];
            }
        }
    }
    cout << S[2][N - 1] << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const int maxn=200005;
int n,p[maxn];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		int k;
		cin>>k;
		p[k]=i;
	}
	int ans=n;
	for(int i=1;i<=n;++i){
		int j=i;
		while((j+1<=n)&&(p[j+1]>p[j]))++j;
		ans=min(ans,i-1+n-j);
		i=j;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int n;
    int a,b;
    while(scanf("%d",&n)!=EOF)
    {
        int sum=0;
        for(int i=0;i<n;i++){
            scanf("%d %d",&a,&b);
            sum=sum+b-a+1;
        }
        cout<<sum<<"\n";
    }
    return 0;
}


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

int main(){
  int a;
  string s;
  
  
  cin >> a;
  cin >> s;
  if(3200<=a){
    cout << s << endl;
  } else {
   cout << "red" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
//I am so vegetable
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2005;
const int MOD = 1e9 + 7;
const double exps = 1e-6;
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	for(int i =0;i<s.size();){
		if (s[i] == 'B' && i != 0) { s.erase(i - 1, 2); i--; }
		else if(s[i] == 'B')s.erase(i,1);
		else ++i;
	}
	cout << s<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
signed main(){
  int n,k,p;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>k>>p;
    if(k%p==0) cout<<p<<"\n";
    else cout<<k%p<<"\n";
  }
}



Measured memory_bytes: 3092
n=int(input())
a=sorted(list(map(int,input().split())))
if n%2==1:
    if a[0]==0 and all(a[i]==2*((i+1)//2) for i in range(1,n)):print(2**(n//2)%(10**9+7))
    else: print(0)
else:
    if all(a[i]==2*(i//2)+1 for i in range(n)):print(2**(n//2)%(10**9+7))
    else: print(0)

Measured memory_bytes: 14008
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
 
using namespace std;

int cnt1[110000] = {};
int cnt2[110000] = {};

int main(){
	
	string str;
	cin >> str;
	
	string str1 = "";
	string str2 = "";
	
	for(int i = 0; i < str.size(); i++){
		string hoge = " ";
		if(str[i] != 'x'){
			hoge[0] = str[i];
			str1 = str1 + hoge;
		}
	}
	
	str2 = str1;
	reverse(str2.begin(), str2.end());
	
	if(str1 != str2){
		cout << "-1" << endl;
		return 0;
	}
	
	str1 = str;
	reverse(str1.begin(), str1.end());
	
	int ind = 0;
	
	for(int i = 0; i < str.size(); i++){
		if(str[i] != 'x'){
			ind++;
		}else{
			cnt1[ind]++;
		}
	}
	
	ind = 0;
	
	for(int i = 0; i < str1.size(); i++){
		if(str1[i] != 'x'){
			ind++;
		}else{
			cnt2[ind]++;
		}
	}
	
	int ans = 0;
	
	for(int i = 0; i < str.size(); i++){
		ans += abs(cnt1[i] - cnt2[i]);
	}
	
	cout << ans / 2 << endl;
	
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

void solve() {
  int n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  string s;
  cin >> s;
  vll basis;
  bool ok = true;
  per(i,n) {
    ll v = a[i];
    for(auto x : basis) v = min(v,v^x);
    if(v) {
      if(s[i]=='1') ok = false;
      basis.push_back(v);
    }
  }
  if(ok) cout << 0 << endl;
  else cout << 1 << endl;
}

int main() {
  int T;
  cin >> T;
  rep(_,T) solve();
  return 0;
}

Measured memory_bytes: 3572
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int x = scan.nextInt();
        int min = x - k + 1;
        int max = k + x - 1;
        if(min < -1000000){
            min = -1000000;
        }
        if(max > 1000000){
            max = 1000000;
        }
        for(int i = min; i <= max; i++){
            System.out.print(i + " ");
        }
    }
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

string n; int len;

int count(int k, int edge, int index) {
    if (index == len) {
        return k == 0;
    }
    if (k) {
        if (edge) {
            if (n[index] == '0') {
                return count(k, edge, index + 1);
            }
            int res = count(k - 1, 0, index + 1) * (n[index] - '0' - 1);
            res += count(k - 1, edge, index + 1);
            res += count(k, 0, index + 1);
            return res;
        } else {
            return count(k - 1, edge, index + 1) * 9 + count(k, edge, index + 1);
        }
    } else {
        return count(k, edge, index + 1);
    }
}

int32_t main() { fastio;
    time_t start = now();

    int k;
    cin >> n >> k;
    len = n.size();
    cout << count(k, 1, 0) << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

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

int main() {
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> a(n+1);
    for (int i = 0; i < m; i++) {
        int ai;
        cin >> ai;
        a[ai] = 1;
    }
    for (int i = 0; i + 1 <= n; i++) a[i+1] += a[i];

    cout << min(a[x-1], m - a[x-1]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 501
#define M 50001
#define MAX_N 50001
#define rank Asdfiasofsad
using namespace std;

class UF{
public:
  vector<int> par,rank;
  UF(){
    par.resize(MAX_N),rank.resize(MAX_N);
    for(int i=0;i<MAX_N;i++)par[i]=i,rank[i]=0;
    
  }

  UF(int n){
    par.resize(n),rank.resize(n);
    for(int i=0;i<n;i++)par[i]=i,rank[i]=0;
  }
  
  int find(int x){
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(int x,int y){
    x=find(x), y=find(y);
    if(x==y)return;
    if(rank[x]<rank[y])par[x]=y;
    else{
      par[y]=x;
      if(rank[x]==rank[y])rank[x]++;
    }
  }

  bool same(int x,int y){return find(x)==find(y);}
};

typedef pair<int,int> P;
typedef pair<int,P> PP;
vector<PP> edge;
int n,m,used[M];

int kruskal(int NG){
  UF U;

  int res=0;
  for(int i=0;i<m;i++){
    int a=edge[i].second.first;
    int b=edge[i].second.second;
    int c=edge[i].first;
    if(U.same(a,b)||i==NG)continue;
    used[i]=1;
    U.unite(a,b);
    res+=c;
  }
  for(int i=0;i<n;i++)if(!U.same(0,i))return -1;
  return res;
}

int main(){
  cin>>n>>m;
  int sum=0;
  for(int i=0,a,b,c;i<m;i++){
    cin>>a>>b>>c;
    edge.push_back(PP(c,P(a-1,b-1)));
    sum+=c;
  }

  sort(edge.begin(),edge.end());
  int cnt=m,mncost=kruskal(-1);
  for(int i=0;i<m;i++)
    if(!used[i]||kruskal(i)==mncost)cnt--,sum-=edge[i].first;

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

Measured memory_bytes: 4008
/*
                                                                           __                _________
                                                                          /  \              /  ______/
                                                                         /    \            /  /
                                                                        /  __  \          /  /
                                                                       /  /  \  \         |  |
                                                                      /  /____\  \        \  \
                                                                     /  ________  \        \  \______
                                                                    /__/        \__\        \________\
	
	I_love_Hacked;
	I_hate_pretest past;
	I_love_STP
	
    coder:xxjAc
    date:2018/6/29
	    
    I_love_Ac;
    I_hate_WA;
    I_hate_Tle;
    I_hate_RE;
    I_hate_CE;
    I_hate_Mle;
    
    I love Accepts very much;
    
    I_don't_love_I_love_zzq
	I_hate_zzq
       
    cd Desktop
    g++ xxjAc.cpp -o std
    ./std
    
    #prag\
    ma GCC optimize("Ofast")
    (O2,O3,Ofast)
*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define ll long long
using namespace std;
const int inf=1000000007;
string s;
int dp[500007];
int main(){
	memset(dp,-1,sizeof(dp));
	int n;
	cin>>n;
	cin>>s;
	for (int i=n;i>=1;i--){
		s[i]=s[i-1];
	}
	dp[0]=0;
	for (int i=1;i<=n;i++){
		dp[i]=max(dp[i],dp[i-1]);
		if (i>=3 && s[i]=='1' && s[i-1]=='0' && s[i-2]=='1'){
			int j=i-2;
			while (j>=1 && s[j]=='1'){
				dp[i]=max(dp[i],dp[j-1]+i-j-1);
				j--;
			}
		}
		if(i<=n-2 && s[i]=='1' && s[i+1]=='0' && s[i+2]=='1'){
			int j=i+2;
			while (j<=n && s[j]=='1'){
				dp[j]=max(dp[j],dp[i-1]+j-i-1);
				j++;
			}
		}
		//cout<<dp[i]<<endl;
	}
	cout<<dp[n]<<endl;
	return 0;
}
//1010101011101010101

Measured memory_bytes: 2820
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void solve(){
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    map<ll,ll>mp;ll pos=1;ll time=1;
    while(mp[pos]==0){
        mp[pos]=time;
        time++;
        pos=a[pos-1];
    }
    //cout<<time-mp[pos];
    if(k>n)
    {
        k-=mp[pos]-1;
        //cout<<k;
        ll period = k%(time-mp[pos]);
        ll currpos = pos;
        while(period>0){
            currpos=a[currpos-1];
            period--;
        }
        cout<<currpos;
    }
    else
    {
        ll currpos=1;
        while(k>0)
        {
            currpos=a[currpos-1];
            k--;
        }
        cout<<currpos;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 17192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin>>n>>m;
  if(n/2<m) {
    cout<<-1<<endl;
    return 0;
  }
  int a[n];
  for(int i=0; i<n; i++) a[i]=i+1;
  while(m--) {
    for(int i=0; i<n/2; i++) {
      cout<<a[i]<<" "<<a[n-i-1]<<endl;
      if(n%2||i!=n/2-1)cout<<a[n-i-1]<<" "<<a[i+1]<<endl;
    }
    if(!m) break;
    cout<<endl;
    rotate(a,a+1,a+n);
  }
  return 0;
}


Measured memory_bytes: 3136
#include <iostream>
using namespace std;
 
int main(){
    int n,x;
    cin >> n;
 
    for(int i = 1; i<= n; i++){
        if(i%3 == 0){
            cout << " " << i;
        }else{
            x = i;
            do{
                if(x%10 == 3){
                    cout << " " << i;
                    break;
                }
                x /=10;
            }while(x);
        }
    }
    cout << endl;
}


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

using namespace std;

const int ms = 1e2 + 17;
int arr[3][ms];
int sum_pref[ms];
int sum_suf[ms];

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

    int n;
    cin >> n;

    for(int i = 1; i <= 2; ++i)
        for(int j = 1; j <= n; ++j)
            cin >> arr[i][j];

    for(int i = 1; i <= n; ++i)
        sum_pref[i] = arr[1][i] + sum_pref[i - 1];

    for(int i = n; i >= 1; --i)
        sum_suf[i] = arr[2][i] + sum_suf[i + 1];

    int answer = 0;

    for(int i = 1; i <= n; ++i)
        answer = max(answer , sum_pref[i] + sum_suf[i]);

    cout << answer << '\n';
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print(max(0, a - 2 * b))
    return

#B
def B():
    n = II()
    d = LI()
    ans = 0
    for i in range(n):
        for k in range(i+1, n):
            ans += d[i] * d[k]
    print(ans)
    return

#C
def C():
    n = II()
    s = S()
    i = 0
    ans = 1
    for i in range(1, n):
        if s[i - 1] == s[i]:
            continue
        ans += 1
    print(ans)
    return

#D
def D():
    n = II()
    l = LI()
    l.sort()
    ans = 0
    for i in range(n - 1, 0, -1):
        for k in range(i - 1, -1, -1):
            ab = l[i] - l[k]
            c = max(0, k - bisect_right(l, ab))
            ans += c
    print(ans)
    return

#E
def E():
    n, m, l = LI()
    dist = [[inf] * n for i in range(n)]

    for _ in range(m):
        a, b, c = LI_()
        c += 1
        if c > l:
            continue
        dist[a][b] = c
        dist[b][a] = c

    supply = [[n] * n for i in range(n)]
    for k in range(n):
        distk = dist[k]
        for i in range(n):
            if i == k:
                continue
            disti = dist[i]
            distik = dist[i][k]
            for j in range(i + 1, n):
                if distik + distk[j] < disti[j]:
                    disti[j] = distik + distk[j]
                    dist[j][i] = disti[j]

    lis = [[] for i in range(n)]
    for i in range(n):
        for j in range(i + 1, n):
            if dist[i][j] <= l:
                supply[i][j] = 0
                supply[j][i] = 0
                lis[i].append(j)
                lis[j].append(i)

    for i in range(n):
        q = []
        for k in lis[i]:
            heappush(q, (0, k))
        supplyi = supply[i]

        while q:
            time, p = heappop(q)
            for k in lis[p]:
                if supplyi[k] > time + 1:
                    supplyi[k] = time + 1
                    heappush(q, (time + 1, k))

    q = II()
    for _ in range(q):
        s, t = LI_()
        if dist[s][t] == inf:
            print(-1)
            continue
        else:
            print(supply[s][t])
    return


#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 44636
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

int main(void){
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    REP(i,n) cin >> a[i] >> b[i] >> c[i];

    int dp[3][n+5];
    dp[0][0] = dp[1][0] = dp[2][0] = 0;

    for(int i = 0; i < n + 3; i++){
        dp[0][i+1] = max(dp[1][i], dp[2][i]) + a[i];
        dp[1][i+1] = max(dp[0][i], dp[2][i]) + b[i];
        dp[2][i+1] = max(dp[1][i], dp[0][i]) + c[i];
    }

    cout << max(dp[0][n], max(dp[1][n], dp[2][n])) << endl;
    
    return 0;
}

Measured memory_bytes: 5956
import java.util.Scanner

fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    
    val S = reader.nextInt()
    
    val h = S / (60 * 60)
    val m = S % (60 * 60) / 60
    val s = S % 60

    println("${h}:${m}:${s}")
}


Measured memory_bytes: 25628
//problem_c.go

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//"sort"
	//"strings"
)

const (
	constMod = int(1e9) + 7
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

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

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

func getIntSlice(n int) []int {
	ns := []int{}
	for i := 0; i < n; i++ {
		ns = append(ns, getInt())
	}
	return ns
}

func getIntDoubleSlice(m int, n int) [][]int {
	var nds [][]int
	for i := 0; i < m; i++ {
		ns := getIntSlice(n)
		nds = append(nds, ns)
	}
	return nds
}

func getFloat() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getFloatSlice(n int) []float64 {
	fs := []float64{}
	for i := 0; i < n; i++ {
		fs = append(fs, getFloat())
	}
	return fs
}

func getFloatDoubleSlice(m int, n int) [][]float64 {
	var fds [][]float64
	for i := 0; i < m; i++ {
		fs := getFloatSlice(n)
		fds = append(fds, fs)
	}
	return fds
}

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

func getStringSlice(n int) []string {
	ss := []string{}
	for i := 0; i < n; i++ {
		ss = append(ss, getString())
	}
	return ss
}

func getStringDoubleSlice(m int, n int) [][]string {
	sds := [][]string{}
	for i := 0; i < m; i++ {
		ss := getStringSlice(n)
		sds = append(sds, ss)
	}
	return sds
}

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

// Num Fanction

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

	return x
}

func numModPow(a int, n int, m int) int {
	result := 1

	for n > 0 {
		if n%2 == 1 {
			result = (result * a) % m
		}
		a = (a * a) % m
		n >>= 1
	}

	return result
}

func numGcd(a int, b int) int {
	if b == 0 {
		return a
	}

	return numGcd(b, a%b)
}

func numLcm(a int, b int) int {
	return a * b / numGcd(a, b)
}

func numModInv(a int, p int) int {
	if a == 1 {
		return 1
	}

	return p - numModInv(p%a, p)*(p/a)%p
}

func numModFrac(n int) []int {
	frac := []int{1}

	for i := 1; i <= n; i++ {
		frac = append(frac, i*frac[i-1]%constMod)
	}

	return frac
}

func numModConb(n int, r int) int {
	frac := numModFrac(n)

	return (frac[n] / ((frac[n-r] * frac[r]) % constMod)) % constMod
}

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

// sort
// sort.SliceStable(SLICENAME, func(i, j int) bool { return SLICENAME[i] < SLICENAME[j] })

// reverse sort
// sort.SliceStable(SLICENAME, func(i, j int) bool { return SLICENAME[i] > SLICENAME[j] })

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

func solve() {

	k := getInt()
	sum := 0

	for a := 1; a <= k; a++ {
		for b := 1; b <= k; b++ {
			for c := 1; c <= k; c++ {
				gcd_ab := numGcd(a, b)
				gcd_abc := numGcd(gcd_ab, c)
				sum += gcd_abc
			}
		}
	}

	fmt.Fprintln(wr, sum)
}

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

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}


Measured memory_bytes: 1784
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(BigInt,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  h,w=pM(split(readline()))
  if h==1 || w==1
    println(1)
  else
    println(cld(h*w,2))
  end
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 112896