akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations as comb
from bisect import bisect_left

import numpy as np
def main():
    H, W, K = map(int, input().split())
    cells = []
    count = 0
    for _ in range(H):
        row = [w for w in input()]
        cells.append(row)

    original = np.copy(np.array(cells))
    black = np.count_nonzero(cells == '#')
    #print(f"black={black}")
    for i in range(H+1):
        for iconb in comb(range(H), i):
            for j in range(W+1):
                for jconb in comb(range(W), j):
                    cells = np.copy(original)
                    cells[iconb, :] = '-'
                    cells[:, jconb] = '-'
                    black = np.count_nonzero(cells == '#')
                    #print(f"black={black} iconb={iconb} jconb={jconb}")
                    if black == K:
                        count += 1
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26976
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/

string S;
int win;
int lose;

int main(void) {
  cin >> S;
  for(int k=0; k<15; k++){
    if(S[k]=='o') win++;
    if(S[k]=='x') lose++;
  }
  
  if(lose>=8)  cout << "NO" << endl;
  else  cout << "YES" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, T;
    cin >> K >> T;
    int temp = -1;
    for(int i = 0; i < K; i++){
    	int a; cin >> a;
    	temp = max(a, temp);
    }
    int ans = max(2*temp - K - 1, 0);
    cout << ans << endl;
    return 0;
}   

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

int main() {
	int N, K; cin >> N >> K;
	bool flag = false;
	int l = 0, r = 0;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		if (flag) {
			r++;
		}
		else {
			if (a == 1)flag = true;
			else l++;
		}
	}
	int ans = 0;
	while (l >= K) {
		ans++;
		l -= K - 1;
	}
	while (r >= K) {
		ans++;
		r -= K - 1;
	}
	ans += ceil(1. * (l + r + 1) / K);
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import math
import copy

n = int(input())
#n, k = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
num = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
#s = [input() for i in range(n)]
#s = input()
#list = list(s)
#dp = [[0 for _ in range(13)] for _ in range(13)]

dp = [[0 for _ in range(2)] for _ in range(n+1)]
dp[0][1]= -(10**9)
for i in range(n) :
    dp[i+1][0] = max(dp[i][0] + num[i], dp[i][1] - num[i])
    dp[i+1][1] = max(dp[i][0] - num[i], dp[i][1] + num[i])

print(dp[n][0])

Measured memory_bytes: 27228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

const int INF = 1e9;

int main() {
    int n, m;
    cin >> n >> m;
    int s, c, ans[n];
    fill(ans, ans+n, INF);
    bool flag = true;
    for (int i = 0; i < m; i++) {
        cin >> s >> c;
        if (ans[s - 1] == INF || ans[s - 1] == c) ans[s - 1] = c;
        else flag = false;
    }
    if (ans[0] == 0 && n > 1) flag = false;
    if (flag) {
        for (int i = 0; i < n; i++) {
            if (ans[i] == INF) {
                if (i > 0 || n == 1) cout << 0;
                else cout << 1;
            } else cout << ans[i];
        }
        cout << endl;
    } else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <set>
#include <utility>
#include <climits>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>

#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	const int mod = 1e9 + 7;
	int n, k;
	cin >> n >> k;
	ll res = 0;
	for (int i = k; i <= n + 1; ++i) {
		res += (n - i + 1 + n) * 1LL * i / 2 - (i - 1) * 1LL * i / 2 + 1;
		res %= mod;
	}
	cout << res;
}


Measured memory_bytes: 3604
n = gets.to_i
command_list = []
n.times do
  command_list << gets.chomp.split
end
list = []

while command_list.length > 0
  command = command_list.shift
  if command[0] == "insert"
    list << command[1].to_i
  elsif command[0] == "delete"
    x = list.rindex(command[1].to_i)
    if x
      list.delete_at(x)
    end
  elsif command[0] == "deleteFirst"
    list.pop
  elsif command[0] == "deleteLast"
    list.shift
  end
end

puts list.reverse.join(" ")

Measured memory_bytes: 438188
use std::io::stdin;
use std::hash::Hash;
use std::collections::BinaryHeap;
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::cmp::Ordering;

