akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n,s=MI()
	A=LI()

	li=[0]*(3010)
	li=np.array(li)
	li[0]=1
	#print(li)

	for i in A:
		tmp=li.copy()
		li*=2
		li[i:]+=tmp[:3010-i]
		li%=998244353
		#print(li)
	print(li[s])



if __name__ == "__main__":
	main()


Measured memory_bytes: 27476
#include<iostream>
#include<string>

using namespace std;

int main(){
	int i, n, dice[7], ans = 1, damy, damy2;
	string word;
	
	while(1){
		
		for(i = 1; i <= 6; i ++){
			dice[i] = i;
		}
		ans = 1;
		cin >> n;
		if(n == 0) break;

		for(i = 0; i < n; i ++){
			cin >> word;
			if(word == "North"){
				damy = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[6];
				damy2 = dice[5];
				dice[5] = damy;
				dice[6] = damy2;
				ans += dice[1];
			}
			else if(word == "East"){
				damy = dice[1];
				dice[1] = dice[4];
				damy2 = dice[3];
				dice[3] = damy;
				dice[4] = dice[6];
				dice[6] = damy2;
				ans += dice[1];
			}
			else if(word == "South"){
				damy = dice[1];
				damy2 = dice[2];
				dice[1] = dice[5];
				dice[2] = damy;
				dice[5] = dice[6];
				dice[6] = damy2;
				ans += dice[1];
			}
			else if(word == "West"){
				damy = dice[1];
				damy2 = dice[4];
				dice[1] = dice[3];
				dice[3] = dice[6];
				dice[4] = damy;
				dice[6] = damy2;
				ans += dice[1];
			}
			else if(word == "Right"){
				damy = dice[2];
				damy2 =dice[4];
				dice[2] = dice[3];
				dice[3] = dice[5];
				dice[4] = damy;
				dice[5] = damy2;
				ans += dice[1];
			}
			else if(word == "Left"){
				damy = dice[2];
				damy2 = dice[3];
				dice[2] = dice[4];
				dice[3] = damy;
				dice[4] = dice[5];
				dice[5] = damy2;
				ans += dice[1];
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3136
import sys
from operator import itemgetter
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[(int(i)+1,int(a)) for i,a in enumerate(input().split())]
    A.sort(key=itemgetter(1))
    print(" ".join(map(str,list(zip(*A))[0])))
if __name__=='__main__':
    main()

Measured memory_bytes: 82788
#include<iostream>
using namespace std;
int H,W,A,B;
main()
{
	cin>>H>>W>>A>>B;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			cout<<((i<B)^(j<A)?0:1);
		}
		cout<<endl;
	}
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int i;
	cin >> i;
	cout << i*i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

    int white[n + 1] = {};
    int black[n + 1] = {};

    rep(i, 0, n) {
        if (s[i] == '.') {
            white[i + 1] = white[i] + 1;
            black[i + 1] = black[i];
        } else {
            white[i + 1] = white[i];
            black[i + 1] = black[i] + 1;
        }

    }

    int ans = 1000000000;
    rep(i, 0, n + 1) {
        int x = i - (white[i] - white[0]);
        int y = white[n] - white[i];
        ans = min(ans, x + y);
    }

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


Measured memory_bytes: 2180
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n;
    cin >> n;
    vector<string>a(n);
    rep(i,n){
        cin >> a[i];
    }
    bool flag = true;
    vector<bool>retsu(n,false);
    rep(i,n){
        rep(j,n){
            if(a[i][j]=='#'){
                flag = false;
                retsu[j] = true;
            }
        }
    }
    if(flag){
        cout << -1 << endl;
        return 0;
    }
    int c = 0;
    rep(j,n){
        rep(i,n){
            if(a[i][j] == '.'){
                c++;
                break;
            }
        }
    }
    int temp = 10000000;
    rep(i,n){
        int x = 0;
        rep(j,n){
            if(a[i][j]=='.'){
                x++;
            }
        }
        if(x==0)temp = 0;
        if(retsu[i])temp = min(x,temp);
        else temp = min(x+1,temp);
        
    }
    cout << temp + c << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.RS", "r", stdin );
	string str = "";
	cin >> str;
	reverse (ALL (str ) );
	cout << str << endl;
		
	return 0;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());

			char[] arr = Console.ReadLine().ToCharArray();

			for (int i = 0; i < arr.Length; i++)
			{
				if ((int)arr[i] + n < 0x5B)
				{
					arr[i] = (char)((int)arr[i] + n);
				}
				else
				{
					arr[i] = (char)((int)arr[i] + n - 26);
				}
			}

			Console.WriteLine(new string(arr));

			return;

		}


	}

}


