akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class agc028_c {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> A(N), B(N);
        for (int i = 0; i < N; ++i) {
            in >> A[i] >> B[i];
        }
        long long ans = min(accumulate(begin(A), end(A), 0LL),
                            accumulate(begin(B), end(B), 0LL));
        vector<pair<int, int>> v(2 * N);
        for (int i = 0; i < N; ++i) {
            v[i] = {A[i], i};
        }
        for (int i = 0; i < N; ++i) {
            v[i + N] = {B[i], i};
        }
        sort(begin(v), end(v));
        vector<pair<int, int>> ind(N, {-1, -1});
        for (int i = 0; i < 2 * N; ++i) {
            //auto [val, j] = v[i];
            int val = v[i].first, j = v[i].second;
            if (ind[j].first == -1) {
                ind[j].first = i;
            } else {
                ind[j].second = i;
            }
        }
        vector<long long> psum(2 * N + 1, 0);
        for (int i = 0; i < 2 * N; ++i) {
            psum[i + 1] = psum[i] + v[i].first;
        }
        for (int i = 0; i < N; ++i) {
            //auto [j1, j2] = ind[i];
            int j1 = ind[i].first, j2 = ind[i].second;
            long long cursum = psum[N - 2] + v[j1].first + v[j2].first;
            if (j1 <= N - 2) {
                cursum = psum[N - 1] + v[j2].first;
                if (j2 <= N - 1) {
                    cursum = psum[N];
                }
            }
            ans = min(ans, cursum);
        }
        out << ans << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	agc028_c solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<stdlib.h>


/*ex)
 * 3
 * 2 5
 * (2,2,5)
 * */
int main() {
	/*
	 参加者N人
	 */
	/*変数宣言*/
	int N;

	/*変数受け取り*/
	scanf("%d", &N);

	int b[100];
	for (int i = 0; i < N-1; i++) {
		scanf("%d", &b[i]);
	}
	int ans = 0;
	//0番目の最大値は必ずb[0]
	ans += b[0];

	for(int i = 0; i < N-2; i++){
		/*
		 * 前の値＜後ろの値なら
		 * 前の値をaに格納
		 *
		 * それ以外なら
		 * 後ろの値をaに格納
		 * */
		if(b[i] < b[i+1]){
			ans += b[i];
		}
		else{
			ans += b[i+1];
		}
	}
	//最後の最大値は必ずb[最後]
	ans += b[N -2];

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979323846
#define mod 1000000007
int main()
{
    IOS;
    ll a,b,c,d,e,cnt=0;
    cin>>a>>b;
    for(c=0;c<a;c++)
    {
        ll x,y;
        cin>>x>>y;
        if(b*b>=(x*x)+(y*y)) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3640
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	
	for i := 0; i < len(s)-1; i++ {
		for j := i + 1; j < len(s); j++ {
			if s[i] == s[j] {
				fmt.Println("no")
				return
			}
		}
	}
	fmt.Println("yes")

}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
	int n;
	int a, b;
	int i;
	int sum = 0;
	cin >> n >> a >> b;
	for (i = 1; i <= n; i++) {
		if (i / 10000 + i / 1000 - (i / 10000) * 10 + i / 100 - (i / 1000) * 10 + i / 10 - (i / 100) * 10 + i - (i / 10) * 10 >= a&&i / 10000 + i / 1000 - (i / 10000) * 10 + i / 100 - (i / 1000) * 10 + i / 10 - (i / 100) * 10 + i - (i / 10) * 10 <= b) {
			sum += i;
		}
	}
	cout << sum << 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;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;++i){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> a >> b >> c;
	cout << (a + b) * c / 2 << rt;
	please AC;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

string S;
int main(void){
    cin >> S;
    ll res = 0, count = 0, right = 0, left = 0;
    while(count < S.length() and S[count] == '>') res += 1 + count++;
    for(;count < S.length();count++){
        if(S[count] == '<') right++;
        else left++;
        if(count == S.length()-1 or (S[count] == '>' and S[count+1] == '<')){
            ll M = max(right, left), m = min(right, left);
            res += M*(M+1)/2 + m*(m-1)/2;
            right = 0;
            left = 0;
        }
        if(count == S.length()-1) break;
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 900
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean ans = isKaibun(s);
        if(ans) ans = isKaibun(s.substring(0, s.length()/2));
        if(ans) ans = isKaibun(s.substring(s.length()/2 + s.length()%2, s.length()));
        System.out.println(ans ? "Yes" : "No");
        sc.close();

    }


    private static boolean isKaibun(String s) {
        for (int i = 0; i < s.length()/2; i++) {
            if(s.charAt(i) != s.charAt(s.length()-1-i)){
                return false;
            }
        }
        return true;
    }

}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <unordered_map>
using namespace std;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

bool compare_by_b(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<2>(a) != get<2>(b)){
        return get<2>(a) > get<2>(b);
    }
}

bool compare_by_string(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<1>(a) != get<1>(b)){
        return get<1>(a) < get<1>(b);
    }else{
      	return get<2>(a) > get<2>(b);
    }
}

int check(vector<int> &v, int k, long weight)
{
  int i=0;
  for(int j=0;j<k;j++)
  {
    long tmp = 0;
    while(tmp + v[i] <= weight)
    {
      tmp += v[i];
      i++;
      if(i == v.size()) return v.size();
    }
  }
  return i;
}


long binary_search(vector<int> &v, int k)
{
	long left = 0;
  	long right = v.size() * 10000; //適宜書き換え
  	long mid;
  	while(right - left > 1)
    {
      	mid = (left + right) / 2;
      	int num = check(v,k,mid);
      	if(num >= v.size()) right = mid;
      	else left = mid;
    }
  	return right;
}

bool isComb(vector<int> &elem, int idx, int sum)
{
  if(sum == 0) return true;
  else if(idx >= elem.size() || sum < 0) return false;
  return isComb(elem, idx+1, sum) || isComb(elem, idx+1, sum - elem[idx]);
}

int Merge(vector<int> &v, int left, int mid, int right)
{
  int count = 0;
  int n_left = mid -left;
  int n_right = right -mid;
  vector<int> v_left(n_left);
  vector<int> v_right(n_right);
  for(int i=0;i<n_left;i++) v_left[i] = v[left+i];
  for(int i=0;i<n_right;i++) v_right[i] = v[mid+i];
  int i=0,j=0;
  for(int k=left;k<right;k++)
  {
    count++;
    if(i < n_left && j < n_right && v_left[i] <= v_right[j])
    {
      v[k] = v_left[i];
      i++;
    }
    else if(i < n_left && j < n_right && v_left[i] > v_right[j])
    {
      v[k] = v_right[j];
      j++;
    }
    else if(i < n_left && j >= n_right)
    {
      v[k] = v_left[i];
      i++;
    }
    else if(i >= n_left && j < n_right)
    {
      v[k] = v_right[j];
      j++;
    }
  }
  return count;
}

int MergeSort(vector<int> &v, int left, int right)
{
  int count = 0;
  if(left + 1 < right)
  {
    int mid = (left + right) / 2;
    count += MergeSort(v, left, mid);
    count += MergeSort(v, mid, right);
    count += Merge(v, left, mid, right);
  }
  return count;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
  	const long div = 1000000007;
	int n;
  	cin >> n;
  	vector<int> S(n);
  	int idx = 0;
  	while(cin >> S[idx])
    {
      idx++;
    }
  	int count = 0;
  	count = MergeSort(S, 0, n);
  	for(int i=0;i<n-1;i++) cout << S[i] << " ";
  	cout << S[n-1] << endl;
  	cout << count << endl;
  	return 0;
}



Measured memory_bytes: 6708
#include<bits/stdc++.h>                                                                                                                  
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
             
#define pb push_back
#define PII pair<int,int>
             
#define VS vector<string>
#define VI vector<int>
#define ll long long int
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {
    string s = "aiueo";
    char c; cin >> c;
    bool p = false;
    REP(i,5) {
        if(c == s[i]) {
            p = true;
            break;
        }    
    }        
    if(p) cout << "vowel" << endl;
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int ans=0;
	int c=0,d[a];
	for(int i=0;i<a;i++){
		int e;
		cin>>e>>d[i];
		c=max(c,e);
	}
	sort(d,d+a);
	for(int i=a-1;i>=0;i--){
		if(d[i]<c)break;
		if(b<=0)break;
		b-=d[i];
		ans++;
	}
	if(b>0){
		ans+=b/c;
		if(b%c)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#a, b = map(int, input().split())
n = int(input())

l = [[0 for i in range(10)] for j in range(10)]

ans = 0
for i in range(n):
    s = str(i+1)
    t = len(s)
    u = int(s[0])
    v = int(s[len(s)-1])

    if u == 0:
        continue
    if v == 0:
        continue

    if u == v:
        ans += 1

    z = 2 * l[v][u]
    ans += z

    l[u][v] += 1

print(ans)


    


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {
        static int sengetsu = 4280;
        static int kihon = 1150;

        public static void Main(String[] args) {
            int n;
            while((n=int.Parse(Console.ReadLine()))!=-1){
                int ryokin = calc_ryokin(n);
                Console.WriteLine(sengetsu - ryokin);
            }

            
        }

        static int calc_ryokin(int water) {
            int ryokin = 0;
            if (water <= 10) { ryokin = kihon; }
            else if (water <= 20) { ryokin = kihon + (water - 10) * 125; }
            else if (water <= 30) { ryokin = kihon + (water - 20) * 140 + 125 * 10; }
            else { ryokin = kihon + (water - 30) * 160 + 140 * 10 + 125 * 10; }
            return ryokin;
        }
      
    }


}

Measured memory_bytes: 5600
N = int(input())
S = []
E = []
for i in range(N):
    a,b = map(int, input().split())
    S.append([a, b])
    E.append([b, a])

S.sort()
E.sort()

if N % 2 == 0:
    mi = S[N//2-1][0] + S[N//2][0]
    ma = E[N//2-1][0] + E[N//2][0]
    print(ma-mi+1)
else:
    mi = S[(N+1)//2-1][0]
    ma = E[(N+1)//2-1][0]
    print(ma-mi+1)

Measured memory_bytes: 130328
str = input()
n = len(str)
str_list = list(str)

ans = 'Yes'
for i in range(0,n//2):
    if str_list[i] != str_list[n//2-i-1]:
        ans = 'No'

for j in range(n//2+1,n):
    if str_list[i] != str_list[-i-1]:
        ans = 'No'

for i in range(n):
    if str_list[i] != str_list[-i-1]:
        ans = 'No'

print(ans)

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int w;
string s,ans;

signed main() {
    cin >> s >> w;
    rep(i,s.size()) if (!(i%w)) ans.pb(s[i]);
    cout << ans << endl;
}












Measured memory_bytes: 256
#![allow(unused)]

use std::{cell, cmp, collections, convert, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let s = read_line();
    let p = s.chars().filter(|&c| c == '+').count() as i32;
    let n = s.chars().filter(|&c| c == '-').count() as i32;
    println!("{}", p - n);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = f64::from(x).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  for(int i=0;i<n-1;i++){
    set<char> former,latter;
    int temp=0;
    for(int j=0;j<=i;j++){
      former.insert(s[j]);
    }
    for(int j=i+1;j<=n-1;j++){
      latter.insert(s[j]);
    }
    for(auto itr=former.begin();itr!=former.end();itr++){
      if(latter.count(*itr)) temp++;
    }
    ans=max(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter

def main():
    N = int(input())
    a = list(map(int,input().split()))
    posi,nega = [],[]
    for num in a:
        if num >= 0:
            posi.append(num)
        else:
            nega.append(num)
    
    posi.sort()
    nega.sort(reverse=True)
    ans = []
    if len(posi) == 0:
        a = nega[0]
        for i in range(N-1):
            ans.append((a,nega[i+1]))
            a -= nega[i+1]
    elif len(nega) == 0:
        if len(posi) == 2:
            ans.append((max(posi),min(posi)))
        else:
            a = posi[0]
            for i in range(N-2):
                ans.append((a,posi[i+1]))
                a -= posi[i+1]
            ans.append((posi[-1],a))
    else:
        pl,nl = len(posi),len(nega)
        a = posi[0]
        for i in range(pl-1):
            ans.append((nega[0],posi[i+1]))
            nega[0] -= posi[i+1]
        for i in range(nl):
            ans.append((a,nega[i]))
            a -= nega[i]
            
    print(ans[-1][0]-ans[-1][1])
    for x,y in ans:
        print(x,y)

if __name__ == "__main__":
    main()


Measured memory_bytes: 19468
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


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

    int h, w;
    int g[500][500];
    vector<pair<int, int>> black_xy;
    char tmp;
    cin >> h >> w;
    rep(i, h){
        rep(j, w){
            cin >> tmp;
            if(tmp == '#'){
                g[j][i] = 1;
                black_xy.push_back(make_pair(j, i));
            }else g[j][i] = 0;
        }
    }

    int visit[500][500];
    int black_visit[500][500];
    Fill(visit, 0);
    Fill(black_visit, 0);
    ll cntbuf, black_cnt;
    function<void(int, int)> dfs = [&](int x, int y){
        visit[x][y] = 1;
        if(g[x][y]){
            black_visit[x][y] = 1;
            black_cnt++;
        }else cntbuf++;

        rep(i, 4){
            int dlx = x + dx[i];
            int dly = y + dy[i];
            if(dlx < 0 || dlx >= w || dly < 0 || dly >= h) continue;
            if(visit[dlx][dly]) continue;
            if(g[x][y] && !g[dlx][dly]){
                dfs(dlx, dly);
            }else if(!g[x][y] && g[dlx][dly]){
                dfs(dlx, dly);
            }
        }
    };

    ll res = 0;
    for(auto const& e : black_xy){
        int x = e.first;
        int y = e.second;
        if(black_visit[x][y]) continue;
        cntbuf = 0;
        black_cnt = 0;
        dfs(x, y);
        res += cntbuf*black_cnt;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 13812
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	vector<char> a = {'2', '4', '5', '7', '9'};
	vector<char> b = {'0', '1', '6', '8'};
	vector<char> c= {'3'};
	rep(i, a.size()) if(s[s.size() - 1] == a[i]){
		cout << "hon" << endl;
		return 0;
	}
	rep(i, b.size()) if(s[s.size() - 1] == b[i]){
		cout << "pon" << endl;
		return 0;
	}
	rep(i, c.size()) if(s[s.size() - 1] == c[i]){
		cout << "bon" << endl;
		return 0;
	}
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3616
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#include<vector>
using namespace std;
// todo: include追加する。
int main(){
    int N,L;cin>>N>>L;
    vector<int>Apple(N);
    int AppleSum = 0;
    bool ans = false;
    for(int i=0;i<N;i++){
        Apple[i] = L+(i+1)-1;
        AppleSum += Apple[i];
        if(Apple[i] == 0)
            ans = true;
    }

    if(ans){
        cout << AppleSum << endl;
        return 0;
    }


    if(L < 0)
        cout << AppleSum - Apple[N-1] << endl;
    else
        cout << AppleSum - Apple[0] << endl;
}

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

signed main() {
	string s;
	while (cin >> s and s != "-") {
		queue<char> a;
		for (int i = 0; i < s.size(); ++i) {
			a.push(s[i]);
		}
		int N;
		cin >> N;
		for (int i = 0; i < N; ++i) {
			int h;
			cin >> h;
			for (int j = 0; j < h; ++j) {
				a.push(a.front());
				a.pop();
			}
		}
		while (!a.empty()) {
			cout << a.front();
			a.pop();
		}
		cout << endl;
	}
}





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

int main()
{
  int64_t n;
  cin >> n;
  vector<int64_t> v(n), e(100001), o(100001);
  for (auto&& e : v) cin >> e;
  for (int64_t i = 0; i < n; i++) {
    if (i % 2 == 0) {
      e[v[i]]++;
    } else {
      o[v[i]]++;
    }
  }
  pair<int64_t, int64_t> e1, e2, o1, o2;
  for (int64_t i = 1; i <= 100000; i++) {
    if (e[i] > e1.second) {
      e2 = e1;
      e1 = {i, e[i]};
    } else if (e[i] > e2.second) {
      e2 = {i, e[i]};
    }
    if (o[i] > o1.second) {
      o2 = o1;
      o1 = {i, o[i]};
    } else if (o[i] > o2.second) {
      o2 = {i, o[i]};
    }
  }
  if (e1.first != o1.first) {
    cout << n - e1.second - o1.second << endl;
  } else {
    cout << min(n - (e1.second + o2.second), n - (o1.second + e2.second)) << endl;
  }
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        Stream<String> stream = Arrays.stream(arr01);
        int arr02[] = stream.mapToInt(Integer::parseInt).toArray();
        int mysum = Arrays.stream(arr02).sum();

        System.out.println(mysum >= 22 ? "bust" : "win");

    }

}


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

int main(){
    int n;
    cin >> n;
    int p[n];
    rep(i,n) cin >> p[i];
    int a[n+1];
    rep(i,n) a[i+1] = n*(i+1);
    int b[n+1];
    rep(i,n) b[p[i]] = (n*n+1+i)-a[p[i]];
    rep(i,n) cout << a[i+1]  << " ";
    cout << endl;
    rep(i,n) cout << b[i+1] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int m;
	scanf("%d",&m);
	rep(tt,m){
		int money,y,n,mx=0;
		scanf("%d%d%d",&money,&y,&n);
		rep(i,n){
			int t,tesu;
			double ri;
			scanf("%d%lf%d",&t,&ri,&tesu);
			int now=money;
			if(t==0){
				int all=0;
				rep(j,y) all+=ri*now,now-=tesu;
				now+=all;
			}
			else rep(j,y) now=(ri+1)*now-tesu;
			mx=max(mx,now);
		}
		printf("%d\n",mx);
	}
}

Measured memory_bytes: 1200
x, k, d = map(int, input().split())
x = abs(x)

#logging.debug(x % d)

if x == 0:
    if k % 2 == 0:
        print(0)
    else:
        print(d)
    exit()

if k * d <= x:
    print(x - k * d)
    exit()

if x % d > 0:
#    logging.debug(x % d)
    y = x // d + 1
else:
    y = x // d

ans1 = x % d #手前
ans2 = d - ans1
#logging.debug("y={},ans1={},{}".format(y,ans1,ans2))

if x % d == 0:
    if (k - y) % 2 == 1:
        #logging.debug((k-y)%2)
        print(ans2)
    else:
        print(ans1)
    exit()

if (k - y) % 2 == 1:
#    logging.debug((k-y)%2)
    print(ans1)
else:
    print(ans2)

Measured memory_bytes: 9148
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int, input().split())),reverse=True)
q=sorted(list(map(int, input().split())),reverse=True)
r=sorted(list(map(int, input().split())),reverse=True)
ans=sorted(p[:x]+q[:y],reverse=True)
for i in range(c):
    if ans[-i-1]<r[i]:
        ans[-i-1]=r[i]
    else:
        break
print(sum(ans))

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

const int N = 3003;
int n , a[N] , ti , vis[N][N][3]; 
ll mem[N][N][3];

ll dp(int i , int j , int pl){
	if(i>j) return 0;
	ll &ret = mem[i][j][pl];
	int &vs = vis[i][j][pl];
	if( vs == ti ) return ret;
	vs = ti;
	return ret = max( 
			a[i] + dp(i+1 , j , (pl+1)%2)*(pl? -1 : -1),
			a[j] + dp(i , j-1 , (pl+1)%2)*(pl? -1 : -1)
			);
}

int main(){
	scanf("%d" , &n);
	for(int i=0 ; i<n ; i++) scanf("%d" , a + i);
	ti++;
	printf("%lld" , dp(0 , n-1 , 1));
}


Measured memory_bytes: 316032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in)) {
			String a = sc.next();
			String b = sc.next();
			
			int ab = Integer.parseInt(a + b);
			int temp = (int)Math.sqrt(ab);
			
			if (Math.pow(temp,2) == ab) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}

	}

}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int C=0;
  //ABCの数を数える
  
  for(int i=0;i<(N-2);i++){
    if(S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C'){
      C++;
    }
  }
  
  cout << C << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main() {
	ll n;
	cin >> n;
	ll a[n+1];
	for(ll i = 1; i <= n; i++) cin >> a[i];
	sort(a+1,a+n+1);
	ll sum = a[n];
	ll ct = 2,i = n-1;
	while(ct < n) {
		sum += a[i];
		ct++;
		if(ct == n) break;
		sum += a[i];
		ct++;
		i--;
	}

	cout << sum << endl;

}

Measured memory_bytes: 5184
import sys
from collections import Counter

a, b, k = map(int, input().split())
ans_set = set()

for i in range(a, a+k):
    if i > b:
        break
    ans_set.add(i)

for i in range(b, b-k, -1):
    if i in ans_set or b-k < 0:
        break
    ans_set.add(i)

for i in sorted(ans_set):
    print(i)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
#include<stdio.h>
#include <sstream>
#define pi 3.141592653589793238462
#define limit 100005
#define mo 1000000007;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli mod=9999999999999983;
lli primes[6]={1125899906842597,1495921043,1005985879,1495921043,1005985879,1495921043};
using namespace std;
vector<lli>adj[2000009];
lli parent[2000009];
lli vis[2000009];
lli level[2000009];
lli dist[2000009];
lli dp[200009][3];
lli arr[200009][3];
lli brr[2000009];
lli crr[2000009];
lli hashing[2000009];
lli ar[509][509];
lli br[509][509];
lli cr[509][509];
lli res;


lli solve(lli n,lli index)
{
     //cout<<"n="<<n<<" "<<"index="<<index<<endl;

     if(dp[n][index]!=0)
     {
         return dp[n][index];
     }

     lli i,res=0;
     if(n<=0)
     {
         return 0;
     }

     for(i=1;i<=3;i++)
     {
         if(i!=index)
         res=max(res,solve(n-1,i));
     }

     dp[n][index]=arr[n][index]+res;
    // cout<<"dp="<<dp[n][index]<<endl;
     return dp[n][index];
}


int main()
{
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int start_s = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    vector<lli>vect,vt,vct;
    vector<lli>::iterator itt;
    set<lli>st;
    set<lli>::iterator itr;
    map<lli,lli>mp;
    map<lli,lli>::iterator it;
    string str;

    lli i,j,k,n,m,q,t,a,b,c,maxi=INT_MIN,mini=INT_MAX,sum=0,ans=0,val=0,ans1=0,ans2=0,rem=0,diff=0,cnt=0,l,r,flag=0,e,index,val1=0,val2=0,x,y,z,h=0,u,v,mid,len,tot,fl=0;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=3;j++)
        {
             cin>>arr[i][j];
        }
    }

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=3;j++)
        {
             //cout<<"i="<<i<<" "<<"j="<<j<<" "<<"dp="<<dp[i][j]<<endl;
        }
    }

    cout<<max(solve(n,3),max(solve(n,2),solve(n,1)));
}


Measured memory_bytes: 64000
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

int n;
vi v;

signed main(){
    FASTER;
    cin>>n;
    v.resize(n);cin>>v;
    
    for(int i=0;i<n-1;i++){
        if(v[i+1]>v[i]){
            v[i+1]--;
        }
    }
    int ok=1;
    for(int i=0;i<n-1;i++){
        if(v[i]>v[i+1]){
            ok=0;
        }
    }
    if(ok){
        cout<<"Yes";
    }else cout<<"No";
    
    
}






Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i < t ; i++)
#define SZ(a) (int)a.size()
using LL = long long; using VL = vector<LL>;
using VI = vector<int>;
#define ALL(a)  begin((a)),end((a))
#define SORT(c) sort(ALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
using VVI = vector<vector<int>>;

