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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N, A, B, C;
vint h;

bool check(int x) {
  int cnt = 0;
  vint g = h;
  rep(i, N) g[i] = max(0LL, h[i]-B*x);
  rep(i, N) {
    if(g[i] == 0) continue;
    cnt += (g[i]+C-1)/C;
  }
  return cnt <= x;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> A >> B;
  C = A - B;
  h.resize(N);
  rep(i, N) cin >> h[i];
  sort(all(h));
  reverse(all(h));
  int lb = 0, ub = h[0]+1;
  while(lb+1 < ub) {
    int mb = (lb+ub)/2;
    if(check(mb)) ub = mb;
    else lb = mb;
  }
  cout << ub << endl;

  return 0;
}


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

int main(){
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    int count = 0;

    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == '-'){
            count++;
        }
    }

    if(count != 1){
        cout << "No" << endl;
    }    
    else if(S.at(A) == '-' && S.size() - A == B + 1){
        cout << "Yes" << endl;
    }
    
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<double,double> P;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int N;
P ps[50];

double triangleArea(P p1, P p2, P p3){
    P a = mp(p2.first-p1.first, p2.second-p1.second),
      b = mp(p3.first-p1.first, p3.second-p1.second);
    return 0.5 * (a.first*b.second - b.first*a.second);
}

int main(){
    int T = 1;

    while(std::cin >> N, N){
        REP(i, N){
            std::cin >> ps[i].first >> ps[i].second;
        }

        double res = 0.0;
        for(int i=1;i+1<N;i++){
            res += triangleArea(ps[0], ps[i], ps[i+1]);
        }

        res = std::abs(res);

        printf("%d %.1f\n", T, res);
        T += 1;
    }
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
const int MAX = 510000;

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

int main()
{

    ll n;
    cin >> n;

    ll d[n][2];

    for (ll i = 0; i < n; i++)
    {
        cin >> d[i][0] >> d[i][1];
    }

    bool ok = false;

    for (ll i = 0; i < n; i++)
    {
        for (ll j = i; j < i + 3; j++)
        {
            if (d[j][0] != d[j][1])
            {
                break;
            }

            if (j == i + 2)
            {
                ok = true;
            }
        }

        if (ok)
        {
            break;
        }
    }

    if (ok)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3672
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long X;
        X = sc.nextLong();
        long[] L = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                L[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, X, L);
    }
}

class Solver {
    public void solve(long N, long X, long[] L) {
        if (X == 0) {
            System.out.println(0);
            return;
        }

        long D = 0;
        for (int i = 0; i < N; i++) {
            D += L[i];
            if (D > X) {
                System.out.println(i + 1);
                return;
            }
        }

        System.out.println(N+1);
    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int  k;
    cin >> k;
    cout << a.at(k-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	double l, r;
	int la=0, ra=0, lb=0, rb=0, lc=0, rc=0, ld=0, rd=0;
	
	while(scanf("%lf %lf",&l, &r)!=EOF){
		if(l>=1.1){
			la++;
		}else if(l<1.1 && l>=0.6){
			lb++;
		}else if(l<0.6 && l>=0.2){
			lc++;
		}else if(l<0.2){
			ld++;
		}
		if(r>=1.1){
			ra++;
		}else if(r<1.1 && r>=0.6){
			rb++;
		}else if(r<0.6 && r>=0.2){
			rc++;
		}else if(r<0.2){
			rd++;
		}
	}
	
	printf("%d %d\n",la, ra);
	printf("%d %d\n",lb, rb);
	printf("%d %d\n",lc, rc);
	printf("%d %d\n",ld, rd);
		
	return 0;
}

Measured memory_bytes: 0
S = input()
result = [1]*len(S)
 
for i,x in enumerate(S):
    if x == "R":
        move_To = S.find("L", i)-1
        result[i] -= 1
        if (move_To - i) % 2 == 0:
            result[move_To] += 1
        else:
            result[move_To+1] += 1
    else:
        move_To = S.rfind("R", 0, i+1) + 1
        result[i] -= 1
        if (i - move_To) % 2 == 0:
            result[move_To] += 1
        else:
            result[move_To-1] += 1
 
print(" ".join(map(str,result)))

Measured memory_bytes: 10484
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int K = scan.nextInt();
			String S = scan.next();
			
			
			if(S.length()<=K) {
				System.out.println(S);
			}else {
				String n = S.substring(0,K)+"...";
				System.out.println(n);
			}
			
		}
		
		
	}
		

}