fn main(){
    let (n, m) = getpair();
    let mut graph: Graph<(i64, i64)> = Graph::new();
    for _ in 0..m {
        let input: Vec<i64> = getvec();
        let (p, q, c) = (input[0], input[1], input[2]);

        graph.entry((p, c)).or_insert_with(BTreeMap::new).insert((q, c), 0);
        graph.entry((q, c)).or_insert_with(BTreeMap::new).insert((p, c), 0);
        graph.entry((p, -1)).or_insert_with(BTreeMap::new).insert((p, c), 1);
        graph.entry((q, -1)).or_insert_with(BTreeMap::new).insert((q, c), 1);
        graph.entry((p, c)).or_insert_with(BTreeMap::new).insert((p, -1), 0);
        graph.entry((q, c)).or_insert_with(BTreeMap::new).insert((q, -1), 0);
    }
    let ans = match dijkstra(&graph, (1, -1), (n as i64, -1)) {
        Some(i) => i as i64,
        None => -1
    };
    println!("{}", ans);
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec<T: std::str::FromStr>() -> Vec<T>{
    let line = getline();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn getpair() -> (usize, usize){
    let nm = getvec();
    (nm[0], nm[1])
}

type Graph<N> = HashMap<N, BTreeMap<N, u64>>;

#[derive(PartialEq, Eq)]
struct RevOrd<M: Ord + Eq>(M);

#[allow(dead_code)]
impl <M: Ord + Eq> PartialOrd for RevOrd<M> {
    fn partial_cmp(&self, other: &RevOrd<M>) -> Option<Ordering> {
        Some(other.0.cmp(&self.0))
    }
}

#[allow(dead_code)]
impl <M: Ord + Eq> Ord for RevOrd<M> {
    fn cmp(&self, other: &RevOrd<M>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(dead_code)]
struct MinHeap<M: Ord>(BinaryHeap<RevOrd<M>>);

#[allow(dead_code)]
impl <M: Ord> MinHeap<M> {
    fn new() -> MinHeap<M> {
        MinHeap(BinaryHeap::new())
    }

    fn push(&mut self, elm: M) {
        self.0.push(RevOrd(elm))
    }

    fn pop(&mut self) -> Option<M> {
        match self.0.pop() {
            Some(RevOrd(elm)) => Some(elm),
            _ => None
        }
    }
}

fn dijkstra<N>(graph: &Graph<N>, start: N, end: N) -> Option<u64>
    where N: Eq + Ord + Hash + Copy
{
    let mut heap = MinHeap::new();
    let mut visited = HashSet::new();

    heap.push((0, start));

    while let Some((cost, current)) = heap.pop() {
        if visited.contains(&current) { continue; }
        if current == end { return Some(cost); }
        visited.insert(current);
        if let Some(edges) = graph.get(&current) {
            for (next, path_cost) in edges {
                heap.push((cost + *path_cost, next.clone()))
            }
        }
    }
    None
}

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

int n;
int k;
int color[100];
int a[100],b[100],c;
int adj[110][110];

void deepread(int k){
  int h;
  color[k]=1;
  a[k]=++c;
  for(h=0;h<n;h++){
    if(adj[k][h]==0){
      continue;
    }
    if(color[h]==0){
      deepread(h);
    }
  }
  color[k]=3;
  b[k]=++c;
}

void deep(){
  for(int i=0;i<n;i++){
    color[i]=0;
  }
  c=0;
  for(int k=0;k<n;k++){
    if(color[k]==0)deepread(k);
  }
  for(int k=0;k<n;k++){
    cout<<k+1<<" "<<a[k]<<" "<<b[k]<<endl;
  }
}


int main(){
  int num;
  cin>>n;
  int rin;
  int i=0,j=0;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      adj[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    cin>>num>>k;
    num--;
    for(j=0;j<k;j++){
      cin>>rin;
      rin--;
      adj[num][rin]=1;
    }
  }
  /*for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)cout<<" ";
      cout<<adj[i][j];
    }
    cout<<endl;
    }*/

  deep();
  return 0;
}



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

void bubbleSort(int A[], int N);

int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	bubbleSort(A, N);
	return 0;
}

void bubbleSort(int A[], int N) {
	int flag = 1;
	int cnt = 0;
	while (flag) {
		flag = 0;
		for (int i = N-1; i > 0; i--) {
			if (A[i] < A[i-1]) {
				int v = A[i];
				A[i] = A[i-1];
				A[i-1] = v;
				flag = 1;
				cnt++;
			}
		}
	}
	for (int i = 0; i <N-1; i++) {
		cout << A[i] << " ";
	}
	cout << A[N-1] << endl;
	cout << cnt << endl;
}

Measured memory_bytes: 1160
use std::io;

fn read() -> (i32, i32) {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let ans : Vec<i32> = input.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect();
    (ans[0], ans[1])
}

fn read_multi(count : i32) -> Vec<(i32, i32)>{
    (0..count).map(|_| read()).collect()
}


fn main() {
    let (count, max_time) = read();
    let inputs = read_multi(count);
    let mut min_cost = 1001;
    for (cost, time) in inputs {
        if time <= max_time && cost < min_cost {
            min_cost = cost;
        }
    }
    if min_cost == 1001 {
        println!("TLE");
        return;
    }

    println!("{}", min_cost);
}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int res = 0x3f3f3f3f;
    for (int i = 0; i < n; i++) {
        priority_queue<int> pq1, pq2;
        for (int j = 0; j < n; j++) {
            if (v[j] < v[i]) {
                while (pq1.size() > 0) pq1.pop();
            } else {
                pq1.push(-v[j]);
                if (pq1.size() >= k) {
                    int t = -pq1.top();
                    pq1.pop();
                    pq2.push(t);
                }
            }
        }
        if (pq2.size() >= q) {
            while (pq2.size() > q) pq2.pop();
            res = min(res, pq2.top() - v[i]);
        }
    }
    cout << res << endl;
}









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

int main() {
	int N, Odd[100010], Even[100010];
	cin >> N;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			cin >> Odd[i / 2];
		}
		else {
			cin >> Even[i / 2];
		}
	}
	if (N % 2 == 0) {
		for (int i = N / 2 - 1; i >= 0; i--) {
			cout << Even[i] << " ";
		}
		for (int i = 0; i < N / 2; i++) {
			cout << Odd[i];
			if (i != N / 2 - 1) cout << " ";
		}
	}
	else {
		for (int i = N / 2; i >= 0; i--) {
			cout << Odd[i] << " ";
		}
		for (int i = 0; i < N / 2; i++) {
			cout << Even[i];
			if (i != N / 2 - 1) cout << " ";
		}
	}
}

