akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (n == i * j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
 #define _USE_MATH_DEFINES 
 #include <math.h> 
 
 
 int main(){ 
     int a, b, angle; 
     double s, l, h; 
 
 
     scanf("%d %d %d", &a, &b, &angle); 
     // sin(), cos(), tan()は角度がラジアン 
     // 度数法からラジアン法への変換：角度(ラジアン)＝角度(度数)*π/180 
     // 定数としてπを使うには：math.hのdefineを利用する。 
     // 参考：dandelion's log » VC++でM_PIが使えなかった理由判明 http://www.atinfinity.info/blog/archives/14 
     h=b*sin(angle*M_PI/180.0); 
     s=a*h/2; 
     l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0))); 
     printf("%f\n", s); 
     printf("%f\n", l); 
     printf("%f\n", h); 
 
 
     return 0; 
 } 



Measured memory_bytes: 2116
#include <iostream>

using namespace std;

template<int SIZE>
class DisjointSetsForests {
    int p[SIZE];
    int rank[SIZE];
public:
    void MakeSet(int x) { p[x] = x; rank[x] = 0; }
    void Union(int x, int y) { Link( FindSet(x), FindSet(y) ); }
    int FindSet(int x) {
        if (x != p[x]) p[x] = FindSet( p[x] );
        return p[x];
    }
    bool IsSameSet(int x, int y) { return FindSet(x) == FindSet(y); }
    void Link(int x, int y) {
        if (rank[x] > rank[y]) p[y] = x;
        else {
            p[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
    }
};
typedef DisjointSetsForests<10000> UnionFind;



int main() {
    int n, q;
    cin >> n >> q;
    UnionFind uf;
    for (int i = 0; i < n; i++) {
        uf.MakeSet(i);
    }
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            uf.Union(x, y);
        } else {
            if (uf.IsSameSet(x, y)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3168
#include<stdio.h>
#include<string.h>
#include<math.h>

int main() {
	int x, y, c = 1;
	scanf("%d", &x);

	y = x;

	while (y % 360 != 0) {
		y += x;
		c++;
	}
	printf("%d", c);
}


Measured memory_bytes: 1700
import numpy as np
import copy

a = map(int,raw_input().split())
H = a[0]
W = a[1]
A = []
for idx in xrange(H):
  A.append( list(raw_input()) )

def textMap(A):
  A = np.array(A, dtype='S')
  A[A!='0'] = '#'
  A[A=='0'] = '.'
  texts = []
  for vec in A:
    texts.append( ''.join(vec) )
  return '\n'.join(texts)

def myfunc(H,W,A):
  A = np.array(A)
  A[A=='#'] = 1
  A[A=='.'] = 0
  A = np.array(A, dtype=np.int)
  T = np.zeros((H,W), dtype=np.int)
  O = np.zeros((H,W), dtype=np.int)
  T[:,0] = 1
  O[:,-1] = 1
  if H%2 == 0:
    for idx in xrange(H/2):
      T[idx*2,1:-1] = 1
      O[idx*2+1,1:-1] = 1
  else:
    for idx in xrange(H/2):
      T[idx*2,1:-1] = 1
      O[idx*2+1,1:-1] = 1
    T[-1,1:-1] = 1
  T[A==1] += 1
  O[A==1] += 1

  tT = textMap(T)
  tO = textMap(O)
  print '\n'.join([tT,'',tO])

myfunc(H,W,A)

Measured memory_bytes: 26532
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        return a;
    }

    gcd(b, a % b)
}

fn main() {
    let n: usize;
    input!(n);
    let mut l = vec![0];
    let mut r = vec![0];
    let v = input_vector::<usize>();

    for i in 0..n {
        let buf = *l.last().unwrap();
        l.push(gcd(v[i], buf));
    }
    for i in (0..n).rev() {
        let buf = *r.last().unwrap();
        r.push(gcd(v[i], buf));
    }

    let mut ans = 0;
    r.push(0);
    for z in 0..n {
        ans = std::cmp::max(ans,gcd(l[z], r[n - 1 - z]));
    }
    p(ans);
}

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


using namespace std;


const int MAXN = 100 * 1000 + 23;








int n, a[MAXN];


int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int mx = *max_element(a, a + n), mn = *min_element(a, a + n), x = count(a, a + n, mx), y = count(a, a + n, mn);
    if (mx - mn > 1) return cout << "No", 0;
    if (mx == mn) return cout << ((mx <= n / 2 || mx == n - 1)? "Yes": "No"), 0;
    if (mx >= y + 1 && mx <= y + x / 2)
        return cout << "Yes", 0;
    cout << "No";
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
  int N;
  scanf("%d",&N);
  char S;
  int flag = 0;

  for(int i = 0;i < N;i++){
    scanf("%c",&S);
    if(S == 'Y'){
      flag = 1;
      break;
    }
  }

  if(flag){
    printf("Four\n");
  }else{
    printf("Three\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
#define fr first
#define sc second
typedef pair<int,int> Pt;
int main(){
  int n;
  while(cin >> n , n){
    int cnt[1001] = {0},ogimother = 0;
    vector< pair<Pt,Pt> > all;
    bool doing = true,nakamura[1001] = {};
    for(int i = 0 ; i < n ; i++ ){
      int I,U,A,P;
      cin >> I >> U >> A >> P;
      all.push_back(make_pair(Pt(-A,P),Pt(I,U)));
    }
    sort(all.begin(),all.end());

    while(ogimother < 26 && doing ){
      doing = false;
      for(int i = 0 ; i < n ; i++ ){
        if(nakamura[i]) continue;
        if(ogimother < 10){
          if(cnt[all[i].sc.sc] < 3){
            cnt[all[i].sc.sc]++;
            ogimother++;
            nakamura[i]  = true;
            doing = true;
            cout << all[i].sc.fr << endl;
          }
        }else if(ogimother < 20){
          if(cnt[all[i].sc.sc] < 2){
            cnt[all[i].sc.sc]++;
            ogimother++;
            nakamura[i]  = true;
            doing = true;
            cout << all[i].sc.fr << endl;
          }
        }else if(ogimother < 26){
          if(!cnt[all[i].sc.sc]){
            cnt[all[i].sc.sc]++;
            ogimother++;
            nakamura[i]  = true;
            doing = true;
            cout << all[i].sc.fr << endl;
          }
        }
      }
    }
  }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int main(){
    int a,b,c;
    string s,t,q;
    cin>>s;
    if(s[0]=='9' || s[1]=='9') cout<<"Yes\n";
    else cout<<"No\n";
    return(0);
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
 
enum face {
  TOP,
  FRONT,
  RIGHT,
  LEFT,
  BACK,
  BOTTOM
};
 
class dice {
  public:
    dice();
    void setDice(int spot, int eye);
    int getSpot(int top);
    void rollNorth();
    void rollSouth();
    void rollEast();
    void rollWest();
    void rollRight();
    void rollLeft();
    std::vector<dice> all_rolls();
 
    int& operator[] (face f) {return id[f];}
    const int& operator[] (face f) const {return id[f];}
    bool operator==(const dice &b) const {
      const dice &a = *this;
      return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
             a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
             a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
    }
 
  private:
    void roll(face a, face b, face c, face d);
    std::vector<int> id;
};
 
dice::dice() {
  id.resize(6);
}
 
void dice::setDice(int spot, int eye) {
  switch(eye) {
    case TOP:
      id[TOP] = spot;
      break;
    case BOTTOM:
      id[BOTTOM] = spot;
      break;
    case FRONT:
      id[FRONT] = spot;
      break;
    case BACK:
      id[BACK] = spot;
      break;
    case LEFT:
      id[LEFT] = spot;
      break;
    case RIGHT:
      id[RIGHT] = spot;
      break;
  }
}
 
int dice::getSpot(int top) {
  return id[top];
}
 
void dice::rollNorth() {
  roll(TOP, FRONT, BOTTOM, BACK);
}
 
void dice::rollSouth() {
  roll(TOP, BACK, BOTTOM, FRONT);
}
 
void dice::rollEast() {
  roll(TOP, LEFT, BOTTOM, RIGHT);
}
 
void dice::rollWest() {
  roll(TOP, RIGHT, BOTTOM, LEFT);
}
 
void dice::rollRight() {
  roll(FRONT, LEFT, BACK, RIGHT);
}
 
void dice::rollLeft() {
  roll(FRONT, RIGHT, BACK, LEFT);
}
 
std::vector<dice> dice::all_rolls() {
  std::vector<dice> ret;
  for(int k = 0; k < 6; (k&1 ? rollEast(): rollNorth()), ++k) {
    for(int i = 0; i < 4; rollRight(), ++i) {
      ret.push_back(*this);
    }
  }
  return ret;
}
 
void dice::roll(face a, face b, face c, face d) {
  int tmp = id[a];
  id[a] = id[b];
  id[b] = id[c];
  id[c] = id[d];
  id[d] = tmp;
}
 
int main() {
  int d;
  dice di;
  for(int i = 0; i < 6; ++i) {
    std::cin >> d;
    di.setDice(d, i);
  }
  std::vector<dice> v = di.all_rolls();
 
  int n;
  int x, y;
  for(std::cin>>n;  n > 0; --n) {
    std::cin >> x >> y;
    for(int i = 0; i < v.size(); ++i) {
      if(v[i][TOP] == x && v[i][FRONT] == y) {
        std::cout << v[i][RIGHT] << std::endl;
      }
    }
  }
 
  return 0;
}


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

int grow(int h[],int l,int r){
    int count=0;
    for(int i=l;i<=r;i++){
        h[i]-=1;
        if(h[i]==0) count+=1;
    }
    return count;
}


int main(){
    int n;
    cin >> n;
    int h[n];
    int count = n;
    for(int i=0;i<n;i++){
        cin >> h[i];
        if(h[i]==0) count-=1;;
    }
    
    int count_ =0;
    while(count>0){
        int l=0;
        int r=n-1;
        for(int i=0;i<n;i++){
            if(h[i]>0){
                l = i;
                break;
            }
        }
        for(int j=l+1;j<n;j++){
            if(h[j]==0){
                //cout << j << " " <<endl;
                r = j - 1;
                break;
        
            }
        }
        //cout << l << " " << r << endl;
        //exit(1);
        int e = grow(h,l,r);
        count -= e;
        count_ += 1;
    }


    cout << count_ << endl;

    return 0;
}


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

int main(){
  int n, c; cin >> n >> c;
  int d[c][c];
  rep(i, c)rep(j, c) cin >> d[i][j];
  int cnt[3][c];
  rep(i, 3)rep(j, c) cnt[i][j] = 0;
  rep(i, n)rep(j, n){
    int g; cin >> g;
    cnt[(i+j)%3][g-1]++;
  }
  int ans = 1000000000;
  rep(i, c)rep(j, c)if(j!=i)rep(k, c)if(k!=i && k!=j){
    int sum = 0;
    rep(l, c) sum += cnt[0][l] * d[l][i] + cnt[1][l] * d[l][j] + cnt[2][l] * d[l][k];
    ans = min(ans, sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#                         author:  kagemeka 
#                         created: 2019-11-07 23:33:56(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n = int(sys.stdin.readline().rstrip())
    s = sys.stdin.readline().rstrip()

    max_count = 0
    for i in range(1, n):
        s1, s2 = s[:i], s[i:]
        count = 0
        for l in set(s1):
            if l in s2:
                count += 1
        max_count = max(count, max_count)
    
    print(max_count)





if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 3060
//   <<In The Name Of God>>
// PTD
/*
ID: alimora2
LANG: C++11
TASK: PROB
*/
#include <bits/stdc++.h>

#define sqr(A) (A) * (A)
using namespace std;
typedef long long ll;

bool ans(int x) {
	while (x) {
		if (x % 10 == 9)
			return 1;
		x /= 10;
	}
	return 0;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n;
	cout << (ans(n) ? "Yes" : "No") << endl;
}

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

int main(){
	string s1,s2;
	cin >> s1 >> s2;
	
	//d[i][j]:=?????????s1???1?????????~i??????????????§?????¨??????????????¨?????????s2???1?????????~j??????????????§?????¨?????????????????¨????????¢
	//(index???0?????¨??????????????????????????¨???)
	int d[1001][1001]={0};
	
	//????????????????????????0??????????????????????????\?????????????¶???????????????????
	for(int i=0; i<=s1.size(); ++i) d[i][0]=i;
	for(int i=0; i<=s2.size(); ++i) d[0][i]=i;
	
	for(int i=1; i<=s1.size(); ++i){
		for(int j=1; j<=s2.size(); ++j){
			int tmp = d[i-1][j-1];
			if(s1[i-1]!=s2[j-1]) tmp++;
			
			d[i][j] = min(tmp, min(d[i-1][j]+1,d[i][j-1]+1));
		}
	}
	
	printf("%d\n", d[s1.size()][s2.size()]);
}



Measured memory_bytes: 7200
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



n = int(input())
a = list(map(int, input().split()))
from collections import Counter
def sub(x):
    l = [1 if item>=x else -1 for item in a]
    count = [0] * (2*n+2)
    count[n] = 1
    i = n
    cumsum = 1
    ans = 0
    for item in l:
        i += item
        if item==1:
            cumsum += count[i]
        else:
            cumsum -= count[i+1]
        ans += cumsum
        count[i] += 1
        cumsum += 1
    return ans

l = 0
r = 10**9+1
tmp = (n+1)*n//2
thre = tmp//2 + tmp%2
while l<r-1:
    m = (l+r)//2
    if sub(m)>=thre:
        l = m
    else:
        r = m
print(l)

Measured memory_bytes: 128588
function Main(input) {
  var inputs = input.split('\n');

  var num = Math.floor(inputs[0]);
  
  var kyoku = [];
  var zikan = [];
  var ans = 0;
  
  for (var i = 1; i <= num; i++) {
    var line = inputs[i].split(' ');
    kyoku.push(line[0]);
    zikan.push(line[1]);
  }
  
  var asleep = inputs[num + 1];
  var sleep = kyoku.indexOf(asleep);
  
  for (var i = sleep + 1; i < kyoku.length; i++) {
    ans += Math.floor(zikan[i]);
  }
  console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22076
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

def find(x):
    if node[x] < 0:
        return x
    else:
        node[x] = find(node[x])
        return node[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    ret = False
    if x != y:
        ret = True
        if rank[x] > rank[y]:
            node[x] += node[y]
            node[y] = x
        else:
            node[y] += node[x]
            node[x] = y
            if rank[x] == rank[y]:
                rank[y] += 1
    return ret

def is_same(x, y):
    return find(x) == find(y)

def size(x):
    return -node[find(x)]

n, m = map(int,input().split())
node = [-1 for i in range(n + 1)]
rank = [0 for i in range(n + 1)]
e = [[int(i) for i in input().split()] for i in range(m)]
ans = deque()
num = int((n * (n - 1)) // 2)
s = 0
for i in e[::-1]:
    s1 = size(i[0])
    s2 = size(i[1])
    ans.appendleft(num)
    if unite(i[0], i[1]):
        num -= s1 * s2
for i in ans:
    print(i)


Measured memory_bytes: 30256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define fi first
#define se second
#define pb push_back
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

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

string s;

void input() {
	cin >> s;
}

void solve() {
    fore(i, 0, (int)s.size()) {
    	if (i & 1) {
    		if (!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
    			cout << "No\n";
    			return;
    		}
    	} else {
    		if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
    			cout << "No\n";
    			return;
    		}
    	}	
    }
    cout << "Yes\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	input();
	solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int N;
    char s[101];
    scanf("%d", &N);
    scanf("%s", s);
    int countR = 0; 
    int countB = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'R') {
            countR++;
        } else {
            countB++;
        }
    }
    if (countR > countB) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 128
def main():
    N = int(input())
    a = [int(input()) for _ in range(N)]
    i = 1
    cnt = 0
    flag = False

    for _ in range(N):
        cnt += 1
        i = a[i - 1]

        if i == 2:
            flag = True
            break

    if flag == True:
        print(cnt)
    else:
        print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13052
X = int(input())
lo = 1
hi = X
while hi - lo > 1:
    m = (hi+lo)//2
    if m*(m+1)//2 >= X:
        hi = m
    else:
        lo = m
if lo*(lo+1)//2 >= X:
    print(lo)
else:
    print(hi)


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

typedef long long int ll;
typedef pair<ll, ll> Pair;



int main() {
    int N;
    string S;
    
    cin >> N >> S;

    int ans = 1;
    rep(i, N - 1) if(S[i] != S[i + 1]) ans++;
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int N, M, X, Y;
	std::cin >> N >> M >> X >> Y;

	std::vector<int> x( N ), y( M );
	for ( int i = 0; i < N; i++ )
	{
		std::cin >> x[i];
	}

	for ( int i = 0; i < M; i++ )
	{
		std::cin >> y[i];
	}

	bool isWar = false;
	std::sort( x.begin(), x.end() );
	std::sort( y.begin(), y.end() );

	if ( x[N - 1] >= y[0] )
	{
		// xnの一番大きいやつがymの一番小さいやつより大きかったらダメ
		isWar = true;
	}

	for ( int i = x[N - 1] + 1; i <= y[0]; i++ )
	{
		if ( ( X >= i ) || ( i > Y ) )
		{
			isWar = true;
		}
	}

	if ( isWar )
	{
		std::cout << "War" << std::endl;
	}
	else
	{
		std::cout << "No War" << std::endl;
	}

	return ( 0 );
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Registration
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

char s[16], t[16];

/* subroutines */

/* main */

int main() {
  scanf("%s%s", s, t);

  int n = strlen(s), m = strlen(t);;
  if (! strncmp(s, t, n) && n + 1 == m) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 3228
for i in range (1000000000000):
    n,x = list(map(int,input().split()))
    if n == 0:
        break
    else:
        k = 0
        for i in range (1,n + 1):
            for j in range (i + 1,x + 1 - i):
                if n >= x - i - j > j:
                    k = k + 1
        print(k)


Measured memory_bytes: 5596
N,K = map(int,input().split())

T = []

for i in range(N):
    t = int(input())
    T.append(t)

T.sort()

A = float("infinity") 
for i in range(N-K+1):
    a = T[i+K-1] - T[i]
    A = min(A,a)

print(A)

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

long long A, B, N;

int main(){
	cin >> A >> B >> N;
	long long ans = (A * N) / B - A * (N / B);
	long long pos2 = (N / B) * B - 1;
	ans = max(ans, (A * pos2) / B - A * (pos2 / B));
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

int main(int argc, char *argv[])
{
    ll n, a, b;
    ll ans;

    std::cin >> n >> a >> b;

    const ll x = n / (a + b);
    ans = a * x;

    if (n - x * (a + b) < a) {
        ans += n - x * (a + b);
    } else {
        ans += a;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fly ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define ll long long
#define inf 100000000000
using namespace std;

int main(int argc, char const *argv[]) {
  fly;
  ll n,k;
  cin >> n >> k;
  std::vector<ll> ara(n);
  for(int i = 0;i<n;i++)cin >> ara[i];

  ll dp[n+1] {inf};
  dp[0] = 0;
  for(int i = 1;i<n;i++){
    dp[i] = dp[i-1] + abs(ara[i]-ara[i-1]);
    for(int j = 2;i-j>=0 && j<=k;j++){
      dp[i] = min(dp[i], dp[i-j]+ abs(ara[i]-ara[i-j]));
    }
  }
  cout << dp[n-1] << endl;

  return 0;
}

Measured memory_bytes: 4720
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
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")
}

//main function
fn main() {
    let a: i8 = read();
    let b: i8 = read();
    if a<b {
	for _i in 0..b{
	    print!("{}",a);
	}
	println!("");
    }else{
	for _i in 0..a{
	    print!("{}",b);
	}
	println!("");
    }
    
}


Measured memory_bytes: 4352
n, m, l = gets.chomp.split.map(&:to_i)

a = []
n.times do
  a << gets.chomp.split.map(&:to_i)
end

b = []
m.times do
  b << gets.chomp.split.map(&:to_i)
end

a.each do |ai|
  row = []
  b.transpose.each do |bi|
    sum = 0
    ai.zip(bi).each do |aij, bij|
      sum += aij * bij
    end
    row << sum
  end
  puts row.join(" ")
end

Measured memory_bytes: 6352
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    string s; cin >> s;
    int n=s.size();

    int ans = 0;
    rep(i, n-1){
        if(s[i]!=s[i+1]) ans++;
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3704
n = gets.to_i
c = gets.split.to_a
h = {}
n.times do |i|
  if h[c[i].to_i]
    h[c[i].to_i] += 1
  else
    h[c[i].to_i] = 1
  end
end
s = h.select{|k, v| v >= 4}.keys.sort{|a, b| b<=>a}
t = h.select{|k, v| v >= 2}.keys.sort{|a, b| b<=>a}
ans = 0
if s.size > 0
  ans = s[0] * s[0]
end
if t.size > 1
  ans = t[0] * t[1] if ans < t[0] * t[1]
end
puts ans

Measured memory_bytes: 16268
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

typedef struct UnionFindTree{
    vector<int> par;

    UnionFindTree(int n){
        par.resize(n, -1);
    }

    bool is_root(int x){
        return par[x]<0;
    }

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

    int size(int x){
        return -par[find(x)];
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

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

    void clear(){
        fill(par.begin(), par.end(), -1);
    }
}UF;

int h, w;

void solve(){
    char c[h][w];
    rep(i, h)rep(j, w) scanf(" %c", &c[i][j]);
    pii p[4] = {{0, 0}, {0, w - 1}, {h - 1, 0}, {h - 1, w - 1}};
    UF uf(h * w);
    rep(x, h)rep(y, w)if(c[x][y] == '.'){
        if(x + 1 < h && c[x + 1][y] == '.'){
            uf.unite(x * w + y, (x + 1) * w + y);
        }
        if(y + 1 < w && c[x][y + 1] == '.'){
            uf.unite(x * w + y, x * w + y + 1);
        }
    }
    rep(k, 4)rep(l, 4){
        if(!uf.same(p[k].fi * w + p[k].se, p[l].fi * w + p[l].se)){
            puts("NO");
            return;
        }
    }

    rep(i, h)rep(j, w)if(c[i][j] == '.'){
        bool flag = true;
        rep(k, 4)if(i == p[k].fi && j == p[k].se){
            flag = false;
            break;
        }
        if(!flag) continue;
        c[i][j] = '#';
        uf.clear();
        rep(x, h)rep(y, w)if(c[x][y] == '.'){
            if(x + 1 < h && c[x + 1][y] == '.'){
                uf.unite(x * w + y, (x + 1) * w + y);
            }
            if(y + 1 < w && c[x][y + 1] == '.'){
                uf.unite(x * w + y, x * w + y + 1);
            }
        }
        rep(k, 4)rep(l, 4){
            if(!uf.same(p[k].fi * w + p[k].se, p[l].fi * w + p[l].se)){
                puts("NO");
                return;
            }
        }
        c[i][j] = '.';
    }
    puts("YES");
}

int main(){
    while(scanf("%d%d", &h, &w) && h){
        solve();
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  vector<vector<int>> cnts(1), cntt(1);
  vector<char> cs(0), ct(0);
  cs.push_back(s.at(0));
  ct.push_back(t.at(0));
  for (int i = 0; i < n; i++) {
    if (i > 0 && s.at(i) != s.at(i - 1)) {
      for (int j = 0; j < cs.size(); j++) {
        if (s.at(i) == cs.at(j)) {
          cnts.at(j).push_back(i);
          break;
        }
        if (j == cs.size() - 1) {
          cs.push_back(s.at(i));
          vector<int> x = {i};
          cnts.push_back(x);
        }
      }
    }
    else cnts.at(cnts.size() - 1).push_back(i);
  }
  for (int i = 0; i < n; i++) {
    if (i > 0 && t.at(i) != t.at(i - 1)) {
      for (int j = 0; j < ct.size(); j++) {
        if (t.at(i) == ct.at(j)) {
          cntt.at(j).push_back(i);
          break;
        }
        if (j == ct.size() - 1) {
          ct.push_back(t.at(i));
          vector<int> x = {i};
          cntt.push_back(x);
        }
      }
    }
    else cntt.at(cntt.size() - 1).push_back(i);
  }
  if (cnts == cntt) Yes();
  else No();
}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int x, n;
    cin >> x >> n;
    vector<int> vec(100 + 2, 0);
    for (int i = 0; i < n; ++i) {
        int val;
        cin >> val;
        vec[val] = 1;
    }
    int ans = 1000;
    for (int i = 0; i <= 101; ++i) {
        int nabs = abs(i - x);
        int prev = abs(x - ans);
        if (vec[i] == 0 && (nabs < prev || (nabs == prev && i < ans))) {
            ans = i;
        }
    }
    cout << ans << '\n';
}

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

    int q = 1;

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

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

int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    if(n == 1) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> row(n);
    for(int i=0; i<n; i++){
        if(s[i] == 'L') row[i] = 0;
        else row[i] = 1;
    }
    vector<int> l,r;
    auto t = row.begin() + 1;
    int state = row[0];
    bool f = false;
    while(t != row.end()){
        if(*t == state) {
            t++;
        }
        else {
            if(state == 0){
                if(f){
                    l.push_back(2);
                }
                else{
                    l.push_back(1);
                    f = true;
                }
            }
            else {
                if(f){
                    r.push_back(2);
                }
                else{
                    r.push_back(1);
                    f = true;
                }
            }
            state = *t;
            t++;
        }
    }
    if(state == 0){
        if(f){
            l.push_back(1);
        }
        else {
            l.push_back(0);
        }
    }
    else {
        if(f){
            r.push_back(1);
        }
        else {
            r.push_back(0);
        }
    }

    int ans = 0;
    if(row[0] == 1 && row[1] == 1) ans++;
    if(row[n-1] == 0 && row[n-2] == 0) ans++;
    for(int i=1; i<n-1; i++){
        if(row[i] == 0 && row[i-1] == 0) ans++;
        if(row[i] == 1 && row[i+1] == 1) ans++;
    }
    int ll =0, rr = 0;
    sort(l.begin(),l.end(),greater<int>());
    sort(r.begin(),r.end(),greater<int>());
    int m = l.size();
    for(int i=0; i<min(m,k); i++){
        ll += l[i];
    }
    m = r.size();
    for(int i=0; i<min(m,k); i++){
        rr += r[i];
    }
    cout << max(ll,rr) + ans << endl;
    return 0;
}



Measured memory_bytes: 1404
#include <iostream>
#include <stdio.h>
using namespace std;

int f[110000],pr[11000];

int main() {
	int n=0,i,j,s=0;
	for (i=2;i<110000;i++) {
		if (f[i]==0) { s+=i; pr[n++]=s; for (j=i;j<110000;j+=i) f[j]=1;}
		}
	while(cin >> n) {
		if (n==0) break;
		cout << pr[n-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1632
N = int(input())
S = input()
list = [0]*N
for i in range(N):
    A = S[:i]
    B = S[i:]
    A = set(A)
    B = set(B)
    for j in A:
      if j in B:
        list[i] += 1
list = sorted(list)
print(list[-1])

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

typedef long long ll;

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

    ll N; cin >> N;

    ll l = 1, r = N+1, c;
    while (r - l > 1) {
        c = l + (r - l)/2;
        if (c * (c+1)/2 <= N) {
            l = c;
        } else {
            r = c;
        }
    }
    
    ll s = l*(l+1)/2;
    for (ll a = 1; a <= l; a++) {
        cout << (a +(l-a+1<=N-s?1:0))<< endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  long long N;
  cin >> N;

  long long ans = 0;

  for (; N > 0; N--)
  {
    if(N%3 != 0 && N%5 != 0){
      ans += N;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3184
#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
typedef pair<long long,int> pii;
 
int main(){
  int w,h,rw,rh;
  priority_queue<pii,vector<pii>,greater<pii> > q;
  scanf("%d %d",&w,&h);
  rw = w+1;
  rh = h+1;
  for(int i=0;i<w;i++){
    long long cost;
    scanf("%lld",&cost);
    q.push(make_pair(cost,1));
  }
  for(int i=0;i<h;i++){
    long long cost;
    scanf("%lld",&cost);
    q.push(make_pair(cost,0));
  }
  long long int ans = 0;
  while(!q.empty()){
    long long c = q.top().first;
    int x = q.top().second;
    q.pop();
    if(x==1){
      ans+=c*rh;
      rw--;
    }else if(x==0){
      ans+=c*rw;
      rh--;
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 4464
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main(void){
   int a, b, c, ans=1, cnt=0;
    std::cin >> a >> b >> c;
    while(true){
        cnt=cnt+a;
        if(ans%7==0){
            cnt=cnt+b;
        }
        //std::cout << cnt << endl;
        if(cnt>=c) break;
        ans++;
    }
    std::cout << ans << endl;
}



Measured memory_bytes: 3116
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll a, v, b, w, t; cin >> a >> v >> b >> w >> t;
  if (a > b) swap(a, b);
  if (v <= w) {
    cout << "NO\n";
    return 0;
  }
  cout << (b - a <= t * (v - w) ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 3656
int main(){
    int h,w,a=0;
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0&&w==0){
            break;
        }else{
            for(;h>0;h--){
            for(int i=w;i>0;i--){
                putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
        }
    }
}


Measured memory_bytes: 2080
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B, C;
	cin >> A >> B >> C;

	if (A + B >= C)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}

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

int main(){

    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; i++) cin >> S[i];

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            char count = '0';
            if(S[i][j] == '#') continue;
            if(i - 1 != -1 && j - 1 != -1 && S[i - 1][j - 1] == '#') count++;
            if(i - 1 != -1 && S[i - 1][j] == '#') count++;
            if(i - 1 != -1 && j + 1 != W && S[i - 1][j + 1] == '#') count++;
            if(j - 1 != -1 && S[i][j - 1] == '#') count++;
            if(j + 1 != W && S[i][j + 1] == '#') count++;
            if(i + 1 != H && j - 1 != -1 && S[i + 1][j - 1] == '#') count++;
            if(i + 1 != H && S[i + 1][j] == '#') count++;
            if(i + 1 != H && j + 1 != W && S[i + 1][j + 1] == '#') count++;
            S[i][j] = count;
        }
    }

    for(int i = 0; i < H; i++) cout << S[i] << endl;

    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
int LIS(vi in){//Longest Increasing Subsequence
	int n=in.size();
	vi out(n+1,inf);
	rep(i,n){
		*upper_bound(all(out),in[i])=in[i];
	}
	return lower_bound(all(out),inf)-out.begin();
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i],in[i]*=-1;
	cout<<LIS(in)<<endl;
}












Measured memory_bytes: 2560
using System;
using System.Linq;

class Program
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var aArray = Console.ReadLine().Split();

        long ans = 0;

        long prev = 0;
        for (int i = 0; i < n; i++)
        {
            var current = long.Parse(aArray[i]);

            var f = current - prev;

            if (f >= 0)
            {
                prev = current;
            }
            else
            {
                prev = current - f;
                ans += -f;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 45380
#include<bits/stdc++.h>
#define ll long long
#define MAXN 200005
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;
ll h[100005];
int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    set<int>s;
    for(int j=0;j<m;j++){
        int a,b;
        cin>>a>>b;
        if(h[a]<h[b]){
            s.insert(a);
        }
        else if(h[b]<h[a]){
            s.insert(b);
        }
        else{
            s.insert(a);
            s.insert(b);
        }
    }
    int ans=n-s.size();
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(void)
{
  int a,b;

	cin>>a>>b;

	if(a > 12){
		;
	}
	else if(a < 6){
		b = 0;
	}
	else{
		b/=2;
	}

	cout<<b<<endl;


	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var A = G;
		var cnt = new long[N + 1, 20];
		for (var i = 0; i < N; i++) for (var j = 0; j < 20; j++) { cnt[i + 1, j] = cnt[i, j] + ((A[i] & (1 << j)) != 0 ? 1 : 0); }
		var r = 0;
		var ans = 0L;
		for (var l = 0; l < N; l++)
		{
			while (r <= l) r++;
			while (r <= N)
			{
				var flag = true;
				for (var i = 0; flag && i < 20; i++) flag &= cnt[r, i] <= cnt[l, i] + 1;
				if (!flag) break;
				r++;
			}
			ans += r - l - 1;
		}
		WriteLine(ans);
	}
}


Measured memory_bytes: 64476
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)
    else:
        break



Measured memory_bytes: 5596
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	values := make([]float64, n)
	for i := 0; i < n; i++ {
		values[i] = float64(readInt())
	}
	fmt.Println(solve(values))
}

func solve(values []float64) float64 {
	x := values[0]
	y := values[1]
	if len(values) == 2 {
		return pot(x, y)
	}
	for len(values) > 1 {
		// 最小値を２つ選ぶ
		minIndex1, min1 := min(values)
		values = remove(values, minIndex1)
		minIndex2, min2 := min(values)
		values = remove(values, minIndex2)
		// 鍋に入れた結果を戻す
		newValue := pot(min1, min2)
		values = append(values, newValue)
	}
	return values[0]
}

func pot(x, y float64) float64 {
	return (x + y) / 2
}

// スライス内の最小値を取得する
func min(nums []float64) (index int, min float64) {
	min = math.MaxFloat64
	for i, n := range nums {
		if n < min {
			index = i
			min = n
		}
	}
	return
}

// ある要素を削除したスライスを返す
func remove(nums []float64, i int) []float64 {
	return append(nums[:i], nums[i+1:]...)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle {
    int f[N2];
    int space;
    string path;
    
    bool operator < ( const Puzzle &p ) const {
        for ( int i = 0; i < N2; i++ ) {
            if ( f[i] == p.f[i] ) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p) {
    for ( int i = 0; i < N2; i++ )
      if ( p.f[i] != (i + 1) ) return false;
    return true;
}

string bfs(Puzzle s) {
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true;
    
    while ( !Q.empty() ) {
        u = Q.front(); Q.pop();
        if ( isTarget(u) ) return u.path;
        int sx = u.space / N;
        int sy = u.space % N;
        for ( int r = 0; r < 4; r++ ) {
            int tx = sx + dx[r];
            int ty = sy + dy[r];
            if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
            v = u;
            swap(v.f[u.space], v.f[tx * N + ty]);
            v.space = tx * N + ty;
            if ( !V[v] ) {
                V[v] = true;
                v.path += dir[r];
                Q.push(v);
            }
        }
    }
    
    return "unsolvable";
}

int main() {
    Puzzle in;
    
    for ( int i = 0; i < N2; i++ ) {
        cin >> in.f[i];
        if ( in.f[i] == 0 ) {
            in.f[i] = N2;
            in.space = i;
        }
    }
    string ans = bfs(in);
    cout << ans.size() << endl;
    
    return 0;
}


Measured memory_bytes: 30612
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

template<int Modulo = MOD>
struct Mint {

	lint val;
	constexpr Mint(lint v = 0) noexcept : val(v% Modulo) { if (val < 0) val += Modulo; }

	constexpr Mint& operator+=(const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator-=(const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator*=(const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator/=(const Mint& r) noexcept {
		lint a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			lint t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}

	constexpr Mint operator+(const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator-(const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator*(const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator/(const Mint& r) const noexcept { return Mint(*this) /= r; }

	constexpr Mint operator-() const noexcept { return val ? Modulo - val : 0; }

	constexpr bool operator==(const Mint& r) const noexcept { return val == r.val; }
	constexpr bool operator!=(const Mint& r) const noexcept { return !((*this) == r); }
	constexpr bool operator< (const Mint& r) const noexcept { return val < r.val; }

	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept { return os << x.val; }
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		lint tmp; is >> tmp;
		x = Mint(tmp);
		return is;
	}

	constexpr Mint pow(lint n) const noexcept {
		Mint res = 1, tmp = val;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	int N, K;
	cin >> N >> K;

	mint ans = 0;
	for (int i = K; i <= N + 1; i++) {
		ans += (mint(1) * (2 * N - i + 1) * i - mint(1) * (i - 1) * i) / 2 + 1;
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3580