akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;

int main() {
    cin >> n;
    vector<ll> lvec(n, 0);
    for(int i = 0; i < n; ++i) cin >> lvec[i];
    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {
            for(int k = j+1; k < n; ++k) {
                if(lvec[i] != lvec[j] && lvec[j] != lvec[k] && lvec[k] != lvec[i]) {
                    // cout << i << " " << j << " " << k << endl;
                    vector<ll> tri(3);
                    tri[0] = lvec[i];
                    tri[1] = lvec[j];
                    tri[2] = lvec[k];
                    sort(tri.begin(), tri.end());
                    ll hen = tri[0]+tri[1];
                    if(hen > tri[2]) cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] s = br.readLine().split(" ");
        int[] a = new int[n+2];
        
        for (int i = 0; i < n; i++) {
            a[i+1] = Integer.parseInt(s[i]);
        }
        
        int distance = 0;
        for (int i = 0; i <= n; i++) {
            distance += Math.abs(a[i+1]-a[i]);
        }
        
        //System.out.println(distance);
        int init_dis = distance;
        
        for (int i = 1; i <= n; i++) {
            distance -= Math.abs(a[i+1]-a[i]) + Math.abs(a[i]-a[i-1]) - Math.abs(a[i+1]-a[i-1]);
            System.out.println(distance);
            distance = init_dis;
        }
        
    }
}





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

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

    int ans = 0;
    for (int i = 0; i < 4; i++)
    {
        if (s[i] == '2')
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			int[][] mapV = new int[n+2][n+2];
			int[][] mapH = new int[n+2][n+2];
			int[][] mapRU = new int[n+2][n+2];
			int[][] mapRD = new int[n+2][n+2];
			
			String s = "";
			int max = 0;
			for(int i=1;i<=n;i++){
				s = sc.next();
				for(int j=1;j<=n;j++){
					if(s.codePointAt(j-1)==49){
						mapV[i][j] = mapV[i-1][j]+1;
						mapH[i][j] = mapH[i][j-1]+1;
						mapRU[i][j] = mapRU[i-1][j+1]+1;
						mapRD[i][j] = mapRD[i-1][j-1]+1;
						max = Math.max(Math.max(Math.max(Math.max(mapV[i][j], mapH[i][j]), mapRU[i][j]),mapRD[i][j]),max);
					}
				}
			}
			System.out.println(max);
		}
	}	
}

Measured memory_bytes: 29924
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
using ll = long long;


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

	ll a, b;
	if (n>=2) a = n-2;
	else a = 1;
	if (m>=2) b = m-2;
	else b = 1;
	cout << a * b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    ll min=m;
    ll ans,i=0;
    while(true)
    {
        if((i+k-1)>=n)break;
        min=a[i+k-1]-a[i];
        if(min<ans)
            ans=min;
        i++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4016
#include<stdio.h>
#include<stdlib.h>
#define N 500001
#define S 1000000001

int c = 0;

void Merge(int A[],int left,int mid,int right){

  int n1 = mid-left,n2 = right - mid;
  int i,j,k;
  int L[n1+1],R[n2+1];

  for(i=0;i<=n1-1;i++)
    L[i]=A[left+i];

  for(i=0;i<=n2-1;i++)
    R[i]=A[mid+i];

  L[n1]=S;
  R[n2]=S;
  i = j = 0;

  for(k=left; k<=right-1; k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i = i + 1;
      c++;
    }
    else {
      A[k]=R[j];
      j = j + 1;
      c++;
    }
  }
}
 
void Merge_Sort(int A[], int left, int right){
  int mid;

  if(left+1<right){
    mid = (left + right)/2;
    Merge_Sort(A, left, mid);
    Merge_Sort(A, mid, right);
    Merge(A, left, mid, right);
  }
}

int main(){
  int n,i,A[N];
 
  scanf("%d", &n);

  for(i=0; i<n; i++)
    scanf("%d", &A[i]);
 
  Merge_Sort(A, 0, n);
 
  for(i=0; i<n-1; i++)
    printf("%d ",A[i]);

  printf("%d\n",A[n-1]);
  printf("%d\n",c);
 
  return 0;
   
}