Measured memory_bytes: 2944
N =int(input())
list1 = list(map(int, input().split()))
ans = 0
max1 = list1[0]
for i in range(len(list1)-1):
    if max1 < list1[i+1]:
        max1 = list1[i+1]
    if max1>list1[i+1]:
        ans = ans+(max1-list1[i+1])
print(ans)

Measured memory_bytes: 32236
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    fp((n%2)&&(m%2));
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#include<set>
#define ws " "
#define nl "\n"
#define tc ll test; cin>>test; while(test--)
#define f(i, a, b) for(ll i = a; i<b; i++)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#include<fstream>

using namespace std;

#define pll pair<ll, ll>
bool compare(pll a, pll b)
{
	//for descending order replace with a.roll >b.roll
   if((a.ff < b.ff)||((a.ff==b.ff)&&a.ss<b.ss))
        return 1;
	else
		return 0;
}

ll power(ll x,  ll y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}


void solve()
{
  ll n;
  double d;
  cin>>n>>d;
  ll ct = 0;
  double temp, x, y;
  f(i, 0, n)
  {
      cin>>x>>y;
      temp = sqrt((x*x) + (y*y));
      if(temp<=d)
        ct++;
  }
  cout<<ct<<nl;
}


int main()
{
    fastIO;
   // tc

    //cout<<"Case #"<<i+1<<" :"<<nl;
    solve();


}


Measured memory_bytes: 3788
a, b = (int(i) for i in input().split())

count = 0
for i in range(a, b+1):
    flg = True
    s = str(i)
    for j in range(len(s)):
        if s[j] != s[-(j+1)]:
            flg = False
            break

    if flg:
        count+=1

print(count)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main () {
int n,k,x,y;
  cin>>n>>k>>x>>y;
  int ans=0;
  if (k<n){
      for (int i=1;i<=k;i++){
  ans+=x;
  }
  for (int i=k+1;i<=n;i++){
          ans+=y;
      }
      cout<<ans;
  }
  else {
      for (int i=1;i<=n;i++){
          ans+=x;
      }
      cout<<ans;
  }
  }

Measured memory_bytes: 256
<?php   
fscanf(STDIN,"%d%d",$h,$w);
$s_li=array();
for($i=0;$i<$h;$i++){
  $s_li[] = str_split(trim(fgets(STDIN)));
}


