akhauriyash/Code-Regression huggingface dataset:
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 300005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll n;
	cin >> n;
	string s;
	cin >> s;
	vl pref(n + 1, 0), suff(n + 1, 0);
	if (s[0] == 'W')
		pref[0] = 1;
	if (s[n - 1] == 'R')
		suff[n - 1] = 1;
	FOR(i, 1, n - 1)
	{
		pref[i] += pref[i - 1];
		if (s[i] == 'W')
			++pref[i];
	}
	FORD(i, n - 2, 0)
	{
		suff[i] += suff[i + 1];
		if (s[i] == 'R')
			++suff[i];
	}
	ll ans = suff[0];
	FOR(i, 1, n - 1)
	{
		ans = min(ans, max(pref[i - 1], suff[i + 1]));
	}
	cout << ans << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


Measured memory_bytes: 6760
main :: IO ()                                                                                                              
main = do                                                                                                                  
  s <- reverse <$> getLine                                                                                                 
  print $ check s                                                                                                          
                                                                                                                           
check :: String -> Int                                                                                                     
check s = if (take l d2s) == (drop l d2s) then l * 2 else check d2s                                                        
  where l = length s `div` 2 - 1                                                                                           
        d2s = drop 2 s

Measured memory_bytes: 508
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n[] = new int[4];
        for(int i=0;i<4;i++){
            n[i] = sc.nextInt();
        }
        Arrays.sort(n);
        if(n[0]==1 && n[1]==4 && n[2]==7 && n[3]==9)System.out.println("YES");
        else System.out.println("NO");
    }
}


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

int N,Q;
string S;
int data[26][1048575];
int C=524287;

void add(int k,int pos,int x){
	pos+=C;
	data[k][pos]+=x;
	while(pos>0){
		pos=(pos-1)/2;
		data[k][pos]+=x;
	}
}

bool exist(int k,int a,int b,int pos,int l,int r){
	if(r<=a || b<=l)return false;
	if(a<=l && r<=b)return (data[k][pos]>0);
	bool ret1=exist(k,a,b,2*pos+1,l,(l+r)/2);
	bool ret2=exist(k,a,b,2*pos+2,(l+r)/2,r);
	return (ret1 || ret2);
}

