akhauriyash/Code-Regression huggingface dataset:
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    n=int(input())
    s=[]
    t=[]
    for i in range(n):
        a,b=input().split()
        b=int(b)
        s.append(a)
        t.append(b)
    x=input()
    ind=s.index(x)
    print(sum(t)-sum(t[0:ind+1]))



if __name__ == "__main__":
    main()

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

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

  for (int i = 0; i < s.size() - 1; i ++) {
    for (int j = i + 1; j < s.size(); j ++) {
      if (s.at(i) == s.at(j)) {
        cout << "no" << endl;
        return 0;
      }
    }
  }
  cout << "yes" << endl;
}


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

int main(void)
{
	long long N;
	scanf("%lld",&N);
	long long ans=30000000000000; 
	long long x = sqrt(N);
	for (long long i=1;i<=x;i++)
	{
		if (N%i) continue;
		ans = min(ans,i+N/i-2);
	}
	printf("%lld",ans);
	return 0;
 } 

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

LL N,K;

mint ans = 0;

void solve(){
	K = min(K,N-1LL);
	combination c(N);
	for(int i=1;i<=K;i++){
		ans += c(N-1,N-1-i)*c(N,i);
	}
	if(K!=1) ans = ans + mint(1);
}

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

    solve();

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

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::min;
using std::max;
using std::abs;
using std::sort;
const int N = 100005;

bool check(int);

int a[N];
int n;

int main () {
    read(n);
    for (int i = 1; i <= n; ++i) {
        read(a[i]);
    }
    int ans = 0;
    int k = a[1];
    for (int i = 1; i * i <= k; ++i) {
        if (k % i == 0) {
            if (check(i)) {
                ans = max(ans, i);
            }
            if (check(k / i)) {
                ans = max(ans, k / i);
            }
        }
    }
    k = a[2];
    for (int i = 1; i * i <= k; ++i) {
        if (k % i == 0) {
            if (check(i)) {
                ans = max(ans, i);
            }
            if (check(k / i)) {
                ans = max(ans, k / i);
            }
        }
    }
    write(ans), EL;
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}

bool check(int x) {
    int num = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[i] % x == 0) {
            ++num;
        }
        if (num < i - 1) {
            break;
        }
    }
    return num >= n - 1;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

ll gcd(ll a, ll b) {
	if (b == 0)return a;

	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

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

	ll cd = lcm(c, d);
	ll fb = b - b / c - b / d + b / cd;
	ll e = a - 1;
	ll fa = e - e / c - e / d + e / cd;
	cout << fb - fa << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int frige_n = Integer.parseInt(sc.next());
        int chin_n = Integer.parseInt(sc.next());
        int coupon_n = Integer.parseInt(sc.next());
        
        int[] frige_prices = new int[frige_n];
        int frige_min=Integer.MAX_VALUE;
        for(int i=0; i<frige_n; i++){
            frige_prices[i] = Integer.parseInt(sc.next());
            if(frige_prices[i] < frige_min) frige_min =frige_prices[i];
        }
        
        int[] chin_prices = new int[chin_n];
        int chin_min = Integer.MAX_VALUE;
        for(int i=0; i<chin_n; i++){
            chin_prices[i] = Integer.parseInt(sc.next());
            if(chin_prices[i] < chin_min) chin_min = chin_prices[i];
        }
        
        int total_min = frige_min + chin_min;
        
        int fr=-1, ch=-1, adv=-1, sum=-1;
        for(int i=0; i<coupon_n; i++){
            fr = Integer.parseInt(sc.next());
            ch = Integer.parseInt(sc.next());
            adv = Integer.parseInt(sc.next());
            sum = frige_prices[fr-1]+chin_prices[ch-1]-adv;
            if(sum < total_min) total_min =sum;
        }
        System.out.println(total_min);
    }
    
}

Measured memory_bytes: 66184
N = int(input())
f = [int(input().replace(' ',''),2) for _ in range(N)]
p = [list(map(int,input().split())) for _ in range(N)]
g = -9999999999
for i in range(1,1024):
    gg = 0
    for j in range(N):
        s = (format(i & f[j],'b').zfill(10))
        c = s.count('1')
        gg += p[j][c]
    g = max(g,gg)