using tp = tuple<double, string>;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N;
	while (cin >> N, N) {
		vector<tp>se;
		string st; LL p, a, b, c, d, e, f, s, m;
		FOR(i, 0, N) {
			cin >> st >>p>> a >> b >> c >> d >> e >> f >> s >> m;
			double XX = s * f*m-p;
			double term = (a+b+c+(d+e)*m);
			double val = XX / term;
			se.push_back(tp(-val, st));
		}
		SORT(se);
		FOR(i, 0, N) {
			double val; string str;
			tie(val, str) = se[i];
			cout << str << endl;
		}
		cout << "#" << endl;
	}


	return 0;
}


Measured memory_bytes: 3244
#include <stdio.h>

main(void)
{
	int a,b,c,sma,mid,big;
	
	scanf("%d%d%d",&a,&b,&c);
	
	if(a>=b && a>=c){
		big=a;
		if(b==c){
			mid=b;
			sma=c;
		}
		if(b>c){
			mid=b;
			sma=c;
		}
		if(b<c){
			sma=b;
			mid=c;
		}
	}
	
	if(b>=a && b>=c){
		big=b;
		if(a==c){
			mid=a;
			sma=c;
		}
		if(a>c){
			mid=a;
			sma=c;
		}
		if(a<c){
			sma=a;
			mid=c;
		}
	}
	
	if(c>=a && c>=b){
		big=c;
		if(a==b){
			mid=a;
			sma=b;
		}
		if(a>b){
			mid=a;
			sma=b;
		}
		if(a<b){
			sma=a;
			mid=b;
		}
	}
	
	else if(a==b==c){
		big=a;
		mid=b;
		sma=c;
	}
	
	printf("%d %d %d\n",sma,mid,big);
	
	return 0;
	
}

