akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N;
  cin >> N;
  for(int i=1; i<N+1; i++){
    int v = i*(i+1) / 2;
    if(v >= N){
      for(int j=1; j<i+1; j++){
        if(j != v-N) cout << j << endl;
      }
      exit(0);
    }
  }

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc103/tasks/abc103_b
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    string S, T;
    cin >> S >> T;
    size_t N = S.size();
    REP(i, N)
    {
        bool ok = true;
        REP(j, N)
        {
            size_t idx = (i + j) % N;
            if (S[idx] != T[j])
            {
                ok = false;
                break;
            }
        }
        if (ok)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int n, k;
    cin >> n >> k;

    vector<bool> v(n, false);

    for(int i = 0; i < k; i++ ){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int tmp;
            cin >> tmp;
            tmp --;
            v[tmp] = true;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(!v[i]) ans ++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

use std::cmp::min;

fn solve_(h: usize, w: usize) -> usize {
    let mut ans = std::usize::MAX;

    for i in 1..h {
        {
            let mut ss = Vec::new();
            ss.push(i * w);
            ss.push((h - i) * (w / 2));
            ss.push((h - i) * (w / 2 + if w % 2 == 0 { 0 } else { 1 }));
            ss.sort();
            let s = ss[2] - ss[0];
            if s < ans {
                ans = s;
            }
        }

        {
            if h - i < 2 {
                continue;
            }
            let mut ss = Vec::new();
            ss.push(i * w);
            ss.push((h - i) / 2 * w);
            ss.push(((h - i) / 2 + if (h - i) % 2 == 0 { 0 } else { 1 }) * w);
            ss.sort();
            let s = ss[2] - ss[0];
            if s < ans {
                ans = s;
            }
        }
    }
    ans
}

fn solve(h: usize, w: usize) -> usize {
    min(solve_(h, w), solve_(w, h))
}

fn main() {
    let (h, w) = parse_line!(usize, usize);

    println!("{}", solve(h, w));
}

#[test]
fn solve_test() {
    assert_eq!(solve(3, 5), 0);
    assert_eq!(solve(4, 5), 2);
    assert_eq!(solve(5, 5), 4);
    assert_eq!(solve(100000, 2), 1);
    assert_eq!(solve(100000, 100000), 50000);
}


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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n, x, t;
  cin >> n >> x >> t;
  cout << n / x * t + (n % x == 0 ? 0 : t) << endl;
  return 0;
}


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

int main(){
  int a,b,c;
  while(1){
    cin>>a>>b;
    if(a==0&&b==0){
      break;
    }else if(a<=b){
      cout<<a<<" "<<b<<endl;
    }else if(b<a){
      cout<<b<<" "<<a<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3060
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//グローバル変数宣言
 ll p=0,q=0,r=0;

 bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }

int main(){
   ll x;
   cin>>x;

   rep(i,2*x){
      if (is_prime(x+i)==true)
      {
         print(x+i);break;
      }
      
   }
}


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

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    double V = a * a * b;

    if(V / 2 > x) {
        cout << setprecision(9) << atan((a * b * b) / (2 * x)) * 180 / M_PI
             << endl;
    } else {
        cout << setprecision(9)
             << atan(2 * (a * a * b - x) / (a * a * a)) * 180 / M_PI << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  int X,A,B;
  cin >> X >> A >> B;

  X -= A;
  X %= B;
  
  cout << X << endl;
  
  return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

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

  ll n, m;

  cin >> n >> m;

  cout << (n - 1) * (m - 1) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
using namespace std;

const unsigned long long BASE = (unsigned long long)(1e9 + 7);
int b[50];
int a[50];

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter < vec.end(); iter++)

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    FROM_0(i, m)
    {
        cin >> b[i];
    }
    int count = 0;
    FROM_0(i, n)
    {
        int sum = c;
        FROM_0(j, m)
        {
            cin >> a[j];
            sum += a[j] * b[j];
        }
        //cout << sum << endl;
        if (sum > 0)
            count++;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    
    vector<ll> a(n);
    vector<pair<ll, int>> b(n);
    
    ll mx = 0;
    for ( ll i = 0; i < n; i++ ){
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    
    for ( ll i = 0; i < n - 1; i++ ){
        if (a[i] == mx ) continue;
        ll p = min( a[i], mx - a[i] );
        ll t = ( a[i] < mx - a[i] ) ? 0 : 1;
        b[i] = make_pair(p, t);
    }
    
    sort(b.begin(), b.end());
        
    ll b_ans;
    if ( b[n-1].second ) b_ans = mx - b[n-1].first;
    else b_ans = b[n-1].first;
    cout << mx << " " << b_ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;

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

int main() {
	int N;
	vector<vector<int> > a(3, vector<int>(3)),c(3,vector<int>(3));

	rep(i, 3) rep(j, 3) cin >> a[i][j];


	cin >> N;

	vector<int> b(N);

	rep(i, N) cin >> b[i];

	rep(i, 3) rep(j, 3) rep(m, N) if (a[i][j] == b[m]) { ++c[i][j]; }

	int k = 0;

	if (c[0][0] == 1 && c[0][1] == 1 && c[0][2] == 1) { ++k; }
	if (c[1][0] == 1 && c[1][1] == 1 && c[1][2] == 1) { ++k; }
	if (c[2][0] == 1 && c[2][1] == 1 && c[2][2] == 1) { ++k; }
	if (c[0][0] == 1 && c[1][0] == 1 && c[2][0] == 1) { ++k; }
	if (c[0][1] == 1 && c[1][1] == 1 && c[2][1] == 1) { ++k; }
	if (c[0][2] == 1 && c[1][2] == 1 && c[2][2] == 1) { ++k; }
	if (c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1) { ++k; }
	if (c[0][2] == 1 && c[1][1] == 1 && c[2][0] == 1) { ++k; }

	if (k > 0) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[200009];
ll n,t;
int main()
{
    cin>>n>>t;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    ll sum=t;
    ll e=t;
  for(int i=2;i<=n;i++)
  {
      if(a[i]>e)
      {
          sum+=t;
          e=a[i]+t;
      }
      else
      {
          sum+=(a[i]+t-e);
          e=a[i]+t;
      }
  }
  cout<<sum<<endl;
}


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

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int sum = 0;
  for(int i = 0; i < N; i++){
    int prev = (i == 0) ? 0 : A[i-1];
    int current = A[i];
    sum += abs(current - prev);
  }
  sum += abs(A[N-1]);

  for(int i = 0; i < N; i++){
    int prev = (i == 0) ? 0 : A[i-1];
    int current = A[i];
    int next = (i == N-1) ? 0 : A[i+1];
    if( (prev - current)*(next - current) > 0 ){
      cout << sum - min(abs(current - next), abs(current - prev))*2 << endl;
    }else{
      cout << sum << endl;
    }
  }
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<math.h>
int main(void){
  double x1,x2,y1,y2;
  scanf("%lf %lf",&x1,&y1);
  scanf("%lf %lf",&x2,&y2);
  printf("%f\n",sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
  return 0;
}

Measured memory_bytes: 652
import sys
input = sys.stdin.readline

MOD = 10 ** 9 + 7

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

N = int(input())
G = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

F = Factorial(N + 2, MOD)

root = 1
stack = [root]
check = [False] * (N + 1)
check[root] = True
p = [0] * (N + 1) 

DAG = []

while stack:
    now_ = stack.pop()
    DAG.append(now_)
    for next_ in G[now_]:
        if check[next_]:
            continue
        stack.append(next_)
        check[next_] = True
        p[next_] = now_

size1 = [0] * (N + 1)
dp1 = [1] * (N + 1)

for now_ in DAG[::-1]:
    size1[now_] += 1
    size1[p[now_]] += size1[now_]
    dp1[now_] *= F.factorial(size1[now_] - 1)
    dp1[now_] %= MOD
    dp1[p[now_]] *= dp1[now_] * F.ifactorial(size1[now_])
    dp1[p[now_]] %= MOD

# print (size1)
# print (dp1)

size2 = [N - size1[i] + 1 for i in range(N + 1)]
dp2 = [1] * (N + 1)

for now_ in DAG[1::]:
    parent = p[now_]
    x = dp1[parent]
    x *= F.ifactorial(size1[parent] - 1)
    x *= F.factorial(size1[now_])
    x *= pow(dp1[now_], MOD - 2, MOD)
    x *= dp2[parent]
    x *= F.ifactorial(size2[parent] - 1)
    x *= F.factorial(size2[now_] - 2)
    dp2[now_] = x % MOD
 
# print (size2)
# print (dp2)

for i in range(1, N + 1):
    ans =  dp1[i] * F.ifactorial(size1[i] - 1) * dp2[i] * F.ifactorial(size2[i] - 1) * F.factorial(N - 1)
    print (ans % MOD)


Measured memory_bytes: 84448
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
for i in range(n-k+1):
  if i==0:
    d=h[k-1]-h[0]
  else:
    a=h[i+k-1]-h[i]
    d=min(d,a)
print(d)

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

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

    int N, K; cin >> N >> K;
    string S; cin >> S;
    S[K-1] -= 'A' - 'a';
    cout << S << "\n";
}

Measured memory_bytes: 256
W, H, N = gets.split.map(&:to_i)
sx = 0
ex = W
sy = 0
ey = H
N.times do
  x, y, a = gets.split.map(&:to_i)

  case a
  when 1
    sx = [sx, x].max
  when 2
    ex = [ex, x].min
  when 3
    sy = [sy, y].max
  when 4
    ey = [ey, y].min
  end
end
dy = ey - sy
dx = ex - sx
if dy > 0 && dx > 0
  puts dy * dx
else
  puts 0
end


Measured memory_bytes: 1788
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
    print("POSSIBLE")
    exit()

max_val = max(A)
if max_val < K:
    print("IMPOSSIBLE")
    exit()

gcd_val = A[0]
for a in A[1:]:
    gcd_val = gcd(gcd_val, a)

ans = max_val
while K <= ans:
    if K == ans:
        print("POSSIBLE")
        exit()
    else:
        ans -= gcd_val
print("IMPOSSIBLE")

Measured memory_bytes: 62576
import sys
n = int(input())
T, X, Y = [], [], []

for i in range(n):
    v1, v2, v3 = map(int, input().split())
    T.append(v1)
    X.append(v2)
    Y.append(v3)

for i in range(n):
    t = T[i]
    x = X[i]
    y = Y[i]

    if x + y > t:
        print('No')
        sys.exit()
    if t % 2 != (x + y) % 2:
        print('No')
        sys.exit()

print('Yes')

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int N;
    cin>>N;
    int ans=N*N*N;
    cout<<ans;
    return 0;
}

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

using namespace std;

int main(void) {
  int N; cin >> N;
  vector<int> L;
  for (int i = 0; i < N; i++) {
    int l; cin >> l;
    L.push_back(l);
  }

  sort(L.begin(), L.end(), greater<int>());

  int ans = 0;
  for (int a = 0; a < N-2; a++) {
    for (int b = a+1; b < N-1; b++) {
      int cl, cr;
      cl = b+1;
      cr = N-1;

      if (L[a] >= L[b] + L[cl]) {
        break;
      }
      if (L[a] < L[b] + L[cr]) {
        ans += cr - b;
        continue;
      }
      while (cr-cl != 1) {
        if (L[a] < L[b] + L[(cl+cr)/2]) {
          cl = (cl+cr)/2;
        } else {
          cr = (cl+cr)/2;
        }
      }

      ans += cl - b;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[110];
int main()
{
    int n,i,j,k,s;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=0;i<n;i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        s=0;
        k=-1;
        for(i=0;i<n;i++)
        {
            if(a[i]>k)
            {
                k=a[i];
                s++;
            }
        }
        printf("%d\n",s);
    }
    return 0;
}


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

int main(){
    int m, f, r;
    cin >> m >> f >> r;
    while(m != -1 || f != -1 || r != -1){
        if(m == -1 || f == -1)cout << "F" << endl;
        else if(m + f >= 80)cout << "A" << endl;
        else if(m + f >= 65 && m + f < 80)cout << "B" << endl;
        else if(m + f >= 50 && m + f < 65)cout << "C" << endl;
        else if(m + f >= 30 && m + f < 50 && r >= 50)cout << "C" << endl;
        else if(m + f >= 30 && m + f < 50)cout << "D" << endl;
        else if(m + f < 30)cout << "F" << endl;
        cin >> m >> f >> r;
    }
    return 0;
}

Measured memory_bytes: 3084
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n, a[100005], i, j, c=0, b;
	memset(a, 0, sizeof(a));
	scanf("%d", &n);
	for(i=1;i<=n;i++)
	{
		scanf("%d", &b);
		if(b>n)
			c++;
		else
			a[b]++;
	}
	for(i=1;i<=n;i++)
		if(a[i]!=0)
		{
			if(a[i]>=i)
				c+=a[i]-i;
			else 
				c+=a[i];
		}
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int field[110][110];
int selected[110] = { 0 };
int v;

int prim()
{
	int no_edge = 0;
	int weight = 0;
	selected[0] = 1;
	int x, y;

	while (no_edge < v - 1)
	{
		int min = 0x7fffffff;
		for (int i = 0; i < v; i++)
		{
			if (selected[i])
				for (int j = 0; j < v; j++)
				{
					if (!selected[j] && field[i][j] != -1)
						if (min > field[i][j])
						{
							min = field[i][j];
							x = i;
							y = j;
						}
				}
		}
		weight += field[x][y];
		no_edge++;
		selected[y] = 1;
	}
	return weight;
}

int main()
{
	scanf("%d", &v);
	for (int i = 0; i < v; i++)
		for (int j = 0; j < v; j++)
			scanf("%d", &field[i][j]);
	printf("%d\n", prim());
}


Measured memory_bytes: 2740
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>

#define ll long long int
#define all(x) x.begin(), x.end()
#define MOD 998244353

using namespace std;


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

    if (s[1] == 'B')
    {
        cout << "ARC\n";
        return;
    }
    cout << "ABC\n";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T = 1;
    //cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(26, 0));
    rep(i, n) {
        string tmp_s;
        cin >> tmp_s;
        rep(j, tmp_s.length()) {
            ++v[i][tmp_s[j]-'a'];
        }
    }
    vector<int> ans(26, 1e8);
    for ( auto tmp_v : v ) {
        rep(i, 26) {
            ans[i] = min(ans[i], tmp_v[i]);
        }
    }
    rep(i, 26) {
        if ( ans[i] == 1e8 ) {
            continue;
        }
        rep(j, ans[i]) {
            cout << (char)(i + 'a');
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    cout << a*b << '\n';    

    return 0;
}







Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>

int main(void){
	int x,h;
	double s,t_h;
	while(0==0){
		scanf("%d",&x);
		scanf("%d",&h);
		if(x==0 && h==0)break;
		t_h=sqrt(h*h+((double)x*(double)x)/4);
		s=(double)x*(double)x+(double)x*t_h*2.0;
		printf("%f\n",s);
	}
	return 0;
}

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

const int MAXN = 11;
const int INF = 1<<28;

int N;
int ax[MAXN], ay[MAXN], bx[MAXN], by[MAXN];
int num;
int order[MAXN];

void rec(int sx, int tx, int y) {
  while(1) {
    int k = -1;
    for(int i = 0; i < N; ++i) {
      if(order[i]) continue;
      if(sx <= ax[i] && bx[i] <= tx && by[i] <= y) {
        if(k == -1 || ax[i] < ax[k] || (ax[i] == ax[k] && ay[i] < ay[k])) {
          k = i;
        }
      }
    }
    if(k == -1) return;
    order[k] = ++num;
    int left = INF;
    for(int i = 0; i < N; ++i) {
      if(bx[k] <= ax[i] && ay[i] < by[k] && by[k] < by[i]) {
        left = min(left, ax[i]);
      }
    }
    rec(ax[k], left, by[k]);
  }
}

int main() {
  bool first = true;
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) {
      cin >> ax[i] >> ay[i] >> bx[i] >> by[i];
      if(ax[i] > bx[i]) swap(ax[i], bx[i]);
      if(ay[i] > by[i]) swap(ay[i], by[i]);
    }
    num = 0;
    fill(order, order+MAXN, 0);
    rec(-INF, INF, INF);
    if(first) first = false;
    else cout << endl;
    for(int i = 0; i < N; ++i) {
      cout << order[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
h,w = map(int, input().split())

if h%3==0 or w%3==0:
    print(0)
    exit()

def getmin(h,w):
    min_w = 10**10

    if h%2==0:
        h1=h//2
        h2=h//2
    else:
        h1=h//2
        h2=h1+1

    for i in range(1,w):
        if (w-i)%2==0:
            w1=(w-i)//2
            w2=(w-i)//2
        else:
            w1=(w-i)//2
            w2=w1+1
        area1=h*i
        area2=h1*(w-i)
        area3=h2*(w-i)

        area2w=h*w1
        area3w=h*w2

        lis=[area1,area2,area3]
        lisw=[area1,area2w,area3w]
        lis.sort()
        lisw.sort()
        dif=10**9
        difw=10**9
        if lis[0] > 0:
            dif = lis[2] - lis[0]
        if lisw[0] > 0:
            difw = lisw[2] - lisw[0]

        if min_w > dif:
            min_w=dif
        if min_w > difw:
            min_w=difw

    return min_w

print(min(getmin(h,w),getmin(w,h)))        
        

Measured memory_bytes: 42732
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <utility>
#include <functional>
using namespace std;

int main() {
	string t;
	cin >> t;
	vector<bool> mark(4, false);
	for(int i = 0; i < t.size(); i ++) {
		if(t[i] == 'N')
			mark[0] = true;
		if(t[i] == 'W')
			mark[1] = true;
		if(t[i] == 'S')
			mark[2] = true;
		if(t[i] == 'E')
			mark[3] = true;
	}
	if(mark[0] == mark[2] && mark[1] == mark[3])
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a == b) {
       cout << "a == b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a < b" << endl;
    }
}



Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define REP(i,a,b) for(int i = a; i < b; i++)
#define FOR(i,n) REP(i,0,n)

string string_add(string a, string b) {
	string new_str = "";
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());

	string long_s;
	string short_s;
	if (a.size() >= b.size()) {
		long_s = a;
		short_s = b;
	}
	else {
		long_s = b;
		short_s = a;
	}
	int carry = 0;
	int dif = long_s.size() - short_s.size();
	FOR(i, dif)
		short_s += "0";
	FOR(i, long_s.size()) {
		int hab = stoi(long_s.substr(i, 1)) + stoi(short_s.substr(i, 1)) + carry;
		if (hab > 9) {
			carry = 1;
			hab -= 10;
		}
		else carry = 0;

		new_str += to_string(hab);
	}
	if (carry != 0) new_str += to_string(carry);
	reverse(new_str.begin(), new_str.end());
	return new_str;
}


string string_multi(string a, string b) {
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());

	string acc = "0";
	FOR(i, a.size()) {
		int carry = 0;
		string gob = "";
		FOR(j, b.size()) {
			int gob_1 = stoi(a.substr(i, 1)) * stoi(b.substr(j, 1)) + carry;
			gob += to_string(gob_1 % 10);
			carry = gob_1 / 10;
		}
		if (carry != 0) gob += to_string(carry);
		FOR(j, i)
			gob = "0" + gob;
		reverse(gob.begin(), gob.end());
		acc = string_add(acc, gob);
	}
	return acc;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N;
	string now = "1" , maxN = "1";
	for (int i = 0; i < 18; i++)maxN += "0";
	cin >> N;
	vector<string>v(N);
	for (auto &i : v)
	{
		cin >> i;
		if (i == "0")
		{
			cout << 0;
			return 0;
		}
	}

	for(auto tmp:v)
	{
		if (tmp == "0")
		{
			cout << 0;
			return 0;
		}
		now = string_multi(now, tmp);
		if (now.size() >= 19 && now != maxN)
		{
			cout << -1;
			return 0;
		}
	}

	cout << now;

}

Measured memory_bytes: 11128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;

int main() {
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A), q(B), r(C);
  for (int i=0; i<A; i++) cin >> p[i];
  for (int i=0; i<B; i++) cin >> q[i];
  for (int i=0; i<C; i++) cin >> r[i];
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  p.erase(p.begin(), p.begin()+A-X);
  q.erase(q.begin(), q.begin()+B-Y);
  vector<ll> eat = p;
  eat.insert(eat.end(), q.begin(), q.end());
  eat.insert(eat.end(), r.begin(), r.end());
  sort(eat.begin(), eat.end());
  reverse(eat.begin(), eat.end());
  ll ans = accumulate(eat.begin(), eat.begin()+X+Y, 0LL);
  cout << ans << endl;
}

Measured memory_bytes: 6592
S=input()
a=int(S[:2])
b=int(S[2:])
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 333;
const int K = 19;
const int mod = 1e9 + 7;
int um[N][N][N], bm[N][N][N], dp[N][N][N], h[N], rev[N];
map < int, int > mp;
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    set < int > s;
    for (int i = 1; i <= n; i++){
        cin >> h[i];
        s.insert(h[i]);
    }
    s.insert(0);
    int cnt = 0;
    for (auto i: s){
        mp[i] = cnt;
        rev[cnt] = i;
        cnt++;
    }
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= cnt; j++){
            for (int l = 0; l <= k; l++){
                dp[i][j][l] = 1e18;
                um[i][j][l] = 1e18;
                bm[i][j][l] = 1e18;
            }
        }
    }
    dp[0][0][0] = 0;
    um[0][0][0] = 0;
    for (int j = 0; j < cnt; j++){
        bm[0][j][0] = 0;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 0; j < cnt; j++){
            for (int l = 0; l <= k; l++){
                dp[i][j][l] = 1e18;
                int nl;
                if (rev[j] != h[i]) nl = l - 1; else nl = l;
                if (nl >= 0) dp[i][j][l] = min(rev[j] + bm[i - 1][j][nl], um[i - 1][j][nl]);
                if (j != 0)
                bm[i][j][l] = min(bm[i][j - 1][l], dp[i][j][l] - rev[j]); else
                bm[i][j][l] = dp[i][j][l] - rev[j];
             //   cout << i << " " << j << " " << l << " " << dp[i][j][l] << " " << rev[j] << " " << nl << " " << bm[i - 1][j][nl] << endl;
            }
        }
        for (int j = cnt - 1; j >= 0; j--){
            for (int l = 0; l <= k; l++){
                um[i][j][l] = min(um[i][j + 1][l], dp[i][j][l]);
            }
        }
    }
    int ans = 1e18;
    for (int i = 0; i < cnt; i++){
        for (int l = 0; l <= k; l++){
            ans = min(ans, dp[n][i][l]);
        }
    }
    cout << ans;
}


Measured memory_bytes: 790784
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int N,P;
    string S;
    vector<pair<string, pair<int, int> > > v;
    cin>>N;
    rep(i,N){
        cin>>S >> P;
        v.push_back(make_pair(S,make_pair(P*-1, i)));
    }
    sort(v.begin(), v.end());
    rep(i,N){
        cout << v[i].second.second + 1 << endl;
    }
}

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

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool same(int x, int y) { return root(x) == root(y); }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

    int size(int x) { return -par[root(x)]; }
};

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

    UnionFind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.merge(a, b);
    }

    set<int> s;
    rep(i, n) s.insert(uf.root(i));

    cout << s.size() - 1 << endl;
    return 0;
}


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