print(g)

Measured memory_bytes: 3064
import static java.lang.System.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ar = new int[n+1];
		int[] count = new int[10001];
		for (int i=1; i<n+1; i++) {
			int temp = sc.nextInt();
			ar[i] = temp;
			count[temp]++;
		}
		
		for (int i=1; i<10001; i++) {
			count[i] = count[i] + count[i-1];
		}

		int[] ans = new int[n+1];
		for (int i=n; i>=1; i--) {
			ans[count[ar[i]]] = ar[i];
			count[ar[i]]--;
		}
		
		StringBuilder sb = new StringBuilder();
		sb.append(ans[1]);
		for (int i=2; i<n+1; i++) sb.append(" "+ans[i]);
		out.println(sb);
	}
}



Measured memory_bytes: 547872
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String S = sc.next();
		String T = sc.next();

		sc.close();

		out.println(T + S);

	}

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


Measured memory_bytes: 21972
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.
	input = input.split(" ");
	// convert string from integer using "parseInt"
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	//output
	console.log('%d',a*b-a-b+1);
}
// Don't edit this line!


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <stdio.h>

int main(void)
{
    int i, n;
    scanf("%d", &n);
    int x[n], y[n];
    for (i = 0; i < n; i++)
        scanf("%d", &x[i]);

    for (i = 0; i < n; i++)
        scanf("%d", &y[i]);
    
    int sum = 0;
    for (i = 0; i < n; i++){
        if(x[i] - y[i] > 0)
            sum += x[i] - y[i];
    }

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int N, M; cin >> N >> M;
  vector<vector<int>> G(N);
  rep(i,M){
    int a, b; cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  bool ans = true;
  rep(i,N){
    if (G[i].size()&1) ans = false;
  }
  if (ans) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 8512
n,m=map(int,input().split())
L=0
R=n
for i in range(m):
    l,r=map(int,input().split())
    if l>L:
        L=l
    if r<R:
        R=r
if R-L<0:
    print(0)
else:
    print(R-L+1)

Measured memory_bytes: 3060
N, M = map(int, input().split())
HFlag = [True] * N
H = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(M)]
for x in ab:
    if H[x[0] - 1] <= H[x[1] - 1]:
        HFlag[x[0] - 1] = False
    if H[x[0] - 1] >= H[x[1] - 1]:
        HFlag[x[1] - 1] = False
print(HFlag.count(True))


Measured memory_bytes: 93276
#include <iostream>
#define MAX 196470

using namespace std;

int main(void){

  int n;
  cin >> n;

 while(n--){
   int y,m,d;
   cin >> y >> m >> d;
   y--; m--; d--;
   int day = 0;
   day += ( 20*5 + 19*5) * y;
   day += (y/3) * 5;
   day += m * 20;
   if( (y + 1) % 3 != 0 ) day -= (m/2);
   day += d;
   cout << MAX - day << endl;
 }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}
// }}}
/* vim:set foldmethod=marker: */

int main(int argc, char const* argv[])
{
    int h,w;
    cin >> h >> w;

    vector<vector<char> > board(h+2, vector<char>(w+2, '#'));
    for (int i = 1; i <= h; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= w; j++) {
            board[i][j] = s[j-1];
        }
    }

    printmatrix(board);
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdlib>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if(n==3){
		puts("2 5 63");
		return 0;
	}
	if(n==4){
		puts("2 5 20 63");
		return 0;
	}
	for(register int i=2;i<n;i+=2)
		if((n-i)<=15000&&i<=5000&&(n-i)%3!=1){
        	for(int j=2,c=1;j<=30000&&c+i<=n;j+=2,c++) printf("%d ",j);
        	for(int j=3,c=1;j<=30000&&c<=i;j+=3) if(j&1) printf("%d ",j),c++;
        	break;
    	}
	return 0;
}

Measured memory_bytes: 256
var
  s: array[0..100000] of char;
  alpha: array[97..122] of integer;
  i: integer;
  ok: boolean;
begin
  readln(s);
  for i := 0 to 100000 do
  begin
    alpha[ord(s[i])] := 1;
  end;
  
  ok := False;
  for i := 97 to 122 do
  begin
    if alpha[i] = 0 then
    begin
      writeln(chr(i));
      ok := True;
      break;
    end;
  end;
  
  if ok = False then
  begin
    writeln('None');
  end;