Measured memory_bytes: 13152
import java.util.*;
import java.util.stream.Collectors;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 16MB stack
        Thread thread = new Thread(null, new Main(), "", 16 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    // int a = Integer.parseInt(scanner.nextLine());
    // int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        long n = Long.parseLong(scanner.nextLine());
        long min = Long.MAX_VALUE;
        for (int i = 0; i < 5; i++) {
            min = Math.min(min, Long.parseLong(scanner.nextLine()));
        }
        long plus = n / min;
        if (n % min == 0) {
            plus--;
        }
        System.out.println(5 + plus);

    }
}


Measured memory_bytes: 22740
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	static BigInteger one=BigInteger.ONE,two=new BigInteger("2"),zero=BigInteger.ZERO;
	static String map[];
	static BigInteger vis[][][];
	static int h=1,w=1;
	static boolean modswitch;
	private static Node dfs(Node n){
		//System.out.println(n.x+" "+n.y+" "+n.dir+" left=="+n.stepleft);
		int d=0;
		switch(n.dir){
		case'N':d=0;break;
		case'S':d=1;break;
		case'E':d=2;break;
		case'W':d=3;
		}
		if(n.stepleft.equals(zero))return n;
		if(!vis[n.x][n.y][d].equals(zero)&&modswitch){
			//System.out.println("mod=="+vis[n.x][n.y][d].subtract(n.stepleft));
			n.stepleft=n.stepleft.mod(vis[n.x][n.y][d].subtract(n.stepleft));
			modswitch=false;
		}
		else vis[n.x][n.y][d]=n.stepleft;
		if(n.stepleft.equals(zero))return n;
		while(!n.goable()){
			//System.out.println("turning");
			n.turn();
		}
		switch(n.dir){
		case'N':return dfs(new Node(n.x-1,n.y,n.dir,n.stepleft.subtract(one)));
		case'E':return dfs(new Node(n.x,n.y+1,n.dir,n.stepleft.subtract(one)));
		case'S':return dfs(new Node(n.x+1,n.y,n.dir,n.stepleft.subtract(one)));
		default:return dfs(new Node(n.x,n.y-1,n.dir,n.stepleft.subtract(one)));
		}
	}
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		BigInteger l=one;
		while(h!=0||w!=0||!l.equals(zero)){
			modswitch=true;
			h=in.nextInt();
			w=in.nextInt();
			l=new BigInteger(in.next());
			if(h==0&&w==0&&l.equals(zero))break;
			vis=new BigInteger[h][w][4];
			map=new String[h];
			Node start = null;
			//System.out.println(h+" "+w+" "+l);
			in.nextLine();
			for(int i=0;i<h;i++){
				map[i]=in.nextLine();
				//System.out.println(map[i]);
				for(int j=0;j<w;j++){
					char c=map[i].charAt(j);
					for(int k=0;k<4;k++){
						vis[i][j][k]=zero;
					}
					if(c!='.'&&c!='#'){
						start=new Node(i,j,c,l);
						map[i].replace(map[i].charAt(j),'.');
						//System.out.println(i+" "+j+" "+c+" "+l);
					}
				}
			}
			start=dfs(start);
			System.out.println((start.x+1)+" "+(start.y+1)+" "+start.dir);
		}
	}
static class Node{
	int x,y;
	char dir;
	BigInteger stepleft;
	public boolean goable(){
		switch(this.dir){
		case'N':return x>0&&map[x-1].charAt(y)!='#';
		case'S':return x+1<h&&map[x+1].charAt(y)!='#';
		case'E':return y+1<w&&map[x].charAt(y+1)!='#';
		case'W':return y>0&&map[x].charAt(y-1)!='#';
		}
		return false;
	}
	private void turn(){
		switch(this.dir){
		case'N':this.dir='E';break;
		case'S':this.dir='W';break;
		case'E':this.dir='S';break;
		case'W':this.dir='N';
		}
	}
	public Node(int x,int y,char dir,BigInteger stepleft){
		super();
		this.x = x;
		this.y = y;
		this.dir = dir;
		this.stepleft = stepleft;
	}
}
}

Measured memory_bytes: 64828
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