Measured memory_bytes: 38676
#include<cstdio>
#include<ctime>
int mtod(int month){
  int result=0;
  if(month>1) result+=31;
  if(month>2) result+=29;
  if(month>3) result+=31;
  if(month>4) result+=30;
  if(month>5) result+=31;
  if(month>6) result+=30;
  if(month>7) result+=31;
  if(month>8) result+=31;
  if(month>9) result+=30;
  if(month>10) result+=31;
  if(month>11) result+=30;
  return result;
}
int main(){
  for(;;){
    int m,d;
    scanf("%d %d",&m,&d);
    if(!(m|d)){break;}
    int diff=mtod(m)+d-1;
    switch(diff%7){
    case 0:puts("Thursday");break;
    case 1:puts("Friday");break;
    case 2:puts("Saturday");break;
    case 3:puts("Sunday");break;
    case 4:puts("Monday");break;
    case 5:puts("Tuesday");break;
    case 6:puts("Wednesday");break;
    }
  }
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n; cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  map<char, int> mp;
  for(char c = 'a'; c <= 'z'; ++c) mp[c] = INF;

  rep(i, n) {
    map<char, int> count;
    for(auto c : s[i]) ++count[c];

    for(char c = 'a'; c <= 'z'; ++c) chmin(mp[c], count[c]);
  }
  for(auto c = 'a'; c <= 'z'; ++ c) rep(i, mp[c]) cout << c;
  cout << endl;
}


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

int main()
{
	int N;
	cin >> N;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		cnt += p != i + 1;
	}
	cout << (cnt <= 2 ? "YES" : "NO") << endl;
	return 0;
}


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

int main() {
	int n = 0;
	string s;
	int a[10] = { 2 };
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') {
			a[n] = 0;
			n++;
		}
		else if (s[i] == '1') {
			a[n] = 1;
			n++;
		}
		else if (s[i] == 'B'&&n != 0) n--;
	}
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (a[i] == 2) break;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
const int MAXN = 201;
int a[MAXN] , n;
int main(){
	cin >> n;
	n *= 2;
	for(int i = 1 ; i <= n ; ++ i) cin >> a[i];
	sort(a + 1 , a + n + 1);
	int ans = 0;
	for(int i = 1 ; i <= n ; i += 2) ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int i,s[m],c[m],a[n]={1},d=0;
	for(i=0;i<m;i++)
	{
		cin>>s[i]>>c[i];
		a[s[i]-1]=c[i];
		
	}
	for(i=0;i<m;i++)
	{
		for(int j=i;j<m;j++)
		{
			if(s[i]==s[j])
			{
				if(c[i]!=c[j])
				{
					cout<<-1<<endl;
					return 0;
				}
			}
		}
	}
	for(i=0;i<n;i++)
	{
	d=d+a[i]*pow(10,n-i-1);
	}
	int t=d/(pow(10,n-1));
	if(m==0 && n==1)
	{
		cout<<0<<endl;
		return 0;
	}
	if(t>0 || (n==1 && c[0]==0))
	{
		cout<<d;
	}
	else
	{
		cout<<-1<<endl;
	}
	
}

Measured memory_bytes: 3752
from itertools import product
import numpy as np

H, W, K = [int(n) for n in input().split()]
arr = np.zeros((H, W))
count = 0

for h in range(H):
    row = input()
    arr[h, :] = np.array([0 if mark=='.' else 1 for mark in row])

for row_onehot, col_onehot in product(product(range(2), repeat=H), product(range(2), repeat=W)):
    row_indexes = np.argwhere(np.array(row_onehot)==1).flatten()
    col_indexes = np.argwhere(np.array(col_onehot)==1).flatten()
    arr_ = arr.copy()
    for row_idx in row_indexes:
        arr_[row_idx, :] = 0
    for col_idx in col_indexes:
        arr_[:, col_idx] = 0
    if arr_.sum() == K:
        count += 1

