akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

long long cnt;

struct SSS
{
	string str;
	int val;
	SSS(string s = "", int v = 0) :str(s), val(v){};
};

void print(vector<SSS> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i].str << " " << data[i].val << endl;
	}
}

void print(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		cout << data[i];
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}
}

void insS(vector<int> &data){
	for (int i = 0; i < data.size(); ++i){
		int v = data[i];
		int j = i - 1;
		while (j >= 0 && data[j] > v){
			data[j + 1] = data[j];
			j--;
		}
		data[j + 1] = v;
		print(data);
	}
}

void bubS(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		int j = data.size() - 1;
		for (; j > i; --j){
			if (data[j] < data[j - 1]) {
				swap(data[j], data[j - 1]);
				cnt++;
			}
		}
	}
	print(data);
	cout << cnt << endl;
}

void selS(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		int idx = i;
		for (int j = i; j < data.size(); ++j) {
			if (data[j] < data[idx]) idx = j;
		}
		swap(data[idx], data[i]);
		cnt += (i != idx);
	}
	print(data);
	cout << cnt << endl;
}


int main(){
	int n; cin >> n;
	vector<int> data(n);
	for (int i = 0; i < n; ++i) cin >> data[i];
	//insS(data);
	//bubS(data);
	selS(data);

	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int va[100010];
vector<int>v[100010];
int val(int a)
{
    int &r=va[a];
    if(r!=-1)
        return r;
    r=0;
    for(auto x:v[a])
        r=max(r,val(x));
    r++;
    return r;
}
int main()
{
    memset(va,-1,sizeof va);
    int n,m,a,b;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>a>>b;
        v[b].push_back(a);
    }
    int ans=1;
    for(int i=1; i<=n; i++)
        ans=max(ans,val(i));
    cout<<ans-1<<endl;
}


Measured memory_bytes: 9088
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    x = II()
    if x < 1200:
        print("ABC")
    else:
        print("ARC")
    return

#B
def B():
    s = S()
    a = inf
    z = 0
    for num,si in enumerate(s):
        if si == "A":
            a = min(a, num)
        if si == "Z":
            z = max(z, num)
    print(z-a+1)
    return

