akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int H = sc.nextInt();
        int W = sc.nextInt();
        int map[][] = new int[H][W];

        for (int i=0;i<H;i++) {
            String S = sc.nextToken();
            for (int j=0;j<W;j++) {
                if (S.charAt(j) == '.') {
                    map[i][j] = 0;
                } else {
                    map[i][j] = 1;
                }
            }
        }

        int w_count[][] = new int[H][W];
        for (int i=0;i<H;i++) {
            int s = 0;
            for (int j=0;j<W;j++) {
                if (map[i][j] == 1) {
                    for (int k=s;k<j;k++) {
                        w_count[i][k] = j - s;
                    }
                    s = j+1;
                } else {

                }
            }
            {
                for (int k=s;k<W;k++) {
                    w_count[i][k] = W - s;
                }
            }
        }

        int h_count[][] = new int[H][W];
        for (int j=0;j<W;j++) {
            int s = 0;
            for (int i=0;i<H;i++) {
                if (map[i][j] == 1) {
                    for (int k=s;k<i;k++) {
                        h_count[k][j] = i - s;
                    }
                    s = i+1;
                } else {

                }
            }
            {
                for (int k=s;k<H;k++) {
                    h_count[k][j] = H - s;
                }
            }
        }

        int ans = 0;
        for (int i=0;i<H;i++) {
            for (int j=0;j<W;j++) {
                ans = Math.max(ans, w_count[i][j] + h_count[i][j] - 1);
            }
        }

        System.out.println(ans);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}

Measured memory_bytes: 73096
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;

