akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N, M;
	int[] A, B;
	Node[] nodes;

	static class Node {
		int id;
		int groupId;
		Set<Integer> conns;

		Node(int id) {
			this.id = id;
			this.groupId = -1;
			this.conns = new HashSet<>();
		}
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		M = Integer.parseInt(tokens[1]);
		A = new int[M];
		B = new int[M];
		for (int i = 0; i < M; ++i) {
			tokens = in.readLine().split(" ");
			A[i] = Integer.parseInt(tokens[0]) - 1;
			B[i] = Integer.parseInt(tokens[1]) - 1;
		}
		nodes = new Node[N];
		for (int i = 0; i < N; ++i) {
			nodes[i] = new Node(i);
		}
		for(int i=0; i <M; ++i) {
			nodes[A[i]].conns.add(B[i]);
			nodes[B[i]].conns.add(A[i]);
		}
	}

	void mark(int id, int gId, int parent) {
		if (nodes[id].groupId >= 0) {
			return;
		}
		nodes[id].groupId = gId;
		for (Integer i : nodes[id].conns) {
			if (i != parent) {
				mark(i, gId, id);
			}
		}
	}

	void calc() {
		int gid = 0;
		for (int i = 0; i < N; ++i) {
			if (nodes[i].groupId < 0) {
				mark(i, gid, -1);
				++gid;
			}
		}
		int[] counts = new int[gid];
		for (int i = 0; i < N; ++i) {
			counts[nodes[i].groupId]++;
		}
		int max = -1;
		for (int i = 0; i < counts.length; ++i) {
			max = Math.max(max, counts[i]);
		}
		System.out.println(max);
	}

	void showResult() {
	}
}

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

typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 1000000007;

#define fr first
#define sc second