#C
def C():
    x = II()
    print(x // 11 * 2 + (x % 11) // 7 + (x % 11 != 0))
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 38512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <vector>
#include <queue>

#define ll long long

using namespace std;

inline int read() {
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int main() {
	int n=read(),m=read();
	cout<<(n*(n-1)+m*(m-1))/2;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

if n % 2 == 0:
    a1 = a[::2]
    a2 = a[1::2]
    a2 = a2[::-1]

    ans = a2 + a1
else:
    a1 = a[::2]
    a1 = a1[::-1]
    a2 = a[1::2]

    ans = a1 + a2

ans = map(str, ans)
print(' '.join(ans))

Measured memory_bytes: 31428
N,Y = map(int,input().split())

flag = 0
for x in range(N+1):
    if flag > 0:
        break
    for y in range(N-x+1):
        z = N-x-y
        if 10000*x+5000*y+1000*z == Y and flag == 0:
            flag+=1
            print(x,y,z)
            break
            
if flag == 0:
    print('-1 -1 -1')

Measured memory_bytes: 9048
n, y = map(int, input().split())
for a in range(n + 1):
  for b in range(0, n - a + 1):
    c = n - a - b
    total = 10000 * a + 5000 * b + 1000 * c
    if (total == y):
      print(a, b, c)
      exit()
else:
  print('-1 -1 -1')


Measured memory_bytes: 3060
#include<stdio.h>
#include <string.h>
int main(void)
{
  int D1[100],D2[100],i=0,N,cnt=0,ans=0;
  
  scanf("%d",&N);
  for(i;i<N;i++)
  {
    scanf("%d %d",&D1[i],&D2[i]);
    if(D1[i]==D2[i]){
      cnt++;
      if(cnt>=3){ans=1;}
    }else{
      cnt=0;
    }
  }
  
  if(ans==1){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

ll diff( ll S1, ll S2, ll S3) {
  ll Smax = std::max( { S1, S2, S3 } );
  ll Smin = std::min( { S1, S2, S3 } );
  return Smax - Smin;
}

ll calc( int H, int W ) {
  ll rtn = 1e10;
  // pattern A
  for(ll h : {H/3-1, H/3, H/3+1} ) {
    ll S1 = h*W;
    for(ll hh : {(H-h)/2-1, (H-h)/2, (H-h)/2+1} ) {
      ll S2 = hh*W;
      ll S3 = (H-h-hh)*W;
      rtn = std::min( rtn, diff(S1, S2, S3) );
    }
    for(ll w : {W/2-1, W/2, W/2+1} ) {
      ll S2 = w*(H-h);
      ll S3 = (W-w)*(H-h);
      rtn = std::min( rtn, diff(S1, S2, S3) );
    }
  }
  return rtn;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int H, W; std::cin >> H >> W;

  ll ans = 1e10;
  ans = std::min( ans, calc(H,W) );
  ans = std::min( ans, calc(W,H) );
  std::cout << ans << std::endl;
 
  return 0;
}


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

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a-1;i>=0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

ll par[100002]; //親を表す
ll myrank[100002];  //木の深さを表す
ll size[100002];

void init(ll n){   //初期化
    REP(i,n){
        par[i]=i;
        myrank[i]=0;
    }
}

ll find(ll x){    //親を見つける
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

void unit(ll x, ll y){    //x,yを併合
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(myrank[x]<myrank[y]){
        par[x]=y;
        size[y] += size[x];
    }else{
        par[y]=x;
        if(myrank[x]==myrank[y])myrank[x]++;
        size[x] += size[y];
    }
}

bool same(ll x, ll y){    //x,yが同じグループか判定
    return find(x)==find(y);
}


ll nC2(ll n){
    return n * (n - 1) / 2;
}

int main() {
    ll n, m;
    cin >> n >> m;
    VE a(m), b(m);
    REP(i, m)cin >> a[i] >> b[i];
    init(n);
    REP(i, n + 1)size[i] = 1;
    VE tmp;
    RREP(i, m) {
        ll A = a[i];
        ll B = b[i];
        if(same(a[i], b[i])){
            tmp.push_back(0);
            continue;
        }
        ll sizeA = size[find(a[i])];
        ll sizeB = size[find(b[i])];

        ll big = nC2(sizeA + sizeB);
        ll smalla = nC2(sizeA);
        ll smallb = nC2(sizeB);
        tmp.push_back(big - smalla - smallb);
        unit(a[i], b[i]);
    }
    ll cnt = 0;
    VE ans;
    REP(i, m){
        ans.push_back(nC2(n) - cnt);
        cnt += tmp[i];
    }
    jkl;
    RREP(i, m){
        print(ans[i]);
    }
}

Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,1,0,-1};
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);

    int A,B,C;cin>>A>>B>>C;
    cout<<C<<" "<<A<<" "<<B<<endl;
    return 0;
}

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

int main()
{
    int n, res = 0;
    cin >> n;

    vector<int> p(n);
    for(int i = 0; i < n; ++i)
        cin >> p[i];

    int mn = p[0];
    for(int i = 0; i < n; ++i)
    {
        if(p[i] <= mn) res++;
        mn = min(mn, p[i]);
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 4052
def readints():
    return list(map(int, input().split()))


N = int(input())
SP = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    SP.append((s, -p, i))
# print(SP)
SP.sort()
for s, p, i in SP:
    print(i+1)


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




int main() {
	int N;
	cin >>N;
	int64_t count =1;
	int64_t pri=pow(10,9)+7;
	vector<int> an(N,0);
	
	if(N%2==0){
		for(int i=0;i<N;i++){
			int a;
			cin >>a;
			if (a==0){
				count =0;
				break;
			}
			
			an.at(a)++;
			if (an.at(a)==3){
				count =0;
				break;
			}
			else if(an.at(a)==2){
				
				count =(count*2) %pri ;
			}
			
			
			
		}
		cout << count %pri<<endl;
	}
	
	else {
		for(int i=0;i<N;i++){
			int a;
			cin >>a;
			
			an.at(a)++;
			
			if(an.at(a)==2){
				count =(count*2)%pri ;
			}
			
			else if (an.at(a)==3){
				count =0;
				break;
			}
			
			if(an.at(0) == 2){
				count =0;
				break;
			}
			
			
		}
		cout << count %pri<<endl;
	}
	
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int fac(int n)
{
	if (n == 0) return 1;
	else return n*fac(n - 1);
}

int main()
{
	int n;
	while (cin >> n, n)
	{
		vs v(n);
		REP(i, n) cin >> v[i];
		int var[26] = {};
		bool ex[26] = {};
		REP(i, n - 1)
		{
			int t = 1;
			REP(j, v[i].size())
			{
				int c = v[i][v[i].size() - j - 1] - 'A';
				ex[c] = true;
				var[c] += t;
				t *= 10;
			}
		}
		int t = 1;
		REP(j, v.back().size())
		{
			int c = v.back()[v.back().size() - j - 1] - 'A';
			ex[c] = true;
			var[c] -= t;
			t *= 10;
		}
		vi let, top;
		int rlet[26];
		t = 0;
		REP(i, 26)
		{
			if (ex[i])
			{
				let.push_back(i);
				rlet[i] = t++;
			}
		}
		REP(i, v.size())
		{
			if (v[i].size() == 1) continue;
			int c = v[i][0] - 'A';
			int ind = find(ALL(let), c) - let.begin();
			if (find(ALL(top), ind) != top.end()) continue;
			top.push_back(ind);
		}
		int ans = 0;
		int per[] = { 0,1,2,3,4,5,6,7,8,9 };
		do
		{
			bool f = false;
			REP(i, top.size())
			{
				if (per[rlet[let[top[i]]]] == 0)
				{
					f = true;
					break;
				}
			}
			if (f) continue;
			int res = 0;
			REP(i, let.size())
			{
				int tmp = var[let[i]] * per[rlet[let[i]]];
				res += tmp;
			}
			if (res == 0)
			{
				ans++;
			}
		} while (next_permutation(per, per + 10));
		cout << ans / fac(10 - let.size()) << endl;
	}
	return 0;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void dfs(vector<int> A) {
    if (A.size() == n+1) {
        // calc score
        int sum = 0;
        for (int i = 0; i < q; i++)
        {
            if (A[b[i]] - A[a[i]] == c[i])
                sum += d[i];
        }
        ans = max(ans, sum);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m)
    {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;

    a = b = c = d = vector<int>(q);
    for (int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1, 1));
    cout << ans << endl;
}

Measured memory_bytes: 3608
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [n,m] = nextIntArray()
    let ab = []
    while(hasNext()){
        ab.push(nextIntArray())
    }
    ab.sort((a,b) => a[0]-b[0])
    let ans = 0
    let i = 0
    while(m>0){
        if(m > ab[i][1]){
            ans += ab[i][0]*ab[i][1]
            m -= ab[i][1]
        }else{
            ans += ab[i][0]*m
            m = 0
        }
        i++
    }
    console.log(ans)
}
Main()



Measured memory_bytes: 64424
N = int(input())
A = list(map(int, input().split()))


def solve(N,A):
    s,e = 0, N-1
    dp = [[0]*N for i in range(N)]
    for k in range(N):
        for i in range(N-k):
            j = i+k
            sign = (-1)**(N-1-k)
            if k==0:
                dp[i][j] = sign*A[i]
                continue
            dp[i][j] = sign*max(sign*dp[i+1][j]+A[i],sign*dp[i][j-1]+A[j])
    ans = dp[0][N-1]
    return ans
print(solve(N,A))

Measured memory_bytes: 111836
N,M=map(int,input().split())
A=list(map(int,input().split()))
L=sum(A)/(4*M)
j=0
A1=sorted(A,reverse=True)
for i in range(M):
    if A1[i]>=L:
        j+=0
    else:
        j+=1
if j==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long int
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define LN outchar('\n')
using namespace std;
const ll MOD  = int(1e9 + 7);

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}

const int NAX = 305;
double dp[NAX][NAX][NAX] = {0};
bool calc[NAX][NAX][NAX] = {false};

double solve (int a , int b , int c  , int n) {
	if (a == 0 && b == 0 && c ==0) {
		return	 0;
	}
	if (calc [a][b][c]) {
		return dp[a][b][c];
	} else {
		int k = a + b + c;
		double first = (a>0) ?solve(a-1,b,c,n):0.0;
		double second = (b>0)?solve(a+1,b-1,c,n):0.0;
		double third = (c>0) ?solve(a,b+1,c-1,n):0.0;
		dp[a][b][c] = (double)n/k + (double)a/k * first + (double) b/k * second + (double) c/k * third;
		calc[a][b][c] = true;
		return dp[a][b][c];
	}
}




int main () {
	// Har state pe char option hai...
	// ya to unrolled 
	int n;
	inpos(n);
	int temp;
	vector <int > count(4,0);
	for (int i = 0 ; i<n;i++) {
		// cin >> temp;
		inpos(temp);
		count[temp]++;
	}

	
	cout << setprecision(10) << solve (count[1], count[2], count[3], n)<<endl;


}

Measured memory_bytes: 246016
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        a: usize,
        b: usize,
        s: String,
    }
    let s_: Vec<&str> = s.split('-').collect();
    if s_.len() != 2 {
        println!("No");
        return;
    } else {
        if s_[0].len() == a && s_[1].len() == b {
            println!("Yes")
        } else {
            println!("No")
        }
    }
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


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

    public static long[] Reads()
    {
         return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
  
     public static int digit(long x)
    {
        int d = 0;
        if (x == 0)
            return 1;
        else
        {
            while (x > 0)
            {
                x /= 10;
                d++;
            }
            return d;
        }
    }
    public static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        
        var n = Read();
        var input = Reads();
        var a = new long[n];
        for(long i = 0; i < n; i++)
        {
            a[i] = input[i];
        }
        Array.Sort(a);
        bool f = false;
        for(long i = 0; i < n-1; i++)
        {
            if (a[i] == a[i + 1])
            {
                f = true;
            }
        }
        if (f)
            Console.WriteLine("NO");
        else
            Console.WriteLine("YES");
        

      
        Console.Out.Flush();

    }
}

Measured memory_bytes: 36380
#include<stdio.h>

int main(void){
  long long int N,i,tmp=0;
  long long int A[100001],B[100001];
  scanf("%lld",&N);
  for(i=0;i<N;i++){
    scanf("%lld %lld",&A[i],&B[i]);
  }
  for(i=N-1;i>0;i--){
    if(A[i]%B[i]){
      tmp+=B[i]-(A[i]%B[i]);
    }
    A[i-1]+=tmp;
  }
  if(A[i]%B[i]){
    tmp+=B[0]-(A[0]%B[0]);
  }
  printf("%lld\n",tmp );
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  int n, k; cin >> n >> k;
  Vi h(n+k+3,INF); rep(i,n) cin >> h[i];
  Vi dp(n+k+3,INF); // iに移動したときの最小コスト
  dp[0] = 0;
  rep(i,n) {
    reps(j,k) {
      chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  pl(dp[n-1])
  dump(dp);

  return 0;
}


Measured memory_bytes: 3972
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = 0, sum = 0;
  for (int left = 0, right = 0; left < n; left++) {
    while (right < n && (sum ^ a[right]) == (sum + a[right])) {
      sum += a[right];
      right++;
    }
    ans += right - left;
    if (left == right)
      right++;
    else {
      sum -= a[left];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll a, b, t;
  cin >> a >> b >> t;
  cout << (t/a) * b;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, a;std::cin >> n;
  std::vector<ll> num(300001, 0), S(300001, 0), T(300001, 0);
  for(int i=0;i<n;i++){
    std::cin >> a;
    num[a]++;
  }
  for(int i=1;i<=n;i++) S[num[i]]++;
  std::vector<ll> x(n, 0);

  S[0] = T[0] = 0;
  for(int i=1;i<=n;i++) {
    T[i] = T[i-1] + S[i];
    S[i] = S[i-1] + S[i] * i;
  }
  for(int i=1;i<=n;i++) x[i-1] = (S[i] + i * (T[n]-T[i]))/i;
  sort(x.begin(), x.end());
  //std::cout << x[0] << " "  << x[1] << " " << x[2] << '\n';
  for(int i=1;i<=n;i++){
    ll ans = lower_bound(x.begin(), x.end(), i) - x.begin();
    std::cout << n - ans << '\n';
  }

  return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string s;
  ll k;
  cin >> s >> k;

  bool f = true;
  ll n = s.length();
  rep(i, n) {
    if (s[i] != s[0]) {
      f = false;
      break;
    }
  }
  if (f) {
    cout << n * k / 2 << '\n';
    return 0;
  }
  ll fi = 0, la = 0;
  ll ans = 0;
  if (s[0] == s[n - 1]) {
    while (s[fi] == s[0]) fi++;
    ans += fi / 2;
    while (s[n - 1 - la] == s[n - 1]) la++;
    ans += la / 2;
    ans += (fi + la) / 2 * (k - 1);
  }
  string u = s.substr(fi, n - fi - la) + 'A';
  char c = u[0];
  ll cnt = 0;
  rep(i, u.length()) {
    if (u[i] == c) cnt++;
    else {
      ans += cnt / 2 * k;
      c = u[i];
      cnt = 1;
    }
  }
  cout << ans << '\n';





  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    int k, t;
    std::cin >> k >> t;
    vector<int> a(t);
    for (int i = 0; i < t; i++) {
        std::cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    ll sum = accumulate(a.begin()+1, a.end(), 0);
    int first = a[0];
    int ans = 0;
    if (first - sum > 1) {
        ans = first - sum-1;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long k, a, b;
long long ans;
int main()
{
cin >> k >> a >> b;
if (k < a || b - a <= 2)
{
cout << k + 1;
return 0;
}
long long res = k - (a - 1);
long long d = b - a;
ans = a + d * (res / 2);
if (res & 1)
++ans;
cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  ll n,p,m=1,e=0;
  cin >> n >> p;
  vector<ll> a(p,0),b(n,0);
  string s;
  cin >> s;
  reverse(all(s));
  if (p==2 || p==5){
    ll ans=0;
    rep(i,n){
      int u=s[i]-'0';
      if (u%p==0) ans+=n-i;
    }
    cout << ans << endl;
    return 0;
  }
  rep(i,n){
    ll u=s[i]-'0';
    e=(e+u*m)%p;
    a[e]++;
    b[i]=e;
    m=(m*10)%p;
  }
  ll ans=0,c=0;
  m=1;
  rep(i,n){
    ans+=a[c];
    // cout << c << endl;
    a[b[i]]--;
    ll u=s[i]-'0';
    c=(c+u*m)%p;
    m=(m*10)%p;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define MAX_N 51
using namespace std;

bool G[MAX_N][MAX_N];
bool visited[MAX_N];
int n,m;

void dfs(int u){
    visited[u] = true;
    for(int v = 0; v < n; v++){
        if( !G[u][v] ) continue;
        if( visited[v] )continue;
        dfs(v);
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    vector<int> b1(m);
    vector<int> b2(m);
    for(int i = 0;i<m;i++){
        cin>> b1[i] >>b2[i];
        b1[i]--;b2[i]--;
        G[b1[i]][b2[i]] = G[b2[i]][b1[i]] = true;
        
    }
    ll ans = 0;
    for(int i = 0; i<m;i++){
        G[b1[i]] [b2[i]] = G[b2[i]] [b1[i]] = false;
        for(int i=0; i<n;++i) visited[i] = false;

        dfs(0);

        bool can = true;
        for(int j =0; j<n; ++j){
            if( !visited[j] ) {
                can = false;
                break;
            }
        }
        if( !can ) ans++;
        G[b1[i]] [b2[i]] = G[b2[i]] [b1[i]] =true;
    }
    cout<< ans <<endl;
}


Measured memory_bytes: 256
def solve():
    S = input()
    lenS = len(S)
    sumS = 0
    N = [0] * (lenS + 1)
    zero = set()
    if S[0] == "<": zero |= {0}
    for i in range(lenS - 1):
        if S[i] == ">" and S[i+1] == "<": zero |= {i+1}
    if S[lenS-1] == ">": zero |= {lenS}

    for start in zero:
        pointer = start
        while pointer <= lenS - 1:
            if S[pointer] == "<":N[pointer + 1] = max(N[pointer] + 1, N[pointer + 1])
            else: break
            pointer += 1
        
        pointer = start - 1
        while pointer >= 0:
            if S[pointer] == ">": N[pointer] = max(N[pointer + 1] + 1, N[pointer])
            else: break
            pointer -= 1

    #print(N)
    print(sum(N))

    return 0

if __name__ == "__main__": solve()


Measured memory_bytes: 23348
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];
int DP[100100];

// 負の数にも対応した % 演算

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

signed main() {
  int N, M; cin >> N >> M;
  memset(Input, 1, sizeof(Input));
  
  for (int i = 0; i < M; i++) {
    int a; cin >> a;
    Input[a] = 0;
  }

  DP[0] = 1;
  DP[1] = (Input[1] == 0 ? 0 : 1);

  for (int i = 2; i <= N; i++) {
    if (Input[i] == 0) {
      DP[i] = 0;
    } else {
      DP[i] = DP[i-1] + DP[i-2];
      DP[i] = mod(DP[i], MOD);
    }
  }
  cout << DP[N] << endl;
}


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

typedef long long int          ll;
typedef set<int>               si;
typedef pair<int,int>          pii;
typedef pair<ll,ll>            pll;
typedef vector<int>            vi;
typedef vector<ll>             vll;
typedef vector<vll>            vvl;
typedef map<int,int>           mi;
typedef map<ll,ll>             mll; 

/*.................................................................................................................................*/

#define mod                    1000000007
#define nl                     "\n";
#define ff                     first 
#define ss                     second
#define mp                     make_pair
#define pb                     push_back
#define sz(a)                  (int)a.size()
#define fi(a,b)                for(ll i=a;i<b;i++)
#define fj(a,b)                for(ll j=a;j<b;j++)
#define fri(a,b)               for(ll i=a;i>=b;i--)
#define frj(a,b)               for(ll j=a;j>=b;j--)
#define all(v)                 (v).begin(),(v).end()
#define mem(v,a)               memset((v),a,sizeof(v))
#define show(v)                for(auto i:v)cout<<i<<" ";cout<<nl; 
#define fast                   ios_base::sync_with_stdio(false);cin.tie(NULL);

/*.................................................................................................................................*/

inline ll add(ll a, ll b)      {a += b ;return a >= mod ? a - mod : a ;}
inline ll sub(ll a, ll b)      {a -= b ;return a < 0 ? a + mod : a ;}
inline ll mul(ll a, ll b)      {return (ll)a * b % mod ;}
inline ll power(ll a,ll n)     {ll res=1;while(n){if(n&1){res=mul(res,a);} n>>=1,a=mul(a,a);}return res;}
inline ll sum(ll n)            {ll sum=n;if(sum%2==0){sum=sum>>1;sum*=(n+1);}else sum*=((n+1)/2);return sum;}

/*.....................................................CODE_STARTS.................................................................*/
int prime[1000005];
void solve(){
	unordered_map<string,int> m;
	m["AC"]=0;
	m["WA"]=0;
	m["TLE"]=0;
	m["RE"]=0;
	int n;cin>>n;
	fi(0,n){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<nl;
	cout<<"WA x "<<m["WA"]<<nl;
	cout<<"TLE x "<<m["TLE"]<<nl;
	cout<<"RE x "<<m["RE"]<<nl;
}
int main(){
    fast
    int t=1;
    //cin>>t;
    while(t--){
       solve();if(t!=0)cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    cin >> n;
    set<char> st;
    forn(i, n) {
        char x;
        cin >> x;
        st.insert(x);
    }
    if (sz(st) == 3)
        cout << "Three" << endl;
    else
        cout << "Four" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = 1LL<<55;
const Int mod = (1e9)+7;
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  map<string,int> M;
  
  int q;
  cin>>q;

  while(q--){
    int cmd;
    cin>>cmd;
    if(cmd == 0){
      string key;
      int x;
      cin>>key>>x;
      M[key] = x;
    }
    
    if(cmd == 1){
      string key;
      cin>>key;
      cout<<M[key]<<endl;
    }
    
    if(cmd == 2){
      string key;
      cin>>key;
      M.erase(key);
    }
  }
  return 0;
}



Measured memory_bytes: 25788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

const ll MOD = 1000000007;
const ll mod = 1000000007;
const ll MAX = 1000009;

struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {
    }
    mint operator-() const {
        return mint(-x);
    }
    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;
    }
};

ll fac[MAX], finv[MAX], inv[MAX];  //階乗、階乗の逆元、逆元

void nCk_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1]            = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i]  = fac[i - 1] * i % MOD;
        inv[i]  = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCk(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    nCk_init();

    mint ans = 0;
    rep(i, N) {
        mint now = nCk(i, K - 1);
        ans += now * A[i];
    }
    reverse(all(A));
    rep(i, N) {
        mint now = nCk(i, K - 1);
        ans -= now * A[i];
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 24064
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {

    int N;
    cin >> N;
    vector<int> P(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> P[i];
    }    
    sort( P.begin(), P.end() );
    long long ans = 0;
    for ( int i = 0; i < N-1; i++ ) {
        ans += P[i];
    }
    ans += P[N-1]/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[]
for _ in range(n):
    a=list(map(int,input().split()))
    a=set(a[1:])
    l.append(a)
for i in range(n-1):
    l[i+1]=l[i]&l[i+1]
print(len(l[-1]))


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

long long INF = 1LL << 60;
int N_MAX = 1e5;
vector<long long int> dp(N_MAX+1, INF);
vector<int> h(N_MAX, 0);

long long play(int i){
  if(dp[i] < INF) return dp[i];
  if(i == 0)  return 0;
  
  long long res = INF;
  res = min(res, play(i - 1) + abs(h[i] - h[i-1]));
  if(i > 1) res = min(res, play(i - 2) + abs(h[i] - h[i-2]));
  
  return dp[i] = res;
}

int main(){
  int N; cin >> N;
  for(int i = 0; i < N; i++){
    cin >> h[i];
  }
  dp[0]=0;
  cout << play(N-1) << endl;
  
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll link[100100];
ll size[100100];
ll find(ll x)
{
    while(link[x]!=x)
    {
        x=link[x];
    }
    return x;
}
ll same(ll a,ll b)
{
    return find(a)==find(b);
}
ll unite(ll a,ll b)
{
    a=find(a);
    b=find(b);
    if(size[a]<size[b])
    {
        swap(a,b);
    }
    size[a]+=size[b];
    link[b]=a;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll a[m+1],b[m+1];
    for(ll i=1;i<=n;i++)
    {
        link[i]=i;
        size[i]=1;
    }
    for(ll i=1;i<=m;i++)
    {
        cin>>a[i]>>b[i];
    }
    vector<ll>ans;
    ll cur=n*(n-1)/2;
    for(ll i=m;i>=1;i--)
    {
        ans.push_back(cur);
        if(find(a[i])!=find(b[i]))
        {
            a[i]=find(a[i]);
            b[i]=find(b[i]);
            ll a1=size[a[i]];
            ll b1=size[b[i]];
            cur=cur+(a1)*(a1-1)/2+(b1)*(b1-1)/2;
            unite(a[i],b[i]);
            //cout<<cur<<" ";
            a1=size[find(a[i])];
            cur=cur-a1*(a1-1)/2;
            //cout<<cur<<endl;
        }
    }
    for(ll i=ans.size()-1;i>=0;i--)
    {
        cout<<ans[i]<<endl;
    }
}

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


int main(){

    //set<pair<int, int> > s;
    map<pair<long long, long long>, long long> m;
    long long h, w, n; cin >> h >> w >> n;
    for(int k = 0; k < n; k++){
        long long a, b; cin >> a >> b;
        for(int i = 0; i < 3 && a - i > 0; i++){
            if(a - i + 2 > h) continue;
            for(int j = 0; j < 3 && b - j > 0; j++){

                if(b - j + 2 > w) continue;
                else if(m[{a - i, b - j}] == 0) m[{a - i, b - j}] = 1;
                else m[{a - i, b - j}]++;
                //s.insert({i, j});
            }
        }
    }

    long long ans[10] = {};
    for(auto itr = m.begin(); itr != m.end(); itr++){
        //cout << itr->second << endl;
        ans[itr->second]++;
    }
    long long num = 0;
    for(int i = 1; i < 10; i++){
        num += ans[i];
    }

    /*for(int i = 1; i <= 2; i++){
        for(int j = 1; j <= 3; j++){
            cout << m[{i, j}] << " ";
        }
        cout << endl;
    }*/
    cout << (h - 2) * (w - 2) - num << endl;
    for(int i = 1; i < 10; i++) cout << ans[i] << endl;
    
    return 0;
}

Measured memory_bytes: 56448
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 1000005
#define MOD 1000000007
#define endl "\n"
lli fact[MAX];
lli invfact[MAX];
long long binpow(long long a, long long b) {
    lli m = MOD;
	a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
void precompute(){
	fact[0] = 1;
	invfact[0] = 1;
	for(lli i = 1; i<MAX-5; i++){
		fact[i] = fact[i-1]*i%MOD;
		invfact[i] = binpow(fact[i], MOD-2);
	}
}
lli nCr(lli x, lli y){
	if(y == 0)
		return 1;
	return fact[x]*invfact[y]%MOD*invfact[x-y]%MOD;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	precompute();
	lli n,m;
	cin>>n>>m;
	lli ans = 0;
	lli q = nCr(m,n)*fact[n]%MOD;
	for(lli i = 0; i<=n; i++){
		lli qty = nCr(n,i)*nCr(m-i,n-i)%MOD;
		qty *= fact[n-i];
		qty %= MOD;
		if(i%2){
			ans -= qty;
		}
		else{
			ans += qty;
		}
		ans %=MOD;
	}
	ans += MOD;
	ans%=MOD;
	cout<<(q*ans)%MOD<<endl;
}

Measured memory_bytes: 19264
#include <stdio.h>
#define MAX 100000
#define N -1
struct Node{int p, l, r;};
struct Node T[MAX];
int n, D[MAX];

void print(int x){
  int i,c;
  printf("node %d: ",x);
  printf("parent = %d, ",T[x].p);
  printf("depth = %d, ",D[x]);
  if(T[x].p==N)
    printf("root, ");
  else if(T[x].l==N)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");
  for(i=0,c=T[x].l;c!=N;i++,c=T[c].r){
    if(i)
      printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int x, int p){
  D[x]=p;
  if(T[x].r!=N)
    rec(T[x].r,p);
  if(T[x].l!=N)
    rec(T[x].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=N;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)
	T[v].l=c;
      else
	T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==N)
      r=i;
  }
  rec(r,0);
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}
      

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

using namespace std;

int main(){
    string S,T,U;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    cin >> U;
    if(S==U){
        cout << A-1 << " " << B << endl;
    }else{
        cout << A << " " << B-1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
int main()
{
  int a , b ;
  cin >> a >> b ;
  int maxn1 = (int) ((a + 1) / 0.08) ;
  int mixn1 = (int) (a / 0.08) ;
  int maxn2 = (int) ((b + 1) / 0.1) ;
  int mixn2 = (int) (b / 0.1) ;
  for(int i = min(mixn1 , mixn2) ;i <= max(maxn1 , maxn2) ;i ++)
   if((int) (i * 0.08) == a && (int) (i * 0.1) == b)
    {
      cout << i << endl ;
      return 0 ;
    }
    puts("-1") ;
  return 0 ;
}


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


int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

long long lcm(int a, int b) {
	return a / gcd(a, b) * 1LL * b;
}

int main() {
	int A, B;
	cin >> A >> B;
	cout << lcm(A, B) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int a, b;

int main () {
  cin >> a >> b;
  vector<int> s(100101, 0);
  for(int i = 1; i*i < 100100; i++) {
    s[i*i] = 1;
  }

  int i = 1;
  while(b/i != 0) {
    i *= 10;
  }

  cout << (s[a*i + b] ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 640
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();

    let (n, m): (usize, usize) = {
        let mut split = buf.split_whitespace().map(|x| x.parse().unwrap());
        (split.next().unwrap(), split.next().unwrap())
    };
    let sc: Vec<(usize, usize)> = (0..m)
        .map(|_| {
            buf.clear();
            stdin.read_line(&mut buf).unwrap();
            let mut split = buf.split_whitespace().map(|x| x.parse().unwrap());
            (split.next().unwrap(), split.next().unwrap())
        })
        .collect();
    'outer: for x in 0..1000 {
        let st = x.to_string();
        if st.len() != n {
            continue;
        }
        for &(s, c) in &sc {
            if st.as_bytes()[s - 1] != c as u8 + b'0' {
                continue 'outer;
            }
        }
        println!("{}", st);
        return;
    }
    println!("-1");
}


Measured memory_bytes: 4352