ll n, a, b;
ll ans = 0;
bool is_ok_binarysearch_number(ll index) {
  ll v = (a * index) / b - a * (index / b);
  if (index <= n) {
    if (v >= ans) {
      ans = v;
      return true;
    } else
      return false;
  } else
    return false;
}

void binarysearch_number() {
  ll ng = 1000000000001;
  ll ok = 0;

  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (is_ok_binarysearch_number(mid))
      ok = mid;
    else
      ng = mid;
  }
}

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

  cin >> a >> b >> n;
  binarysearch_number();
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include<stdio.h>
#define max(x,y)(x > y? x:y)
#define min(x,y)(x < y? x:y)

int main(){
	int k,x;
	scanf(" %d %d",&k,&x);
	int from = max(-1000000,x-k+1);
	int to = min(1000000,x+k-1);
	for(int i = from; i <= to;++i){
		if(i != from)
			printf(" %d",i);
		else
			printf("%d",i);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int A,B;
  cin  >> A >> B;
  int count=0;
  for(int i=A; i<=B;i++){
    if(i%10==i/(10*10*10*10) && (i/10)%10==(i-(i/(10*10*10*10))*(10*10*10*10))/(10*10*10)){count++;}
  }
  cout << count << endl;
}






Measured memory_bytes: 256
//嘘解法
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
 
int n;
int x[100], y[100];
 
signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> x[i] >> y[i];
	
	int ans = 0;
	bool firstUse[100];
	
	rep(i, n) {
		bool use[100] = {false};
		rep(j, n) {
			int dot = x[i] * x[j] + y[i] * y[j];
			if (dot >= 0) { use[j] = true; }
		}
		
		int sumX = 0;
		int sumY = 0;
		rep(j, n) {
			if (use[j]) {
				sumX += x[j];
				sumY += y[j];
			}
		}
		int hoge = sumX * sumX + sumY * sumY;
		if (ans < hoge) {
			rep(j, n) firstUse[j] = use[j];
			ans = hoge;
		}
	}
	
	//山登り
	rep(i, 1000000) {
		int p = rand() % n;
		firstUse[p] = !firstUse[p];
		int sumX = 0;
		int sumY = 0;
		rep(j, n) {
			if (firstUse[j]) {
				sumX += x[j];
				sumY += y[j];
			}
		}
		int hoge = sumX * sumX + sumY * sumY;
		if (ans < hoge) {
			ans = hoge;
			continue;
		}
		else {
			firstUse[p] = !firstUse[p];
		}
	}
	
	double Ans = sqrt((double)ans);
	printf("%.14f\n", Ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define PB push_back
#define MP make_pair
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

bool f(string s) {
    string t = "";
    for (auto it = s.rbegin(); it != s.rend(); it++) {
        t += *it;
    }
    return s == t;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    auto t = s.substr(0, (n - 1) / 2);
    auto w = s.substr((n + 1) / 2, (n - 1) / 2);
    PUTS(f(s) && f(t) && f(w) ? "Yes" : "No");
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


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

  int n;
  string s;
  cin >> n >> s;
  int white_num = 0;
  int black_num = 0;
  for (int i = 0; i < n; i++) {
    if(s[i] == '.') white_num++;
    else black_num++;
  }

  // if(white_num == 0 || black_num == 0){
  //   cout << 0 << endl;
  //   return 0;
  // }

  vector<int> black(n+1, 0);
  vector<int> white(n+1, white_num);

  for (int i = 0; i < n; i++) {
    if(s[i] == '#'){
      black[i+1] = black[i] + 1;
      white[i+1] = white[i];
    }else{
      white[i+1] = white[i] - 1;
      black[i+1] = black[i];
    }
  }


  // int black_num = black[n];
  int res = INT_MAX;
  // print(white);
  // print(black);

  for (int i = 0; i < n+1; i++) {
    res = min(res, black[i] + white[i]);
  }
  cout << res << endl;

}


Measured memory_bytes: 2196
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////
 
#define fs first
#define sc second
#define pb push_back
//#define int long long
#define len(x) (int)(x).size()     
#define all(x) (x).begin(), (x).end()
#define test int _; cin >> _; while(_--)
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
 
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MOD = 1e9+7;
 
inline ll gcd(ll a, ll b){while(b){ a %= b; swap(a, b); } return a; }
inline ll mod(ll a, ll b){return ((a%b)+b)%b;}
inline ll expo(ll b, ll p, ll m = MOD){
  ll ans = 1; 
  while(p > 0){
    if(p&1LL) ans = mod(ans*b, m); 
    b = mod(b*b, m); 
    p >>= 1LL;
  } 
  return ans;
}
 
////////////////////////// Solution starts below. //////////////////////////////

int32_t main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  for(int i = 0; i < len(s); i++){
  	if(s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0; 
}

Measured memory_bytes: 3776
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	ll a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	
	static int n;//頂点数
	static boolean[][] side;//辺があるかどうか
	static int[] visit;//訪問済みかどうか
	static int[] start;
	static int[] end;
	static int time=1;
	
	static void dfs(int x) {
		visit[x]=1;
		start[x]=time++;
		for(int i=1; i<=n; i++) {
			if(visit[i]!=1 && side[x][i]) {
				dfs(i);
			}
		}
		end[x]=time++;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			n=sc.nextInt();
			side=new boolean[n+1][n+1];
			start = new int[n+1];
			end = new int[n+1];
			visit=new int[n+1];
			for(int i=0; i<n; i++) {
				int u=sc.nextInt();
				int k=sc.nextInt();
				for(int j=0; j<k; j++) {
					int v=sc.nextInt();
					side[u][v]=true;
				}
			}
			for(int i=1; i<=n; i++) {
				if(visit[i]==0) {
					dfs(i);
				}
			}
			for(int i=1; i<=n; i++) {
				System.out.printf("%d %d %d\n", i, start[i], end[i]);
			}

		}
	}
}


Measured memory_bytes: 29568
#include <iostream>

int main(){
  
  unsigned int N = 0;
  std::cin >> N;
  
  unsigned long long sum = 0;
  for(unsigned int cnt = 1; cnt <= N; cnt++){
    if(cnt%3 != 0){
      if(cnt%5 != 0){
        sum += cnt;
      }
    }
  }
  
  std::cout << sum << std::endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
int dp[n+2];
dp[0]=0;
dp[1]=abs(arr[1]-arr[0]);
for(int i=2;i<=n;i++)
{
    int a=dp[i-1]+abs(arr[i-1]-arr[i]);
    int b=dp[i-2]+abs(arr[i-2]-arr[i]);
    dp[i]=min(a,b);
    
}
cout<<dp[n-1];

}


Measured memory_bytes: 1024
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     loopR(n,i,a)    for(int i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    int n;
    cin>>n;
    ll arr[n];
    map<ll,ll>a,b;
    loop(n,i,0)
        cin>>arr[i];
    loop(n,i,0)
        a[arr[i]+i]++;
    loop(n,i,0)
        b[i-arr[i]]++;
    ll res=0;
    for(auto x:a)
        res+=(x.s*b[x.f]);
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

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

int main() {
    string s;
    cin >> s;
    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

typedef struct {
  unsigned int x;
  unsigned int y;
  unsigned int l;
} Square;

int main(void)
{
  char buf[1024];
  Square sample;
  int count[2] = {0};

  while (fgets(buf, 1024, stdin) != NULL) {
	sscanf(buf, "%d,%d,%d", &(sample.x), &(sample.y), &(sample.l));

	if (pow(sample.l, 2) == pow(sample.x, 2) + pow(sample.y, 2)) {
	  count[0]++;
	} else if (sample.x == sample.y) {
	  count[1]++;
	}
  }
  printf("%d\n%d\n", count[0], count[1]);
  
  return 0;
}

Measured memory_bytes: 604
struct Rin{}
impl Rin{
    fn input(&self)->String{
        let mut x=String::new();
        std::io::stdin().read_line(&mut x).ok();
        x
    }
    fn inputs(&self)->String{
        let s=self.input().trim().to_string();
        s
    }
    fn inputn(&self)->i32{
        let n:i32=self.input().trim().parse().unwrap();
        n
    }
    fn inputvs(&self)->Vec<String>{
        let vs=self.input().trim().split(' ').map(|x|x.to_string()).collect();
        vs
    }
    fn inputvn(&self)->Vec<i32>{
        let vn=self.input().trim().split(' ').map(|x|x.to_string().parse().unwrap()).collect();
        vn
    }
}

fn main(){
    let rin=Rin{};
    let v=rin.inputvn();
    let n=v[0] as usize; let k=v[1];
    let mut flags=vec![false;n];
    for i in 0..k{
        let d=rin.inputn() as usize;
        let v=rin.inputvn();
        for j in 0..d{
            let a=v[j] as usize;
            flags[a-1]=true;
        }
    }
    let mut cnt=0;
    for flag in flags.iter(){
        if flag==&false{
            cnt+=1;
        }
    }
    println!("{}",cnt);
}

Measured memory_bytes: 2124
import random
import numpy as np

def scoring(t,d,c,s):
  for day in range(d):
    t[day]=t[day]-1
  last=[0 for _ in range(26)]
  score=0
  for day in range(d):
    score=score+s[day][t[day]]
    score=score+c[t[day]]*(day-last[t[day]])*(d-day)
    last[t[day]]=day
  return score

d=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(d)]
t=[0 for _ in range(d)]
last=[-1 for _ in range(26)]
for day in range(d):
  s_d=s[day]
  for i in range(26):
    s_d[i]=s_d[i]+c[i]*(day-last[i])*(d-day)
#  print(s_d)
  max_value = max(s_d)
  max_index = s_d.index(max_value)
  t[day]=max_index+1
  last[max_index]=day
for i in range(d):
  print(t[i])
#print(scoring(t,d,c,s))



Measured memory_bytes: 27576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max(a,b)-min(a,b))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)n,(int)n)
#define nHr(n,r) nCr((int)(n+r+1),(int)r)
#define sankaku(x) ((1+x)*x)/2
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  ll rCount=0,gCount=0,bCount=0;
  char s[LIMIT1];
  ll dMin,dist;
  
  scanf("%lld",&n);
  scanf("%s",s);
  
  rep(i,n){
    switch(s[i]){
      case 'R':
        rCount++;
        break;
      case 'G':
        gCount++;
        break;
      case 'B':
        bCount++;
        break;
    }
  }
  
  result = rCount*gCount*bCount;
  for(dist=1;dist<=n/2;dist++){
    for(i=0;i<n-dist;i++){
      j=i+dist;
      k=i+2*dist;
      if(k>=n) break;
      
      if(s[i]==s[j]) continue;
      else if(s[i]==s[k]) continue;
      else if(s[j]==s[k]) continue;
      result--;
    }
  }
  
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 1712
#include <iostream>
#include <numeric> //For gcd()
#define ll long long int
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fo(i, n) for (int i = 0; i < n; ++i)
#define foe(i, n) for (int i = 1; i <= n; ++i)
#define Fo(i, k, n) for (int i = k; i < n; ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++(i))
#define vi vector<int>
#define vll vector<ll>
#define vvl vector<vector<ll>>
#define vpll vector<pair<ll, ll>>
#define MOD 998244353
#define MAX 1024
using namespace std;
using pi = pair<ll, ll>;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	bool flag= 0;
	while(a>0 && c>0){
		if(!flag){
			c-=b;
		} else a-=d;
		flag = 1 -flag;
	}
	if(a<=0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3136
K,N = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
A.append(K+A[0])

max_distance = 0
for i in range(1,len(A)):
  max_distance = max(max_distance,A[i] - A[i-1])

ans = K - max_distance

print(ans)


Measured memory_bytes: 26420
#include <iostream>
#include <deque>
#include <cstdio>
#include <vector>
#include <string>
#include <limits>
#include <algorithm>
#include <sstream>

using namespace std;

int dp[1000001];
int main(){
  fill((int*)dp,(int*)dp + 1000000,1);
  dp[0] = 0;
  dp[1] = 0;
  for(int i=2;i*i<=1000000;i++){
    if(!dp[i]) continue;
    for(int j=i+i;j<=1000000;j+=i){
      dp[j] = 0;
    }
  }

  int n;
  while(~scanf("%d",&n)){
    if(n==0) break;
    int sum = 0;
    for(int i=n+1;i<=n*2;i++){
      sum += dp[i];
    }
    printf("%d\n",sum);
  }
}

Measured memory_bytes: 0
import java.util.Scanner

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val ma = sc.nextInt
  val mb = sc.nextInt

  val a = Array.ofDim[Int](n)
  val b = Array.ofDim[Int](n)
  val c = Array.ofDim[Int](n)

  for(i <- 0 until n) {
    a(i) = sc.nextInt
    b(i) = sc.nextInt
    c(i) = sc.nextInt
  }

  val maxWeight = 400

  val dp = Array.fill(n + 1, maxWeight + 1, maxWeight + 1)(Int.MaxValue)

  run()

  def run(): Unit = {
    dp(0)(0)(0) = 0

    for(i <- 0 until n) {
      for(wa <- 0 until maxWeight) {
        for(wb <- 0 until maxWeight) {
          if(dp(i)(wa)(wb) < Int.MaxValue) {
            dp(i + 1)(wa)(wb) = math.min(dp(i + 1)(wa)(wb), dp(i)(wa)(wb))
            dp(i + 1)(wa + a(i))(wb + b(i)) = math.min(dp(i + 1)(wa + a(i))(wb + b(i)), dp(i)(wa)(wb) + c(i))
          }
        }
      }
    }

    minValue(ma, mb) match {
      case Int.MaxValue => println(-1)
      case i => println(i)
    }
  }

  def minValue(wa: Int, wb: Int): Int = {
    if(wa > maxWeight || wb > maxWeight) Int.MaxValue
    else math.min(dp(n)(wa)(wb), minValue(wa + ma, wb + mb))
  }
}

