akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i) ++)

using namespace std;

int main() {
  int n, a[110], b[110];
  cin >> n;
  rep(i, 0, n) {
    cin >> a[i] >> b[i];
  }

  int dp[110][110];
  rep(i, 0, 110) {
    rep(j, 0, 110) {
      dp[i][j] = 2<<29;
    }
  }

  for(int len = 1; len <= n; len ++) {
    if(len == 1) {
      for(int p = 0; p < n; p ++) {
	dp[p][p+1] = 0;
      }
    }
    else {
      for(int p = 0; p <= n; p ++) {
	int r = p + len;
	if(r > n) continue;

	for(int q = p + 1; q < r; q ++) {
	  dp[p][r] = min(dp[p][r], dp[p][q] + dp[q][r] + a[p]*b[q-1]*a[q]*b[r-1]);
	}
      }
    }
  }

  cout << dp[0][n] << endl;

  return 0;
}

Measured memory_bytes: 1204
N, K = [int(i) for i in input().split()]
R, S, P = [int(i) for i in input().split()]
T = input()

outputs = ""
score = 0

for i in range(N):
    if (i >= K) and (T[i - K] == T[i]) and (outputs[i - K] == "w"):
        score += 0
        outputs += "l"
        continue

    if T[i] == "r":
        score += P
        outputs += "w"
    elif T[i] == "s":
        score += R
        outputs += "w"
    elif T[i] == "p":
        score += S
        outputs += "w"
    

print(score)


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=100010;
namespace G{
	const int E=400010;
	int to[E],bro[E],head[N],e=0;
	int col[N];
	inline void init(){
		memset(head,-1,sizeof(head));
		memset(col,-1,sizeof(col));
	}
	inline void ae(int u,int v){
		to[e]=v,bro[e]=head[u],head[u]=e++;
	}
	inline void add(int u,int v){
		ae(u,v),ae(v,u);
	}
	int pcnt[2];
	bool dfs(int x,bool c){
		if(~col[x])return col[x]!=c;
		pcnt[col[x]=c]++;
		bool flag=false;
		for(int i=head[x];~i;i=bro[i]){
			flag|=dfs(to[i],!c);
		}
		return flag;
	}
}
int main(){
	int n=ni;
	G::init();
	for(int tot=ni;tot--;G::add(ni,ni));
	lint sing=0,bi=0,whole=0;
	for(int i=1;i<=n;i++){
		using namespace G;
		if(col[i]==-1){
			pcnt[0]=pcnt[1]=0;
			if(dfs(i,0)){
				whole++;
			}else if(pcnt[1]==0){
				assert(pcnt[0]==1);
				sing++;
			}else{
				bi++;
			}
		}
	}
	lint ans=sing*sing+sing*(n-sing)*2+bi*bi*2+whole*whole+bi*whole*2;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6016
using System;

public class Hello{
    public static void Main(){
        var input = Console.ReadLine();
        var n = input.Length;
        bool flag = true;
        
        for(var i = 0;i <  n / 2;i++){
            if(input[i] != input[n-i -1]|| input[i] != input[n/2 -1 -i] || input[i] != input[n/2 +1 + i])
            {
                flag= false;
                break;
            }
        }
        
        Console.WriteLine(flag?"Yes":"No");
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#define ALL(X) X.begin(), X.end()
#define SZ(A) int((A).size())
#define RALL(X) X.rbegin(), X.rend()
#define FOR(B) for (size_t i = 0; i < B; i++)
#define FOR2(B) for (size_t j = 0; j < B; j++)
#define FORE(B) for (size_t i = 1; i <= B-1; i++)
#define FORC(A, B) for (size_t i = A; i < B; i++)
#define PRINT(X) cout << X << endl
#define PRINTALL(E, X) { FOR(X) {cout << E[i] << endl; } }
#define PRINTSIDE(E, X) { FOR(X) {cout << E[i] << " ";} }
#define READALLI(V, N) FOR(N) {int x; cin >> x; V.push_back(x); }
#define READALL(V, N) FOR(N) {LL x; cin >> x; V.push_back(x); }
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXN 100000
#define SQRSIZE  317
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<LL>VL;
typedef vector<PII> VPII;
typedef map<int, int> MII;
typedef map<char, int>MCI;
typedef map<string, int> MSI;
typedef set<int> SI;
const int INF = (1 << 30);


int main() {

    int num = 0;
    cin >> num;
    int multi = num;
   while(multi >= 10){
       multi /= 10;

   }
    if(111 * multi >= num){
        cout << 111 * multi;
    }else{
        cout << 111 * (multi + 1);
    }
    cout << endl;
    return 0;
}






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

int main(){
  int A, B;
  cin >> A >> B;

  int ans = 0;
  for(int i = A; i <= B; i++){
    string num_f = to_string(i);
    string num_b = num_f;
    reverse(num_b.begin(), num_b.end());
    if(num_f == num_b){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		int count;

		while(true){
			count = 0;
			n = sc.nextInt();
			if(n == 0){
				break;
			}
			for(int i=0;i<n/4;i++){
				count += sc.nextInt();
			}

			System.out.println(count);
		}
	}

}

Measured memory_bytes: 0
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := iScan()
	a := int(math.Ceil(math.Pow(float64(s), 0.5)))
	s = a*a - s
	b, c := 1, 0
	if s != 0 {
		for i := int(math.Ceil(math.Pow(float64(s), 0.5))); ; i-- {
			if s%i == 0 {
				b, c = i, s/i
				break
			}
		}
	}
	fmt.Println(0, 0, a, b, c, a)
}


Measured memory_bytes: 1780
import numpy as np

n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())) + [0]*(k+1))
dp = np.array([0] * n)