end.

Measured memory_bytes: 128
length = int(input())

words = []

for i in range(length):
  words.append(input())
  
flg = 'Yes'
pre = words[0]
for word in words[1:]:
  if pre[-1] != word[0]:
    flg = 'No'
  pre = word

if len(words) != len(set(words)):
  flg = 'No'
  
print(flg)

Measured memory_bytes: 3064
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                         long long int
#define mp make_pair

using namespace std;

int main(){

     ll i,n,m,s=0,sum=0,x=0;
     cin>>n;
     ll a[n+9];
     for(i=0;i<n;i++){
        cin>>a[i];
     }
     for(i=0;i<n;i+=2){
        if(a[i]%2==1) x++;
     }
 cout<<x<<endl;

}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 




////////////////////////////////////////////////////////


int main() {
    ll k; cin >> k;
    string s; cin >> s;
    if(sz(s) <= k) co(s);
    else{
        co(s.substr(0, k) << "...");
    }

    return 0;
}


Measured memory_bytes: 3624
N = int(input())
CSFlist = [list(map(int, input().split())) for _ in range(N-1)]
def calc_time(start):
    now = 0
    for i in range(start, N-1):
        C, S, F = CSFlist[i]
        now = max(now, S)
        if now % F != 0:
            now += F - now % F
        now += C
    return now
for _ in range(N-1):
    print(calc_time(_))
print(0)


Measured memory_bytes: 40560
#include <iostream>
#include <queue>
#include <deque>

using namespace std ;

/*ifstream cin ("input") ;
ofstream cout ("output") ;*/

const int MAX = 1e3 + 14 ;

bool dp [MAX][MAX][2] ;

int main(int argc, char const *argv[])
{
	int n ; 
	cin >> n ; 
	string s ; 
	cin >> s ; 
	int open = 0 ; 
	int surpl = 0 ; 
	for (auto x : s) {
		if (x == '(') {
			open += 1 ; 
			continue ; 
		}
		if (x == ')' and open) {
			open -= 1 ; 
			continue ; 
		}
		if (open <= 0 and x == ')') surpl += 1 ; 
	}
	// cout << surpl << '\n' ;
	while (surpl --) {
		s = "(" + s ; 
	}
	// cout << s << '\n' ;
	open = 0 ; 
	for (auto x : s) {
		if (x == '(') open += 1 ; 
		if (x == ')') open -= 1 ;
	}
	while (open --) {
		s = s + ")" ;
	}
	cout << s ;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
S = input()
S = S[::-1]

rest = 0
ans = 0
memo = defaultdict(int)
memo[0] = 1
for i in range(len(S)):
    rest = (rest + int(S[i])*pow(10,i,2019)) %2019
    ans += memo[rest]
    memo[rest] += 1
print(ans)

Measured memory_bytes: 74380
#include <cstdio>
#include <vector>
#include <algorithm>
#define COST(x, y) (((x)-(y)) * ((x)-(y))) 
using namespace std;

int N;
vector <int> v;
int Min = 0x7fff0000;

int main(void)
{
	int flag = 1;
	int num;
	int onum;
	scanf("%d", &N);

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

		scanf("%d", &num);
		if (i == 0) onum = num;
		if (num != onum && flag) flag = 0;
		if (flag) onum = num;
		v.push_back(num);
	}

	if (flag)
	{
		printf("0\n");
		return 0;
	}

	sort(v.begin(), v.end());

	for (int i = v.front(); i <= v.back(); i++)
	{
		int tot = 0;
		for (auto vi : v)
		{
			tot += COST(vi, i);
		}
		if (tot < Min) Min = tot;
	}


	printf("%d\n", Min);


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int l[N], r[N], p[N];
    rep(i, N) cin >> l[i] >> r[i] >> p[i];
    int dp[401][401];
    rep(i, 401) rep(j, 401) dp[i][j] = -inf;
    dp[0][0] = 0;
    rep(i, 401){
        rep(j, 401){
            rep(k, N){
                if(dp[i][j] == -inf) continue;
                int ni = min(i+l[k], 400), nj = min(j+r[k], 400);
                chmax(dp[ni][nj], dp[i][j]+p[k]);
            }
        }
    }
    int M;
    cin >> M;
    int ans[M];
    rep(i, M){
        ans[i] = -1;
        int w; cin >> w;
        rep2(j, 0, w){
            rep2(k, w, 400){
                chmax(ans[i], dp[j][k]);
            }
        }
        if(ans[i] == -1) {cout << -1 << endl; return 0;}
    }
    rep(i, M) cout << ans[i] << endl;
}