print(count)

Measured memory_bytes: 27268
#include<bits/stdc++.h>
using namespace std;
string a, b;
int n;
bool isnumber(char a)
{
	if(a >= '0' && a <= '9') return true;
	return false;
}
bool cmp(string a, string b)	// b < a is -, return false; b > a is +, return true;
{
	int len1 = a.length(), len2 = b.length();
	int sum1 = 0, sum2 = 0;
	for(int i = 0; i < len1 &&  i < len2; i++)
	{
		if(a[i] < b[i] && !sum1 && !sum2 && (!isnumber(a[i]) || !isnumber(b[i]))) return true;
		if(a[i] > b[i] && !sum1 && !sum2 && (!isnumber(a[i]) || !isnumber(b[i]))) return false;
		
		if(isnumber(a[i]) && isnumber(b[i]))
		{
			int tmp = i;
			while(tmp < len1 && isnumber(a[tmp])) 
			{
				sum1 = sum1 * 10 + (a[tmp] - '0');
				++tmp;
			}
			int tmp2 = i;
			while(tmp2 < len2 && isnumber(b[tmp2]))
			{
				sum2 = sum2 * 10 + (b[tmp2] - '0');
				++tmp2;
			}
			if(sum1 > sum2) return false;
			if(sum1 < sum2) return true;
			sum1 = sum2 = 0;
			int mx = max(tmp, tmp2);
			i = mx - 1;
			if(mx == len1 || mx == len2) break;
		
		}
	}
	if(sum1 != sum2)
	{
		int mlen = min(len1, len2);
		if(mlen == len1 && mlen == len2)
			return sum1 < sum2;
		int i = mlen + 1;
		if(i < len1 && isnumber(a[i]))
			return false;
		if(i < len2 && isnumber(b[i]))
			return true;
	}
	return len1 <= len2;
}
int main()
{
	//freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
	cin >> n;
	cin >> a;
	//cout << "a : " + a << endl;
	while(n--)
	{
		cin >> b;
		//cout << "b : " + b << endl;
		if(cmp(a, b))
			puts("+");
		else 
			puts("-");
	}
	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
typedef vector<i64> vi;
typedef vector<vi> vvi;
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;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  string S="";
  char c;
  vi count(26,0);
  while(cin >> c){
    S = S + c;
    count[c-'a']++;
  }

  i64 ans = 1;
  ans += sz(S) * (sz(S)-1) / 2;
  rep(i,26)
    ans -= count[i]*(count[i]-1)/2;

  cout << ans << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(){
    int n;cin >> n;
    int m;cin >> m;
    pair<ll,ll> p[n];
    for(int i = 0;i<n;i++){
        int a,b;cin >> a >> b;
        p[i] = make_pair(a,b);
    }
    sort(p,p+n);
    ll sum = 0;ll c = 0;ll money = 0;
    while(sum < m){
        if(p[c].second == 0){
            c++;
        }else if(sum + p[c].second <= m){ 
            money += p[c].first*p[c].second;
            sum += p[c].second;
            c++;
        }else{
            money += p[c].first;
            sum += 1;
            p[c].second -= 1;
        }
        //cout << money <<" "<< sum << endl;
    }
    cout << money << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main(){
	int a[]={1,3,5,7,8,10,12};
	int b[]={4,6,9,11};
	int c[]={2};
	int x,y;
	while(scanf("%d%d",&x,&y)!=EOF){
		int i,flag1=0,flag2=0;
		for(i=0;i<7;i++){
			if(a[i]==x)
				flag1=1;
			if(a[i]==y)
				flag2=1;
		}
		for(i=0;i<4;i++){
			if(b[i]==x)
				flag1=2;
			if(b[i]==y)
				flag2=2;
		}
		for(i=0;i<1;i++){
			if(c[i]==x)
				flag1=3;
			if(c[i]==y)
				flag2=3;
		}
		if(flag1==flag2)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
} 

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


int main(){

    string name1;
    cin>>name1;

    cin.ignore();

    string name2;
    cin>>name2;
    bool dekh = true;

    for(int i=0;i<name1.length();i++){


        if(name1.at(i) != name2.at(i)){


            cout<<"No"<<endl;
            dekh = false;
            break;

        }

    }

    if(name2.length()>name1.length() && dekh == true){

        cout<<"Yes"<<endl;

    }


}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] T = new int[N];
		int[] X = new int[N];
		int[] Y = new int[N];
		for(int i = 0;i < N;i++) {
			T[i] = sc.nextInt();
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
			if(!(T[i]%2==(X[i] + Y[i])%2)
					|| X[i] + Y[i] > T[i]) {
				System.out.println("No");
				sc.close();
				return;
			}
		}
		sc.close();
		System.out.println("Yes");
	}
}