using namespace std;

int main() {
  int n;
  string s("");
  cin >> s;

  n=0;

  for (int i; i < 6; i++) {
    if (s[i] == '1') {
      n = n + 1;
    };
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)

if n % 2 == 1:
    print('No')
else:
    if n == 2:
        if s == 'hi':
            print('Yes')
        else:
            print('No')
    elif n == 4:
        if s == 'hihi':
            print('Yes')
        else:
            print('No')
    elif n == 6:
        if s == 'hihihi':
            print('Yes')
        else:
            print('No')
    elif n == 8:
        if s == 'hihihihi':
            print('Yes')
        else:
            print('No')
    elif n == 10:
        if s == 'hihihihihi':
            print('Yes')
        else:
            print('No')

Measured memory_bytes: 3064
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int k, a, b;
    cin >> k >> a >> b;
    FOR(i,a,b)
        if (i % k == 0) {
            cout << "OK";
            return 0;
        }
    cout << "NG";
    return 0;
}


Measured memory_bytes: 3648
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String lns[] = br.readLine().split(" ");
			int ln[] = parseInts(lns);
			if(ln[0]==0 && ln[1]==0) break;
			for(int x=0; x<ln[0] ;x++){
				for(int y=0; y<ln[1]; y++){
					if(y==ln[1]-1){
						System.out.println("#");
					}else if(y==0 || x==0 || x==ln[0]-1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
			}
			System.out.println();
		}
	}
	static int[] parseInts(String[] s){
		int[] x = new int[s.length];
		for(int i=0;i<s.length;i++){
			x[i] = Integer.parseInt(s[i]);
		}
		return x;
	}
}