Measured memory_bytes: 3720
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

struct Point{
	double x,y;
};

int main(){

	int n,m,checkTable[101],path[101],id,start,goal,count,min_index;
	double distance[101][101],x,y,calc[101][101],min_value;
	bool canGO[101];
	Point table[101];
	stack<int> S;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i=1; i <= n; i++){
			scanf("%d %lf %lf",&id,&x,&y);
			table[id].x = x;
			table[id].y = y;
		}

		for(int i = 1; i <= n; i++){
			for(int k = 1; k <= n; k++){
				distance[i][k] = sqrt((table[i].x-table[k].x)*(table[i].x-table[k].x)+(table[i].y-table[k].y)*(table[i].y-table[k].y));
			}
		}

		scanf("%d",&m);

		for(int i = 1; i <= m; i++){
			scanf("%d %d",&start,&goal);

			for(int k = 1; k <= n; k++){
				checkTable[k] = 0;
				if(distance[start][k] < 50 || fabs(distance[start][k] - 50) < 0.00000001){
					canGO[k] = true;
				}else{
					canGO[k] = false;
				}
				path[k] = start;
				for(int p = 1; p <= n; p++)calc[k][p] = distance[k][p];
			}

			count = 1;
			checkTable[start] = 1;

			while(count < n){
				min_value = 1000000000;

				for(int k = 1; k <= n; k++){
					if(checkTable[k] == 0 && canGO[k] == true && calc[start][k] < min_value){
						min_value = calc[start][k];
						min_index = k;
					}
				}

				if(min_value == 1000000000)break;

				checkTable[min_index] = 1;
				count++;

				for(int p = 1; p <= n; p++){
					if((canGO[p] == false || calc[start][p] > calc[start][min_index]+calc[min_index][p]) && (distance[min_index][p] < 50 || fabs(distance[min_index][p] - 50) < 0.00000001)){
						calc[start][p] = calc[start][min_index]+calc[min_index][p];
						canGO[p] = true;
						path[p] = min_index;
					}
				}
			}

			if(canGO[goal] == false)printf("NA\n");
			else{
				int t = goal;
				while(true){
					S.push(t);
					t = path[t];
					if(t == start)break;
				}
				printf("%d",start);
				while(!S.empty()){
					printf(" %d",S.top());
					S.pop();
				}
				printf("\n");
			}
		}
	}


	return 0;
}

Measured memory_bytes: 2860
n=int(input())
ar=list(map(int,input().split()))
def srt(ar):
    return ar==sorted(ar)
b=0
if(srt(ar)):b=1
for i in range(n):
    for j in range(i,n):
        ar[i],ar[j]=ar[j],ar[i]
        if(srt(ar)):b=1
        ar[i],ar[j]=ar[j],ar[i]
if(b):
    print("YES")
else:
    print("NO")


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

