akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define MOD 1000000007

int main()
{
	int n,m;cin >> n >> m;
	
	vector<ll> w;
	vector<ll> h;
	
	REP(i,n)
	{
		ll tmp;cin >> tmp;w.PB(tmp);
	}
	REP(i,m)
	{
		ll tmp;cin >> tmp;h.PB(tmp);
	}
	ll H=0,W=0;
	
	REP(i,n-1)
	{
		ll now = abs(w[i+1] - w[i]);
		now = (now*(i+1))%MOD;
		now = (now*(n-(i+1)))%MOD;
		W = (W+now)%MOD;
	}
	
	REP(i,m-1)
	{
		ll now = abs(h[i+1]-h[i]);
		now = (now*(i+1))%MOD;
		now = (now*(m-(i+1)))%MOD;
		H = (H+now)%MOD;
	}
	
	ll ret = (H*W)%MOD;
	
	cout << ret << endl;
		
	
	
	
	return 0;
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    cout << A[N - 1] - A[0] << "\n";
}

Measured memory_bytes: 3624
import sys

def S(): return sys.stdin.readline().rstrip()
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

H,W,K = map(int,S().split())
c = [LS2() for i in range(H)]
for i in range(H):
    for j in range(W):
        if c[i][j] == '.':
            c[i][j] = 0
        else:
            c[i][j] = 1

from copy import deepcopy

# bit全探索

ans = 0
for i in range(2**H):
    A = []
    for k in range(H):
        if (i >> k) & 1:
            A.append(k)
    for j in range(2**W):
        B = []
        for l in range(W):
            if (j >> l) & 1:
                B.append(l)
        d = deepcopy(c)
        for k in range(H):
            for l in range(W):
                if k in A or l in B:
                    d[k][l] = 0
        if sum(sum(d[k]) for k in range(H)) == K:
            ans += 1

print(ans)

Measured memory_bytes: 72576
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;	
	string s[100];
	for(int i=0;i<h;i++)cin>>s[i];
	for(int i=0;i<h+2;i++){
		for(int j=0;j<w+2;j++){
			if(i==0||i==h+1||j==0||j==w+1)cout<<'#';
            else cout<<s[i-1][j-1];
        }
		cout<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: usize,
        d: usize,
        xy: [(i64, i64); n],
    };

    let mut ans = 0;
    let mut dd = d * d;
    for &(x, y) in &xy {
        if (x * x + y * y) as usize <= dd {
            ans += 1;
        }
    }

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


Measured memory_bytes: 7788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  ll m;
  cin >> m;
  ll dig = 0;
  ll dsum = 0;
  for (int i = 0; i < m; i++) {
    ll d, c;
    cin >> d >> c;
    dig += c;
    dsum += c * d;
  }

  cout << ((dsum - 1) / 9) + (dig - 1) << endl;
}


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

int main(){
    int N; cin >> N;
    vector<int> V(N);
    for(int i = 0; i < N; i++) cin >>V[i];
    map<int,int> mp1,mp2;
    set<int> st1,st2;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0){mp1[V[i]]++; st1.insert(V[i]);}
        else {mp2[V[i]]++; st2.insert(V[i]);}
    }
    vector<pair<int,int>> vec1,vec2;
    
    for(auto s:st1)vec1.push_back(make_pair(mp1[s],s));
    for(auto s:st2)vec2.push_back(make_pair(mp2[s],s));
    sort(vec1.begin(),vec1.end(),greater<pair<int,int>>());
    sort(vec2.begin(),vec2.end(),greater<pair<int,int>>());
    
    if(vec1[0].second != vec2[0].second)cout << N - vec1[0].first - vec2[0].first << endl;
    else if( vec1[0].first + vec2[1].first >  vec1[1].first + vec2[0].first ){
        cout << N - vec1[0].first - vec2[1].first << endl;
    }else{
        cout << N - vec1[1].first - vec2[0].first << endl;
    }
    
    
}

Measured memory_bytes: 13880
# import sys
# input = sys.stdin.readline
n = int(input())
h = list(map(int,input().split()))
if n==1:
    print(0)
    exit()
