akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    ll N; cin >> N;
    ll count = 0, idx = 1;
    while(true){
        ll tmp = idx * 10 + 1;
        bool ok = true;
        for(ll i = 2; i * i <= tmp; i++){
            if(tmp % i == 0){
                ok = false; break;
            };
        }
        if(ok){
            cout << tmp << " "; count++;
        };
        if(count == N) break;
        idx++;
    }
    cout << endstr;
    return 0;
}


Measured memory_bytes: 256
#!/bin/python3

import math
import os
import random
import re
import sys



if __name__ == '__main__':
    n = int(input())
    h = []
    for _ in range(n):
        h.append(list(map(int, input().split())))

    dp = []
    for _ in range(n):
        dp.append([])
        for _ in range(3):
            dp[-1].append(0)

    for i in range(n):
        for j in range(3):
            for k in range(3):
                if k != j:
                    dp[i][j] = max((dp[i - 1][k] if i - 1 >= 0 else 0) + h[i][j], dp[i][j])

    ans = max(dp[-1])
    print(ans)

Measured memory_bytes: 47976
#include<bits/stdc++.h>
using namespace std;
int main(){int n;
cin>>n;
vector<int>v;
           int input;
unordered_map<int,int>m;           
for(int i=0;i<n-1;i++){
cin>>input;
v.push_back(input);
m[v[i]]++; 
  }
for(int i=0;i<n;i++){
  if(m.find(i+1)!=m.end())
cout<<m[i+1]<<" ";
  else
    cout<<0<<" ";
}    
  cout<<endl;         
}

Measured memory_bytes: 12400
#define _USE_MATH_DEFINES
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <list>
#include <algorithm>
#include <sstream>
#include <set>
#include <math.h>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>
 
using namespace std;

typedef long long ll;

ll S,T,A,B;

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

for(int i=0; i<N; i++){

  ll L=1,M=1;

  scanf("%lld %lld",&T,&A);

  if(i==0){
    S=T; B=A;
  }

  if(S>T){
    if(S%T==0) M=S/T;
    else M=S/T+1;
  }
  if(B>A){
    if(B%A==0) L=B/A;
    else L=B/A+1;
  }

  S=T*max(M,L); B=A*max(M,L);
  
}

cout<<S+B<<endl;

