akhauriyash/Code-Regression huggingface dataset:
<?php

fscanf(STDIN, "%d %d", $n, $m);
$S = [];
for ($i = 0; $i < $m; ++$i) {
    $tmp = array_map('intval', explode(' ', trim(fgets(STDIN))));
    $k = $tmp[0];

    for ($j = 1; $j <= $k; ++$j) {
        $S[$i][] = ($tmp[$j] - 1);
    }
}
$P = array_map('intval', explode(' ', trim(fgets(STDIN))));


// bit全探索
$total = 0;
// スイッチの点灯パターン
for ($i = 0; $i < 1<<$n; ++$i) {

    // 電球の点灯数 これがmと一致すればよい
    $m_cnt = 0;

    // 電球
    for ($k = 0; $k < $m; ++$k) {
        $switches = $S[$k];
        // 電球kのスイッチの点灯数
        $cnt = 0;
        for ($j = 0; $j < $n; ++$j) {
            // j番目のスイッチが点灯している状態
            if ($i & 1<<$j) {
                if (in_array($j, $switches)) {
                    ++$cnt;
                }
            }
        }
        if ($P[$k] === ($cnt % 2)) {
            ++$m_cnt;
        }
    }

    $total += $m_cnt === $m ? 1 : 0;
}

echo $total;


Measured memory_bytes: 4856
#include <iostream>

using namespace std;

