akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            d = C[i][k] + C[k][j]
            if C[i][j] > d:
                C[i][j] = d

cost = [C[d][1] for d in range(10)]

ans = 0
for R in A:
    for a in R:
        if a == -1:
            continue
        ans += cost[a]
print(ans)


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=2e5+100;

int a[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    int x=0;
    for(int i=1;i<=n;i++)
        cin>>a[i],
        x^=a[i];
    for(int i=1;i<=n;i++)
        cout<<(a[i]^x)<<" ";
}


Measured memory_bytes: 5204
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n,a,b,x;

int main()
{
  scanf("%d",&n);
  a = b = 0;
  TC(n)
  {
    scanf("%d",&x);
    if (x % 2 == 1) ++a;
    else ++b;
  }
  if (a%2 + min(1,a/2+b) <= 1) puts("YES");
  else puts("NO");
  return 0;
}










Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int a, b, k;
  scanf("%d%d%d", &a, &b, &k);
  int max = a > b ? a : b;
  int count = 0;
  for (int i = max; i >= 1; i--) {
    if ((!(a % i)) && (!(b % i))) count++;
    if (count == k) {
      printf("%d", i);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int64 n,ans=0;
  cin>>n;
  rep1(i,sqrt(n)+1){
    if(n%i==0){
      int64 x=n/i;
      if(x>=1+sqrt(n+1)){
        ans+=x-1;
      }
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include<cstdio>
#define ll long long 
 
const int N=1e7+7;
int b[N];
int n,t;
 
int main()
{
	ll x;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&x);
		b[x%N]++;
	}
	scanf("%d",&t); if(t>n){printf("NO"); return 0;}
	for(int i=1;i<=t;i++){
		scanf("%lld",&x); x=x%N;
		b[x]--;
		if(b[x]<0){
			printf("NO"); return 0;
		}
	}
	printf("YES");
	return 0;
}

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

using namespace std;

int main(){
    char c;
    cin >> c;

    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  int b,e;
  int tb,te;
  int count = 0;
  cin >> n >> m;
  tb = 1;
  te = n;
  vector<int> data(n);
  //for (int i = 0; i < n; i++) {
  //  data.at(i) = i + 1;
  //}
  for (int i = 0; i < m; i++) {
    cin >> b >> e;
    if (b > tb) {
      tb = b;
    }
    if (e < te) {
      te = e;
    }
    //vector<int> in(n);
    //for (int i = 0; i < e; i++) {
    //  in.at(b - 1) = b;
    //  if (b == e) {
    //    break;
    //  }
    //  b++;
    //}
  }
  for (int i = tb; i <= te ; i++) {
      data.at(i - 1) = i;
      //if (in.at(i) == 0) {
      //  data.at(i) = 0;
      //}
  }
  for (int x : data) {
    if (x) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 640
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))


from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys

# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *


def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1 / f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret


def bunsu(n):
    ret = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            tmp = 0
            while (True):
                if n % i == 0:
                    tmp += 1
                    n //= i
                else:
                    break
            ret.append((i, tmp))

    ret.append((n, 1))
    return ret


def solve():
    n = getN()
    nums = []
    for i in range(n):
        nums.append(getList())

    if n % 2 == 1:
        nums.sort()
        med = nums[(n + 1) // 2 - 1][0]
        nums.sort(key=lambda x: x[1])
        medhigh = nums[(n + 1) // 2 - 1][1]

        print(medhigh - med + 1)
    else:
        nums.sort()
        med = (nums[n // 2 - 1][0] + nums[n // 2][0]) / 2
        nums.sort(key=lambda x: x[1])
        medhigh = (nums[n // 2 - 1][1] + nums[n // 2][1]) / 2
        # print(medhigh, med)
        print(int((medhigh - med) * 2) + 1)


def main():
    # n = getN()
    # for _ in range(n):
    solve()


if __name__ == "__main__":
    solve()

Measured memory_bytes: 116592
#E A, B, C = gets.chomp.split.map(&:to_i)
N = gets.chomp.to_i

r = 0
1.upto(N).each do |i|
  s = i.to_s
  if (s.size % 2) == 1
    # p i
    # p s.size
    r += 1
  end
end

p r

Measured memory_bytes: 1788
#include <stdio.h>


int main(void){
int a,b;
int coin=0;
int i;

scanf("%d",&a);
scanf("%d",&b);

for(i=0;i<2;i++){
if(a>=b){coin=coin+a; a--;}
else if(b>a){coin=coin+b; b--;}
}
printf("%d",coin);
  return 0;
}

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

vector<int> pre, in, post;
int position = 0;

void reconstruction(int left, int right) {
  if (left >= right) return;
  int root = pre[position];
  position++;
  int in_pos = distance(in.begin(), find(in.begin(), in.end(), root));
  reconstruction(left, in_pos);
  reconstruction(in_pos + 1, right);
  post.push_back(root);
}

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

  int n;
  cin >> n;

  int id;
  for (int i = 0; i < n; i++) {
    cin >> id;
    pre.push_back(id);
  }
  for (int i = 0; i < n; i++) {
    cin >> id;
    in.push_back(id);
  }

  reconstruction(0, n);

  for (int i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << post[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),m = sc.nextInt();
		int a = 0;
		int[] mkind = new int[m+1];
		for(int i = 0;i < n;i ++) {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		}
		//System.out.println(Arrays.toString(mkind));
		int sum = 0;
		for(int i = 0;i < m+1;i ++) {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
int a[7],b[7];
int degree[7];
int main(){
    long long k,a,b;
    scanf("%lld%lld%lld",&k,&a,&b);
    long long ans=0;
    if(a>=b-1){
        ans=k+1;
    }
    else{
        long long x=k-a;
        if(x>0){
            ans+=b;
            k-=a+1;
        }
        else
            ans=k+1,k=0;
        x=0;
        x=k/2;
        long long y=k&1;
        ans+=x*(b-a);
        ans+=y;
    }
    printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

static const int N = 100;
static const int M = 21000;
static const int INF = N * M + 1;
vector<P> adj[N];
int a[M], b[M], c[M];
int n, mat[N][N], p[N][N];

void dijkstra(int s){
    bool reached[n];
    priority_queue<P> PQ;
    rep(i, n){
        reached[i] = false;
        mat[s][i] = INF;
    }
    mat[s][s] = 0;
    p[s][s] = -1;
    PQ.push(make_pair(-mat[s][s], s));

    while(!PQ.empty()){
        P f = PQ.top(); PQ.pop();
        int u = f.second;
        reached[u] = true;
        if(-f.first > mat[s][u]) continue;

        rep(i, adj[u].size()){
            int v = adj[u][i].first;
            if(reached[v]) continue;
            if(mat[s][u] + adj[u][i].second < mat[s][v]){
                mat[s][v] = mat[s][u] + adj[u][i].second;
                p[s][v] = u;
                PQ.push(make_pair(-mat[s][v], v));
            }
        }
    }
    return;
}

int main(){
    int m;
    cin >> n >> m;
    rep(i, m){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
        adj[a[i]].push_back(make_pair(b[i], c[i]));
        adj[b[i]].push_back(make_pair(a[i], c[i]));
    }

    rep(i, n) dijkstra(i);

    int ans = m;
    rep(i, m){
        bool used = false;
        rep(j, n){
            //if(mat[j][a[i]] + c[i] == mat[j][b[i]]) used = true;
            if(p[j][a[i]] == b[i] || p[j][b[i]] == a[i]) used = true;
        }
        if(used) ans--;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    long long fib[50];
    fib[0] = fib[1] = 1;
    for (int i = 2; i < 50; ++i) {
        fib[i] = fib[i - 1] + fib[i - 2];
    }
    int n;
    cin >> n;
    cout << fib[n] << "\n";
    return 0;
}

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

using namespace std;

const int MX = 3002, md = 998244353;

int dp[MX][MX], s[MX][MX], p[MX][MX], q[MX][MX], inv[MX];

int main() {
	inv[1] = 1;
	for (int i = 2; i < MX; i++) {
		inv[i] = md - inv[md % i] * 1LL * (md / i) % md;
	}
	
	for (int i = 0; i < MX; i++) {
		p[i][0] = 1;
		q[i][0] = 1;
		for (int j = 1; j < MX; j++) {
			p[i][j] = p[i][j - 1] * 1LL * i % md;
			q[i][j] = q[i][j - 1] * 1LL * inv[i] % md;
		}
	}
	
	int a, b, c, d;
	ignore = scanf("%d %d %d %d", &a, &b, &c, &d);
	
	dp[c][d] = 1;
	s[c][d] = p[d - 1][c];
	for (int x = c - 1; x > 0; x--) {
		dp[x][d] = dp[x + 1][d] * 1LL * d % md;
		s[x][d] = (s[x + 1][d] + dp[x][d] * 1LL * p[d - 1][x]) % md;
	}
	
	for (int y = d - 1; y > 0; y--)
		for (int x = c; x > 0; x--) {
			dp[x][y] = (dp[x][y + 1] * 1LL * x + s[x + 1][y + 1] * 1LL * q[y][x]) % md;
			s[x][y] = (s[x + 1][y] + dp[x][y] * 1LL * p[y - 1][x]) % md;
		}
	
	printf("%d\n", dp[a][b]);
	
	return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;
const ll MOD = 924844033;

// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}

// 逆元を求める
ll modinv(ll n){
	return modpow( n, MOD-2 );
}

// 階乗を求める。O(1)  準備O( n*log(n) )
// fact[n]     : nの階乗
// fact.inv[n] : nの階乗の逆元
class FACTORIAL{
public:
	vector<ll> fact, inv;
	FACTORIAL(int MAX_NUM): fact(MAX_NUM), inv(MAX_NUM) {
		fact[0] = inv[0] = 1;
		for(ll i=1; i<MAX_NUM; i++){
			fact[i] = (fact[i-1] * i) % MOD;
			inv[i] = modinv( fact[i] );
		}
	}
	const ll& operator [ ] ( const int i ) const {
		return fact[i];
	}
} fact(10006); // nの最大値を指定


// 組み合わせ(Combinationを求める) O(1)
ll cmb(unsigned int n, unsigned int r){
	if( n < r ) return 0;
	return fact[n] * fact.inv[r] % MOD * fact.inv[n-r] % MOD;
}


ll dp[2005][2005] = {};
ll dp2[4005][4005] = {};
int main(){
	//ios_base::sync_with_stdio(false);
	ll N, K, ans=0;

	cin >> N >> K;

	dp[0][0] = 1;
	rep(i,N+1) rep(j,N+1){
		dp[i][j] %= MOD;
		dp[i+2][j+1] += dp[i][j];
		dp[i+1][j+0] += dp[i][j];
	}
	// rep(i,2*N){
	// 	rep(j,2*N) cout << dp[i][j] << " ";
	// 	cout << endl;
	// }

	dp2[0][0] = 1;
	rep(i,2*K){
		rep(j,2*N) dp2[i+1][j] += dp2[i][j];
		rep(j,N){
			//int m = (N - 1 - i) / K;
			int m = (N - 1 - i) / K;
			if( i >= K ) m = (N - 1 - i + K) / K;
			reps(k,1,m+1){
				dp2[i+1][j+k] += dp2[i][j] * dp[m+1][k];
				dp2[i+1][j+k] %= MOD;
			}
		}
	}
	//rep(i,N+N) cout << dp2[2*K][i] << ", ";
	//cout << endl;

	rep(i,N+2){
		ans += MOD;
		ans += dp2[2*K][i] * (i%2 ? -1 : +1) * fact[N - i];
		ans %= MOD;
		//cout << i << " : " << dp2[2*K][i] * (i%2 ? -1 : +1) * fact[N - i] << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 157056
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long           ll;
typedef pair<ll, ll>        P;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
const ll                    INF = 2e9;
const ll                    INF_LL = 1LL<<60;
const ll                    MOD = 1e9 + 7;
namespace {
	ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
	ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
	ll FloorN(ll x, ll n)     { return (x - x % n); }
	bool IsOdd(ll x)          { return ((x & 1) == 1); }
	bool IsEven(ll x)         { return ((x & 1) == 0); }
	template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
	template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
};

// 処理
void Solve()
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;

	ll ans = min(K, A);
	K -= A;
	if (0 < K) {
		K -= B;
		if (0 < K) {
			ans -= K;		
		}
	}

	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#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;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  string s;cin>>s;
  s.erase(unique(all(s)),s.end());
  cout<<s.size()<<endl;
  return 0;

}


Measured memory_bytes: 512
<?php 
    fscanf(STDIN, "%s", $s);
    fscanf(STDIN, "%s", $t);

    $roop_times = strlen($s);

    $array_s = str_split($s);
    $array_t = str_split($t);

    if($s == $t) {
        echo 0;
        exit;
    }

    $count = 0;
    for($i=0; $i<=$roop_times; $i++) {
        if($s[$i] == $t[$i]){
        } else {
            $count += 1;
        }
    }

    echo $count;


Measured memory_bytes: 41452
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val N,T= sc.nextInt
  val list = (1 to N).map(i=>(sc.nextInt,sc.nextInt)).filter(i=>i._2<=T)
  val ans = if(list == Nil){"TLE"}else{list.map(i=>i._1).min}
  println(ans)
}



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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  ll n,a,b; cin >> n >> a >> b;
  ll ans = 0;
  vector<ll> x(n);
  rep(i,n){
    cin >> x[i];
  }

  rep(i,n-1){
    if( (x[i + 1] - x[i]) * a < b) ans += (x[i + 1] - x[i]) * a;
    else ans += b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;

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

    ll N, M;//N頂点M個のクエリ
    cin >> N >> M;
    vector <int> g(N);

    REP(i,M)
    {
        int a,b;
        cin >> a >> b;
        --a;--b;
        ++g[a];
        ++g[b];
    }

    string res = "YES";

    REP(i,N)
    {
        if(g[i] % 2 == 1)
        {
            res = "NO";
            break;
        }
    }

    cout << res << endl;



    return 0;    
}


Measured memory_bytes: 640
L, R = map(int, input().split())
a = 2020

for i in range(L,R+1):
    for j in range(i+1,R+1):
        ans = i*j%2019
        if(a > ans):
            a = ans
        if ans == 0:
            print(a)
            exit(0)
print(a)


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

int main () {
  int N,M;
  cin >> N >> M;
  vector<pair<int,int> > C;
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    C.push_back({A,B});
  }
  sort(C.begin(), C.end());
  int i = 0;
  int64_t ans = 0;
  while (M && i < N) {
    if (C[i].second == 0) {
      i++;
    }
    else {
      ans += C[i].first;
      C[i].second--;
      M--;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4244
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 int n , m;
 cin >> n >> m;
 int a;
 int sum = 0;
 for(int i = 0; i < m;i++){
     cin >> a;
     sum += a;
 }
 if(n - sum >= 0)cout << n - sum << endl;
 else cout << - 1 << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int ka[1145140],inv[1145140];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int res = 1;
	while(k>0){
		if(k%2)res = (res*x)%inf;
		x = (x*x)%inf;
		k >>=1;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if( k<0 || n<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
signed main(){
	int n;
	cin>>n;
	setkaijo(1114514);
	setinv(1114514);
	int mi = n/2 + n%2;
	int ma = n-1;
	int ans = 0;
	int sum = 0;
	for(int i = mi; i<= ma;i++){
		int tmp = 1;
		tmp *= comb( i-1, n-i-1 );
		tmp *= ka[i]; tmp %= inf;
		tmp *= ka[n-1-i]; tmp %= inf;
		tmp += inf-sum; tmp %= inf;
		ans += tmp * i; ans %= inf;
		sum += tmp; sum %= inf;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
	ll n;
	cin>>n;
	if(n%7==0)
		n/=7;
	ll x=0;
	for(int i=1;i<=n;++i)
	{
		x+=power(10,i-1,n);
		x%=n;
		if(!x)
		{
			cout<<i;return 0;
		}
	}
	cout<<-1;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	return 0;
}

Measured memory_bytes: 3624
from math import sqrt

pf={}
m=int(input())
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1

ans =0
for value in pf.values():
    ans += int((sqrt(value*8+1)-1)/2)
print(ans)

Measured memory_bytes: 9384
#include<stdio.h>
	int main(void)
{
	int S, s, h, m, temp;
	scanf("%d", &S);
	h = S / 3600;
	S = S - 3600 * h;
	m = S / 60;
	S = S - 60 * m;
	s = S;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }



int main() {
    int n; cin >> n;
    set<string> st;
    rep(i, n) {
        string s; cin >> s;
        st.insert(s);
    }

    cout << st.size() << endl;


    return 0;
}

Measured memory_bytes: 19180
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 1;
	for (int i = 1; i < n; i++) {
		ans += a[i] >= a[i - 1];
		a[i] = max(a[i], a[i - 1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=200005;
#define M 1000000007
#define double long double
#define BINF 10000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 5000004
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;



#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);
 



    int n;
    cin >> n;
    int ans = 0;
    ans = (n / 500) * 1000;
    n -= (n / 500) * 500;
    ans += (n / 5) * 5;
    cout << ans << endl;
    
    





return 0;  
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 2 * 105000;

class SegmentTree {
private: 
  const long long INF = 1e18;
  vector<long long> tree;
  int n;
public:
  void init(int sz) {
    n = 1;
    while (n < sz) {
      n *= 2;
    }
    tree.resize(2 * n, -INF);
  }

  // l, r are in [0, n - 1]
  long long getMax(int l, int r) {
    l = n + l; r = n + r;
    long long res = -INF;
    
    while (l <= r) {
      if (l & 1) {
        res = max(res, tree[l]);
        l++;
      }
      if (r % 2 == 0) {
        res = max(res, tree[r]);
        r--;
      }
      l /= 2; r /= 2;
    }

    return res;
  }

  // pos is in [0, n - 1]
  void update(int pos, long long val) {
    pos = n + pos;
    tree[pos] = val;
    pos /= 2;
    while (pos >= 1) {
      tree[pos] = max(tree[pos * 2], tree[pos * 2 + 1]);
      pos /= 2;
    }
  }
};

int n;
int h[MAXN];
int a[MAXN];
long long ans;
SegmentTree tree;

int main() { 

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  tree.init(n);

  for (int i = 0; i < n; i++) {
    long long cur = a[i];
    if (h[i] > 1) {
      long long mx = tree.getMax(0, h[i] - 2);
      if (mx >= 0) {
        cur += mx;
      }
    }
    ans = max(ans, cur);
    tree.update(h[i] - 1, cur);
  }

  cout << ans << endl;

  return 0;
}


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

bool is_prime(int n)
{
  if (n == 1) return false;
  if (n == 2) return true;
  if (n%2 == 0) return false;
  for (int i = 3; i*i <= n; i += 2) {
    if (n%i == 0)
      return false;
  }
  return true;
}

int main()
{
  int n, cnt;
  cin >> n;
  cnt = 0;
  for (int i = 0; i < n; i++) {
    int k; cin >> k;
    if (is_prime(k))
    cnt++;
  }
  cout << cnt << endl;
  return EXIT_SUCCESS;
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	string s; int t, a=0, b=0, c=0, d=0;
	cin>>t;
	while(t--){
		cin>>s;
		if(s=="AC") a++;
		if(s=="WA") b++;
		if(s=="TLE")c++;
		if( s=="RE") d++;
	}
	printf("AC x %d\n",a);
	printf("WA x %d\n",b);
	printf("TLE x %d\n",c);
	printf("RE x %d\n",d);
	
	return 0;
}


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

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

typedef long long ll;

void solve(){
	int x;
	cin>>x;
	if(x>=30)cout<<"Yes";
	else cout<<"No";
}

int main(){
	Red;
	int T=1;
	//cin>>T;
	while(T--)solve();
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<pair<int, int> > p(n);
  REP(i,n){
    int temp1,temp2;
    cin>>temp1>>temp2;
    p[i]=make_pair(temp2,temp1);
  }
  sort(p.begin(),p.end());
  int count=0;
  REP(i,n){
    count+=p[i].second;
    if(count>p[i].first){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

double nCr(const int n, int r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return(result);
}


int main(int argc, char *argv[]){
  int N;
  cin>>N;
  vector<string> S(N+1,"");
  map<string,long long> mp;
  for(int i=1; i<N+1; i++){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    auto itr=mp.find(s);
    if(itr!=mp.end()){
      mp[s]++;
    }
    else{
      mp[s]=1;
    }
    //cout<<mp[s]<<endl;
  }
  long long count=0;
  for(auto itr=mp.begin(); itr!=mp.end(); itr++){
    if(itr->second != 1){
      count+=nCr(itr->second,2);
    }
  }
  cout<<count<<endl;


}
  
  


Measured memory_bytes: 11904
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <stdlib.h>

using namespace std;

int main (void)
{
	int a,b,c,d,p,x,y;

	cin >> a >> b >> c >> d >> p;

	x = a * p;

	if (p <= c)
	{
		y = b;
	}
	else if (p > c)
	{
		y = b + ((p - c) * d);
	}

	if (x <= y)
	{
		cout << x << endl;
	}
	else
	{
		cout << y << endl;
	}
}

Measured memory_bytes: 3096
#include<iostream>
#include<vector>
using namespace std;

int main(void){
  char b;
  cin>>b;
  if(b=='A') cout<<"T"<<endl;
  else if(b=='T') cout<<"A"<<endl;
  else if(b=='C') cout<<"G"<<endl;
  else if(b=='G') cout<<"C"<<endl;
  return 0;
}

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

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a + 2), t(b + 2), x(q);
    s[0] = -INF, s[a + 1] = INF;
    t[0] = -INF, t[b + 1] = INF;
    rep(i, 1, a + 1) cin >> s[i];
    rep(i, 1, b + 1) cin >> t[i];
    rep(i, 0, q) cin >> x[i];

    rep(i, 0, q) {
        ll tmp1 = lower_bound(all(s), x[i]) - s.begin();
        ll left_s = s[tmp1 - 1];
        ll right_s = s[tmp1];

        ll tmp2 = lower_bound(all(t), x[i]) - t.begin();
        ll left_t = t[tmp2 - 1];
        ll right_t = t[tmp2];

        ll p1 = abs(x[i] - left_s) + min(abs(left_s - left_t), abs(left_s - right_t));
        ll p2 = abs(x[i] - left_t) + min(abs(left_t - left_s), abs(left_t - right_s));
        ll p3 = abs(x[i] - right_s) + min(abs(right_s - right_t), abs(right_s - left_t));
        ll p4 = abs(x[i] - right_t) + min(abs(right_t - right_s), abs(right_t - left_s));

        cout << min({p1, p2, p3, p4}) << endl;
    }
    return 0;
}


Measured memory_bytes: 3712
import statistics
import math

N = int(input())
A = list(map(int, input().split(" ")))
A_i = [0]*N
K_1 = 0
K_2 = 0
K_3 = 0


for i in range(N):
    A_i[i] = A[i] - i - 1

try:
    b_1 = statistics.mode(A_i)
except:
    b_1 = int(statistics.mean(A_i))

b_2= int(statistics.mean(A_i))
b_3 = int(statistics.median(A_i))

for i in range(N):
    K_1 = K_1 + abs(A_i[i] - b_1)
    K_2 = K_2 + abs(A_i[i] - b_2)
    K_3 = K_3 + abs(A_i[i] - b_3)

print(min(K_1, K_2, K_3))

Measured memory_bytes: 49260
H, W = map(int, input().split())
ls = []

for i in range(H):
    ls.append([i if i == '#' else 0 for i in input().split()[0]])

for i in range(H):
    for j in range(W):
        if ls[i][j] == '#':
            ii_min = i if (i - 1) < 0 else i - 1
            ii_max = i if (i + 1) >= H else i + 1
            jj_min = j if (j - 1) < 0 else j - 1
            jj_max = j if (j + 1) >= W else j + 1

            for ii in range(ii_min, ii_max + 1):
                for jj in range(jj_min, jj_max + 1):
                    if ls[ii][jj] != '#':
                        ls[ii][jj] += 1

for i in range(H):
    print(''.join(map(str, ls[i])))

Measured memory_bytes: 3064
using System;

class BeautifulStrings
{
	static void Main(String[] args)
	{
		String w = Console.ReadLine();
		int[] count = new int[26];

		foreach(char c in w)
		{
			count[c - 'a']++;
		}

		bool beautiful = true;
		for(int i=0; i<26; i++)
		{
			if(count[i] % 2 == 1)
			{
				beautiful = false;
				break;
			}
		}
		if(beautiful)
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}


Measured memory_bytes: 2648
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{

    class Program
    {
        static void Main(string[] args)
        {
            //素因数分解が必要
            var read = Console.ReadLine();
            long N = long.Parse(read.Split(' ')[0]);
            long P = long.Parse(read.Split(' ')[1]);
            long output = 1;
            if (N == 1)
            {
                Console.WriteLine(P);
                return;
            }
            for (int i = 2; i <= Math.Sqrt(P); i++)
            {
                int wareta = 0;
                while (P % i == 0)
                {
                    wareta++;
                    P = P / i;
                }
                if ((wareta / N) >= 1)
                {
                    output = output * (int)Math.Pow(i, (int)(wareta / N));
                }
            }
            Console.WriteLine(output);
            return;
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <limits>
#include <iostream>
#define int int64_t
using namespace std;
main() {
    int N; cin>>N;
    int min_= numeric_limits<int>::max();
    for(int i=1; i<=5; ++i) {
        int x; cin>>x;
        min_= min(min_, x);
    }
    cout<< (N-1)/min_+5 <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

int main() 
{
	string s;
	getline(cin, s);
	vector<int> stack;
	for(auto ch : s)
	{
		if(ch == '0') 
		{
			stack.push_back(0);
		} 
		else if(ch == '1')
		{
			stack.push_back(1);
		} 
		else if(ch == 'B')
		{
			if(stack.size() > 0) 
			{
				stack.pop_back();
			}
		}
	}
	for(int v : stack)
	{
		cout << v;
	}
	cout << endl;
}

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

	
int main(){
	const int N_MAX = 100000;
	const int BigNumber = 1000000007;	
	long long* RevFactrial = new long long[N_MAX];
	int number[N_MAX], counter[N_MAX];
	int N,R;
	
	RevFactrial[N_MAX-1] = 1;
	for(int i=N_MAX-2; i>=0; i--){
		RevFactrial[i] =  ((long long) RevFactrial[i+1] * (N_MAX -i-1)) % BigNumber;
	}
	while(true){
		cin >> N;
		if(N==0) break;
		cin >> R;
	
		for(int n=0; n<N; n++){
			number[n] = n;
			counter[n] = 0;
		}
		
		for(int r=0; r<R; r++){
			int s, t;
			cin >> s >> t;
			s--; t--;
			int ns = number[s];
			int nt = number[t];
			int cs = counter[t];
			int ct = counter[s];
				
			if(ns<nt)	cs++;
			else		ct--;
			for(int i=s+1; i<t; i++){
				int ni = number[i];
				if(ni < nt){
					cs++;
					if(ns<ni) counter[i]++;
				}
				if(ni < ns){
					ct--;
					if(nt<ni) counter[i]--;
				}
			}

			counter[s] = cs;
			counter[t] = ct;
			number[s] = nt;
			number[t] = ns;
		}

		long long  index = 0;
		for(int i=0; i<N-1; i++){
			index  +=  counter[i]*RevFactrial[N_MAX-N+i]%BigNumber;
		}
		cout << index%BigNumber << endl;
		
	}

	delete[] RevFactrial;
	return 0;
}

Measured memory_bytes: 2584
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main()
{
   cin >> n >> s;
   if( n % 2 )
   {
    cout << "No";
    return 0;
   }
   else
   {
     for( int i = 0; i <= n/2 - 1; i++ )
     {
        if( s[i] != s[i+n/2] )
        {
          cout << "No";
          return 0;
        }
     }
   }
   cout << "Yes";
   return 0;
}


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


void solve(long long A, long long B, long long C, long long X){
    int count = 0;
    for(long long a = 0; a <= A; ++a){
        for(long long b = 0; b <= B; ++b){
            for(long long c = 0; c <= C; ++c){
                if(500 * a + 100 * b + 50 * c == X) count++;
            }
        }
    }
    cout << count << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long X;
    scanf("%lld",&X);
    solve(A, B, C, X);
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] count = new int[N];
    for (int i = 0; i < M; i ++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      
      count[a] ++;
      count[b] ++;
    }
    
    for (int v : count) {
      System.out.println(v);
    }
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 23124
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    public static void process(int test_number)throws IOException
    {
        int n = ni();
        long arr[] = new long[n];
        for(int i = 0; i < n; i++)
            arr[i] = nl();

        long res = 0l;
        for(int i = 0; i < n - 2; i++){
            for(int j = i + 1; j < n - 1; j++){
                for(int k = j+ 1; k < n; k++){
                    if(arr[i] == arr[j] || arr[i] == arr[k] || arr[j] == arr[k])
                        continue;

                    if(arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] 
                        && arr[j] + arr[k] > arr[i])
                        res++;
                }
            }
        }
        pn(res);
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 36952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int A[N]{};
    for (int i = 1; i < N; i++) {
        cin >> A[i];
    }
    int b[N]{};
    for (int i = 1; i < N; i++) {
        b[A[i] - 1]++;
    }
    for (int i : b) {
        cout << i << "\n";
    }
    return 0;
}

Measured memory_bytes: 5192
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1505;
const int MOD=998244353;
int n;
char s[N][N];
struct Graph
{
	int n;
	int G[N][N];
	int fa[N];
	int d[N];
	int getf(int v)
	{
		if(v==fa[v]) return v;
		fa[v]=getf(fa[v]);
		return fa[v];
	}
	bool merge(int u,int v)
	{
		int f1=getf(u),f2=getf(v);
		if(f1!=f2)
		{
			fa[f2]=f1;
			d[f1]+=d[f2];
			d[f2]=0;
			return true;
		}
		else return false;
	}
	void init(int _n)
	{
		n=_n;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				G[i][j]=-1;
		for(int i=1;i<=n;i++)
			fa[i]=i,d[i]=0;
		return;
	}
	bool add(int u,int v,int w)
	{
		if(w==-1) return true;
		if(G[u][v]!=-1) return G[u][v]==w;
		else
		{
			G[u][v]=G[v][u]=w;
			return true;
		}
	}
	long long solve()
	{
		int tot=0;
		for(int u=1;u<=n;u++)
			for(int v=u+1;v<=n;v++)
				if(G[u][v]==-1) tot++;
				else d[u]+=G[u][v],d[v]+=G[u][v];
		if(n%2==0)
		{
			long long ans=1;
			for(int i=1;i<=tot;i++)
				ans=ans*2%MOD;
			return ans;
		}
		for(int u=1;u<=n;u++)
			for(int v=u+1;v<=n;v++)
				if(G[u][v]==-1)
				{
					if(merge(u,v)) tot--;
				}
		for(int i=1;i<=n;i++)
			if(getf(i)==i&&d[i]%2==1) return 0;
		long long ans=1;
		for(int i=1;i<=tot;i++)
			ans=ans*2%MOD;
		return ans;
	}
};
Graph g[2];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
		scanf("%s",s[i]+1);
	g[0].init(n/2+1),g[1].init((n+1)/2);
	for(int i=1;i<n;i++)
		for(int j=1;j<n;j++)
		{
			int x=(s[i][j]=='o'?1:(s[i][j]=='x'?0:-1));
			int u=(min(i+j,n-i+n-j)/2)+1,v=(max(i-j,j-i)/2)+1;
			if(!g[(i+j)&1].add(u,v,x))
			{
				printf("0");
				return 0;
			}
		}
	printf("%lld",g[0].solve()*g[1].solve()%MOD);
	return 0;
}

Measured memory_bytes: 14916
import sys
import math
import collections

def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin


def int_input():
    return list(map(int, input().split()))


def get(s):
    return str(s % 9) + '9' * (s // 9)

if __name__ == '__main__':
    # set_debug(True)

    # t = int(input())
    t = 1

    for ti in range(1, t + 1):
        n, k = int_input()
        A = int_input()

        A.sort()

        print(sum(A[:k]))


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

#define rep(i,a,b) for(long long i = a; i < b; i++)
#define dump(a) for(auto x : a) cout << x << " "; cout << "\n"
#define print(a) cout << a << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr << #x << ": " << x << ", " << #y << ": " << y << "\n"
#define debug3(x,y,z) std::cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << "\n"

typedef long long ll;
using vi   = vector<int>;
using vll  = vector<long long>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvs  = vector<vector<string>>;

int main() {
  int n;
  cin >> n;
  ll a[n];rep(i,0,n) cin >> a[i];
  ll dai = 0;
  rep(i,1,n) {
    if(a[i - 1] > a[i])  {
      ll tmp = a[i - 1] - a[i];
      dai += tmp;
      a[i] += tmp;
    }
  }
  print(dai);
  return 0;
}

Measured memory_bytes: 5184