long long gcd(long long x,long long y){
    return y?gcd(y,x%y):x;
}
int main(){

    long long a,b;
    cin >> a >> b;
    long long n=gcd(a,b);
    vector<pair<long long,long long>> num;
    for(long long i=2;i*i<=n;i++){
        if(n%i) continue;
        int c=0;
        while(n%i == 0){
            c++;
            n /= i;
        }
        num.push_back(make_pair(n,c));
    }
    if(n != 1) num.push_back(make_pair(n,1));
    cout << num.size()+1 <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
std::map<string, int> num;
long long int n;
void dfs(string s) {
    if (num[s]==1) {
        return;
    } else if (stoll(s)>n) {
        return;
    } else {
        num.emplace(s,1);
        for (int i=3;i<=7;i+=2) {
            dfs(s+to_string(i));
        }
    }
}

int main(void){
    cin>>n;
    dfs("0");
    int cnt=0;
    for (auto itr=num.begin();itr!=num.end();itr++) {
        string tmp=itr->first;
        if (stoll(tmp)<=n) {
            int count3=0,count5=0,count7=0;
            for (int j=0;j<tmp.size();j++) {
                if (tmp[j]=='3') {
                    count3=1;
                } else if (tmp[j]=='5') {
                    count5=1;
                } else if (tmp[j]=='7') {
                    count7=1;
                }
                if (count3==1&&count5==1&&count7==1) {
                    cnt++;
                    break;
                }
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 9984
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  string s;
  cin >> N >> s;

  int b = 0;
  for (int i = 0; i < N; i++) {
    if (s[i] == '#') b++;
  }

  int cont = 0, w = N - b;
  int ans = min(b, w);
  for (int i = 0; i < N; i++) {
    if (s[i] == '#') {
      cont++;
    } else {
      w--;
    }
    ans = min(ans, cont + w);
  }

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


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

int main(){
    long long X, Y;cin >> X >> Y;
    int i = 1;
    for (;;) {
        if (X > Y) {
            i --;
            break;
        }
        X *= 2;
        i ++;
    }

    cout << i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

int main() {

	int n;
	cin >> n;
	vector<ll> h(n);
	rep(i, n) cin >> h[i];

	bool can = true;
	/*
	rep(i, n - 1) { // 自分を下げる
		if (h[i] > h[i + 1]) {
			h[i]--;
			if (i != 0) {
				if (h[i] < h[i - 1]) {
					can = false;
					break;
				}
			}
		}
		if (h[i] > h[i + 1]) {
			can = false;
			break;
		}
	}
	if(n != 1)
		if (h[n - 2] > h[n - 1]) can = false;

	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
	*/

	// 2以上差がついた奴はだめ
	ll ma = 0;
	rep(i, n) {
		if (h[i] < ma - 1) {
			can = false;
			break;
		}
		ma = max(ma, h[i]);
	}

	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 1024
def solve(N):
  ans = []
  if N % 2 == 1:
    ans = solve(N - 1)
    for i in range(1, N):
      ans.append('{} {}'.format(i, N))
  else:
    for i in range(1, N + 1):
      for j in range(i + 1, N + 1):
        if j == N - i + 1: continue
        ans.append('{} {}'.format(i, j))
  return ans

ans = solve(int(input()))
print(len(ans))
[print(a) for a in ans]

Measured memory_bytes: 3592
N = int(input())
A = tuple(map(int, input().split()))

MOD = 10 ** 9 + 7
cnt = [0] * 61

for a in A:
  for i in range(61):
    cnt[i] += 1 if (a >> i) & 1 else 0

answer = 0
for i in range(61):
  answer = (answer + (2 ** i * cnt[i] * (N - cnt[i]))) % MOD
print(answer)

Measured memory_bytes: 122936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int A = 2e5 + 2;
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n, a[3][3];
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];
    cin >> n;
    bool mark[3][3] = {};
    while(n--) {
        int x;
        cin >> x;
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                if (x == a[i][j]) 
                    mark[i][j] = 1;
    }
    bool done = ((mark[0][0] && mark[1][1] && mark[2][2]) || (mark[0][2] && mark[1][1] && mark[2][0]));
    for (int i = 0; i < 3; i++) {
        int cnt = 0;
        for (int j = 0; j < 3; j++)
            if (mark[i][j]) 
                cnt++;
        if (cnt == 3) done = 1;
    }
    for (int j = 0; j < 3; j++) {
        int cnt = 0;
        for (int i = 0; i < 3; i++)
            if (mark[i][j]) 
                cnt++;
        if (cnt == 3) done = 1;
    }
    cout << (done ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 3604
using System;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		var I = G;
		int H = I[0], W = I[1], K = I[2] - 1;
		if (W == 1) { WriteLine(1); return; }
		var fib = new int[W + 1];
		fib[1] = fib[2] = 1;
		for (var n = 3; n <= W; n++) fib[n] = (fib[n - 1] + fib[n - 2]) % MOD;
		var M = new Matrix(W);
		for (var i = 0; i < W; i++) M[i, i] = fib[i + 1] * fib[W - i] % MOD;
		for (var i = 0; i < W - 1; i++) M[i, i + 1] = M[i + 1, i] = fib[i + 1] * fib[W - i - 1] % MOD;
		WriteLine(M.Pow(H)[0, K]);
	}
}
class Matrix
{
	const long MOD = K.MOD;
	public readonly int Size;
	readonly long[,] a;
	public long this[int r, int c] { get { return a[r, c]; } set { a[r, c] = value; } }
	public Matrix(int s) { Size = s; a = new long[s, s]; }
	public Matrix(int s, Func<int, int, long> f) : this(s) { for (var i = 0; i < s; i++) for (var j = 0; j < s; j++) a[i, j] = f(i, j); }
	public static Matrix operator *(Matrix p, Matrix q)
		=> new Matrix(p.Size, (i, j) => { var sum = 0L; for (var k = 0; k < p.Size; k++) sum = (sum + p.a[i, k] * q.a[k, j] % MOD) % MOD; return sum; });
	public static Matrix One(int size) => new Matrix(size, (i, j) => i == j ? 1 : 0);
	public Matrix Pow(long n)
	{
		var p = One(Size);
		var x = this;
		while (n > 0)
		{
			if ((n & 1) == 1) p *= x;
			n >>= 1;
			x *= x;
		}
		return p;
	}
}

Measured memory_bytes: 13396
#include<cstdio>
const int MaxN=100010;
int N,fa[MaxN],fc[MaxN],siz[MaxN],gs[2],gc;
struct edge{int to,c;edge*next;}E[MaxN*2],*ne=E,*fir[MaxN];
void link(int a,int b,int c){*ne=(edge){b,c,fir[a]};fir[a]=ne++;}
int min(int a,int b){return a<b?a:b;}
void dfs(int i){
	siz[i]=1;
	bool ig=1;
	for(edge*e=fir[i];e;e=e->next)if(e->to!=fa[i]){
		fa[e->to]=i;
		fc[e->to]=e->c;
		dfs(e->to);
		if(siz[e->to]>N/2)ig=0;
		siz[i]+=siz[e->to];
	}
	if(N-siz[i]>N/2)ig=0;
	if(ig)gs[gc++]=i;
}
int main(){
	scanf("%d",&N);
	for(int i=1,a,b,c;i<N;i++){
		scanf("%d%d%d",&a,&b,&c);
		link(a,b,c);
		link(b,a,c);
	}
	dfs(1);
	long long sum=0,mv=1<<30;
	for(int i=2;i<=N;i++)sum+=2ll*fc[i]*min(siz[i],N-siz[i]);
	if(gc==2)mv=fa[*gs]==gs[1]?fc[*gs]:fc[gs[1]];
	else for(edge*e=fir[*gs];e;e=e->next)mv=min(mv,e->c);
	printf("%lld\n",sum-mv);
}

Measured memory_bytes: 9216
n = int(input())
a=0
b=0

if n % 9 == 0 and (n/9) <= 9:
   print("Yes")
elif n % 8 == 0and (n/8) <= 9:
   print("Yes")
elif n % 7 == 0and (n/7) <= 9:
   print("Yes")
elif n % 6 == 0and (n/6) <= 9:
   print("Yes")
elif n % 5 == 0and (n/5) <= 9:
   print("Yes")
elif n % 4 == 0and (n/4) <= 9:
   print("Yes")
elif n % 3 == 0and (n/3) <= 9:
   print("Yes")
elif n % 2 == 0and (n/2) <= 9:
   print("Yes")
elif n % 1 == 0and (n/1) <= 9:
   print("Yes")   
else:
   print("No")

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#define mod 1000000007

int pri[101000], tot = 0; bool used[101000];
long long fac[101000], inv[101000];

void init()
{
	for(int i = 2; i <= 100000; i++)
	{
		if(!used[i]) pri[++tot] = i;
		for(int j = 1; j <= tot && i * pri[j] <= 100000; j++)
		{
			used[i * pri[j]] = 1;
			if(i % pri[j] == 0) break;
		}
	}
}

long long C(int a, int b) {return fac[a] * inv[b] % mod * inv[a - b] % mod;}

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	fac[0] = inv[0] = inv[1] = 1;
	for(int i = 1; i <= 100500; i++) fac[i] = fac[i - 1] * i % mod;
	for(int i = 2; i <= 100500; i++) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	for(int i = 1; i <= 100500; i++) inv[i] = inv[i] * inv[i - 1] % mod;
	long long ans = 1;
	init();
	for(int i = 1; pri[i] * pri[i] <= m; i++)
	{
		int s = 0;
		while(m % pri[i] == 0) {s++; m /= pri[i];}
		ans = ans * C(n + s - 1, n - 1) % mod;
	}
	if(m != 1) ans = ans * n % mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1920
fn main() {
    let (n,m,k) = {
        let v: Vec<usize> = read_vec();
        (v[0], v[1], v[2])
    };
    let fact = |n| (2..n+1).fold(F(1), |f, a| f * F(a as u64));
    let comb = fact(n*m-2) / fact(n*m-k) / fact(k-2);
    let solve = |n, m| {
        let mut res = F(0);
        let (h, w) = (F(n as u64), F(m as u64));
        for d in 1..n {
            let d = F(d as u64);
            res += d*(h-d);
        }
        res * comb * w * w
    };
    println!("{}", solve(n,m)+solve(m,n));
}
fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_owned()
}

fn read<T: std::str::FromStr>() -> T{
    get_line().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T>{
    get_line().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_pair<T: std::str::FromStr + Copy>() -> (T,T){
    let v:Vec<T> = read_vec(); (v[0], v[1])
}

#[derive(Copy, Clone)]
struct F(u64);
const MOD:u64 = 1000000007;

impl F {
    pub fn new(n: i32) -> Self { F((MOD as i32 + n)as u64%MOD) }
    pub fn pow(self, mut exp: u32) -> Self {
        let mut base = self.0;
        let mut acc = 1;
        while exp > 1 {
            if (exp & 1) == 1 { acc *= base; acc %= MOD; }
            exp /= 2; base *= base; base %= MOD;
        }
        if exp == 1 { acc *= base; acc %= MOD; }
        F(acc)
    }
}
impl std::cmp::PartialEq for F {
    fn eq(&self, rhs: &Self) -> bool {self.0 == rhs.0}
}
impl std::fmt::Display for F {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}

use std::ops::*;
impl Mul for F {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self {F((self.0 * rhs.0)%MOD)}
}
impl MulAssign for F {
    fn mul_assign(&mut self, rhs: Self) {*self = F((self.0 * rhs.0)%MOD)}
}
impl Add for F {
    type Output = Self;
    fn add(self, rhs: Self) -> Self {F((self.0 + rhs.0)%MOD)}
}
impl AddAssign for F {
    fn add_assign(&mut self, rhs: Self) {*self = F((self.0 + rhs.0)%MOD)}
}
impl Neg for F {
    type Output = Self;
    fn neg(self) -> Self {if self.0==0 {F(0)} else {F(MOD-self.0)}}
}
impl Sub for F {
    type Output = Self;
    fn sub(self, rhs: Self) -> Self {F((self.0 - rhs.0 + MOD)%MOD)}
}
impl SubAssign for F {
    fn sub_assign(&mut self, rhs: Self) {*self = F((self.0 - rhs.0 + MOD)%MOD)}
}
impl Div for F {
    type Output = Self;
    fn div(self, rhs: Self) -> Self {F(self.0 * rhs.pow(MOD as u32-2).0 %MOD)}
}
impl DivAssign for F {
    fn div_assign(&mut self, rhs: Self) {*self = F(self.0 * rhs.pow(MOD as u32-2).0 %MOD)}
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll X, K, D; cin >> X >> K >> D;
    X = abs(X);
    if( (__uint128_t)D * (__uint128_t)K <= X ){
        cout << X - D*K << endl;
        return 0;
    }
    ll num = X / D;
    X -= num*D;
    K -= num;
    K%=2;
    if(K == 0) cout << X << endl;
    else cout << abs(X-D) << endl;

}

Measured memory_bytes: 3584
#include <stdio.h>

int main() {
  long a, d, n;
  long i, j;
  int pri[1000000] = {};
  pri[2] = 1;
  pri[3] = 1;

  for(i = 2; i < 1000000; i++)
    pri[i] = 1;
  for(i = 2; i * i < 1000000; i++) {
    if(pri[i] == 1) {
      for(j = (i * 2); j < 1000000; j+=i){
        pri[j] = 0;
      }
    }
  }

  while(1) {
    scanf("%ld %ld %ld", &a, &d, &n);
    if(a > 9307 || d > 346 || n > 210)
     scanf("%ld %ld %ld", &a, &d, &n);
    else if(a == 0 && d == 0 && n == 0)
      break;
    i = 0;

    do{
      if(pri[a] == 1){
        i++;
      }
      if(i < n)
        a += d;
    } while (i < n);

    printf("%ld\n", a);
  }
  return 0;
}

Measured memory_bytes: 4512
k = int(input())
# if k <= 0 or k >=33:
#     exit()
target = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(target[k-1])

Measured memory_bytes: 3060
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU
int main(){
	int hp,hp_max;
	while(cin>>hp>>hp_max,hp||hp_max){
		int n,m;
		cin>>n>>m;
		vs in(n);
		rep(i,n)cin>>in[i];
		int t;
		cin>>t;
		vi damage(26);
		while(t--){
			char a;int b;
			cin>>a>>b;
			damage[a-'A']=b;
		}
		string s="";
		cin>>t;
		while(t--){
			char a;int b;
			cin>>a>>b;
			rep(i,b)s+=a;
		}
		int P;
		cin>>P;
		vi p(P);
		rep(i,P)cin>>p[i];
		
		int N=1<<P;
		vvi dp(s.size()+1,vi(N,-inf));
		dp[0][0]=hp;
		//RDLU
		int x=0,y=0;
		rep(i,s.size()){
			rep(j,N)if(dp[i][j]!=-inf){
				if(s[i]=='R')t=0;
				if(s[i]=='D')t=1;
				if(s[i]=='L')t=2;
				if(s[i]=='U')t=3;
				int nx=x+dx[t],ny=y+dy[t];
				int now=dp[i][j];
				rep(k,P)if((j&1<<k)==0){
					cmax(dp[i][j|1<<k],min(hp_max,now+p[k]));
				}
				now-=damage[in[nx][ny]-'A'];
				if(now>0)cmax(dp[i+1][j],now);
			}
			x+=dx[t];
			y+=dy[t];
		}		
		bool h=false;
		rep(i,N)h|=dp[s.size()][i]!=-inf;
		if(h)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}








Measured memory_bytes: 18900
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
import math
n, k = getList()
pn = 1 / n

ans = 0
for i in range(1,n+1):
    if i >= k:
        ans += 1
    else:
        kaisu = math.ceil(math.log2(k/i))
        ans += 0.5 ** kaisu
    #print(ans, kaisu)#

print(ans * pn)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();

        int ways = (int) (Math.pow((K-1), N-1)* K);

        System.out.println(ways);
    }
}

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

int main() {
    string s;
    cin >> s;
    stack<char> st;
    for (char c: s) {
        if (!st.empty() && st.top() == 'S' && c == 'T')
            st.pop();
        else
            st.push(c);
    }
    cout << st.size() << endl;
    return 0;
}



Measured memory_bytes: 644
#include<stdio.h>
int main(){
  int n, d, ans=1, i, temp=1;
  scanf("%d%d", &n, &d);
  temp=2*d+1;
  for(;;){
    if(n-ans*2*d-ans*1>0){
      ans++;
    }else{
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

N=int(input())
S=[0 for i in range(0,N)]
string=''
for i in range(0,N):
    string+='a'
print(string)
digit=N-1
while True:
    if digit!=0:
        if S[digit]==max(S[0:digit])+1:
            digit-=1
        else:
            S[digit]+=1
            for j in range(digit+1,N):
                S[j]=0
            digit=N-1
            if S[0]==1:
                break
            string=[0 for i in range(0,N)]
            for i in range(0,N):
                string[i]=alphabetlist[S[i]]
            print(''.join(string))
    else:
        break

Measured memory_bytes: 50520
N = int(input())
s = []
for _ in range(N):
    s.append(input())

M = int(input())
t = []
for _ in range(M):
    t.append(input())


ans = []
for i in s:
    plus = s.count(i)
    minus = t.count(i)

    score = (plus - minus)
    ans.append(score)

if max(ans) < 0:
    print(0)
else:
    print(max(ans))

Measured memory_bytes: 3188
///17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

#define n_l '\n'
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

void IO() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s, t; cin >> s >> t;
    int cnt = 0;
    int n = s.size();
    for (int i = 0; i < n; i++) {
    	if (s[i] != t[i]) {
    		cnt++;
    	}
    }
    cout << cnt << endl;
    

    return 0;
}


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






Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int x,k,d;
	cin >> x >> k >> d;
	int ans = abs(x);
	int dis = ans;
	int steps = ans / d;
	ans = abs(ans  - min(k,steps) * d);
	 k -= min(k,steps);
	if((k) % 2 == 1) ans = abs(ans - d);
	cout << ans;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b) {
	if (b == 0)return a;
	return gcd(b,a%b);
}
long long lcm(long long a,long long b) {
	return a/gcd(a,b)*b;
}
int main()
{
    int n;
	long long x,ans;
    cin>>n;
    cin>>x;
    ans = x;
    for (int i = 2;i<=n;i++) {
		cin>>x;
		ans = lcm(x,ans);
	}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
    let n = read();

    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    if n == "a" || n == "i" || n == "u" || n == "e" || n == "o" {
        out.write(b"vowel");
    } else {
        out.write(b"consonant");
    }
}
// fn read_v() -> String {
//     let s = stdin();
//     let b = s.bytes()
//         .map(|c| c.unwrap() as char)
//         .take_while(|c| !c.is_whitespace())
//         .collect::<String>();
//     b
// }

// fn read_t() -> (u32, u32) {
//     let mut s = String::new();
//     stdin().read_line(&mut s).expect("failed read_t");
//     let mut i = s.split_whitespace().map(|c| c.parse().ok().unwrap());
//     (i.next().unwrap(), i.next().unwrap())
// }

fn read() -> String {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    b
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl << flush
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

map<char, char> mp = {
    {'A', 'T'},
    {'T', 'A'},
    {'G', 'C'},
    {'C', 'G'},
};

int main() {
    init_io();
    char b;
    cin >> b;
    cout << mp[b] << endl;
    return 0;
}


Measured memory_bytes: 256
n,m,k=map(int,input().split())
A=[]
for i in range(n):
    row=list(map(int,input().split()))
    A.append(row)
mn=10**9
for i in range(int(2**n)):
    x=bin(i)[2:]
    x=("0"*(n-len(x)))+x
    curr=[0 for ptr in range(m)]
    s=0
    for j in range(n):
        if(x[j]=="1"):
            s+=A[j][0]
            curr=[curr[ptr]+A[j][ptr+1] for ptr in range(m) ]

    curr=[curr[ptr]>=k for ptr in range(m)]
    curr=list(set(curr))
    if(curr==[True]):
        if(s<mn):
            mn=s
if(mn==10**9):
    print(-1)
else:
    print(mn)

Measured memory_bytes: 9256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
#include <random>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

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

//********************************template END****************************************//

#define debug(x) cerr << #x << "=" << x << endl;

void solve(void){

	int N;
	cin >> N;
	debug(N);
	cout << (N & 1 ? N*2 : N) << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

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

    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) { cin >> A[i]; }

    rep(i, N) { cin >> B[i]; }

    ll diff_sum = 0;
    ll diff_b = 0, diff_a = 0;
    rep(i, N) {
        diff_sum += (B[i] - A[i]);
        if (B[i] > A[i])
            diff_b += (B[i] - A[i]) / 2;
        else
            diff_a += (A[i] - B[i]);
    }

    if (diff_sum < 0) {
        cout << "No" << endl;
        return 0;
    }

    if (diff_b >= diff_a) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    set<int32> s;
    int32 ans = 0;
    REP(i,n){
        int32 a;
        cin >> a;
        if(s.count(a) == 1){
            s.erase(a);
            ans--;
        }else{
            s.insert(a);
            ans++;
        }
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 4992
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const ll inf = 9e18;
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

class debug
{
public:
    typedef long long ll;
    template<typename T> void vd(vector<T> vec);
    template<typename T> void vd2(vector<vector<T>> vec);
    template<typename T> void ad(T *arr, ll n);
    template<typename T, size_t N> void ad2(T (&arr)[N], ll n);
    template<typename T> void md(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vd(vector<T> vec)
{
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T> void debug::vd2(vector<vector<T>> vec)
{
    for(auto vv : vec) for(auto vvv : vv) cout << vvv << " ";
    cout << endl;
}

template<typename T> void debug::ad(T *arr, ll n)
{
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T, size_t N> void debug::ad2(T (&arr)[N], ll n)
{
    for(int i=0; i<=N; i++) for(int j=0; j<=n; j++) cout << arr[i][j] << " ";
    cout << endl;
}

template<typename T> void debug::md(T mp)
{
    cout << "key : value" << endl;
    for(auto const& m : mp) cout << m.first << " : " << m.second << endl;
    cout << endl;
}
debug debug;

double dp[3000][3000];

class ICoins {
public:
	void solve(std::istream& in, std::ostream& out)
	{
        int N;
        in >> N;
        vector<double> P(N);
        for (int i = 0; i < N; i++) {
            in >> P[i];
        }

        vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
        dp[0][0] = 1.0;

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < i + 1; j++) {
                dp[i + 1][j + 1] += dp[i][j] * P[i];
                dp[i + 1][j] += dp[i][j] * (1 - P[i]);
            }
        }

        double res = 0.0;
        for (int i = (N + 1) / 2; i < N + 1; i++) {
            res += dp[N][i];
        }
        out << fixed << setprecision(10) << res << '\n';
	}
};


int main() {
	ICoins solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 70656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.HashMap;

public class Main{
	
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String[] args) throws IOException{
		
		String words[] = br.readLine().split(" ");
		Map<String,Integer> dict = new HashMap<String,Integer>();
		String longest = "";
		
		for(int i = 0;i<words.length;i++){
			if(dict.containsKey(words[i])){
				dict.put(words[i],dict.get(words[i])+1);
			}else{
				dict.put(words[i],1);
			}
			if(words[i].length()>longest.length()){
				longest = words[i];
			}
		}
		
		int max = -1;
		String dict_max = "";
		
		for(String key : dict.keySet()){
			if(max<dict.get(key)){
				max = dict.get(key);
				dict_max = key;
			}
		}
		
		System.out.println(dict_max + " " + longest);
	}
}

Measured memory_bytes: 24180
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int x,a,b;
    cin >> x >> a >> b;
    int n;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        if (s=="nobiro") x+=a;
        else if (s=="tidime") x+=b;
        else x=0;
        if (x<=0) x=0;
    }
    cout << x << endl;
}



Measured memory_bytes: 3208
N=int(input())
D=[{} for _ in range(N+1)]

for i in range(1,N+1):
    A=int(input())
    for k in range(A):
        p,x=map(int,input().split())
        D[i][p]=x

Max=0
for x in range(2**N):
    y=x

    B=["*"]*(N+1)
    for i in range(N):
        B[i+1]=y%2
        y>>=1

    Flag=True
    for i in range(1,N+1):
        if B[i]==1:
            for k in D[i]:
                Flag&=(B[k]==D[i][k])

    if Flag:
        Max=max(Max,B.count(1))

print(Max)


Measured memory_bytes: 73884
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define ll long long
using namespace std;
int main(){
     string S;
     cin >> S;
     if(S[1] == 'R'){
          cout << "ABC" << endl;
     }else{
          cout << "ARC" << endl;
     }
     return 0;
}

Measured memory_bytes: 3628
/*  -*- coding: utf-8 -*-
 *
 * 3014.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int M = 12;
const int D = 30;
const int Y = M * D;

/* typedef */

/* global variables */

int cs[Y];

/* subroutines */

inline void setmin(int &a, int b) { if (a > b) a = b; }
inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

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

  while (n--) {
    int m, d, v, s;
    scanf("%d%d%d%d", &m, &d, &v, &s);
    m--, d--;
    int st = m * D + d, et = st + v - 1;

    for (int i = 1; i < s; i++) {
      setmax(cs[(st - i + Y) % Y], s - i);
      setmax(cs[(et + i) % Y], s - i);
    }
    for (int i = 0; i < v; i++)
      setmax(cs[(st + i) % Y], s);
  }

  int minc = cs[0];
  for (int i = 1; i < Y; i++) setmin(minc, cs[i]);

  printf("%d\n", minc);
  return 0;
}



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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int k, a, b; cin >> k >> a >> b;
    int c = k;
    while (1) {
        if (k > b) {
            k -= c;
            break;
        } else {
            k += c;
        }
    }

    (k >= a && k <= b) ? cout << "OK\n" : cout << "NG\n";
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    // cin >> t;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long h = sc.nextLong();
		int[] a = new int[n], b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		int max = Arrays.stream(a).max().getAsInt();
		Arrays.sort(b);
		long ans = 0L;
		for(int i = n-1; i >= 0; i--) {
			if(b[i] >= max) {
				h -= b[i];
				ans++;
				if(h <= 0) {
					System.out.println(ans);
					return;
				}
			} else {
				break;
			}
		}
		System.out.println(ans+(int)Math.ceil((double)h/(double)max));
	}
}

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

using namespace std;

int X, Y;
int mod = 1e9 + 7;

long long mod_inv(long long a) {
  long long n = mod - 2;
  long long res = 1;
  while (n > 0) {
    if (n & 1) {
      res *= a;
      res %= mod;
    }
    a *= a;
    a %= mod;
    n >>= 1;
  }
  return res;
}

int main() {
  cin >> X >> Y;
  long long x = 2 * Y - X;
  long long y = 2 * X - Y;
  if (x < 0 or y < 0 or x % 3 != 0 or y % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  x /= 3;
  y /= 3;
  long long ans = 1;
  for (int i = 2; i <= x + y; i++) {
    ans = ans * i % mod;
  }
  for (int i = 2; i <= x; i++) {
    ans = ans * mod_inv(i) % mod;
  }
  for (int i = 2; i <= y; i++) {
    ans = ans * mod_inv(i) % mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
cnt = [0]*4
for i in range(3):
    a,b = map(int,input().split())
    a -= 1; b -= 1
    cnt[a] += 1
    cnt[b] += 1
ans = "YES"
for e in cnt:
    if e >= 3:
        ans = "NO"
        break
print(ans)

Measured memory_bytes: 3060
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

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

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int power(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
vector<vector<int> > es;
int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  es = vector<vector<int> >(n);
  for (int i = 0; i < n - 1; ++i) {
    int s, t;
    scanf("%d%d", &s, &t);
    --s, --t;
    es[s].pb(t), es[t].pb(s);
  }
  return 1;
}

int pr[maxn];
pair<int, int> tosort[maxn];
int used[maxn];

void dfs(int v, int p) {
  pr[v] = p;
  for (int u : es[v]) {
    if (u == p) {
      continue;
    }
    tosort[u] = mp(tosort[v].first + 1, u);
    dfs(u, v);
  }
}

void solve() {
  tosort[0] = mp(0, 0);
  dfs(0, -1);
  sort(tosort, tosort + n);

  for (int i = 0; i < n; ++i) {
    used[i] = 0;
  }

  for (int iter = n - 1; iter >= 0; --iter) {
    int v = tosort[iter].second;
    if (used[v]) {
      continue;
    }
    if (pr[v] == -1 || used[pr[v]]) {
      printf("First\n");
      return;
    }
    used[v] = used[pr[v]] = 1;
  }

  printf("Second\n");
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 7424
# http://drken1215.hatenablog.com/entry/2019/03/21/234900
# 写経

def main():
    from bisect import bisect_left
    import sys

    input = sys.stdin.readline

    n, m = map(int, input().split())
    PY = []
    e = [[] for _ in range(n + 1)]
    for _ in range(m):
        _p, _y = map(int, input().split())
        e[_p].append(_y)
        PY.append((_p, _y))

    for idx in range(n + 1):
        e[idx] = tuple(sorted(set(e[idx])))

    for p, y in PY:
        id = bisect_left(e[p], y)
        print('{:06d}{:06d}'.format(p, id + 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 30604
#include <bits/stdc++.h>
using namespace std;
int a[4];
int main()
{
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	sort(a,a+4);
	if (a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9) puts("YES"); else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (int argc, char* argv[]) {
  int a, b;
  scanf("%d %d", &a, &b);

  int x = a + b, y = a - b, z = a * b;
  if (x >= y && x >= z) printf("%d\n", x);
  else if (y >= x && y >= z) printf("%d\n", y);
  else if (z >= x && z >= y) printf("%d\n", z);

  return 0;
}


Measured memory_bytes: 128