Measured memory_bytes: 52328
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 
// const int mo = 1e9 + 7;

// int n;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;

	for (int i = 0; i < 3; ++i)
		if (s[i] == s[i+1]) {
			cout << "Bad" << endl;
			return 0;
		}

	cout << "Good" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  char a[5];
  int l;
  gets(a);
  l=strlen(a);
  if(l==2)
  puts(a);
  else 
  {
  putchar(a[2]);
  putchar(a[1]);
  putchar(a[0]);}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	N--;
	int diff = abs(A - B);
	int tmp = diff / D - 1;
	
	if ((N - tmp) % 2 == 1) {
		tmp++;
	}
	if (diff - D * tmp <= C * (tmp + 2) - diff) {
		N -= tmp;
		diff -= D * tmp;
	}
	else {
		N -= tmp + 2;
		diff = C * (tmp + 2) - diff;
	}
	int maxdiff = (N / 2) * (D - C);
	// cout << N << " " <<  diff << " " << maxdiff << endl;
	if (diff <= maxdiff && N >= 0) {
		cout << "YES" << endl; 
	}
	else {
		cout << "NO" << endl;
	}




	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//templete
int main() {
	int a;
	string S;
	cin>>a>>S;
	if(a>=3200)
		cout<<S<<endl;
	else
		cout<<"red"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
const int INF = 1e9;
const double PI = acos(-1.0);

int main() {
	int n, x;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	vector<int> ret;
	REP(i, 1, 2 * n) {
		if (i == x || i == x - 1 || i == x + 1) continue;
		ret.push_back(i);
	}

	int pos = 0;
	REP(i, 1, 2 * n) {
		if (i == n)cout << x << endl;
		else if (i == n-1)cout << x - 1 << endl;
		else if (i == n+1)cout << x + 1 << endl;
		else {
			cout << ret[pos] << endl;
			pos++;
		}
	}

	return 0;
}

Measured memory_bytes: 2420
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int[] S = new int[n];
		
		for(int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
		}
		
		int q = sc.nextInt();
		
		int[] T = new int[q];
		
		for(int i = 0; i < q; i++) {
			T[i] = sc.nextInt();
		}
		
		int cnt = 0;
		
		for(int i = 0; i < q; i++) {
			for(int j = 0; j < n; j++) {
				if(T[i] == S[j]) {
					cnt++;
					break;
				}
			}
		}
		
		System.out.println(cnt);
	}
}