return 0;
 
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

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

	public static class Task {
		static final long MOD = (long) 1e9 + 7;
	
		public void solve() {
			Scan sc = new Scan();
			int n = (int) sc.scanLong();
			int m = (int) sc.scanLong();
			int res = 1;
			for(int i = 1, end = (int) Math.sqrt(m); i <= end; ++i){
				if(m%i == 0){
					int j = m/i;
					int tres = (j >= n ? i : 0);
					tres = Math.max(tres, i >= n ? j : 0);
					res = Math.max(res, tres);
				}
			}
			System.out.println(res);
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  
  if(N % 2 == 0) {
    cout << N / 2 << endl;
  }
  else{
    cout << (N / 2) + 1 << endl;
  }
  
}
  
  

Measured memory_bytes: 256
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  
  if 0 in A:
    print(0)
    return
  
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
    
  print(prod)
  
main ()


Measured memory_bytes: 21652
#include <iostream>
#include <vector>

using namespace std;

int main(){
	vector<int> x;
	while(1){
		int temp;
		cin>>temp;
		if (temp==0){
			break;
		}
		x.push_back(temp);
	}
	for (vector<int>::size_type i=0;i<x.size();i++){
		cout<<"Case "<<i+1<<": "<<x[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1320
/*
 *Author - Abhas Jain
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
    int a, b;
    cin >> a >> b;
    int c = (a + b) / 2;
    if (abs(a - c) == abs(b - c)) {
    	cout << c << endl;
    } else {
    	cout << "IMPOSSIBLE" << endl;
    }
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
Ap = list(map(int, input().split()))
Bq = list(map(int, input().split()))
Cr = list(map(int, input().split()))

Ap.sort(reverse = True)
Bq.sort(reverse = True)

L = sorted(Ap[:X] + Bq[:Y] + Cr, reverse = True)

print(sum(L[:X+Y]))

Measured memory_bytes: 108436
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
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; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

int main() {
	string h;
	cin >> h;
	int ans = 0;
	if (h.length() % 2 == 0) {
		for (int i = 0; i < h.length() / 2; ++i) {
			if (h[i] != h[h.length() - i - 1]) { ++ans; }
		}
	}
	else {
		for (int i = 0; i < h.length() / 2; ++i) {
			if (h[i] != h[h.length() - i-1]) { ++ans; }
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	vector<ll> arr(n, 0);
	unordered_map<ll, ll> mp;
	f(i, 0, n)
	{
		cin >> arr[i];
		if (mp.find(arr[i] + i) == mp.end())
			mp[arr[i] + i] = 1;
		else
			mp[arr[i] + i] += 1;
	}
	ll ans = 0;
	rf(j, n-1, 0)
	{
		if (mp.find(arr[j] + j) != mp.end() && mp[arr[j]+j]>0)
			mp[arr[j] + j] -= 1;
		if (j - arr[j] > 0)
			ans += mp[j - arr[j]];
	}
	cout << ans;
	return 0;
}

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

int main(void) {
  int S, h, m, s;
  cin >> S;
  h = S / 3600;
  m = (S - h * 3600) / 60;
  s = S - h * 3600 - m * 60;
  cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3084
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (r, ) = [int(e) for e in lines[0].split(' ')]

    return (r, )


def solve(r):

    
    return  2 * r * math.pi
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 62148
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 1e6 + 111;
        
using namespace std;          

int n, m, a[maxn], ans[maxn];

void solve(){                             
	cin >> n;

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

	int sum = 0;

	for (int i = 1; i <= n; i++)
		sum += (ans[i] - 1) * ans[i] / 2;

	for (int i = 1; i <= n; i++){
		sum -= (ans[a[i]] - 1) * ans[a[i]] / 2;
		ans[a[i]]--;
		cout << sum + (ans[a[i]] - 1) * ans[a[i]] / 2 << endl;
		ans[a[i]]++;
		sum += (ans[a[i]] - 1) * ans[a[i]] / 2;
	}
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}


Measured memory_bytes: 7296
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
const int N = 2e5 + 10;
vector<int> G[N];
int n, t[2], k[3], dep[N], ans[N];
void dfs(int u, int F, int d)
{
	t[d]++;
	dep[u] = d;
	for (int v : G[u])
		if (v != F)
			dfs(v, u, d ^ 1);
}
int main()
{
	n = read();
	for (int i = 1; i < n; ++i)
	{
		k[i % 3]++;
		int u = read(), v = read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	k[n % 3]++;
	dfs(1, 0, 0);
	int p = 0;
	if (t[0] > t[1])
		swap(t[0], t[1]), p = 1;
	if (k[0] >= t[0])
	{
		for (int i = 1; i <= n; ++i)
			if (dep[i] == p)
				ans[i] = k[0]-- * 3;
		for (int i = 1; i <= n; ++i)
			if (dep[i] != p)
			{
				if (k[0])
					ans[i] = k[0]-- * 3;
				else if (k[1])
					ans[i] = (k[1]-- - 1) * 3 + 1;
				else
					ans[i] = (k[2]-- - 1) * 3 + 2;
			}
	}
	else if (k[1] <= t[0])
	{
		for (int i = 1; i <= n; ++i)
			if (dep[i] == p)
			{
				if (k[1])
					ans[i] = (k[1]-- - 1) * 3 + 1;
				else
					ans[i] = k[0]-- * 3;
			}
		for (int i = 1; i <= n; ++i)
			if (dep[i] != p)
			{
				if (k[0])
					ans[i] = k[0]-- * 3;
				else if (k[1])
					ans[i] = (k[1]-- - 1) * 3 + 1;
				else
					ans[i] = (k[2]-- - 1) * 3 + 2;
			}
	}
	else
		assert(false);
	for (int i = 1; i <= n; ++i)
		printf("%d ", ans[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 19072
n, m, l = map(int, input().split())
mat_a = [list(map(int, input().split())) for _ in range(n)]
mat_b = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    row = []
    for j in range(l):
        tmp = 0
        for k in range(m):
            tmp += mat_a[i][k]*mat_b[k][j]
        row.append(tmp)
    print(*row)



Measured memory_bytes: 6584
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe
import           Data.Vector           ((!))
import qualified Data.Vector           as V

main :: IO ()
main = do
  n <- readLn
  a <- V.fromList . map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
  let
    solve i = if i == n
      then 0
      else (if (a!(a!i-1)) == i+1 then 1 else 0) + solve (i+1)
  print $ solve 0 `div` 2


Measured memory_bytes: 10620
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>  
#include <stdio.h>  
#include <string>
#include <string.h>
#include <stdlib.h>  
#include <math.h>  
#include <queue>  
#include <stack>
#include <set>
#include <map>  
#include <vector>  
#include <algorithm>
#include <time.h>
#define ms(a) memset(a,0,sizeof(a)) 
#define inf 0x3f3f3f3f
#define MAX 100010
#define MX 10010
#define ll long long
using namespace std;
int a[MAX], par[MAX];
int findpar(int x)//直到最?属于的集合
{
	if (x != par[x])par[x] = findpar(par[x]);
	return par[x];
}
int main()
{
	int t, n, m, o, x, y, z;
	cin >> n >> m;
	bool oper;
	for (int i = 0; i < n; i++)
	{
		par[i] = i;//初始化各自?一个集合
	}
	for (int i = 0; i < m; i++)
	{
		cin >> oper >> x >> y;
		if (!oper){
			x = findpar(x);//得集合?
			y = findpar(y);
			//算法?化
			if (a[x]>a[y])par[y] = x;//小集合跟上大集合
			else{
				par[x] = y;
				if (a[x] == a[y])a[y]++;
			}
		}
		else printf(findpar(x) == findpar(y) ? "1\n" : "0\n");
	}
	return 0;
}

Measured memory_bytes: 3308
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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 T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    ll N,K;
    cin >> N >> K;
    cout << (K==1 ? 0 :N-K) << endl;
}

Measured memory_bytes: 256
# your code goes here
n = input()
res = 1
num_str = input()  # 1 3 2 1 2
num_str_arr = num_str.split(' ')
num_arr = [int(x) for x in num_str_arr]
done = 0
for x in num_arr:
	if x == 0:
		res = 0
	if res <= 1000000000000000000:
		res = res * x
if res > 1000000000000000000:
	print(-1)
else:
	print(res)

Measured memory_bytes: 23448
# https://atcoder.jp/contests/abc118/tasks/abc118_b


N, M = gets.split.map(&:to_i)
Ks = Array.new(N)
Ass = Array.new(N)
N.times do |i|
  Ks[i], *Ass[i] = gets.split.map(&:to_i)
end

ans = Ass.flatten.group_by(&:itself).count { |k, vs| vs.count == N }

puts ans


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

map<long long, long long> a;

int main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    
    int k;
    cin >> k;

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

    int ind = 10;
    int i = 1;
    while (ind <= 100000) {
        int d = a[i] % 10;
        if (d >= 1 && d < 9) {
            a[ind] = a[i] * 10 + (d - 1);
            // cout << a[ind] << " ";
            ind++;

            a[ind] = a[i] * 10 + d;
            // cout << a[ind] << " ";
            ind++;
            
            a[ind] = a[i] * 10 + (d + 1);
            // cout << a[ind] << endl;
            ind++;
        }
        else if (d == 0) {
            a[ind] = a[i] * 10 + d;
            // cout << a[ind] << " ";
            ind++;
            
            a[ind] = a[i] * 10 + (d + 1);
            // cout << a[ind] << endl;
            ind++;           
        }
        else {
            a[ind] = a[i] * 10 + (d - 1);
            // cout << a[ind] << " ";
            ind++;

            a[ind] = a[i] * 10 + d;
            // cout << a[ind] << endl;
            ind++;
        }
        //cout << i << endl;
        i++;
    }
    cout << a[k];

    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N, K, Q;
	cin >> N >> K >> Q;

	vector <ll> cnt(N, 0);
	for (int ii = 0; ii < Q; ++ii){
		ll A;
		cin >> A;
		A--;
		cnt[A]++;
	}

	for (int ii = 0; ii < N; ++ii){
		ll minus = Q - cnt[ii];
		if (K - minus <= 0){
			cout << "No" << "\n";
		} else {
			cout << "Yes" << "\n";			
		}
	}


	return 0;
}


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

using ll = long long;

constexpr ll M = 1e9 + 7;

int main() {
    int N;
    string s1, s2;
    cin >> N;
    cin >> s1 >> s2;
    ll res = 0;
    for(int i = 0; i < N; ) {
        if(s1[i] == s2[i]) {
            if(i == 0) {
                res = 3;
            } else {
                if(s1[i - 1] == s2[i - 1]) {
                    res = (res * 2) % M;
                }
            }
            i++;
        } else {
            if(i == 0) {
                res = 6;
            } else {
                if(s1[i - 1] == s2[i - 1]) {
                    res = (res * 2) % M;
                } else {
                    res = (res * 3) % M;
                }
            }
            i += 2;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
N = int(input())
import itertools
#N = 6
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

NN = factorization(N)

# N-1について
NN_1 = factorization(N-1)
#print(NN_1)
ans = 0
tmp = 1
for i in NN_1:
    tmp *= i[1]+1
ans += tmp - 1
#print(ans)

#
P = []
IKU = []
PP = []
for i in NN:
    P.append(i[0])
    j = i[1]
    tmp = []
    for k in range(j+1):
        tmp.append(k)
    PP.append(tmp)
    IKU.append(i[1])
L = len(P)
#print('aaa')
for i in itertools.product(*PP):
    tmp = 1
    for j in range(L):
        tmp *= P[j]**i[j]
    K = tmp
    tmp = 1

    if K != 1:
        #print('K',K)
        for j in range(1,41):
            tmp *= K
            if N<tmp:
                break
            #print(tmp)
            if (N-tmp)%(tmp*K)==0:
                ans += 1
                #print('YES',K)
                break
            
#print(NN_1)
#print(NN)
if N==2:
    print(1)
else:
    print(ans)


Measured memory_bytes: 40176
#include <iostream>

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

    for (int x = 0; x <= 50000; ++x) {
        int px = x * 108 / 100;
        if (px == n) {
            std::cout << x << std::endl;
            return 0;
        }
    }

    std::cout << ":(" << std::endl;
    return 0;
}


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

int main(){
    int n;
    std::cin>>n;
    std::vector<int> S(n);
    for(int i=0;i<n;i++){
        std::cin>>S[i];
    }
    int q;
    std::cin>>q;
    std::vector<int> T(q);
    for(int i=0;i<q;i++){
        std::cin>>T[i];
    }

    int ans=0;

    for(int i=0;i<T.size();i++){
        int cnt=0;
        for(int j=0;j<S.size();j++){
            if(S[j]==T[i]){
                cnt=1;
                break;
            }
        }
        if(cnt==1){
            ans++;
        }
    }

    std::cout<<ans<<'\n';
}



Measured memory_bytes: 3052
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,s,n) for(ll i=(s);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

map<ll,ll> prime;

void factorization(ll x){
    for(ll i=2;i*i<=x;i++){
        while(x%i==0){
            prime[i]++;
            x/=i;
        }
    }
    if(x!=1)prime[x]++;
    return;
}

int main(){
    ll n;cin>>n;
    rep2(i,2,n+1)factorization(i);
    ll ans=1;
    rep2(i,2,n+1){
        if(prime.count(i)){
            ans*=(prime[i]+1)%inf;
            ans%=inf;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.util.Scanner;

public class Main {


	public static void main(String args[]) {
        InputStream inputStream = System.in;
        Scanner sc = new Scanner(inputStream);
        String out;
        //String N=sc.next();
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println((A-1)*(B-1));

	}

}

Measured memory_bytes: 21716
#include<stdio.h>

int n, a[50];

int soleve2(int i, int m)
{
	if (m == 0)
		return true;
	if (i >= n)
		return false;
	int ret = soleve2(i + 1, m) || soleve2(i + 1, m - a[i]);
}

int main()
{
	int q, M, i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	scanf("%d", &q);
	for (i = 0; i < q; i++)
	{
		scanf("%d", &M);
		if (soleve2(0, M))
			printf("yes\n");
		else
			printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 2692
import Foundation

extension String {
    @inlinable
    func wordsMap<T>(_ f: (Substring) -> T?) -> [T] {
        return self.split(separator: " ").compactMap(f)
    }
}

@inlinable
func readWords<T>(_ f: (Substring) -> T?) -> [T] {
    return readLine()!.wordsMap(f)
}

    let nh = readLine()!.wordsMap { Int($0) }
    let n = nh[0]
    let h = nh[1]

    var maxA = 0
    let weapons = (1...n).map { _ -> Int in
        let ab = readWords { Int($0) }
        let a = ab[0]
        let b = ab[1]
        maxA = max(a, maxA)
        return b
    }

    let niceB = weapons.filter { $0 > maxA }.sorted(by: >)

    var total = 0
    var ans = 0
    for b in niceB {
        total += b
        ans += 1
        if total >= h {
            print(ans)
            exit(0)
        }
    }

    let rest = h - total

    print((rest % maxA == 0 ? 0 : 1) + rest / maxA + ans)


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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int N;
  cin >> N;
  int gcd = 0, maxA = 0;
  vector<int> cnts(1e6 + 5);
   for (int i = 0, e; i < N; i++) {
    cin >> e;
    if (!gcd)
      gcd = e;
    gcd = __gcd(gcd, e);
    maxA = max(maxA, e);
    cnts[e]++;
  }

  bool flag = true;
  for (int i = 2; i <= maxA; i++) {
    int cnt = 0;
    for (int p = i; p <= maxA; p += i) {
      cnt += cnts[p];
    }
    if (cnt > 1) {
      flag = false;
    }
  }

  if (flag) {
    cout << "pairwise coprime";
    return;
  }

  if (gcd == 1) {
    cout << "setwise coprime";
    return;
  }
  cout << "not coprime";
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  // cout << nl;
  // }

  return 0;
}

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

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

int main() {
  ioinit();
  int N, K;
  long double ret = 0;
  cin >> N >> K;
  for(int i = N; i >= 1; i--){
    ret += (long double)pow(0.5, (int)ceil(log2(max((double)K/i, 1.0))));
  }
  ret /= (long double)N;
  cout << setprecision(12) << ret << endl;
}


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

int main() {
    int n; cin >> n;
    using pii = pair<int, int>;
    vector<pii> vp(n);
    for (auto &p: vp) cin >> p.first >> p.second;
    sort(vp.begin(), vp.end(), [](const pii &a, const pii &b) {
        if (a.first == b.first) return a.second < b.second;
        return a.first < b.first;
    });
    for (auto p: vp) cout << p.first << " " << p.second << endl;
    return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>

int main(void) {
  char s[1001];
  scanf("%s", s);
  printf("%s", s);
  if(s[strlen(s)-1] != 's') {
    printf("s\n");
  }
  else {
    printf("es\n");
  }
  return 0;
}

Measured memory_bytes: 1728
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
import random  # randome is not available at Codeforces
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#eps=10**(-10)
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n=I()
a=sorted(LI())[::-1]

def solve(a):
    s=set()
    for i in a:
        s.add(i)
    s=sorted(list(s))[::-1]
    L=1010
    k=[0]*(L)
    ak=[0]
    for i in a:
        k[i]+=1
    for i in range(L):
        ak.append(ak[-1]+k[i])
    ans,a1,a2,a3,a4=0,0,0,0,0
    un=len(s)
    for i in range(un):
        c=s[i]
        if k[c]>=3:
            a1+=k[c]*(k[c]-1)*(k[c]-2)//6
        if k[c]>=2:
            a2+=ak[c]*k[c]*(k[c]-1)//2
        for j in range(i+1,un):
            sc=s[j]
            a3+=(1 if 2*sc>c else 0)*k[c]*k[sc]*(k[sc]-1)//2
            mm=c-sc+1
            if mm<0:
                continue
            elif mm>sc:
                break
            else:
                a4+=k[c]*k[sc]*(ak[sc]-ak[mm])
            
    ans=a1+a2+a3+a4
    return ans,a1,a2,a3,a4

def naive(a):
    b=sorted(a)[::-1]
    n=len(b)
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                if b[j]+b[k]>b[i]:
                    ans+=1
    return ans

print(solve(a)[0])


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl

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

  ll gcd;
  ll a=n, b=m;
  while(true){
    ll ma = max(a,b);
    ll mi = min(a,b);
    if(ma%mi == 0) {
      gcd = mi;
      break;
      }
      a = mi;
    b = ma%mi;
  }
  ll ng = n/gcd;
  ll mg = m/gcd;
  ll ans = ng * mg * gcd;
  REP(i,gcd){
    if(s[i*ng]!=t[i*mg]) ans = -1;
  }
  
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

const ll INTEG = pow(10,9) + 7;

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

  int X[n][d];

  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> X[i][j];
    }
  }

  int count = 0;

  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      double distance2 = 0.0;

      for(int k = 0; k < d; k++){
        distance2 += pow(X[i][k] - X[j][k],2);
      }

      double dist = pow(distance2,0.5);

      if(dist == (int)dist){
        count++;
      }
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 640
// AOJ 2635 Snake
// 2018.3.19 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

// [library]

//#define getchar_unlocked()  getchar()
int in()	// get non-negative integer from stdin
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

typedef struct { int x, y; } PP;

#define INF		 1e8
#define EPS		 1e-8
#define EQ(a,b)  (fabs((a)-(b))<EPS)

PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double cross(PP a, PP b) { return (double)a.x * b.y - (double)a.y * b.x; }

double polygon_area(int n, PP *p)
{
   int i;
   double s;

   if (n < 3) return 0;
   s = 0; p[n] = p[0];
   for (i = 0; i < n; i++) s += cross(p[i], p[i+1]);
   return fabs(s)/2;
}

int cmp(PP *a, PP *b) {
	if (a->y - b->y) return a->y - b->y;
	return a->x - b->x;
}

int convex_hull(int n, PP *ps, PP *po)
{
	int i, k, j = 0;

	qsort(ps, n, sizeof(PP), cmp);
	for (i = 0; i < n; i++) {
		while (j > 1 && cross(vsub(po[j-1], po[j-2]), vsub(ps[i], po[j-1])) <= 0) j--;
		po[j++] = ps[i];
	}
	k = j;
	for (i = n - 2; i >= 0; i--) {
		while (j > k && cross(vsub(po[j-1], po[j-2]), vsub(ps[i], po[j-1])) <= 0) j--;
		po[j++] = ps[i];
	}
	return j-1;
}
// [\library]  

PP  snake[1002];
PP  pp[2][1002];

void reverse(int n, PP *p)
{
	int i, j;
	memcpy(pp[0], p, sizeof(PP)*n);
	j = n, i = 0; while (j--) p[i++] = pp[0][j];
}

int check(int n, PP *p)
{
	int i, k, k1, k2;
	double prev, s;

	prev = 0, k = 0, k1 = 0, k2 = 1;
	for (i = 0; i < n; i++) {
		pp[k1][k++] = p[i];
		if (i < 2) continue;
		k = convex_hull(k, pp[k1], pp[k2]);
		s = polygon_area(k, pp[k2]);
		if (EQ(s, prev)) return 0;
		prev = s, k1 = k2, k2 = !k2;
	}
	return 1;
}

int main()
{
	int n, i, ans;

	n = in();
	for (i = 0; i < n; i++) snake[i].x = in(), snake[i].y = in();
	ans = 0;
	if (check(n, snake)) {
		reverse(n, snake);
		if (check(n, snake)) ans = 1;
	}
	puts(ans? "Possible": "Impossible");
	return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T &a, T b){if(a > b){ a = b; return true;} return false;}

int main(){
    int n, k; cin >> n >> k;
    int dp[n+5], h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 0; i < n; i++){
        dp[i] = 1001001001;
    }
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; j <=k; j++){
            if(i - j >= 0) chmin(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
n = int(input())
if n < 600:
    ans = 8
elif  n < 800:
    ans = 7
elif n < 1000:
    ans = 6
elif n < 1200:
    ans = 5
elif  n < 1400:
    ans = 4
elif  n < 1600:
    ans = 3
elif  n < 1800:
    ans = 2
else:
    ans = 1
print(ans)


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

int main(){
    int n, q;
    cin >> n >> q;
    
    string s;
    cin >> s;
    
    vector<int> l(q), r(q);
    rep(i, q){
        cin >> l.at(i) >> r.at(i);
    }

    int count = 0;
    vector<int> d(n+1);
    for(int i = 2; i <= n; i++){
        if(s.at(i-2) ==  'A' && s.at(i-1) == 'C') count++;
        d.at(i) = count;
    }
    
    rep(i, q){
        cout << d.at(r.at(i)) - d.at(l.at(i)) << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
using System;

class Program
{
    static int Main()
    {
        int max = 0, cnt = 0,h;
        int n = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        for(var i=0; i<n; i++)
        {
            h = int.Parse(input[i]);
            if (max <= h)
            {
                max = h;
                cnt++;
            }
        }
        Console.WriteLine(cnt.ToString("d"));
        return 0;
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


const int MAX = 1110000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if(n > k) cout << 0 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 3168
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _016_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            var freq = new int[26];
            int cnt = s.Length - 1;
            var dict = new Dictionary<char, int>();
            for(int i = 0; i < s.Length; i++)
            {
                if (!dict.ContainsKey(s[i])) dict.Add(s[i], 0);

                dict[s[i]]++;
            }
            foreach(char c in dict.Keys)
            {
                string ss = s;
                if (dict[c] == s.Length)
                {
                    Console.WriteLine(0);
                    return;
                }
                for(int j = 0; j < s.Length; j++)
                {
                    string sss = "";
                    int sameCnt = 0;
                    for (int k = 0; k < ss.Length - 1; k++)
                    {
                        if (ss[k] == c||ss[k+1]==c)
                        {
                            sss += c;
                            sameCnt++;
                        }
                        else
                        {
                            sss += ss[k];
                        }
                    }
                    ss = sss;
                    if (sameCnt == ss.Length)
                    {
                        cnt = Math.Min(cnt, j + 1);
                    }
                }
            }
            Console.WriteLine(cnt);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 17360
import bisect
n=int(input())
a=list(map(int, input().split()))
plus=[0]*n
minus=[0]*n
ans=0

for i in range(n):
    plus[i]=i+a[i]+1
    minus[i]=i-a[i]+1
p=sorted(plus)
m=sorted(minus)
for i in range(n):
    l_index=bisect.bisect_left(p,m[i])
    r_index=bisect.bisect_right(p,m[i])
    ans+=r_index-l_index
print(ans)

Measured memory_bytes: 36416
parseline(str=readline()) = parse.(Int, split(str))
function binarysearches(arr, left, right)
    r = searchsortedfirst(arr, right) - 1
    l = searchsortedlast(arr, left) + 1
    ans = r - l + 1
    return max(0, ans)
end
function Triangles()
    N = parse(Int, readline())
    L = sort(parseline())
    ans = 0
    for n in N:-1:2
        for m in n-1:-1:1
            b = binarysearches(L, L[n]-L[m], L[n]+L[m])
            ans += L[n]<2L[m] ? b - 2 : b - 1
        end
    end
    println(ans÷3)
end
Triangles()

Measured memory_bytes: 176988
#include<iostream>
using namespace std;
int a[100][100],b[100][100],c[100][100],d[100][100],t[100][100],n,sum=0,x,mx;
void init();
int main(){
  init();
  mx=t[0][0];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=i;k<n;k++){
	for(int l=j;l<n;l++){
	  x=a[k][l];
	  if(i>0)x-=a[i-1][l];
	  if(j>0)x-=a[k][j-1];
	  if(i>0&&j>0)x+=a[i-1][j-1];
	  if(mx<x){
	    mx=x;
	  }
	}
      }
    }
  }
  cout<<mx<<endl;
  
}
void init(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>t[i][j];
      sum+=t[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      a[i][j]=t[i][j];
      if(i>0)a[i][j]+=a[i-1][j];
      if(j>0)a[i][j]+=a[i][j-1];
      if(i>0&&j>0)a[i][j]-=a[i-1][j-1];
    }	
  }

  
}

Measured memory_bytes: 1240
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    double revAns = 0;
    rep(i,N) revAns += double(1)/A[i];
    cout << setprecision(6) << 1/revAns << nn;
    return 0;
}

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

class union_find  // union find.
{
	int* U;
public:
	union_find(int n){ U = new int [n + 1]; for(int i = 1; i <= n; i++) U[i] = i; }
	int root(int a){ if(U[a] == a){ return a; } U[a] = root(U[a]); return U[a]; }
	bool same(int a, int b){ return root(a) == root(b); }
	void join(int a, int b){ int x = root(a), y = root(b); U[x] = y; }
	~union_find(){ delete [] U; }
};

struct edge{ int v1, v2; int weight; };  // edge.

edge init(){
	edge e;
	e.v1 = 0; e.v2 = 0; e.weight = -1;
	return e;
}

edge init(int a, int b, int w){
	edge e;
	e.v1 = a; e.v2 = b; e.weight = w;
	return e;
}

void swap_e(edge e1, edge e2)
{
	swap(e1.v1, e2.v1); swap(e1.v2, e2.v2); swap(e1.weight, e2.weight);
}

class edge_heap  // heap.
{
	edge* E;
	int edge_n;
public:
	edge_heap(int n){ E = new edge [n + 1]; edge_n = 0; }
	void min_heap(int i);
	void insert_heap(edge e);   // sorting.
	void insert_nl(edge e);     // no sorting.
	edge delete_min();
	bool isEmpty(){ return edge_n == 0; }
	int total_weight();
	~edge_heap(){ delete [] E; }
};

void edge_heap::min_heap(int i)
{
	int l = 2 * i, r = 2 * i + 1;
	if(l > edge_n && r > edge_n) return;
	int minid = i;
	if(l <= edge_n){ if(E[l].weight < E[minid].weight) minid = l; }
	if(r <= edge_n){ if(E[r].weight < E[minid].weight) minid = r; }
	if(minid == i) return;
	swap(E[minid], E[i]);
	min_heap(minid);
}

void edge_heap::insert_heap(edge e)
{
	edge_n++;
	int w = e.weight;
	int i = edge_n;
	while(i > 1){
		if(w < E[i / 2].weight){
		E[i] = E[i / 2];
		}else{ break; }
		i /= 2;
	};
	E[i] = e;
}
void edge_heap::insert_nl(edge e){ edge_n++; E[edge_n] = e; }

edge edge_heap::delete_min()
{
	edge e = E[1];
	E[1] = E[edge_n]; edge_n--;
	min_heap(1);
	return e;
}

int edge_heap::total_weight()
{
	int tw = 0;
	for(int i = 1; i <= edge_n; i++) tw += E[i].weight;
	return tw;
}

int main()
{
	int n, i, j, w;
	cin >> n;
	edge_heap EH(n * (n + 1) / 2); // All Edge heap.
	edge e;

	for(i = 1; i <= n; i++){
		for(j = 1; j <= n; j++){
			cin >> w;
			if(j <= i || w < 0) continue;
			e = init(i, j, w);
			EH.insert_heap(e);
		}
	}

	edge_heap TH(n);   // Tree heap.

	union_find VG(n);  // vertex group.

	while(!EH.isEmpty()){
		e = EH.delete_min();
		if(!VG.same(e.v1, e.v2)){
			VG.join(e.v1, e.v2);
			TH.insert_nl(e);
		};
	};

	cout << TH.total_weight() << endl;

	return 0;
}

Measured memory_bytes: 1248