Measured memory_bytes: 90980
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
anosize = a.size
count = 0
all = 1
if a.include?(0)
    puts "0"
    exit
end
a.each do |i|
    all = all.to_i
    all = all * i
    all = all.to_s
    if all.size >= 19 
        all = all.to_i
        if all > 1000000000000000000

        puts "-1"
        exit
        end
        all = all.to_s
    end
    count += 1
    if count == anosize
        puts all
    end
end

Measured memory_bytes: 23592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int a[500500], cnt = 0;

void merge (int left, int mid, int right) {
    int n1 = mid - left, n2 = right - mid;
    int L[n1 + 1], R[n2 + 1];
    rep (i, 0, n1) L[i] = a[left + i];
    rep (i, 0, n2) R[i] = a[mid + i];
    L[n1] = inf, R[n2] = inf;

    int i = 0, j = 0;
    rep (k, left, right) {
        if (L[i] <= R[j]) {
            a[k] = L[i];
            i++;
        } else {
            a[k] = R[j];
            j++;
        }
        cnt++;
    }
}

void mergesort (int left, int right) {
    if (right - left > 1) {
        int mid = (left + right) / 2;
        mergesort (left, mid);
        mergesort (mid, right);
        merge (left, mid, right);
    }
}

int main() {
    int n;
    cin >> n;
    rep (i, 0, n) cin >> a[i];
    mergesort (0, n);
    rep (i, 0, n) {
        if (i) cout << " ";
        cout << a[i];
    }
    cout << "\n" << cnt << "\n";
}


Measured memory_bytes: 6972
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, s: chars,
    }
    let mut s = s;
    for i in 0..s.len() {
        let mut c = (s[i] as u8 - b'A') as usize;
        c = (c + n) % 26;
        s[i] = (c as u8 + b'A') as char;
        puts!("{}", s[i]);
    }
    puts!("\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  int l = -1, r = n;
  while(l+1<r){
    int c = (l+r)/2;
    if(a[c]>=k){
      r = c;
      continue;
    }
    int x = lower_bound(a.begin(),a.end(),a[c]) - a.begin();
    vector<bool> dp(k);
    dp[a[x]] = true;
    int res = 1001001001;
    rep(i,n){
      if(i==x) continue;
      int v = a[i];
      rep(jj,k){
        int j = k-1-jj;
        if(!dp[j]) continue;
        if(j+v<k) dp[j+v] = true;
        else res = min(res,(j+v)-k);
      }
    }
    if(res<a[x]) r = c;
    else l = c;
  }
  cout << l+1 << endl;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  ll a, b, c;
  std::cin >> a >> b >> c;

  ll d = c - a - b;
  if(d < 0) {
    std::cout << "No" << '\n';
    return 0;
  }

  if(d * d > a * b * 4) {
    std::cout << "Yes" << '\n';
  } else {
    std::cout << "No" << '\n';
  }
}


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

int main(){
    string n;
    cin >> n;
    bool isgood = true;
    if(n[0] == n[1]) isgood = false;
    if(n[1] == n[2]) isgood = false;
    if(n[2] == n[3]) isgood = false;
    if(isgood){
        cout << "Good" << endl;
    }else{
        cout << "Bad" << endl;
    }
}

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