int main(){
	cin >> N >> S >> Q;
	for(int i=0;i<S.size();i++){
		int k=S[i]-'a';
		add(k,i,1);
	}
	
	for(int q=0;q<Q;q++){
		int query;
		cin >> query;
		if(query==1){
			int i;
			char c;
			cin >> i >> c;
			i--;
			int k=S[i]-'a';
			add(k,i,-1);
			S[i]=c;
			k=S[i]-'a';
			add(k,i,1);
		} else{
			int l,r;
			cin >> l >> r;
			int ans=0;
			l--;
			for(int k=0;k<26;k++)if(exist(k,l,r,0,0,C+1))ans++;
			cout << ans << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 107396
def solve():
    H, W, D = map(int, input().split())
    posX, posY = [0] * (H * W + 1), [0] * (H * W + 1)
    for i in range(H):
        Ai = list(map(int, input().split()))
        for j in range(W):
            posX[Ai[j]] = i
            posY[Ai[j]] = j
    
    d_cum = [0] * (H * W + 1)
    for i in range(D + 1, H * W + 1):
        d_cum[i] = d_cum[i - D] + abs(posX[i] - posX[i - D]) + abs(posY[i] - posY[i - D])
    
    Q = int(input())
    for _ in range(Q):
        L, R = map(int, input().split())
        print(d_cum[R] - d_cum[L])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9264
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll A, ll B, ll H, ll M) {
  double tb = (M / 60.0) * 2 * M_PI;
  double ta = (H / 12.0) * 2 * M_PI + (M / 60.0) * (M_PI / 6.0);

  double t = abs(tb - ta);

  cout << sqrt(A * A + B * B - 2 * A * B * cos(t)) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll A;
  scanf("%lld", &A);
  ll B;
  scanf("%lld", &B);
  ll H;
  scanf("%lld", &H);
  ll M;
  scanf("%lld", &M);
  solve(A, B, H, M);
  return 0;
}


Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int 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<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

string S, T;

int main()
{
    cin >> S >> T;
    map<int, set<int>> m;
    REP(i, S.size())
    {
        m[S[i] - 'a'].insert(T[i] - 'a');
    }

    set<int> s, t;
    for (auto v : m)
    {
        if (v.second.size() > 1) cout << "No" << endl, exit(0);
        s.insert(v.first);
        t.insert(*v.second.begin());
    }
    if (s.size() == t.size()) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 916
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    map<string,int> mp;
    int mx=0;
    rep(i,n){
        string x;
        cin>>x;
        mp[x]++;
        chmax(mx,mp[x]);
    }
    for(auto s:mp){
        if(s.sc==mx) cout<<s.fs<<endl;
    }
}

Measured memory_bytes: 23808
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int d=0, f=0;
  for(int i=0;i<n;i++){
    bool ans = false;
    if(s[i]=='a'){
      if(d+f<a+b){
        d++;
        ans = true;
      }
    }else if(s[i]=='b'){
      if(d+f<a+b&&f<b){
        f++;
        ans = true;
      }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "-1" << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(){
    int N,Q;
    int A[214514],B[214514];
    int p[214514],x[214514];
    vector<int> G[214514];
    cin >> N >> Q;
    REP(i,N-1){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
        G[A[i]].push_back(B[i]);
    }
    REP(i,Q){
        cin >> p[i] >> x[i];
        p[i]--;
    }
    
    queue<int> P;
    P.push(0);
    int d[214514]={};
    REP(i,Q){
        d[p[i]]+=x[i];
    }
    while(!P.empty()){
        int T=P.front();
        P.pop();
        REP(i,G[T].size()){
            P.push(G[T][i]);
            d[G[T][i]]+=d[T];
        }
    }
    REP(i,N){
        if(i!=0)cout << " ";
        cout << d[i];
    }
    cout << endl;
    return 0;
}   


Measured memory_bytes: 22420
import numpy as np

num = [input() for i in range(2)]
num_0 = int(num[0])
num_1 = np.array(list(map(int, num[1].split())))

num_min = num_1[0]
count = 1

for i in range(1,num_0):
  if num_1[i] <= num_min:
    count = count + 1
    num_min = num_1[i]
    
print(count)

Measured memory_bytes: 35416
//
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    float e[10000][6];
    int n = 0;
    float x[10000], y[10000];
    while (cin >> e[n][0] >> e[n][1] >> e[n][2] >> e[n][3] >> e[n][4] >> e[n][5]) {
        float d = e[n][0] * e[n][4] - e[n][1] * e[n][3];
        x[n] = (e[n][4] * e[n][2] - e[n][1] * e[n][5]) / d;
        y[n] = (0 - e[n][3] * e[n][2] + e[n][0] * e[n][5]) / d;
        //printf("d: %f, x: %.4f, y: %.4f\n", d, x[n], y[n]);
        n++;
    }
    
    
    for(int i = 0; i < n; i++){
        if(x[i] == -0){
            x[i] = 0;
        }
        if(y[i] == -0){
            y[i] = 0;
        }
        printf("%.3f %.3f\n", x[i], y[i]);
    }
    
    
    return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

const int MAX_N = 300005;
const int mod = 998244353;

int N, A, B, K;

int NN[MAX_N];

int hou(int k)
{
  int ret = 1;
  int tmp = k;

  int kk = mod-2;

  while(kk > 0) {
    if(kk&1) {
      ret *= tmp;
      ret %= mod;
    }
    kk >>= 1;
    tmp *= tmp;
    tmp %= mod;
  }

  return ret;
}

int myTimes(int a, int b)
{
  return (a*b)%mod;
}

signed main()
{
  cin >> N >> A >> B >> K;

  NN[0] = NN[1] = 1;
  for(int i = 1; i < MAX_N-1; i++) {
    NN[i+1] = (NN[i]*(i+1))%mod;
  }

  int ans = 0;
  for(int i = 0; i <= N; i++) {
    int j = (K-A*i)/B;
    if(0 <= j && j <= N && i*A + B*j == K) {
      ans += myTimes(myTimes(NN[N], myTimes(hou(NN[j]), hou(NN[N-j]))),
		     myTimes(NN[N], myTimes(hou(NN[i]), hou(NN[N-i]))));
      ans %= mod;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){

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

Measured memory_bytes: 5200
#include <iostream>
using namespace std;
int main(){
	int a, b, c, d = 0;
	int e, f, g, h = 0;
	cin >> a >> b >> c >> d;
	cin >> e >> f >> g >> h;
	if (a + b + c + d > e + f + g + h){
		cout << a + b + c + d << endl;
	}
	else if (a + b + c + d < e + f + g + h){
		cout << e + f + g + h << endl;
	}
	else if (a + b + c + d == e + f + g + h){
		cout << a + b + c + d << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
    
        System.out.println(dirrerentString(S,T));
    }
    
    private static int dirrerentString(String p, String c) {
        int different = 1001;
        for (int i=0; i<=p.length()-c.length(); i++) {
            int d = dirrerentLetter(c, p.substring(i, i+c.length()));
            if (d < different) {
                different = d;
                if (different == 0) {
                    break;
                }
            }
        }
        return different;
    }
    
    private static int dirrerentLetter(String s1, String s2) {
        int result = 0;
        for (int i=0; i<s1.length(); i++) {
            if (s1.charAt(i) != s2.charAt(i)) {
                result++;
            }
        }
        return result;
    }
}


Measured memory_bytes: 35428
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val d = sc.nextInt()
    val c = Array(26) { sc.nextInt() }
    val s = Array(d) { Array(26) { sc.nextInt() } }
    for (i in 0 until d) {
        println(i % 26 + 1)
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 35924
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
int main()
{
    char a,b;
    cin>>a>>b;
    if(a=='H')
      cout<<b;
    else
    {
       if(b=='H')
         cout<<'D';
       else
         cout<<'H';
    }
    cout<<nl;
    return 0;
}


Measured memory_bytes: 256
void main() {
    long n = readln.chomp.to!long;
    string s = readln.chomp;

    long cnt;
    foreach (i; 0 .. 1000)
    {
        dchar[] a =[
            (i / 100 + '0').to!dchar,
            (i % 100 / 10 + '0').to!dchar,
            (i % 10 + '0').to!dchar
        ];
        bool ok;
        long index;
        foreach (x; s)
        {
            if (x == a[index])
            {
                ++index;
            }

            if (index == 3)
            {
                ++cnt;
                break;
            }
        }
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 380
from math import sqrt

n = int(input())

def prime_factors(N):
    a = []
    while N % 2 == 0:
        a.append(2)
        N //= 2
    f = 3
    while f * f <= N:
        if N % f == 0:
            a.append(f)
            N //= f
        else:
            f += 2
    if N != 1:
        a.append(N)
    return a


factors = prime_factors(n)
print("{}:".format(n), *factors)


Measured memory_bytes: 5656
#include <iostream>
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <set>
#include <vector>
#include <list>
#include <deque>
#include <algorithm>
#include <stack>
#include <numeric>
#include <time.h>
#include<iomanip>
#include<sstream>
#pragma disable:4996)
using namespace std;
const long long inf = 0x7f7f7f7f;
long long GCD(long long a, long long b) { return 0 == b ? a : GCD(b, a%b); }
const long long mod = 1e9 + 7;
const double pi = acos(-1);
long long a[120000];
long long l[120000];
long long r[120000];
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	l[0] = a[0];
	for (int i = 1; i < n; i++)
		l[i] = GCD(l[i - 1], a[i]);
	r[n - 1] = a[n - 1];
	for (int i = n - 2; i >= 0; i--)
		r[i] = GCD(r[i + 1], a[i]);
	long long ans = 1;
	for (int i = 1; i < n-1; i++)
		ans = max(GCD(l[i - 1], r[i + 1]), ans);
		cout << max(ans,max(r[1],l[n-2])) << endl;
}


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

int main(void) {
	double x1, y1, x2, y2;
	if (scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2) != 4) return 1;
	printf("%.15f\n", sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
	return 0;
}




Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  bool ok = true;
  rep(i, s.size()) {
    if(i % 2 && s[i] != 'i')
      ok = false;
    else if(i % 2 == 0 && s[i] != 'h')
      ok = false;
  }
  if(s.size() % 2) ok = false;
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

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

fn solve(h: i64) -> i64 {
  if h == 1 {
    return 1;
  }
  return 1 + 2 * solve(h / 2);
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    h: i64,
  }

  puts!("{}\n", solve(h));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cstdlib> 
#include <string.h>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <ctime>
#include <algorithm>
#include <cmath>
#define PI 3.1415926535897932384626433832795l
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define deci(n) cout<<fixed<<setprecision(n);
#define F first
#define S second
#define mk make_pair
#define pb push_back
#define ALPHA 27
#define ll long long int
#define ld long double
#define mmset(arr, n) memset(arr, n, sizeof arr)
#define debug(x) cerr << '#' << ' ' << x << '\n'
#define len(s) s.length()
#define ForA(i,a,b) for(int i = a; i < b; i++)
#define ForA1(i,a,b) for(int i = b - 1; i >= a; i--)
#define ForB1(i,a,b) for(int i = b; i > a; i--)
#define ForB(i,a,b) for(int i = a; i <= b; i++)
#define INT_SIZE 18 
#define maxn 110

using namespace std;

const ll INF = (ll)(8e18);
const ll MOD = 1000000007;

ll w[maxn],v[maxn], dp[maxn][100001];

int main()
{
    IOS;      
    ll n,W; cin >> n >> W;
    ForB(i,1,n) cin >> w[i] >> v[i];
    ForB(i,1,n){
        ForB(j,1,W){
           if(j >= w[i]) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
           else dp[i][j] = dp[i - 1][j];
        }
    }
    cout << dp[n][W] << '\n';
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0 ;
}


Measured memory_bytes: 79360
S = input()
n = len(S)
import copy

ans = [0]

def rec(index,tmp,tmp_list):
    # print(tmp,tmp_list)
    if index > n-1:

        tmp_list.append(tmp)
        # print(tmp_list)
        # print(tmp_list)
        ans[0] += sum(tmp_list)
        return

    tmp_list1 = copy.deepcopy(tmp_list)
    tmp_list2 = copy.deepcopy(tmp_list)
    
    
    tmp_list1.append(tmp)
    rec(index+1,int(S[index]),tmp_list1)

    rec(index+1,10*tmp + int(S[index]),tmp_list2)
    return

rec(1,int(S[0]),[])
print(ans[0])

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
const int maxn=3010;
typedef long long ll;
int r,c,k;
ll v[maxn][maxn],dp[maxn][maxn][4];
int main()
{
    scanf("%d%d%d",&r,&c,&k);
    for(int i=1;i<=k;i++)
    {
        int ri,ci,vi;
        scanf("%d%d%d",&ri,&ci,&vi);
        v[ri][ci]=vi;
    }
    dp[1][1][1]=v[1][1];
    for(int i=1;i<=r;i++)
        for(int j=1;j<=c;j++)
    {
        if(j-1>=1)
        {
            for(int k=0;k<4;k++)
                dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
            for(int k=1;k<4;k++)
                dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k-1]+v[i][j]);
        }
        if(i-1>=1)
        {
            for(int k=0;k<4;k++)
                dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
            for(int k=0;k<4;k++)
                dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+v[i][j]);
        }
    }
    ll ans=0;
    for(int i=0;i<4;i++) ans=max(ans,dp[r][c][i]);
    printf("%lld\n",ans);
}


Measured memory_bytes: 356080
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;

const int N = 2048; typedef long long ll;

int bz[N],st[N],pre[N]; queue < int > q;
int n,tot,S,T,V1,V2,V3,V4; ll ans,dis[N];
struct EDGE{ int to,next,flow,cost; } g[N * 50];

int min(int x,int y) { return x < y ? x : y; }

void add(int u,int v,int w,int x)
{ g[++tot] = (EDGE){ v,st[u],w,x }, st[u] = tot; }

void add_edge(int u,int v,int w,int x) { add(u,v,w,x), add(v,u,0,-x); }

int spfa()
{
	memset(bz,0,sizeof bz),
	memset(pre,0,sizeof pre),
	memset(dis,-0x3f,sizeof dis);
	
	while(q.size()) q.pop();
	q.push(S), dis[S] = 0, bz[pre[S] = S] = 1;
	
	for(int x;q.size();bz[x] = 0)
	{
		x = q.front(), q.pop();
		for(int i = st[x];i;i = g[i].next)
			if(g[i].flow && dis[x] + g[i].cost > dis[g[i].to])
				!bz[g[i].to] && (q.push(g[i].to), bz[g[i].to] = 1),
				dis[g[i].to] = dis[x] + g[i].cost, pre[g[i].to] = i;
	}
	
	return pre[T];
}

void update()
{
	int flow = 0x3f3f3f3f; ll cost = 0ll;
	for(int i = T;i != S;i = g[pre[i] ^ 1].to)
		flow = min(flow,g[pre[i]].flow), cost += g[pre[i]].cost;
	ans += cost * flow;
	for(int i = T;i != S;i = g[pre[i] ^ 1].to)
		g[pre[i]].flow -= flow, g[pre[i] ^ 1].flow += flow;
}

int main()
{
	scanf("%d",&n), S = n * 2 + 1, T = S + 1, tot = 1,
	V1 = T + 1, V2 = V1 + 1, V3 = V2 + 1, V4 = V3 + 1;
	
	for(int i = 1,x,y,z;i <= n; ++ i)
		scanf("%d%d%d",&x,&y,&z), add_edge(S,i,z,0),
		add_edge(i,V1,z,x + y), add_edge(i,V2,z,x - y),
		add_edge(i,V3,z,- x + y), add_edge(i,V4,z,- x - y);
	
	for(int i = 1,x,y,z;i <= n; ++ i)
		scanf("%d%d%d",&x,&y,&z), add_edge(i + n,T,z,0),
		add_edge(V4,i + n,z,x + y), add_edge(V3,i + n,z,x - y),
		add_edge(V2,i + n,z,- x + y), add_edge(V1,i + n,z,- x - y);
	
	for(ans = 0ll;spfa();) update();
	printf("%lld\n",ans);
	
	return 0;
}

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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 3e6 + 5;
const int P = 1e9 + 7;
int fac[N], ifac[N], f[N];

int Pow(int x, int t)
{
	int res = 1;
	for (; t; t >>= 1, x = 1LL * x * x % P)
		if (t & 1) res = 1LL * res * x % P;
	return res;
}

int main()
{
	int n = read();
	
	fac[0] = 1;
	for (int i = 1; i < N; ++i) fac[i] = 1LL * i * fac[i - 1] % P;
	ifac[N - 1] = Pow(fac[N - 1], P - 2);
	for (int i = N - 1; i >= 1; --i) ifac[i - 1] = 1LL * i * ifac[i] % P;
	
	int ans = 0;
	for (int i = (n + 1) / 2; i <= n; ++i) 
		f[i] = 1LL * fac[i] * fac[i - 1] % P * ifac[2 * i - n] % P;
	for (int i = (n + 1) / 2; i <= n; ++i) 
		ans = ((ans + 1LL * i * (f[i] - f[i - 1]) % P) % P + P) % P;
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 27904
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<int> h(n+2,0);
  rep(i,n){
    cin>>h[i+1];
  }
  int ans=0;
  int poi=h[0];
  for(int i=1; i<=n; i++){
    poi = min(poi,h[i]);
    if(h[i-1]<=h[i] && h[i]>h[i+1]){ ans += h[i]-poi; poi=inf; }
  }  
  
  cout << ans << endl; 
  return 0;
}


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

int main(){
  int z=0,n;
  string s,t;
  cin >> s;
  n=s.size();
  int k=n-1;
  while(k>=6){
    if(s[k]=='m'&&s[k-1]=='a'&&s[k-2]=='e'&&s[k-3]=='r'&&s[k-4]=='d') k-=5;
    else if(s[k]=='r'&&s[k-1]=='e'&&s[k-2]=='m'&&s[k-3]=='a'&&s[k-4]=='e'&&s[k-5]=='r'&&s[k-6]=='d') k-=7;
    else if(s[k]=='e'&&s[k-1]=='s'&&s[k-2]=='a'&&s[k-3]=='r'&&s[k-4]=='e') k-=5;
    else if(s[k]=='r'&&s[k-1]=='e'&&s[k-2]=='s'&&s[k-3]=='a'&&s[k-4]=='r'&&s[k-5]=='e') k-=6;
    else break;
  }
  if(k==5){
    if(s[k]=='r'&&s[k-1]=='e'&&s[k-2]=='s'&&s[k-3]=='a'&&s[k-4]=='r'&&s[k-5]=='e') k-=6;
  }else if(k==4){
    if(s[k]=='m'&&s[k-1]=='a'&&s[k-2]=='e'&&s[k-3]=='r'&&s[k-4]=='d') k-=5;
    else if(s[k]=='e'&&s[k-1]=='s'&&s[k-2]=='a'&&s[k-3]=='r'&&s[k-4]=='e') k-=5;
  }
  if(k==-1) cout << "YES" << endl;
  else cout <<"NO" <<endl;
  return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
	int n , k;
	cin >> n >> k;
	vector<int> a(n); for(int i = 0; i < n; i++)cin >> a[i];
	if(k > *max_element(a.begin(), a.end())) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	int gc = a[0];
	for(int i = 0; i < n; i++) {
		gc = __gcd(a[i], gc);
	}

	for(int i = 0; i < n; i++) {
		if(a[i] < k)continue;
		if((a[i] - k) % gc == 0) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;

}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int q;
  cin>>q;

  while(q--){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();

    vector<vi> dp(n+1,vi(m+1,0));

    loop(i,1,n+1)loop(j,1,m+1){
      if(s[i-1] == t[j-1]){
        dp[i][j] = dp[i-1][j-1] + 1;
      }else{
        dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
      }
    }

    cout << dp[n][m] << endl;
  }
}



Measured memory_bytes: 6876
# frozen_string_literal: true

def factor(n)
  return [1] if n == 1

  `factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n`.split.map(&:to_i)
end

def uniq_factor(n)
  `factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n|uniq`.split.map(&:to_i)
end

n, p = gets.split(' ').map(&:to_i)

factors = factor(p)

factors_map = Hash.new(0)
factors.each do |i|
  factors_map[i] += 1
end

ans = 1
factors_map.each do |key, val|
  ans *= key**(val / n) if val >= n
end

puts ans


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

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

  vector<vector<int>> to(n);

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    to[a - 1].push_back(b - 1);
  }

  int s, t;
  cin >> s >> t;
  s--;
  t--;
  vector<vector<int>> dist(n, vector<int>(3, -1));
  queue<pair<int, int>> q;
  q.emplace(s, 0);
  dist[s][0] = 0;

  while (!q.empty()) {
    int v = q.front().first;
    int l = q.front().second;
    q.pop();
    for (const auto& u : to[v]) {
      int nl = (l + 1) % 3;
      if (dist[u][nl] >= 0) continue;
      dist[u][nl] = dist[v][l] + 1;
      q.emplace(u, nl);
    }
  }

  int ans = dist[t][0];
  if (ans > 0) ans /= 3;
  cout << ans << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>

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

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}


Measured memory_bytes: 256
#include <iostream>

inline int calcGcd(int x,int y){
	while(x % y != 0){
		int num = x % y;
		x = y;
		y = num;
	}
	return y;
}

inline int calcLcm(int x,int y){
	return x / calcGcd(x,y) * y;
}

int main(){
	int a,b;
	while(std::cin >> a >> b)
		std::cout << calcGcd(a,b) << " " << calcLcm(a,b) << std::endl;
}

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

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

	int N,M;
	int i,k;
	int digit,num;
	bool flag=false;
	int ans=0;

	cin >> N >> M;

	vector<int> gv(N);

	rep(i,M){
		cin >> digit;
		cin >> num;

		if((gv[digit-1]!=0 && gv[digit-1]!=num)) flag=true;
		if((digit-1==0 && num==0) && N!=1) flag=true;

		gv[digit-1]=num;
	}

	if(flag){
		cout << "-1" << endl;
		return 0;
	}

	if(gv[0]==0 && N!=1) gv[0]=1;
	rep(i,N) ans+=gv[i]*pow(10.0,(double)(N-1-i));
	
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3776
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

bool bingo[3][3];

int main(){	
	ll A[3][3];
	rep(i, 3) {
		rep(j, 3) {
			cin >> A[i][j];
		}
	}
	ll N;
	cin >> N;
	vector<ll> b(N);
	rep(i, N) {
		cin >> b[i];
	}

	
	rep(i, N) {
		rep(j, 3) {
			rep(k, 3) {
				if (b[i] == A[j][k]) bingo[j][k] = true;
			}
		}
	}

	if ((bingo[0][0] && bingo[1][1] && bingo[2][2])
	|| (bingo[2][0] && bingo[1][1] && bingo[0][2])
	|| (bingo[0][0] && bingo[0][1] && bingo[0][2])
	|| (bingo[1][0] && bingo[1][1] && bingo[1][2])
	|| (bingo[2][0] && bingo[2][1] && bingo[2][2])
	|| (bingo[0][0] && bingo[1][0] && bingo[2][0])
	|| (bingo[0][1] && bingo[1][1] && bingo[2][1])
	|| (bingo[0][2] && bingo[1][2] && bingo[2][2])) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;


int main(){
    int n,tm;
    long long dp[101][21];
    memset(dp,0,sizeof(dp));
    cin>>n>>tm;
    dp[1][tm]=1;
    for(int i=1;i<n-1;++i){
        cin>>tm;
        for(int j=0;j<21;++j){
            if(j+tm<=20) dp[i+1][j+tm]+=dp[i][j];
            if(j-tm>=0) dp[i+1][j-tm]+=dp[i][j];
        }
    }
    cin>>tm;
    cout<<dp[n-1][tm]<<endl;
    return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	string S;
	cin >> S;
	if (S == "ABC")
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "ABC" << endl;
	}

	return 0;
}

Measured memory_bytes: 3628
#include <cstdio>

int main() {
  int question_count;
  scanf("%d", &question_count);

  int sec_for_solve_array[question_count];
  // int sum = 0;
  for (int i = 0; i < question_count; ++i) {
    scanf("%d", &sec_for_solve_array[i]);
    // sum += sec_for_solve_array[i];
  }

  int drink_count;
  scanf("%d", &drink_count);

  int question_num_array[drink_count];
  int sec_for_solve_after_drink_array[drink_count];
  for (int i = 0; i < drink_count; ++i) {
    scanf("%d", &question_num_array[i]);
    scanf("%d", &sec_for_solve_after_drink_array[i]);
  }

  int sec_for_solve_index;
  int sec_for_solve;
  int sec_for_solve_after_drink;
  int question_num;
  int sum = 0;
  for (int i = 0; i < drink_count; ++i) {
    question_num = question_num_array[i];
    sec_for_solve_index = question_num - 1;
    sec_for_solve = sec_for_solve_array[sec_for_solve_index];
    sec_for_solve_after_drink = sec_for_solve_after_drink_array[i];
    sec_for_solve_array[sec_for_solve_index] = sec_for_solve_after_drink;
    for (int j = 0; j < question_count; ++j) {
      sum += sec_for_solve_array[j];
    }
    printf("%d\n", sum);

    // 合計値の初期化
    sum = 0;

    // かかる時間リストの初期化
    sec_for_solve_array[sec_for_solve_index] = sec_for_solve;
  }
  // printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

bool all_on(const int pattern, vector<vector<int>> lights, vector<int> p)
{
    for(size_t i = 0 ; i < p.size() ; i++){
        int sw_on = 0;
        for(int& sw : lights[i]){
            if(((pattern >> (sw - 1)) & 1) == 1){
                sw_on++;
            }
        }
        if(sw_on % 2 == p[i]){
            continue;
        } else {
            return false;
        }
    }
    return true;
}


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

    vector<vector<int>> lights(m);
    for(vector<int>& l : lights){
        int k; 
        cin >> k;
        l.resize(k);
        for(int& sw : l){
            cin >> sw;
        }
    }

    vector<int> ps(m);
    for(int& p : ps){
        cin >> p;
    }

    int result = 0;
    for(int pattern = 0 ; pattern < (int)pow(2.0, (double)n) ; pattern++){
        if(all_on(pattern, lights, ps)){
            result++;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
void quit(T a)
{
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 10010020030040056ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main()
{
    string s;
    cin >> s;
    int a = 0;
    int b = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A')
        {
            a++;
        }
        else
        {
            b++;
        }
    }
    if (a == 0 || b == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
import sys
import numpy as np
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
XY = [[] for _ in range(N)]
for i in range(N):
    a = ir()
    for j in range(a):
        x, y = lr()
        XY[i].append((x-1, y)) # 0-indexedとして

A = np.array(list(itertools.product([0, 1], repeat=N)), np.bool)
for i in range(N):
    for x, y in XY[i]:
        bl = (~A[:, i]) | (A[:, x] == bool(y)) # その人が不親切の場合、または、正直者の場合
        A = A[bl]

answer = np.sum(A, axis=1).max()
print(answer)
# 24 repeat

Measured memory_bytes: 28188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	vector<int> a(5);
	int ans = -1;
	for (int i = 0; i < 5; ++i) {
		cin >> a[i];
		if (a[i] == 0)
			ans = i+1;
	}
	cout << ans << '\n';	
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int n,m;
char ch[60][60];
int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    for(int j=1; j<=m; j++)
    cin>>ch[i][j];
    for(int i=1; i<=n; i++)
    {
    	for(int j=1; j<=m; j++)
    	if(ch[i][j]!='#')
    	{
    		int h=0;
    		h+=(ch[i][j+1]=='#');
    		h+=(ch[i][j-1]=='#');
    		h+=(ch[i-1][j]=='#');
    		h+=(ch[i+1][j]=='#');
    		h+=(ch[i+1][j-1]=='#');
    		h+=(ch[i+1][j+1]=='#');
    		h+=(ch[i-1][j-1]=='#');
    		h+=(ch[i-1][j+1]=='#');
    		cout<<h;
    	}
    	else
    	cout<<"#";
    	cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n;
    string s;
    cin >> n >> s;

    int lc=0, rc=0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '(') {
            lc++;
        } else {
            if (lc > 0) {
                lc--;
            } else {
                rc++;
            }
        }
    }

    for (int i = 0; i < rc; i++) {
        cout << "(";
    }
    cout << s;
    for (int i = 0; i < lc; i++) {
        cout << ")";
    }

    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e6+5;
string s;
vector<int> v[N];
int n;
ll a[N];

int main () {
  cin >> n;

  cout << n*n*n << endl;
}


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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] > b[i]) {
			sum += a[i] - b[i];
		}
	} 
	cout << sum;
}



















Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"3 8
3 30
4 50
5 60"# => r#"90"#,

r#"5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000"# => r#"5000000000"#,

r#"6 15
6 5
5 6
6 4
6 6
3 5
7 2"# => r#"17"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        n: usize, w: usize,
        wv: [(usize, usize); n],

    }

    let mut dp = vec![vec![0; 100100]; 110];
    // let mut dp = vec![vec![0; 10]; 110];

    for i in 0..n {
        for j in 0..w + 1 {
            if wv[i].0 <= j {
                dp[i + 1][j] = std::cmp::max(dp[i + 1][j], dp[i][j - wv[i].0] + wv[i].1);
            }
            dp[i + 1][j] = std::cmp::max(dp[i + 1][j], dp[i][j]);
        }
    }

    // println!("{:?}", dp[n]);
    // println!("{}", dp[n][w]);
    dp[n][w].to_string()
}

Measured memory_bytes: 116988