else:
    count_list = []
    count = 0
    i = n-1
    while i<n:
        # print(i)
        if i>0 and h[i-1]>=h[i]:
            count += 1
            i -= 1
        else:
            count_list.append(count)
            count = 0
            if i>0:
                i = i-1
            elif i==0:
                break
print(max(count_list))

Measured memory_bytes: 14252
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    AI=[(a,i) for i,a in enumerate(map(int,input().split()),1)]
    AI.sort()
    I=[i for a,i in AI]
    print(*I)
resolve()

Measured memory_bytes: 64748
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using f32 = float;
using f64 = double;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
inline void fast_io()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

int main(int argc, char *argv[])
{
    using namespace std;
    fast_io();

    long long n;
    string s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    cin >> n >> s;
    long long num = 0;
    for (long long i = 0; i < n; i++) {
        if (s[i] == 'R')
            r.push_back(i + 1);
        if (s[i] == 'G')
            g.push_back(i + 1);
        if (s[i] == 'B')
            b.push_back(i + 1);
    }
    for (auto i : r)
        for (auto j : g)
            for (auto k : b) {
                if (2 * j == i + k)
                    continue;
                if (2 * k == i + j)
                    continue;
                if (2 * i == j + k)
                    continue;
                num++;
            }
    cout << num;
}

Measured memory_bytes: 3236
#include<iostream>
#include<stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
using namespace std;