for($i=0;$i<count($s_li);$i++){
  for($j=0;$j<count($s_li[$i]);$j++){
    if($s_li[$i][$j]=="#"){
      if(isset($s_li[$i][$j-1])){
        
        //i,j-1
        if($s_li[$i][$j-1]=='.'){
          $s_li[$i][$j-1]=1;
        }elseif($s_li[$i][$j-1]=='#'){
        }else{
          $s_li[$i][$j-1]++;
        }
      }
       
      if(isset($s_li[$i][$j+1])){
         //i,j+1
        if($s_li[$i][$j+1]=='.'){
          $s_li[$i][$j+1]=1;
        }elseif($s_li[$i][$j+1]=='#'){
        }else{
          $s_li[$i][$j+1]++;
        }
      }
      
       if(isset($s_li[$i-1][$j])){
         //i-1,j
        if($s_li[$i-1][$j]=='.'){
          $s_li[$i-1][$j]=1;
        }elseif($s_li[$i-1][$j]=='#'){
        }else{
          $s_li[$i-1][$j]++;
        }
       }
        
        if(isset($s_li[$i-1][$j+1])){
          //i-1,j+1
        if($s_li[$i-1][$j+1]=='.'){
          $s_li[$i-1][$j+1]=1;
        }elseif($s_li[$i-1][$j+1]=='#'){
        }else{
          $s_li[$i-1][$j+1]++;
        }
        }
      
       if(isset($s_li[$i-1][$j-1])){
           //i-1,j-1
        if($s_li[$i-1][$j-1]=='.'){
          $s_li[$i-1][$j-1]=1;
        }elseif($s_li[$i-1][$j-1]=='#'){
        }else{
          $s_li[$i-1][$j-1]++;
        }
       }
        
       if(isset($s_li[$i+1][$j])){
           //i+1,j
        if($s_li[$i+1][$j]=='.'){
          $s_li[$i+1][$j]=1;
        }elseif($s_li[$i+1][$j]=='#'){
        }else{
          $s_li[$i+1][$j]++;
        }
       }
       if(isset($s_li[$i+1][$j-1])){
          //i+1,j-1
        if($s_li[$i+1][$j-1]=='.'){
          $s_li[$i+1][$j-1]=1;
        }elseif($s_li[$i+1][$j-1]=='#'){
        }else{
          $s_li[$i+1][$j-1]++;
        }
       }
        if(isset($s_li[$i+1][$j+1])){
          //i+1,j+1
         if($s_li[$i+1][$j+1]=='.'){
          $s_li[$i+1][$j+1]=1;
        }elseif($s_li[$i+1][$j+1]=='#'){
        }else{
          $s_li[$i+1][$j+1]++;
        }
        }
        
        
      
    }
  }
}
  


foreach($s_li as $s){
  foreach($s as $v){
    if($v=='.'){
      echo "0";
    }else{
     echo $v;
    }
  }
  echo "\n";
}



Measured memory_bytes: 4728
//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 <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
    cin>>a>>b;
    if(a<=0&&b>=0){
        cout<<"Zero"<<endl;
        return 0;
    }
    if(a>0&&b>0)cout<<"Positive"<<endl;
    if(a<0&&b<0){
        if(!((a-b)%2))
        cout<<"Negative"<<endl;
        else cout<<"Positive"<<endl;
    }
    return 0;
}

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

