akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x,long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }

        public static long C(long n,long k)
        {
            long x=1;
            for (long i = 1; i <=k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = Reads();
            var d = new Dictionary<long, long>();
            for (int i = 0; i < n; i++)
            {
                if (d.ContainsKey(a[i])) d[a[i]]++;
                else d.Add(a[i], 1);
            }
            long ans = 0;
            var f = false;
            var nd = d.OrderByDescending(x => x.Key);
            foreach (var item in nd)
            {
                if (item.Value >= 4)
                {
                    if (f)
                    {
                        ans *= item.Key;
                        break;
                    }
                    else
                    {
                        ans = item.Key * item.Key;
                        break;
                    }
                }
                else if (item.Value >= 2)
                {
                    if (f)
                    {
                        ans *= item.Key;
                        break;
                    }
                    else
                    {
                        ans = item.Key;
                        f = true;
                    }
                }
            }
            WriteLine(ans);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 42864
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
const int mod = 1e9 + 7;
inline ll inv(ll a){
	ll b = mod, x = 1, y = 0;
	while(b){
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		x -= t * y;
		swap(x, y);
	}
	return (mod + x % mod) % mod;
}
int pw(int n, int m){
	int res = 1;
	for(; m; m /= 2){
		if(m & 1) res = res * (ll)n % mod;
		n = (ll)n * n % mod;
	}
	return res;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, a, b; cin >> n >> a >> b;
	ll ans = (pw(2, n) + mod - 1) % mod;
	
	ll x = 1, y = 1;
	rep(i, a) x = x * (n - i) % mod * inv(i + 1) % mod;
	rep(i, b) y = y * (n - i) % mod * inv(i + 1) % mod;
	
	ans = (ans + mod - x + mod - y) % mod;
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n;
  int x;
  int t;
  cin >> n >> x >> t;
  int ans;
  ans = n / x * t;
  if (n % x > 0) {
    ans += t;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>

using namespace std;

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

int main() {


	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int ri = in.nextInt();
		int wi = in.nextInt();
		int c = in.nextInt();
		int r = in.nextInt();
		if (ri + wi + c + r == 0) return false;

		int l = -1, u = 1<<30;
		while (u - l > 1) {
			int m = (l + u)/2;
			if (ri + (long)m*r >= (long)wi*c) u = m;
			else l = m;
		}

		out.println(u);

		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

int main() {
  int N;
  cin >> N;
  
  string ans;
  ans="No";
  if(N>0 and N<10){
    ans="Yes";
  }else{
    for (int i=9;i>0;i--) {
      int mod;
      mod=N % i;
      if(mod==0){
        int sho;
        sho=N / i;
        if(sho < 10){
          ans="Yes";
          break;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int X = scanner.nextInt();
        int A = scanner.nextInt();

        if(X < A){
            System.out.println(0);
        }else{
            System.out.println(10);
        }
    }
}

Measured memory_bytes: 22996
from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
kind = defaultdict(int)
for d in D:
  kind[d] += 1

M = int(input())
T = list(map(int, input().split()))
for t in T:
  kind[t] -= 1
  if kind[t] < 0:
    print('NO')
    quit()

print('YES')

Measured memory_bytes: 46560
#!/usr/bin/env ruby

if __FILE__ == $0 then
	loop do
		card = gets.chomp
		if card == '-' then
			break
		end

		gets.chomp.to_i.times do
			h = gets.chomp.to_i
            card = card[h..-1]+card[0,h]
		end
		puts card
	end
end


Measured memory_bytes: 6876
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  string S,ans="NO";
  cin>>S;
  int N[3];
  rep(i,3)N[i]=0;
  rep(i,S.size())N[S[i]-'a']+=1;
  sort(N,N+3);
  if(N[2]-N[0]<=1)ans="YES";
  cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		while(true) {
			n=sc.nextInt();
			if(n==0)break;
			int ans[] = new int[n];
			String test;

			for(int i=0;i<n;i++) {
				test  = sc.next();
				ans[i] = test.length();
			}

			boolean flag[] = new boolean[5];


			for(int i=0;i<n;i++) {
				int f1=0,f2=0,f3=0,f4=0,f5=0;
				int ansdata = 0;

				while(ansdata<=5) {
					ansdata += ans[i+f1];
					f1++;
					if(ansdata==5) {
						flag[0]=true;
						break;
					}
				}

				ansdata=0;
				while(ansdata<=7) {
					ansdata += ans[i+f1+f2];
					f2++;
					if(ansdata==7) {
						flag[1]=true;
						break;
					}
				}

				ansdata =0;
				while(ansdata<=5) {
					ansdata += ans[i+f1+f2+f3];
					f3++;
					if(ansdata==5) {
						flag[2]=true;
						break;
					}
				}


				ansdata=0;
				while(ansdata<=7) {
					ansdata += ans[i+f1+f2+f3+f4];
					f4++;
					if(ansdata==7) {
						flag[3]=true;
						break;
					}
				}


				ansdata=0;
				while(ansdata<=7) {
					ansdata += ans[i+f1+f2+f3+f4+f5];
					f5++;
					if(ansdata==7) {
						flag[4]=true;
						break;
					}
				}




				if(flag[0]&&flag[1]&&flag[2]&&flag[3]&&flag[4]) {
					System.out.println((i+1));
					for(int j=0;j<5;j++)flag[j]= false;
					f1=0;f2=0;f3=0;f4=0;f5=0;
					break;
				}else {
					for(int j=0;j<5;j++)flag[j]= false;
					f1=0;f2=0;f3=0;f4=0;f5=0;
				}


			}




		}

		sc.close();
	}
}


Measured memory_bytes: 32636
use proconio::input;
fn main() {
    input! {
        n: i64,
    }
    println!(
        "{}",
        (1..=n)
            .filter(|&x| x % 3 != 0 && x % 5 != 0)
            .fold(0, |sum, a| sum + a)
    );
}

Measured memory_bytes: 2164
from collections import deque
N,M=map(int,input().split(' '))
chk = [0 for i in range(N+1)]
chk[0]=chk[1]=1
maze = [[] for i in range(N+1)]
for i in range(M):
    a,b=list(map(int,list(input().split(' '))))
    maze[a].append(b)
    maze[b].append(a)
l = deque([1])
while l:
    n = deque.popleft(l)
    for i in maze[n]:
        if not chk[i]:
            chk[i]=n
            l.append(i)
if 0 in chk:
    print('No')
    exit()
print('Yes')
for i in chk[2:]:
    print(i)

Measured memory_bytes: 34856
package main

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

var n = 1000

func main() {
	X := nextInt64()
	f := make([]int64, n)

	for i := 0; true; i++ {
		f[i] = int64(i*i) * int64(i*i*i)

		if i > 0 && f[i]-f[i-1] > int64(10e9) {
			n = i
			break
		}
	}
	for j := 0; j < n; j++ {
		for i := 0; i < n; i++ {
			// (+i)^5 - (+j)^5
			if f[i]-f[j] == X {
				fmt.Printf("%d %d\n", i, j)
				return
			}
			// (+i)^5 - (-j)^5
			if f[i]+f[j] == X {
				fmt.Printf("%d %d\n", i, -j)
				return
			}
		}
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

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

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 1796
"""
author : halo2halo
date : 15, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

H, W, h, w = map(int, read().split())
print((H - h) * (W - w))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long,long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S,T;
    cin >> S >>T;
    int N = S.size();
    int ans = 0;
    REP(i,N) {
        if(S[i] != T[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3864
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int result = 0;
    for (int i = 1; i <= n; i += 2) {
        int count = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0)
                count++;
        }
        if (count == 8)
            result++;
    }

    cout << result << endl;

    return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    int a[m], st[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    for(int i = 0; i < m; i++) cin >> a[i];
    string dp[11000]; // i本使って作れる最大値
    for(int i = 0; i < 11000; i++) dp[i] = "-";
    dp[0] = "";
    for(int i = 0; i <= n; i++){
        for(int j = 0; j < m; j++){
            if(dp[i] == "-") continue;
            int idx = i + st[a[j] - 1];
            string t1 = dp[idx];
            string t2 = dp[i] + (char)('0' + a[j]);
            if(dp[idx] == "-" || t1.size() < t2.size()) dp[idx] = t2;
            else if(t1.size() == t2.size()) dp[idx] = (t1 < t2 ? t2 : t1);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 44928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

vector<PAIR> e;

signed main() {
  INIT;
	VAR(int,n);

	REP(i,n){
		REP(j,i){
			e.push_back(make_pair(i+1,j+1));
			//debug(i);
			//debug(j);
		}
	}

	REP(i,e.size()) {
		if(n%2==0){
			if(e[i].first+e[i].second == n+1) {
				e.erase(e.begin()+i);
				--i;
			}
		} else{
			if(e[i].first+e[i].second == n) {
				//debug(e[i].first);
				//debug(e[i].second);
				e.erase(e.begin()+i);
				--i;
			}
		}
	}

	OUT(e.size())BR;
	REP(i,e.size()) {
		//debug(e[i].first);
		//debug(e[i].second);
		OUT(e[i].first)SP;OUT(e[i].second)BR;
	}
  
  return 0;
}


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

using namespace std;

int main(){
    int Age, Cost;
    cin >> Age >> Cost;
    if(Age >= 13){
        cout<< Cost<< endl;
    }
    else if(Age >= 6){
        cout << Cost/2 << endl;
    }
    else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

vector<pii> G[100000];
pii farestNode;

void visit(int n, int p, int w)
{
	if (G[n].size() == 1 && G[n][0].first == p)
	{
		if (w > farestNode.second)
		{
			farestNode = pii(n, w);
		}
		return;
	}
	for (auto& m : G[n])
	{
		if (m.first != p)
		{
			visit(m.first, n, w + m.second);
		}
	}
}

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

	farestNode = pii(-1, 0);

	int V;
	scanf("%d", &V);

	for (int i = 0; i < V - 1; i++)
	{
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);

		G[u].push_back(pii(v, w));
		G[v].push_back(pii(u, w));
	}

	visit(0, -1, 0);
	int t = farestNode.first;
	farestNode = pii(-1, 0);
	visit(t, -1, 0);
	printf("%d\n", farestNode.second);

	return 0;
}


Measured memory_bytes: 13280
def process():
    try:
        n = int(raw_input().strip())
    except ValueError:
        return True
    except EOFError:
        return False
    a = [int(i) for i in raw_input().strip().split()]
    s = {}
    s[0] = 1
    c = 0
    foo = 0
    for i in xrange(n):
        c += a[i]
        if c in s:
            foo += s[c]
            s[c] += 1
        else:
            s[c] = 1
    print foo
    return True

def main():
    while True:
        if not process():
            break
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 31616
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		Integer arr[]=new Integer[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		}
		Arrays.sort(arr);
		System.out.println(arr[(n/2)]-arr[n/2-1]);
	}
}


Measured memory_bytes: 61328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

vector<int> L;
int N, A, B, C;
const int INF = 1 << 30;
int rec(int index, int a, int b, int c)
{
    if (N == index)
    {
        if (!a || !b || !c)
        {
            return INF;
        }
        else
        {
            return abs(A - a) + abs(B - b) + abs(C - c);
        }
    }
    int res = rec(index + 1, a, b, c);
    res = min(res, rec(index + 1, a + L[index], b, c) + (a ? 10 : 0));
    res = min(res, rec(index + 1, a, b + L[index], c) + (b ? 10 : 0));
    res = min(res, rec(index + 1, a, b, c + L[index]) + (c ? 10 : 0));
    return res;
}

int main()
{
    cin >> N >> A >> B >> C;

    for (int i = 0; i < N; i++)
    {
        int l;
        cin >> l;
        L.push_back(l);
    }

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

    return 0;
}

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

a = int(input())
b = int(input())
c = int(input())

x = int(input())


pettern = 0
for i in range(0, a + 1):
    temp_x = x - (i * 500)

    if temp_x == 0:
        pettern += 1

    if temp_x <= 0:
        break

    # 500円玉を使った後のパターン
    for j in range(0, b + 1):
        temp_x2 = temp_x - (j * 100)

        if temp_x2 == 0:
            pettern += 1

        if temp_x2 <= 0:
            break

        # 100円玉を使った後のパターン
        for k in range(0, c + 1):
            temp_x3 = temp_x2 - (k * 50)

            if temp_x3 == 0:
                pettern += 1

            if temp_x3 <= 0:
                break

print(pettern)


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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;++i) cin >> v[i];
  cout << abs(*max_element(v.begin(),v.end())-*min_element(v.begin(),v.end())) << endl;
  

  return 0;
}

Measured memory_bytes: 256
from collections import deque
N, X, Y = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(N - 1):
    G[i].append(i + 1)
    G[i + 1].append(i)
G[X - 1].append(Y - 1)
G[Y - 1].append(X - 1)

L = [0] * N
for i in range(N - 1):
    dist = [N] * N
    dist[i] = 0
    Q = deque()
    Q.append(i)
    while len(Q) > 0:
        q = Q.popleft()
        for j in G[q]:
            if dist[j] != N:
                continue
            dist[j] = min(dist[q] + 1, dist[j])
            Q.append(j)
    for k in range(i, N):
        if dist[k] != N and dist[k] != 0:
            L[dist[k]] += 1
for i in range(1, N):
    print(L[i])

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
   fast;
   int n,m;
   cin >> n >> m;
   int sum = 0 ,a;
   while(m--){
      cin >> a;
      sum += a;
   }
   if(sum > n){
      cout << -1;
   }
   else{
      cout << n-sum;
   }
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	ll sum=0,cur=0;
	rep(i,n){
		sum+=abs(cur-a.at(i));
		cur=a.at(i);
	}
	sum+=abs(cur);
	rep(i,n){
		ll num=sum;
		if(i==0){
			num=num-abs(a.at(i))-abs(a.at(i)-a.at(i+1))+abs(a.at(i+1));
		}
		else if(i==n-1){
			num=num-abs(a.at(i-1)-a.at(i))-abs(a.at(i))+abs(a.at(i-1));
		}
		else{
			num=num-abs(a.at(i-1)-a.at(i))-abs(a.at(i+1)-a.at(i))+abs(a.at(i-1)-a.at(i+1));
		}
		cout << num << endl;
	}
}

Measured memory_bytes: 1664
function Main(input){
  
  var str = input;
  var tmp = str.split(" ").map(Number);

  if(tmp[0]==tmp[1] && tmp[1]==tmp[2]){
     console.log("Yes");}
  
  else {
       console.log("No");}
    
}//function
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N, M ;
  cin >> N;
  vector<string> s(N) ;
  cinf(N,s) ;
  cin >> M ;
  vector<string> t(M) ;
  cinf(M,t) ;
  
  int ans =0 ;
  rep(i,N){
    int sum =0;
    rep(j,N){
      if(s[i] == s[j])
        sum ++;
    }
    rep(j,M){
      if(s[i] == t[j])
        sum -- ;
    }
    ans = max(ans,sum) ;
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];
    set<ll> X(A.begin(), A.end());
    set<ll> Y(B.begin(), B.end());
    if (X.size() != A.size() || Y.size() != B.size()) {
        cout << 0 << '\n';
        return;
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    ll ans = 1;
    rrep(i, N * M, 1) {
        if (X.count(i) && Y.count(i)) {
            continue;
        } else if (X.count(i)) {
            ll cnt = B.size() - (lower_bound(B.begin(), B.end(), i) - B.begin());
            ans *= cnt;
            ans %= MOD;
        } else if (Y.count(i)) {
            ll cnt = A.size() - (lower_bound(A.begin(), A.end(), i) - A.begin());
            ans *= cnt;
            ans %= MOD;
        } else {
            ll cnt1 = A.size() - (lower_bound(A.begin(), A.end(), i) - A.begin());
            ll cnt2 = B.size() - (lower_bound(B.begin(), B.end(), i) - B.begin());
            ans *= (cnt1 * cnt2 - (N * M - i));
            ans %= MOD;
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rd read()
#define maxn 500001
int a[maxn];
int ans1,ans2;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
}
bool cmp(int x,int y)
{
	return x>y;
}
int main() {
	int n=rd;
    for(int i=1;i<=n;i++) a[i]=rd;
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++) {
        if(i%2==1) ans1+=a[i];
        if(i%2==0) ans2+=a[i];
    }
    cout<<ans1-ans2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  
  int n;cin >> n;
  string s;cin >> s;
  int f = 0;
  int p = s[0];
  for(int i=1;i<n;i++){
    if(s[i]==p) continue;
    else f++,p=s[i];
  }
  f++;
  cout << f << endl;

  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <iostream>
// 18:45 -
using namespace std;

int main(void)
{
    while(1){
        int n, p;
        scanf("%d %d", &n, &p);
        if(n == 0 & p == 0)
            break;
        int mine[n];
        for(int i = 0; i < n; i++) mine[i] = 0;
        int all = 0;
        int count = 0;
        while(1){
            all = 0;
            if(p > 0){
                p--;
                mine[count % n]++;
                for(int i = 0; i < n; i++) all += mine[i];
                all -= mine[count % n];
                if(all == 0 && p == 0){
                    break;
                }
            } else if(p == 0){
                p += mine[count % n];
                mine[count % n] = 0;
            }
            count++;
        }
        printf("%d\n", count % n);
    }

    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int G[8][8];


int main() {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      G[i][j] = 0;
    }
  }
  
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b; a--; b--;
    G[a][b] = 1; G[b][a] = 1;
  }
  
  vector<int> v;
  for (int i = 0; i < N; i++) {
    v.push_back(i);
  }
  
  int ans = 0;
  do {
    bool ok = true;
    for (int i = 0; i < N-1; i++) {
      if (G[v[i]][v[i+1]] == 0) {ok = false;}
    }
    if (ok) {ans++;}
  } while (next_permutation(v.begin()+1, v.end()));
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import math

def is_prime(n):
  if n == 1:
    return False

  for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
      return False
  return True

N = int(input())

pn_l = []
for i in range(2, N + 1):
  if is_prime(i):
    pn_l.append(i)

ans = 1
n_factorial = math.factorial(N)
for pn in reversed(pn_l):
  s = 0
  while n_factorial % pn == 0:
    s += 1
    n_factorial //= pn
  ans *= s + 1 
print(ans % (10**9+7))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
}

Measured memory_bytes: 256
// TODO: 
// https://www.geeksforgeeks.org/sqrt-square-root-decomposition-set-2-lca-tree-osqrth-time/
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100001

int block_sz;          // block size = sqrt(height)
int depth[MAXN];       // stores depth for each node.
int parent[MAXN];      // stores first parent for each node.
int jump_parent[MAXN]; // stores first ancestor in previous block.
vector<int> adj[MAXN];

void addEdge(int u, int v){
    adj[u].push_back(v);
    adj[v].push_back(u);
}

int LCANaive(int u,int v){
    if(u == v)              return u;
    if(depth[u] > depth[v]) swap(u, v);
    v = parent[v];
    return LCANaive(u, v);
}

// precalculating the required parameters associated with every node.
void dfs(int cur, int prev){
    // marking depth of cur node
    depth[cur] = depth[prev] + 1;
    
    // marking parent of cur node
    parent[cur] = prev;
    
    // making jump_parent of cur node
    // if it is first node of the block then its jump_parent is its cur parent.
    if (depth[cur] % block_sz == 0) jump_parent[cur] = parent[cur];
    // if it is not the first node of this block then its jump_parent is jump_parent of its parent.
    else                            jump_parent[cur] = jump_parent[prev];
    
    // propogating the marking down the subtree
    for(int i = 0; i < adj[cur].size(); ++i) if(adj[cur][i] != prev) dfs(adj[cur][i], cur);
}

// using sqrt decomposition trick
int LCASQRT(int u, int v){
    while(jump_parent[u] != jump_parent[v]){
        // maintaining depth[v] > depth[u]
        if(depth[u] > depth[v]) swap(u, v);
        // climb to its jump parent
        v = jump_parent[v];
    }
    // u and v have same jump_parent
    return LCANaive(u, v);
} 

void preprocess(int height){
    block_sz = sqrt(height);
    depth[0] = -1;
    // precalclating 1) depth.  2) parent.  3) jump_parent for each node
    dfs(0, 0);
}

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    for(int i = 0, s, t, w; i < N; ++i){
        int k;
        scanf("%d", &k);
        for(int j = 0; j < k; ++j){
            int c;
            scanf("%d", &c);
            addEdge(i, c);
        }
    }
    
    // 2. 事前処理.
    preprocess(MAXN);
    
    // 3. 各判定クエリに対し, 出力を行う.
    int Q;
    scanf("%d", &Q);
    for(int i = 0; i < Q; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        printf("%d\n", LCASQRT(u, v));
    }
    
    // 4. 後処理.
    return 0;
}


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

int main() {
	int a, b, c;
	
	cin >> a >> b >> c;

	if (a + b < b + c) {
		if (a + b < c + a)cout << a + b;
		else cout << c + a;
	}
	else if (b + c < c + a) {
		if (b + c < a + b)cout << b + c;
		else cout << a + b;
	}
	else {
		if (c + a < b + c)cout << c + a;
		else cout << b + c;
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll dp[51][51],n,a[100],b[100],ans,pw[100];
vector<ll>g;
bool check(vector<ll>v){
    for(int i=0; i<=50; i++)
        for(int j=0; j<=50; j++)
            dp[i][j] = 0;
    for(int i=0; i<=50; i++){
        dp[i][i] = 1;
        for(int j=0; j<=50; j++)
            for(int l=0; l<v.size(); l++)
                dp[i][j] |= dp[i % v[l]][j],
                dp[i][i%v[l]] = 1;
    }
    for(int i=1; i<=n; i++)
        if(!dp[a[i]][b[i]])
            return false;
    return true;
}
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    ll ok = 1;
    for(int i=1; i<=n; i++){
        cin >> b[i];
        if(a[i] != b[i])ok = 0;
    }
    
    if(ok == 1){
        cout << 0 << endl;
        return 0;
    }
    pw[0] = 1LL;
    for(int i=1; i<=50; i++){
        pw[i] = pw[i - 1] * 2LL;
    }
    
    for(int i=1; i<=50; i++){
        g.pb(i);
        if(check(g)){
            vector<ll>nec;
            nec.pb(i);
            for(int j=i-1; j>=1; j--){
                for(int l=1; l<j; l++)
                    nec.pb(l);
                if(check(nec) == 0){
                    for(int l=1; l<j; l++)
                        nec.pop_back();
                    nec.pb(j);
                }
                else{
                    for(int l=1; l<j; l++)
                        nec.pop_back();
                }
            }
            for(int j=0; j<nec.size(); j++)
                ans += pw[nec[j]];
            cout << ans << '\n';
            return 0;
        }
    }
    
    cout << -1;
    
    
    return 0;
}


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

using namespace std;

int main()
{
    int d,t,s;

    cin>>d>>t>>s;

    double k=(double)d/s;


    if((double)t>=k){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


    return 0;
}


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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int A, B; cin >> A >> B;
    if ((A+B) % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (A+B)/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int prime[1000000];
void eratosthenes(){
    for(int i = 0; i < 1000000; i++)    prime[i] = 1;
    prime[0] = prime[1] = 0;
    for(int i = 0; i * i <= 1000000; i++)
        if(prime[i])
            for(int j = i * 2; j < 1000000; j += i)
                prime[j] = 0;
}

int main(){
    int n;
    eratosthenes();
    while(cin >> n){
        int ans = 0;
        rep(i, n + 1)if(prime[i])ans++;
        cout << ans << endl;
    }
}

Measured memory_bytes: 6996
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n, k;
vector<int> a;
vector<int> dp(100005, -1);

int memo_rec(int rest = k){
    if(dp[rest] != -1)  return dp[rest];
    if(rest == 0)   return dp[rest] = 0;

    int is_win = 1;
    bool is_possible = false;
    for(int i = 0; i < n; ++i){
        if(a[i] > rest) continue;
        is_possible = true;
        is_win &= memo_rec(rest - a[i]);
    }
    cerr << is_win << endl;
    if(!is_possible)    return dp[rest] = 0;
    return dp[rest] = is_win ^ 1;
}

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

    cin >> n >> k;
    a.resize(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];

    if(memo_rec())  cout << "First\n";
    else    cout << "Second\n";
}

Measured memory_bytes: 6912
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;


char s[N];

int main() {
	scanf("%s", s+1);
	int n = strlen(s+1);
	int L = 1e9, R = -1;
	REP(i,1,n) {
		if (s[i]=='A') L=min(L,i);
		if (s[i]=='Z') R=max(R,i);
	}
	int ans = max(0, R-L+1);
	printf("%d\n",ans);
}








Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Blue ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,n) for(int i=a;i<n;++i)
typedef vector<int> vi;
typedef long long ll;
const int mod=1e9+7;
 
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
vector<ll>q;

ll getAns(ll m){
	ll x=0;
	auto it=upper_bound(all(q),m)-q.begin()-1;
	return it;
}

void solve(){
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=0;i<=65;i++){
		q.pb(((i+1)*i)/2);
	}
	for(ll i=2;i*i<=n;i++){
		ll cnt=0;
		while(n%i==0){
			cnt++;
			n/=i;
		}
		ans+=getAns(cnt);
	}
	if(n>1)ans++;
	cout<<ans;
 
}
 
 
int main(){
	Blue;
	int test=1;
	//cin>>test;
	while(test--)
		solve();
	return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		int N = keyboard.nextInt();
		//キーがStringで中身がintのHashMapを作る
		HashMap<String, Integer> count = new HashMap<String, Integer>();
		
		for (int s=0; s<N; s++) {
			String S = keyboard.next();
			if (count.containsKey(S)) { //HashMapに既にキーがあるとき
				int now = count.get(S); //キーSに紐づく中身のintを取得
				count.replace(S, now + 1);
			}
			else {
				count.put(S, 1); //まだHashMapにキーが登録されていないなら、登録する
			}
		}
		
		int Max = 0;
		for (int val: count.values()) { 
			if (Max <= val) {
				Max = val;
			}
		}
		
		List<String> print = new ArrayList<String>();
		
		for (String s: count.keySet()) { 
			int now = count.get(s);
			if (now == Max) {
				print.add(s);
			}
		}
		Collections.sort(print);
		
	    for (int i = 0 ; i < print.size() ; i++){
	        String ans = print.get(i);
	        System.out.println(ans);
	    }
		keyboard.close();
	}
	
}


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

#define ll long long int
using namespace std;
int main()
{
    ll n,i,j,k;
    cin>>n;
    if(n<10)
    {
        cout<<n<<endl;
    }
    else if(n>=10&&n<=99)
    {
        cout<<9<<endl;
    }
    else if(n>=100&&n<=999)
    {
        cout<<9+n-100+1<<endl;
    }
    else if(n>=1000&&n<=9999)
    {
        cout<<909<<endl;
    }
    else if(n>=10000&&n<=99999)
    {
        cout<<909+n-10000+1<<endl;
    }
    else if(n==100000)
    {
        cout<<909+90000<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> ans(N-1, 0);
  int dist_min;
  for (int i=1; i<=N-1; i++) {
    for (int j=i+1; j<=N; j++) {
      dist_min = min(abs(j-i), min(abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)));
      ans[dist_min-1]++;
    }
  }
  for (int i=0; i<N-1; i++) cout << ans[i] << endl;
}

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

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define len(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>


signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  cin >> n;
  map<ll,ll> majj;
  ll res = 0;
  rep(i,n){
    ll a; cin >> a;
    ll aii = a-i;
    if(majj.find(aii)!=majj.end())
      res += majj[aii];
    majj[-(a+i)]++;
  }
  cout << res << endl;
  ret;
}


Measured memory_bytes: 16008
n = int(input())
a = list(map(int,input().split()))

a.sort()
isBad = False
pre = -1
for i in range(n):
    if(pre==a[i]):
        isBad=True
        break
    pre = a[i]


if(isBad):
    print('NO')
else:
    print('YES')

Measured memory_bytes: 26808
n,a,b,c,d = map(int,input().split())
plus = [a,a]
minus = [a,a]
ans = 'NO'
if n%2 == 0:
    plus = [a+c,a+d]
    minus = [a-d,a-c]
can = (n-1)//2
delta = d-c
for i in range(can+1):
    if plus[0]-delta*(can-i) <= b <= plus[1] + delta*(can-i):
        ans = 'YES'
        break
    if minus[0] - delta*(can-i) <= b <= minus[1] + delta*(can-i):
        ans = 'YES'
        break
    plus[0] += 2*c
    plus[1] += 2*d
    minus[0] -= 2*d
    minus[1] -= 2*c
print(ans)


Measured memory_bytes: 3064
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;

void main() {
  auto input = readln.split.map!(to!int);
  int N = input[0];
  int T = input[1];
  auto A = readln.split.map!(to!int).array;
  auto M = new int[](N);

  M[N-1] = A[N-1];
  foreach (i; iota(N-2, -1, -1))
    M[i] = max(M[i+1], A[i]);

  auto L = new int[](N);
  int m = 0;
  foreach (i; iota(N-1)) {
    L[i] = M[i+1] - A[i];
    m = max(m, L[i]);
  }

  int ans = 0;
  foreach (i; iota(N-1))
    if (L[i] == m)
      ans++;
  writeln(ans);
}


Measured memory_bytes: 4148
#include <iostream>

using namespace std;

void call(int n){
    int i = 1;
    CHECK_NUM:
    int x = i;
    if ( x % 3 == 0 ){
        cout << " " << i;
        goto END_CHECK_NUM;
    }
    INCLUDE3:
    if ( x % 10 == 3 ){
        cout << " " << i;
        goto END_CHECK_NUM;
    }
    x /= 10;
    if ( x ) goto INCLUDE3;
    END_CHECK_NUM:
    if ( ++i <= n ) goto CHECK_NUM;

    cout << endl;
}


int main() {
    int n; cin >> n;
    call(n);
    return 0;
}




Measured memory_bytes: 3116
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2019-12-13 14:53:56
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++)
        cin >> d[i];

    LL ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i < j) {
                ans += d[i]*d[j];
            }
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include <typeinfo>
using namespace std;
int main(void){
    // Your code here!
    int x,a,b;
    
    int sums=0;
    int& sum_a=sums;
    
    int sumf=0;
    int& sum_b=sumf;
    
    cin>>x>>a>>b;
    sum_a=x-a;
    sum_b=x-b;

    if(sum_a<0) sum_a=sum_a*-1;
    if(sum_b<0) sum_b=sum_b*-1;
    
    if(sum_a>sum_b) cout<<"B"<<endl;
    else cout<<"A"<<endl;

}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef vector<int> VI;
typedef pair<int, int> PII;
# define mp make_pair
# define pb push_back
# define FOR(i, a, b) for (int i = a; i <= b; ++i)
# define FDR(i, a, b) for (int i = a; i >= b; --i)
const int N = 100005;
const int MOD = 1000000007;
// code begin...


int main ()
{
    int n, k;
    cin >> n >> k;
    puts(n % k == 0 ? "0" : "1");
    return 0;
}


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

int main() {
  int A;
  string S;
  cin >> A;
  S = "No";
  for (int i=1; i<10; i++) {
    for (int j=1; j<10; j++) {
      if (i*j == A) {
        S = "Yes";
      }
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 256
//g++  5.4.0

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

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;


signed main()
{
    fast;
    int n , x ; 
    cin >> n >> x;
    vector<int> y;
    int pr;
    cin >> pr;
    int z = pr;
    for(int i=0 ; i<x-1; i++ )
    {
        int cur;
        cin >> cur;
        y.pb( cur-pr );
        pr = cur;
    }
    z += (n-pr);
    y.pb(z );
    for(int i=0; i<x ; i++ )
        y.pb(y[i]);
    int sum = 0;
    int ans;
    for(int i=0 ; i<x-1 ; i++ )
        sum += y[i];
    ans =sum;
    int j=0;
    for(int i=x-1; i<2*x ; i++ )
    {
        sum -= y[j++];
        sum += y[i];
        ans = min(ans,sum);
    }
    cout << ans;
}

Measured memory_bytes: 6512