Measured memory_bytes: 596
A, B, C, X, Y = map(int, input().split())
price = A*X + B*Y
for i in range(0, max(X, Y)+1):
    if  price > A*max(0, X-i) + B*max(0, Y-i) + 2*C*i:
        price = A*max(0, X-i) + B*max(0, Y-i) + 2*C*i 
print(price)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int k;
    cin >> k;
    vector<ll> a(k);
    for(int i = 0; i < k; i++)
    {
        cin >> a[i];
    }
    if(a[k-1] != 2)
    {
        cout << -1 << endl;
        return 0;
    }

    ll l = 2, h = 3;
    for(int i = k-2; i >= 0; i--)
    {
        if(a[i] > h)
        {
            cout << -1 << endl;
            return 0;
        }
        if(a[i] >= l) l = a[i];
        else
        {
            l = ((l-1)/a[i] + 1) * a[i];
        }
        ll x = h / a[i] * a[i];
        h = x + a[i] - 1;
        if(l > h)
        {
          cout << -1 << endl;
          return 0;
        }
    }
    cout << l << " " << h << endl;
}


Measured memory_bytes: 1024
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] S = scanner.nextLine().split("");
		String[] T = scanner.nextLine().split("");
		int ans = 0;

		for (int i = 0; i < 3; i++) {
			if (S[i].equals(T[i]))
				ans++;
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define ll long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 2015;
int dp[N][N], f1[N][N], f2[N][N], a[N];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n >> a[1] >> a[2];
    n += 2;
    for (int i = 3; i <= n; i++) cin >> a[i];
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= n; j++) f2[i][j] = 2e9;
    }
    for (int i = n; i >= 1; i--){
        for (int j = n; j >= 1; j--){
            if (i == j) continue;
            if (i == n || j == n) dp[i][j] = abs(a[i] - a[j]); else
            if (i > j){
                dp[i][j] = abs(a[i] - a[n]);
                dp[i][j] = min(dp[i][j], f2[i][i + 1]);
                //for (int l = i + 1; l <= n; l++) dp[i][j] = min(dp[i][j], dp[i][l]);
                f1[i][j] = max(f1[i + 1][j], dp[i][j]);
            } else{
                dp[i][j] = abs(a[j] - a[n]);
                dp[i][j] = max(dp[i][j], f1[j + 1][j]);
                //for (int l = j + 1; l <= n; l++) dp[i][j] = max(dp[i][j], dp[l][j]);
                f2[i][j] = min(f2[i][j + 1], dp[i][j]);
            }
        }
    }
    cout << dp[1][2];
}