Measured memory_bytes: 40080
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
  
using namespace std;
vector<int> dp(2001,-1);
int count(vector<int> &s,int n){
  if(n < 0)return 0;
  if(n==0){
    return 1;
  }
  if(dp[n] != -1){
    return dp[n];
  }
  int ans = 0;
  for(int i = 0; i < s.size() ; i++){
    ans = (ans%mod + count(s, n- s[i])%mod)%mod;
  }
  dp[n] = ans%mod;
  return ans%mod;
}
signed main()
{

  std::ios::sync_with_stdio(false);
  cin.tie(); cout.tie();
  int n;
  cin>>n;
 vector<int> s;
      for(int i = 3;i<=n;i++){
          s.push_back(i);
     }

     cout<<count(s,n);
  return 0;
}

Measured memory_bytes: 3688
import collections as cc
I=lambda:list(map(int,input().split()))
n,k=I()
l=[[] for i in range(n)]
for j in range(k):
    nn,=I()
    m=I()
    for i in range(nn):
        l[m[i]-1].append(i)
ans=0
for i in l:
    if len(i)==0:
        ans+=1
print(ans)

Measured memory_bytes: 68104
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		int array[] = new int[num];
		int count = 0;
		
		for(int i = 0; i < num; i ++ ){
			array[i] = scanner.nextInt();
		}
		
		count = bubbleSort(array, num);

		System.out.println(count);
		
		scanner.close();
	}

	public static int bubbleSort( int[] numArray, int num){ // N 個の要素を含む 0-オリジンの配列 A
		int count = 0;
		
		//バブルソート処理
		for (int i = 0; i < num - 1; i++) {
				for (int j = num - 1; j > i; j--) {
					if (numArray[j - 1] > numArray[j]) {
						int work = numArray[j - 1];
						numArray[j - 1] = numArray[j];
						numArray[j] = work;
						count++;
					}
				}
			}
		//出力
		for(int i = 0; i < num; i ++ ){
			System.out.print(numArray[i]);
			if( i == num - 1) {
			System.out.print("\n");
			}else {
				System.out.print(" ");
			}
		}
		return count;
	}
}