Measured memory_bytes: 22852
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
int n,a,b,cou,ans;
int main()
{
	cin>>n>>a>>b;
	cou=a*n;
	if(cou<=b) ans=cou;
	else ans=b;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se  second
int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<3;++j)
        {
            cin>>a[i][j];
        }
    }
    ///ll ans1=0,ans2=0,ans3=0;
    for(int i=n-2;i>=0;--i)
    {
        a[i][0]+=max(a[i+1][1],a[i+1][2]);
        a[i][1]+=max(a[i+1][0],a[i+1][2]);
        a[i][2]+=max(a[i+1][0],a[i+1][1]);
    }
    cout<<max({a[0][0],a[0][1],a[0][2]})<<endl;
    return 0;
}


Measured memory_bytes: 1408
N = int(input())
A = list(map(int, input().split()))
 
cnt1 = 0
for i in range(8):
  v1 = i * 400
  v2 = (i + 1) * 400 - 1
  for j in range(N):
    if v1 <= A[j] and A[j] <= v2:
      cnt1 += 1
      break
 
cnt2 = 0
for i in range(N):
  if A[i] >= 3200:
    cnt2 += 1
 
if cnt1 == 0:
  print(1, cnt2)
else:
  print(cnt1, cnt1 + cnt2)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 1) {
            System.out.println("Hello World");
        } else {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a + b);
        }

    }

}