int main(){
	int n;
	string s;
	cin >> n >> s;
	
	string t = s;
	if(s[0] == 'B'){
		t[0] = 'S';
	}
	else {
		t[0] = 'G';
	}
	for(int i = 1 ; i < 2*n ; i ++){
		if(s[i] == s[i-1]){
			if(t[i-1] == 'S')t[i] = 'G';
			else t[i] = 'S';
		}
		else t[i] = t[i-1];
	}
	
	ll ret = 1;
	ll cnt = 0;
	for(int i = 0 ; i < 2*n ; i ++){
		if(t[i] == 'S')cnt ++;
		else {
			ret *= cnt;
			ret %= MOD;
			cnt --;
		}
	}
	if(cnt != 0){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 1 ; i <= n ; i ++){
		ret *= i;
		ret %= MOD;
	}
	cout << ret << endl;
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    vi v = {a, b, c};
    sort(all(v));
    if (v[0] == v[1] && v[0] != v[2])
        cout << "Yes" << endl;
    else if (v[1] == v[2] && v[0] != v[1])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    GAME_OVER;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

MAXN = 10000
G = [[] for _ in range(MAXN)]
color = [-1] * MAXN

def dfs(i,idx,c):
    color[i] = c[idx]
    for e in G[i]:
        if color[e] != -1:
            continue
        idx = dfs(e,idx + 1,c)
    return idx

def main():
    n = int(input())
    for _ in range(n - 1):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    
    c = list(map(int,input().split()))
    c.sort(reverse = True)

    dfs(0,0,c)
    ans = sum(c) - c[0]
    print(ans)
    print(*color[:n])

if __name__ =='__main__':
    main()  

Measured memory_bytes: 14448
def module2019(m):
    if m <= 2018:
        return m
    else:
        return module2019(m%2019)

# ij = []
# for i in range(2019):
#     for j in range(i+1,2019):
#         ij += [[i,j]]

# modij = [module2019(i[0]*i[1]) for i in ij]

l,r = map(int,input().split())
d = int(r//2019)-int(l//2019)
if d >= 1:
    print(0)
else:
    mods = []
    for i in range(l%2019,r%2019 +1):
        for j in range(i+1,r%2019 +1):
            mods += [module2019(i*j)]
    print(min(mods))

Measured memory_bytes: 75416
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <cstring>
#include <queue>
using namespace std;

int main(){
    int n, r;
    cin >> n >> r;
    if(n >= 10) cout << r << '\n';
    else {
        cout << (r + 100*(10 - n)) << '\n';
    }
}


Measured memory_bytes: 256
h,w = map(int,input().split())
li = [input() for _ in range(h)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]

for i in range(h):
  for j in range(w):
    if li[i][j] == ".":
      continue
    for k in range(4):
      if not(0<=i+dx[k]<h) or not(0<=j+dy[k]<w):
        continue
      else:
        if li[i+dx[k]][j+dy[k]] == "#":
          break
    else:
      print("No")
      exit()
print("Yes")

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

#define ll long long

using namespace std;

const ll N = 1e6, mod = 1e9 + 7;

ll x, y;

ll ans, f[N + 123];

ll binpow (ll a, ll b) {
    if (b == 0) return 1 % mod;
    ll res = binpow (a, b / 2) % mod;
    res = (res * res) % mod;
    if (b % 2 == 1) res = (res * a) % mod;
    return res;
}

int main () {
    cin >> x >> y;
    f[1] = 1;
    if ((x + y) % 3 != 0 || min (x, y) * 2 < max (x, y)) {
        cout << 0;
        exit (0);
    }
    if (x * 2 == y || y * 2 == x) {
        cout << 1;
        exit (0);
    }
    for (int i = 2;i <= N;i ++) {
        f[i] = (f[i - 1] * 1ll * i) % mod;
    }
    for (int i = 0;i <= x;i ++) {
        ll n = i, m;
        if (n * 3 == 2 * x - y) {
            m = x - 2 * n;
            ll sz = n + m;
            ll a = f[sz] % mod, b = (f[n] * 1ll * f[sz - n]) % mod;
            ans = (ans + (a * 1ll * ((binpow (b, mod - 2)) % mod)) % mod) % mod;
        }
    }
    if (!ans) {
        
    }
    cout << ans;
}


Measured memory_bytes: 8064
n=int(input())
x=list(map(float,input().split()))
y=list(map(float,input().split()))
for p in range(1,4):
    Dxy=float(0)
    for i in range(n):
        Dxy+=abs(x[i]-y[i])**p
    Dxy=Dxy**(1/p)
    print(f'{Dxy:.6f}')
Dxy=float(0)
for i in range(n):
    if Dxy<abs(x[i]-y[i]):Dxy=abs(x[i]-y[i])
print(f'{Dxy:.6f}')


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

typedef long long ll;
int N, K;
vector<int> arr;
vector<ll> psum, dp1, dp2;

int main() {
    scanf("%d %d", &N, &K);
    arr.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &arr[i]);
    }

    psum.resize(N);
    for(int i = 0; i < N; i++) {
        psum[i] = arr[i];
        if(i) psum[i] += psum[i - 1];
    }
    dp1.resize(N);
    for(int i = 0; i < N; i++) {
        dp1[i] = max(arr[i], 0);
        if(i) dp1[i] += dp1[i - 1];
    }
    dp2.resize(N);
    for(int i = N - 1; i >= 0; i--) {
        dp2[i] = max(arr[i], 0);
        if(i != N - 1) dp2[i] += dp2[i + 1];
    }

    ll ans = 0;

    for(int i = 0; i <= N - K; i++) {
        ans = max(ans, (i == 0? 0 : dp1[i - 1]) + max((ll)0, psum[i + K - 1] - (i == 0? 0 : psum[i - 1])) + (i + K == N? 0 : dp2[i + K]));
    }
    printf("%lld", ans);
}


Measured memory_bytes: 2944
package main

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