signed main(void)
{
	int i, n, first, second;
	cin >> n;
	vector<int> v(n);
	int a[n];
	map<int, int> score;

	first = 0;
	second = 0;
	rep(i, n)
	{
		cin >> a[i];
		v.push_back(a[i]);
		score[a[i]]++;
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	first = v.at(0);
	second = v.at(1);
	rep(i, n)
	{
		if (a[i] == first && score[first] == 1)
			cout << second << endl;
		else
			cout << first << endl;
	}
	return 0;
}


Measured memory_bytes: 9456
A, B, C, D = map(int, list(input()))

f = True

for op1 in range(2):
    for op2 in range(2):
        for op3 in range(2):
            if f == True:
                R = 0
                r = ''
                if op1 == 0:
                    R = A + B
                    r = '%s+%s' % (A, B)
                else:
                    R = A - B
                    r = '%s-%s' % (A, B)
                if op2 == 0:
                    R += C
                    r = '%s+%s' % (r, C)
                else:
                    R -= C
                    r = '%s-%s' % (r, C)
                if op3 == 0:
                    R += D
                    r = '%s+%s' % (r, D)
                else:
                    R -= D
                    r = '%s-%s' % (r, D)
                if R == 7:
                    print('%s=7' % r)
                    f = False


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

int main()
{
  string s, t;
  cin >> s >> t;

  int len = t.size();

  bool flag = false;

  for (int i = 0; i < len; ++i) {
    int tmp = t.compare(s);

    if(tmp == 0) {
      flag = true;
      break;
    }
    else s = s[len-1] + s.substr(0, len-1);
  }

  //cout << s << "\n";
  //cout << s.size() << "\n";
  //cout << t << "\n";
  
  if (flag) cout << "Yes" << "\n";
  else cout << "No" << "\n";

  return 0;
  
}


Measured memory_bytes: 3596
#include<stdio.h>

int main(){
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  
  return 0;
}


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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
typedef long long ll;
typedef pair<ll, ll> P;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<long long> dijkstra(vector<vector<pair<long long, long long>>> graph, long long s) {
    vector<long long> ans(graph.size(), -1);
    priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>>
        pq;
    pq.push({0, s});
    while (pq.size() > 0) {
        ll cur1 = 0;
        ll cur2 = 0;
        if (ans[pq.top().second] != -1) {
            pq.pop();
        } else {
            cur1 = pq.top().first;
            cur2 = pq.top().second;
            pq.pop();
            ans[cur2] = cur1;
            for (long long i = 0; i < graph[cur2].size(); i++) {
                pq.push({cur1 + graph[cur2][i].second, graph[cur2][i].first});
            }
        }
    }
    return ans;
}
const ll INF = 1LL << 60;
void bellman_ford(vector<vector<P>> &edge, vector<ll> &dist, vector<bool> &loop, int s) {
    int n = edge.size();
    dist.resize(n, INF);
    dist[s] = 0;
    for (int i = 1; i < n; i++) {
        for (int from = 0; from < n; from++) {
            if (dist[from] == INF) continue;
            for (P e : edge[from]) {
                int to = e.first;
                dist[to] = min(dist[to], dist[from] + e.second);
            }
        }
    }

    loop.resize(n, false);
    for (int i = 0; i < n; i++) {
        for (int from = 0; from < n; from++) {
            if (dist[from] == INF) continue;
            for (P &e : edge[from]) {
                int to = e.first;
                if (dist[to] > dist[from] + e.second) {
                    dist[to] = dist[from] + e.second;
                    loop[from] = true;
                    loop[to] = true;
                }
            }
        }
    }
}
int main() {
    ll n, m, t;
    cin >> n >> m;
    vector<vector<P>> graph(n);
    vector<ll> dist;
    vector<bool> loop;
    REP(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        c = -1 * c;
        graph[a].push_back({b, c});
    }
    bellman_ford(graph, dist, loop, 0);
    if (loop[n - 1] == true) {
        cout << "inf" << endl;
    } else {
        cout << -1 * dist[n - 1] << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, d, e;
    cin >> a >> c >> b >> d >> e;

    int t = (b - a) * 60 + (d - c);

    cout << t - e << endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if (A+B>2*A-1 && A+B>2*B-1){
    cout << A + B << endl;
  }
  else if (A > B){
    cout << 2*A-1 << endl;
  }
  else {
    cout << 2*B-1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

double cross(double x1,double y1,double x2,double y2)
{
	return x1*y2-x2*y1;
}

int ccw(double x1,double y1,double x2,double y2,double x3,double y3)
{
	return cross(x2-x1,y2-y1,x3-x1,y3-y1)>=0;
}

int main()
{
	for(double x[4],y[4];scanf("%lf%lf%lf%lf%lf%lf%lf%lf",x,y,x+1,y+1,x+2,y+2,x+3,y+3)==8;){
		int counter=0;
		rep(i,3)
			counter+=ccw(x[i],y[i],x[(i+1)%3],y[(i+1)%3],x[3],y[3]);
		
		cout<<(counter%3==0?"YES":"NO")<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#from numpy import*
#from scipy import*
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial
from copy import deepcopy
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)


def main():
    n,*a=map(int,open(0).read().split())
    if abs(max(a))>abs(min(a)):
        b=a.index(max(a))
        print(2*n-1)
        for i in range(n):
            print(b+1,i+1)
        for i in range(n-1):
            print(i+1,i+2)
    else:
        b=a.index(min(a))
        print(2*n-1)
        for i in range(n):
            print(b+1,i+1)
        for i in reversed(range(n-1)):
            print(i+2,i+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5088
#include<iostream>
#include<string>
using namespace std;
bool isKai(string T){
  int len=(int)(T.length());
  if(len%2==0){
    int max=len/2;
  }else{
    int max=(len-1)/2;
  }
  for(int i=0;i<len/2;i++){
    if(T[i]!=T[len-1-i]){
      return false;
    }
  }
  return true;
}
int main(){
  string S;
  cin>>S;
  int len=(int)(S.length());
  if(!isKai(S)){
    cout<<"No";
    return 0;
  }
  string K=S.substr(0,(len-1)/2);
  if(isKai(K)){
    cout<<"Yes";
    return 0;
  }
  cout<<"No";
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int V,E,s,t;
vector<vector<int>> v(10001);
vector<int> u;
int visited[10001] = {0};

void dfs(int n){
	visited[n] = 1;
	for(int i=0;i<v[n].size();i++){
		if(visited[v[n][i]]==0) dfs(v[n][i]);
	}
	u.push_back(n);
}

int main(){
	cin >> V >> E;
	for(int i=0;i<E;i++){
		cin >> s >> t;
		v[s].push_back(t);
	}
	for(int i=0;i<V;i++){
		if(visited[i]==0) dfs(i);
	}
	for(int i=V-1;i>=0;i--) cout << u[i] << endl;
}


Measured memory_bytes: 3756
#include<stdio.h>
int main()
{
	int P,Q,R,t[6],x,y,z;
	scanf("%d %d %d",&P,&Q,&R);
	 x=P+Q;
	 y=Q+R;
	 z=P+R;
	 if(x<y && x<z || x==y || x==z )
	 {
	 printf("%d\n",x)	;
	 }
	 else if(x>y && y<z || y==x || y==z)
	 {
	 	printf("%d\n",y);
	 }
	 
	 else printf("%d\n",z);
	 return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

using namespace std;


char s[200005];
int main() {
    scanf("%s", s);
    unsigned long long sol = 0;
    int a = 0;
    int n = strlen(s);
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'A') {
            a++;
        } else if (i < n - 1 && s[i] == 'B' && s[i + 1] == 'C') {
            sol += a;
            i++;
        } else {
            a = 0;
        }
    }

    cout << sol;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define NOT_FREE -1
#define FREE 1

int A[N][N];
int k,row[N],col[N],dpos[2*N-1],dneg[2*N-1];

void printboard(){
    int i,j;
    
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if(A[i][j]){
                if(row[i]!=j){
                    return;
                }
            }
        }
    }
    
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            if (row[i]==j){
                printf("Q");
            }else{
                printf(".");
            }
        }
        printf("\n");
    }
}

void putQueen(int i){
    int j;
    
    if(i==N){
        printboard();
        return;
    }
    
    for(j=0;j<N;j++){
        if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1] == NOT_FREE){
            continue;
    }
        row[i]=j;
        col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
        putQueen(i+1);
        col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
    }
}

int main(){
    int i,j,r,c;
    
    scanf("%d",&k);
    for(i=0;i<2*N-1;i++){
        dpos[i]=dneg[i]=FREE;
    }
    
    for(i=0;i<N;i++){
        col[i]=row[i]=FREE;
    }
    
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            A[i][j]=false;
        }
    }
    
    for(i=0;i<k;i++){
        scanf("%d %d",&r,&c);
        A[r][c]=true;
    }
    
    putQueen(0);
    
    return 0;
}