int main(){
	int n;
	cin >> n;
	bool bl = false;
	
	for( int i = 0; i <= 100; i += 4 ){
		for( int j = 0; j <= 100; j+=7 ){
			if( i+j == n )
				bl = true;
		}
	}
	if( bl ) cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (a,b) = get!(usize, usize);
    for i in 1..10000 {
        if i*8/100 == a && i/10 == b {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}


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

typedef long long ll;
const int N = 2e5;
ll arr[N + 5];

int main() {
	int n, k;
	cin>>n>>k;
	for(int i = 0;i < n;i++) cin>>arr[i];
	sort(arr, arr + n);
	ll total = 0;
	for(int i = 0;i < n - k;i++) total += arr[i];
	cout<<total<<endl;
}

Measured memory_bytes: 1792
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

x,y,z,k = inpl()
a = inpl()
b = inpl()
c = inpl()
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
q = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
heapify(q)
old = set((0,0,0))
for i in range(k):
    k,l,m,n = heappop(q)
    print(-k)
    if l + 1 < x and not (l+1,m,n) in old:
        heappush(q,[-(a[l+1] + b[m] + c[n]), l+1, m, n])
        old.add((l+1,m,n))
    if m + 1 < y and not(l,m+1,n) in old:
        heappush(q,[-(a[l] + b[m+1] + c[n]), l, m+1, n])
        old.add((l,m+1,n))
    if n + 1 < z and not (l,m,n+1)  in old:
        heappush(q,[-(a[l] + b[m] + c[n+1]), l, m, n+1])
        old.add((l,m,n+1))
    # print(q)

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

ll scores[5500][5500];

int main(){
  int n,k;cin>>n>>k;
  vector<int>p(n);
  rep(i, n){ cin>>p[i];p[i]--; }
  vector<ll>c(n);
  rep(i, n)cin>>c[i];

  vector<int>loopc(n);
  rep(i, n){
    int nex = i;
    rep1(j, n){
      loopc[i]++;
      scores[i][j] = scores[i][j-1] + c[nex];
      nex = p[nex];
      if(i==nex)break;
    }
  }

  ll result = -INF;

  // first loop
  rep(i, n)rep1(j, n){
    if(j>k)continue;
    result = max<ll>(result, scores[i][j]);
  }

  rep(i, n){
    ll lc = loopc[i];
    if(k<=lc)continue;
    ll count = k/lc;

    // one before last one loop
    if(count>=2){
      rep(j, lc+1){
        result = max<ll>(result, scores[i][lc]*(count-1) + scores[i][j]);
      }
    }

    // last one loop
    rep1(j, k%lc){
      result = max<ll>(result, scores[i][lc]*count + scores[i][j]);
    }
  }

  cout<<result<<endl;

  return 0;

rep(i, n)cout<<loopc[i]<<' ';cout<<endl;
rep(i, n){
rep(j, n+1)cout<<scores[i][j]<<' ';cout<<endl;
}

  return 0;
}




Measured memory_bytes: 218564
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n;
vector<pair<int,int> > con[100111];
int sz[100111],pc[100111];
ll ans;
void dfs(int x,int pre=-1)
{
	sz[x]=1;
	for(int i=0;i<con[x].size();i++)
	{
		int u=con[x][i].FF;
		if(pre!=u)
		{
			dfs(u,x);
			sz[x]+=sz[u];
			pc[u]=con[x][i].SS;
			ans+=1ll*pc[u]*min(sz[u],n-sz[u])*2;
		}
	}
}
int main()
{
	geti(n);
	for(int i=1;i<n;i++)
	{
		int x,y,c;
		getiii(x,y,c);
		con[x].PB(MP(y,c));
		con[y].PB(MP(x,c));
	}
	dfs(1);
	int mn=n+1,mnid=-1;
	for(int i=1;i<=n;i++)
	{
		if(sz[i]*2==n)
		{
			cout<<ans-pc[i]<<endl;
			return 0;
		}
		if(sz[i]*2>=n)
		{
			if(sz[i]<mn)mn=sz[i],mnid=i;
		}
	}
	mn=1e9;
	for(int i=0;i<con[mnid].size();i++)
	{
		mn=min(mn,con[mnid][i].SS);
	}
	cout<<ans-mn<<endl;
	return 0;
}


Measured memory_bytes: 13312
#include<iostream>

using namespace std;

int main(){
  long A,B,K;
  cin >> A >> B >> K;
  
  A = A - K;
  if (A < 0){
    B = B + A;
    A = 0;
  }
  if (B < 0) B = 0;
  
  cout << A << " " << B << endl;
  return 0;
  
}

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(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n%2 != 0){
    cout<< "No" <<endl;
    return 0;
  }
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[n/2+i]){
      cout<< "No" <<endl;
      return 0;
    }
  }
  cout<< "Yes" <<endl;
}


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


int cmp(const void *a,const void *b){
    if(*(int*)a>*(int*)b){return 1;}
    else if(*(int*)a<*(int*)b){return -1;}
    else {return 0;}
}


int main(void){
int s,w;
scanf("%d %d",&s,&w);
if(s>w){printf("safe");}
else{printf("unsafe");}

}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