int main()
{
    int K,S;
    cin >> K >> S;
    int count = 0;

    for(int x = 0; x<=K; x++){
        for(int y=0; y<=K; y++){
                int z = S - x - y;
                if(z >= 0 && z <= K) count++;
            }
        }
    
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[15];

int main(){

	scanf("%s",buf);

	if(buf[0] == 'a'){

		printf("square1001\n");

	}else{

		printf("e869120\n");
	}

	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
int main()
{
    int n;cin>>n;
    vector<int> l(2*n);
    int sum = 0;
    for(int i = 0; i < 2*n; i++) {cin>>l[i]; sum += l[i];}
    sort(l.begin(), l.end());
    for(int i = 1; i <2*n ; i += 2){  
        sum -= l[i]-l[i-1];
    }
    cout << sum/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

const int MAX_N = 3e5, A = 1e9 + 7;
int n;
long a[MAX_N];
int cnt[60][2];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%ld", &a[i]);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 60; j++) cnt[j][(a[i] >> j) & 1]++;
    }
    int ans = 0;
    for (int i = 0; i < 60; i++) {
        ans = (ans + (1L << i) % A * static_cast<long>(cnt[i][1]) % A
                   * cnt[i][0] % A) % A;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

#define int long

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n;
std::string s, t;

bool judge(int a){
	for(int i = 0; i < a; i++){
		if(s[s.length() - a + i] != t[i]){
			return false;
		}
	}
	return true;
}

signed main(){
	scanf("%ld", &n);
	std::cin >> s;
	std::cin >> t;
	int cnt = 0;
	for(int i = 1; i <= std::min(s.length(), t.length()); i++){
		//printf("%ld %ld\n", i, judge(i));
		if(judge(i)){
			cnt = i;
		}
	}
	printf("%ld\n", s.length() + t.length() - cnt);
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
int main()
{
    long long int r,d,x,i;
    while(scanf("%lld %lld %lld",&r,&d,&x)!=EOF)
    {
        for(i=1;i<=10;i++)
        {
            x=r*x-d;
            printf("%lld\n",x);

        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
        int k[1000], p[1000];
        int n, winner;
        int i;

        scanf("%d", &n);

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

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

                if( (k[i]%p[i])==0 )
                        winner = p[i];

                else
                        winner = (k[i]%p[i]);

                printf("%d\n", winner);
        }

        return 0;
}

Measured memory_bytes: 604
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
S = S()
condition1 = ('S' in S) == ('N' in S)
condition2 = ('E' in S) == ('W' in S)
print('Yes' if condition1 and condition2 else 'No')


Measured memory_bytes: 3896
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

use std::io::BufWriter;
use std::io::Write;

fn run() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    input! {
        n: usize,
        q: usize,
        p: [(i32, i32, i32); n],
        d: [i32; q],
    }
    let mut s = Vec::with_capacity(n);
    let mut t = Vec::with_capacity(n);
    for (a, b, x) in p {
        s.push((a - x, x));
        t.push((b - x, x));
    }
    s.sort();
    t.sort();
    let mut h = std::collections::BinaryHeap::new();
    let mut del = std::collections::BinaryHeap::new();
    let mut i = 0;
    let mut j = 0;
    for d in d {
        while i < n && s[i].0 <= d {
            h.push(-s[i].1);
            i += 1;
        }
        while j < n && t[j].0 <= d {
            del.push(-t[j].1);
            j += 1;
        }
        while !h.is_empty() && !del.is_empty() {
            let &x = h.peek().unwrap();
            let &y = del.peek().unwrap();
            if x != y {
                break;
            }
            h.pop();
            del.pop();
        }
        if h.is_empty() {
            writeln!(out, "-1").unwrap();
        } else {
            let &ans = h.peek().unwrap();
            writeln!(out, "{}", -ans).unwrap();
        }
    }
}

fn main() {
    run();
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto &x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << endl; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

//=========================

void run_test() {
	int a, b, c, k; read(a, b, c, k);
    while(k > 0 && b <= a) b *= 2, k--;
    while(k > 0 && c <= b) c *= 2, k--;
    cout << (b > a && c > b ? "Yes" : "No") << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005];
bool cmp(ll a,ll b){
    return a > b;
}
int main(){
    ll n;
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+1+n,cmp);
    ll asw;
    ll sum;
    if( n == 2 ){
        printf("%lld\n",a[1]);
        return 0;
    }
    asw = a[1];
    sum = 1;
    for(ll i=2;i<=n;i++){
        for(ll j=1;j<=2;j++){
            asw += a[i];
            sum++;
            if( sum == n - 1 ){
                printf("%lld\n",asw);
                return 0;
            }
        }
    }
    printf("%lld\n",asw);
}



Measured memory_bytes: 5380
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int numPerson = sc.nextInt();
		int initialPoint = sc.nextInt();
		int problemCount = sc.nextInt();
		
		int[] personPoints = new int[numPerson];
		for(int i = 0 ; i < numPerson ; i++ ) {
			personPoints[i] = initialPoint - problemCount;
		}
		
		for(int i = 0 ; i < problemCount ; i++ ) {
			int numOfPerson = sc.nextInt();
			personPoints[numOfPerson - 1]++;
		}
		
		for(int i = 0 ; i < numPerson ; i++ ) {
			System.out.println(personPoints[i] > 0 ? "Yes" : "No");
		}
		
	}
}

Measured memory_bytes: 55808
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;
ll p[200010][2];
ll r[200010][2];
ll R(ll x, ll f) {
	return p[x][f] == x ? x : p[x][f] = R(p[x][f],f);
}
void unite(ll x, ll y,ll f) {
	x = R(x, f);
	y = R(y, f);
	if (x == y)return;
	if (r[x][f] < r[y][f])p[x][f] = y;
	else {
		p[y][f] = x;
		if (r[x][f] == r[y][f])r[x][f]++;
	}
}
int main() {
	ll n, k, l, x, y;
	cin >> n >> k >> l;
	for (int i = 1; i <= n; i++)p[i][0] = p[i][1] = i;
	for (int i = 0; i < k; i++) {
		cin >> x >> y;
		unite(x, y, 0);
	}
	for (int i = 0; i < l; i++) {
		cin >> x >> y;
		unite(x, y, 1);
	}
	map<P, ll>mp;
	ll a, b;
	for (int i = 1; i <= n; i++) {
		a = R(i, 0);
		b = R(i, 1);
		mp[make_pair(a, b)]++;
	}
	for (int i = 1; i <= n; i++) {
		a = R(i, 0);
		b = R(i, 1);
		cout << mp[make_pair(a, b)];
		if (i == n)cout << endl;
		else cout << ' ';
	}
	return 0;
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=998244353;
const ll inf=1e17;
const ll ms=(1e5)+5;








int main()
{
    idfc;


    string s;
    cin>>s;
    int n;
    n=s.length();
    int i;
    string p;
    set<string> ss;
    ss.insert("dream");
    ss.insert("dreamer");
    ss.insert("erase");
    ss.insert("eraser");
    for(i=n-1;i>=0;i--)
    {
        p=s[i]+p;
        if(p.length()>7)break;
        if(ss.count(p))
        {
            p="";
        }
    }

    if(p.empty())cout<<"YES";
    else cout<<"NO";

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L(N);
  for (int i=0; i<N; i++){
    cin >> L.at(i);
  }
  int count=0;
  for (int i=0; i<N-2; i++){
    for (int j=i+1; j<N-1; j++){
      for (int k=j+1; k<N; k++){
        if (L.at(j)!=L.at(i)){
        if (L.at(i)+L.at(j)>L.at(k) && L.at(j)+L.at(k)>L.at(i) && L.at(k)+L.at(i)>L.at(j) && L.at(k)!=L.at(i) && L.at(k)!=L.at(j)) {
          count++;
        }
        }
      }
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

int main() {
  int m, n;
  std::cin >> m;
  std::cin >> n;
  if (m > 2 && n > 2) {
    std::cout << (long long) (m - 2) * (n - 2);
  } else if (m == 2 || n == 2) {
    std::cout << 0;
  } else if (m == 1) {
    std::cout << std::max(n - 2, 1);
  } else if (n == 1) {
    std::cout << std::max(m - 2, 1);
  } else {
    std::cout << 0;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int N = sc.nextInt();

		Map<Integer,String> map = new LinkedHashMap<Integer, String>();
		for (int i=0;i<N;i++) {
			String s = sc.next();
			int a = sc.nextInt();
			map.put(a, s);
		}
		Map<Integer,String> result = map.entrySet().stream().sorted(Map.Entry.<Integer,String>comparingByValue().thenComparing(Map.Entry.<Integer,String>comparingByKey().reversed())).collect(Collectors.toMap(Map.Entry::getKey,Map.Entry::getValue,(e1,e2) -> e1, LinkedHashMap::new));



		for (Map.Entry<Integer, String> e : result.entrySet()) {
			int i = 1;
			for (Map.Entry<Integer, String> e1 : map.entrySet()) {
				if (e.equals(e1)) {
					System.out.println(i);
				}
				i++;
			}
		}

	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 26452
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

const long long MOD = 1000000007;

using namespace std;



int main(void) {

    long long i, j;
    long long n, k;
    long long sum = 0;
    long long temp;
    long long min, max;
    long long a, b, c, d;
    int turn = 0;


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

    while(1) {
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }

        if (turn == 0) {
            c -= b;
            turn = 1;
        }else {
            a -= d;
            turn = 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3648
<?php
$n = int();

$abc = "abcdefghijklmn";
dfs(0,-1,'');
function dfs($i, $c, $str){
    global $n, $abc;
    if($i == $n){
        echo $str."\n";
        return;
    }
    for($cc = 0; $cc <= $c+1; $cc++){
        dfs($i+1, max($cc, $c), $str.$abc[$cc]);
    }
}

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 5880
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int cnt[3];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll ans = 1;
    rep(i,n) {
        int a; cin >> a;
        ll hoge = 0;
        rep(j,3) {
            if (cnt[j] == a) hoge++;
        }
        ans = ans * hoge % MOD;
        rep(j,3) {
            if (cnt[j] == a) {
                cnt[j]++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9,n;
int t,j,cs=0,a,b,i;
string s;

int main()
{
    cin>>n;
    cout<<n*(n-1)/2<<endl;

}



Measured memory_bytes: 3628
//#define WYS
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i = (a); i >= (b); --i)
#define pb push_back
#define Pll pair<ll,ll>
#define Pii pair<int,int>
#define Plp pair< ll,Pii >
#define Pip pair< int,Pii >
#define Ppp pair< Pii,Pii >
#define x first
#define y second
typedef long long ll;
const int N = 1010;
using namespace std;
char s[111];
int n, m,a,b,c,R,B;
int ck(int a,int b,int c)  {
    return (a+b>c&&abs(a-b)<c);
}
int main() {
#ifdef WYS
    freopen("in.txt","r",stdin);
#endif
    scanf("%d",&n);
    scanf(" %s",s+1);
    rep(i,1,n) {
        R += (s[i]=='R');
        B += (s[i]=='B');
    }
    if(R > B) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	q := scanInt()

	g := make([][]int, n)
	done := make([]bool, n)
	cnt := make([]int, n)

	for i := 0; i < n-1; i++ {
		a,b := scanInt()-1, scanInt()-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	for i := 0; i < q; i++ {
		p := scanInt()-1
		x := scanInt()
		cnt[p] += x
	}

	var fn func(next, sum int)
	fn = func(next, sum int) {
		done[next] = true
		cnt[next] += sum
		for _, v := range g[next] {
			if done[v] {
				continue
			}

			fn(v, cnt[next])
		}
	}

	fn(0,0)

	for _, e := range cnt {
		fmt.Fprintf(wr, "%d ", e)
	}

	fmt.Fprintln(wr)

}


Measured memory_bytes: 117632
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			int m=in.nextInt();
			if((n|m)==0)
				return;
			int a[]=new int[n];
			int b[]=new int[m];
			for(int i=0;i<n;i++)
				a[i]=in.nextInt();
			for(int j=0;j<m;j++)		
				b[j]=in.nextInt();
			int now=0;
			for(int j=0;j<m;j++)
			{
				now+=b[j];
				if(now>=n-1)
				{
					System.out.println(j+1);
					break;
				}
				now+=a[now];
				if(now>=n-1)
				{
					System.out.println(j+1);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		
		int[] point = new int[N];
		
		for(int i = 0 ; i < N ; i++) {
			point[i] = K - Q;
		}
		
		for(int i = 0 ; i < Q ; i++) {
			int A = sc.nextInt();
			point[A - 1]++;
		}
		
		for(int i = 0 ; i < N ; i++) {
			if (point[i] > 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
		
	}

}


Measured memory_bytes: 69112
#include<iostream>
#include<algorithm>
#include<vector>

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

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

const int max_n = 10e5;
vector<pii> xind;
vector<pii> yind;
vector<triple> dist;

int n;

int par[max_n];
int r[max_n];

void init(int n){
    REP(i, n){
        par[i] = i;
        r[i] = 0;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);

    if(x == y) return;
    if(r[x] < r[y]){
        par[x] = y;
    } else {
        par[y] = x;
        if(r[x] == r[y]) r[x]++;
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

int main(){
    xind.clear();
    yind.clear();
    dist.clear();

    cin >> n;
    REP(i, n){
        long long x, y;
        cin >> x >> y;
        xind.push_back(pii(x, i));
        yind.push_back(pii(y, i));
    }
    sort(xind.begin(), xind.end());
    sort(yind.begin(), yind.end());

    REP(i, n-1){
        dist.push_back(triple(xind[i+1].first - xind[i].first, pii(xind[i].second, xind[i+1].second)));
        dist.push_back(triple(yind[i+1].first - yind[i].first, pii(yind[i].second, yind[i+1].second)));
    }
    sort(dist.begin(), dist.end());

    init(n);
    long long money = 0;
    int count = 0;
    REP(i, dist.size()){
        if(count == n-1) break;
        
        long long d = dist[i].first;
        long long x = dist[i].second.first;
        long long y = dist[i].second.second;

        if(same(x, y)){
            continue;
        } else {
            unite(x, y);
            money += d;
            count += 1;
        }
    }

    cout << money << endl;
}


Measured memory_bytes: 12128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se seoncd
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005;
struct node{
	ll a,b;
} p[N];
int f[N][35],x[N],n,m,cnt,T;

int main(){
	read(n),read(T),T++;
	rep(i,1,n){
		read(p[i].a),read(p[i].b);
		p[i].a++,p[i].b++;
	}
	sort(p+1,p+n+1,[&](node p,node q){
		return (q.a-1)*p.b<(p.a-1)*q.b;
	});
	m=n;
	while(m>=1&&p[m].a==1){
		x[++cnt]=p[m].b,m--;
	}
	sort(x+1,x+cnt+1);
	memset(f,0x3f,sizeof f);
	f[0][0]=1;
	rep(i,1,m){
		f[i][0]=1;
		rep(j,1,31){
			f[i][j]=f[i-1][j];
			f[i][j]=min((ll)f[i][j],f[i-1][j-1]*p[i].a+p[i].b);
		}
	}
	int ans=0;
	rep(j,0,31){
		ll now=f[m][j];
		if(now>T) continue;
		int res=j;
		rep(i,1,cnt){
			if(now+x[i]>T) break;
			now+=x[i],res++;
		}
		ans=max(ans,res);
	}
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 31488
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import product
    x = list(map(int, readline().split()))

    def judge():
        for bit in product(range(2), repeat=3):
            first = 0
            second = 0
            for i, b in enumerate(bit):
                if b:
                    first += x[i]
                else:
                    second += x[i]
            if first == second:
                return True
        return False

    if judge():
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 62204
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

void insertionSort(int a[], int n)
{
    rep(j, n)
        {
            if (j > 0)
                printf(" ");
            printf("%d", a[j]);
        }
        printf("\n");
    FOR(i, 1, n)
    {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v)
        {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;

        rep(j, n)
        {
            if (j > 0)
                printf(" ");
            printf("%d", a[j]);
        }
        printf("\n");
    }
}
int main()
{
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    insertionSort(a, n);
}


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

using namespace std;
 
int main(void) {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int N;
	cin >> N;

	int a[N];
	for(int i = 0;i<N;i++){
		cin >> a[i];
		a[i]--;
	}

	int cnt = 0;
	for(int i = 0;i < N;i++){
		int t = a[i];
		// cout << i << "," << a[i] << "," << a[t] << "," << (a[t] == i && i < t) << endl;
		if(a[t] == i && i < t) cnt++;
	}

	cout << cnt << endl;
}

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

int main(){
  int A,B,num,count=0,i,j,k;
  cin >> A >> B;
  
  for(i=1; i<10; i++){
    for(j=0; j<10; j++){
      for(k=0; k<10; k++){
        num=10001*i+1010*j+100*k;
        if(num >= A && num <= B) count++;
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 

using namespace std;
int calc(unordered_set<int >mp){
    
    int Mex=0;
    while(mp.find(Mex)!=mp.end()){
        Mex+=1;
    }
    return(Mex);
}
int main(){
    int n,k;
    cin >>n;
    ll arr[3001];
    for(int i=0;i<n;i++) cin >> arr[i];
    //cout <<arr[0];
    ll ans[n+1][n+1];
    for(int l=n-1;l>=0;l--){
        for(int r=l;r<n;r++){
            if(l==r){
                ans[l][r]=arr[l];
            }
            else{
                ans[l][r]=max(arr[l]-ans[l+1][r],arr[r]-ans[l][r-1]);
            }
        }
    }
    /*for(int i=0;i<n;i++){
        for(int j=i;j<n;j++){
            cout <<ans[i][j]<<" ";
        }
        cout <<endl;
    }*/
    cout <<ans[0][n-1]<<endl;
}



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

int main() {
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N),y(M);
    rep(i,N) cin>>x[i];
    rep(i,M) cin>>y[i];
    if (X >= Y) {
        cout << "War" << endl;
        return 0;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if (x[N - 1] < y[0] && x[N - 1] < Y && y[0] > X) cout << "No War" << endl;
    else cout << "War" << endl;   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
char s[300005];
int n, cnt[3];
int main()
{
    while (~scanf("%d", &n)) {
        ll ans = 1;
        scanf("%s", s + 1);
        for (int i = 1; i <= n * 3; i++) { //思路填满再说
            int x[3], _x[3];
            x[0] = cnt[0], x[1] = cnt[1], x[2] = cnt[2]; //现有的
            sort(x, x + 3);
            int color = (s[i] == 'R' ? 0 : (s[i] == 'G' ? 1 : 2));
            cnt[color]++;

            _x[0] = cnt[0], _x[1] = cnt[1], _x[2] = cnt[2]; //进来的
            sort(_x, _x + 3);
            if (_x[2] != x[2]) {
                ; //进了一个最多的，给下一个人
            } else if (_x[0] != x[0]) { //进了一个最少，选一个人给
                ans = 1ll * ans * (x[1] - x[0]) % mod;
            } else { //进了一个中间的，选一个人给
                ans = 1ll * ans * (x[2] - x[1]) % mod;
            }
        }
        for (int i = 1; i <= n; i++) //A[n,n]
            ans = 1ll * ans * i % mod;
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 512
x = gets.to_i

def fact_five? n
	flag = false
	n = n.abs
	res = 0
	(0..n).each do |i|
		fact = i ** 5
		if fact == n
			flag = true
			res = i
		end
		break if fact > n
	end
	flag ? res : false
end

a = -1
ans_flag = false
while !ans_flag
	a += 1
	temp = x - a ** 5
	res = fact_five?(temp)
	if res
		if temp > 0
			b = -res
		else
			b = res
		end
		ans_flag = true
	end
end

puts [a,b].join(" ")

Measured memory_bytes: 14308
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N; cin >> N;
  int w = 1,odd=1;
  rep(i,N){
    int x; cin >> x;
    w*=3;
    if(x%2==0) odd*=2;
  }
  cout << w-odd << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    Int S; cin >> S;
    Int E9 = 1e9;
    Int x1, y1, x2, y2, x3, y3;
    x1 = 0, y1 = 0;
    x2 = (S + E9 - 1) / E9, y2 = 1;
    x3 = x2*E9-S, y3 = E9;
    cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << endl;
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)

unsigned GetDigit(unsigned num) {
	return log10(num) + 1;
}

int f(long long a, long long b) {
	int n = GetDigit(a);
	int m = GetDigit(b);

	return max(n, m);
}

int main() {

	long long n;
	cin >> n;

	int min = 20;

	FOR(i,1, sqrt(n)+1) {
		if (n%i == 0) {
			long long a = i;
			long long b = n / i;
			if (min > f(a, b)) {
				min = f(a, b);
				
			}

		}
		//cout << i << endl;
	}

	cout << min << endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
	static final int r = 1000000000 + 7;
	static int n;
	static long fact[], finv[], inv[];
	
	public static void cominit() {
		fact = new long[n + 2];
		finv = new long[n + 2];
		inv = new long[n + 2];
		fact[0] = fact[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i = 2; i < n + 2; ++i) {
			fact[i] = (fact[i - 1] * i) % r;
			inv[i] = r - (inv[r % i] * (r / i)) % r;
			finv[i] = (finv[i - 1] * inv[i]) % r;
		}
	}
	
	public static int comb(int n, int k) {
		if(n < k)return 0;
		if(k < 0 || n < 0)return 0;
		if(k == 0)return 1;
		
		return (int)((fact[n] * (finv[k] * finv[n - k] % r)) % r);
	}

	public static int homogenerous(int x, int y) {
		return comb(x + y - 1, x - 1);
	}
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int k = sc.nextInt();
		cominit();
		sc.close();
		long ans = 0;
		int len = Math.min(n - 1, k);
		for(int i = 0; i <= len; ++i){
			long tmp = (long)comb(n, i) % (long)r;
			tmp *= (long)homogenerous(n - i, i);
			tmp %= (long)r;
			ans += tmp;
			ans %= (long)r;
		}
		System.out.println(ans);
	}
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<int>>height(N);
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    height.at(i).push_back(x);
  }
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    int p=height.at(A-1).at(0);
    int q=height.at(B-1).at(0);
    height.at(A-1).push_back(q);
    height.at(B-1).push_back(p);
  }
  int counter=0;
  for(int i=0;i<N;i++){
    bool judge=true;
    for(int j=1;j<height.at(i).size();j++){
      if(height.at(i).at(0)<=height.at(i).at(j)){
        judge=false;
        break;
      }
    }
    if(judge){
      counter++;
    }
  }
  cout << counter <<endl;
}
        
        
    
  

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

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

struct Matrix{
	int h, w;
	vector<i64> v;

	Matrix(int h, int w) : h(h), w(w), v(h * w, 0){}

	Matrix(vector<vector<i64>> v_) : h(v_.size()), w(v_[0].size()), v(h * w){
		for(int i = 0; i < h; ++i)
			for(int j = 0; j < w; ++j)
				v[i * w + j] = v_[i][j];
	}

	static Matrix makeUnit(int n){
		Matrix mat(n, n);
		for(int i = 0; i < n; ++i)
			mat.at(i, i) = 1;
		return mat;
	}

	static Matrix modMul(const Matrix& a, const Matrix& b, const int mod = MOD){
		assert(a.w == b.h);
		Matrix ret(a.h, b.w);
		for(int i = 0; i < a.h; ++i)
			for(int k = 0; k < a.w; ++k)
				for(int j = 0; j < b.w; ++j)
					ret.v[i * b.w + j] = (ret.v[i * b.w + j] + a.v[i * a.w + k] * b.v[k * b.w + j]) % mod;
		return ret;
	}

	i64& at(int i, int j){
		assert(0 <= i && i <= h && 0 <= j && j < w);
		return v[i * h + j];
	};

	Matrix pow(i64 x, const i64 mod = MOD){
		assert(h == w);
		auto mat = x & 1 ? *this : makeUnit(h);
		auto u = *this;
		while(u = modMul(u, u, mod), x >>= 1)
			if(x & 1)
				mat = modMul(mat, u, mod);
		return mat;
	}

	Matrix& operator+=(const Matrix& mat){
		assert(h == mat.h && w == mat.w);
		for(int i = 0; i < h * w; ++i)
			v[i] += mat.v[i];
		return *this;
	}

	Matrix& operator-=(const Matrix& mat){
		assert(h == mat.h && w == mat.w);
		for(int i = 0; i < h * w; ++i)
			v[i] -= mat.v[i];
		return *this;
	}

	Matrix& operator%=(const i64 mod){
		for(int i = 0; i < h * w; ++i)
			v[i] %= mod;
		return *this;
	}

	Matrix operator*(const Matrix& mat){
		assert(w == mat.h);
		Matrix ret(h, mat.w);
		for(int i = 0; i < h; ++i)
			for(int k = 0; k < w; ++k)
				for(int j = 0; j < mat.w; ++j)
					ret.v[i * mat.w + j] += v[i * w + k] * mat.v[k * mat.w + j];
		return ret;
	}

	Matrix operator+(const Matrix& mat){return Matrix(*this) += mat;}
	Matrix operator-(const Matrix& mat){return Matrix(*this) -= mat;}
	Matrix operator%(const i64 mod){return Matrix(*this) %= mod;}
	Matrix& operator*=(const Matrix& mat){return *this = *this * mat;}
};

signed main(){
	int n;
	i64 k;
	cin >> n >> k;
	vector<vector<i64>> v(n, vector<i64>(n));
	for(auto& x : v)
		for(auto& y : x)
			cin >> y;
	auto mat = Matrix::modMul(Matrix(v).pow(k), vector<vector<i64>>(n, vector<i64>(1, 1)));
	cout << accumulate(mat.v.begin(), mat.v.end(), 0LL) % MOD << endl;
}



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

int main() {
  vector<char> S(9);
  for(int i=0; i<9; i++){
    cin >> S.at(i);
  }

  cout << S.at(0) << S.at(4) << S.at(8) << 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++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  string s ;
  cin >> s;
  rep(i,3){
  cout << s[i];
  }
}


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;

int H, W;
vector<string> s;
vector<vector<int>> dist;
vector<int> di={0,1,0,-1};
vector<int> dj={1,0,-1,0};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> H >> W;
    s.resize(H);
    for (int i=0;i<H;i++) cin >> s[i];
    int white = 0;
    for (int i=0;i<H;i++){
        for (int j=0;j<W;j++){
            if (s[i][j] == '.') white++;
        }
    }
    if (s[0][0] == '#' || s[H-1][W-1] == '#'){
        cout << -1 << "\n";
        return 0;
    }
    dist.resize(H,vector<int>(W,-1));
    queue<pair<pair<int,int>,int>> q;
    dist[0][0] = 0;
    q.push(make_pair(make_pair(0,0),dist[0][0]));
    while (!q.empty()){
        pair<pair<int,int>,int> p = q.front();q.pop();
        for (int x=0;x<4;x++){
            int ni = p.first.first + di[x];
            int nj = p.first.second + dj[x];
            if (ni<0||ni>=H) continue;
            if (nj<0||nj>=W) continue;
            if (s[ni][nj]=='#') continue;
            if (dist[ni][nj] != -1) continue;
            dist[ni][nj] = p.second + 1;
            q.push(make_pair(make_pair(ni,nj),dist[ni][nj]));
        }
    }
    if (dist[H-1][W-1]==-1) {
        cout << -1 << "\n";
        return 0;
    }
    int res = dist[H-1][W-1] + 1;
    int ans = white - res;
    cout << ans << "\n";
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int N, K;
    cin >> N >> K;
    vector<int> H(N, 0);
    REP(i, N) {
        cin >> H[i];
    }
    if(N <= K) {
        printf("0\n");
        return 0;
    }
    SORT(H);
    int ans = 0;
    REP(i, N - K) {
        ans += H[i];
    }
    printf("%lld\n", ans);

    return 0;
}



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

class Sieve {
private:
  int prime_num;     // N以下の素数の個数
  vector<int> prime; // i番目の素数
  vector<bool> is_prime;

public:
  Sieve(int N) {
    prime.resize(N);
    is_prime.resize(N + 1);

    prime_num = 0;
    for (int t = 0; t <= N; t++)
      is_prime[t] = true;
    is_prime[0] = is_prime[1] = false;
    for (int t = 2; t <= N; t++) {
      if (is_prime[t] == true) {
        prime[prime_num++] = t;
        for (int i = 2 * t; i <= N; i += t)
          is_prime[i] = false;
      }
    }
  }

  int getPrimeNum(int n) { return prime_num; }
  int getKthPrime(int k) { return prime[k]; }
  bool isPrime(int n) { return is_prime[n]; }
};

signed main() {
  int X;
  cin >> X;

  Sieve siv(1000000);

  for (int i = 0;; i++) {
    if (siv.getKthPrime(i) >= X) {
      cout << siv.getKthPrime(i);
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 8192
n = int(input())
def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res
if n == 1:
    print(0)
else:
    mod = 10**9+7
    print((power_func(10, n, mod)-(power_func(9, n, mod)*2-power_func(8, n, mod)))%mod)

Measured memory_bytes: 9200
#include<stdio.h>
#include <string.h>
#include<algorithm>
using namespace std;

int main(void){
int N,i,x,cnt;
  scanf("%d",&N);
  cnt=0;
  if(N<=9){
  	printf("Yes");
  }
  else{
for (i=2;i<=9;i++){
	if(N%i==0){
		for(x=2;x<=9;x++){
			if(N==i*x){
				cnt=1;
				break;
			}
		}
	}
if (cnt==1){
	break;
}
}

if(cnt==0){
printf("No");
}
else if(cnt==1){printf("Yes");} 
}
}

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

int main() {
    
    int a, b;
    
    cin >> a >> b;
    
    int count = 0;
    for(int month = 1; month <= a; month++) {
        for(int day = 1; day <= month; day++) {
            if(month == a && day > b) {
                break;
            }
            
            if(month == day) {
                count++;
            }
        }
    }
    
    cout << count << "\n";
    
    return 0;
}

Measured memory_bytes: 256
xy=[map(int,input().split()) for a in range(4)]
x,y=[list(i) for i in zip(*xy)]

for i in range(4):
    if x[i]==1:
        print(y[i]*6000)
    elif x[i]==2:
        print(y[i]*4000)
    elif x[i]==3:
        print(y[i]*3000)
    else:
        print(y[i]*2000)


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> H(N), A(M), B(M);
    rep(i, N) cin >> H.at(i);
    rep(i, M) cin >> A.at(i) >> B.at(i);

    vector<int> cnt(N);
    rep(i, M){
        if (H.at(A.at(i) - 1) > H.at(B.at(i) - 1)){
            cnt.at(B.at(i) - 1)++;
        }
        if (H.at(A.at(i) - 1) < H.at(B.at(i) - 1)){
            cnt.at(A.at(i) - 1)++;
        }
        if (H.at(A.at(i) - 1) == H.at(B.at(i) - 1)){
            ++cnt.at(A.at(i) - 1);
            ++cnt.at(B.at(i) - 1);
        }
        
    }
    int ans = 0;
    rep(i, N){
        if (cnt.at(i) == 0) ++ans;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

class combination
{
public:
  vector<ll> fac, finv, inv;

  combination(ll M)
  {
    fac = vector<ll>(M, 1);
    finv = vector<ll>(M, 1);
    inv = vector<ll>(M, 1);

    for (ll i = 2; i < M; i++)
    {
      fac.at(i) = fac.at(i - 1) * i % MOD;
      inv.at(i) = MOD - inv.at(MOD % i) * (MOD / i) % MOD;
      finv.at(i) = finv.at(i - 1) * inv.at(i) % MOD;
    }
  }

  ll P(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * finv.at(N - K) % MOD;
  }

  ll C(ll N, ll K)
  {
    if (N < K) return 0;
    if (N < 0 || K < 0) return 0;
    return fac.at(N) * (finv.at(K) * finv.at(N - K) % MOD) % MOD;
  }

  ll H(ll N, ll K)
  {
    return C(N + K - 1, K);
  }
};

int main()
{
  ll X, Y;
  cin >> X >> Y;
  if (X < Y)
    swap(X, Y);

  if ((X + Y) % 3 != 0)
    FINALANS(0);
  ll N = (X + Y) / 3;

  if ((N + X - Y) % 2 != 0 || (N - X + Y) % 2 != 0)
    FINALANS(-1);
  ll A = (N + X - Y) / 2;
  ll B = (N - X + Y) / 2;

  combination com(2 * 1e6 + 10);
  ll ans = com.C(N, A);
  cout << ans << endl;
}

Measured memory_bytes: 47104
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+') {
		cout << a + b << endl;
	}
	else {
		cout << a - b << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,s=0,ma=0,p;
	vector<int> x,y;
	priority_queue<int,vector<int>,less<int> > q;
	scanf("%d%d",&n,&m);
	x.resize(n); 
	y.resize(n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		if(x[i]>ma)
		{
			ma=x[i];
			p=i;
		}
	}
	for(i=0;i<n;i++)
	{
		if(y[i]>ma&&i!=p)
		{
			q.push(y[i]);
		}
	}
	q.push(0);
	while(m)
	{
		if(y[p]>=m)
		{
			s++;
			break;
		}
		if(ma>q.top())
		{
			s++;
			m-=ma;
		}
		else
		{
			s++;
			m-=q.top();
			q.pop();
		}
	}
	printf("%d",s);
	return 0;
} 

Measured memory_bytes: 1660