Measured memory_bytes: 21460
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n;
  int a[105];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a+n);
  int x = a[0];
  int y = a[n-1];
  cout << y - x << endl;
  return 0;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}

ModInt func[200000];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
ModInt comb(ModInt n, ModInt r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}

lint S[2000], T[2000], N, M;
ModInt dp0[2005][2005];
ModInt dp1[2005][2005];
int main() {
	cin >> N >> M;
	REP(i, N) {
		cin >> S[i];
	}
	REP(i, M) {
		cin >> T[i];
	}
	dp0[0][0] = 1;
	REP(i, N + 1) {
		REP(j, M + 1) {
			dp0[i + 1][j] += dp0[i][j];
			dp1[i][j] += dp0[i][j];
			dp1[i][j + 1] += dp1[i][j];
			if (S[i] == T[j]) {
				dp0[i + 1][j + 1] += dp1[i][j];
			}
		}
	}
	cout << dp1[N][M].a << endl;
}


Measured memory_bytes: 66196
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll k;cin>>k;
    if(k>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3632
/*
Link: 
*/

#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

void Res(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    while(n){
        n/=k;
        ans++;
    }
    cout<<ans;

}
int main(){
    IOS;
    Res();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int l[110];

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

    int n;
    cin >> n;

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

    sort(l, l + 2 * n);

    int ans = 0;
    for(int i = 0; i < n; ++i){
        ans += l[2 * i];    
    }    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n,k; cin >> n >> k;
	if (((n+1)  / 2) < k){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}
	// cout << (n+1)  / 2  << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
  struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
  int main(){
      lint N;
      cin >>N; lint A[N];
      rep(i,N)cin >> A[i];
      lint ans=0;
      lint sum=A[0];
      if(sum<=0){
          ans+=abs(sum)+1;
        sum=1;
      }
      rep(i,N-1){
        sum+=A[i+1];
        if(sum<=0&&sum-A[i+1]<=0){
            ans+=abs(sum)+1;
            sum+=abs(sum)+1;
        }else if(sum>=0&&sum-A[i+1]>=0){
              ans+=abs(sum)+1;
             sum-=(abs(sum)+1);
        }
      }
      
       lint ans2=0;
      lint sum2=A[0];
      if(sum2>=0){
          ans2+=abs(sum2)+1;
        sum2=-1;
      }
      rep(i,N-1){
        sum2+=A[i+1];
        if(sum2<=0&&sum2-A[i+1]<=0){
            ans2+=abs(sum2)+1;
            sum2+=abs(sum2)+1;
        }else if(sum2>=0&&sum2-A[i+1]>=0){
              ans2+=abs(sum2)+1;
             sum2-=(abs(sum2)+1);
        }
      }
      cout<<min(ans,ans2);
  }
  
  
     
  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  string s,t;
  cin >> n >> s >> t;
  ll ans=2*n;
  ll k=0;
  FOR(i,1,n+1){
    bool a=true;
    FOR(j,0,i){
      if(t[j]!=s[j+n-i]){
        a=false;
      }
    }
    if(a){
      k=i;
    }
  }
  cout << ans -k << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX ((int)(1e9)+2)
using namespace std;

int dp[102][(int)(1e5)+2], c[105], v[105];

int call(int n, int rem)
{
    if(rem<=0) return 0;
    if(n==0){
        return MAX;
    }
    if(dp[n][rem]!=-1) return dp[n][rem];
    dp[n][rem] = MAX;
    dp[n][rem] = min(dp[n][rem],call(n-1,rem));
    dp[n][rem] = min(dp[n][rem],call(n-1,rem-v[n])+c[n]);
    return dp[n][rem];
}

int main()
{
    int n, w;
    scanf("%d %d",&n,&w);
    for(int i = 1; i<=n; i++) scanf("%d %d",&c[i],&v[i]);
    memset(dp,-1,sizeof dp);
    for(int i = ((int)(1e5)+2); i>=0; i--){
        if(call(n,i)<=w){
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 40064
# ABC161 B

def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))

    sortedA = sorted(A)[::-1]

    if sortedA[m-1] >= sum(A) / (4*m):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060