Measured memory_bytes: 26408
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

#include <complex>
typedef complex<double> P;
typedef vector<P> vP;

double dot(P a, P b) {
	return (a.real()*b.real() + a.imag()*b.imag());
}

double cross(P a, P b) {
	return (a.real()*b.imag() - a.imag()*b.real());
}

int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if(cross(b, c) > 0) return +1;
	if(cross(b, c) < 0) return -1;
	if(dot(b, c) < 0)   return +2;
	if(norm(b) < norm(c)) return -2;
	return 0;
}

namespace std {
	bool operator<(const P &a, const P &b) {
		return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
	}
}

vP convex_hull(vP ps) {
	int n = ps.size(), k = 0;
	sort(ALL(ps));
	vP ch(2*n);
	for(int i = 0; i < n; ch[k++] = ps[i++]) {
		while(k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) {
			--k;
		}
	}
	for(int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) {
		while(k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) {
			--k;
		}
	}
	ch.resize(k-1);
	return ch;
}

int main() {
	int n;
	while(cin >> n, n) {
		vP points;
		double x, y;
		char c;
		REP(_, n) {
			cin >> x >> c >> y;
			points.push_back(P(x, y));
		}

		cout << n-convex_hull(points).size() << endl;
	}

	return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
#define hell 1000000007
#define int long long int

using namespace std;

void solve(){
    int n,k;
    cin>>n>>k;
    vector <int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(begin(a),end(a));
    int ans=0;
    for(int i=0;i<k;i++)
        ans+=a[i];
    cout<<ans;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define MOD 1000000007
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define read(a, n) for(ll i = 0;i<n;i++) cin>>a[i];
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
const int INF = 1e9 + 5;

void solve() {
	ll n;
	cin>>n;
	
	ll h[n];
	read(h, n);
	
	ll dp[n];
	memset(dp, 0, sizeof(dp));
	
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(ll i = 2;i<n;i++) {
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
	}
	
	cout<<dp[n-1]<<"\n";
}

int main()
{
	fastio;
	
	int T = 1;
	//cin>>T;
	//int tc = 1; 
	while(T--) {
		//cout<<"Case #"<<tc<<": ";
		solve();
		//tc++;
	}	
	return 0;
}


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

typedef long long ll;
ll LL = 1000000;

int main() {
	ll vari[LL];
	for (int i = 0;i < LL;i++) {
		vari[i] = 0;
	}
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 0;i < n;i++) {
		ll x;
		cin >> x;
		if (x > 100000) {
			ans++;
		} else {
			vari[x]++;
		}
	}
	for (int i = 0;i < LL;i++) {
		if (vari[i] < i) {
			ans += vari[i];
		} else {
			ans += (vari[i] - i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8064
import sys
input = sys.stdin.readline

n = int(input())
arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])
cnt = {}
for i in range(n):
    for j in range(i + 1, n):
        dif = (arr[j][0] - arr[i][0], arr[j][1] - arr[i][1])
        cnt.setdefault(dif, 0)
        cnt[dif] += 1
print(1 if cnt == {} else n - max(cnt.values()))

Measured memory_bytes: 3188
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}




using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> vec(n),dp(n);

    REP(i,n){
        cin >> vec[i];
    }

    dp[0] = 0;dp[1] = abs(vec[0] - vec[1]);

    for(int i = 2; i< n;i++){
        dp[i] = dp[i-1] + abs(vec[i] - vec[i-1]);
        for(int j = 2;j <= k;j++){
            if(i-j>=0) dp[i] = min(dp[i], (dp[i-j] + abs(vec[i] - vec[i-j])));
        }
    }
    cout << dp[n-1]<<endl;
}





Measured memory_bytes: 4056
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int n, a[100007], b;
int main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] % 2 == 1)b++; }
	if (b % 2 == 1)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for(int i = 0; i < N; i++){
        cin >> H.at(i);
    }

    int count = 0;

    for(int i = 0; i < N; i++){
        if(H.at(i) >= K){
            count++;
        }
    }

    cout << count << endl;

}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main() {
	
	int H, R;
	cin >> H >> R;
	
	if( H + R == 0)
	cout << "0\n";
	
	else if( H + R > 0)
	cout << "1\n";
	
	else
	cout << "-1\n";

}


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