for i in range(1, n):
    s = max(0, i-k)
    dp[i] = min(dp[s:i] + abs(h[i] - h[s:i]))

print(dp[n-1])

Measured memory_bytes: 22840
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b))?(b):(a))
#define chmin(a, b) a = (((a)<(b))?(a):(b))

const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}



signed main(){
  int n,k; cin>>n>>k;
  VL a(n),memo(n);
  rep(i,n){
    cin>>a[i]; memo[i]=0;
  }


  // int idx;
  // if(k<=n-k) idx=n-k-1;
  // else idx = n-k+1;
  // memo[idx] = 1;
  //

  memo[n-k] = 1;
  for(int i=n-k-1; i>=0; i--){
    memo[i] = (memo[i+1]*(n-1-i))%MOD;
    memo[i] *= mpow(n-i-k,MOD-2);
    memo[i] = (memo[i]+MOD)%MOD;
  }

  // // memo[n-k-1] = 1;
  // for(int i=idx+1; i<=n-1; i++){
  //   memo[i] = (memo[i-1]*i)%MOD;
  //   memo[i] *= mpow(i-(k-1),MOD-2);
  //   memo[i] = (memo[i]+MOD)%MOD;
  // }
  // rep(i,n){
  //   cerr << memo[i] << endl;
  // }

  ll big = 0, small = 0;
  sort(ALL(a));
  rep(i,n-k+1){
    small += (a[i]*memo[i])%MOD;
    small %= MOD;
  }
  sort(RALL(a));
  rep(i,n-k+1){
    big += (a[i]*memo[i])%MOD;
    big %= MOD;
  }
  //
  //
  //
  // rep(i,n-k+1){
  //   big += (a[n-1-i]*memo[n-1-i])%MOD;
  //   big %= MOD;
  //   small += (a[i]*memo[n-1-i])%MOD;
  //   small %= MOD;
  //   cerr << big SP small << endl;
  // }
  ll ans = (big-small+2*MOD)%MOD;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1792
#include "cstdio"
int n,k,x,s,i;
int min(int x,int y){
	return x<y?x:y;
}
int main(){
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++){
		scanf("%d",&x);s+=min(x,k-x);
	}
	printf("%d\n",s<<1);
}

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

vector<int> c={1,6,36,216,1296,
               7776,46656,9,81,729,
               6561,59049};

int main(){
  int n;
  cin>>n;
  vector<int> dp(n+1,100);
  dp[0]=0;
  rep(i,n){
    rep(j,12){
      if(i+c[j]>n) continue;
      dp[i+c[j]]=min(dp[i+c[j]],dp[i]+1);
    }
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define plaese return
constexpr auto AC = 0;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> dp(n+1, vector<int>(3)),a(n,vector<int>(3));
	rep(i, n) {
		rep(j, 3) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		rep(j, 3) {
			rep(k, 3) {
				if (k != j) {
					dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i-1][j]);
				}
			}
		}
	}
	int ans = 0;
	rep(i, 3) {
		ans = max(ans, dp[n][i]);
	}
	cout << ans << endl;
	plaese AC;
}

Measured memory_bytes: 11136
v, e = map(int, input().split())
g = [[] for _ in range(v)]
dp = [[float("inf")] * v for _ in range(v)]
for i in range(v):
    dp[i][i] = 0
for i in range(e):
    s, t, d = map(int, input().split())
    #g[s].append((d, t))#(重み, 次の頂点)
    dp[s][t] = d

