akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d;
	cin>>n>>d;
	int x[n][d];
	int count=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			cin>>x[i][j];
		}
	}
	for(int r=0;r<n-1;r++)
	{	
		for(int i=r;i<n;i++)
		{
			double sum=0;
			for(int j=0;j<d;j++)
			{
				sum+=pow(x[r][j]-x[i][j],2);
			}
			if(sqrt(sum)/int(sqrt(sum))==1)
				count++;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

const int MAX = 210000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理O(n)
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;
    }
}

// 二項係数計算O(1)
ll 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;
}

int main() {

    int n, m;
    cin >> n >> m;

    COMinit();

    cout << COM(n, 2) + COM(m, 2) << endl;

    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
    double l;
    cin >> l;
    cout << fixed << setprecision(10) << pow(l, 3) / 27 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int x,a,b;
	cin>>x>>a>>b;
	if((a-b)>=0) cout<<"delicious"<<endl;
	else if((a-b)<0&&(b-a)>x) cout<<"dangerous"<<endl;
	else cout<<"safe"<<endl;
}

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

using i64 = long long int;

i64 gcd(i64 m, i64 n) {
    return (n == 0 ? m : gcd(n, m % n));
}

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

    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 tmp;
        cin >> tmp;
        v.push_back(abs(tmp-x));
    }

    i64 ans = v[0];
    for(int i=1;i<n;++i){
        ans = gcd(ans, v[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1400
from collections import Counter
n=int(input())
a=list(map(int,input().split()))

c=Counter(a)
can_make=[i[0] for i in c.items() if i[1]>=2]
can_make_square=[i[0] for i in c.items() if i[1]>=4]
can_make+=can_make_square
can_make.sort()

if len(can_make)<2:
    print(0)
else:
    print(can_make[-1]*can_make[-2])

Measured memory_bytes: 22180
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();
        if (s == "RRR")
        {
            Console.WriteLine("3");
        }
        else if (s == "SRR" || s == "RRS")
        {
            Console.WriteLine("2");
        }
        else if (s.Contains('R'))
        {
            Console.WriteLine("1");
        }
        else
        {
            Console.WriteLine("0");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 25800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)

string maxst(string x,string y){
	if(x=="-")return y;
	if(y=="-")return x;
	if(x.size()>y.size())return x;
	if(x.size()<y.size())return y;
	if(x>=y)return x;
	if(x<y)return y;
}

int main(){
	ll N,M;
	cin >> N >> M;
	vector<ll> c={0,2,5,5,4,5,6,3,7,6},a(M);
	FOR(i,0,M)cin>>a[i];

	vector<string> dp(N+1,"-");
	dp[0] = "";
	FOR(i,0,N+1){
		if(dp[i]=="-")continue;
		for(auto x:a){
			if(i+c[x]>N)continue;
			dp[i+c[x]] = maxst(dp[i+c[x]],dp[i]+char('0'+x));
		}
	}
	cout << dp[N] << endl;
}


Measured memory_bytes: 43648
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
int a[100009],b[100009];
void era(){
  a[0]=1;
  a[1]=1;
  for(int i=2;i<100009;i++){
    if(!a[i]){
      for(int j=i+i;j<100009;j+=i)a[j]=1;
    }
  }
  r(i,100009)if(!a[i]){
    int f=0;
    if(!a[(i+1)/2])f++;
    if(f)b[i]=1;
  }
  r(i,100008)b[i+1]+=b[i];
}
main(){
  era();
  int q,s,t;
  cin>>q;
  while(q--){
    cin>>s>>t;
    cout<<b[t]-b[s-1]<<endl;
  }
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
using namespace std;

int main(){
int a,b,c,flag=0;
cin>>a>>b>>c;
for(int i=a;i<=b;i++){
    if(c%i==0)flag++;

}
cout<<flag<<endl;

}


Measured memory_bytes: 3108
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int num = n-1;
    int c[] = new int[num];
    int s[] = new int[num];
    int f[] = new int[num];
    for(int i = 0 ; i < num ; ++i){
      c[i] = sc.nextInt();
      s[i] = sc.nextInt();
      f[i] = sc.nextInt();
    }
    
    for(int i = 0 ; i < num ; ++i){
      int t = 0;
      for(int j = 0 ; j < num-i ; ++j){
        if(t<s[i+j]){
          t = s[i+j];
        }else if(t%f[i+j] != 0){
          t += f[i+j]-(t%f[i+j]);
        }
        t += c[i+j];
      }
      System.out.println(t);
    }

    System.out.println(0);
    
  }
}

Measured memory_bytes: 39304
#include <iostream>

using namespace std;

int main(){
  int sumA=0,sumB=0;
  int ans=0;
  for(int i=0;i<8;i++){
    int num;cin>>num;
    if(i<4){
      sumA += num;
    }else{
      sumB += num;
    }
  }
  if(sumA<sumB) ans=sumB;
  else ans=sumA;
  cout<<ans<<endl;
}


Measured memory_bytes: 3088
#include <stdio.h>

int main(void) {
    
    int count;
    int input;
    
    count = 0;

    scanf("%d", &input);

    while(input != 0) {
        count++;
        printf("Case %d: %d\n", count, input);
        scanf("%d", &input);
    }

    return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, P[50], Q[50];
//---------------------------------------------------------------------------------------------------
bool check(int* v) {
	rep(i, 0, N) if (v[i] != i + 1) return false;
	return true;
}
//---------------------------------------------------------------------------------------------------
#define yes "YES"
#define no "NO"
string solve() {
	if (check(P)) return yes;

	rep(i, 0, N) rep(j, i + 1, N) {
		rep(k, 0, N) Q[k] = P[k];
		swap(Q[i], Q[j]);
		if (check(Q)) return yes;
	}

	return no;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> P[i];
	cout << solve() << endl;
}







Measured memory_bytes: 256
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


ascii_lowercase = 'zabcdefghijklmnopqrstuvwxy'
import math
def main():
    n = input_int()

    kazu = len(ascii_lowercase)

    val = []
    temp = n
    while temp > kazu:
        amari = temp % kazu
        val.append(amari)
        syo = math.floor(temp / kazu)
        if amari == 0:
            temp = syo - 1
        else:
            temp = syo

    val.append(temp % kazu)

    ans = ""
    for v in val[::-1]:
        ans += ascii_lowercase[v]

    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9220
import sys

inf = 1<<60

def solve():
    N, M, r = map(int, sys.stdin.readline().split())
    edges = [None] * M

    for i in range(M):
        si, ti, di = map(int, sys.stdin.readline().split())
        edges[i] = (si, ti, di)

    ans = BellmanFord(N, M, edges, r)

    print(*ans, sep='\n')

def BellmanFord(N, M, edges, r):
    d = [inf] * N
    d[r] = 0

    for i in range(N):
        flag = False

        for (u, v, c) in edges:
            if d[u] != inf and d[u] + c < d[v]:
                d[v] = d[u] + c
                flag = True

        if flag and i == N - 1:
            return ['NEGATIVE CYCLE']

    d = [di if di < inf else 'INF' for di in d]

    return d

if __name__ == '__main__':
    solve()

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

using namespace std;

int n, k;
long long v[2001];
long long dp[2001][2001], rez;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
        dp[i][0] = v[i];
        rez += v[i];
    }
    for (int salt = 1; salt <= n; ++salt) {
        long long sum = 0;
        for (int i = 1; i <= n; ++i) {
            int pr = i - salt;
            if (pr <= 0) pr += n;
            dp[i][salt] = min(dp[i][salt - 1], v[pr]);
            sum += dp[i][salt];
        }
        rez = min(rez, sum + 1LL * salt * k);
    }
    return cout << rez, 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#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;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

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

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

  int n;
  cin >> n;
  int t, x, y;
  t = x = y = 0;
  rep(i, n) {
    int nt, nx, ny;
    cin >> nt >> nx >> ny;
    int a = (nt-t)-(abs(nx-x)+abs(ny-y));
    if(a < 0 || a%2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    vector<int> a(2);
    rep(i, 2){
        char c;
        cin >> c;
        a[i] += c - '0';
        a[i] *= 10;
        cin >> c;
        a[i] += c - '0';
    }

    if(1 <= a[0] && a[0] <= 12 && (13 <= a[1] || a[1] == 0)){
        cout << "MMYY" << endl;
        return 0;
    }
    if(1 <= a[1] && a[1] <= 12 && (13 <= a[0] || a[0] == 0)){
        cout << "YYMM" << endl;
        return 0;
    }
    if(1 <= a[0] && a[0] <= 12 && 1 <= a[1] && a[1] <= 12){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    cout << "NA" << endl;

    return 0;
}


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

int compare_ll(const void *a, const void *b){
    return *(long long*)a - *(long long*)b;
}

int main(){
	long long	n, h, a, amax=0, cnt=0, d=0;
    long long   b[100000+1]={0};

	scanf("%lld %lld", &n, &h);

	for(int i=0; i<n; i++){
		scanf("%lld %lld", &a, &b[i]);
		if( a > amax ){ amax = a; }
	}
    qsort( b, n, sizeof(long long), compare_ll );
	
    int j=n-1;
    //投げてからずっと使い続けても同じ（1度しか投げなければOK）
    while(h > 0){
    	//強い剣は先に投げる
        if( j >= 0 && b[j] >= amax ){
            h -= b[j];
            cnt++;
            j--;
    	//あとはずっとamaxを使う
        }else{
            h -= amax;
            cnt++;
        }
    }
    printf("%lld\n", cnt);
	
	return 0;
}

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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/*------------------------------↓ここからコード↓----------------------------------*/
void solve(){
    int K;
    cin >> K;
    vector<bool> found (K,false);
    int ans = 0;
    int before = 7;
    int sum = 0;
    while(1){
        sum += before;
        sum %= K;
        ans++;
        if(sum == 0){
            cout << ans << endl;
            break;
        }
        if(found[sum]){
            cout << "-1" << endl;
            break;
        }
        found[sum] = true;
        before = before*10%K;
    }
}


Measured memory_bytes: 3716
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

const int INF = 1000;

void Main() {
  int n;
  cin >> n;
  int keta = int(log10(n));
  if (keta == 0) {
    cout << n << endl;
    return;
  }
  vector<vector<vector<int>>> A(9, vector<vector<int>>(9, vector<int>()));
  rep(i, 9) A[i][i].emplace_back(1);
  rep(i, 9) rep(j, 9) {
    int x = (i + 1) * 10 + j + 1;
    int s = 1;
    while (x <= n) {
      A[i][j].emplace_back(min(s, (n - x) / 10 + 1));
      x = (x - (j + 1)) * 10 + j + 1;
      s *= 10;
    }
  }
  int ans = 0;
  rep(i, 9) rep(j, 9) {
    if (A[i][j].empty() || A[j][i].empty()) continue;
    for (int a : A[i][j])
      for (int b : A[j][i]) {
        ans += a * b;
      }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i + j) % 2 == 0) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << "\n";
        }
        cout << endl;

    }

    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  int n;cin>>n;
  set<string> S;
  string s;
  rep(i,0,n-1) {
    cin>>s;
    S.insert(s);
  }
  pr(S.size());
  return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

char s[252521];

int main(){
  scanf("%s",s);
  int n = strlen(s);
  ll ans = 0;
  int tmp = 0;
  REP(i,n){
    if(s[i]=='B')tmp++;
    else{
      ans += tmp;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
//#include<bits/stdc++.h>
#include<tuple>
#include<queue>
#include<map>
#include<algorithm>
//#include <bits/stdc++.h>


#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

bool _predicate(int a,const int& element) {
	return (element == a); // This will cause all elements to be deleted that are larger than 3
}

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	vector<int> white(0);
	vector<int> red(0);
	rep(i, n) {
		if (s[i] == 'W') {
			white.push_back(i);
		}
		if (s[n - i - 1] == 'R') {
			red.push_back(n - i - 1);
		}

	}
	int x = min(white.size(), red.size());
	ll ans = 0;
	rep(i, x) {
		if (white[i] < red[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	
}

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

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    vector<vector<int>> vv(n, vector<int>(3));

    for (int i = 0; i < n; i++)
    {
        cin >> vv[i][0] >> vv[i][1] >> vv[i][2];
    }

    int ll_x = 0, ll_y = 0;
    int ur_x = w, ur_y = h;

    for (int i = 0; i < n; i++)
    {
        if (vv[i][2] == 1)
        {
            ll_x = max(vv[i][0], ll_x);
        }
        else if (vv[i][2] == 2)
        {
            ur_x = min(vv[i][0], ur_x);
        }
        else if (vv[i][2] == 3)
        {
            ll_y = max(vv[i][1], ll_y);
        }
        else if (vv[i][2] == 4)
        {
            ur_y = min(vv[i][1], ur_y);
        }
    }
    int area = ((ur_x > ll_x) ? (ur_x - ll_x) : 0) * ((ur_y > ll_y) ? (ur_y - ll_y) : 0);
    cout << ((area > 0) ? area : 0);
}

Measured memory_bytes: 256
<?php
# 入力部
// fscanf(STDIN, "%d", $a);
// fscanf(STDIN, "%d %d %d", $n, $x, $t);
$s = fgets(STDIN);
// fscanf(STDIN, "%d", $n);

# 処理部
$arr = explode(" ", $s);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
for ($i = 0; $i < count($arr); $i++) {
  if ($i + 1 != $arr[$i]) {
    $r = $i + 1;
  }
}

# 出力部
echo $r . "\n";
// echo ($i * 1000) - $n . "\n";

Measured memory_bytes: 16240
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
#define pii pair<int,int>
#define MAXN 200009
const int INF = 1e9+7;
#define int int64_t
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << " = "; for (auto xxxx: a) cerr << xxxx << " "; cerr << endl


int32_t main(){
		
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    unordered_map<int,int> h;
    int cs = 0;
    rep(i,0,n){
    	int a;
    	cin>>a;
    	h[a]++;
    	cs+=a;
    }
    int q;
    cin>>q;
    while(q--){
    	int b,c;
    	cin>>b>>c;
    	cs-=b*h[b];
    	cs+=c*h[b];
    	h[c]+=h[b];
		h[b]=0;
		cout<<cs<<"\n";
    }

}

Measured memory_bytes: 6968
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n, m, x = map(int, readline().split())
    bookcosts = [] 
    data = [] 
    for _ in range(n):
        c, *d = map(int, readline().split())
        bookcosts.append(c)
        data.append([i for i in d])
    INF = int(1e9)
    #bit全探索
    ans = INF
    for i in range(1<<n):
        cost = 0
        score = [0 for _ in range(m)]
        for j in range(n):
            if (i>>j) & 1:
                #j番目のbookをかう
                #j番目のbookを買うとcostは増える
                cost += bookcosts[j]
                #j番目のbookを買うと理解度が上がる
                for k in range(m):
                    score[k] += data[j][k]
        #全ての理解度がx以上か判定する
        f = True
        for j in range(m):
            if score[j] >= x:
                pass
            else:
                f = False
        
        if f:
            ans = min(cost, ans)

    if ans == INF:
        print(-1)
    else:
        print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 68540
#include<stdio.h>
int b[100000];
int now=0;
bool isBlack;
int color;
int main(){
	int a;
	while(scanf("%d",&a),a){
		now=1;
		int first;
		scanf("%d",&first);
		if(first){
			isBlack=true;
			color=1;
		}else{
			isBlack=false;
			color=0;
		}
		b[0]=0;
		for(int i=1;i<a;i++){
			int val;
			scanf("%d",&val);
			if(i%2==1){
				if(isBlack&&val==0){
					now--;
					isBlack=false;
					if(now==0){
						color=0;
						now++;
					}
				}
				else if(!isBlack&&val==1){
					now--;
					isBlack=true;
					if(now==0){
						color=1;
						now++;
					}
				}
			}else{
				if(isBlack&&val==0){
					b[now++]=i;
					isBlack=false;
				}
				else if(!isBlack&&val==1){
					b[now++]=i;
					isBlack=true;
				}
			}
			//printf("%d %d\n",now,b[now-1]);
		}
		int ret=0;
		b[now++]=a;
		if(color==0){
			for(int i=1;i<now;i+=2)ret+=b[i]-b[i-1];
		}else{
			for(int i=2;i<now;i+=2)ret+=b[i]-b[i-1];
		}
		printf("%d\n",ret);
	}
}

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

void comb(vector<vector <long long int> > &v){
        for(int i = 0;i <v.size(); i++){
                v[i][0]=1;
                v[i][i]=1;
        }
        for(int k = 1;k <v.size();k++){
                for(int j = 1;j<k;j++){
                        v[k][j]=(v[k-1][j-1]+v[k-1][j]);
                }
        }
}

int main(void){
        int N, P;
        cin >> N >> P;
        int a[2] = {0,0};
        rep(i,N) {
                int A;
                cin >> A;
                a[A%2]++;
        }

        ll ans = 1;
        rep(i, a[0]) ans *= 2;
        ll tmp = 0;
        vector<vector<ll>> v(a[1]+1, vector<ll>(a[1]+1,0));
        comb(v);
        if (P == 0) {
                for (int i = 0; i <= a[1]; i+=2) tmp += v[a[1]][i];
        }
        else {
                for (int i = 1; i <= a[1]; i+=2) tmp += v[a[1]][i];
        }
        ans *= tmp;
        cout << ans << endl;
        return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    i64 H, W;
    cin >> H >> W;

    if ((H==1)||(W==1))
    {
        cout << 1 << endl;
        return 0;
    }

    i64 ans = H * W >> 1;
    if ((H & 1LL) && (W & 1LL))
        ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int n,m,_,x,y,q;
string s,sb;
bool ok;

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

  cin>>n>>m>>q; 
  rep(i,m+1){
    rep(j,n+1){
      if(i*n+m*j-2*i*j==q){cout<<"Yes"<<'\n'; return 0;}
    }
  }
  pri1("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


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

  int a;
  string s;
  cin>>a>>s;

  if(a >= 3200) cout<<s<<endl;
  else cout<<"red"<<endl;

  return 0;
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void){
	int seisu[5],tmp,i,j;
	
	scanf("%d %d %d %d %d",&seisu[0],&seisu[1],&seisu[2],&seisu[3],&seisu[4]);
	
	for(i=0;i < 4;i++){
		for(j=i+1;j < 5;j++){
			if(seisu[i] < seisu[j]){
				tmp = seisu[i];
				seisu[i] = seisu[j];
				seisu[j] = tmp;
			}
		}
	}
	
	printf("%d %d %d %d %d\n",seisu[0],seisu[1],seisu[2],seisu[3],seisu[4]);
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    ll n,d,a;
    cin>>n>>d>>a;
    vector<P> p(n);
    for(ll i=0;i<n;i++) cin>>p[i].first>>p[i].second;
    sort(p.begin(),p.end());
    vector<ll> x(n),h(n);
    for(ll i=0;i<n;i++){
        x[i]=p[i].first;
        h[i]=p[i].second;
    }
    ll ans=0;
    vector<ll> damage(n+1,0);
    for(ll i=0;i<n;i++){
        ll now=x[i];
        ll hp=h[i];
        damage[i+1]+=damage[i];
        ll num=(hp-damage[i+1]+a-1)/a;
        num=max(num,(ll)0);
        ans+=num;
        damage[i+1]+=num*a;
        ll next=upper_bound(x.begin(),x.end(),now+2*d)-x.begin();
        if(next>=n) continue;
        next++;
        damage[next]-=num*a;
    }
    cout<<ans<<endl;
}

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

int main(){
  string s, t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());reverse(t.begin(), t.end());
  
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll C[51][51];

void comb_table(){
    C[0][0] = 1;
    for(int i=1;i<51;i++){
        for(int j=0;j<=i;j++){
            C[i][j]+=C[i-1][j];
            if(j>0) C[i][j]+=C[i-1][j-1];
        }
    }
}



int main(){
    int n; cin >> n;
    int a,b; cin >> a >> b;
    vector<ll> v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    comb_table();

    double sum=0;
    rep(i,a)sum+=v[i];
    double ave = (double)(sum)/a;

    ll res = 0;
    int num=0;
    rep(i,n)if(v[a-1]==v[i])num++;

    if(v[0]!=v[a-1]){
        int k=0;
        rep(i,a)if(v[a-1]==v[i])k++;
        res = C[num][k];
    }else{
        for(int i=a;i<=b;i++){
            res+=C[num][i];
        }
    }
    
    cout << fixed << setprecision(10) << ave << endl;
    cout << res << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<char> colors (N);
  for (int i = 0; i < N; i++){
  	cin >> colors[i];
  }
  int counter = 0;
  int l = 0, r = N-1;
  while(l<r){
  	if ((colors[l] == 'W') && (colors[r] == 'R')){
  		swap(colors[l], colors[r]);
  		l++;
  		r--;
  		counter++;
  	}
  	else if ((colors[l] == 'R') && (colors[r] == 'R')){
  		while(colors[l]!='W' && l<r) l++;
  		if (l<r) {
  		  swap(colors[l], colors[r]);
  		  r--;
  		  l++;
  	   	  counter++;	
  		}
  	}
  	else if ((colors[l] == 'W') && (colors[r] == 'W')){
  		while(colors[r]!='R' && l<r) r--;
  		if (l<r) {
  		  swap(colors[l], colors[r]);
  		  r--;
  		  l++;
  	   	  counter++; 			
  		}
  	}
	else {
		r--;
		l++;
	}  	
  }
  cout << counter << endl;
  
return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<set>
#define N 300005
#define LL long long
using namespace std;
multiset<int> S;
int n,a[N];
LL f[N],g[N],ans=-(1LL<<60);
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=3*n;i++)
		scanf("%d",&a[i]);
	for(i=1;i<=3*n;i++){
		S.insert(a[i]);
		f[i]=f[i-1]+a[i];
		if(S.size()>n){
			f[i]-=(*S.begin());
			S.erase(S.begin());
		  }
	  }
	S.clear();
	for(i=3*n;i>=1;i--){
		S.insert(-a[i]);
		g[i]=g[i+1]+a[i];
		if(S.size()>n){
			g[i]+=(*S.begin());
			S.erase(S.begin());
		  }
	  }
	for(i=n;i<=2*n;i++)
		ans=max(ans,f[i]-g[i+1]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 10752
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p =sorted(p)[::-1][:x][::-1]
q =sorted(q)[::-1][:y][::-1]
r =sorted(r)[::-1][:x+y]

pp = 0
qq = 0
pf = True
qf = True
for rr in r:
    lll = False
    if pf == True and qf == True:
        if p[pp]<rr and q[qq]<rr:
            lll = True
            if p[pp]<q[qq] and pf == True:
                p[pp] = rr
                pp += 1
                if pp == x:
                    pf = False
            elif qf == True:
                q[qq] = rr
                qq +=1
                if qq == y:
                    qf = False
    if pf == True and lll == False:
        if p[pp]<rr:
            lll = True
            if pf == True:
               p[pp] = rr
               pp += 1
               if pp == x:
                  pf = False
    if qf == True and lll == False:
        if q[qq]<rr:
            lll = True
            if qf == True:
                q[qq] = rr
                qq +=1
                if qq == y:
                    qf = False

print(sum(p)+sum(q))

Measured memory_bytes: 23328
import java.util.*;
import java.util.Arrays;
import java.lang.Math; 
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long sum = 1;

        for(int i = 1 ; i <= N; i++){
            int b = 1000000007;
            sum = (sum * i) % b;
        }
        
        System.out.println(sum);
    }
}

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

int main() {
    string s;
    cin >> s;
    int cnt_s = 0;
    int del_n = 0;
    for (int i=0; i<s.size(); ++i) {
        if (cnt_s) {
            if (s[i] == 'S') cnt_s++;
            else {
                del_n += 2;
                cnt_s--;
            }
        }
        else {
            if (s[i] == 'S') cnt_s++;
        }
    }
    int ans = s.size() - del_n;
    cout << ans << endl;
}

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

int main() {
  int n,x;
  cin >> n >> x;
  vector<string> s(n);
  for(int i=0; i<n; i++) cin >> s[i];
  sort(s.begin(),s.end());
  for(int i=0; i<n; i++) {
    cout << s[i];
    if(i == n-1) cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;

void ansYes(bool flag){
    if (flag) cout << "Yes" << endl; else  cout << "No" << endl;
}

void ansYES(bool flag){
    if (flag) cout << "YES" << endl; else  cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

struct datas{
    Int max;
    Int size;
};


int main(void) {
    string s;
    cin >> s;
    int a = 0,b = 0;
    REP(3,i){
        if (s.at(i) == 'A') a++ ; else b++;
    }
    ansYes(!(a == 3 || b == 3));
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    cout << max({ a + b,a - b,a * b}) << endl;

}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    string s;
    cin>>s;
    if(s[0]==s[s.size()-1] && s.size()%2==1){cout<<"Second"<<endl;}
    else if(s[0]!=s[s.size()-1] && s.size()%2==0){cout<<"Second"<<endl;}
    else{cout<<"First"<<endl;}
    
    
    
    return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
int main()
{
		int W,H,x,y,r,a,b,c,d;
		scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
		a=x-r;
		b=x+r;
		c=y-r;
		d=y+r;
		if(a>=0 && b<=W && c>=0 && d<=H){
		printf("Yes\n");
		}
		else{
			printf("No\n");
			}
			return 0;
	}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll d,t,s;
  cin>>d>>t>>s;
  YesNo(d<=t*s);
}

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


Measured memory_bytes: 3644
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int h[3],r,n;
	int t;
	for(;;){
		rep(i,3)scanf("%d",h+i);
		sort(h,h+3);
		if(h[2]==0)break;
		t=(h[0]*h[0]+h[1]*h[1]);
		scanf("%d",&n);
		rep(i,n){
			scanf("%d",&r);
			puts(r*r*4>t?"OK":"NA");
		}
	}
	return 0;
}

Measured memory_bytes: 1180
program prob1
    implicit none
    integer :: x, y
    read(*,*) x,y

    if(x == 1 .and. y == 1) then
        write(*,*) "1000000"
    else
        write(*,*) (max(4-x, 0)+max(4-y, 0))*100000
    end if


    stop
contains
end program prob1

Measured memory_bytes: 2776
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;

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

    vector<int> node[n];
    rep(i,n){
        node[i].pb(i+1);
        node[i].pb(i+n+1);
    }
    vector<P> ans;
    int two = 20;
    set<ll> st;
    rep(i,two){
        st.insert(1 << i);
    }

    // for(auto itr = st.begin(); itr != st.end();itr++){
    //     cout << *itr << endl;
    // }
    // cout << st.insert(3).second << endl;
    if(!st.insert(n).second){
        cout << "No" << endl;
        return 0;
    }

    if(n%2){
        rep(i,n){
            if(i == 0)continue;
            if(i%2){
                ans.pb(P(node[0][0],node[i][0]));
                ans.pb(P(node[i][0],node[i+1][0]));
                ans.pb(P(node[0][0],node[i+1][1]));
                ans.pb(P(node[i+1][1],node[i][1]));
            }
        }
        ans.pb(P(node[0][1],node[2][0]));
    }
    else{
        rep(i,n-1){
            if(i == 0)continue;
            if(i%2){
                ans.pb(P(node[0][0],node[i][0]));
                ans.pb(P(node[i][0],node[i+1][0]));
                ans.pb(P(node[0][0],node[i+1][1]));
                ans.pb(P(node[i+1][1],node[i][1]));
            }
        }
        ans.pb(P(node[0][1],node[2][0]));
        // int temp = (n^3)-1;
        int temp = 0;
        int jud = 0;
        rep(j,two){
            if(n & (1 << j)){
                jud = (1 << j);
                temp = (n ^ jud);
                break;
            }
        }
        // cout << "temp" << temp << endl;
        ans.pb(P(node[temp][1],node[n-1][0]));
        ans.pb(P(node[n-1][1],node[jud-1][0]));
    }

    cout << "Yes" << endl;
    for(auto p : ans) cout << p.first  << " " << p.second << endl;
    return 0;

}

Measured memory_bytes: 9968
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	Info(int arg_count,int arg_loc){
		count = arg_count;
		loc = arg_loc;
	}
	int count,loc;
};

int main(){

	int N,next_loc;
	scanf("%d",&N);

	int* min_num = new int[N+1];
	int* map = new int[N+1];

	for(int i = 1; i <= N; i++){
		min_num[i] = BIG_NUM;
		scanf("%d",&map[i]);
	}

	min_num[1] = 0;

	queue<Info> Q;
	Q.push(Info(0,1));
	bool FLG;

	while(!Q.empty()){

		if(Q.front().loc == N){
			Q.pop();
		}else if(Q.front().count > min_num[Q.front().loc]){
			Q.pop();
		}else{

			for(int add = 1; add <= 6; add++){

				next_loc = Q.front().loc+add;
				if(next_loc > N){
					next_loc = N;
				}

				FLG = true;

				while(true){
					if(min_num[next_loc] <= Q.front().count+1){

						FLG = false;
						break;
					}else{
						min_num[next_loc] = Q.front().count+1;

						if(map[next_loc] == 0){
							break;
						}else{
							next_loc += map[next_loc];
						}
					}
				}

				if(FLG){
					Q.push(Info(Q.front().count+1,next_loc));
				}
			}
			Q.pop();
		}
	}

	printf("%d\n",min_num[N]);

	return 0;
}

Measured memory_bytes: 3580