Measured memory_bytes: 2104
Q = gets.to_i
queries = Q.times.map { gets.split.map(&:to_i) }

queries.each do |a, b|
  a, b = [a, b].minmax

  if a == b
    puts 2 * a - 2
  elsif a + 1 == b
    puts 2 * a - 2
  else
    f = -> (c) { c ** 2 < a * b }

    ok = 1
    ng = 10 ** 18

    while (ok - ng).abs > 1
      mid = (ok + ng) / 2

      if f[mid]
        ok = mid
      else
        ng = mid
      end
    end

    if ok * (ok + 1) >= a * b
      puts 2 * ok - 2
    else
      puts 2 * ok - 1
    end
  end
end


Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl;exit(0);}else return;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	ll N, M, ans = 0; cin >> N >> M;
	V<ll> A(N+1,0);
	FOR(i, 1, N + 1) cin >> A[i];
	FOR(i, 1, N + 1) (A[i] += A[i-1])%=M;
	map<ll, ll> mp;
	FOR(i, 0, N + 1) mp[A[i]]++;
	for (auto u : mp) ans += (u.second*(u.second - 1)) / 2;
	cout << ans << endl;
	return 0;
}



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

int main()
{
	int  n;
	string s1, s2;
	int a = 0, b = 0;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s1 >> s2;
		if (s1 > s2)a += 3;
		else if (s1 < s2)b += 3;
		else {
			a++;
			b++;
		}
	}
	cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int sub = A - B;
        int add = A + B;
        int mul = A * B;
        if(sub > add){
            if(sub < mul){
                System.out.println(mul);
            }else{
                System.out.println(sub);
            }
        }else{
            if(add < mul){
                System.out.println(mul);
            }else{
                System.out.println(add);
            }
        }
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define pi acos(-1)
using namespace std;
ll n;
ll ara[100009];
ll dp[100009];
ll call(ll ind )
{
    if(ind==n-1) return 0;
    ll a=LLONG_MAX,b=LLONG_MAX;
    ll &ret=dp[ind];
    if(ret!=-1) return ret;
    if(ind+1<n) a=abs(ara[ind+1]-ara[ind])+call(ind+1);
    if(ind+2<n) b=abs(ara[ind+2]-ara[ind])+call(ind+2);
    return ret=min(a,b);
}
int  main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(ll i=0;i<n;i++) cin>>ara[i];
    cout<<call(0)<<endl;
}


Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <stdio.h>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <queue>
#include <bitset>
#include <stack>
#include <unordered_map>