var sc = bufio.NewScanner(os.Stdin)
var depth [101]int
var finish [101]int
var d [101]int
var n, time int

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func visit(graph [][]int, u int) {
	depth[u] = 1
	time++
	d[u] = time
	for i := 0; i < n; i++ {
		if graph[u][i] == 1 {
			if depth[i] == 0 {
				visit(graph, i)
			}
		}
	}
	depth[u] = 2
	time++
	finish[u] = time
}
func main() {
	sc.Split(bufio.ScanWords)

	n = nextInt()
	graph := make([][]int, n)
	for i := 0; i < n; i++ {
		graph[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		s := nextInt()
		t := nextInt()
		if t == 0 {
			continue
		}
		for i := 0; i < t; i++ {
			u := nextInt()
			graph[s-1][u-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		if depth[i] == 0 {
			visit(graph, i)
		}
	}
	for i := 0; i < n; i++ {
		fmt.Printf("%d %d %d\n", i+1, d[i], finish[i])
	}
}



Measured memory_bytes: 1168
#include <iostream>
#include <string> //文字列を使う
using namespace std;

int main(void){
    string s;
    while(true){
        cin >> s;
        if(s == "0"){
            break;
        }
        int sum=0;
        for(int i=0; i<s.size() /*長さ*/; i++){
            int n=s[i]-48; 
            //TODO:文字コードを数値に変換する
            sum += n;
        }
        cout << sum << endl;
    }
} 


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int64_t N;
vector<int64_t> L;

int main() {
  std::cout << std::fixed << std::setprecision(20);

  cin >> N;
  L = vector<int64_t>(N,0);
  REP(i,N){
    cin >> L.at(i);
  }

  sort(ALL(L));

  int ans = 0;

  REP(i,N-2){
    FOR(j,i+1,N-1){
      FOR(k,j+1,N){
        if(L[i] == L[j] || L[i] == L[k] || L[j] == L[k]){
          continue;
        }
        if(L[i] + L[j] <= L[k]){
          continue;
        }
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 3624
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int s, w;cin>>s>>w;
  if(s>w)cout<<"safe"<<endl;
  else cout<<"unsafe"<<endl;
  system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;cin >> a >> b >> c;
	int ans=0;
	if(a%2==b%2 && b%2!=c%2){
		a++;
		b++;
		ans++;
	}
	else if(a%2==c%2 && a%2!=b%2){
		a++;
		c++;
		ans++;
	}
	else if(b%2==c%2 && a%2!=b%2){
		b++;
		c++;
		ans++;
	}
	if(a>=b && a>=c) cout << (a-b)/2+(a-c)/2+ans << endl;
	else if(b>=a && b>=c) cout << (b-a)/2+(b-c)/2+ans << endl;
	else cout << (c-a)/2+(c-b)/2+ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

int main(void)
{
  for(;;){
    string s;
    cin >> s;
    if(s=="#") return 0;
    int f=0,cost=0;
    REP(i,s.size()-1){
      if((s[i]-'1')%3-(s[i+1]-'1')%3==0){
	f=-f;
      }else{
	if(f*((s[i]-'1')%3-(s[i+1]-'1')%3)>0) ++cost;
	f=(s[i]-'1')%3-(s[i+1]-'1')%3;
      }
    }
    cout << cost << endl;

  }
}

Measured memory_bytes: 3280
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

#define PI 3.14159265358979

int main(void) {
  int a, b, x;
  cin >> a >> b >> x;

  double c, d, ans;
  if (2 * x >= a * a * b) {
    c = (double)a / 2.0;
    d = (double)b - (double)x / (double)(a * a);
  }
  else {
    c = 2 * (double)x / (double)(a * b);
    d = (double)b;
  }
  double rad = atan2(d, c);
  ans = rad * 180.0 / PI;
  printf("%.12f\n", ans);

  return 0;
}


Measured memory_bytes: 512
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn main() {
    let n:usize = read();
    let T:u32 = read();
    let p:Vec<(u32,u32)> = (0..n).map(|_| (read(), read())).collect();

    let p:Vec<u32> = p.iter().filter(|&&(c,t)| t <= T).map(|&(c,t)| c).collect();
    if p.len() == 0 {
        println!("TLE");
    } else {
        println!("{}", p.iter().min().unwrap());
    }
}


Measured memory_bytes: 4352
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#include<numeric>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,gv,ma_v=0;
  bool is_pair=true;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    ma_v = max(a[i],ma_v);
  }
  vector<bool> lst(ma_v+1,false);
  for(int i=0;i<n;i++){
    ll tp = a[i];
    for(ll j=2;j*j<=tp;j++){
      ll cnt = 0;
      while(tp%j==0){
        cnt++;
        tp /= j;
      }
      if(cnt){
        if(lst[j]){
          is_pair = false;
          break;
        }else{
          lst[j] = true;
        }
      }
    }
    if(tp!=1&&lst[tp]){
      is_pair = false;
    }
    lst[tp] = true;
    if(!is_pair){
      break;
    }
  }
  gv = a[0];
  for(int i=1;i<n;i++){
    gv = gcd(gv,a[i]);
  }
  if(is_pair){
    cout << "pairwise coprime"<<endl;
  }else if(gv==1){
    cout << "setwise coprime"<<endl;
  }else{
    cout <<"not coprime"<<endl;
  }
}


Measured memory_bytes: 11356
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm

//#include "BIT.h"

#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}

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

  ll h, a;
	cin >> h >> a;

	//vector<vector<int>> work(m, vector<int>());

	cout << 1+ (h-1) / a << endl;
}




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

X.sort()
X_min = X[0]
X_max = X[N-1]

result = -1
total = 0
for P in range(X_min, X_max+1):
    for x in X:
        total = total + (x-P)**2
    if (total < result or result < 0):
        result = total
    elif (total > result):
        break
    total = 0
print(result)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define MAX INT_MAX
#define MIN INT_MIN
#define ss second
#define ff first
#define double long double
const int mod = 1e9+7;

int score(vector<int> &v){
	int n = v.size();
	int dp[n][n];
	for(int i = n-1; i >= 0; --i){
		for(int j = i; j < n; ++j){
			if(i == j)
				dp[i][j] = v[i];
			else {
				dp[i][j] = max(v[i]-dp[i+1][j], v[j]-dp[i][j-1]);
			}
		}
	}
	return dp[0][n-1];
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<int> v(n);
	for(int &a: v)
		cin >> a;
	cout << score(v) << endl;
	return 0;
}


Measured memory_bytes: 46464
#include <stdio.h>

int main()
{
    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    
    if (a%2 == 0 || b%2 == 0){
        printf("Even\n");
    }
    else{
        printf("Odd\n");
    }
    return 0;
}

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

int main(void) {
    int n;
    while(cin >> n) {
        int a[n];
        for(int i = 0; i <= n; i++) {
            a[i] = 1;
        }
        for(int i = 2; i <= sqrt(n); i++) {
            if(a[i]) {
                for(int j = 2; i * j <= n; j++) {
                    a[i * j] = 0;
                }
            }
        }
        int cnt = 0;
        for(int i = 2; i <= n; i++)
            if (a[i]) cnt++;
        cout << cnt << endl;
    }
}

Measured memory_bytes: 6948
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>

using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = 0 ; i < a ; i ++)
#define vi vector<int>

int main(void){
	int s,t,r=0;
	cin>>s;
	vi sv(s);
	rep(i,s)cin>>sv[i];
	cin>>t;
	vi tv(t);
	rep(i,t){
		cin>>tv[i];
		rep(j,s){
			if(sv[j] == tv[i]){
				r++;
				break;
			}
		}
	}
	cout<<r<<endl;
}	

Measured memory_bytes: 1232
from collections import deque

n,m=map(int,input().split())
adj=[[] for _ in range(n)]
for _ in range(m):
  x,y=map(int,input().split())
  adj[x-1].append(y-1)
  adj[y-1].append(x-1)

before=[None] * n
before[0] = -1
q=deque([0])
while len(q):
  node=q.popleft()
  for nxt in adj[node]:
    if before[nxt] is not None:
      continue
    q.append(nxt)
    before[nxt] = node
print("Yes")
for i in range(1, n):
  print(before[i] + 1)

  

Measured memory_bytes: 34104
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;

ll N, K;
vector<ll> A, E;

bool f(ll x) {
	//x秒より短い時間で可能か？
	ll cntK = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] * E[i] <= x)continue;
		ll tmp = x / E[i];
		cntK += (A[i] - tmp);
	}
	if (cntK <= K)return true;
	else return false;
}

