akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(void){
  int a,b,c,d;
  cin >> a >> b>> c >> d;
  if(a+b > c+d){
    cout << "Left";
  }else if(a+b < c+d){
    cout << "Right";
  }else{
    cout << "Balanced";
  }
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//define
#define INF 100000000
#define NUM 1000000007
int main() {
	string s1, s2;
	cin >> s1 >> s2;
	bool flag = false;
	sort(s1.begin(), s1.end());
	sort(s2.begin(), s2.end());
	reverse(s2.begin(), s2.end());
	if (s1 < s2) {
		flag = true;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
	
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = [int(x) for x in input().split()]
ans = 0
for i in range(N):
    A = [int(y) for y in input().split()]
    S = 0
    for j in range(M):
        S += A[j] * B[j]
    if S + C > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 2000;
ll mod = INF;

ll fac[maxn+1];
ll rfac[maxn+1];
ll s;
ll ans=0;

ll pow(ll x,ll y){
    if(y==0){
        return 1;
    }else if(y==1){
        return x;
    }else if(y%2==0){
        ll a=pow(x,y/2);
        return (a*a)%mod;
    }else{
        ll a=pow(x,(y-1)/2);
        return a*a%mod*x%mod;
    }
}

int main(){

    cin >> s;


    fac[0]=fac[1]=rfac[0]=rfac[1]=1;

    for(ll i=1;i<=maxn;i++){
            fac[i]=fac[i-1]*i%mod;
    }

    rfac[maxn]=pow(fac[maxn],mod-2);
    
    for(ll i=maxn;i>=1;i--){
        rfac[i-1]=rfac[i]*i%mod;
    }

    // for(int i=2;i<=4;i++){
    //     cout << fac[i]*rfac[i]%mod<<endl;
    // }

    ll i=1;
    while(s-3*i>=0){
        ll add=fac[s-2*i-1]*rfac[i-1]%mod*rfac[s-3*i]%mod;
        ans=(ans+add)%mod;
        i++;
    }

    cout << ans<<endl;

    return 0;
}

Measured memory_bytes: 3656
N,Q = map(int,input().split())
S = input()
L = [list(map(int,input().split())) for i in range(Q)]

loc = [0 for i in range(N+1)]
for i in range(N) :
    if S[i:i+2] == "AC" :
        loc[i+1] = loc[i]+1
    else :
        loc[i+1] = loc[i]
for l,r in L :
    l -= 1
    r -= 1
    ans = loc[r] - loc[l]
    print(ans)


Measured memory_bytes: 30808
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

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

	vector <int> a(N), b(N);

	vector <pair <int, int> > c(N);

	for (int i=0;i<N;++i)
	{
		cin >> a[i] >> b[i];
		c[i] = make_pair(b[i], a[i]); // 締め切り時刻, かかる時間
	}

	sort(c.begin(), c.end());

	ll t = 0;
	for (const auto& x : c)
	{
		if (t > x.first - x.second)
		{
			cout << "No" << endl;
			return 0;
		}

		t += x.second;
	}

	cout << "Yes" << endl;

	return 0;
}


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

#define fl(n)             for(long long int i=0;i<n;i++)
#define sz(a)             int((a).size())
#define tr(c,i)           for(auto i = (c).begin(); i != (c).end(); i++)
#define trr(c,i)          for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define present(c,x)      ((c).find(x) != (c).end())
#define cpresent(c,x)     (find(all(c),x) != (c).end())
#define vi                vector <int>
#define vvi               vector < vi >
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define M                 1000000007LL


int solve()
{
  int n;
  cin>>n;
  ll ans=0;
  for(int i=1;i<=n-1;i++)
  {
    ans+=(n-1)/i;
  }
  cout<<ans<<endl;
  


  return 0;
}


int main() {
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);       

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




Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << endl
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, K;
  cin >> N >> K;
  vll A(N), F(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> F[i];

  SORT(A);
  REVERSE(A);
  SORT(F);
  ll l = -1;
  ll r = 0;
  rep(i, N) {
    r = max(r, A[i] * F[i]);
  }

  while (r - l > 1) {
    ll c = (l + r) / 2;
    // debug(c);
    ll count = 0;
    rep(i, N) {
      ll temp = 0;
      ll sa = A[i] * F[i] - c;
      if (sa < 0) continue;
      temp += sa / F[i];
      if (sa % F[i] != 0) temp++;
      count += min(temp, A[i]);
      if (c == 12) {
        // debug(A[i]);
        // debug(F[i]);
        // debug(count);
        // ENDL;
      }
    }
    // debug(count);

    if (count <= K) {
      r = c;
    } else {
      l = c;
    }
    // debug(l);
    // debug(r);
    // ENDL;
  }
  COUT(r);

  return 0;
}

Measured memory_bytes: 6348
#include<stdio.h>

int main(void){
    int kuku[] = {1,2,3,4,5,6,7,8,9,10,12,14,16,18,15,21,24,27,20,28,32,36,25,30,35,40,45,36,42,48,54,49,56,63,64,72,81};
    int n;
    int *iter,*end;
    int kukuSize = sizeof(kuku)/sizeof(kuku[0]);
    end = &kuku[kukuSize];
    scanf("%d",&n);
    for(iter = kuku; iter != end;iter++){
        if(n == *iter){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
def solve(N, As):
    bools = [a % 3 == 0 or a % 5 == 0 for a in As if a % 2 == 0]
    if len(bools) == 0:
        return "APPROVED"
    else:
        if all(bools):
            return "APPROVED"
        else:
            return "DENIED"


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Measured memory_bytes: 2940
s = input()
x, y = map(int, input().split())

fs = s.split('T')
f_num = [len(f) for f in fs]
dir_lst = [[], []]
for i in range(len(f_num)):
    dir_lst[i % 2].append(f_num[i])
x_lst = dir_lst[0]
x -= x_lst[0]
x_lst = x_lst[1:]
y_lst = dir_lst[1]

can_x = False
can_y = False

s = set([0])
for x_ in x_lst:
    s_ = set()
    for e in s:
        s_.add(e+x_)
        s_.add(e-x_)
    s = s_
if x in s:
    can_x = True

s = set([0])
for y_ in y_lst:
    s_ = set()
    for e in s:
        s_.add(e+y_)
        s_.add(e-y_)
    s = s_
if y in s:
    can_y = True

if can_x and can_y:
    print('Yes')
else:
    print('No')


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

using Int = __int128_t;
Int abs128(Int val){return val<0?-val:val;}

ostream &operator<<(ostream &os,Int val){
  if(ostream::sentry(os)){
    __uint128_t tmp=abs128(val);
    char buf[64];
    char *d=end(buf);
    do{
      --d;
      *d=char(tmp%10+'0');
      tmp/=10;
    }while(tmp);
    if(val<0) *--d='-';
    Int len=end(buf)-d;
    if(os.rdbuf()->sputn(d,len)!=len){
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}

istream &operator>>(istream &is,Int &val){
  string s;
  is>>s;
  val=0;
  for(Int i=0;i<(Int)s.size();i++)
    if(isdigit(s[i])) val=val*10+s[i]-'0';
  if(s[0]=='-') val*=-1;
  return is;
}


//INSERT ABOVE HERE
signed main(){
  Int x;
  cin>>x;
  string b="FESTIVAL";
  using P = pair<Int, Int>;
  const Int E=1<<9;
  vector<P> v(E,P(0,1));
  for(Int k=1;k<7;k++){
    Int tmp=0;
    for(Int i=0;i<(Int)v.size();i++){
      if(v[i].first==k-1){
	tmp+=v[i].second;
	if(__builtin_popcountll(tmp)!=1) continue;
	v.emplace(v.begin()+i+1,P(k,tmp));
	if(tmp==1) v.emplace(v.begin()+i+1,P(k,tmp));
      }
    }
    //cout<<tmp<<endl;
    for(Int i=2;i<E;i++) v.push_back(P(k,tmp));
  }
  Int tmp=0;
  for(Int i=0;i<(Int)v.size();i++){
    if(v[i].first==6){
      tmp+=v[i].second;
      if(__builtin_popcountll(tmp)!=1) continue;
      //cout<<i<<" "<<tmp<<endl;
      if(x&tmp){
	v.emplace(v.begin()+i+1,P(7,tmp));
	x^=tmp;
      }
    }
  }
  //cout<<x<<endl;
  string s;
  for(Int i=0;i<(Int)v.size();i++)
    s.push_back(b[v[i].first]);
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    static private Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();
        
        displayChars(sx, tx, 'R');
        displayChars(sy, ty, 'U');
        displayChars(tx, tx + 1, 'R');
        displayChars(ty, sy - 1, 'D');
        displayChars(tx + 1, sx, 'L');
        displayChars(sy - 1, ty, 'U');
        displayChars(sx, tx, 'R');
        displayChars(ty, ty + 1, 'U');
        displayChars(tx, sx - 1, 'L');
        displayChars(ty + 1, sy, 'D');
        displayChars(sx - 1, sx, 'R');
    }
    
    static void displayChars(int a, int b, char c) {
        if(a > b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        
        for(int i = a; i < b; ++i) {
            System.out.print(c);
        }
    }
}


Measured memory_bytes: 27012
import math
def bittoarr(x):
  i = 1
  ret = []
  while i <= x:
    if i & x:
      ret.append(int(math.log2(i)))
    i <<= 1
  return ret
h, w, k = map(int, input().split())
c = []
result = 0
for i in range(h):
  c.append(input())
hh = 2 ** h
ww = 2 ** w
for i in range(hh):
  row = []
  #print(bittoarr(i))
  for tmp in bittoarr(i):
    row.append(c[tmp])
  #print(row)
  for j in range(ww):
    sm = 0
    for r in row:
      for cl in bittoarr(j):
        if r[cl] == "#":
          sm += 1
    if sm == k:
      result += 1
print(result)
        
    

Measured memory_bytes: 9224
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))

r = [0]*3
for i in p:
    if i <= a:
        r[0] += 1
    elif i <= b:
        r[1] += 1
    else:
        r[2] += 1
print(min(r))    

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


void solve(long long N){
  long long acc = 0;
  for(long long i = N-1; i >= 0; i--){
    acc += i;
  }

  cout << acc << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}

func readLines() -> [String] {
    return readLine()!.map { String($0) }
}

///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}
// https://algo-logic.info/divisor/
/// 約数の配列を返す
func divisor(_ n:Int) -> [Int] {
    var ret = [Int]()
    var i = 1
    while i * i <= n {
        if n % i == 0 {
            ret.append(i)
            if i * i != n {
                ret.append(n / i)
            }
        }
        i += 1
    }
    return ret.sorted()
}

func main() {
    let input = readInts()
    let (N, M) = (input[0], input[1])
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var ans = (N - M) * 100 + M * 1900
    let e = Int(pow(2.0, Double(M)))
    ans *= e
    print(ans)
}
main()


Measured memory_bytes: 13656
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  REP(i,a+2) {
    if(i == 0 || i == a+1) {
      REP(j,b+2) cout << "#";
      cout << endl;
    }
    else {
      string s;
      cin >> s;
      cout << "#" << s << "#" << endl;
    }
  }
  return 0;
}
//templete by private_yusuke

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

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 100005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[104][li],PS[li];
int cev;
string s;
vector<int> v;

inline int add(int x,int y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

main(void){
	scanf("%lld %lld",&n,&k);
	FOR{
		scanf("%lld",&a[i]);
	}
	PS[0]=1;
	dp[1][0]=1;
	for(int i=1;i<=a[1];i++){dp[1][i]=1;PS[i]=add(PS[i-1],1);}
	for(int i=a[1]+1;i<=k;i++)PS[i]=PS[i-1];
	for(int i=2;i<=n;i++){
		dp[i][0]=1;
		for(int j=1;j<=k;j++){
			if(j<=a[i])dp[i][j]=PS[j];
			else dp[i][j]=max(add(PS[j],mod-PS[j-a[i]-1]),0ll);
		}
		for(int j=1;j<=k;j++)PS[j]=add(PS[j-1],dp[i][j]);
		//~ cout<<"**"<<PS[4]<<" : : "<<dp[2][1]<<"**"<<endl;
	}
	printf("%lld\n",dp[n][k]);
	return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

ll mod = 998244353;
const ld error = 1e-5;
const ld PI = acosl(-1); //const ld PI = acosl(-1)

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define eq(x, y) (fabs((x)-(y))<error)
#define bt(i) (1LL<<(i))

#define debug(x) cerr<<#x<<" = "<<(x)<<"\n"
#define hoise cerr<<"hoise - "<<__LINE__<<"\n"
#define tham getchar()
mt19937 rng((unsigned)chrono::system_clock::now().time_since_epoch().count()); //mt199937_64 for ll

inline ll MOD(ll x, ll m = mod)
{
    ll y = x % m;
    return (y >= 0) ? y: y+m;
}

const int inf = 1e9;
const ll infl = 1e18+1;
const int nmax = 50+10;
///===========================================  template  =======================================================



int main(){

    int a, b, c;
    cin>>a>>b>>c;
    cout<<((a+b+c >= 22)? "bust" : "win");
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,ans=0,m=0;
	cin>>n;
	for(int p=0;p<n;p++){
		cin>>k;
		if(k==1){
			m++;
		}else{
			m=0;
		}
		ans=max(m,ans);
	}
	cout<<ans+1<<endl;
}


Measured memory_bytes: 3096
#C
N=int(input())
A = list(map(int, input().split()))
ans=0
a=A[0]
for i in range(1,len(A)):
    if A[i]-A[i-1]<0:
        ans+=A[i-1]-A[i]
        A[i]=A[i-1]
print(ans)

Measured memory_bytes: 32248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200025,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,Q,cnt,need,fa[N],siz[N],h[N];
ll m;
vector< pair<int,int> > a;
int find(int x){return (x==fa[x]) ? x : fa[x]=find(fa[x]);}
void merge(int x,int y){
	x=find(x);y=find(y);
	if (x==y) return;
	if (siz[x]<siz[y]) swap(x,y);
	fa[y]=x;siz[x]+=siz[y];
}
int main(){
//	freopen("balance.in","r",stdin);
//	freopen("balance.out","w",stdout);
	scanf("%d %lld %d",&n,&m,&Q);
	for (int i=1;i<=n;i++) fa[i]=i,siz[i]=1;
	while (Q--){
		int u=read()+1,v=read()+1,typ=read();
		if (typ) a.push_back(make_pair(u,v));
		else merge(u,v);
	}
	for (int i=1;i<=n;i++) if (fa[i]==i) {cnt++;m-=siz[i]-1;}
	if (m<0) {puts("No");return 0;}
	for (auto t : a){
		int u=t.first,v=t.second;
		if (find(u)==find(v)) {puts("No");return 0;}
		else{
			if (!h[find(u)]) need++;
			if (!h[find(v)]) need++;
			h[find(u)]=h[find(v)]=1;
		}
	}
	if (need&&(need<3)) need=3;
	if (need>cnt) {puts("No");return 0;}
	if (m<need) {puts("No");return 0;}
	if (m>(ll)cnt*(cnt-1)/2) {puts("No");return 0;}
	puts("Yes");
	return 0;
}

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m;
  map<int,int> ma;
  lol o=m;/*
  while(o%2==0){
    ma[2]++;
    o/=2;
    }*/
  for(lol i=2;i*i<=m;i++){
    while(o%i==0){
      o/=i;
      ma[i]++;
    }
  }
  lol ans=1;
  for(auto l=ma.begin();l!=ma.end();l++){
    if(n<=l->se){
      ans*=pow(l->fi,(l->se/n));
    }
  }
  if(n==1) cout <<m<<'\n';
  else cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = new int[num][];
        for (var i = 0; i < num; i++)
            ar[i] =Array.ConvertAll(ReadLine().Split(' '),int.Parse);
        var dif = 0L;
        for (var i = num - 1; i >= 0; i--)
        {
            dif += (ar[i][0]+dif)%ar[i][1]!=0?ar[i][1] - (ar[i][0]+dif) % ar[i][1]:0;
        }
        WriteLine(dif);
    }
}


Measured memory_bytes: 23868
import itertools as ite
import math
d,g=list(map(int,input().split()))
question=[]
for i in range(d):
    question.append(list(map(int,input().split())))

ans=1000
for pattarn in ite.product([0,1],repeat=d):
    score=0
    max_notsolve=-1
    solvednum=0
    for i in range(d):
        if pattarn[i]==1:
            score += question[i][0]*(i+1)*100+question[i][1]
            solvednum+=question[i][0]
        else:
            max_notsolve=max(max_notsolve,i)
    if score >= g:
        ans=min(ans,solvednum)
    else:
        if max_notsolve==-1:
            continue
        elif g-score > question[max_notsolve][0]*(max_notsolve+1)*100:
            continue
        else:
            solvednum+=math.ceil((g-score)/((max_notsolve+1)*100))
    ans=min(ans,solvednum)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
vector<int>v[100002];
priority_queue<pair<int,int>>q;
int c[100002];
int n,m;

int main() {
scanf("%d",&n);
for(int a,b, i=0;i<n-1;i++){
	scanf("%d%d",&a,&b);
	v[a].push_back(b);
	v[b].push_back(a);
}
scanf("%d",&m);
for(int i=1;i<=n;i++){
	c[i]=-1e7;
}
for(int a,b, i=0;i<m;i++){
	scanf("%d%d",&a,&b);
	c[a]=b;
		q.push({c[a],a});
}
while(q.size()){
	pair<int,int> x=q.top();
	q.pop();
	for(int i=0;i<v[x.second].size();i++){
		int y=v[x.second][i];
		if(c[y]!=-1e7 && abs(c[y]-x.first)!=1){
			cout<<"No";
			return 0;
		}
		if(c[y]==-1e7)
		c[y]=x.first-1,q.push({c[y],y});
	}
}
puts("Yes");
for(int i=1;i<=n;i++)cout<<c[i]<<endl;


	return 0;
}

Measured memory_bytes: 8448
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll h,w,n,v;
  cin >> h >> w >> n;
  v = 0;
  for(int i=1;;i++){
    v += max(h,w);
    if(v>=n){
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
n=int(input())
d={}

for i in range(2, int(n**0.5)+1):
    while n % i == 0:
        if n<2:
            break
        d[i] = d.get(i, 0)+1
        n //=i
    if n<2:
        break
if n>1:
    d[n] = 1
def get(n):
    cur, total = 0, 0
    while cur+total<n:
        cur +=1
        total +=cur
    return cur
ans = 0
for v in d.values():
    ans += get(v)
print(ans)

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


int main(){
    int n; cin >> n;
  
  n %= 10;
  if(n==3)cout << "bon" << endl;
  else if(n==0 ||n==1 ||n==6 ||n==8)cout << "pon" << endl;
  else cout << "hon" << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;

using ll = long long;
using namespace std;

int main(){
    int n, k, a[50];
    cin >> n >> k;

    rep(i, n) cin >> a[i];
    sort(a, a+n, greater<int>());

    int sneak_length=0;
    rep(i, k) sneak_length += a[i];

    cout << sneak_length << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
x = 0
c_lst = []

s = 0
for i in a:
    s += abs(i-x)
    x = i
s += abs(0-x)

b, f = 0, 0

for i in range(len(a)):
    if i == 0:
        f, b = 0, a[i+1]
    elif i == len(a)-1:
        f, b = a[i-1], 0
    else:
        f, b = a[i-1], a[i+1]

    c = s + abs(b-f) - (abs(a[i]-f)+abs(b-a[i]))
    c_lst.append(c)

for i in c_lst:
    print(i)


Measured memory_bytes: 14172
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

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

const int MAXN = 2e5 + 5;
const int MOD = 1000000007;

vi adj[MAXN];
int n, fac[MAXN], sz[MAXN], f[MAXN], ans[MAXN];

int mod_pow(int a, int b) {
  int res = 1;
  for (; b; b >>= 1, a = 1LL * a * a % MOD)
    if (b & 1) res = 1LL * res * a % MOD;
  return res;
}

void dfs1(int u, int from) {
  f[u] = 1;
  sz[u] = 0;
  for (int v : adj[u]) {
    if (v == from) continue;
    dfs1(v, u);
    f[u] = 1LL * f[u] * f[v] % MOD * mod_pow(fac[sz[v]], MOD - 2) % MOD;
    sz[u] += sz[v];
  }
  f[u] = 1LL * f[u] * fac[sz[u]++] % MOD;
  // cerr << "DEBUG: " << u << " " << f[u] << "\n";
}

void dfs2(int u, int from) {
  ans[u] = 1LL * f[u] * mod_pow(fac[sz[u] - 1], MOD - 2) % MOD;
  if (from != -1) {
    ll cur = 1;
    cur = cur * ans[from] * mod_pow(fac[n - 1], MOD - 2) % MOD;
    cur = cur * fac[sz[u]] % MOD * mod_pow(f[u], MOD - 2) % MOD;
    cur = cur * mod_pow(n - sz[u], MOD - 2) % MOD;
    ans[u] = ans[u] * cur % MOD;
  }
  ans[u] = 1LL * ans[u] * fac[n - 1] % MOD;
  for (int v : adj[u]) {
    if (v == from) continue;
    dfs2(v, u);
  }
}

void solve() {
  cin >> n;
  fac[0] = 1;
  for (int i = 1; i <= n; ++i) fac[i] = 1LL * fac[i - 1] * i % MOD;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs1(0, -1);
  dfs2(0, -1);

  for (int i = 0; i < n; ++i) cout << ans[i] << "\n";
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int o_o = 1;
  if (!o_o) cin >> o_o;
  for (; o_o; --o_o) solve();
  return 0;
}


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

int main(){
    int n,w;
    scanf("%d %d",&n,&w);
    int wt[n],val[n];
    for(int i=0;i<n;i++)
        scanf("%d %d",&wt[i],&val[i]);
    long long dp[n+1][w+1];
    for(int i=0;i<w+1;i++)dp[0][i]=0;
    for(int i=0;i<n+1;i++)dp[i][0]=0;
    for(int i=1;i<n+1;i++){
        for(int j=1;j<w+1;j++){
            if(j-wt[i-1]>=0)dp[i][j] = max(val[i-1]+dp[i-1][j-wt[i-1]], dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    printf("%lld",dp[n][w]);
    return 0;
}

Measured memory_bytes: 82564
D, G = list(map(int, input().split()))

p, c = [], []
for i in range(1,D+1):
  pi,ci = list(map(int, input().split()))
  p.append(pi)
  c.append(ci)

res = float('inf')

for i in range(2**D):
  score, solved = 0, 0
  all_solved = []

  for j in range(D):
    if (i>>j)&1:
      score += 100*(j+1)*p[j] + c[j]
      solved += p[j]
      all_solved.append(j)
      if score >= G: break

  if score < G:
    for k in range(D-1, -1, -1):
      if k not in all_solved:
        for num in range(p[k]):
          score += 100*(k+1)
          solved += 1
          if score >= G: break
        if score >= G: break
        score += c[k]

  if score >= G:
    res = min(res, solved)

print(res)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
const int MN=50+5;
const int P=1000000007;
using namespace std;
typedef long long ll;
template<typename T>inline T&IN(T&in){
	in=0;char c=getchar();int f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))in=in*10+c-'0',c=getchar();
	return in*=f;
}
int n,m,k,N;
ll fac[MN*MN],inv[MN*MN],ans;
vector<int>vec[MN];int g[MN][MN];
int low[MN],dfn[MN],vis[MN],scc,st[MN];
int nxt[MN*4],to[MN*4],h[MN],cnt;
void add(int u,int v){to[cnt]=v,nxt[cnt]=h[u],h[u]=cnt++;}
ll qp(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%P)if(b&1)c=c*a%P;return c;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int polya(int n){ll c=0;for(int i=1;i<=n;++i)c=(c+qp(k,gcd(i,n)))%P;return c*qp(n,P-2)%P;}
ll C(int n,int m){return fac[n]*inv[m]%P*inv[n-m]%P;}
void tarjan(int u,int fa){
	dfn[u]=low[u]=++dfn[0];
	vis[u]=1,st[++st[0]]=u;
	for(int e=h[u],v=to[e];~e;e=nxt[e],v=to[e])if(v^fa){
		if(!dfn[v]){
			tarjan(v,u);low[u]=min(low[v],low[u]);
			if(low[v]>=dfn[u]){
				vec[++scc].push_back(u);
				while(dfn[st[st[0]]]>=dfn[v])
					vec[scc].push_back(st[st[0]]),vis[st[st[0]]]=0,st[0]--;
			}
		}
		else if(vis[v])low[u]=min(low[u],dfn[v]);
	}
}
void input(){
	IN(n),IN(m),IN(k);memset(h,-1,sizeof h);fac[0]=ans=1;N=1000;
	for(int i=1;i<=N;++i)fac[i]=fac[i-1]*i%P;
	inv[N]=qp(fac[N],P-2);
	for(int i=N;i>=1;--i)inv[i-1]=inv[i]*i%P;
	for(int i=1,u,v;i<=m;++i)IN(u),IN(v),add(u,v),add(v,u),g[u][v]=g[v][u]=1;
	for(int i=1;i<=n;++i)if(!dfn[i])tarjan(i,0);
	for(int i=1;i<=scc;++i){
		int s=0;
		for(int j=0;j<vec[i].size();++j)for(int k=j+1;k<vec[i].size();++k)
			s+=g[vec[i][j]][vec[i][k]];
		if(s==vec[i].size())ans=ans*polya(s)%P;
		else ans=ans*C(s+k-1,k-1)%P;
	}
	printf("%lld\n",ans);
}
int main(){
	input();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll h,w,k;cin>>h>>w>>k;
  vector<string> v(h);
  VV<int> ans(h,vector<int>(w));
  vector<bool> nai(h,false);
  rep(i,0,h)cin>>v[i];
  ll ind=1;
  bool ini=true;
  rep(i,0,h){
    ini=true;
    rep(j,0,w){
      if(v[i][j]=='#'){
        if(!ini)ind++;
        else ini=false;
      }
      ans[i][j]=ind;
    }
    nai[i]=ini;
    if(!nai[i])ind++;
  }


  rep(i,0,h){
    if(!nai[i]){
      ll g=i;
      while(0<g && nai[g-1]){
        rep(j,0,w){
          ans[g-1][j]=ans[g][j];
        }
        g--;
        nai[g]=false;
      }
      g=i;
      while(g<h-1 && nai[g+1]){
        rep(j,0,w){
          ans[g+1][j]=ans[g][j];
        }
        g++;
        nai[g]=false;
      }
    }
  }

  rep(i,0,h){
    rep(j,0,w){
      cout<<ans[i][j]<<" ";
    }cout<<endl;
  }
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,k,ans=0,fct[N];
ll ksm(ll x,ll y)
{
	if(y==0)
	{
		return 1;
	}
	if(y==1)
	{
		return x;
	}
	ll ret=ksm(x,y/2);
	if(y%2==1)
	{
		return ((ret*ret)%MOD*x)%MOD;
	}
	return (ret*ret)%MOD;
}
ll com(ll a,ll b)
{
	b=min(n,a-b);
	return ((fct[a]*ksm(fct[b],MOD-2))%MOD*ksm(fct[a-b],MOD-2))%MOD;
}
int main(){
	ll i,t;
	cin>>n>>k;
	fct[0]=1;
	for(i=1;i<=n;i++)
	{
		fct[i]=(fct[i-1]*i)%MOD;
	}
	for(i=n;i>=max(n-k,(ll)1);i--)
	{
		ans=(ans+(com(n,i)*com(n-1,i-1))%MOD)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    int tmp = n;
    int sum = 0;
    while (tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }
    if (n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O2")
// #pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
// #define int ll
#define pb push_back
#define pob pop_back
#define __bp __builtin_popcount
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pdd = pair<ld,ld>;
using vint = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
#define F first
#define S second
const int N = 2e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int Inf = 1e9+7;
const ll INF = 1e18+7;
const int Mod = 998244353;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("sweets.in", "r", stdin);
//	freopen("sweets.out", "w", stdout);
//	cout << setprecision(7) << fixed;
}

int n, a[N], b[N], c[N], d[N];

void solve()
{
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	for (int i = 0; i < n; ++i)
	{
		++c[a[i]];
		++d[b[i]];
	}
	for (int i = 1; i <= n; ++i)
	{
		if (c[i] + d[i] > n) {
			cout << "No\n";
			return;
		}
		c[i] += c[i - 1];
		d[i] += d[i - 1];
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		ans = max(ans, c[i] - d[i - 1]);
	}
	cout << "Yes\n";
	for (int i = 0; i < n; ++i)
	{
		cout << b[(i + n - ans) % n] << ' ';
	}
	cout << '\n';
}

signed main()
{
	io();
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		// solve();
		solve();
//		cerr << '\n';

	}
}

Measured memory_bytes: 6788
class String
  def C
    self.rotate 1
  end

  def J
    self.rotate -1
  end

  def E
    h = self.length/2
    if self.length.odd?
      self.slice(h+1, self.length)+self[h]+self.slice(0,h)
    else
      self.slice(h,self.length)+self.slice(0,h)
    end
  end

  def A
    self.reverse
  end

  def M
    s=''
    self.chars.each do |c|
      if c =~ /[0-9]/
        s += c=='9' ? '0' : (c.to_i+1).to_s
      else 
        s += c
      end
    end
    s
  end

  def P
    s=''
    self.chars.each do |c|
      if c =~ /[0-9]/
        s += c=='0' ? '9' : (c.to_i-1).to_s
      else 
        s += c
      end
    end
    s
  end

  def rotate(n)
    n += self.length if n < 0
    self.slice(n, self.length-n)+self.slice(0,n)
  end
end

n = gets.to_i
n.times do
  s = gets.chomp
  msg = gets.chomp
  s.reverse.chars.each do |c|
    msg = msg.J if c == 'J'
    msg = msg.C if c == 'C'
    msg = msg.E if c == 'E'
    msg = msg.A if c == 'A'
    msg = msg.P if c == 'P'
    msg = msg.M if c == 'M'
  end
  puts msg
end

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

int main() {
    string S,O;
    int a,b;
    cin >> S;
    O = "NA";
    a = (S[0]-'0')*10+(S[1]-'0');
    b = (S[2]-'0')*10+(S[3]-'0');
    if(a<=12 && a>=1){
        O = "MMYY";
        if(b<=12 && b>=1){
            O = "AMBIGUOUS";
        }
    }
    else if(b<=12 && b>=1){
        O = "YYMM";
    }
    cout << O << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;

int main(){

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

    char last_word;
    for(int i = 0; i < N; i++){
        if(i == 0){
            last_word = W[i].back();
            continue;
        }
        if(W[i].front() == last_word){
            for(int j = 0; j < i; j++){
                if(W[j]==W[i]){
                    puts("No");
                    return 0;
                }
            }
        }else{
            puts("No");
            return 0;
        }
        last_word = W[i].back();
    }

    puts("Yes");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
double dist(double x,double y,double a,double b){
    return sqrt((x-a)*(x-a)+(y-b)*(y-b));
}
pair<pair<double,double>,double>Vertical_bisector(double x1,double y1,double x2,double y2){
    pair<pair<double,double>,double>res=mp(mp((x1-x2),(y1-y2)),(x2*x2-x1*x1+y2*y2-y1*y1)/2.0);
    return res;
}
pair<double,double>Intersection(pair<pair<double,double>,double>l,pair<pair<double,double>,double>s){
    double a1,b1,c1,a2,b2,c2;
    a1=l.first.first;
    b1=l.first.second;
    c1=l.second;
    a2=s.first.first;
    b2=s.first.second;
    c2=s.second;
    double x,y,bunbo;
    bunbo=a1*b2-a2*b1;
    x=(c2*b1-c1*b2)/bunbo;
    y=(a2*c1-a1*c2)/bunbo;
    return mp(x,y);
}
int main(){
    ll n;cin>>n;
    vector<pair<double,double> >p(n);
    rep(i,n){
        cin>>p[i].first>>p[i].second;
    }
    double ma=2000.0;
    rep(i,n){
        REP(j,i+1,n){
            double x=(p[i].first+p[j].first)/2.0;
            double y=(p[i].second+p[j].second)/2.0;
            double r=0.0;
            rep(k,n){
                r=max(r,dist(p[k].first,p[k].second,x,y));
            }
            ma=min(ma,r);
        }
    }
    rep(i,n){
        REP(j,i+1,n){
            REP(k,j+1,n){
                double x1,x2,x3,y1,y2,y3;
                x1=p[i].first,y1=p[i].second;
                x2=p[j].first,y2=p[j].second;
                x3=p[k].first,y3=p[k].second;
                if((y1-y2)*(x1-x3)-(x1-x2)*(y1-y3)!=0.0){
                    pair<pair<double,double>,double>l,s;
                    l=Vertical_bisector(x1,y1,x2,y2);
                    s=Vertical_bisector(x1,y1,x3,y3);
                    pair<double,double>c=Intersection(l,s);
                    double x=c.first,y=c.second;
                    double r=0.0;
                    rep(l,n){
                        r=max(r,dist(p[l].first,p[l].second,x,y));
                    }
                    ma=min(ma,r);
                }
            }
        }
    }
    cout<<fixed<<setprecision(10)<<ma<<endl;
}

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

int main(){
  double a, b, c, d, e, f, tmp;

  while(cin>>a>>b>>c>>d>>e>>f){
    tmp = d/a;
    e -= tmp*b;
    f -= tmp*c;

    f /= e;
    c -= b*f;
    c /= a;

    printf("%.3f %.3f\n", c, f);
  }
}

Measured memory_bytes: 1232
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

class unionfind {
	VI par, rank;
public:
	void init(int N) {
		par.clear();
		rank.clear();
		for (int i = 0; i < N; i++) par.push_back(i);
		for (int i = 0; i < N; i++) rank.push_back(1);
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	int size(int x) {
		if (par[x] == x)return rank[x];
		return size(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		if (rank[rx] < rank[ry]) {
			par[rx] = ry;
			rank[ry] += rank[rx];
		}
		else {
			par[ry] = rx;
			rank[rx] += rank[ry];
		}
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

int main() {
	int n;
	cin >> n;
	vector<pair<ll, int>> x(n), y(n);
	FOR(i, n) {
		cin >> x[i].first >> y[i].first;
		x[i].second = i; y[i].second = i;
	}

	vector<pair<ll, pair<int, int>>> edge;
	SORT(x); SORT(y);
	FOR1(i, n) {
		edge.push_back({ x[i].first - x[i - 1].first,{x[i - 1].second,x[i].second} });
		edge.push_back({ y[i].first - y[i - 1].first,{y[i - 1].second,y[i].second} });
	}

	SORT(edge);
	unionfind uf;
	uf.init(n);
	ll ans = 0;
	for (auto e : edge) {
		if (!uf.same(e.second.first, e.second.second)) {
			uf.unite(e.second.first, e.second.second);
			ans += e.first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 9584
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) (((long long)mod_x)%modulo)

//aのb乗
int beki(int a,int b){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=mod(x*a);
		}
		a=mod(a*a);
		b>>=1;
	}
	return x;
}

//aの逆元
int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	void kaijou_set(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		/*
		int a = kaijou[n];int b = 1;int m = modulo-2;
		while(m!=0){
			if(m%2){
				b=mod(b*a);
			}
			a=mod(a*a);
			m/=2;
		}
		*/
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		if(r<0)return 0;
		if(n<0)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
};

int main(){
	
	int B,W;
	cin>>B>>W;
	combi c;
	c.kaijou_set(B+W+1);
	int white[B+W+1]={};
	int black[B+W+1]={};
	int half = gyakugen(2);
	int a = 1;
	for(int i=0;i<=B+W;i++){
		white[i]=mod(a*c.combination(i-1,i-W));
		black[i]=mod(a*c.combination(i-1,i-B));
		if(i!=0){
			white[i]=mod(white[i]+white[i-1]);
			black[i]=mod(black[i]+black[i-1]);
		}
		a=mod(a*half);
	}
	for(int i=1;i<=B+W;i++){
		int aa = 1-white[i-1];
		if(aa<0)aa+=modulo;
		aa-=black[i-1];
		if(aa<0)aa+=modulo;
		int ans = white[i-1];
		aa = mod(aa*half);
		ans=mod(ans+aa);
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
struct UnionFind{
    vl par;
    UnionFind(ll N):par(N,-1){}
    ll root(ll x){
        if(par[x]<0)return x;
        return par[x]=root(par[x]);
    }
    bool same(ll x,ll y){
        return root(x)==root(y);
    }
    bool unite(ll x,ll y){
        x=root(x),y=root(y);
        if(x==y)return false;
        if(par[x]>par[y])swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }
};
int main(){
    ll N,M;cin>>N>>M;
    UnionFind uf(N);
    vl A(M),B(M);
    rep(i,M)cin>>A[i]>>B[i],A[i]--,B[i]--;
    vl ans(M+1);
    ans[M]=N*(N-1)/2;
    per(i,M){
        if(uf.same(A[i],B[i]))ans[i]=ans[i+1];
        else{
            ans[i]=ans[i+1]-uf.par[uf.root(A[i])]*uf.par[uf.root(B[i])];
            uf.unite(A[i],B[i]);
        }
    }
    repl(i,1,M+1)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,i,x;
cin>>n;
vector<int>a(n);
for(i=0;i<n-1;i++)
{
cin>>x;
x--;
a[x]++;
}
for(i=0;i<n;i++)
cout<<a[i]<<"\n";

}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  long long N,H,W,ans;
	cin>>N>>H>>W;
	ans=0;
	rep(i,N){
	  long long A,B;
		cin>>A>>B;
		if(A>=H && B>=W) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3600