using namespace std;

int main(){
	string s,t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	int res = 1e9;
	for(int i = 0; i + m - 1 < n; i++){
		string tmp = s.substr(i,m);
		int cnt = 0;
		for(int j = 0; j < m; j++){
			cnt+= tmp[j]!=t[j];
		}
		res = min(res,cnt);
	}
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <tuple>

using namespace std;

int main()
{  
    char a,b;
    cin >> a >> b;
    if(a == 'H' && b == 'H'){
        cout << "H" << endl;
    }
    else if(a == 'H' && b == 'D'){
        cout <<  "D" << endl;
    }
    else if(a == 'D' && b == 'H'){
        cout << "D" << endl;
    }
    else{
        cout << "H" << endl;
    }
}

Measured memory_bytes: 256
N,M,X = map(int,input().split())

C = []

A = []

for i in range(N):

    lis = list(map(int,input().split()))
    C.append(lis[0])
    A.append(lis[1:])

ans = float("inf")

for i in range(2**N):

    now = [0] * M
    ns = 0

    for j in range(N):

        if i & (2**j) > 0:
            ns += C[j]

            for k in range(M):
                now[k] += A[j][k]

    if min(now) >= X:
        ans = min(ans,ns)

if ans == float("inf"):
    print (-1)
else:
    print (ans)


Measured memory_bytes: 74300
#include<stdio.h>
#include<math.h>
int main()
{
    int A,B,i,max,c = 1,x,y;
    scanf("%d%d",&A,&B);
    if(A > B)
    {
        max = A;
    }
    else
    {
        max = B;
    }
    for(i = 1 ; i <= max ; i = i + 1)
    {
        x = abs(A - i);
        y = abs(B - i);
        if(x == y)
        {
            c = 5;
            break;
        }
    }
    if(c == 5)
    {
        printf("%d\n",i);
    }
    else
    {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int n, m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    vector<ll>v(n);rep(i,n)cin>>v[i];
    priority_queue<ll,vector<ll>,greater<ll>>que;
    ll ans=0;
    for(int i=0;i<=min(n,k);i++){
        for(int j=0;j+i<=min(n,k);j++){
            rep(l,i)que.push(v[l]);
            rep(l,j)que.push(v[n-1-l]);
            rep(l,k-i-j){
                if(!que.empty()&&que.top()<0)que.pop();
            }
            ll com=0;
            while(!que.empty()){com+=que.top();que.pop();}
            ans=max(ans,com);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define MAXN 100
int main()
{
	int a,b,t,ans;
	scanf("%d %d",&a,&b);
	if(a<b) t=a,a=b,b=t;
	ans=a-b+1;
	if(a>=0)
		ans=-b;
	if(a>=0&&b>=0) ans=0;
	if(a>=0&&b<=0) 
	{
		printf("Zero\n");
		return 0;
	}
	if(ans%2==0) printf("Positive\n");
	if(ans%2) printf("Negative\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    deque<int> q;
    bool flip = false;
    rep(i, n) {
        if (!flip) {
            q.push_back(a[i]);
        }
        else {
            q.push_front(a[i]);
        }
        flip = !flip;
    }

    rep(i, n) {
        int ans;
        if (!flip) {
            ans = q.front();
            q.pop_front();
        }
        else {
            ans = q.back();
            q.pop_back();
        }
        cout << ans << " ";
    }
    cout << endl;
    
    return 0;
}


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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
}

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
   long long n;
   cin>>n;
   string s;
   cin>>s;

   if(n>=3200){
    cout<<s<<endl;
   }
   else{
    cout<<"red"<<endl;
   }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}


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

int main()
{
    int a, b, c, x, count=0;
    cin >> a >> b>> c>>x;



        for (int i = 0; i <= a; i++)
        {
            for (int j = 0; j <= b; j++)
            {
                for (int k = 0; k <= c; k++)
                {
                    if (x - ((500 * i) + (100 * j) + (50 * k)) == 0){
                        /*
                        cout << "OK a: "<<i << endl;
                        cout << "OK b: "<< j << endl;
                        cout << "OK c: " << k << endl;
                        cout << endl;
                         */
                        count++;
                    }
                    else{
                        /*
                        cout << "NG a: " << i << endl;
                        cout << "NG b: " << j << endl;
                        cout << "NG c: " << k << endl;
                        cout << endl;
                         */
                    }

                }
            }
        }

    cout << count << endl;



}

Measured memory_bytes: 256
n,k,q = map(int,input().split())
point_list = [k for i in range(n)]
for i in range(q):
  point_list[int(input()) - 1] += 1
ans_list = []
for j in point_list:
  ans_list.append(j - q)
for a in ans_list:
  if a>=1:
    print("Yes")
  else:
    print("No")
  
  
  
  

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


// # DEFINES # //
#define ll long long
#define M (ll)(1e9+7)
#define EPS 1e-9

using namespace std;

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

    ll a, b, c, k;

    cin >> a >> b >> c >> k;

    while(k) {
        if(a > b && b > c)
            a *= 2;
        else if(b > c && b > a)
            b *= 2;
        else 
            c *= 2;

        k--;
    }

    cout << (a + b + c) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <mutex>
#include <queue>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 30;
int n, m, c, s, g;

struct Line {
	int x, y, c;
	ll d;
} lines[10000];

int p[20];
int q[20][10000];
int r[20][10000];
vector<ll> cost[20], seg[20];

ll calc(int c, int d) {
	if (d == 0) return 0;
	int idx = upper_bound(seg[c].begin(), seg[c].end(), d) - seg[c].begin() - 1;
	int rem = d - seg[c][idx];
	return cost[c][idx] + rem * r[c][idx];
}

typedef ll W;

struct edge {
	int to;
	W cost;
};

typedef pair<W, int> P;
typedef vector<vector<edge> > Graph;

void dijkstra(int s, const Graph G, vector<W>& d) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d.begin(), d.end(), INF);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

ll wf[100][100];
ll money[100][100];

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

	while (cin >> n >> m >> c >> s >> g , n) {
		s-- , g--;
		for (int i = 0; i < m; i++) {
			cin >> lines[i].x >> lines[i].y >> lines[i].d >> lines[i].c;
			lines[i].x-- , lines[i].y-- , lines[i].c--;
		}


		for (int i = 0; i < c; i++) {
			cin >> p[i];
		}
		for (int i = 0; i < c; i++) {
			seg[i].clear();
			cost[i].clear();
			seg[i].push_back(0);
			cost[i].push_back(0);
			for (int j = 0; j < p[i] - 1; j++) cin >> q[i][j];
			for (int j = 0; j < p[i]; j++) cin >> r[i][j];
			ll sum = 0;
			for (int j = 0; j < p[i] - 1; j++) {
				seg[i].push_back(q[i][j]);
				sum += (seg[i][j + 1] - seg[i][j]) * r[i][j];
				cost[i].push_back(sum);
			}
			seg[i].push_back(INF);
			cost[i].push_back(INF);
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				money[i][j] = INF;
			}
		}

		for (int cc = 0; cc < c; cc++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					wf[i][j] = (i == j) ? 0 : INF;
				}
			}
			for (int i = 0; i < m; i++) {
				if (lines[i].c != cc) continue;
				wf[lines[i].x][lines[i].y] = min(wf[lines[i].x][lines[i].y], lines[i].d);
				wf[lines[i].y][lines[i].x] = min(wf[lines[i].y][lines[i].x], lines[i].d);
			}

			for (int k = 0; k < n; k++) {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
					}
				}
			}
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					money[i][j] = min(money[i][j], calc(cc, wf[i][j]));
				}
			}
		}

		Graph G(n);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (money[i][j] != INF) G[i].push_back(edge{j, money[i][j]});
			}
		}

		vector<ll> d(n);
		dijkstra(s, G, d);

		cout << (d[g] == INF ? -1 : d[g]) << endl;
	}
}