Measured memory_bytes: 5588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt() - 1;
		}
		int[] a = new int[n];
		int[] b = new int[n];
		int[] r = new int[n];
		for (int i = 1; i <= n; i++) {
			r[p[i - 1]] = i;
		}
		for (int i = 1; i <= n; i++) {
			a[i - 1] = 30000 * i;
			b[i - 1] = 30000 * (n - i) + r[i - 1];
		}
		sb.append(a[0]);
		for (int i = 1; i < n; i++) {
			sb.append(" " + a[i]);
		}
		sb.append("\n");

		sb.append(b[0]);
		for (int i = 1; i < n; i++) {
			sb.append(" " + b[i]);
		}
		sb.append("\n");
		System.out.print(sb);
	}
}

Measured memory_bytes: 44324
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math

d = [int(s) for s in stdin.readline().rstrip().split()]
x = d[0]
y = d[1]
res = 0
if x == 1:
    res += 300000
elif x == 2:
    res += 200000
elif x == 3:
    res += 100000

if y == 1:
    res += 300000
elif y == 2:
    res += 200000
elif y == 3:
    res += 100000
if x == 1 and y == 1:
    print(1000000)
else:
    print(res)


Measured memory_bytes: 3572
#include<cstdio>
#include<vector>
using namespace std;
int main(){
        int n;
        vector<bool> ar(1000*1000+1,true);
        for(int i=2;i<=1000;i++){
                if(ar[i])for(int j=i*i;j<ar.size();j+=i)ar[j]=false;
        }
        vector<long> ps;
        for(int i=2;i<ar.size();i++){
                if(ar[i])ps.push_back(i);
                if(ps.size()==10000)break;
        }
        for(int i=1;i<ps.size();i++)ps[i]=ps[i-1]+ps[i];
        for(;;){
                scanf("%d",&n);
                if(n==0) break;
                printf("%ld\n",ps[n-1]);
        }
}

Measured memory_bytes: 0
import sys
sys.setrecursionlimit(1000000)
K = int(input())
all = []
def dfs(number):
    all.append(number)
    if len(str(number)) == 10:
        return
    first_digit = int(str(number)[-1])
    for n_number in range(first_digit-1, first_digit+2):
        if n_number >= 0 and n_number <= 9:
            dfs(number*10+n_number)

for i in range(1, 10):
    dfs(i)
all.sort()
print(all[K-1])

