akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e17
    const int N=1e6+6;
    const int M=1e9+7;
    
    signed main(){
    	FAST
    	int n;
    	cin>>n;
    	int a[n];
    	for(int i=0;i<n;i++)
    	{
    		cin>>a[i];
    	}
    	set<int> s;
    	int ans=0;
    	for(int i=0;i<n;i++)
    	{
    		s.insert(a[i]);
    		if(*s.begin()==a[i])
    		ans++;
    	}
    	cout<<ans;
    } 
  

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define llrep(i,a,b) for(ll i=a;i<b;i++)
#define llrepd(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; const ll MOD = 1000000007;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//---------------------------------------------------------------------------------------------------
void _main() {
    ll N; cin >> N;
    vector<ll> L(N);
    ll count = 0;
    rep(i, 0, N) {
        count++; L[i] = count;
    }
    vector<ll> P(N); rep(i, 0, N) cin >> P[i];
    vector<ll> Q(N); rep(i, 0, N) cin >> Q[i];
    ll p, q;
    count = 0;
    do{
        count++;
        bool p_state = true, q_state = true;
        rep(i, 0, N) {
            if (L[i] != P[i]) p_state = false;
            if (L[i] != Q[i]) q_state = false;
        }
        if(p_state) p = count;
        if(q_state) q = count;
    }while(next_permutation(all(L)));
    cout << abs(p-q) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if((a*b)%2==0)
        {
            cout<<"Even"<<endl;
        }
        else
        {
            cout<<"Odd"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
# print('hello world')

n = int(input())
R = []
for i in range(n):
    R.append(int(input()))

# max_profit = None
# min_price = R[0]
#
# for i in range(1, n, 1):
#     if R[i] > min_price:
#         profit = R[i] - min_price
#         if profit > max_profit:
#             max_profit = profit
#     elif R[i] < min_price:
#         min_price = R[i]
#
# print(min_price)

min_value_tmp = R[0]
max_profit_tmp = - 10 ** 9

for i in range(1, n, 1):
    max_profit_tmp = max(max_profit_tmp, R[i]-min_value_tmp)
    min_value_tmp = min(min_value_tmp, R[i])
    # print(i, max_profit_tmp, min_value_tmp)

print(max_profit_tmp)



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

using namespace std;

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

int main() {
    int a, b, x, y;
    //cin >> a >> b >> x >> y;
    scanf("%d%d%d%d",&a,&b,&x,&y);
//    int ans = 0;
//    if(x == a / 2 && y == b / 2) ans = 1;
    int ans = (x+x==a && y+y==b);
    cout << setprecision(9) << (double(a)*double(b))/2 << " " << ans << endl;
    //printf("%lf %d\n", double(a) * double(b) / 2, x+x==a && y+y==b);
}


Measured memory_bytes: 384
from bisect import bisect_right
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    b = [v for v in a]
    for i in range(1, n):
        b[i] += b[i-1]
    ans = 0
    for i in range(n):
        target = b[i]
        index = bisect_right(a, 2*target)
        while index < n:
            target = b[index-1]
            j = index-1
            index = bisect_right(a, 2*target)
            if j+1 == index:
                break
        if index == n:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14480
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S; cin >> S;
    S[3] = '8';
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 3604
//given n integers and an integer m such that n>m then there exits a pair
//(a-b) such that (a-b)%m==0

#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
const ll M=1000000007;
void solve(){
 ll n,d,ans=0;
 cin>>n>>d;
 for(ll i=0;i<n;i++){
    ll x,y;
    cin>>x>>y;
    if(sqrt(x*x+y*y)<=d)ans++;
 }
 cout<<ans;
}

int main(){
 int t=1;
 //cin>>t;
 while(t--){
        solve();
        cout<<endl;
 }
}


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>
#include <iomanip>

using namespace std;

const int CMax = 100002;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, m;

int gcd(int a, int b)
{
    if (b != 0) return gcd(b, a % b);
    else return a;
}

string baseConverter(int base, int num) {
    string tNum = "";
    while (num > 0) {
        tNum = (char)('0' + num%base) + tNum;
        num /= base;
    }
}

bool isPalindrom(string tS) {
    int sn = (int)tS.length();
    for (int i = 0; i < sn / 2; i++) {
        if (tS[i] != tS[sn - i - 1]) return false;
    }
    return true;
}

int dist(int i, int j) {
    return  (j < i ? n + j : j) - i;
}

long long greatestDivisor(long long a) {
    for (int i = 2; i <= (long long)sqrt(a); i++) {
        if (a % i == 0) return a / i;
    }
    return a;
}

int main()
{
    int W, H, x, y, e = 0.000000001;
    scanf("%d %d %d %d", &W, &H, &x, &y);
    cout << std::fixed;

    cout << setprecision(9) << ((double)W * (double)H) / 2;
    if (W % 2 == 0 && H % 2 == 0 && W / 2 == x && H / 2 == y) {
        cout << " 1"<< endl;
    } else {
        cout << " 0"<< endl;
    }



    return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = [input() for i in range(N)]

AC= 0
WA = 0
TLE = 0
RE = 0

for i in range(len(ans)):
    if ans[i] == 'AC':
        AC += 1
    elif ans[i] == 'WA':
        WA += 1
    elif ans[i] == 'TLE':
        TLE += 1
    else:
        RE += 1

print('AC x',AC)
print('WA x',WA)
print('TLE x',TLE)
print('RE x',RE)

Measured memory_bytes: 16316
N = int(input())
H = [int(i) for i in input().split()]
cnt = 0

for i in range(1, N-1):
   
    if H[-i] + 1 == H[-1-i]:
        H[-1-i] = H[-1-i] - 1
    elif H[-i] + 2 <= H[-1-i]:
        print("No")
        cnt = 1
        break
if cnt == 0:
    print("Yes")

Measured memory_bytes: 14252
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::stdout;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const A: i64 = 1;

fn query(n: i64) -> bool {
    println!("? {}", n);
    stdout().flush();
    read::<String>() == "Y"
//     if (A >= n) ^ (A.to_string() >= n.to_string()) {
//         false
//     } else {
//         true
//     }
}

fn main() {
    let mut q = 1;
    let mut qq = 0;
    while q <= 1e11 as i64 {
        if !query(q) {
            qq = q / 10;
            break
        }
        q *= 10;
    }

    if qq == 0 {
        q = 9;
        let mut ans = 1;
        while true {
            if query(q) {
               break;
            }
            ans *= 10;
            q *= 10;
            q += 9;
        }
        println!("! {}", ans);
    } else {
        let mut from = 0;
        let mut to = 9;

        let mut ans = 0;
        while qq >= 1 {
            while to - from > 1 {
                let med = (to + from) / 2;
                let tq = (ans + qq * med + qq - 1) * 10 + 9;
                if query(tq) {
                    to = med;
                } else {
                    from = med;
                }
            }
            ans += qq * to;
            qq /= 10;
            from = -1;
            to = 9;
        }
        println!("! {}", ans);
    }
}

Measured memory_bytes: 4692
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,ans=0;
int main()
{
	cin>>a>>b>>c>>n;
	for(int i=0;i<=n;i+=a) for(int j=0;i+j<=n;j+=b) if((n-i-j)%c==0) ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 3604
s = input()
l = len(s)
a = [0]*l
for i in range(l):
    if s[i] == "A" or s[i] =="T" or s[i] =="C" or s[i] =="G":
        a[i] = 1
m = 0
if a[0] == 1:
  m = 1
for i in range(1,l):
    a[i] = (a[i-1]+1)*a[i]
    if m < a[i]:
        m = a[i]

print(m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    string S;
    cin>>N>>S;
    int ans=0;
    for(int w=0;w<1000;w++){
        string a=to_string(w);
        while(a.size()<3) a="0"+a;
        int c=0;
        rep(i,N){
            if(a[c]==S[i]) c++;
            if(c==3){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    



}


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


int main(){
   int N;
   cin >> N;
   int K;
   cin >> K;
   vector<int> H(N,0);
   for(int i=0;i<N;i++){
      cin>>H[i];
   ;}
   sort(H.begin(), H.end());
   long long int ans=0;
   for(int i=0;i<N-K;i++){
      ans+=H[i]
   ;}
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 1024
/*

Sviatoslav Bidzilia 2019
CF: anakib1

*/

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long

template<typename A, typename B, typename C>
struct triple
{
	A X;
	B Y;
	C Z;
	triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0)
{
	return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b)
{
	if (a.X != b.X)
		return a.X < b.X;
	if (a.Y != b.Y)
		return a.Y < b.Y;
	return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p)
{
	ofs << "( " << p.F << " , " << p.S << " )";
	return ofs;
}
template<typename T>
void print(T a)
{
	for (auto i : a)
		cout << i << ' ';
	cout << '\n';
}
template<typename T>
T max(T a, T b, T c)
{
	return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c)
{
	return min(a, min(b, c));
}
struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
int solve(int x)
{
	if (x == 1)
		return 1;
	return 2 * solve(x / 2) + 1;
}
signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	srand(time(NULL));
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	int  h;
	cin >> h;
	cout << solve(h) << '\n';

}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

vi a,b;
vector<bool> seen;
vi cycle;
int pos;

void dfs(int v, int dep=0)
{
    cycle.pb(v+1);
    b[v] = dep;
    seen[v]=true;
    if (seen[a[v]]){
        pos = b[a[v]];
        return;
    }else{
        dfs(a[v],dep+1);
    }
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k; cin>>n>>k;
    a.resize(n);
    b.resize(n);
    seen.resize(n,false);
    rep(i,n) cin>>a[i];
    rep(i,n) a[i]--;
    dfs(0);
    int p = cycle.size()-pos;
    if (k<=pos){
        cout<<cycle[k]<<"\n";
    }else{
        k-=pos;
        cout<<cycle[k%p+pos]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 14768
using System;
using System.Collections.Generic;
using System.Linq;

namespace A
{

    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineInt();
            var s = new string[n];
            for(int i = 0; i < n; i++) {
                s[i] = ReadLine();
            }
            
            var cyoufuku = s.Distinct();

            Console.WriteLine(cyoufuku.Count());
            ReadLine();
        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N;
  cin >> N;
  vector<pii> p;
  REP(i,N){
    LL x, y;
    cin>>x>>y;
    p.push_back({x, y});
  }

  map<pii, LL> mp;
  REP(i,N){
    REP(j,N){
      if(i!=j){
        mp[{p[i].first - p[j].first, p[i].second - p[j].second}]++;
      }
    }
  }

  LL max = 0;

  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if(max<itr->second){
      max = itr->second;
    }
  }

  cout << N - max << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(int)rept;++i)
typedef long long ll;
using namespace std;
const int mod = 1e+9 + 7;

std::vector<bool> IsPrime;



int main() {
	//14日目

	cin.tie(0); ios::sync_with_stdio(false);

	ll n, m, ans = 0;
	cin >> n >> m;

	ll a;
	a = m / 2;
	if (a < n) {
		ans += a;
		cout << ans << endl;
		return  0;
	}
	else {
		ans += n;
		m -= n * 2;
		cout << ans + (m / 4) << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
struct UnionFind{
    vector<int> par;
    vector<int> siz;
    int c;//親の個数(グループ数)
 
    void init(int n){
        c=n;
        for(int i=0;i<n;i++){
            par.push_back(i);
            siz.push_back(1);
        }
    }
 
    UnionFind(int n){
        init(n);
    }
 
    int root(int x){
        //根を返す
        if(par[x]==x){
            return x;
        }
        else{
            return (par[x]=root(par[x]));
        }
    }
    bool sameParent(int x,int y){
        return(root(x)==root(y));
    }
    void unite(int x, int y){
        x=root(x);y=root(y);
        if(x==y)    return;
        //データ構造->小を大にくっつける
        if(siz[x]<siz[y]) swap(x,y);
        siz[x] += siz[y];
        par[y]=x;
        c--;
    }
 
    int size(int x){
        return siz[root(x)];
    }
};

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

    int n,k,l;cin>>n>>k>>l;
    UnionFind rail(n),road(n);
    rep(_,k){
        int p,q;cin>>p>>q;p--,q--;
        road.unite(p,q);
    }
    rep(_,l){
        int r,s;cin>>r>>s;r--,s--;
        rail.unite(r,s);
    }
    vector<pair<int,int>> v(n);
    map<pair<int,int>,int> mp;
    rep(i,n){
        auto p=make_pair(road.root(i),rail.root(i));
        v[i]=p;
        mp[p]++;
    }
    rep(i,n){
        cout<<mp[v[i]];
        cout<<(i==n-1?'\n':' ');
    }
    return 0;
}


Measured memory_bytes: 16660
#include <stdio.h>          // putchar(), getchar()
#include <ctype.h>          // toupper()

#define N 200
static const int NUL = '\0';

int
main(int argc, char** argv)
{
	int c;

	while ((c = getchar()) != EOF)
		putchar(toupper(c));

	return 0;
}

Measured memory_bytes: 524
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    int[] arr1 = new int[n];
    int min = Integer.MAX_VALUE;
    for(int i=0;i<n;i++){
      if(arr[i]<min){
        min=arr[i];
        arr1[i]=min;
      }
      else{
        arr1[i]=min;
      }
    }
    int ans =0;
    for(int i=0;i<n;i++){
      if(arr[i]<=arr1[i]){
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 65616
n,k,q=map(int,input().split())
# if k>q:
#     for i in range(n):
#         print("Yes")
#         exit()
ans=[k-q for i in range(n)]
for i in range(q):
    ans[int(input())-1]+=1
for i in range(n):
    if ans[i]>0:
        print("Yes")
    else:
        print("No")

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

int main(){
  int N,tmp;
  cin >>N;
  string s;
  cin >> s;
  vector<int>a(N,0);
  for(int i=1;i<N;i++){
    if(s.at(i)=='E')
      a.at(0)++;
  }
  tmp=a.at(0);
  for(int i=1;i<N;i++){
    a.at(i)=a.at(i-1);
    if(s.at(i)=='E')
    a.at(i)=a.at(i-1)-1;
    if(s.at(i-1)=='W')
      a.at(i)=a.at(i)+1;
    tmp=min(tmp,a.at(i));
  }
    cout <<tmp<<endl; 
}

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

int main() {
  int k, n;
  cin >> k >> n;
  
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    sum += a;
  }
  
  if (sum > k) {
    cout << -1 << endl;
  } else { 
    cout << k - sum << endl;
  }
}

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

int main() {
    int h,w;
    string field[60][60]={"."};
    string result[60][60];
    cin >> h >> w;
    for(int i=1;i<=h;i++){
        string s;
        cin >> s;
        for(int j=1;j<=w;j++){
            field[i][j] = s[j-1];
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(field[i][j] == "#"){
                result[i][j] = "#";
            }else{
                int count = 0;
                if(field[i-1][j-1] == "#") count++;
                if(field[i-1][j] == "#") count++;
                if(field[i-1][j+1] == "#") count++;
                if(field[i][j-1] == "#") count++;
                if(field[i][j+1] == "#") count++;
                if(field[i+1][j-1] == "#") count++;
                if(field[i+1][j] == "#") count++;
                if(field[i+1][j+1] == "#") count++;
                result[i][j] = to_string(count);
            }
        }
    }
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cout << result[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 512
s = gets.chomp
k = gets.to_i
as = ('a'..'z').to_a
alps = Hash[as.map.with_index{ |a,i| [a,i] }]
(0...s.size).each{ |i|
  v = alps[s[i]]
  c = (26 - v) % 26
  if c <= k
    k -= c
    s[i] = 'a'
  end
}
#$stderr.puts s,k
s[-1] = as[(alps[s[-1]] + k) % 26]
puts s

Measured memory_bytes: 2044
from collections import Counter, defaultdict
from itertools import count
from functools import reduce


MOD = 10 ** 9 + 7
N = int(input())


def prime_factor(n):
  c = defaultdict(int)
  for i in count(2):
    if i * i > n:
      break
    while n % i == 0:
      c[i] += 1
      n //= i;
  if n != 1:
    c[n] = 1
  return Counter(c)

counter = reduce(
  lambda a, i: a + prime_factor(i),
  range(N, 1, -1),
  Counter()
)
  
answer = reduce(
  lambda a, c: (a * (c + 1)) % MOD,
  counter.values(),
  1
)

print(answer)

Measured memory_bytes: 46064
#include<stdio.h>
int min(int a, int b)
{
	return a < b ? a : b;
}
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	int N,K;
	int h[100010];
	int dp[100010] = { 0 };
	scanf("%d%d", &N,&K);

	for (int i = 1;i <= N;i++)scanf("%d", &h[i]);
	h[0] = h[1];
	for (int i = 2;i <= N;i++)
	{
		int step1 = dp[i - 1] + abs(h[i - 1] - h[i]);
		if (K == 1)dp[i] = step1;
		else {
			for (int j = 2; j <= K;j++)
			{
				int stepCompare = dp[i - j] + abs(h[i - j] - h[i]);
				dp[i] = min(step1, stepCompare);
				step1 = dp[i];
				if (i - j <1)break;
			}
		}
	}
	printf("%d", dp[N]);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  vec b(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  for(ll i=0;i<n;i++) cin >> b[i];
  priority_queue<pll,vector<pll>,greater<pll>> q;
  for(ll i=0;i<n;i++) {
    if(b[i]>a[i]&&b[i]>b[(i+1)%n]+b[(i+n-1)%n]) {
      q.push(pll(b[i],i));
    }
  }
  ll ans=0;
  while(q.size()) {
    ll t=q.top().second;
    q.pop();
    if(a[t]>=b[t]) continue;
    if(b[t]<=b[(t+1)%n]+b[(t+n-1)%n]) continue;
    ll count=min((b[t]-a[t])/(b[(t+1)%n]+b[(t+n-1)%n]),b[t]/(b[(t+1)%n]+b[(t+n-1)%n]));
    b[t]-=count*(b[(t+1)%n]+b[(t+n-1)%n]);
    ans+=count;
    for(ll i=-1;i<2;i++) {
      if(i==0) continue;
      ll nt=(t+i+n)%n;
      if(a[nt]>=b[nt]) continue;
      if(b[nt]<=b[(nt+1)%n]+b[(nt+n-1)%n]) continue;
      q.push(pll(b[nt],nt));
    }
  }
  for(ll i=0;i<n;i++) {
    if(a[i]!=b[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define ub upper_bound
#define pp push_back
#define ep emplace_back
#define all(v) (v).begin(),(v).end()
#define szz(v) ((int)(v).size())
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

vector<int> B, A;
int n;

int main(){
    fio;
    cin >> n;
    for(int i = 0, x; i < n; i++){
        cin >> x;
        B.pp(x);
    }
    while(B.size()){
        int lst = -1;
        for(int i = 0; i < B.size(); i++){
            if(B[i] == i + 1) lst = i;
        }
        if(lst == -1){
            cout << -1 << '\n';
            return 0;
        }
        B.erase(B.begin() + lst);
        A.push_back(lst + 1);
    }
    reverse(all(A));
    for(int a : A) cout << a << '\n'; cout << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, x;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            x = a + b;

            if (x < a - b) x = a - b;
            if (x < a * b) x = a * b;


            Console.WriteLine(x);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();

    let p: Vec<u32> = iter.map(|it| it.parse().unwrap()).collect();

    let mut mins: Vec<u32> = Vec::with_capacity(n);
    let mut min = p[0];
    mins.push(min);
    for i in 1..n {
        let pi = p[i];
        if pi < min {
            min = pi;
        }
        mins.push(min);
    }

    let mut count = 0;
    for i in 0..n {
        let pi = p[i];
        if pi <= mins[i] {
            count += 1;
        }
    }

    return count.to_string();
}

#[test]
fn test() {
    assert_eq!(solve(r"5
    4 2 5 1 3"), "3");
    assert_eq!(solve(r"4
    4 3 2 1"), "4");
    assert_eq!(solve(r"6
    1 2 3 4 5 6"), "1");
    assert_eq!(solve(r"8
    5 7 4 2 6 8 1 3"), "4");
    assert_eq!(solve(r"1
    1"), "1");
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <queue>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  sort(RALL(p));
  sort(RALL(q));
  sort(RALL(r));
  priority_queue<pair<int, int>> pq;
  rep(i, a) pq.push({p[i], 1});
  rep(i, b) pq.push({q[i], 2});
  rep(i, c) pq.push({r[i], 3});
  ll sum = 0;
  int n1 = 0, n2 = 0;
  for(int i = 0; i < x+y; i++){
    int c = pq.top().second;
    int v = pq.top().first;
    pq.pop();
    if(c == 1) n1++;
    if(c == 2) n2++;
    if((n1 > x && c == 1) || (c == 2 && n2 > y)){
      i--;
      continue;
    }
    sum += v;
  }

  cout << sum << endl;

}


Measured memory_bytes: 8688
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        boolean first = false;
        boolean second = false;
        for(int i = 0; i < N; i++) {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        }


        os.println("No");
    }
}

Measured memory_bytes: 27236
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N;

int X[MAX_N];

unordered_map<int, int> mp;

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

    cin >> N;

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (mp.count(a)) {
            mp[a]++;
        } else {
            mp.insert(P(a, 1));
        }
    }

    int ans = 0;
    for (auto ite = mp.begin(); ite != mp.end(); ite++) {
        if (ite->first > ite->second) {
            ans += ite->second;
        } else if (ite->first < ite->second) {
            ans += ite->second - ite->first;
        }
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 7180
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define fr(i,a,b) for(ll i=(a);i<(b);i++)
#define frd(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl "\n"
#define inf ((long long) 1e18 + 10)
#define ve vector<ll>
using namespace std;


int main() {
        std::ios::sync_with_stdio(false);
        cin.tie(0);cout.tie(0);
        int n,m;
        cin>>n>>m;
        if(n > m)
                cout<<"safe\n";
        else
                cout<<"unsafe\n";
        return 0;
}



Measured memory_bytes: 3652
f=lambda:map(int,input().split())
n,m=f()
lt=[]
ll=[[0]*n for _ in range(n)]
for _ in range(m):
  a,b=f()
  a-=1;b-=1
  lt+=[(a,b)]
  ll[a][b]=ll[b][a]=1
def dfs(x):
  if lv[x]>0: return
  lv[x]=1
  for i in range(n):
    if ll[i][x]>0: dfs(i)
c=0
for a,b in lt:
  ll[a][b]=ll[b][a]=0
  lv=[0]*n
  dfs(0)
  if sum(lv)<n: c+=1
  ll[a][b]=ll[b][a]=1
print(c)

Measured memory_bytes: 3064
#include<bits//stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n, ans = 0,h; cin >> n;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i) continue;
        h = n;
        while (h % i == 0) h /= i;
        if (h % i == 1) ans++;
    }h = n - 1;
    for (ll i = 1; i * i < n; i++) {
        if (h % i) continue;
        ans += 2;
        if (i * i == h) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int h[n];
    rep(i,n) cin >> h[i];
    int ans = 0;
    rep (i,n){
        if(h[i] >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	min := math.MaxInt64
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			ans := f(i, n/i)
			if ans < min {
				min = ans
			}
		}
	}
	fmt.Println(min)
}

func f(a, b int) int {
	al := len(strconv.Itoa(a))
	bl := len(strconv.Itoa(b))
	if al > bl {
		return al
	}
	return bl
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

struct edge{int to, cap, rev;};

vector<edge> G[202];
bool used[202];
int n;

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, (int)G[to].size()});
	G[to].push_back((edge){from, 0, (int)G[from].size()-1});
}

int dfs(int v, int t, int f){
	if(v == t) return f;
	used[v] = 1;
	for(int i = 0; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for(;;){
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INF);
		if(f == 0) return flow;
		flow += f;
	}
}

int a[101], b[101], c[101], d[101];

int main(){
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		add_edge(n*2, i, 1);
	}
	for(int i = 0; i < n; i++){
		cin >> c[i] >> d[i];
		add_edge(n+i, n*2+1, 1);
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(a[i] < c[j] && b[i] < d[j])
				add_edge(i, n+j, 1);
		}
	}
	
	cout << max_flow(n*2, n*2+1) << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a,b,c;cin>>a>>b>>c;
  if(a+b>=10){
    cout << "error";
  }else{
    cout << a+b;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include <math.h> 
using namespace std;

main(){
	string x,y,z;
  	cin >> x>> y;
  	z = x+y;
   
  	int n = stoi(z);
  	if (int(sqrt(n))*int(sqrt(n)) == n)
      cout << "Yes"<<endl;

  	else cout << "No" << endl;

  	return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())


def f(x):
    n = x % 4
    if n == 0:
        return x
    elif n == 1:
        return 1
    elif n == 2:
        return x + 1
    elif n == 3:
        return 0


print(f(A-1) ^ f(B))


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

#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a)) 

#define fastio() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file() freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define nl "\n"
#define sp " "

template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

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

const long double N = 1000000000000000000;

int tc = 1;

double eps = 1e-8;

ll ara[100005], ans;

int n, flg;

int main(){   

   	//file();

    fastio();

    //cin >> tc;

    while(tc--){

    	cin >> n;

    	flg = 1;
    	ans = 1;

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

    		cin >> ara[i];

    		if(ara[i] == 0)
    			flg = 0;
    	}
    	
    	if(flg == 0)
    		cout << 0 << nl;
    	else{

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

    			if(N/ans < ara[i] ){
    				flg = -1;
    				break;
    			}
    			else
    				ans *= ara[i];
    		}

    		if(flg == -1)
    			cout <<  (-1) << nl;
    		else
    			cout << ans << nl;

    	}

    }

    return 0;        
        
}

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

int main(){
  int n;
  string s;
  cin >> n;
  
  double temp,sum=0;
  
 cout << setprecision(15);

 for(int i=0;i<n;i++){
   cin >> temp >> s;
   if(s == "JPY"){
     sum += temp;
   }else if(s == "BTC"){
     sum += temp * 380000;
 }
 }
 cout << sum << endl;


 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define print(x) cout << to_string(x) << '\n'
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 998244353;

string to_string(char &c) {string x(1, c); return x;}
string to_string(const char s[]) {return (string)s;}
string to_string(string &s) {return s;}
string to_string(vb &v) {string res; for (const bool &x : v) res += to_string(x) + ' '; return res;}
template <class C> string to_string(C &v) {string res; for (auto &x : v) res += to_string(x) + ' '; return res;}
template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 32;
    string res(d, ' ');
    REP(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n;
    cin >> n;
    vector<pii> robots;
    REP(i, 0, n) {
        int x, s;
        cin >> x >> s;
        robots.push_back({x-s, x+s});
    }
    sort(robots.begin(), robots.end());
    int i=0, j=1;
    vb keep(n, true);
    while (j<n) {
        if (robots[i].second <= robots[j].first) i=j;
        else if (robots[i].second < robots[j].second) {
            keep[j] = false;
        } else {
            keep[i] = false;
            i=j;
        }
        ++j;
    }
    cout << accumulate(keep.begin(), keep.end(), 0LL);
}


Measured memory_bytes: 2420
import os
import heapq

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, M = list(map(int, sys.stdin.buffer.readline().split()))
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

graph = [[] for _ in range(N)]
for a, b in AB:
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

dist = [(INF, None)] * N
dist[0] = 0, None
heap = [(0, 0, None)]
while heap:
    d, v, p = heapq.heappop(heap)
    if dist[v][0] > d:
        continue
    for u in graph[v]:
        if d + 1 >= dist[u][0]:
            continue
        dist[u] = d + 1, v
        heapq.heappush(heap, (d + 1, u, v))
print('Yes')
for d, p in dist[1:]:
    print(p + 1)


Measured memory_bytes: 131272
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<cstdint>

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int64_t> ans(N, 0);
  std::map<int,std::pair<int,int64_t>> m;
  for(int i = 0; i < N; ++i) {
    int a; std::cin >> a;
    if(m.count(a)>0) ++m[a].second;
    else m[a] = std::make_pair(i, 1);
  }
  while(m.size() > 1) {
    auto it = m.end();
    --it;
    auto p = it->second;
    int64_t a = it->first;
    m.erase(it);
    ans[p.first] += (a - m.rbegin()->first)*p.second;
    auto& np = m.rbegin()->second;
    np.first = std::min(np.first, p.first);
    np.second += p.second;
  }
  int a = m.begin()->first;
  auto p = m.begin()->second;
  ans[p.first] += a*p.second;
  for(int i = 0; i < N; ++i) std::cout << ans[i] << "\n";

  return 0;
}


Measured memory_bytes: 8192
d,g=map(int, input().split()) 
pc=[list(map(int, input().split())) for _ in range(d)]

#どの問題を完璧に解くかを全探索
bins = []  
for i in range(2**d): 
    bins.append(list(str(format(i,'b')).zfill(d)))
    
ans=0
for i in range(d):
    ans +=  pc[i][0]
for i in range(2**d):
    #print(bins[i])
    tmp_num = 0
    tmp_ans = 0
    for j in range(d):
        if(bins[i][j]=='1'):
            tmp_num += pc[j][0]*100*(j+1)+pc[j][1]
            tmp_ans += pc[j][0]
        else:
            rest_max = j
    if(tmp_num>=g):
        ans = min(tmp_ans,ans)
    else:
       #print("tmp="+str(tmp_ans))
        plus = -(-(g-tmp_num)//(100*(rest_max+1)))
        if(plus<pc[rest_max][0]):
            tmp_ans += plus
            ans=min(tmp_ans,ans)
        #print("plus="+str(plus))
    #print(ans)
print(ans)
    

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

using namespace std;

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

   set<string>s;

   string se;

   while(n--)
   {
       cin>>se;
       s.insert(se);
   }

   cout<<s.size();

}

int main()
{

   ios::sync_with_stdio(0);
   cin.tie(NULL);

   solve();

   return 0;
}


Measured memory_bytes: 19204
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
using namespace std;
int hot[201] = { 0 };
int cloth_low[201] = { 0 };
int cloth_high[201] = { 0 };
int cloth_hade[201] = { 0 };
int dp[201][201] = { 0 };
int main() {
	int d, n;
	scanf("%d%d", &d, &n);
	for (int i = 1;i <= d;++i) scanf("%d", &hot[i]);
	for (int i = 1;i <= n;++i) scanf("%d%d%d", &cloth_low[i], &cloth_high[i], &cloth_hade[i]);
	for (int i = 2;i <= d;++i) {
		for (int backcloth = 1;backcloth <= n;++backcloth) {
			if (cloth_low[backcloth] <= hot[i-1] && hot[i-1] <= cloth_high[backcloth]) {
				for (int nowcloth = 1;nowcloth <= n;++nowcloth) {
					if (cloth_low[nowcloth] <= hot[i] && hot[i] <= cloth_high[nowcloth]) {
						int hoge = 0;
						if (cloth_hade[backcloth] < cloth_hade[nowcloth]) {
							 hoge = cloth_hade[nowcloth] - cloth_hade[backcloth];
						}
						else {
							hoge = cloth_hade[backcloth] - cloth_hade[nowcloth];
						}
						dp[i][nowcloth] = max(dp[i][nowcloth], dp[i - 1][backcloth] + hoge);
					}
				}
			}
		}
	}
	int maxes = 0;
	for (int i = 1;i <= n;++i) {
		maxes = max(maxes, dp[d][i]);
	}
	printf("%d\n", maxes);
}


Measured memory_bytes: 1192