using namespace std;

#define all(v) (v).begin(),(v).end()
#define SRT(v) sort(all(v))
#define rall(v) (v).rbegin(),(v).rend()
#define rSRT(v) sort(rall(v))
#define sz(a) int((a).size())
#define sc(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define PB push_back
#define mem(a, b) memset(a, b, sizeof(a))
#define MP make_pair
#define EPS 1e-9
#define Mod (ll)1000000007
#define oo (int)1<<30
#define OO (ll)1ll<<60
#define PI 3.141592653589793
#define F first
#define S second
#define pw(x) (x)*1LL*(x)

typedef stringstream ss;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii>vii;
typedef pair<int, ll> il;
typedef vector<vector<ii>> vvii;
typedef vector<vector<il>> vvil;

//ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
//int dcmp(long double x, long double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

//string alpha = "abcdefghijklmnopqrstuvwxyz";
//string vowels = "aeoui";
//string pm = "AHIMOTUVWXY";

//const int dx[] = { 0, -1, 0, 1, -1, -1, 1, 1 };
//const int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };

string a, b, ans;
int dp[3005][3005];

int solve(int i, int j)
{
	if (i == a.size() || j == b.size()) return 0;
	if (~dp[i][j]) return dp[i][j];
	if (a[i] == b[j]) return dp[i][j] = solve(i + 1, j + 1) + 1;
	return dp[i][j] = max(solve(i + 1, j), solve(i, j + 1));
}

void build(int i, int j)
{
	if (i == a.size() || j == b.size()) return;
	if (a[i] == b[j]) {
		ans += a[i];
		build(i + 1, j + 1);
	}
	else {
		if (solve(i, j) == solve(i + 1, j)) build(i + 1, j);
		else build(i, j + 1);
	}
}

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> a >> b;
	mem(dp, -1);
	solve(0, 0);
	build(0, 0);
	cout << ans;
	//int wait; sc(wait);
}


Measured memory_bytes: 35840
N = int(input())
tmp = []
work = []
for _ in range(N):
    a,b = map(int, input().split())
    tmp.append(b)
    tmp.append(a)
    work.append(tmp)
    tmp = []

work.sort()
# print(work)

sum = 0
time = 0

for i in range(len(work)):
    time = time + work[i][1]
    if work[i][0] < time:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 39756
# coding: utf-8
# Your code here!
N=int(input())

pl=[]
num=[]
for _ in range(N):
    temp=list(input().split())
    pl.append(temp[0])
    num.append(temp[1])

num=list(map(int,num))

start=int(pl.index(input()))
print(sum(num[start+1:]))


Measured memory_bytes: 3060
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