Measured memory_bytes: 12284
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count=0;
		for(int x=0; x<=k; x++) {
			for(int y=0; y<=k; y++) {
				if(0<=s-x-y&&s-x-y<=k) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define print(a,n)  for(lli i=0;i<n;i++)cout<<a[i]<<' ';br
#define br          cout<<endl;
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define upar        1000000007
#define fr(i,a,b)  for(int i=a;i<=b;i++)
using namespace std;

int ans=0;
using namespace std;
void solve()
{
    int a,b;
    cin>>a>>b;

  int ans=1;
  b=b-a;
  ans+=ceil(b/((a-1)*1.0));
  cout<<ans;

}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

    //cin>>t;

    while(t--){
        solve();

    }

    return 0;
}


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

cnt = [0] * 9
for i in a:
    x = min(i // 400, 8)
    if x >= 8:
        cnt[8] += 1
    else:
        cnt[x] = 1

if sum(cnt[:8]) == 0:
    l = 1
    r = cnt[8]
else:
    l = sum(cnt[:8])
    r = l+cnt[8]
print(l, r)

Measured memory_bytes: 8996
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long k;
    int now=1,cum,n,a[210000],b[210005];
    scanf("%d%lld",&n,&k);
    for(int i=1; i<=n; i++) scanf("%d",&a[i]);
    while(k--){
        now=a[now];
        if(b[now])k%=cum-b[now];
        b[now]=cum++;
    }
    printf("%d\n",now);
    return 0;
}


Measured memory_bytes: 5384
from itertools import accumulate
N = int(input())
A = sorted(list(map(int,input().split())))
aa = list(accumulate(A))
aa.reverse()
ans = 1
for i in range(N-1):
    if 3*aa[i+1] >= aa[i]:
        ans += 1
    else:
        break
print(ans)

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

int n;
vector< vector<int> > g;
vector<int> deg;
vector<int> c, a;
int idx;

void dfs(int u, int p) {
  a[u] = c[idx++];
  for (auto& v : g[u]) {
    if (v != p) {
      dfs(v, u);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  deg.assign(n + 1, 0);
  g.resize(n + 1);
  c.resize(n);
  vector< pair<int, int> > edges;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
    deg[a]++;
    deg[b]++;
    edges.push_back({a, b});
  }
  int s = 1;
  for (int i = 1; i <= n; i++) {
    if (deg[i] > deg[s]) {
      s = i;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  sort(c.rbegin(), c.rend());
  a.resize(n + 1);
  dfs(s, -1);
  long long ans = 0;
  for (auto& e : edges) {
    ans += (long long) min(a[e.first], a[e.second]);
  }
  cout << ans << '\n';
  for (int i = 1; i <= n; i++) {
    cout << a[i] << ' ';
  }
  cout << '\n';
  return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

// 約数の全列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll ans = 0;
    for(ll i=1; i<=N; i++){
        if(i%2 == 0) continue;
        vector<ll> k = divisor(i);
        if(k.size() == 8) ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from math import gcd
n = int(input())
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10 ** 6) + 100)

res = s[0]
for ss in s:
    dp[ss] += 1
    res = gcd(res, ss)

A = max(s)
pairwise = True
setwise = (res == 1)

for i in range(2, A + 1):
    cnt = 0
    for j in range(i, A + 1, i):
        cnt += dp[j]
    if cnt > 1:
        pairwise = False
        break

if pairwise:
    print("pairwise coprime")
elif setwise:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 195252
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;



int main()
{
  cout<<fixed<<setprecision(20);
  int n;
  cin>>n;
  vector<double> x(n),y(n);
  for(auto&& e: x) 
  {
    cin>>e;
  }
  for(auto&& e: y) 
  {
    cin>>e;
  }
  auto dist_minc=[&](int p){
    double ret=0;
    for (int i = 0; i < n; ++i)
    {
      ret+=pow(abs(x[i]-y[i]),p);
    }
    return pow(ret,1/(double)p);
  };
  auto dist_cheb=[&]{
    double ret=abs(x[0]-y[0]);
    for (int i = 0; i < n; ++i)
    {
      ret=(ret<abs(x[i]-y[i]))? abs(x[i]-y[i]):ret;
    }
    return ret;
  };
  for (int i = 0; i < 3; ++i)
  {
    cout<<dist_minc(i+1)<<endl;
  }
  cout<<dist_cheb()<<endl;
}


Measured memory_bytes: 3416
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] process = br.readLine().split(" ");
        int psNum = Integer.parseInt(process[0]);
        int time = Integer.parseInt(process[1]);
        Queue<String> que = new Queue<String>();
        Queue<String> result = new Queue<String>();
        int totaltime = 0;
        
        for(int i = 0; i<psNum ;i++)que.enqueue(br.readLine());
        
        while(!(que.isEmpty())){
            String[] line = que.dequeue().split(" ");
            if(Integer.parseInt(line[1]) <= time){
                totaltime = totaltime + Integer.parseInt(line[1]);
                result.enqueue(line[0] + " " + totaltime);
            } else {
                totaltime = totaltime + time;
                line[1] = Integer.toString(Integer.parseInt(line[1]) - time);
                que.enqueue(line[0] + " " + line[1]);
            }
        }
        while(!(result.isEmpty())){
            System.out.println(result.dequeue());
        }

    }
    static class Queue<T> {
        final int SIZE = 100000;
        private List<T> values = new LinkedList<T>();
        boolean enqueue(T data) {
            if (data == null) return false;
            if (values.size() == SIZE) {
                return false;
            }
            values.add(data);
            return true;
        }
        T dequeue() {
            T data = null;
            if (values.size() != 0) {
                data = values.remove(0);
            }
            return data;
        }
        boolean isEmpty() {
            return (values.size() == 0);
        }
        boolean isFull() {
            return (values.size() >= 100000);
        }
    }
};


Measured memory_bytes: 77036
N, M = map(int, input().split())
Edge = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    Edge[a-1].append(b-1)
    Edge[b-1].append(a-1)
Used = [False for i in range(N)]
Path = [1, Edge[0][0]+1]
Used[0], Used[Edge[0][0]] = True, True
AFin, BFin = False, False
Anext, Bnext = 0, Edge[0][0]
for node in Edge[0]:
    if not Used[node]:
        Anext = node
        Used[Anext] = True
        break
else: AFin = True
for node in Edge[Bnext]:
    if not Used[node]:
        Bnext = node
        Used[Bnext] = True
        break
else: BFin = True

while not AFin or not BFin:
    if not AFin:
        Path.insert(0, Anext+1)
        for node in Edge[Anext]:
            if not Used[node]:
                Anext = node
                Used[Anext] = True
                break
        else: AFin = True
    if not BFin:
        Path.append(Bnext+1)
        for node in Edge[Bnext]:
            if not Used[node]:
                Bnext = node
                Used[Bnext] = True
                break
        else: BFin = True

print(len(Path))
print(" ".join(map(str, Path)))


Measured memory_bytes: 32896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+100;
string s;
char q[]="hi";
int main() {
    int f = 1,len=0;
    cin>>s;
    for(int i=0; i<s.size(); i++,len=len^1) {
        if(q[len]!=s[i])
            f=0;
    }
    if(f==1&&len==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n,m;
  std::cin >> n >> m;
  vt<int> a(m);
  rep(i,m)
    std::cin >> a[i];

  int t = std::accumulate(a.begin(),a.end(),0);

  std::cout << (n - t >= 0 ? n-t : -1) << '\n';
  return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Snake Toy
            var line = ReadLine();
            int n = line[0];
            int k = line[1];

            var l = ReadLine().OrderByDescending(x => x);

            Console.WriteLine(l.Take(k).Sum());
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}


Measured memory_bytes: 13396
local a = io.read()
local b = io.read()
local alen, blen = #a, #b
local ret = nil

for i = 1, alen + 1 - blen do
  local accept = true
  for j = i, i + blen - 1 do
    local jb = j - i + 1
    local as, bs = a:sub(j, j), b:sub(jb, jb)
    if as ~= "?" and as ~= bs then
      accept = false break
    end
  end
  if accept then
    local str = ""
    for j = 1, alen do
      local jb = j - i + 1
      if jb < 1 or blen < jb then
        local as = a:sub(j, j)
        if as == "?" then as = "a" end
        str = str .. as
      else
        str = str .. b:sub(jb, jb)
      end
    end
    if not ret then
      ret = str
    elseif str < ret then
      ret = str
    end
  end
end
if not ret then print("UNRESTORABLE")
else print(ret) end


Measured memory_bytes: 880
import sys
import bisect
input = sys.stdin.readline
##http://drken1215.hatenablog.com/entry/2019/01/14/033200
def solve():
  n,m = (int(i) for i in input().split())
  a = sorted(list(int(i) for i in input().split()))
  b = sorted(list(int(i) for i in input().split()))
  mod = 10**9+7
  for i in range(n-1):
    if a[i] == a[i+1] or a[i] > n*m:
      print(0)
      exit()
  for i in range(m-1):
    if b[i] == b[i+1] or b[i] > n*m:
      print(0)
      exit()
            
  
  
  ans = 1
  for i in range(n*m,0,-1):
    placea = bisect.bisect_left(a,i)
    placeb = bisect.bisect_left(b,i)
    if placea >= n or placeb >= m:
      ans *= 0
    else:
      if i == a[placea] and i == b[placeb]:
        ans *= 1
      elif i == a[placea] and i != b[placeb]:
        ans *= (m-placeb)
      elif i != a[placea] and i == b[placeb]:
        ans *= (n-placea)
      else:
        ans *= (m-placeb)*(n-placea)-(n*m-i)
    ans%= mod
  print(ans)
    
solve()

Measured memory_bytes: 42476
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define int long long
#define M 1000000007
int ispalindrome(int l, int h, string s)
{
    // cout << l << " " << h << endl;
    while (h > l)
    {
        if (s[l++] != s[h--])
        {
            return 0;
        }
    }
    return 1;
}
signed main()
{
    rootdada;
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    string s;
    cin >> s;
    int l = s.length();
    if (ispalindrome(0, l - 1, s) && ispalindrome(0, (l - 1) / 2 - 1, s) && ispalindrome((l + 3) / 2 - 1, l - 1, s))
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define nl '\n'

#define PI 3.14159265

using namespace std;

int n, a, b;

int main(){
    cin >> n;
    if(n == 1){
        cout << "Hello World";
    } else{
        cin >> a >> b;
        cout << a+b;
    }

}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n, m;
	
	cin>>n>>m;
	
	cout<<n*m<<endl;
	
	
	
	return 0;
}


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


void solve(long long N){
vector<int64_t> Nm(N);
for(int64_t i=1; i<=N; i++){
    if((i%3 == 0)||(i%5 == 0)){
        Nm.at(i-1)=0;
    }
    else Nm.at(i-1)=i;
}
int64_t ans=0;
for(int64_t j=0; j<N; j++){
    ans=ans+Nm.at(j);
}
cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        long result = 0;
        for (var i = 0; i <Math.Pow(2,str.Length-1); i++)
        {
            var s = "";
            for(var j = 0; j < str.Length - 1; j++)
            {
                s += str.Substring(j, 1);
                if ((1&i >> j) == 1) s += "+";
            }
            s += str.Substring(str.Length - 1, 1);
            result += SpiltStr(s);
        }
        WriteLine(result);
    }
    
    private static long SpiltStr(string str)
    {
        var list = str.Split('+').Select(long.Parse).ToList();
        return list.Sum();
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll k;
    cin >> k;
    ll n = 50;
    vll a(n);
    REP(i, n) a[i] = i;
    ll c = k / n, r = k - c * n;
    REP(i, n) a[i] += c;
    REP(i, r){
        a[i] += n;
        REP(j, n){
            if(j != i) a[j]--;
        }
    }
    
    cout << n << endl;
    REP(i, n) cout << a[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,sum;
  long long min,max;
  
  while(1){
    cin >> y >> x;
    if(x == 0 && y == 0)break;
    for (int i = 0; i < y; i++) {
          for (int j = 0; j < x; j++) {
            if((i+j)%2 == 0)cout << "#";
            else cout << ".";
    	  } 
  	  cout << endl;
    } 
      	  cout << endl;
  }
}


Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n,m,x; cin>>n>>m>>x;
    int l = 0, r = 0;
    for(int i = 0; i < m; ++i) {
        int a; cin>>a;
        if(a < x) {
            ++l;
        }
        else {
            ++r;
        }
    }
    cout << min(l,r) << endl;
    return 0;
}


Measured memory_bytes: 256
N,X,Y=map(int,input().split())
A=[]
for i in range(N-1):
    A.append([-1]*(N-1-i))

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

for k in range(N-1):
    print(Ndmin[k])

Measured memory_bytes: 20852
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderCs
{

    class Program
    {

        const int Mod = 1000000007;

        static void Main()
        {

            var Arg = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = Arg[0];
            var K = Arg[1];
            var result = 0L;

            var Patern = new long[K];

            for (long i = K; 0 < i; i--)
            {

                Patern[i - 1] = pw((K / i), N);
                for (long j = i + i; j <= K; j += i)
                {

                    Patern[i - 1] -= Patern[j - 1];
                    if (Patern[i - 1] < 0) Patern[i - 1] += Mod;

                }

            }
            for (var i = 0; i < K; i++)
            {

                result += (Patern[i] * (i + 1));
                result %= Mod;

            }

            Console.WriteLine(result);

        }

        static long pw(long Base, long Dim)
        {

            long Result = 1;
            while (0 < Dim)
            {

                if ((Dim & 1) != 0)
                {

                    Result = (Result * Base) % Mod;

                }

                Base = (Base * Base) % Mod;
                Dim >>= 1;

            } 

            return Result;

        }

    }
}


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

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

    ll maxNumberOfDigits = LLONG_MAX;

    ll sqN = floor(sqrt(N));

    for (ll i = 1; i <= sqN; ++i)
    {
        if (N % i == 0)
        {
            ll A = i;
            ll B = N / i;

            ll numberOfDigits = max(to_string(A).length(), to_string(B).length());

            if (maxNumberOfDigits > numberOfDigits)
            {
                maxNumberOfDigits = numberOfDigits;
            }
        }
    }

    std::cout << maxNumberOfDigits << endl;

    return 0;
}


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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

int H, W;
vector<string> c;


ll solve(string s1, string s2){
	ll dp[H+1][H+1];
	ll cost[H+1][H+1];
	for(int i=H;i>=0;i--){
		for(int j=H;j>=0;j--){
			if (i==H || j==H){
				cost[i][j] = 0;
			}else{
				cost[i][j] = cost[i+1][j+1] + ((s1[i]==s2[j]) ? 1 : 0);
			}
		}
	}
	for(int i=0;i<=H;i++){
		for(int j=0;j<=H;j++){
			//cout << cost[i][j] << " ";
			if (i==0 && j==0){
				dp[i][j] = 0;
			}else if (i==0){
				dp[i][j] = dp[i][j-1] + cost[i][j-1];
			}else if (j==0){
				dp[i][j] = dp[i-1][j] + cost[i-1][j];
			}else{
				dp[i][j] = min(dp[i-1][j] + cost[i-1][j], dp[i][j-1] + cost[i][j-1]);
			}
		}
		//cout << endl;
	}
	return dp[H][H];
}


int main(void){
	cin >> H >> W;
	string s;
	for(int i=0;i<H;i++){
		cin >> s;
		c.push_back(s);
	}
	
	ll ans = 0;
	
	string s1(H,' '), s2(H,' ');
	for(int j=0;j+1<W;j++){
		for(int i=0;i<H;i++){
			s1[i] = c[H-1-i][j];
			s2[i] = c[H-1-i][j+1];
		}
		ll num = solve(s1, s2);
		//cout << j << " " << num << endl;
		ans += num;
	}
	cout << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 6e5+7;
const int INF = 1e9+7;
const double eps = 1e-5;
#define pb push_back

int main(){
    int x;
    cin >> x;
    int happy = (x/500)*1000;
    happy += (x%500/5)*5;
    cout << happy << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,M; cin>>N>>M;
  if(N%2==1){
    for(int i=0; i<M; i++){
     ll a,b;
      a=N/2-i;
      b=N/2+i+1;
      cout<<a<<" "<<b<<endl;
    }
  }
  else{
    ll n=N/2;
    ll m=M/2;
    if(M%2==1) m++;
    for(int i=0; i<m; i++){
      ll a,b;
      a=n-i;
      b=1+i;
      cout<<b<<" "<<a<<endl;
    }
    for(int i=0; i<M/2; i++){
      ll a,b;
      a=n+1+i;
      b=N-i-1;
      cout<<a<<" "<<b<<endl;
    }
  }
} 

Measured memory_bytes: 3636
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
#define show(ans) cout << ans << endl
const long MOD = 1000000007;

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

	if (N >= M) show(0);
	else {


	vector<long> x(M);
	rep(i, M) cin >> x[i];
	sort(x.begin(), x.end());
	long ans = x[M - 1] - x[0];
	//reverse(x.begin(), x.end());
	vector<long> y(M - 1);
	rep(i, M - 1) {
		y[i] = x[i + 1] - x[i];
	}
	sort(y.begin(), y.end());
	reverse(y.begin(), y.end());
	rep(i, N - 1) {
		ans -= y[i];
	}

		show(ans);
	}





	return 0;

}
// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
//ll MOD = 1000000007;
ll MOD = 998244353;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
  gearup;
  int n; cin >> n;
  vl a(n);
  rep(i,n) cin>>a[i];
  vl c;
  rep(i,n)c.push_back(a[i]-(i+1));
  sort(all(c));
  ll b = c[n/2];
  ll res = 0;
  rep(i,n)res+=abs(c[i]-b);
  out(res);
}


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