void f(int n, double p, int *x, int *y)
{
	double sum=0;
    for(int i=0; i<n; i++){
        sum+=pow((double)abs(x[i]-y[i]), p);
	}
	printf("%.8f\n", pow(sum, 1.0/p));
}

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

	int i;
	int x[100], y[100];

	for(i=0; i<n; i++)cin >> x[i];
	for(i=0; i<n; i++)cin >> y[i];

    f(n, 1.0, x, y);
	f(n, 2.0, x, y);
	f(n, 3.0, x, y);

	double max=0.0;

    for(i=0; i<n; i++){
        if(max < abs(x[i]-y[i]))max = (double)abs(x[i]-y[i]);
	}
	printf("%.8f\n", max);


	
    return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;
    int count;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
        count = n;
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;
        --count;

        return true;
    }
};




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

    int N, K, L; cin >> N >> K >> L;
    UnionFind rail(N), road(N);

    rep(i, K){
        int p, q; cin >> p >> q;
        --p; --q;
        road.connect(p, q);
    }
    rep(i, L){
        int s, t; cin >> s >> t;
        --s; --t;
        rail.connect(s, t);
    }

    map<pair<int, int>, int> mp;
    rep(i, N) ++mp[make_pair(road.root(i), rail.root(i))];

    rep(i, N) cout << mp[make_pair(road.root(i), rail.root(i))] << ' ';
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 13568
/*
Author : N_o_o_B
Created : April 22 2020 23:17:10 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#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 ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll n;
    cin >> n;
    int d = 0;
    int cnt = 0;
    int sum = 0;
    while(n){
        d = n%10;
        sum += d;
        n /= 10;
        cnt++;
    }
    
    cout << max(sum,d-1+(cnt-1)*9)<< endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 998244353;
const int MAX = 510000;

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;
}
signed main(void){
    COMinit();
    int n,a,b,k; cin>>n>>a>>b>>k;
    int ans = 0;
    for(int i=0;i<=300000;i++){
        int blue = k - a*i;
        if(blue%b) continue;
        blue /=b;
        if(max(i, blue)>n) continue;
        ans += COM(n, i)*COM(n, blue);
        ans %= MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12160
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = [0] * 50

for i in a:
    for j in range(50):
        if i & (1 << j) == 0:
            cnt[j] += 1 << j
        else:
            cnt[j] -= 1 << j

gg = []
for i in range(50):
    gg.append([cnt[i], i])
gg.sort(reverse = True)

ans = 0
for i in gg:
    if i[0] < 0:
        break
    if (1 << i[1]) <= k:
        k -= 1 << i[1]
        ans += i[0]

print(ans + sum(a))

Measured memory_bytes: 15144
#include <bits/stdc++.h>
using namespace std;
 
static const int DAYS = 3;
 
int main(){
  int rain = 0;
  int ans = 0;
  string sdays;
  cin >> sdays;
  for(int i = 0; i < DAYS; i++){
    if(sdays.at(i) == 'R'){
      ++rain;
      if(ans < rain){
        ans = rain;
      }
    }else{
      rain = 0;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define lp(i, a, b) for (int i=a; i<(b); i++)
#define lpd(i,a,b) for (int i = (b)-1; i >= a; i--)
	
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin>>n;

    for (int i=1;i<=9;++i){
        int a = n/i;
        if (n%i==0 && a>=1 && a<=9) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
 
    return 0;
}

Measured memory_bytes: 256
x = gets
ans = 0
o = ''
l = 0
x.each_char do |c|
    if c == 'R'
        if o == 'R'
            l += 1
        else
            l = 1
        end
    else
        l = 0
    end
    o = c
    ans = [ans,l].max
end
p ans


Measured memory_bytes: 14340
n = int(input())
a = [int(i) for i in input().split()]
if n == 1:
    ans = 1
else:
    if a[1] > a[0]:
        temp = 1
    elif a[1] < a[0]:
        temp = -1
    else:
        temp = 0
    ans = 1
    for i in range(1, n-1):
        if a[i+1] > a[i]:
            if temp >= 0:
                temp = 1
            elif temp == -1:
                ans += 1
                temp = 0
        elif a[i+1] < a[i]:
            if temp <= 0:
                temp = -1
            elif temp == 1:
                ans += 1
                temp = 0
print(ans)

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

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


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(9);
    int N;
    cin >> N;
    int res = N % 1000;
    if (res == 0) cout << 0 << "\n";
    else cout << 1000 - res << "\n";
}

Measured memory_bytes: 3644
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (h, n) = (0 until 2).map { sc.nextLong() }
    val a = (0 until n).map { sc.nextInt() }
    val sumA = a.sum()
    if (h > sumA) {
        println("No")
    } else {
        println("Yes")
    }
}

Measured memory_bytes: 53888
#!/usr/bin/env python
# coding: utf-8

# In[1]:


s = input()


# In[6]:


s_ = s.replace("BC","D")
cnt = 0
ans = 0
for i in range(len(s_)):
    if s_[i] == "A":
        cnt += 1
    elif s_[i] == "D":
        ans += cnt
    else:
        cnt = 0
print(ans)


# In[ ]:






Measured memory_bytes: 9188
n,w=list(map(int,input().split()))
m=0
d={0:0}
for i in range(n):
  nd={}
  a,b=list(map(int,input().split()))
  for j in d:
    if j in nd:
      nd[j]=max(nd[j],d[j])
    else:
      nd[j]=d[j]
    if j+a>w:
      continue
    if j+a in nd:
      nd[j+a]=max(nd[j+a],d[j]+b)
    else:
      nd[j+a]=d[j]+b
    m=max(m,d[j]+b)
  d=nd
print(m)

Measured memory_bytes: 9380
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = str(input())

def win(a):
  if a == "r":
    return P
  elif a == "s":
    return R
  else:
    return S

flag = [0 for i in range(N)]

for i in range(N):
  if i < K or T[i] != T[i-K]:
    flag[i] = win(T[i])
  elif flag[i-K] == 0:
    flag[i] = win(T[i])

print(sum(flag))

Measured memory_bytes: 4212
N = int(input())
weight_list = list(map(int, input().split()))
ans = sum(weight_list)
for i in range(N):
    S1 = sum(weight_list[:i])
    S2 = sum(weight_list[i:])
    num = abs(S1-S2)
    if ans > num:
        ans = num
print(ans)

Measured memory_bytes: 3060
N = int(input().strip())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
    s = input().strip()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    elif s == "RE":
        re += 1

print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

Measured memory_bytes: 9084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#define ll long long
using namespace std;

int main(){
//  cout<<123<<endl;
  int s;string ans;
  cin>>s;
  ans = s<=999?"ABC":"ABD";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll A, B, C, N, M, K;
string S;
vector<ll> vec;

void solve() {
	cin >> N >> A;
	cout << (N < A ? 0 : 10);

}

int main() {
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

def gcd(x,y):
    if y==0:
        return x
    return gcd(y,x%y)

def lcm(x,y):
    return x*y//gcd(x,y)
ans=1
for num in a:
    ans=lcm(ans,num)
    
ans-=1

x=0
for num in a:
    x+=ans%num
print(x)

Measured memory_bytes: 3316
#include <stdio.h>

int ANS[110][110],d[110],f[110],t=1;

void DFS(int i)
{
  int j;
  if(d[i]==0)
    {
      d[i]=t;
      t++;
      for(j=1;ANS[i][j]!=-1;j++) if(d[ANS[i][j]]==0) DFS(ANS[i][j]);
      f[i]=t;
      t++;
    }
}


int main()
{
  int j=0,i=0,n=0,k=0,u=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&u,&k);
      for(j=1;j<=k;j++) scanf("%d",&ANS[i][j]);
      ANS[i][j]=-1;
    }
  for(i=1;i<=n;i++) DFS(i);
  for(i=1;i<=n;i++) printf("%d %d %d\n",i,d[i],f[i]);
  return 0;
}



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

int main(){
  int N , l , r;
  cin >> N;
  int cnt = 0;
  for(int i = 0; i < N ; i++){
    cin >> l >> r;
    cnt += r - l + 1;    
  }
  
  cout << cnt << endl;
  
}

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

using namespace std;

int main()
{
    int i,j=0,t=0,n=0;
    char s[5];
    scanf("%s",s);
    for(i=0;i<3;i++)
    {
        if(s[i]=='a')
            j=1;
        if(s[i]=='b')
            n=1;
        if(s[i]=='c')
            t=1;
    }
    if(n==1&&t==1&&j==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x) cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x) cout << ((x) ? "YES" : "NO") << endl
#define absi(a) (((a) >= 0) ? (a) : (-(a))) 

int main(int argc, const char* argv[]) {
	ll n, m;
	cin >> n >> m;

	if(n >= m) {
		cout << 0 << endl;
		return 0;
	}

	vector<ll> x(m), l(m-1);
	rep(i, m) cin >> x[i];
	sort(x.begin(), x.end());
	rep(i, m-1) l[i] = x[i+1] - x[i];
	sort(l.begin(), l.end(), greater<ll>());

	ll ret = x.back() - x[0];
	rep(i, n-1) {
		debug(ret);
		ret -= l[i];
	}

	cout << ret << endl;

	return 0;
}


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

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

    int a[55] = {
        11, 31, 41, 61, 71, 101, 131, 151, 181, 191,
        211, 241, 251, 271, 281, 311, 331, 401, 421, 431,
        461, 491, 521, 541, 571, 601, 631, 641, 661, 691,
        701, 751, 761, 811, 821, 881, 911, 941, 971, 991,
        1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231,
        1291, 1301, 1321, 1361, 1381
    };

    for (int i = 0; i < N; ++i) cout << a[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

set<string>a;
int main() {
	string s;
	cin>>s;ll n;cin>>n;
	for(int i=0;i<s.size();i++){
		for(int j=1;j+i-1<s.size();j++){
			if(j>n){
				break;
			}
			string t=s.substr(i,j);
			a.insert(t);
		}
	}
    auto itr = a.begin();
    for(int i = 0; i < n-1; ++i)
        ++itr;
        cout << *itr;
	// your code goes here
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; i++){
        cin >> S[i];
    }

    map<string, int> M;
    for(int i=0; i<N; i++){
        M[S[i]]++;
    }

    int max_cnt = 0;
    for(int i=0; i<N; i++){
        max_cnt = max(max_cnt, M[S[i]]);
    }

    for(auto i : M){
        if(i.second == max_cnt){
            cout << i.first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

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

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(double)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50




int main(){
    int N;cin>>N;
    int a[100004];
    REP(i,N){
        cin>>a[i];
    }
    sort(a,a+N);
    bool f=false;
    if(a[0]==a[N-1]){
        if(a[0]==N-1||N%a[0]==0)f=true;
    }else if(a[N-1]-a[0]==1){
        int cnt=0;
        REP(i,N)if(a[i]==a[N-1])cnt++;
        if(cnt>=2){
            if(N-cnt==a[0])f=true;
            else{
                int sho=cnt/2;
                if(sho+(N-cnt)==a[N-1]){
                    f=true;
                }
            }
        }
    }
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 640
H,N = map(int,input().split())
DP = [10**9]*(H+1)
DP[0] = 0
AB_s = [list(map(int,input().split())) for _ in range(N)]
for i in range(H):
    for AB in AB_s:
        goal = min(AB[0] + i, H)
        DP[goal] = min(DP[goal],DP[i]+AB[1])
print(DP[-1])




Measured memory_bytes: 41836
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;
typedef long double ld;

const ld EPS = 10e-14;

void solve();


int main( void ) {

	solve();

	return 0;
}

void solve() {

	ld d, e, f = 0.0;
	cin >> d;

	f = floor( d );
	if( d*d - f*f + EPS < 1.0 ) {
		e = f + 1.0;
	}
	d = sqrt(2.0)*d;

	cout << fixed << setprecision(14) << max(d,e) << endl;

	return;

}

Measured memory_bytes: 3284
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int a[128][2];
	int s1 = 0, s2 = 0;
	for(int i=0; i<n; ++i)
	{
		cin >> a[i][0];
		s1 += a[i][0];
	}
	for(int i=0; i<n; ++i)
	{
		cin >> a[i][1];
		s2 += a[i][1];
	}

	int ans = 0;
	
	int p1 = 0, p2 = 0;
	for(int i=0; i<n; ++i)
	{
		int v = p1 + a[i][0] + (s2-p2);
		p1 += a[i][0];
		p2 += a[i][1];
		ans = max(ans, v);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int memo[100001];
int to[100001], ne[100001], he[100001];
int dfs(int A) {
	if (memo[A] != -1) return memo[A];
	int saidai = 0;
	for (int i = he[A]; i; i = ne[i]) {
		chmax(saidai, dfs(to[i]));
	}
	return memo[A] = saidai + 1;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), M = getint();
	rep1(i, M) {
		int x = getint();
		to[i] = getint();
		ne[i] = he[x];
		he[x] = i;
	}

	rep1(i, N) memo[i] = -1;

	int saidai = 0;
	rep1(i, N) if (memo[i] == -1) chmax(saidai, dfs(i) - 1);
	printf("%d", saidai);

	Would you please return 0;
}

Measured memory_bytes: 2944
N=int(input())
R=[]
for i in range(N):
    X,L=map(int, input().split())
    R.append((X-L,X+L))

R=sorted(R)
now=-(10**9+1)
minr=-(10**9+1)
count=0
for t in R:
    l,r=t
    if now<=l:
        if l<minr:
            minr=min(r,minr)
        else:
            count+=1
            now=l
            minr=r
    else:
        continue

print(count)


Measured memory_bytes: 17752
// 2011/11/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int t1, t2, t3, t4;
	cin >> t1;
	cin >> t2;
	cin >> t3;
	cin >> t4;

	int total = t1+t2+t3+t4;
	int x = total/60;
	int y = total%60;

	cout << x << endl;
	cout << y << endl;

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define reps(i,j,k) for(int i=j;i<k;i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second 

using namespace std;

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

int main(){
	string s, t;
	cin >> s >> t;
	map<char, char> m,n;
	int l = s.length();
	bool f = true;
	rep(i,l){
		if(m.find(s[i])==m.end()) m[s[i]] = t[i];
		else if (m[s[i]] != t[i]) f = false;
		if(n.find(t[i])==n.end()) n[t[i]] = s[i];
		else if (n[t[i]] != s[i]) f = false;
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 776
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);   
      int N = sc.nextInt();
      int K = sc.nextInt();
      if(K==1){
        System.out.println("0");
      }else{
        System.out.println(N-K);
      }
    }
}

Measured memory_bytes: 35708
import sys
sys.setrecursionlimit(10 ** 6)
N, M, Q = map(int, input().split())
Q = [list(map(int,input().split())) for _ in range(Q)]
ans = 0
A = []


def dfs():
    global A
    if len(A) == N:
        return
    global ans
    if len(A) == 0:
        start = 1
    else:
        start = A[-1]
    for i in range(start, M + 1):
        A.append(i)
        dfs()
        if len(A) != N:
            A.pop()
            continue
        # print(A)
        tmp_ans = 0
        for a, b, c, d in Q:
            if A[b - 1] - A[a - 1] == c:
                tmp_ans += d
        ans = max(ans, tmp_ans)
        A.pop()


dfs()
print(ans)

Measured memory_bytes: 9264
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    string s;cin>>s;
    sort(all(s));
    cout<<(s=="abc"?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            while (true)
            {
                var inputs = Console.ReadLine().Split(' ');
                var nums = Array.ConvertAll(inputs, int.Parse);
                if ((nums[0] | nums[1]) == 0) return;

                var H = nums[0];
                var W = nums[1];
                const char block = '#';

                for (int i = 0; i < H; i++)
                {
                    Console.WriteLine(new String(block, W));
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 5408
a,b,c,d=map(int,input().split())
from fractions import gcd
def lcm(x,y):
  return x * y // gcd(x,y)

cZ = (b//c)-((a-1)//c)

dZ = (b//d)-((a-1)//d)

cdZ = (b//(lcm(c,d)))-((a-1)//(lcm(c,d)))

ans = b-a+1-cZ-dZ+cdZ
print(ans)

Measured memory_bytes: 5332
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def wins(c):
    if c == "r":
        return "p"
    elif c == "s":
        return "r"
    else:
        return "s"

n,k = get_nums_l()
r,s,p = get_nums_l()
point = {
    "r": r,
    "s": s,
    "p": p
}
t = input()

won = [False] * n

ans = 0
for i,c in enumerate(t):
    if i >= k and t[i-k] == c and won[i-k]:
        # 勝てる手が出せない
        # log("lose:", i, c)
        pass
    else:
        # log("win:", i, c, wins(c), point[wins(c)])
        won[i] = True
        ans += point[wins(c)]

print(ans)

Measured memory_bytes: 43248
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}	
	int b[n];
	for (int i = 1; i <= n; i++) {
		cin >> b[i];
	}	
	int c[n];
	for (int i = 1; i <= n - 1; i++) {
		cin >> c[i];
	}

	int x = 0;
	x += b[a[0]];
	for (int i = 1; i < n; i++) {
		if (a[i] == (a[i - 1] + 1)) {
			x += b[a[i]] + c[a[i - 1]];
		} else {
			x += b[a[i]];
		} 
	}

	cout << x << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1010
#define M 200200
using namespace std;

int n, m;
vector<int> G[N];

queue<int> q;
void bfs(int s, int mark, int *vis) {
    q.push(s), vis[s] = mark;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int v : G[u]) {
            if (vis[v]) continue;
            vis[v] = mark, q.push(v);
        }
    }
}

int vis[N][N], v1[N], v2[N], vis2[N][N], ans[N], stk[N], top, id[N][N];

int main() {
#ifdef isLOCAL
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    
    cin >> n >> m;
    for (int i = 1, u, v; i <= m; ++i)
        scanf("%d%d", &u, &v), id[u][v] = i,
        G[u].push_back(v);

    for (int i = 1; i <= n; ++i)
        bfs(i, 1, vis[i]);

    for (int u = 1; u <= n; ++u) {
        memset(v1, 0, sizeof v1);
        memset(v2, 0, sizeof v2);
        top = 0;
        for (int v : G[u])
            stk[++top] = v; 
        for (int i = 1, v; i <= top; ++i)
            if (!v1[v = stk[i]])
                v1[u] = i, bfs(v, i, v1);
        for (int i = top, v; i >= 1; --i)
            if (!v2[v = stk[i]])
                v2[u] = i, bfs(v, i, v2);
        for (int i = 1, v; i <= top; ++i) {
            v = stk[i];
            if (vis[v][u] == (v1[v] != i || v2[v] != i))
                ans[id[u][v]] = 1;
        }
    }
    
    for (int i = 1; i <= m; ++i)
        puts(ans[i] ? "same" : "diff");

    return 0;
}


Measured memory_bytes: 14592
import math

info = list(map(int, input().split()))
num = info[0]
dis = info[1]
A = [list(map(int, input().split())) for i in range(num)]
disA = [math.sqrt(A[i][0]**2 + A[i][1]**2) for i in range(num)]
cnt = 0 
for i in range(num):
    if disA[i] <= dis:
        cnt += 1
print(cnt)


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    if (a == b) cnt++;
    if (b == c) cnt++;
    if (a == c) cnt++;

    if (cnt == 3) cout << 1 << endl;
    else cout << 3 - cnt << endl;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
int n;string s;
int main()
{
	cin>>s;
	if(s[0]==s[1]&&s[1]==s[2])
		puts("No");
	else
		puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <bits/stdc++.h>
#include <vector>
typedef long long ll; 
const ll maxi = (2 * 1e5 + 3);
ll mod = (1e9 + 7);
using namespace std;

int main() {
  	ll N;
  	ll K;
	cin >> N;
  	vector<ll> input(N);
  	unordered_map<int, int> hash;
  	ll sum = 0;
  	for(int i = 0; i < N; i++) {
      cin >> input[i];
      hash[input[i]]++;
      sum += input[i];
    }
  	cin >> K;
    ll orig, upd;
    for(int i = 0; i < K; i++){
      cin >> orig >> upd;
      ll num = hash[orig];
      ll diff = upd - orig;
      sum += diff * num;
      cout << sum << endl;
      hash.erase(orig);
      hash[upd] += num;
    }
}

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

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> maze(h,vector<char>(w));
    vector<vector<int>> seen(h,vector<int>(w,-1));
    queue<pair<int,int>> q;

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> maze[i][j];
            if(maze[i][j] == '#'){
                q.push(make_pair(i,j));
                seen[i][j] = 0;
            }
        }
    }

    int ans = 0;

    vector<int> dy(4); dy = {1,0,0,-1};
    vector<int> dx(4); dx = {0,1,-1,0};

    while(!q.empty()){
        int y = q.front().first;
        int x = q.front().second;
        q.pop();

        for(int i=0; i<4; i++){
            int ny = y + dy[i];
            int nx = x + dx[i];

            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(seen[ny][nx] != -1) continue;

            seen[ny][nx] = seen[y][x] + 1;
            q.push(make_pair(ny,nx));
            ans = max(ans,seen[ny][nx]);
        }
    }
    cout << ans << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    int m,x,y;
    m=n/2;
    x=arr[m-1];
    y=arr[m];
    if(x==y)
        cout<<0;
    else
    {
        y-=x;cout<<y;
    }

    //code goes here
	return 0;
}


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

#include <math.h>
#include <stdlib.h>


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

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; }

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    if(n/10 == 9 || n % 10 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int ans=0,i=0,j;
  string s;
  cin>>s;
  j=s.size()-1;
  while(i<j){
    if(s[i]!=s[j]){ans++;}
    i++;j--;
  }
  cout<<ans;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <random>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }

bool ok(vi v) {
	sort(all(v));
	return v[0] + v[1] > v[2];
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vi v(n);
		lop(i, n) cin >> v[i];
		int ans = 0;
		lop(i, n) loop(j, i + 1, n) loop(k, j + 1, n) if(v[i] != v[j] and v[i] != v[k] and v[j] != v[k]) ans += ok(vi({v[i], v[j], v[k]}));
		cout << ans << endl;
	}


	return 0;
}


Measured memory_bytes: 3628
# Problem C - Tsundoku

# input
N, M, K = map(int, input().split())
a_nums = list(map(int, input().split()))
b_nums = list(map(int, input().split()))

# initialization
a_sum_list = [0]*(N+1)
b_sum_list = [0]*(M+1)
for i in range(N):
    a_sum_list[i+1] = a_sum_list[i] + a_nums[i]
for i in range(M):
    b_sum_list[i+1] = b_sum_list[i] + b_nums[i]
max_count = 0
b_i = M

# count
for i in range(N+1):
    a_time = a_sum_list[i]

    # a check
    if a_time>K:
        continue

    if b_i>0:
        while a_time+b_sum_list[b_i]>K:
            b_i -= 1
            if b_i==0:
                break
    # update
    max_count = max(max_count, i + b_i)

# output
print(max_count)


Measured memory_bytes: 47516
#include <algorithm>
#include <iostream>
int n, a[100], max, min;
int main() {
    std::cin >> n >> a[1];
    max = min = 1;
    for (int i = 2; i <= n; i++) {
        std::cin >> a[i];
        if (a[i] > a[max]) max = i;
        if (a[i] < a[min]) min = i;
    }
    std::cout << n * 2 - 2 << std::endl;
    if (std::abs(a[max]) > std::abs(a[min])) {
        for (int i = 1; i <= n; i++)
            if (i != max) std::cout << max << ' ' << i << std::endl;
        for (int i = 2; i <= n; i++)
            std::cout << i - 1 << ' ' << i << std::endl;
    } else {
        for (int i = 1; i <= n; i++)
            if (i != min) std::cout << min << ' ' << i << std::endl;
        for (int i = n - 1; i > 0; i--)
            std::cout << i + 1 << ' ' << i << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[int(i) for i in input().split()]
s.sort()
count=0
for x in range(n-2):
  len_one=s[x]
  for f in range(n-x-1):
    len_two=s[f+x+1]
    if len_two==len_one:
      pass
    else:
      for z in range(n-x-f-2):
        len_three=s[z+x+f+2]
        if len_three==len_two or len_three==len_one:
          pass
        else:
          if (len_one+len_two)>len_three:
            count+=1
          else:
            pass
print(count)

Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int n;
   string s;
   cin >> n;
   double pi = 3.141;
   cout << pi*n*2 << endl;
   return 0;
}


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

typedef long long int ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    
    map<string, int> cnt;
    for (int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        
        cnt[s]++;
    }
    
    int maxCnt = -1;
    for (auto it : cnt)
        maxCnt = max(maxCnt, it.second);
    
    for (auto it : cnt)
    {
        if (it.second == maxCnt)
            cout << it.first << "\n";
    }

    return 0;
}


Measured memory_bytes: 23936
#include <iostream>
#include <vector>

using namespace std;
int main(){
  vector<vector<int>> v(3,vector<int>(101,3));
  string l;
  int i=0;
  while(i<3){
    cin>>l;
    for(int j=0;j<l.length();j++){
      if('a'==l[j]){
      	v.at(i).at(j)=0;
      }else if('b'==l[j]){
        v.at(i).at(j)=1;
      }else{
        v.at(i).at(j)=2;
      }
    }
    i++;
  }
  int val=1,temp=1,i_a=0,i_b=0,i_c=0;

  while(true){
    if(0==val){
      temp=v.at(val).at(i_a);
      if(3==temp)
      {
        //cout<<val;
        break;
      }
      val=temp;
      i_a++;
    }else if(1==val){
      temp=v.at(val).at(i_b);
      if(3==temp)
      {
        //cout<<val;
        break;
      }
      val=temp;
      i_b++;
    }else{
      temp=v.at(val).at(i_c);
      if(3==temp)
      {
        //cout<<val;
        break;
      }
      val=temp;
      i_c++;
    }
  }
  string ret;
  if(0==val){
    ret="A";
  }else if(1==val){
    ret="B";
  }else{
    ret="C";
  }
  cout<<ret;
  return 0;
}

Measured memory_bytes: 256