int main() {
	cin >> N >> K;
	A.resize(N), E.resize(N);
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> E[i];
	}

	if (sum <= K) {
		cout << 0 << endl;
		return 0;
	}

	sort(A.begin(), A.end());
	sort(E.begin(), E.end(), greater<ll>());
	ll l = 0, u = 1e15;
	while (u - l > 1) {
		ll mid = (u + l) / 2;
		if (f(mid)) u = mid;
		else l = mid;
	}
	if (f(l))cout << l << endl;
	else cout << u << endl;
	
	return 0;
}

Measured memory_bytes: 3328
N=int(input())
suits=["S","H","C","D"]
cards=[]
for i in range(N):
    s,n=input().split()
    if s=="S":
        cards.append(int(n))
    elif s=="H":
        cards.append(13+int(n))
    elif s=="C":
        cards.append(26+int(n))
    else:
        cards.append(39+int(n))

for i in range(1,53):
    if i not in cards:
        print(suits[(i-1)//13],(i-1)%13+1)


Measured memory_bytes: 5604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;


int main() {
	int N, K;
	cin >> N >> K;
	
	vector<int> H(N, 0);
	for(int i = 0; i < N; i++){
		cin >> H[i];
	}
	
	int count = 0;
	for(int i = 0; i < N; i++){
		if(H[i] >= K) count++;
	}
	
	cout << count << endl;
	
	return 0;
	
}


/*

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

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


*/


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

ll dp[105][100010], dp2[105][100010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  REP(i, a[0]+1) dp[0][i] = 1, dp2[0][i] = 1;
  FOR(i, 1, k+1) dp2[0][i] += dp2[0][i-1];

  FOR(i, 1, n) {
    REP(j, k+1) {
      // [j-a[i], j]
      dp[i][j] = dp2[i-1][j] - ((j-a[i]<1)?0:dp2[i-1][j-a[i]-1]);
      dp[i][j] = (dp[i][j]%MOD+MOD)%MOD;
    }
    dp2[i][0] = dp[i][0];
    FOR(j, 1, k+1) {
      dp2[i][j] = (dp2[i][j-1] + dp[i][j]) % MOD;
    }
  }

  // REP(i, n) {
  //   REP(j, k+1) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  // cout << endl;
  // REP(i, n) {
  //   REP(j, k+1) {
  //     cout << dp2[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  
  cout << dp[n-1][k] << endl;

  return 0;
}


Measured memory_bytes: 160000
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Info> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            int h = scan.nextInt();
            Info info = new Info();
            info.x = x;
            info.y = y;
            info.h = h;
            list.add(info);
        }
        int cx = 0;
        int cy = 0;
        int ch = 0;
        for (int i = 0; i <= 100; i++) {
            for (int j = 0; j <= 100; j++) {
                HashSet<Integer> set = new HashSet<>();
                for (int k = 0; k < N; k++) {
                    Info info = list.get(k);
                    if (0 < info.h) {
                        set.add(info.estimate(i, j));
                    }
                }
                if (set.size() != 1) {
                    continue;
                }
                cx = i;
                cy = j;
                for (int x : set) {
                    ch = x;
                }
                boolean ng = false;
                for (int k = 0; k < N; k++) {
                    Info info = list.get(k);
                    if (!info.match(cx, cy, ch)) {
                        ng = true;
                        break;
                    }
                }
                if (ng) {
                    continue;
                }
                System.out.println(cx + " " + cy + " " + ch);
                return;
            }
        }
    }
    class Info {
        int x;
        int y;
        int h;
        int estimate(int px, int py) {
            return h + Math.abs(px-x) + Math.abs(py-y);
        }
        boolean match(int px, int py, int ph) {
            return h == Math.max(ph - Math.abs(px-x) - Math.abs(py-y),0);
        }
    }
}


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