for k in range(v):
    for i in range(v):
        for j in range(v):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
            if i == j and dp[i][j] < 0:
                print("NEGATIVE CYCLE")
                exit()

for i in range(v):
    for j in range(v):
        if j == v - 1:
            if dp[i][j] == float("inf"):
                print("INF")
            else:
                print(dp[i][j])
        else:
            if dp[i][j] == float("inf"):
                print("INF", end = " ")
            else:
                print(dp[i][j], end = " ")



Measured memory_bytes: 6292
//C
#include <cassert>
#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>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#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>
#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>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N, D;
	cin >> N >> D;
	vector<vector<double>>data(N, vector<double>(D));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			cin >> data[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			double sum = 0;
			for (int k = 0; k < D; k++) {
				sum += pow(data[i][k] - data[j][k], 2);
			}
			sum = sqrt(sum);
			if (sum - floor(sum) == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const int INF = 1e6; 
static const vector<int> dx = {-1,0,0,1}, dy = {0,1,-1,0}; 

queue<vector<int>> que; 
vector<vector<char>> graph; 
vector<vector<int>> dist; 
int H , W ;
int x, y, x_ , y_ ; 
int black_cnt = 0 ; 
vector<int> now; 
//最短経路を探す -> 最短経路意外は全て黒にするのが多分最大値
void bfs(vector<int> pos){
    que.push(pos);
    x = pos[0]; y = pos[1];
    dist[x][y] = 0 ; 
    while(!que.empty()){
        now = que.front(); que.pop(); 
        x = now[0]; y = now[1];
        for(int i = 0 ; i < 4; i++){
            x_ = x + dx[i]; y_ = y + dy[i]; 
            if(x_ < 0 || x_ >= H || y_ < 0 || y_ >= W) continue;
            if(graph[x_][y_] == '#') continue;
            if(dist[x_][y_] != INF) continue;
            dist[x_][y_] = dist[x][y] + 1 ; 
            que.push({x_,y_});

        }
    }

}

int main(){
    cin >> H >> W ; 
    graph.assign(H,vector<char>(W,0));
    dist.assign(H,vector<int>(W,INF));
    for(int i = 0 ; i < H ; i ++){
        for(int j = 0 ; j < W; j ++){
            cin >> graph[i][j] ; 
            if(graph[i][j] == '#') black_cnt++; 
        }
    }
    bfs({0,0});
    if(dist[H-1][W-1] == INF) cout << -1 << endl ; 
    else cout << H * W - 2 - (dist[H-1][W-1] - 1) -black_cnt << endl ; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
typedef struct{
  int parent;
  int left;
  int right;
}node;
 
int degree(node*,int,int);
int depth(node*,int,int);
int height(node*,int,int);
void print_type(node*,int);
#define NIL -1
 
int main(){
  int n,id,frag,count;
  int i,j,k;
  int dep;
 
  node D[25];
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    D[i].parent=-1;
    D[i].left=-1;
    D[i].right=-1;
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&D[id].left,&D[id].right);
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(i==D[j].left){
    D[i].parent=j;
      }
      if(i==D[j].right){
    D[i].parent=j;
      }
    }
  }
   
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,D[i].parent);
    for(j=0,frag=0;j<n;j++){
      if(i==j) continue;
      if(D[i].parent==D[j].parent){
    printf("sibling = %d, ",j);
    ++frag;
    break;
      }
    }
    if(frag==0) printf("sibling = -1, ");
    printf("degree = %d, ",degree(D,n,i));
    printf("depth = %d, ",depth(D,n,i));
    printf("height = %d, ",height(D,n,i));
    print_type(D,i);
  }
 
  return 0;
}
 
int degree(node *D,int n,int i){
  int count=0;
  int j;
  for(j=n-1;j>=0;j--){
    if(i==j) continue;
    if(i==D[j].parent){
      count++;
    }
  }
  return count;
}
 
int depth(node *D,int n,int i){
  int count=0;
  int j;
  for(j=0;j<n;j++){
      if(D[i].parent==j){
    count++;
    i=j;
    j=-1;
      }
  }
   
   
  return count;
}
 
int height(node *D,int n,int i){
  int count=0;
  int h1=0,h2=0;
   
  if(D[i].left!=-1) h1=height(D,n,D[i].left)+1;
  if(D[i].right!=-1) h2=height(D,n,D[i].right)+1;
  if(h1<h2) return h2;
  else return h1;
   
}
 
void print_type(node *D,int i){
    if(D[i].parent==NIL) printf("root\n");
    else if(D[i].left==NIL && D[i].right==NIL) printf("leaf\n");
    else printf("internal node\n");
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)
#define inf (int)(1e18)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