r,D,x=MI()
bef=x
for i in range(1,11):
    print(r*bef-D)
    bef=r*bef-D

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,a,b,ans=0;
    cin>>n>>m;
    vector<int> h(n+1);
    vector<vector<int>> adj(n+1);
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=1;i<=m;i++)
        cin>>a>>b,
        adj[a].push_back(b),
        adj[b].push_back(a);
    for(int i=1;i<=n;i++)
    {
        bool flag=1;
        for(auto p:adj[i])
            flag&=(h[i]>h[p]);
        ans+=flag;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8736
#include<iostream>
#include<cstdio>
using namespace std;
int k,a[100005];
long long ans1=2,ans2=2;
int read(){
	char c=getchar();
	while(c>'9'||c<'0') c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x;
}
int main(){
	k=read();
	for(int i=1;i<=k;i++) a[i]=read();
	for(int i=k;i>0;i--){
		if(ans1%a[i]!=0) ans1+=a[i]-ans1%a[i];
		ans2=(ans2/a[i]+1)*a[i]-1;
	}
	if(ans1>ans2) printf("-1\n");
	else printf("%lld %lld",ans1,ans2);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
    #include <vector>
    #include <cmath>
     
    using namespace std;
     
    int main(){
        int n;
        long long z,w, tmp, ans;
        vector<long long> v;
        cin >> n >> z >> w;
        for(int i=0;i<n;i++){
            cin >> tmp;
            v.push_back(tmp);
        }
        if(v.size() == 1){
            cout << abs(v[0] - w) << endl;
        } else {
            if(abs(v[n-2]-v[n-1]) < abs(v[n-1]-w))
                cout << abs(v[n-1] -w) << endl;
            else
                cout << abs(v[n-2]-v[n-1]) << endl;
        }
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<limits>
#include<stack>
#include<queue>
#include<math.h>
#include <iomanip>

#define rep(i,n) for(auto i=0;i<(n);i++)
#define all(vs) (vs).begin(),(vs).end()
#define roundup(A,B) (A)/(B)+(A%B==0?0:1)
#define maximize(A,B) A=max((A),(B))
#define read(type,name) type name;cin>>name
#define ll long long

using namespace std;
template<typename T>
T MAX() { return numeric_limits<T>::max(); }

//二次元テーブル
template<typename T>
class Table {
public:
	Table(int height, int width, T value) {
		if (width < 0)throw out_of_range("Width should be >=0");
		if (height < 0)throw out_of_range("Height should be >=0");
		this->wid = width;
		this->hgt = height;
		vs = new T[width * height];
		for (auto i = 0; i < width * height; i++)vs[i] = value;
	}
	Table(const Table& table) {
		hgt = table.hgt;
		wid = table.wid;
		vs = new T[hgt * wid];
		for (size_t i = 0; i < table.size(); i++) {
			vs[i] = table.vs[i];
		}
	}
	Table(Table&& table) {
		hgt = table.hgt;
		wid = table.wid;
		swap(vs, table.vs);
	}
	~Table() {
		if (vs)delete[] vs;
	}
	Table& operator=(const Table& table) {
		if (table == *this)return *this;
		this->wid = table.wid;
		this->hgt = table.hgt;
		if (vs)delete[] vs;
		vs = new T[wid * hgt];
		for (auto i = 0; i < wid * hgt; i++)vs[i] = table.vs[i];
	}
	Table& operator=(Table&& table) {
		wid = table.wid;
		hgt = table.hgt;
		swap(vs, table.vs);
	}
	inline T& at(int y, int x) {
		if (wid > x)throw out_of_range("x>width.");
		if (hgt > y)throw out_of_range("y>height.");
		return vs[x + y * wid];
	}
	int size()const { return wid * hgt; }
	int width()const { return wid; };
	int height()const { return hgt; };
	T* begin() { return vs; }
	T* end() { return vs + wid * hgt; }
	T& operator()(int y, int x) { return vs[x + y * wid]; }
	const T& operator()(int y, int x)const { return vs[x + y * wid]; }
private:
	int wid, hgt;
	T* vs;
};

//Nが偶数であれば偶奇が同じ数だけあるので0.5である。
//Nが奇数2k+1である場合はk+1個の奇数とk個の偶数が存在する
void A() {
	read(int, N);
	if (N % 2 == 0)cout << 0.5 << endl;
	else cout << (double)(N / 2 + 1) / N << endl;
}

void B() {
}

void C() {
}

void D() {

}

void E() {}
void F() {}

int main() {
	A();
}

Measured memory_bytes: 3704
///#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define all(x) (x).begin(), (x).end()
#define finout(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
#define X first
#define Y second

using namespace std;
const int MOD = 1e9 + 7;

typedef pair <int, int> pii;
typedef vector <int> vi;
inline int ni() {int x; cin >> x; return x;}
template <class T>
inline T nt() {T x; cin >> x; return x;}
inline void print(){}
template<typename T, typename ...TAIL>
inline void print(const T &t, TAIL... tail) {cout << t; print(tail...);}
inline void input() {return;}
template<typename T, typename ...TAIL>
inline void input(T &t, TAIL&... tail) {cin >> t; input(tail...);}

const int N = 2 * 1005001;
const int inf = 1e9 + 7;
const double PI = 3.14159265359;

vi v;
int L;
int go[N][20];

bool check(int x, int a, int b) {
    for (int i = 19; i >= 0; i--) {
        if (x >= (1<<i)) {
            x -= 1<<i;
            a = go[a][i];
        }
    }
    return a >= b;
}

signed main () {
    ios_base::sync_with_stdio(NULL);  cin.tie(0); cout.tie(0);
    int n = ni();
    for (int i = 0; i < n; i++) v.push_back(ni());
    L = ni();

    for (int i = 0; i < n; i++) {
        int l = i + 1, r = n;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (v[m] - v[i] <= L)
                l = m;
            else
                r = m;
        }
        go[i][0] = l;
    }
    go[n][0] = n;
    for (int j = 1; j < 20; j++) {
        for (int i = 0; i <= n; i++) {
            go[i][j] = go[go[i][j - 1]][j - 1];
        }
    }



    int Q = ni();
    for (int i = 0; i < Q; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);
        int ans = 0;
        int l = 0, r = b - a + 1;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (check(m, a, b)) {
                r = m;
            }
            else {
                l = m;
            }
        }
        if (check(l, a, b)) r = l;
        cout << r << '\n';
    }
}




/*
5
1 2 3 4 5
2
1
1 5

*/











Measured memory_bytes: 19820