Measured memory_bytes: 4160
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unordered_set<ll> uset;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=0;i<=n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#pragma gcc optimize("O3")
#pragma gcc optimize("unroll-loops")
#pragma gcc target("avx2,see4")

int main(){
	ll h,w;
	cin>>h>>w;
	if(h>w)swap(h,w);
	if(h==1)cout<<1<<endl;
	else cout<<(h*w+1)/2<<endl;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> a(4);
    for(int i=3;i>=0;i--){
        a[i]=n%10;
        n/=10;
    }
    vector<char> op(3);
    int sum=0;
    for(int bit=0;bit<(1<<3);bit++){
        sum=a[0];
        rep(i,3){
            if(bit & (1<<i)){
                op[i]='+';
                sum+=a[i+1];
            }
            else{
                op[i]='-';
                sum-=a[i+1];
            }
        }
        if(sum==7) break;
    }
    rep(i,3){
        cout<<a[i]<<op[i];
    }
    cout<<a[3]<<"=7"<<"\n";
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int X, A;
    cin >> X >> A;

    if (X < A) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }

    return 0;
}


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

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define piii    pair<int, pair<int, int>>

int main() {
        int x, a, b;
        cin >> x >> a >> b;
        cout << (abs(b - x) > abs(a - x) ? "A" : "B")  << endl;
        return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int sum = 0;
		int k = n / 4;
		for(int i = 0; i < k; ++i)
		{
			int a;
			cin >> a;
			sum += a;
		}
		cout << sum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1160
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int A, P;
	cin >> A >> P;

	cout << (A * 3 + P) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
/* *FIXME* BAD ALGORITHM */

#include <stdio.h>

int max(int a, int b)
{
    return a > b ? a : b;
}

int sum(int a, int b, int rate)
{
    return (int)(a * (100 + rate) / 100) + (int)(b * (100 + rate) / 100);
}

int main(void)
{
    int x, y, s, res, a, b;

    while(scanf("%d%d%d", &x, &y, &s), x + y + s)
    {
        res = 0;
        for(a = 1; a < s; a++)
            for(b = 1; b < s; b++)
                if(sum(a, b, x) == s)
                    res = max(res, sum(a, b, y));

        printf("%d\n", res);
    }

    return 0;
}

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

		double d1=0,d2=0,d3=0,d4=0,xy;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );

		int n = Integer.parseInt(br.readLine() );

		int[] x = new int[n];
		int[] y = new int[n];

		String[] strX = br.readLine().split(" ", n);
		String[] strY = br.readLine().split(" ", n);
		
		for(int i=0; i<n; i++)
		{
			x[i] = Integer.parseInt(strX[i]);
			y[i] = Integer.parseInt(strY[i]);
		}
		
		for(int i=0; i<n; i++)
		{
			xy = Math.abs(x[i] - y[i]);
			
			d1 = d1 + Math.pow(xy, 1);
			d2 = d2 + Math.pow(xy, 2);
			d3 = d3 + Math.pow(xy, 3);
			d4 = Math.max(xy, d4);
			
		}
		
		System.out.printf("%.5f\n",d1);
		System.out.printf("%.5f\n",Math.sqrt(d2) );
		System.out.printf("%.5f\n",Math.cbrt(d3) );
		System.out.printf("%.5f\n",d4);

	}
}