using IV = std::vector<int>;
IV ToFixedIntArray(std::istream& is, int n) {
	IV ret(n);
	auto* dst = ret.data();
	while(n > 0) {
		--n;
		is >> *dst++;
	}
	return ret;
}

#include <iostream>

void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
int main() {
	DisableIOSync();
	const auto input = ToFixedIntArray(std::cin, 2);
	std::cout << std::max(0, input[0] - input[1]) << std::endl;
	return 0;
}


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

int main () {
	int n, h[100000];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> h[i];
	int dp[100010];
	dp[n-1] = 0, dp[n-2] = abs(h[n-1] - h[n-2]);
	for (int i = n-3; i >= 0; i--) {
		dp[i] = min(abs(h[i+1]-h[i])+dp[i+1], abs(h[i+2]-h[i])+dp[i+2]);
	}
	cout << dp[0] << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define N 3
int ansArr[N][N]={{1,2,3},
                  {4,5,6},
                  {7,8,0}};
int tempArr[N][N];
int curMinCost=40;
void calcMinCost(int,int);
int get0Row(void);
int get0Col(void);
int isCorrect(void);
void printArr(void);//debugging
int main(void)
{
  int i,j;//counter
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      scanf("%d",&tempArr[i][j]);
  calcMinCost(0,0);
  printf("%d\n",curMinCost);
  return 0;
}
void calcMinCost(int cost,int lastMove)
{
  int row,col;
  //printArr();
  if(cost>=curMinCost) return;
  if(isCorrect()==1)
    {
      curMinCost=cost;
      return;
    }
  row=get0Row();
  col=get0Col();
  if(row!=N-1&&lastMove!=3)//slide up
    {
      tempArr[row][col]=tempArr[row+1][col];
      tempArr[row+1][col]=0;
      calcMinCost(cost+1,1);
      tempArr[row+1][col]=tempArr[row][col];
      tempArr[row][col]=0;
    }
  if(col!=N-1&&lastMove!=4)//slide left
    {
      tempArr[row][col]=tempArr[row][col+1];
      tempArr[row][col+1]=0;
      calcMinCost(cost+1,2);
      tempArr[row][col+1]=tempArr[row][col];
      tempArr[row][col]=0;
    }
  if(row!=0&&lastMove!=1)//slide down
    {
      tempArr[row][col]=tempArr[row-1][col];
      tempArr[row-1][col]=0;
      calcMinCost(cost+1,3);
      tempArr[row-1][col]=tempArr[row][col];
      tempArr[row][col]=0;
    }
  if(col!=0&&lastMove!=2)//slide right
    {
      tempArr[row][col]=tempArr[row][col-1];
      tempArr[row][col-1]=0;
      calcMinCost(cost+1,4);
      tempArr[row][col-1]=tempArr[row][col];
      tempArr[row][col]=0;
    }
}
int get0Row(void)
{
  int i,j;//counter
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(tempArr[i][j]==0) return i;
}
int get0Col(void)
{
  int i,j;//counter
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(tempArr[i][j]==0) return j;
}
int isCorrect(void)
{
  int i,j;//counter
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(ansArr[i][j]!=tempArr[i][j]) return 0;
  return 1;
}
void printArr(void)
{
  int i,j;//counter
  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
        {
          printf("%d ",tempArr[i][j]);
        }
      printf("\n");
    }
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const double pi=acos(-1);



//基本的に勝つ手をだす．
//勝つ手がなければ，K回後に勝つ手以外を出す．

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

  rep(i,size(s)){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  cout<<ans<<endl;

}


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


int main(){
  ll n;cin >> n;
  vector<ll> a(n*3);
  rep(i,n*3) cin >> a.at(i);
  sort(a.begin(),a.end());
  ll ans = 0;
  for(ll i=3*n-2;i>=3*n-n*2;i-=2){
    ans += a.at(i);
  }
  cout << ans << endl;

  return 0;
}


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

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

    int n, wmax;
    cin >> n >> wmax;
    vector<int> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];

    const int INF = 1001001001;
    vector<vector<int>> dp(n, vector<int>(110000, INF));
    dp[0][0] = 0;
    dp[0][v[0]] = w[0];
    rep1(i, n){
        rep(j, 110000){
            if(j < v[i]) dp[i][j] = dp[i-1][j];
            else{
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
            }
        }
    }

    int res = 0;
    rep(j, 110000){
        if(dp[n-1][j] <= wmax){
            res = max(res, j);
        }
    }

    cout << res << endl;

    return 0;
}

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