int n,ans,no[N],a[N];

int main() {

  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
    scanf("%d",&a[i]);
    no[i]=(a[i]==i);
  }
  for(int i=1;i<=n;i++) {
    int tut=i;
    while(no[i]) i++;
    ans+=(i-tut+1)/2;
  }
  printf("%d",ans);

}


Measured memory_bytes: 1024
import sys

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

S = S()

first = S[:2]
second = S[2:4]

if 0 < int(first) <= 12:
    if 0 < int(second) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < int(second) <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define ld long double
#define mod 998244353ll
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)#define case_g "Case #"<<ti<<": "
#define Debug(x) cout << x << "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
int main() {
    ll n;
    cin >> n;
    int umap[4] = {};
    string ans;
    for(int i = 0; i < n; ++i) {
        cin >> ans;
        if(ans == "AC")
            ++umap[0];
        else if(ans == "WA")
            ++umap[1];
        else if(ans == "TLE")
            ++umap[2];
        else
            ++umap[3];
    }
        cout << "AC" << " x " <<  umap[0] << "\n";
        cout << "WA" << " x " << umap[1] << "\n";
        cout << "TLE" << " x " << umap[2] << "\n";
        cout << "RE" << " x " << umap[3] << "\n";
}


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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int cnt=0;
  rep(i,0,n){
    if(s[i]=='p') cnt++;
  }
  cout<<n/2-cnt<<endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print