Measured memory_bytes: 24744
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)

int n,m;
char x[55][55];
bool used[55][55][2];
int main(){
    while (1) {
        scanf("%d%d",&m,&n);
        if(n == 0) return 0;
        rep(i,n) scanf("%s",&x[i]);
        rep(i,n) rep(j,m) used[i][j][0] = used[i][j][1] = 0;
        int dx[4]={0,0,1,-1};
        int dy[4]={1,-1,0,0};
        queue<pair<int,int> >que[2];
        rep(i,n) rep(j,m){
            if(x[i][j] == '.'){
                rep(k,4){
                    int nx = i+dx[k];
                    int ny = j+dy[k];
                    if(0<=nx&&nx<n&&0<=ny&&ny<m){
                        if(x[nx][ny] == 'B'){
                            que[0].push(pair<int,int>(i,j)); //break;
                        }
                        if(x[nx][ny] == 'W'){
                            que[1].push(pair<int,int>(i,j)); //break;
                        }
                    }
                }
            }
        }
        rep(q,2){
            while(!que[q].empty()){
                pair<int,int>p = que[q].front(); que[q].pop();
                if(used[p.first][p.second][q]) continue;
                used[p.first][p.second][q] = 1;
                rep(k,4){
                    int nx = p.first+dx[k];
                    int ny = p.second+dy[k];
                    if(0<=nx&&nx<n&&0<=ny&&ny<m){
                        if(x[nx][ny] == '.'){
                            que[q].push(pair<int,int>(nx,ny));
                        }
                    }
                }
            }
        }
        int ans[2]={};
        rep(i,n)rep(j,m){
            if(used[i][j][0] && !used[i][j][1]) ans[0]++;
            if(used[i][j][1] && !used[i][j][0]) ans[1]++;
        }
        cout << ans[0] << " "  << ans[1] << endl;
    }
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("input.txt", "r", stdin);
    string str;
    getline(cin, str);
    int len = str.length();
    int minimum = INT_MAX;
    int temp = 0;
    string tempStr;
    for(int i = 0; i < len; i++){
        tempStr = "";
        for(int j = i; j < i+3 && i < len-2; j++){
            tempStr += str[j];
        }
        if(tempStr.length() > 1) temp = stoi(tempStr);
        minimum = min(abs(temp-753), minimum);
    }
    cout << minimum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  while (1) {
	  if (N / 100 == N % 10 && (N / 10) % 10 == N % 10) {
		  cout << N << endl;
		  break;
		}
	  N++;
	}
  return 0;
}