signed main(){
	int N, W, i, j;
	scanf("%lld%lld", &N, &W);
	vector<int> w(N);
	for(i = 0; i < N; i++){
		scanf("%lld", &w[i]);
	}
	sort(w.begin(), w.end());
	vector<vector<int>> dp(N + 1, vector<int>(W + 1, 0));
	dp[N][0] = 1;
	for(i = N - 1; i >= 0; i--){
		for(j = 0; j <= W; j++){
			dp[i][j] = dp[i + 1][j];
			if(w[i] <= j){
				dp[i][j] = MOD(dp[i][j] + dp[i + 1][j - w[i]]);
			}
		}
	}
	int ans = 0;
	for(i = 0; i < N; i++){
		for(j = 0; j <= W; j++){
			if(W - w[i] < j){
				ans = MOD(ans + dp[i + 1][j]);
			}
		}
		W -= w[i];
	}
	if(W >= 0){
		ans = MOD(ans + 1);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 18688
#include<cstdio>
#include<algorithm>
#define  N  110000
using  namespace  std;
int  n,a[N],what[N];
inline  bool  cmp(int  x,int  y){return  a[x]<a[y];}
int  main()
{
	scanf("%d",&n);
	for(int  i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);what[i]=i;
	}
	sort(what+1,what+n+1,cmp);
	for(int  i=1;i<n;i++)printf("%d ",what[i]);
	printf("%d\n",what[n]);
	return  0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};



int main(){

  int n,m;
  cin >> n >> m;
  ll res = 0,acc = 0;
  vector<Pl> v;
  REP(i,n){
    ll x,y;cin >> x >> y;
    v.push_back(make_pair(x,y));
  }
  sort(ALL(v));
  for(ll i = 0;i < n;i++){
    for(ll j = 0;j < v[i].second;j++){
      if(acc >= m)break;
      acc++;
      res += v[i].first;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 2420
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/05/20 20:45:24
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w,k; cin>>h>>w>>k;
  vector<string> grid(h);
  for (int i = 0; i < h; i++)
    cin>>grid[i];

  int ans = 0;
  for (int hmask = 0; hmask < (1<<h); hmask++) {
    for (int wmask = 0; wmask < (1<<w); wmask++) {
      int cnt = 0;
      for (int i = 0; i < h; i++) {
        if ((1u<<i) & hmask)
          continue;
        for (int j = 0; j < w; j++) {
          if ((1u<<j) & wmask)
            continue;
          if (grid[i][j] == '#')
            cnt++;
        }
      }
      if (cnt == k)
        ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size);
	data tmp;
	h->obj[i] = x;
	while (i > 1) {
		if (h->obj[i].key < h->obj[i>>1].key) {
			tmp = h->obj[i>>1];
			h->obj[i>>1] = h->obj[i];
			h->obj[i] = tmp;
			i >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j = i << 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], t[200002], left[200002], right[200002], BIT[200001] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		t[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
		add_BIT(W, BIT, i, 1);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, A - 1);
		if (sum_BIT(BIT, B) == tmp) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		L = A;
		R = B++;
		while (L < R) {
			M = (L + R) / 2;
			if (sum_BIT(BIT, M) > tmp) R = M;
			else L = M + 1;
		}
		
		left[B] = left[L];
		right[left[L]] = B;
		if (s[B] < 0) add_BIT(W, BIT, B, 1);
		for (j = L; j < B; j = right[j]) {
			t[s[j]] = B;
			s[B] = (s[j] > s[B])? s[j]: s[B];
			s[j] = -1;
			add_BIT(W, BIT, j, -1);
		}
		if (j != B) {
			left[j] = B;
			right[B] = j;
		}
		if (B <= W) {
			d.key = B - s[B];
			d.id = s[B];
			push(d, &h);
		}
		
		while (h.size > 0 && t[h.obj[1].id] > h.obj[1].key + h.obj[1].id) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7404
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using ll = long long;
using namespace std;
#define modmod 1000000007

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


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

    ll result;

    if(N > 2*M){
        result = M/2;
    }else{
        if(2*N > M){
            result = M/2;
        }else{
            result = N + (M - 2*N)/4;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, c, cnt;
int d[500020];
vector<pair<int, int> > a[500020];
map<int, int> g[100020];
deque<int> q;
int get(int x, int y) {
	if (g[x].count(y)) {
		return g[x][y];
	}
	return g[x][y] = ++cnt;
}
void add(int x, int y, int z) {
	a[x].push_back(make_pair(y, z));
	a[y].push_back(make_pair(x, z));
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		get(i, 0);
	}
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d", &x, &y, &c);
		int x0 = get(x, 0), xc = get(x, c);
		int y0 = get(y, 0), yc = get(y, c);
		add(xc, yc, 0);
		add(x0, xc, 1);
		add(yc, y0, 1);
	}
	memset(d, -1, sizeof d);
	d[1] = 0;
	q.push_back(1);
	while (q.size()) {
		int u = q.back();
		q.pop_back();
		for (pair<int, int> i: a[u]) {
			if (d[i.first] == -1 || d[i.first] > d[u] + i.second) {
				d[i.first] = d[u] + i.second;
				if (i.second == 1) {
					q.push_front(i.first);
				} else {
					q.push_back(i.first);
				}
			}
		}
	}
	printf("%d\n", d[n] >> 1);
	return 0; 
}

Measured memory_bytes: 60544
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
//#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*
lli power(lli x,lli y)
{
    lli res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}
*/
/*
lli C[100001];
lli ncr(lli n, lli k) 
{ 
	if(C[k]!=0)
	return C[k];	
	memset(C, 0, sizeof(C)); 
    C[0] = 1;  // nC0 is 1 
  
    for (lli i = 1; i <= n; i++) 
    { 
        for (lli j = min(i, k); j > 0; j--) 
            C[j] = (C[j]%mod + C[j-1]%mod)%mod; 
    } 
    return C[k]%mod; 
}*/
/*
void dfs(lli node,vector<lli> graph[],lli *arr)
{
	arr[node]=1;
	for(lli i=0;i<graph[node].size();i++)
	{
		lli child=graph[node][i];
		if(arr[child]!=1)
		dfs(child,graph,arr);
	}
	return ;
}*/
int main()
{
//cout.precision(10);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
		lli n,i,z,ans=0;
		cin>>n;
		lli a[n+1]={0};
		vector<lli> b;
		for(i=0;i<n-1;i++)
		{
			cin>>z;
			b.pb(z);
		}
		a[n]=z;
		a[n-1]=z;
		for(i=n-1;i>1;i--)
		{
			if(b[i-2]<a[i])
			a[i]=b[i-2];
			a[i-1]=b[i-2];
		}
		for(i=1;i<=n;i++)
		{
			ans+=a[i];
		}
		cout<<ans<<endl;
	}
}
/*
*/



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)

const int INF = 1 << 24;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

typedef unsigned long long ull;

int M, N;//x, y
int ice[100][100], used[100][100];

int rec(int x, int y){
    if(0 <= x && x < M && 0 <= y && y < N);
    else{return 0;}

    if(used[x][y] || !ice[x][y]){return 0;}

    used[x][y] = 1;
    
    int res = 0;

    REP(i, 4){
        res = std::max(res, rec(x+dx[i], y+dy[i]) + 1);
    }

    used[x][y] = 0;

    return res;
}

int main(){
    while(std::cin >> M >> N, M){
        REP(i, N){
            REP(j, M){
                std::cin >> ice[j][i];
            }
        }

        REP(i, N){
            REP(j, M){
                used[j][i] = 0;
            }
        }

        int res = 0;
        REP(i, N){
            REP(j, M){
                res = std::max(res, rec(j, i));
            }
        }

        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 1224
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  uint64_t cnt = 0;
  for (int c = 1; c < n; c++)
  {
    int diff = n - c;
    double calc = sqrt(diff);
    for (int a = 1; a <= calc; a++)
    {

      if (diff % a == 0)
      {
        if (a == diff / a)
        {
          cnt++;
        }
        else
        {
          cnt += 2;
        }
      }
    }
  }

  cout << cnt << endl;
  return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

llint cnt = 0;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};


int main()
{
    int n;
    int v[30];
    int c;
    
    ci >> n;
    rep(i, n) ci >> v[i];
    rep(i, n) {
	ci >> c;
	v[i] -= c;
    }

    int ans = 0;

    rep(i, n) if(v[i] > 0) ans += v[i];

    co << ans << en;
  
    return 0;
}


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

int main(void){
  int N;
  scanf("%d", &N);
  int c0 = 0;
  int c1 = 0;
  int c2 = 0;
  int c3 = 0;

  for(int i = 0; i < N; i++){
    char s[256];
    scanf("%s", s);

    if(!strcmp(s, "AC")){
      c0++;
    }
    else if(!strcmp(s, "WA")){
      c1++;
    }
    else if(!strcmp(s, "TLE")){
      c2++;
    }
    else if(!strcmp(s, "RE")){
      c3++;
    }
  }
  printf("AC x %d\n", c0);
  printf("WA x %d\n", c1);
  printf("TLE x %d\n", c2);
  printf("RE x %d\n", c3);

}


Measured memory_bytes: 1700
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
const int maxn=100100;
typedef long long LL;
int a,b,c,x,y;
LL aa[maxn],bb[maxn],cc[maxn];
LL av[maxn],bv[maxn],cv[maxn];
LL ans[3*maxn];
int tot;
int main()
{
	
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(int i=1;i<=a;++i)
	{
		scanf("%lld",&aa[i]);	
	}
	for(int i=1;i<=b;++i)
	{
		scanf("%lld",&bb[i]);	
	}
	for(int i=1;i<=c;++i)
	{
		scanf("%lld",&cc[i]);	
	}
	sort(aa+1,aa+1+a);
	sort(bb+1,bb+1+b);
	sort(cc+1,cc+1+c);
	for(int i=1;i<=x;++i)
	{
		ans[++tot]=aa[a-i+1];
	}
	for(int i=1;i<=y;++i)
	{
		ans[++tot]=bb[b-i+1];
	}
	for(int i=1;i<=c;++i)
	{
		ans[++tot]=cc[c-i+1];
	}
	sort(ans+1,ans+1+tot);
	int temp=0;LL ret=0;
	for(int i=tot;i>0;--i)
	{
		ret+=ans[i];
		temp++;
		if(temp==x+y)break;
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 8340
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

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

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

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

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    a = [int(input()) for _ in range(6)]

   
    if a[-2] - a[0] <= a[-1]:
        print("Yay!")
    else:
        print(":(")


main()


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

int main() {

    int N, Y; cin >> N >> Y;
    int x = -1, y = -1, z = -1;

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

            int total = 10000*i + 5000*j + 1000*(N-i-j);

            if (total == Y) {
                x = i;
                y = j;
                z = N - i - j;
            }

        }
    }

    cout << x << " " << y << " " << z << endl;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int hantei(int, int, int*, int);

int main(void) {
#ifdef DEBUG
	printf("");
#endif

	int A[] = { 1, 3, 5, 7 ,8, 10, 12 };
	int sizeA = sizeof(A) / sizeof(A[0]);
	int B[] = { 4, 6, 9 ,11 };
	int sizeB = sizeof(B) / sizeof(B[0]);
	int C[] = { 2 };
	int sizeC = sizeof(C) / sizeof(C[0]);
	int x, y;
	int flag = 0;

	scanf("%d %d", &x, &y);

#ifdef DEBUG
	printf("1\n");
#endif
	flag = hantei(x, y, A, sizeA);
#ifdef DEBUG
	printf("%d\n",flag);
	printf("2\n");
#endif
	if (flag == 0) flag=hantei(x, y, B, sizeB);
#ifdef DEBUG
	printf("3\n");
#endif
	if (flag==0) flag = hantei(x, y, C, sizeC);

	if (flag==0) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

	return 0;
}

int hantei(int num1, int num2, int* group, int size) {
	int i;
	int flag = 0;
	for (i = 0; i < size;i++) {
#ifdef DEBUG
		printf("num=%d, group[%d]=%d\n", num1, i, group[i]);
#endif
		if (num1 == group[i]) {
			if (num2 == 0) {
				flag = 1;
				break;
			}
			else {
				flag=hantei(num2, 0, group, size);
				break;
			}
		}
	}

#ifdef DEBUG
	printf("戻り値：%d\n", flag);
#endif
	return flag;
}



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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;
    double near_t = INF;
    int near_p;
    for(int i = 0; i < n; i++){
        int h;
        cin >> h;
        double temp;
        temp = t - h * 0.006;
        if(near_t > abs(temp - a)){
            near_t = abs(temp - a);
            near_p = i;
        }
    }
    cout << near_p + 1 << endl;
    return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int,string> Pis;

int main(){
  int n;
  cin>>n;
  int ans=0;
  int k;
  int a[n];
  string as;
  string ps;
  string qs;
  REP(i,n){
    a[i]=i+1;
    cin>>k;
    ps+=to_string(k);
  }
  REP(i,n){
    cin>>k;
    qs+=to_string(k);
  }
  k=0;
  int l=0;
  do{
    k++;
    as.clear();
    REP(i,n){
      as+=to_string(a[i]);
    }
    if(as==ps){
      ans+=k;
    }
    if(as==qs){
      ans-=k;
    }
  }while(next_permutation(a,a+n));
  cout<<abs(ans)<<endl;
  return 0;
}

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

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  in(int,K,T);
  int i;
  int a[112345]={};
  rep(i,T)cin>>a[i];
  int sum=0;

  sort(a,a+T);
  rep(i,T-1)sum+=a[i];
  putv(max(0,a[T-1]-sum-1));
  return 0;
}


Measured memory_bytes: 640
S=input()
if len(S)==1:
    print(1)
    quit()
if len(S)%2==0:
    A=S[:len(S)//2]
    B=S[len(S)//2:]
    A=A[::-1]
    s=A[0]
    ans=len(S)//2
if len(S)%2==1:
    A=S[:len(S)//2]
    B=S[len(S)//2+1:]
    A=A[::-1]
    s=S[len(S)//2]
    ans=len(S)//2+1
for i in range(len(A)):
    if A[i]!=s or B[i]!=s:
        print(ans+i)
        quit()
print(len(S)) 


Measured memory_bytes: 40176
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 1e12;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e6 + 100;



signed main() {
	speed;
	int n, x;
	cin >> n;
	set<int> st;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		st.emplace(x);
	}
	if (st.size() == n) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;
 
ll X[18], Y[18], P[18], N;
ll R[18];
 
void dfs(vector<int>& XX, vector<int>& YY, int c, int k) {
	if (c == N) {
		ll xd = MOD, yd = MOD, S = 0;
		for (int i = 0;i < N;i++) {
			xd = MOD, yd = MOD;
			for (ll x : XX) {
				xd = min(xd, abs(x - X[i]));
			}
			for (ll y : YY) {
				yd = min(yd, abs(y - Y[i]));
			}
			S += min(xd, yd) * P[i];
		}
		R[k] = min(R[k], S);
		return;
	}
 
	XX.push_back(X[c]);
	dfs(XX, YY, c + 1, k + 1);
	XX.pop_back();
 
	YY.push_back(Y[c]);
	dfs(XX, YY, c + 1, k + 1);
	YY.pop_back();
 
	dfs(XX, YY, c + 1, k);
}
 
int main() {
	cin >> N;
 
	for (int i = 0;i < N;i++) {
		cin >> X[i] >> Y[i] >> P[i];
		R[i] = INT64_MAX;
	}
	R[N] = INT64_MAX;
	vector<int> BX = { 0 };
	vector<int> BY = { 0 };
	dfs(BX, BY, 0, 0);
	
	for (int i = 0;i <= N;i++) {
		cout << R[i] << endl;
	}
}

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

bool isValid(vector<int> &digits, int result)
{
    while (result) {
	int d = result % 10;
	if (find(digits.begin(), digits.end(), d) != digits.end()) {
	    return false;
	}
	result /= 10;
    }
    return true;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> digits;
    while (k--)
    {
	int d;
	cin >> d;
	digits.push_back(d);
    }
    int result = n;
    while (true)
    {
	if (isValid(digits, result))
	{
	    cout << result;
	    break;
	}
	result++;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N, Q;
	cin >> N >> Q;
	vector<vector<int>> edge(N + 1);
	REP(i, N - 1) {
		int a, b;
		cin >> a >> b;
		edge[a].emplace_back(b);
		edge[b].emplace_back(a);
	}
	vector<int> par(N + 1), lazy(N + 1);
	REP(i, Q) {
		int p, x;
		cin >> p >> x;
		lazy[p] += x;
	}
	par[1] = 1;
	queue<int> qu;
	qu.emplace(1);
	while (!qu.empty()) {
		int i = qu.front();
		qu.pop();
		for (auto j : edge[i]) {
			if (par[i] == j) continue;
			par[j] = i;
			lazy[j] += lazy[i];
			qu.emplace(j);
		}
	}
	FOR(i, 1, N + 1) {
		cout << lazy[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 16372
#include<iostream>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
#include<cstring>
using namespace std;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);
int main() {

	//A

	int n;
	cin >> n;
	if (n >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;

	//B
	/*int n;
	int i;
	int counter = 0;
	long long int x, y;
	long long int d;
	cin >> n >> d;
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		if (x * x + y * y <= d * d)counter++;
	}
	cout << counter << endl;
	return 0;
	*/
	//C
	/*int k;
	cin >> k;
	
	if (7 % k == 0) {
		cout << 1 << endl;
		return 0;
	}
	if (k % 7 == 0)k = k / 7;
	if (k % 2 == 0 || k % 5 == 0) {
		cout << -1 << endl;
		return 0;
	}
	if (k == 3) {
		cout << 3 << endl;
		return 0;
	}
	else if (k == 9) {
		cout << 9 << endl;
		return 0;
	}
	
	
	int i = 0;
	int j = 1;
	while (1) {
		i++;
		j = j * 10;
		j = j % k;
		if (j == 1) {
			if (k % 9 == 0) {
				i = i * 9;
			}
			else if (k % 3 == 0) {
				i = i * 3;
			}
			cout << i << endl;
			return 0;
		}

	}*/

	//D
	/*int n;
	string c;
	cin >> n;
	cin >> c;
	int sum = 0;
	int i, j;
	int s = 0;
	i = 0; j = n - 1;
	while (i < j) {
		if (c[i] == 'W') {
			if (c[j] == 'R') {
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
			else {
				while (c[j] != 'R') {
					j--;
					if (j < 0 || j <= i) {
						cout << sum << endl;
						return 0;
					}
				}
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
		}
		else {
			while (c[i] != 'W') {
				i++;
				if (i >= n || i >= j) {
					cout << sum << endl;
					return 0;
				}
			}
			if (c[j] == 'R') {
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
			else {
				while (c[j] != 'R') {
					j--;
					if (j < 0 || j <= i) {
						cout << sum << endl;
						return 0;
					}
				}
				c[i] = 'R';
				c[j] = 'W';
				i++;
				j--;
				sum++;
			}
		}
	}

	cout << sum << endl;
	return 0;	
	*/
}

// a^n mod を計算する
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;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}


Measured memory_bytes: 3588
N,M,X,Y=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if max(A) >= min(B):
  print("War")
elif X >= min(B):
  print("War")
elif Y < min(B):
  print("War")
else:
  print("No War")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << (x) << endl;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int A = 0, B = 0;
    if (N % 2 == 0) {
        for (int i = 0; i < N; i += 2) {
            A += a.at(i);
            B += a.at(i + 1);
        }
    }
    else {
        for (int i = 0; i < N - 1; i += 2) {
            A += a.at(i);
            B += a.at(i + 1);
        }
        A += a.at(N - 1);
    }
    cout << A - B << endl;
}

Measured memory_bytes: 256
#include<sstream>
#include<string>
#include<iostream>
#include<queue>
#include<stdlib.h>
using namespace std;
class A{
public:
    string Int_to_String(int n)
    {
        ostringstream stream;
        stream<<n;
        return stream.str();
    }
};
int main(){
    queue<string> Q;
    int n,q,t=0;
    cin>>n>>q;
    string nt;
    while(cin>>nt){
        Q.push(nt);
    }
    while(!Q.empty()){
        string n1=Q.front();
        Q.pop();
        string n2;
        n2=Q.front();
        int n3;
        
        n3=atoi(n2.c_str());
        
        Q.pop();
        if(n3<=q){
            t+=n3;
            cout<<n1<<" "<<t<<endl;
            }
        else{
            n3-=q;
            t+=q;
            Q.push(n1);
            A a;
            Q.push(a.Int_to_String(n3));
            //Q.push(to_string(n3));
        }
    }
    return 0;
}
    
    
    

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

int main(){
int N,a;
  int min,count;
  min=444;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a;
    count=0;
    while(a%2==0){
      a=a/2;
      count+=1;
    }
    
    if(min>count){
      min=count;
    }
  }
  cout<<min<<endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
const int inf=1e9+9;
int powmod(int x, int k){ int ret=1;for(;k;k>>=1,x=(ll)x*x%mod) if(k&1) ret=(ll)ret*x%mod;return ret;}
pair<int,int> Solve(vector<int> a)
{
	int mn=inf;
	for(int i:a) mn=min(mn,i);
	int cnt=0;
	for(int i:a) cnt+=i==mn;
	int all=powmod(2,cnt);
	int only=2;
	vector<int> tmp;
	for(int i:a)
	{
		if(i==mn && tmp.size())
		{
			pair<int,int> ans=Solve(tmp);
			tmp.clear();
			all=(ll)all*((ans.first+ans.second)%mod)%mod;
			only=(ll)only*ans.second%mod;
		}
		if(i!=mn) tmp.push_back(i-mn);
	}
	if(tmp.size())
	{
		pair<int,int> ans=Solve(tmp);
		tmp.clear();
		all=(ll)all*((ans.first+ans.second)%mod)%mod;
		only=(ll)only*ans.second%mod;
	}
	all-=only;
	if(all<0) all+=mod;
	only=(ll)only*powmod(2,mn-1)%mod;
	all+=only;
	if(all>=mod) all-=mod;
	return make_pair(all,only);
}
int main()
{
	int n,i;
	scanf("%i",&n);
	vector<int> a(n);
	for(i=0;i<n;i++) scanf("%i",&a[i]);
	printf("%i\n",Solve(a).first);
	return 0;
}

Measured memory_bytes: 256