output: in_order + pre_order
1 12 17 20 25 30 88
30 12 1 20 17 25 88

def tree_data(self):
    stack = []
    node = self
    while stack or node:
        if node:
            stack.append(node)
            node = node.left
        else:
            node = stack.pop()
            yield node.data
            node = node.right
"""

import sys


class Node(object):
    def __init__(self, data):
        self.data = data
        self.left, self.right = None, None

    def insert(self, data):
        """
        insert data according to BST rules
        """
        if data < self.data:
            if self.left is None:
                self.left = Node(data)
            else:
                self.left.insert(data)
        else:
            if self.right is None:
                self.right = Node(data)
            else:
                self.right.insert(data)

        return None


def in_order(node):
    if node is not None:
        in_order(node.left)
        print('', node.data, end='')
        in_order(node.right)
    return None


def pre_order(node):
    if node is not None:
        print('', node.data, end='')
        pre_order(node.left)
        pre_order(node.right)
    return None


def action(command, content):
    if command[0] == 'i':
        tree_root.insert(data=int(content))

    elif command[0] == 'p':
        in_order(tree_root)
        print('')
        pre_order(tree_root)
        print('')

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    command_list = list(map(lambda x: x.split(), _input[1:]))
    # assert len(command_list) == array_length
    # print(array_length, *command_list)

    flag, tree_root = True, None
    for each in command_list:
        command, content = each[0], each[-1]
        if flag and command[0] == 'i':
            tree_root = Node(data=int(content))
            flag = False
            continue
        action(command=command, content=content)

Measured memory_bytes: 288740
import sys


def main():
    while True:
        H, W = [int(i) for i in sys.stdin.readline().split()]
        if H == 0 and W == 0:
            break
        width = '#'
        for i in range(W - 1):
            width += '#'
        for i in range(H):
            print(width)
        print()


if __name__ == '__main__':
    main()



Measured memory_bytes: 5636
#include <cstdio>
#include <cstring>

typedef long long ll;
char data[20];
int n;

int main()
{
    scanf("%s", data);
    n=strlen(data);
    if(n == 1){
        puts(data);
        return 0;
    }
    int naka = 1<<(n-1);
    ll ans = 0;
    for(int i=0; i<naka; ++i){
        ll sum = 0;
        ll cur = 0;
        for(int j=0; j<n; ++j){
            cur = cur*10 + (data[j]-48);
            if((1&(i>>j)) || (j==n-1)) sum += cur, cur=0;
        }
        ans += sum;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128