Measured memory_bytes: 256
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(Q);
    vector<ll> A(N+1);
    FORI(i,1,N+1)
    {
        cin>>A[i];
    }
    ll C[N+1];
    memset(C,-1,sizeof(C));
    vector<vector<pll>> Z(N+1);
    vector<ll> ans(Q);
    ordered_set calc;
    FORI(i,0,Q)
    {
        READV(l);
        READV(r);
        Z[r].pb({l,i});
    }
    FORI(i,1,N+1)
    {
        if(C[A[i]]!=-1)
        {
            calc.erase(calc.find(C[A[i]]));
        }
        C[A[i]]=i;
        calc.insert(C[A[i]]);
        for(auto v: Z[i])
        {
            ans[v.se]=calc.order_of_key(v.fi-1);
        }
    }
    for(auto x:ans)
    {
        cout<<x<<endl;
    }

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


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ll N = 0, M;
    cin >> N >> M;
    ll ans = 0;
    vector<pair<ll, ll> > A(N);
    for(ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        A.at(i) = make_pair(a, b);
    }
    sort(A.begin(),A.end());
    for(ll i = 0; i < N; i++) {
        if(M <= A.at(i).second) {
            ans += M*A.at(i).first;
            break;
        }
        ans +=A.at(i).first*A.at(i).second;
        M -= A.at(i).second;
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 4784
#include<iostream>
using namespace std;
 
bool overlap(int a, int b, int c, int d){
  if ( d <= a ) return false;
  if ( b <= c ) return false;
  return true;
}
 
 int main(){
  int a, b, s, f, n;
  cin >> a >> b >> n;
  for ( int i = 0; i < n; i++ ){
    cin >> s >> f;
    if ( overlap(a, b, s, f) ){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>

using namespace std;

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

    string ans;
    if (r < 1200){
        ans = "ABC";
    } else if (r < 2800){
        ans = "ARC";
    } else {
        ans = "AGC";
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    char S[10];
    int i;

    cin >> S;

    if((S[0]==S[1] && S[2]==S[3] && S[0]!=S[2])||(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[1])||(S[0]==S[3]&&S[1]==S[2]&&S[0]!=S[1])){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,t,i,min=1001;
  scanf("%d%d",&n,&t);
  int a[n],b[n];
  for(i=0;i<n;i++){
    scanf("%d%d",&a[i],&b[i]);
    if(b[i]<=t&&a[i]<min){
      min=a[i];
    }
  }
  if(min==1001){
    printf("TLE");
  }else{
    printf("%d",min);
  }
  return 0;
}



Measured memory_bytes: 128