Measured memory_bytes: 47744
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


int main(){
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    ld x=abs(12-abs((h+m/60.0)-m/5.0));
    ld y=abs(360-360*x/12.0);
    
    ld rad=y/180*M_PI;
    cout<<fixed<<setprecision(18)<<sqrt(a*a+b*b-2*a*b*cos(rad));
}

Measured memory_bytes: 4164
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
ll i,j,k,l,ii,jj;
ll n,t;
ll a[100005];
ll syo=INF,dai=0;
ll memo=0;
ll ans;

int main(){
	cin>>n>>t;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		if(syo>a[i]){
			syo=a[i];
		}else if(a[i]-syo>dai){
			ans=1;
			dai=a[i]-syo;
		}else if(a[i]-syo==dai){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;


}

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

int main (){
	int N;cin>>N;
	vector<pair<int,int>> AB(N);
	for(int i=0;i<N;i++){
		int a,b;cin>>a>>b;
		AB[i] = make_pair(b,a);
	}
	sort(AB.begin(),AB.end());
	int now=0;
	for(int i=0;i<N;i++){
		now+=AB[i].second;
		//cout << now<<","<<AB[i].first<<endl;
		if(now>AB[i].first){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int D[n+1];
    bool counter[101] = {};
    for(int i = 0; i < n; i++){
        cin >> D[i];
        counter[D[i]] = 1;
    }
    int count = 0;
    for(int i = 1; i < 101; i++){
        if(counter[i] == 1){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

n, m = map(int, input().split())
h = [int(i) for i in input().split()]
list = [[i, []] for i in range(n)]

for i in range(m):
  a, b = map(int, input().split())
  list[a-1][1].append(b-1)
  list[b-1][1].append(a-1)

ans_list = []
for i in range(n):
  tmp = []
  if list[i][1] == []:
    tmp.append(1)
  else:
    tmp = []
    for j in range(len(list[i][1])):
      if h[list[i][0]] > h[list[i][1][j]]:
        tmp.append(1)
      else:
        tmp.append(0)
  ans_list.append(tmp)

print(str(sum([np.prod(ans_list[i]) for i in range(len(ans_list))])))

Measured memory_bytes: 73604
MOD = 10**9 + 7
e, N = map(int, input().split())

def phi_table(N):
    phi = list(range(N + 1))
    for p in range(2, N + 1):
        if phi[p] == p:
            for n in range(N // p, 0, -1):
                phi[p * n] -= phi[n]
    return phi


L = int(N ** .66)
H = int(N // (L + 1))
phi = phi_table(L)

# f(n) = \sum_{i=1}^n phi(i)

f_l = phi.copy()
for n in range(L):
    f_l[n + 1] += f_l[n]

f_h = [0] * (H + 1)  # f(N//d)


def f(n):
    return f_l[n] if n <= L else f_h[N // n]


def compute_f(n):
    sq = int(n ** .5)
    x = n * (n + 1) // 2
    for d in range(1, n + 1):
        m = n // d
        if m <= sq:
            break
        x -= f(m)
    for m in range(1, sq + 1):
        cnt = n // m - n // (m + 1)
        x -= f_l[m] * cnt
    return x


for d in range(H, 0, -1):
    f_h[d] = compute_f(N // d)

sq = int(N ** .5)
answer = 0
for d in range(1, N + 1):
    n = N // d
    if n <= sq:
        break
    answer += pow(n, e, MOD) * phi[d]

for n in range(1, sq + 1):
    low_d = N // (n + 1)
    high_d = N // n
    phi_sum = f(high_d) - f(low_d)
    answer += phi_sum * pow(n, e, MOD)

answer %= MOD
print(answer)


Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

  vector<int> x(N), y(N), h(N);
  int xx, yy, hh;

  rep(i, N) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] > 0) {
      xx = x[i];
      yy = y[i];
      hh = h[i];
    }
  }

  repp(cx, 0, 100) {
    repp(cy, 0, 100) {
      int h_cand = hh + abs(cx - xx) + abs(cy - yy);
      int correct = true;
      rep(i, N) {
        int h_inf = max(h_cand - abs(cx - x[i]) - abs(cy - y[i]), 0);
        if (h_inf != h[i]) {
          correct = false;
          break;
        }
      }
      if (correct) {
        cout << cx << ' ' << cy << ' ' << h_cand << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
require 'set'

def change_state(n, state)
    new_state = 0
    (0..n-1).each do |i|
        (0..n-1).each do |j|
            count = 0
            t = (i == 0 ? 0 : i-1)
            b = (i == n-1 ? n-1 : i+1)
            l = (j == 0 ? 0 : j-1)
            r = (j == n-1 ? n-1 : j+1)
            (t..b).each do |y|
                (l..r).each do |x|
                    next if y == i && x == j
                    count += 1 if state[y * n + x] == 1
                end
            end

            if state[i * n + j] == 1
                if count == 2 || count == 3
                    new_state |= (1 << i * n + j)
                end
            elsif count == 3
                new_state |= (1 << i * n + j)
            end
        end
    end
    new_state
end

loop do
    n = gets.to_i
    break if n == 0

    inf_state = 0
    x = y = nil
    n.times do |i|
        gets.chomp.each_char.with_index do |c, j|
            if c == ?#
                inf_state |= (1 << i * n + j)
            elsif c == ?@
                y = i
                x = j
            end
        end
    end

    if inf_state == 0
        puts 0
        next
    end

    state = (inf_state << 6) + (x << 3) + y
    queue = [state]
    reached = Set[state]
    d = 1

    catch(:break) do
        until queue.empty?
            new_queue = []
            until queue.empty?
                state = queue.shift
                inf_state, x0, y0 = state >> 6, (state >> 3) & 7, state & 7
                [-1, 0, 1].repeated_permutation(2) do |dx, dy|
                    next if dx == 0 && dy == 0
                    x, y = x0 + dx, y0 + dy
                    next if x < 0 || x >= n || y < 0 || y >= n
                    next if inf_state[y * n + x] == 1

                    k = y * n + x
                    changed = change_state(n, inf_state + (1 << k))
                    changed -= (1 << k) if changed[k] == 1

                    if changed == 0
                        throw :break
                    end

                    new_state = (changed << 6) + (x << 3) + y
                    next if reached.include?(new_state)
                    reached << new_state
                    new_queue << new_state
                end
            end
            queue = new_queue
            d += 1
        end
        d = -1
    end

    p d
end

Measured memory_bytes: 25408