int main (void)
{
	char a[1200];
	int out;
	fgets(a, 1200, stdin);
		/*for ( int q = 1; q < 1200; q++)
		{
			scanf("%c" , &a[q]);
			if ( a[q] == '\n') break;
			out = q;
		}*/
		
		for ( int z = 0; a[z] != '\0'; z++)
		{
			if ( a[z] >= 'A' && a[z] <= 'Z')
			{
				printf("%c", a[z] + 32);
				//cout << a[z] - 32;
			}
			else if ( a[z] >= 'a' && a[z] <= 'z')
			{
				printf("%c", a[z] - 32);
				//cout << a[z] + 32;
			}
			else
			{
				printf("%c",a[z]);
			}
		}
	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    string s1,s2;
    cin>>s1>>s2;
    reverse(s2.begin(),s2.end());
    string ans = "NO";
    if(s1==s2)ans="YES";
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N;
    cin >> N;
    ll sqrt_N = sqrt(N), smaller;

    for(ll i=sqrt_N; i>=1; --i) {
        if(N%i==0) {
            smaller = i;
            break;
        }
    }
    cerr << smaller << endl;
    cout << smaller + N/smaller - 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

  int bits = 0;

  for (int i = 0; i < N; i++) {
    int a;
    std::cin >> a;

    bits += __builtin_popcount((a & (-a)) - 1);
  }

  std::cout << bits << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 1234567890;

int D;
int x[100000];

const int B = 250;
const int SZ = 400;

// default,sorted
vector<int> d[B],s[B];

int f(int l, int r, int p, int q)
{
    int ret = r-l+1;
    for(int i=l; i<=r; ++i)if(p<=x[i] && x[i]<=q) --ret;
    return ret;
}

int g(int bid, int p, int q)
{
    int lidx = lower_bound(all(s[bid]), p) - s[bid].begin();
    int ridx = upper_bound(all(s[bid]), q) - s[bid].begin();
    int ct = ridx - lidx;
    return SZ - ct;
}

int query(int l, int r, int e)
{
    int a = min(x[l],x[r]), b = max(x[l],x[r]);
    int lb = l/SZ, rb = r/SZ;
    int ret = 0;
    if(lb==rb) ret += f(l,r,a-e,b+e);
    else
    {
        ret += f(l,SZ*(lb+1)-1,a-e,b+e);
        for(int i=lb+1; i<rb; ++i) ret += g(i,a-e,b+e);
        ret += f(SZ*rb,r,a-e,b+e);
    }
    return ret;
}

int main()
{
    scanf(" %d", &D);
    rep(i,D) scanf(" %d", &x[i]);

    rep(i,B)
    {
        d[i] = vector<int>(SZ,INF);
        rep(j,SZ)
        {
            int id = i*SZ+j;
            if(id<D) d[i][j] = x[id];
        }

        s[i] = d[i];
        sort(all(s[i]));
    }

    int Q;
    scanf(" %d", &Q);
    while(Q--)
    {
        int l,r,e;
        scanf(" %d %d %d", &l, &r, &e);
        --l; --r;
        printf("%d\n", query(l,r,e));
    }
    return 0;
}

Measured memory_bytes: 4212
N = int(input())
l = list(map(int, input().split()))
d = {}

for x in l:
    if x in d.keys():
        d[x] = d[x] + 1
    else:
        d[x] = 1

keys = list(d.keys())
keys.sort()

cnt = 0
for i in range(len(keys)):
    for j in range(i + 1, len(keys)):
        for k in range(j + 1, len(keys)):
            if keys[i] + keys[j] <= keys[k]:
                continue
            cnt += d[keys[i]] * d[keys[j]] * d[keys[k]]

print(cnt)

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

int main() {
    int n;
    cin >> n;
    vector<int> ch(26, INT_MAX);
    rep(i, n) {
        string str;
        cin >> str;
        vector<int> temp(26, 0);
        rep(j, str.length()) temp.at(str.at(j) - 'a')++;
        rep(j, 26) ch.at(j) = min(ch.at(j), temp.at(j));
    }
    string ans = "";
    rep(i, 26) rep(j, ch.at(i)) ans += 'a' + i;
    cout << ans << endl;
}

Measured memory_bytes: 256
S=input()
T=input()

match = -1
for s in range(len(S)-len(T)+1):
    ok = True
    for t in range(len(T)):
        if S[s+t] == '?':
            continue
        if S[s+t] == T[t]:
            continue
        ok = False
        break
    if ok:
        #print("===")
        #print(S)
        #print(" "*s+T)
        match = s
#print(match)
if match == -1:
    print("UNRESTORABLE")
else:
    S = list(S)
    A = []
    for i in range(len(S)):
        if match <= i < match+len(T):
            A.append(T[i-match])
        else:
            if S[i] == '?':
                A.append('a')
            else:
                A.append(S[i])
    print("".join(A))







Measured memory_bytes: 3064
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim n As Integer = NextInt()
        Dim s(n) As Long

        For i As Integer = 0 To n - 1
            Dim a As Integer = NextInt()
            s(i + 1) = s(i) + a
        Next

        Array.Sort(s)
        Dim ans, cnt As Long
        For i As Integer = 0 To s.Length - 2
            If s(i) = s(i + 1) Then
                cnt += 1
            Else
                cnt = 0
            End If
            ans += cnt
        Next

        WriteLine(ans)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 26064
#include<iostream>
#include<vector>
#include <cstdlib>
#include <numeric>
#include <cmath>

using namespace std;

int main(){
  long long int n,num=1,count=0;
  cin>>n;
  vector<long long int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
 
  for(int i=0;i<n;i++){
    if(a[i]==num){
      num++;
    }else{
      count++;
    }
  }

  if(count==n) cout<<-1;
  else cout<<count;

  
  return 0;
}

Measured memory_bytes: 1792
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=2005;

int f[N+1];int inf[N+1];
int c(int n,int r)
{
    if(r>n||n<0)
        return 0;
    int ans=(f[n]*inf[n-r])%hell;
    return (ans*inf[r])%hell;
}

void solve()
{
    f[0]=1;
    for(int i=1;i<=N;i++)
        f[i]=(f[i-1]*i)%hell;
    inf[N]=power(f[N],hell-2,hell);
    for(int i=N-1;i>=0;i--)
        inf[i]=(inf[i+1]*(i+1))%hell;
    int s;
    cin>>s;
    int ans=0;
    for(int i=1;i<=(s/3);i++)
    {
        ans=(ans+c(s-2*i-1,i-1))%hell;
    }
    cout<<ans<<endl;
    
    
    
    
}

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







Measured memory_bytes: 3688