int main(){
  int N, K, y;
  cin >> N >> K;
  for(int i = 0;i < N; i++){
    int x;
    cin >> x;
    if (x < (K - x)){
      y += 2 * x ;
    }
    else {
      y += 2 * (K - x);
    }
  }
  cout << y <<endl;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## libs ##
from collections import deque
#======================================================#
def main():
    n = II()
    aa = [II() for _ in range(n)]
    aa.sort()
    maxv = 0
    if n%2==0:
        sumv = 0
        l = aa[:n//2]
        r = aa[n//2:]
        sumv += sum(2*ri for ri in r)
        sumv -= r[0]
        sumv -= sum(2*li for li in l)
        sumv += l[-1]
        maxv = max(maxv, sumv)
    else:
        sumv = 0
        l = aa[:n//2]
        r = aa[n//2:]
        sumv += sum(2*ri for ri in r)
        sumv -= r[0]+r[1]
        sumv -= sum(2*li for li in l)
        maxv = max(maxv, sumv)

        sumv = 0
        l = aa[:n//2+1]
        r = aa[n//2+1:]
        sumv += sum(2*ri for ri in r)
        sumv -= sum(2*li for li in l)
        sumv += l[-1]+l[-2]
        maxv = max(maxv, sumv)
    print(maxv)

if __name__ == '__main__':
    main()

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

#define INF 100000000

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

    ll ans = 0;
    if(n < b) ans = floor(a*n/b);
    else ans = floor(a*(b-1)/b);

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

/////////////         qsortのラッピング

int qsort_int_compare_ascend(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
int qsort_int_compare_descend(const void* a, const void* b) {
	return *(int*)b - *(int*)a;
}
void ascendOrder(int size, int* array) {//昇順
	qsort(array, size, sizeof(int), qsort_int_compare_ascend);
}
void descendOrder(int size, int* array) {//降順
	qsort(array, size, sizeof(int), qsort_int_compare_descend);
}

int main() {
	int N; cin >> N;
	if (N % 3 != 0) {
		bool flag = false;
		for (int i = 0; i < N; i++) {
			int a; cin >> a;
			if (a != 0) {
				flag = true;
				break;
			}
		}
		if (flag) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
		return 0;
	}
	int* a = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	ascendOrder(N, a);

	int m = N / 3;
	for (int i = 1; i < m; i++) {
		if (a[i] != a[i - 1]) {
			cout << "No" << endl;
			return 0;
		}
		if (a[i + m] != a[i + m - 1]) {
			cout << "No" << endl;
			return 0;
		}
		if (a[i + m * 2] != a[i + m * 2 - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	if ((a[0] ^ a[m]) == a[m * 2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 1020
import math
A, B, H, M = map(int, input().split())
a = (H * 60 + M) / (12 * 60)
b = M / 60
c = abs(a - b) * 2 * math.pi
print((A**2 + B**2 - 2 * A * B * math.cos(c))**0.5)


Measured memory_bytes: 9248
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

#define int long long

signed main() {
    int n, x, t;
    cin >> n >> x >> t;

    int ans = ((n / x) + (n % x == 0 ? 0 : 1)) * t; 

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

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

int main()
{
	long long n, m; cin >> n >> m;

	const long long mod = 1000000007LL;

	if (m < n) swap(n, m);

	if (2 <= m - n) {
		cout << 0 << endl;
		return 0;
	}

	long long tmp;

	if (n == m) {

		tmp = 2LL;

		while (true) {
			tmp *= m;
			tmp = tmp % mod;
			tmp *= n;
			tmp = tmp % mod;

			if (m == 1LL) {
				break;
			}
			m--;
			n--;
		}

	}
	else { // n + 1 = m

		tmp = 1LL;

		while (true) {
			tmp *= m;
			tmp = tmp % mod;
			tmp *= n;
			tmp = tmp % mod;

			if (m == 1LL && n == 1LL) {
				break;
			}
			m = max(m - 1, 1LL);
			n = max(n - 1, 1LL);
		}

	}
	
	cout << tmp << endl;
	return 0;
}

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

int main() {
    string x;
    cin >> x;
    int st = x.size();
    int rs = 0;
    int rem = 0;
    char c;
    for (int i = 0; i < st; i++) {
        if (x[i] == 'S') {
            rs++;
        } else if(rs > 0 && x[i] == 'T') {
            rs--;
            rem += 2;
        }
    }
    cout << (st - rem) << endl; 
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll x;
    cin >> x;
    if (x < 1200) {
        cout << "ABC" << endl;
    }
    else {
        cout << "ARC" << endl;
    }
}

Measured memory_bytes: 256
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

from collections import Counter 
from collections import defaultdict
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

n,m=input_list()
a=input_list()
count=defaultdict(int,Counter(a))
for _ in range(m):
    b,c=input_list()
    count[c]+=b

s_val=sorted(count.keys())
s_val.reverse()
ans=0
cnt=n
for i in s_val:
    now=count[i]
    if now>cnt:
        ans+=cnt*i
        break
    ans+=now*i
    cnt-=now
print(ans)


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

int main() {

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int k; 
    cin>>k;
    long long int sum = 0;
    for (int i=1; i<=k; i++){
        for (int j=1; j<=k; j++){
            for (int l=1; l<=k; l++){
                sum += __gcd(i, __gcd(j, l));
            }
        }
    }
    cout<<sum;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define forna(i,a,n) for(int i=a;i<n;i++)
typedef long long int lli;
#define MOD 1000000007
using namespace std;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli t,n,m,tot=0;string s;
cin>>n;
forna(i,1,n+1){
  forna(j,1,n+1){
    if(i*j>n-1) break;
    tot++;
  }
}
cout<<tot<<endl;
}


Measured memory_bytes: 3580
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sec second
#define fir first
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(ll (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define MOD 998244353
void solve()
{
	ll k;
	cin >> k;
	std::vector<ll> res;
	for (ll i = 1; i < 10; ++i)
		res.pb(i);
	if (k <= 11)
	{
		cout << k << endl;
		return;
	}
	ll i = 0;
	while (res.size() < k)
	{
		ll val = res[i];
		ll r = val % 10;
		val *= 10;
		ll ans1, ans2, ans3;
		if (r)
		{
			ans1 = val + r - 1, ans2 = val + r, ans3 = val + r + 1;
			res.pb(ans1);
			res.pb(ans2);
			if(r!=9)
			res.pb(ans3); 
		
		}
		else
		{
			ans1 = val + r, ans2 = val + r + 1;
			res.pb(ans1);
			res.pb(ans2);
		}
		i++;
	}
	cout << res[k - 1] << endl;


}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	int T;
	// cin >> T;
	T = 1;
	while (T--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 4272
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] H = Console.ReadLine().Split(' ');
            int N = int.Parse(H[0]);
            int K = int.Parse(H[1]);

            int[] temp = new int[N];

            for (int i = 0; i < K; i++)
            {
                int d = int.Parse(Console.ReadLine());
                string[] A = Console.ReadLine().Split(' ');
                for (int j = 0; j < d; j++)
                {

                    temp[int.Parse(A[j])-1]++;
                }
                
            }

            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                if (temp[i] == 0) cnt++;
            }

            Console.WriteLine(cnt);
           
        }
    }
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifdef APURBA
#define HERE cout<<"here - "<<__LINE__<<"\n";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout<<endl;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << " ";
    err(++it, args...);
}
#else
#define HERE
#define debug(args...)
#endif
const ll mod = 1e9+7 ;
const int N = (1<<17);
typedef pair<int,int> pii;

void TEST_CASES(int cas)
{
    int d,s,t;
    cin>>d>>s>>t;
    if(d<=s*t)
    {
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}



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

int main (){
    int r, g, b;
    cin >> r >> g >> b;
    
    int num = (r * 100) + (g * 10) + b;
    if (num % 4 == 0){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3632
#https://qiita.com/Kerzival/items/6923c2eb3b91be86f19f
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
N,M,K = list(map(int,input().split()))
uf = UnionFind(N)
fr = [0]*(N+1)
for i in range(M):
    [x_tmp,y_tmp] = list(map(int,input().split()))
    uf.Unite(x_tmp,y_tmp)
    fr[x_tmp] += 1
    fr[y_tmp] += 1
ans = [0]*(N+1)
for i in range(1,N+1):
    ans[i] = uf.Count(i) - fr[i] - 1
for j in range(K):
    [x_tmp,y_tmp] = list(map(int,input().split()))
    if uf.isSameGroup(x_tmp,y_tmp):
        ans[x_tmp] -= 1
        ans[y_tmp] -= 1
print(' '.join(list(map(str,ans[1::]))))

Measured memory_bytes: 16628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n,k;
ll dp[66666][111];
vector<int>v;
int main()
{
    scanf("%d%d",&n,&k);
    int l=1,r=1;
    while(r+1<=n)
    {
        v.push_back(r);
        l=r+1;r=n/(n/l);
    }
    v.push_back(r);
    sort(v.begin(),v.end());
    dp[0][1]=v[0];
    for(int i=1;i<v.size();i++)
        dp[i][1]=v[i]-v[i-1];
    ll ans=0;
    for(int i=2;i<=k;i++)
    {
        int r=v.size()-1;
        ll now=0;
        for(int j=0;j<v.size();j++)
        {
           now=(now+dp[j][i-1])%mod;
           dp[r][i]=now*(r==0?v[r]:v[r]-v[r-1])%mod;
           r--;
        }
    }
    for(int i=0;i<v.size();i++)
        ans+=dp[i][k];
    printf("%lld\n",ans%mod);
}


Measured memory_bytes: 55932
x,k,d=map(int,input().split())
p=k*d-x
q=p//(2*d)
r=p/(2*d)
if r<=0:
  print(-p)
elif 0<r<k:
  s=min(p-2*d*q,-p+2*d*(q+1))
  print(s)
else:
  print(-x-k*d)


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

using namespace std;
using Int = long long;

const int nax = 3005;
Int dp[nax][nax][2];
Int ar[nax];

Int rec(int i, int j, int p) {
  if(i == j) {
    return (p ? -1 : 1) * ar[i];
  }
  Int &x = dp[i][j][p];
  if(x != -1) {
    return x;
  } 
  x = 0;
  if(!p) {
    x = max(ar[i] + rec(i + 1, j, 1), ar[j] + rec(i, j - 1, 1));
  } else {
    x = min(-ar[i] + rec(i + 1, j, 0), -ar[j] + rec(i, j - 1, 0));
  }
  return x;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> ar[i];
  }
  memset(dp, -1 ,sizeof dp);
  cout << rec(0, n - 1, 0) << '\n';
  return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int n;cin>>n;

    VI a(n);
    REP(i, n) cin >> a[i];

    SORT_ASC(a);

    

    REP(i,n-1){
        if(a[i] == a[i+1]){
            cout << "NO" << endl;
            return;
        }

    }

    cout << "YES" << endl;




    

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	ll a[100001], b[100001], s[100001], sb=0;
	for(int i=0; i<n; i++){
		cin>>a[i]>>b[i];
		s[i]=a[i]+b[i];
		sb+=b[i];
	}
	sort(s, s+n, greater<ll>());
	ll ans=-sb;
	for(int i=0; i<n; i+=2){
		ans+=s[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
  int a,b;
  char num[10]={'0','1','2','3','4','5','6','7','8','9'};
  scanf("%d %d",&a,&b);
  char s[128];
  scanf("%s",s);

  for(int i=0;i<a;i++){
    int flag=0;
    for(int j=0;j<10;j++){
      if(s[i]==num[j]){
        flag=1;
      }
    }
    if(flag==0){
      puts("No");
      return 0;
    }
  }


  if(s[a]!='-'){
    puts("No");
    return 0;
  }

  for(int i=a+1;i<a+b+1;i++){
    int flag=0;
    for(int j=0;j<10;j++){
      if(s[i]==num[j]){
        flag=1;
      }
    }
    if(flag==0){
      puts("No");
      return 0;
    }
  }
  puts("Yes");

  return 0;
}


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

int w,d;

struct rec{
    int w, d;
    int num; // 何回目のカットで生まれたか
    rec(int w_, int d_, int num_) : w(w_), d(d_), num(num_){}

    // 昇順ソート
    bool operator<(const rec& that) const {
        if(num == that.num) return w * d < that.w * that.d;
        return num < that.num;
    }
};

bool is_little(const rec& r1, const rec& r2){
    return r1.w * r1.d < r2.w * r2.d;
}

vector<rec> rs;

void cut(int p, int s, int num_of_cuts){
    rec target = rs[p];
    rs.erase(rs.begin()+p);

    // カッティング
    int i = 0;
    while(s > 0){
        if(i & 1) s -= target.d;
        else s -= target.w;
        i++;
    }

    // rsに追加
    if(!(i & 1)){
        rs.push_back(rec(target.w, target.d + s, num_of_cuts));
        rs.push_back(rec(target.w, -s, num_of_cuts));
    }else{
        rs.push_back(rec(target.w + s, target.d, num_of_cuts));
        rs.push_back(rec(-s, target.d, num_of_cuts));
    }
}

int main(){
    int n;

    while(true){
        cin >> n >> w >> d;
        if(n == 0 && w == 0 && d == 0) break;

        rs.clear();
        rs.push_back(rec(w, d, 0));
        for(int i = 1; i <= n; ++i){
            int p, s; cin >> p >> s;
            p--;
            cut(p, s, i);
            sort(rs.begin(), rs.end());
        }

        sort(rs.begin(), rs.end(), is_little); // 面積の小さい順番に並べる

        for(int i = 0; i < rs.size(); ++i){
            int space = rs[i].w * rs[i].d;
            if(i == rs.size()-1) cout << space << endl;
            else cout << space << ' ';
        }
    } 

    return EXIT_SUCCESS;
}



Measured memory_bytes: 3012
from collections import deque

def main():
    n, m = map(int,raw_input().split())
    A = [[] for i in xrange(n)]
    for i in xrange(m):
        s, t = map(int,raw_input().split())
        A[s].append(t)
        A[t].append(s)

    g = [-1]*n
    x = 0
    for i in xrange(n):
        if g[i] == -1:
            g = bfs(n,A,i,g,x)
            x += 1
            
    q = input()
    a =[0]*q
    for i in xrange(q):
        s, t = map(int,raw_input().split())
        if g[s] == g[t]:
            a[i] = 'yes'
        else:
            a[i] = 'no'
    for i in a:
        print i
        
def bfs(n,A,s,color,x):
    Q = deque([s])
    while(len(Q)!=0):
        u = Q.popleft()
        for i in A[u]:
            if color[i] == -1:
                Q.append(i)
        color[u] = x
    return color

if __name__ == '__main__':
    main()

Measured memory_bytes: 24900
N = int(input())
S = []
for i in range(N):
  S.append(input())
 
A = S.count("AC")
B = S.count("WA")
C = S.count("TLE")
D = S.count("RE")
 
print("AC x "+str(A))
print("WA x "+str(B))
print("TLE x "+str(C))
print("RE x "+str(D))

Measured memory_bytes: 16136
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,l;
    int s=0;
    int t=0;
    cin>>n>>l;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        a.at(i)=l+i;
    }
    if(a.at(0)>=0){
        t=a.at(0);
    }else if(a.at(0)<0&&abs(a.at(0))>=n){
        t=a.at(n-1);
    }
    for(int i=0;i<n;i++){
        s+=a.at(i);
        
    }
    s-=t;
    cout<<s<<endl;
}
 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
#define int long long
#define ll long long 
#define F first
#define sqr(x) ((x) * (x))
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;

const int MOD = (int)1e9 + 7;
const int N = (int)2e6+ 222;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;
                                  

int n, m;
char a[N];

void solve () {                   	
	cin >> n >> m;
	for (int i = 1; i <= n + 1; ++i) {
		cin >> a[i];
   	}
   	vector <int> v;
   	for (int i = 1; i <= n + 1; ++i) {
   	 	if (a[i] == '0') v.pb(i);
   	}
   	vector <int> ans;
   	n ++;
   	while (n != 1) {
   		int x = n - m;
   		int pos = lower_bound(all(v), x) - v.begin();
   		pos = v[pos];
   		if (pos >= n) {
   			cout << -1;
   			return;
   		}
   		ans.pb((n - pos));
   		n -= n - pos;
   	}
   	reverse(all(ans));
   	for (auto to : ans) cout << to << " "; 
}






signed main () {
    #ifdef Maga
        freopen("input", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);                                              
    int t = 1;
   // cin >> t;
    while (t --) {
    	solve ();
    }
    return 0;
}





Measured memory_bytes: 2676
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

uf = UnionFind(N)
for a,b in AB:
    a,b = a-1,b-1
    if uf.is_same(a,b): continue
    uf.unite(a,b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))
print(ans)

Measured memory_bytes: 45556