akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e3+10,inf=1e9+10,mod=1e9+7;
int a[M],cnt[M];
main()
{
	int n;
	cin>>n;
	int maxx=0;
	for(int i=1;i<=n;i++)cin>>a[i],cnt[a[i]]++,maxx=max(a[i],maxx);
	int tmp=maxx/2;
	if(maxx==1 && n>2)return cout<<"Impossible",0;
	if(maxx%2==0)tmp--;
	for(int i=tmp;i>=0;i--)
	{
		if(cnt[i])return cout<<"Impossible",0;
	}
	if(maxx%2==0){
	//	cout<<maxx<<endl;
		for(int i=maxx;i>maxx/2;i--)
		{
			if(cnt[i]<2)return cout<<"Impossible",0;
		}
		if(cnt[maxx/2]!=1)return cout<<"Impossible",0;
		cout<<"Possible";
		return 0;
	}
	else
	{
		for(int i=maxx;i>=maxx/2+1;i--)
		{
			if(cnt[i]<2)return cout<<"Impossible",0;
		}
		if(cnt[maxx/2+1]!=2)return cout<<"Impossible",0;
		cout<<"Possible";
		return 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n,c;
  while(cin>>n>>c,n||c){
    int s[n+2][n+2],i,j,k,l,x,y,z,a,tmp,ans=-n*n;
    bool u[n+2][n+2],f,d;
    int ax[]={-1,-1,0,0,1,1},ay[]={-1,0,-1,1,0,1};
    memset(s,-1,sizeof(s));
    for(i=1;i<=n;i++) for(j=1;j<=i;j++) cin>>s[i][j];
    for(i=1;i<=n;i++)
      for(j=1;j<=i;j++){
	if(s[i][j]) continue;
	s[i][j]=c;
	memset(u,0,sizeof(u));
	tmp=0;
	for(k=1;k<=n;k++)
	  for(l=1;l<=k;l++){
	    if(!s[k][l]||u[k][l]) continue;
	    f=1;z=0;
	    queue<P> q;
	    q.push(P(k,l));
	    while(!q.empty()){
	      x=q.front().first;y=q.front().second;q.pop();
	      if(u[x][y]) continue;
	      u[x][y]=1;z++;
	      for(a=0;a<6;a++){
		if(s[k][l]==s[x+ax[a]][y+ay[a]]) q.push(P(x+ax[a],y+ay[a]));
		if(!s[x+ax[a]][y+ay[a]]) f=0;
	      }
	    }
	    tmp+=z*f*(s[k][l]==c?-1:1);
	  }
	ans=max(ans,tmp);
	s[i][j]=0;
      }
    cout<<ans<<endl;
  }
  return 0;
}

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

unsigned long long popcount(unsigned long long x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) +
      (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) +
      (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) +
      (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) +
      (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) +
      (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) +
      (x & 0x00000000ffffffffUL);
  return x;
}

vector<string> s;
vector<int> num;
vector<vector<int>> dp;
int n, m;

int solve();
int all_search();
int bit_dp();

int main() {
  while(1) {
    cin >> n >> m;
    if(n + m == 0) break;
    s.resize(n);
    for(int i = 0; i < n; ++i) cin >> s[i];
    sort(s.begin(), s.end());
    cout << solve() << endl;
  }
  return 0;
}

int solve() {
  if(n * n <= 500)
    return all_search();
  else
    return bit_dp();
}

int all_search() {
  num.assign(m, 0);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < m; ++j)
      num[j] += (s[i][j] == '1') * (1 << i);
  int ans = 0;
  for(int i = 0; i < (1 << n); ++i) {
    bool isok = 1;
    for(int j = 0; j < m; ++j)
      if(popcount(i & num[j]) & 1) isok = 0;
    if(isok) ans = max(ans, (int)popcount(i));
  }
  return ans;
}

int bit_dp() {
  num.assign(n, 0);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < m; ++j)
      num[i] += (s[i][j] == '1') * (1 << j);
  dp.assign(n + 1, vector<int>((1 << m), 0));
  for(int i = 1; i < (1 << m); ++i) dp[0][i] = -n;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < (1 << m); ++j)
      dp[i + 1][j] = max(dp[i][j], dp[i][j ^ num[i]] + 1);
  return dp[n][0];
}



Measured memory_bytes: 231304
#include "iostream"
#include "string"