const int MAX_V=1e4+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; ll W; cin >> N >> W;
    vector<ll> v(N),w(N);
    rep(i,N) cin >> v[i] >> w[i];
    map<ll,ll> m1,m2;
    int n=N/2;
    rep(bit,1<<n){
        ll sumv=0,sumw=0;
        rep(i,n) if (bit&1<<i) sumv+=v[i],sumw+=w[i];
        if (sumw>W) continue;
        chmax(m1[sumw],sumv);
    }
    rep(bit,1<<(N-n)){
        ll sumv=0,sumw=0;
        rep(i,N-n) if (bit&1<<i) sumv+=v[i+n],sumw+=w[i+n];
        if (sumw>W) continue;
        chmax(m2[sumw],sumv);
    }
    ll M=0;
    set<ll> s;
    s.insert(0);
    for (auto x:m2) chmax(m2[x.first],M),chmax(M,x.second),s.insert(x.first);
    ll ans=0;
    for (auto x:m1){
        auto itr=s.upper_bound(W-x.first); --itr;
        chmax(ans,x.second+m2[*itr]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 183344
#include <stdio.h>
#include <stdlib.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)

int main() {
	int d,c[27],s[366][27]={0},last[27]={0},sat=0;
	scanf("%d",&d);
	rep(i,26)scanf("%d",c+i+1);
	rep(i,d)rep(j,26)scanf("%d",&s[i+1][j+1]);
	rep(i,d){
		int ms=1,mt=1;
		rep(j,26)if(s[i+1][j]>ms){mt=j;ms=s[i+1][j];}
		printf("%d\n",mt);
	}
	return 0;
}

Measured memory_bytes: 1776
#include<bits/stdc++.h>
#define ll   long long int   
#define pb push_back
using namespace std;
const int M=1e9 + 7;
int main()
{  
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int a=0;
    while(n--)
    {   int b;
    	cin>>b;
    	a=a^b;
	}
    if(a==0)
    {
    	cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
    return 0 ; 
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  for(auto& i : d) cin >> i;
  
  int ans = 0;
  for(int x = 0; x < n - 1; ++x)
  {
    for(int y = x + 1; y < n; ++y)
    {
      ans += d[x] * d[y];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N, M, C = map(int, input().split(' '))

    B = list(map(int, input().split(' ')))
    
    A = []; i = 0
    while i < N:
        A.append(list(map(int, input().split(' '))))
        i += 1
    
    counter = 0

    for a in A:
        total = 0
        for elem_a, elem_b in zip(a, B):
            total += elem_a * elem_b
        total += C
        if total > 0:
            counter += 1
    
    print(counter)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <tuple>
#include <algorithm>
int main() {
    int n,t,a;
    string s;
    cin >> n;
    vector<tuple<string, int, int>> mise;
    for (int i = 1; i < n+1; i++) {
        cin >> s >> t;
        t = 100 - t;
        mise.emplace_back(s,t ,i );
    }
    
    sort(mise.begin(), mise.end());
   
    for (int i = 0; i < n; i++) {
        a = get<2>(mise[i]);
        cout << a << endl;
    
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<long> H(N), A(M), B(M);
  vector<bool> good(N, true);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  for (int i = 0; i < M; i++) {
    cin >> A.at(i) >> B.at(i);
    if (H.at(A.at(i)-1) <= H.at(B.at(i)-1)) {
      good.at(A.at(i)-1) = false;
    } 
    if (H.at(A.at(i)-1) >= H.at(B.at(i)-1)) {
      good.at(B.at(i)-1) = false;
    }
  }
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (good.at(i) == 1) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 5636
def II(): return int(input())
def LII(): return list(map(int, input().split()))

n=II()
alist=LII()
blist=LII()
clist=LII()

alist.sort()
blist.sort()
clist.sort()

#あるbより小さいaの数
def count_a(b):
    ok,ng = -1,n
    def is_ok(i):
        return alist[i]<b
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok+1

def count_c(b):
    ok,ng = n,-1
    def is_ok(i):
        return clist[i]>b
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return n-ok

result=0
for b in blist:
    result += count_a(b) * count_c(b)

print(result)

Measured memory_bytes: 29996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char alpha,ans;
  cin >> alpha;
  
  
  if('A' <= alpha && alpha <= 'Z'){
    ans = 'A';
  }else if('a' <= alpha && alpha <= 'z'){
    ans = 'a';
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define MAX 1007
#define INF 100000007

using namespace std;

typedef pair<int,int> di;
typedef pair<int, di> pii;

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    long long h, w; cin >> h >> w;
	if(min(h, w) == 1) cout << 1 << endl;
    else cout << (h/2LL)*w + (h%2 == 1)*((w+1LL)/2LL) << endl;
    return 0;
}

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

typedef long long ll;
typedef pair< int, int > PII;
typedef pair< ll, ll > PLL;

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define PI 3.14159265358979323846
#define INF 1000000006
#define LINF 1000000000000000006
#define DINF 1e300
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair

ll n, x;
vector< int > ans;

void init() {
  cin >> n >> x;
}
void solve() {
  int num = 2 * n - 1;
  if ( x == 1 || x == num ) {
    cout << "No" << endl;
    return;
  }
  if ( n == 2 && x == 2 ) {
    cout << "Yes" << endl;
    for ( int i = 1 ; i <= 3 ; ++i )
      cout << i << endl;
    return;
  }
  cout << "Yes" << endl;
  if ( x <= num - 2 ) {
    int a = 1;
    for ( int count = 0 ; count < ( num - 4 ) / 2 + 1 ; ++count ) {
      if ( a == x - 1 ) 
        a = x + 3;
      ans.PB( a );
      ++a;
    }
    ans.PB( x + 2 );
    ans.PB( x );
    ans.PB( x - 1 );
    ans.PB( x + 1 );
    while ( 1 ) {
      if ( a == x - 1 ) 
        a = x + 3;
      if ( a > num ) break;
      ans.PB( a++ );
    }
  }
  else {
    int a = 1;
    for ( int count = 0 ; count < ( num - 4 ) / 2 + 1 ; ++count ) {
      if ( a == x - 2 ) 
        a = x + 2;
      ans.PB( a );
      ++a;
    }
    ans.PB( x - 1 );
    ans.PB( x );
    ans.PB( x + 1 );
    ans.PB( x - 2 );
    while ( 1 ) {
      if ( a == x - 2 ) 
        a = x + 2;
      if ( a > num ) break;
      ans.PB( a++ );
    }
  }
  for ( int i = 0 ; i < ans.size() ; ++i )
    cout << ans[ i ] << endl;
}
int main() {
  IOS;
  int __ = 1;
  //cin >> __;
  while ( __-- ) {
    init();
    solve();
  }
  return 0;
}


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

int main()
{
    int n,c,m;
    while(~scanf("%d%d",&n,&m))
    {
        c=pow(2,m);
        printf("%d\n",(m*1900+(n-m)*100)*c);
    }
    return 0;
}


Measured memory_bytes: 128
N,K=map(int,input().split())
T=[0]*N
for i in range(K):
	D=int(input())
	A=list(map(int, input().split()))
	for j in range(D):
		x=A[j]
		y=x-1
		#print(T[0])
		if T[y]==0:
			T[y]=1
print(N-sum(T))

Measured memory_bytes: 9060
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
typedef long long int ll;

int h, w;
string s0[12];
bool e;

void solve(vector<int> v){
  if(e==1) return;
  if(v.size()==(h+1)/2){
    bool b[12]={};
    for(int j=0; j<v.size(); j++){
      b[v[j]]=1;
    }
    for(int i=0; i<h; i++){
      if(b[i]==0){
        v.push_back(i);
      }
    }
    for(int i=0; i<h/2; i++){
      if(v[i]>v[h-1-i]) return;
    }
    string str[12];
    for(int i=0; i<w; i++){
      for(int j=0; j<h; j++){
        str[i]+=s0[v[j]][i];
      }
    }
    int t=0;
    bool used[12]={};
    string rstr[12];
    for(int i=0; i<w; i++){
      for(int j=0; j<h; j++){
        rstr[i]+=str[i][h-1-j];
      }
    }
    for(int i=0; i<w; i++){
      if(used[i]==1) continue;
      bool e1=0;
      for(int j=0; j<w; j++){
        if(i==j || used[j]==1) continue;
        if(str[i]==rstr[j]){
          used[i]=1;
          used[j]=1;
          e1=1;
          break;
        }
      }
      if(e1==0){
        if(str[i]!=rstr[i]){
          return;
        }
      }
    }
    for(int i=0; i<w; i++){
      if(used[i]==0) t++;
    }
    if((t==0 && w%2==0) || (t==1 && w%2==1)) e=1;
    return;
  }
  bool used[12]={};
  for(int j=0; j<v.size(); j++){
    used[v[j]]=1;
  }
  for(int i=0; i<h; i++){
    if(used[i]==0){
      v.push_back(i);
      solve(v);
      v.pop_back();
    }
  }
  return;
}

int main()
{
	e=0;
  scanf("%d %d", &h, &w);
  for(int i=0; i<h; i++){
    cin>>s0[i];
  }
  vector<int> v;
  solve(v);
  if(e==1){
    printf("YES\n");
  }else{
	printf("NO\n");
  }
	return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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;
};

// 単一始点全点間最短路を求めるアルゴリズム。単一始点全点間最短路を求めるアルゴリズム。負辺があっても動作する。また負閉路も検出する。

// 計算量 O(V * E)

static const int INF = 1e9;

struct Edge {
  int from;
  int to;
  int cost;
};

vector<int> bellman_ford(int s, int V, vector<Edge> &edges) {
  vector<int> dist(V, INF);
  dist[s] = 0;
  rep(i, 0, V - 1) {
    rep(j, 0, edges.size()) {
      struct Edge e = edges[j];
      if (dist[e.from] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
    }
  }

  bool flag = true;
  rep(i, 0, edges.size()) {
    struct Edge e = edges[i];
    if (dist[e.from] == INF) continue;
    // 負回路発見
    if (dist[e.from] + e.cost < dist[e.to]) {
      flag = false;
      break;
    }
  }

  if (flag) {
    return dist;
  } else {
    vector<int> neg;
    return neg;
  }
};


int main() {
  int V, E, r;
  cin >> V >> E >> r;
  vector<Edge> edges(E);
  int s, t, d;
  rep(i, 0, E) {
    cin >> s >> t >> d;
    edges[i] = { s, t, d };
  }

  vector<int> dist = bellman_ford(r, V, edges);
  if (dist.empty()) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  } else {
    rep(i, 0, dist.size()) {
      if (dist[i] == INF) {
        printf("INF\n");
      } else {
        printf("%d\n", dist[i]);
      }
    }
    return 0;
  }
};



Measured memory_bytes: 3232
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  int m;
  cin>>m;
  cout<<48-m<<endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
	ll n;
  	cin >> n;
  	vl a(n);
	rep(i,n) cin >> a[i];
  	sort(all(a));
  	rep(i,n-1){if(a[i]==a[i+1]){NO;return 0;}}
  	YES;
  	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else if(s[0] == s[2] && s[2] != s[1] && s[1] == s[3]) cout << "Yes" << endl;
    else if(s[0] == s[3] && s[3] != s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
A,B,C,D,E,F = map(int,input().split())
max_con = (100*E)/(100+E)
W,S = [],[]
for i in range(0,F+1,100*A):
    j = 0
    while i+100*B*j<=F:
        W.append(i+100*B*j)
        j += 1
setW = set(W)
for i in range(0,F+1,C):
    j = 0
    while i+D*j<=F:
        S.append(i+D*j)
        j += 1
setS = set(S)
con = -1
total, ans_s = 0,0
for w in setW:
    for s in setS:
        if w==s==0:
            continue
        if (100*s)/(w+s)<=max_con and s+w<=F and con<(100*s)/(w+s):
            con = (100*s)/(w+s)
            total = w+s
            ans_s = s
print(total, ans_s)


Measured memory_bytes: 52480
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
  ll n,a;
  ll Max=0,Min=0,Sum=0;
  cin >> n;
  REP(i,n){
    cin >> a;
    if(i==0){Min=a;Max=a;}
    Max = (ll)max(a,Max);
    Min = (ll)min(a,Min);
    Sum += a;
  }
  cout << Min <<" "<< Max <<" "<<Sum<<endl;
  return 0;
}


Measured memory_bytes: 3116