int main()
{
    int h, m;
    std::string str, temp;
    while(1){
        std::cin >> str;
        if(str == "-") break;
        std::cin >> m;
        for(int i = 0; i < m; i++){
            std::cin >> h;
            temp = str.substr(0, h);
            str = str.substr(h, str.length() - 1);
            str = str + temp;
        }
        std::cout << str << std::endl;
    }
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct block{
    public:
        int w, s;
        ll v;

        block(int _w, int _s, ll _v){
            w = _w;
            s = _s;
            v = _v;
        }

        bool operator<(const block& in) const {
            return (w + s) < (in.w + in.s);
        }
};
ll dp[1005][20005];

int main() {
    //cout.precision(10);
    vector<block> blocks;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int w, s;
        ll v;
        cin >> w >> s >> v;
        block in(w, s, v);
        blocks.push_back(in);
    }
    sort(blocks.begin(), blocks.end());
    for(int index = 0; index < n; index++){
        block now = blocks[index];
        for(int weight = 0; weight <= 20000; weight++){
            dp[index + 1][weight] = max(dp[index + 1][weight], dp[index][weight]);
            if(weight <= now.s){
                dp[index + 1][weight + now.w] = max(dp[index + 1][weight + now.w], dp[index][weight] + now.v);
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i <= 20000; i++){
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 156544
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    int n, m, k;
    cin >> n >> m >> k;
    for ( int i = 0; i <= n; i++) {
        for ( int j = 0; j <= m; j++) {
            if ( i * j + (n - i) * (m - j) == k) {
                cout <<"Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;

int main(){




int n;
char tcard[100];
char hcard[100];
int tsum=0;
int hsum=0;

cin>>n;
for(int i=0;i<n;i++){
cin>>tcard>>hcard;
if(strcmp(tcard,hcard)>0)tsum += 3;
else if(strcmp(tcard,hcard)<0)hsum += 3;
else tsum += 1,hsum += 1;
}

cout<<tsum<<" "<<hsum<<endl;
}



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

int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  vector<int> sum(N);
  for(int i = 0; i < N; i++)
    cin >> s.at(i);
  cin >> M;
  vector<string> t(M);
  for(int i = 0; i < M; i++)
    cin >> t.at(i);
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(s.at(i) == s.at(j))
        sum.at(i) += 1;
    }
    for(int j = 0; j < M; j++){
      if(s.at(i) == t.at(j))
      sum.at(i) -= 1;
    }
    if((i ==0) && (sum.at(i) < 0))
      sum.at(i) = 0;
    if((i > 0) && (sum.at(i) < sum.at(i - 1)))
      sum.at(i) = sum.at(i - 1);
  }
  cout << sum.at(N - 1) << endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll solve(ll N, ll X, ll D) {
    if(X == 0 and D == 0) return 1LL;
    if(D == 0) return N + 1;
    if(D < 0) {
        X += D * (N - 1);
        return solve(N, X, -D);
    }

    // D > 0 としてよい
    // A_i = X + iD (0-indexed)
    // 1X + kD (0 <= k <= N-1)
    // 2X + kD (1 <= k <= 2N-3)
    // 3X + kD (3 <= k <= 3N-6) ...
    // iX + kD ( i*(i-1)/2 <= k <= i*N-i*(i+1)/2 )
    // fprintf(stderr, "N = %lld, X = %lld, D = %lld\n", N, X, D);
    
    ll ans = 0;
    map< ll, ll > mod_l, mod_u;
    for(ll i=0; i<=N; i++) {
        ll lb = i*(i-1)/2, ub = i*N-i*(i+1)/2;
        if(lb > ub) swap(lb, ub);
        ll m = (X * i) % D, d = (X * i) / D;
        if(m < 0) d--, m += D;
        lb += d, ub += d;
      
        if(mod_l.count(m)) {
            if(mod_u[m] <= lb) ans += ub - lb + 1;
            else if(ub <= mod_l[m]) ans += ub - lb + 1;
            else {
                if(mod_u[m] <= ub) ans += ub - mod_u[m] + 1;
                if(lb <= mod_l[m]) ans += mod_l[m] - lb + 1;
            }
            chmax(mod_u[m], ub + 1);
            chmin(mod_l[m], lb - 1);
        }
        else {
            ans += ub - lb + 1;
            mod_u[m] = ub + 1;
            mod_l[m] = lb - 1;
        }
    }

    return ans;
}

int main() {
    ll N, X, D; cin >> N >> X >> D;
    cout << solve(N, X, D) << endl;
    return 0;
}


Measured memory_bytes: 25216
let rec make_list n m =
    if n = m then [n] else n :: make_list (n+1) m
let rec string_of_list lst = match lst with
    | [] -> ""
    | f :: r -> string_of_int f ^ " " ^ string_of_list r
let () =
    let k, x = Scanf.scanf "%d %d\n" (fun a b -> a, b) in
    let str = string_of_list (make_list (x-k+1) (x+k-1)) in
    Printf.printf "%s\n" str

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int volume = scanner.nextInt();
        int length = scanner.nextInt();
        // 文字の取得
        List<String> list = new ArrayList<>();
        for (int n = 0; n < volume; n ++) {
            String word = scanner.next();
            list.add(word);
        }
        List<String> sortedList = list.stream().sorted(Comparator.naturalOrder())
                .collect(Collectors.toList());
        String result = "";
        for (String word : sortedList) {
            result += word;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 30676
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
int a[1010][8],n,t,d[90];char s[1010];main(){scanf("%d%s",&n,s);a[0][1]=d[79]=1;d[73]=2;r(i,n)r(j,8)r(k,8)if(j&k&&k>>d[s[i]]&1)(a[i+1][k]+=a[i][j])%=10007;r(i,8)t+=a[n][i];printf("%d\n",t%10007);}

Measured memory_bytes: 1204
#include <stdio.h>

int A[2000],n;
int find(int,int);
int main(){
  int i,q,m;

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

  scanf("%d",&q);

  for(i=0;i<q;i++){

    scanf("%d",&m);

    if(find(m,0)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int find(int m,int i){

  if(m==0) return 1;
  if(i>=n) return 0;

  int r=find(m,i+1)||find(m-A[i],i+1);
  return r;

}

Measured memory_bytes: 580
#include<iostream>
using namespace std;
int a[200000]={0};
int main(){
	int n,x;
	cin>>n;
	for(int i=0;i<n-1;i++)cin>>x,a[x-1]++;
	for(int i=0;i<n;i++)cout<<a[i]<<'\n';
} 

Measured memory_bytes: 4372
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, P[10];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> P[i];
    sort(P, P + N);

    int ans = 0;
    rep(i, 0, N - 1) ans += P[i];
    ans += P[N - 1] / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<vector<int>> bulb(M);
  rep(i, M)
  {
    int k;
    cin >> k;
    rep(j, k)
    {
      int s;
      cin >> s;
      s--;
      bulb[i].emplace_back(s);
    }
  }

  vector<int> p(M);
  rep(i, M)
  {
    cin >> p[i];
  }

  int sum = 0;
  for (int i = 0; i < (1 << N); i++)
  {
    rep(m, M)
    {
      int count = 0;
      rep(s, bulb[m].size())
      {
        int sw = bulb[m][s];
        if (i & (1 << sw))
          count++;
      }
      if (count % 2 != p[m])
        break;

      if (m == M - 1)
        sum++;
    }
  }

  cout << sum << endl;

  return 0;
}


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

int main() {
    stack<int> stack1;
    string string1;
    char tmp;
    int a, b;
    while (cin >> string1) {
        char &opt = string1[0];
        if (opt == '+') {
            a = stack1.top();
            stack1.pop();
            b = stack1.top();
            stack1.pop();
            stack1.push(a + b);
        } else if (opt == '-') {
            b = stack1.top();
            stack1.pop();
            a = stack1.top();
            stack1.pop();
            stack1.push(a - b);
        } else if (opt == '*') {
            a = stack1.top();
            stack1.pop();
            b = stack1.top();
            stack1.pop();
            stack1.push(a * b);
        } else {
            stack1.push(atoi(string1.c_str()));
        }
    }
    cout << stack1.top() << endl;
    return 0;
}

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

int main(){
  
  int a,b;
  cin >> a >> b;
  
  int ans=0;
  
  if(b==1){
    cout << 0 << endl;
  }
  
  if(b>1){
    while(b>0){
      if(a<b){
        b-=a-1;
        ans++;
      }else if(a>=b){
        ans++;
        break;
      }
    }
  cout << ans << endl;
  }
}

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

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = INF;
  chmin(ans, a * n);
  chmin(ans, b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[1000111],s=0;
main()
{
  cin>>n;
  for(long long i=1; i<=n; i++)
    cin>>a[i];
  s=a[1];
  for(long long i=2; i<=n; i++)
    s=__gcd(s,a[i]);
  cout<<s;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define llint long long

using namespace std;

llint n, m;
vector<llint> G[100005], revG[100005];
llint color[100005];
llint cnt[3], ecnt;
bool used[100005];

bool dfs(llint v, llint c)
{
	color[v] = c;
	bool ret = true;
	for(int i = 0; i < G[v].size(); i++){
		if(color[G[v][i]] == (c+1)%3) continue;
		if(color[G[v][i]] != -1){
			ret = false;
			continue;
		}
		if(!dfs(G[v][i], (c+1)%3)) ret = false;
	}
	for(int i = 0; i < revG[v].size(); i++){
		if(color[revG[v][i]] == (c+2)%3) continue;
		if(color[revG[v][i]] != -1){
			ret = false;
			continue;
		}
		if(!dfs(revG[v][i], (c+2)%3)) ret = false;
	}
	return ret;
}

void dfs2(llint v)
{
	used[v] = true;
	cnt[color[v]]++;
	for(int i = 0; i < G[v].size(); i++){
		ecnt++;
		if(used[G[v][i]]) continue;
		dfs2(G[v][i]);
	}
	for(int i = 0; i < revG[v].size(); i++){
		if(used[revG[v][i]]) continue;
		dfs2(revG[v][i]);
	}
}

int main(void)
{
	cin >> n >> m;
	llint u, v;
	for(int i = 0; i < m; i++){
		cin >> u >> v;
		G[u].push_back(v);
		revG[v].push_back(u);
	}
	
	llint ans = 0; bool res;
	for(int i = 1; i <= n; i++) color[i] = -1;
	for(int i = 1; i <= n; i++){
		if(color[i] >= 0) continue;
		cnt[0] = cnt[1] = cnt[2] = ecnt = 0;
		res = dfs(i, 0), dfs2(i);
		if(res){
			if(cnt[0] && cnt[1] && cnt[2]){
				ans += cnt[0] * cnt[1] + cnt[1] * cnt[2] + cnt[2] * cnt[0];
			}else ans += ecnt;
		}
		else ans += (cnt[0]+cnt[1]+cnt[2])*(cnt[0]+cnt[1]+cnt[2]); 
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 19840
integer(16) N
integer(16),allocatable::A(:),Num(:)
integer(16) i
read*,N
allocate(A(N),Num(N))
read*,A
do i=1,N
  Num(i)=i
end do
call HeapsortPair(N,A,Num)
write(*,'(i0)', advance='no') Num(1)
do i=2,N
  write(*,'(x,i0)', advance='no')Num(i)
end do
write(*,*)

contains
subroutine HeapsortPair(n,array,array2)
  implicit none
!ここの入力は状況に応じて変更すること
  integer(16),intent(in) :: n
  integer(16),intent(inout) :: array(1:n),array2(1:n)
  integer(16)::i,k,j,l
  integer(16):: t,t2

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
        t2=array2(L)
     else
        t=array(k)
        t2=array2(k)
        array(k)=array(1)
        array2(k)=array2(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           array2(1)=t2
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           array2(i)=array2(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     array2(i)=t2
  enddo
  return
end subroutine HeapsortPair
end

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


def main():
    n, d = map(int, input().split())
    ans = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if (x**2 + y**2) ** 0.5 <= d:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9632
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n, m;
    cin >> n >> m;
    vector<int> cnt(m);

    for(int i=0; i<n; i++){
        int k;
        cin >> k;
        while(k--){
            int a;
            cin >> a;
            cnt[a-1]++;
        }
    }

    int ans = 0;
    for(int i=0; i<m; i++)
        ans += cnt[i] == n;

    cout << ans << endl;

    return 0;
}



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

int main() {
  int a, b;
  cin >> a >>  b;
  int ret;
  ret = max(max(a+b, a-b), a*b);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-12;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint n,i,A,B,C,gru=0,over=0;cin>>n>>A>>B;C=min(A,B)+1;
	if(A==B){
		for(i=0;i<n;i++){
			llint S;cin>>S;S%=C;
			gru^=S;
		}
		cout<<(gru>0?"Hanako":"Jiro")<<endl;
	}else if(A>B){
		for(i=0;i<n;i++){
			llint S;cin>>S;
			if(S>B){over=S;}S%=C;
			gru^=S;
		}
		if(over>0){gru=1;}
		cout<<(gru>0?"Hanako":"Jiro")<<endl;
	}else{
		for(i=0;i<n;i++){
			llint S;cin>>S;
			if(S>A){over+=S;}
			else{S%=C;gru^=S;}
		}
		if(over>gru+A){gru=0;}
		if(over>0&&gru>A){gru=0;}
		cout<<(gru>0?"Hanako":"Jiro")<<endl;
	}
	return 0;
}



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

int main(){
  string s;
  int n, ans = 0;
  cin >> n;
  cin >> s;
  int i = 2;
  while(i < n){
  	if(s[i] == 'C' && s[i-1] == 'B' && s[i-2] == 'A'){
    	ans++;
      	i+=2;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	s := []rune(getString())
	t := []rune(getString())

	ans := 0
	for i := 0; i < 3; i++ {
		if s[i] == t[i] {
			ans++
		}
	}

	fmt.Println(ans)
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  cout<<max(0,a-2*b)<<endl;
}

Measured memory_bytes: 256
fn main() {
    let mut xs = [0; 120];
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let n: usize = line.trim().parse().unwrap();
    for _ in 0..n {
        line.clear();
        std::io::stdin().read_line(&mut line).unwrap();
        let v: Vec<i8> = line.split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect();
        let (b, f, r, p) = (v[0] as usize, v[1] as usize, v[2] as usize, v[3]);
        xs[(b-1)*30+(f-1)*10+r-1] += p;
    }
    for (i, p) in xs.iter().enumerate() {
        if i%30==0 && i!=0 {
            println!("####################", );
        }
        print!(" {}", p);
        if (i+1)%10==0 {
            println!("");
        }
    }
}


Measured memory_bytes: 5028
#約数の個数の和（１~N）約数そのものを求めないので「速い」
def divisor_num(N):
    ans =0
    for i in range(1,N):
        ans +=(N-1)//i #項数
    return ans


# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない

N = int(input())
ans =divisor_num(N)

print(ans)

Measured memory_bytes: 9084
#include <stdio.h>

int main()
{
    int n,m,i,k,j;
    int sum[100] = {0};
    
    scanf("%d %d", &n,&m);
    
    int a[n][m];
    int xb[m];
    
    //行列A
    for(i=0; i<n; i++)
    {
        for(k=0; k<m; k++)
        {
            scanf("%d ", &a[i][k]);
        }
    }
    
    //行列b
    for(i=0; i<m; i++)
    {
        scanf("%d", &xb[i]);
    }
    
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            sum[i] += a[i][j] * xb[j];
        }
        printf("%d\n", sum[i]);
    }
    
    return 0;
}

Measured memory_bytes: 644
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val numbers = readLine()!!.split(" ").map { it.toInt() }
    var sum = 0
    for(i in 0 until n) sum += numbers[i]
    if (sum % 2 == 0) println("YES") else println("NO")
}


Measured memory_bytes: 53680
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vi L(N);
	REP(i, N) {
		cin >> L[i];
	}
	so(L);
	int sum = 0;
	REP(i, N - 1) {
		sum += L[i];
	}
	if (L[N - 1] < sum)cout << "Yes" << endl;
	else cout << "No" << endl;
	PAU;
	return 0;
}


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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N, std::vector<long long> L) {
    int ans = 0;
    rep(i, N) loop (j, i + 1, N) loop (k, j + 1,N) {
        if (L[i] == L[j] || L[i] == L[k] || L[j] == L[k]) continue;
        vector<long long> l = {L[i], L[j], L[k]};
        sort(l.begin(),l.end());
        if (l[0] + l[1] > l[2]) ans++;
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> L(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

int main() {
	int x, t;
	cin >> x >> t;
	if (x > t)cout << x - t;
	else cout << 0;
	cout << endl;
	return 0;
}

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

public class Contestant
{
    public static void Main(string[] args)
    {
        checked
        {
            var /*XN*/ (X, N) = (Int(), Int());
            var line = Console.ReadLine();
            var para = line == "" ? new HashSet<int>() :
            line.Split()
               .Select(int.Parse)
               .ToHashSet();

            for (int i = 0; ; i++)
            {
                var left = X - i;
                if (!para.Contains(left))
                {
                    Console.WriteLine(left);
                    return;
                }

                var right = X + i;
                if (!para.Contains(right))
                {
                    Console.WriteLine(right);
                    return;
                }
            }
        }
    }

    private static string NextInput = "";

    private static int Int() => int.Parse(Str());
    private static long Long() => long.Parse(Str());
    private static float Float() => float.Parse(Str());
    private static double Double() => double.Parse(Str());
    private static string Str()
    {
        var s = NextInput;
        if (s == "") s = Console.ReadLine();

        var idx = s.IndexOf(' ');
        if (idx >= 0)
        {
            NextInput = s.Substring(idx + 1);
            return s.Substring(0, idx);
        }
        NextInput = "";
        return s;
    }
}



Measured memory_bytes: 28368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();
		
		if(Math.abs(A - B) < 2) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 22996
S = list(input())
data=[0]*(len(S)+1)
for i in range(len(S)):
  if S[i] == "<":
    data[i+1] = data[i] + 1
for i in range(len(S)):
  if S[len(S) - i - 1] == ">":
    data[len(S) -i -1] = max(data[len(S)-i]+1, data[len(S)-1-i])
print(sum(data))

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll signed long long int

ll a[MAXX];
multiset<ll> ms;
multiset<ll>::iterator it;
signed main()
{
    FAST;
    string s;
    cin >> s;
    ll ans= 0, br = 0, zer = 0;
    for(ll i = 0; i < s.size(); i++){
    	zer = 0;
    	br = 0;
    	if(s[i] == s[i+1]) {
    			if(s[i+1] == '1'){
    				s[i+1] = '0';
				} 
				else{
					s[i+1] = '1';
				}
				ans ++;
			}
	}
	if(s.size() == 1){
		cout << 0;
		return 0;
	}
	
	cout << ans;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  
  long long N, M, Q, i, j, Maximum = 0, point;
  cin >> N >> M >> Q;
  vector<long long> a(Q), b(Q), c(Q), d(Q);
  
  for(i = 0; i < Q; i++){
    
    cin >> a.at(i);
    cin >> b.at(i);
    cin >> c.at(i);
    cin >> d.at(i);
  }
  
  long long i1, i2, i3, i4, i5, i6, i7, i8, i9, i10;
  vector<long long> A(10);
  
  for(i1 = 0; i1 < M; i1++){
    for(i2 = i1; i2 < M; i2++){
      for(i3 = i2; i3 < M; i3++){
        for(i4 = i3; i4 < M; i4++){
          for(i5 = i4; i5 < M; i5++){
            for(i6 = i5; i6 < M; i6++){
              for(i7 = i6; i7 < M; i7++){
                for(i8 = i7; i8 < M; i8++){
                  for(i9 = i8; i9 < M; i9++){
                    for(i10 = i9; i10 < M; i10++){
                      
                      point = 0;
                      A.at(0) = i1;
                      A.at(1) = i2;
                      A.at(2) = i3;
                      A.at(3) = i4;
                      A.at(4) = i5;
                      A.at(5) = i6;
                      A.at(6) = i7;
                      A.at(7) = i8;
                      A.at(8) = i9;
                      A.at(9) = i10;
                      
                      //for (int j = 9; j > N - 1; j--) A.at(j) = -1;
                      
					  for(j = 0; j < Q; j++){ 
   						if(A.at(b.at(j) - 1) - A.at(a.at(j) - 1) == c.at(j)) point += d.at(j);
    					
  					  }
                      
                      if(point > Maximum) Maximum = point;
                        
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << Maximum << endl;
  return 0;
}

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

using namespace std;

int main(void)
{
	string str;

	cin >> str;

	int ret = 0;

	if (str.length() % 2 == 1){
		char c = str[str.length() / 2];
		if (c != 'w' && c != 'i') ret++;
	}

	int s1 = (str.length() % 2 == 0 ? str.length() / 2 : str.length() / 2 + 1), s2 = str.length() / 2 - 1;
	for ( ; s2 >= 0 && s1 < str.length(); s2--, s1++){
		// cout << str[s2] << " " << str[s1] << endl;
		if (str[s2] == 'i' && str[s1] != 'i'){
			ret++;
			continue;
		}
		if (str[s2] == 'w' && str[s1] != 'w'){
			ret++;
			continue;
		}
		if (str[s2] == '(' && str[s1] != ')'){
			ret++;
			continue;
		}
		if (str[s2] == ')' && str[s1] != '('){
			ret++;
			continue;
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<ll> a(N);
	rep(i,N)cin>>a[i];
	sort(all(a));
	std::map<ll, ll> map;
	rep(i,N){
		map[a[i]]++;
	}
	ll cnt = map.size();
	cerr<<cnt<<endl;
	if(N%3 != 0){
		if(map[0] == N){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
		return 0;
	}
	string ans = "No";
	if(cnt == 3){
		ll res = 0;
		for(auto x: map){
			res ^= x.first;
			if(x.second != N/3){
				res = INF;
				break;
			}
		}
		if(res == 0)ans = "Yes";
	}
	else if(cnt == 2){
		if(map[0] == N/3)ans = "Yes";
	}
	else if(cnt == 1){
		if(map[0] == N)ans = "Yes";
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5632
package main

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

func main() {
	In := readLineInt()
	K, X := In[0], In[1]

	Result := make([]int, 0, K*2)
	Loop(0, K, func(i int) {
		Result = append(Result, X+i)
		if i != 0 {
			Result = append(Result, X-i)
		}
	})
	sort.Ints(Result)

	for i, v := range Result {
		fmt.Print(v)
		if i != (K*2)-1 {
			fmt.Print(" ")
		}
	}
}

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

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

int N;
map<pair<int, int>, vector<pair<int, int>>> Mp;
int inp[1010][1010];

int main() {
	int N, a, b, c1, c2, d1, d2, cnt = 0;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> a;
		a--;
		for (int j = 0;j < N - 2;j++) {
			cin >> b;
			b--;
			c1 = min(a, i);
			d1 = max(a, i);
			c2 = min(b, i);
			d2 = max(b, i);
			if (Mp.count({ c1,d1 }))
				Mp[{c1, d1}].push_back({ c2,d2 });
			else
				Mp.insert({ {c1,d1},{{c2,d2}} });
			inp[c2][d2]++;
			a = b;
		}
	}
	queue<pair<int,int>> Q;
	for (int i = 0;i < N;i++) {
		for (int j = i + 1;j < N;j++) {
			if (inp[i][j] == 0)Q.push({ i,j });
		}
	}
	Q.push({ -1,1 });
	while (Q.size() > 1) {
		tie(a, b) = Q.front();
		Q.pop();
		if (a < 0) {
			Q.push({ a,b + 1 });
			continue;
		}
		cnt++;
		//cout << cnt << " " << a <<" "<<b<< endl;
		for (auto i : Mp[{a, b}]) {
			inp[i.first][i.second]--;
			if (inp[i.first][i.second] == 0)Q.push(i);
		}
	}
	if (cnt != N * (N - 1) / 2)cout << -1 << endl;
	else cout << Q.front().second << endl;
}

Measured memory_bytes: 58880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n,t,a;cin>>n>>t>>a;
    double mn =1e9;
    double dif[n];
    rep(i,n){
        double h;cin>>h;
        double tmp = t-h*0.006;
        mn = min(mn,abs((double)a-tmp));
        dif[i]=abs((double)a-tmp);
    }
    rep(i,n){
        if(dif[i]==mn){
            co(i+1);return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, x;
    cin >> n;
    unordered_map<int, int> a;
    rep(i, n) {
        cin >> x;
        a[x]++;
    }
    bool res = true;
    for (auto p: a) {
        res &= (p.second <= 1);
    }
    cout << (res ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 8520
n,m = map(int,input().split())
A = []
B = []
C = []
d = []

for i in range(n):
  a, b, c = map(int, input().split())
  A.append(a)
  B.append(b)
  C.append(c)
  
for i in range(n):
  d.append(A[i]+B[i]+C[i])
d.sort(reverse = True)
d_1 = 0
for i in range(m):
  d_1 += d[i]

e = []
for i in range(n):
  e.append(-A[i]+B[i]+C[i])
e.sort(reverse = True)
e_1 = 0
for i in range(m):
  e_1 += e[i]


f = []
for i in range(n):
  f.append(-A[i]-B[i]+C[i])
f.sort(reverse = True)
f_1 = 0
for i in range(m):
  f_1 += f[i]

g = []
for i in range(n):
  g.append(A[i]-B[i]+C[i])
g.sort(reverse = True)
g_1 = 0
for i in range(m):
  g_1 += g[i]

h = []
for i in range(n):
  h.append(A[i]+B[i]-C[i])
h.sort(reverse = True)
h_1 = 0
for i in range(m):
  h_1 += h[i]


j = []
for i in range(n):
  j.append(-A[i]+B[i]-C[i])
j.sort(reverse = True)
j_1 = 0
for i in range(m):
  j_1 += j[i]


k = []
for i in range(n):
  k.append(A[i]-B[i]-C[i])
k.sort(reverse = True)
k_1 = 0
for i in range(m):
  k_1 += k[i]


l = []
for i in range(n):
  l.append(-A[i]-B[i]-C[i])
l.sort(reverse = True)
l_1 = 0
for i in range(m):
  l_1 += l[i]


print(max([d_1,e_1,f_1,g_1,h_1,j_1,k_1,l_1]))

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    int x;
    cin>>x;
    vi p(n);
    rep(i,n){cin>>p[i];p[i]-=x;}
    if(n==1)cout<<abs(p[0])<<endl;
    else{
        ll res=abs(p[0]);
        for(int i=1;i<n;i++){
            res=gcd(res,(ll)abs(p[i]));
        }
        cout<<res<<endl;
    }
    return 0;
}




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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	int res = min(a, c);
	
	a -= res;
	c -= res;
	
	if (c > 0) {
		int temp = min(b, c);
		
		res += temp + temp;
		
		c -= temp;
		b -= temp;
		
		res += b;
		
		if (c > 0) res++;
	} else {
		res += b;
	}
	
	cout << res << endl;
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int ans=1;
  int len=k;
  while(len<n){
    ans++;
    len+=k-1;
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int n1, n2, n3, n4;
  
  cin >> N;
  n1 = N /1000;
  n2 = ( N % 1000 ) / 100;
  n3 = ( N % 100 ) / 10;
  n4 = ( N % 10);
  
  if ( n1 == n2  && n2 == n3 ) {
    cout << "Yes" << endl;
  } else if ( n2 == n3  && n3 == n4 ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }   
}

Measured memory_bytes: 256
/*
▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
TAYA
*/
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>
#include <random>


using namespace std;



#define ll long long
#define ld double
#define null NULL
#define prev prev228
#define index index228
#define left left228
#define right right228
#define hash hash228
#define y1 y1228
#define y0 y0228
#define firn(i, n) for (int i = 0; i < (int)n; ++i)
#define forn(i, n) for (int i = 1; i <= (int)n; ++i)
#define int long long

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

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

signed main() {
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n + 1);
	int sum = 0;
	forn(i, n) cin >> a[i], sum += a[i] - 1;
	cout << sum << endl;
	return 0;
}



// kek













Measured memory_bytes: 256
# from collections import defaultdict
# from heapq import heappush, heappop, heapify
# from bisect import bisect_left, insort_left
# from itertools import groupby


class Solution:
    def main(self):
        N = int(input())
        d = list(map(int, input().split()))

        print((sum(d)**2 - sum([d[i]**2 for i in range(len(d))]))//2)


if __name__ == '__main__':
    Solution().main()


Measured memory_bytes: 2940
#coding:utf-8
import collections

a = []
b = []
for i in range(3):
    temp = list(map(int, input().split()))
    a.append(temp[0]-1)
    b.append(temp[1]-1)

c = []
for i in range(3):
    c.append([a[i], b[i]])
    c.append([b[i], a[i]])
    
def hitohude(route):
    if not (0 in route and 1 in route and 2 in route and 3 in route):
        return False
        
    for i in range(3):
        if [route[i], route[i+1]] in c:
            continue
        else:
            return False
    return True

finish=False
for i in range(4):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                route = [i,j,k,l]
                flag = hitohude(route)
                if flag == True:
                    print('YES')
                    finish = True
                if finish==True:
                    break
            if finish==True:
                break
        if finish==True:
            break
    if finish==True:
        break
if finish==False:
    print('NO')

            

Measured memory_bytes: 3316