akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int a[3],k;
    for(int i=0;i<3;i++)cin>>a[i];
    cin>>k;
    sort(a,a+3);
    int ans=a[0]+a[1]+a[2]*pow(2,k);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4128
import bisect
from itertools import *
n=range(50001);a=list(n);a[1]=0
for i in range(2,224):a[i*2::i]=[0]*len(a[i*2::i])
p=list(compress(n,a))
for x in iter(input,'0'):x=int(x);print(sum(1 for d in p[:bisect.bisect(p,x//2)]if a[x-d]))


Measured memory_bytes: 7796
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  auto s = cin.next!(dchar[]);
  int res;
  foreach (c; s) {
    if (c == '1') ++res;
  }
  writeln(res);
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

// const int64 mod = 1e9+7;
int64 N, mod;

int64 fact[3030], inv[3030];
int64 dp[3030][3030] = {};

int64 mpow(int64 a, int64 b, int64 m){
	if(b == 0) return 1;
	if(b%2) return a*mpow(a, b-1, m)%m;
	int64 ret = mpow(a, b/2, m);
	return ret*ret%m;
}

int64 comb(int64 a, int64 b){
	return fact[a]*inv[b]%mod*inv[a-b]%mod;
}

void init(){
	fact[0] = 1;
	REP(i, 3029) fact[i+1] = (fact[i]*(i+1))%mod;
	REP(i, 3030) inv[i] = mpow(fact[i], mod-2, mod);
	REP(i, 3030) dp[i][0] = 1;
	FOR(i, 1, 3030){
		FOR(j, 1, 3030){
			dp[i][j] = dp[i-1][j]*(j+1)+dp[i-1][j-1];
			dp[i][j] %= mod;
		}
	}
}

int64 f(int64 x){
	int64 ret = 0;
	int64 p = mpow(2, (N-x), mod);
	int64 pa = 1;
	int64 pb = mpow(2, mpow(2, N-x, mod-1), mod);
	FOR(i, 0, x+1){
		ret += dp[x][i]*pa%mod*pb%mod;
		ret %= mod;
		pa = pa*p%mod;
	}
	return ret;
}

int main(void){
	cin >> N >> mod;
	init();

	int64 res = 0;
	REP(i, N+1){
		if(i%2) res = (res-comb(N, i)*f(i)%mod+mod)%mod;
		else res = (res+f(i)*comb(N, i)%mod)%mod;
	}
	cout << res << endl;
}

Measured memory_bytes: 71936
#include <iostream>
using namespace std;
#define CIN(n) int n; cin>>(n);
int main()
{
	unsigned int n;
	cin >> n;
	unsigned int k;
	cin >> k;
	int a[100005];
	int p = 0;
	for (int i = 1; i < n + 1; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n + 1; i++) {
		if (a[i] == 1)p = i;
	}
	int t = 0;
	t = (p - 1) /( k - 1);
	if ((p - 1) % (k - 1) == 0); else t++;
	int q = 0;
	q = t * (k - 1) - (p - 1);
	p = p + q;
	if (p > n - 1)cout << t; else {
		int y = 0;
		y = (n - p) / (k - 1);
		if ((n - p) % (k - 1) == 0); else y++;

		cout << t + y;
	}

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>

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

int main () {
  int r, g, b;
  std::cin >> r >> g >> b;
  int n = r * 100 + g * 10 + b;
  std::cout << (n & 1 || n >> 1 & 1 ? "NO" : "YES") << std::endl;
  return 0;
}

Measured memory_bytes: 3548
program ABC_048_A_Betweenaandb
   implicit none
   integer(8) a, b, x
   read(*, *) a, b, x
   if(mod(a, x) == 0) then
      write(*, *) (b / x) - (a / x) +1
   else
      write(*, *) (b / x) - (a / x)
   end if
end program ABC_048_A_Betweenaandb

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;
int n;
long long dp[100010];
long long h[100010];
int main() {
   cin >>n;
   for(int i = 0;i<n;i++) cin >> h[i];
   for(int i = 0;i<100010;i++) dp[i] = INF;
   dp[0] = 0;
   for(int i = 0;i<n;i++){
     chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
     if(i > 1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));   
   }
   cout << dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii,
       std.typecons;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int n = cin.next!int;
  int[dchar] c;
  foreach (i; 0 .. n) {
    dchar s = cin.next!dchar;
    c[s]++;
  }
  writeln(c.length == 3 ? "Three" : "Four");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  while(1){
    cin >> H >> W;
    if(H==0&&W==0)break;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(i==0 || i==H-1){
	  cout << '#';
	}
	else{
	  if(j==0 || j==W-1){
	    cout << '#';
	  }
	  else{
	    cout << '.';
	  }
	}
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
import math
N = int(input())
A = list(map(int, input().split()))

is_pairwise = True

def calc_primes(n):
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

primes = calc_primes(int(math.sqrt(10**6)))
used = set()

def factorize(n):
    for prime in primes:
        if n == 1:
            break
        is_used = False
        while n % prime == 0:
            if prime in used:
                return False
            n //= prime
            is_used = True
        if is_used:
            used.add(prime)
    if n > 1:
        if n in used:
            return False
        used.add(n)
    return True

all_gcd = A[0]
for a in A:
    all_gcd = math.gcd(all_gcd, a)
    if is_pairwise:
        if not factorize(a):
            is_pairwise = False

if is_pairwise:
    print('pairwise coprime')
elif all_gcd == 1:
    print('setwise coprime')
else:
    print('not coprime')



Measured memory_bytes: 196808
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = map(int, raw_input().split())
edge = [[False] * N for i in range(N)]

for i in range(M):
    a, b = map(int, raw_input().split())
    a, b = a - 1, b - 1
    edge[a][b] = True
    edge[b][a] = True

def func(num, used):
    if not True in used:
        return 1
    ret = 0
    for i in range(N):
        if used[i] and edge[num][i]:
            used[i] = False
            ret += func(i, used)
            used[i] = True
    return ret

print func(0, [False] + [True] * (N - 1))

Measured memory_bytes: 2812
S=input()
N=len(S)

A=S[:(N-1)//2]
B=S[(N+3)//2-1:]

for i in range(len(S)):
	if S[i]!=S[-(i+1)]:
		print("No")
		exit()
for i in range(len(A)):
	if A[i]!=A[-(i+1)]:
		print("No")
		exit()
for i in range(len(B)):
	if B[i]!=B[-(i+1)]:
		print("No")
		exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> a(n + 1);
  for (int i = 0; i < m; i++) {
    int e;
    cin >> e;
    a[e] = true;
  }
  vector<int> dp(n + 2);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    if (a[i]) dp[i] = 0;
    for (int j = 1; j <= 2; j++) {
      dp[i + j] += dp[i];
      dp[i + j] %= mod;
    }
  }
  cout << dp[n] << endl;
}


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

int main() {
  int N ;
  string S ;
  cin >> N ;
  for (int i = 0 ; i < N ; i++){
    cin >> S ;
    if ( S == "Y" ){
      cout << "Four" << endl;
      break;
    }
    if ( i == N-1 )
      cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N,L;
    cin>>N>>L;
    vector<string> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    sort(S.begin(),S.end());
    for(int i=0;i<N;i++){
        cout<<S[i];
    }
    return 0;
}

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

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let a: usize = sc.read();
    let b: usize = sc.read();

    let ans = a * b;
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2176
def solve(K):
    cur = 0
    tens = 1
    for i in range(1_000_001):
        cur += 7 * tens
        cur %= K
        if cur == 0:
            return i + 1
        tens *= 10
        tens %= K
    else:
        return -1


print(solve(int(input())))


Measured memory_bytes: 9036
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('');
   let len = xs.length;
   let S = '';
   let cnt = 0;
   for(let i=0; i<len; i++){
     S=xs[i]+xs[i+1];
     if(S=='WB'|| S=='BW'){
       cnt +=1;
     }else{
       cnt +=0;
     }
   }
   console.log(cnt);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 14924
S = input()
ACGT = ["A","C","G","T"]

ans = 0 
ans_lis = [0]

for i in range(len(S)):
    if S[i] in ACGT:
        ans = ans + 1 
        if i == (len(S)-1):
            ans_lis.append(ans)
    elif S[i] not in ACGT:
        ans_lis.append(ans)
        ans = 0 

print(max(ans_lis))

Measured memory_bytes: 3060
#include <iostream>

int main(){
    using namespace std;
    int k,x,y,z,s,sum;
    int counter = 0;

    cin >> k >> s;
    for (x = 0; x <= k; x++){
        for (y = 0; y <= k; y++){
            if(s - x - y <= k && s - x - y >= 0){ // for文で回すのが基本だが、それだと計算量が多すぎる。この条件式は少しトリッキーだが理解できるはず
            // if(s - x - y <= k){ 
            // x + y + z = sを満たす
            // z = s - x - y
            // 0 <= z <= k
            // 0 <= s - x- y <= k
                // cout << x << " " << y << endl;
                counter++;
            }
        }
    }
    cout << counter;
}

Measured memory_bytes: 256
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
long long int modp(lld a,lld p,lld n)
{
   lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

//lld fac[100001]; 
/*
void solve2()
{
   lld p=1000000007;
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}
*/
lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,a,b,n2,h,z,c;
queue<lld> q;
lld d,p=1000000000;
//vector< vector <lld > > v(100001);
/*
void bfs(lld x , vector<lld>& d)
{
    d[x]=0;
    q.pu(x);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        l=v[x].size();
        for(i=0;i<l;i++)
        {
            y=v[x][i];
            if(d[y]==INF) 
            {
                d[y] = d[x]+1;
                q.pu(y);
            }       
        }
    }

}
/*

lld DFS(lld a ,lld x)
{
    visited[a] =true;
    sub_size[a]=1;
 //   if(a==x) 
   //     cont[a] =true;
    lld l= v[a].size();
    for(lld i=0;i<l;i++)
    {
        if(visited[v[a][i]] == false)
        {
            sub_size[a]+= DFS(v[a][i],b);
//            if(cont[v[a][i]] ==true ) cont[a]=true;
        }
    }
    return sub_size[a];

}
*/

void solve()
{
    cin>>n>>m;
    vector<vector<lld> > v(n+1);
    vector <lld> w(n+1);
    for(i=1;i<=n;i++)
    {
        cin>>w[i];
    } 
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    ans=0;
    for(i=1;i<=n;i++)
    {
        l=v[i].size();
        x=1;
        for(j=0;j<l;j++)
        {
            if(w[v[i][j]] >= w[i])
            {
                x=0;
                break;
            }
        }
        ans+=x;
    }
    cout<<ans;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
 //   cin>>t;
 //   solve2();
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
        solve();
    //    cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 9804
N = int(input())
count = {}
for i in range(N):
  s = input()[0]
  count[s] = count.get(s, 0) + 1

ans = 0
m = 'MARCH'
for i in range(5):
  mi = m[i]
  for j in range(i+1, 5):
    mj = m[j]
    for k in range(j+1, 5):
      mk = m[k]
      ans += count.get(mi, 0) * count.get(mj, 0) * count.get(mk, 0)

print(ans)

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

int main() {
	int L,A,B,C,D;
	cin >> L >> A >> B >> C >> D;
	int X,Y;
	if(A%C!=0){
		X=A/C+1;
	}
	else X=A/C;
	if(B%D!=0){
		Y=B/D+1;
	}
	else Y=B/D;
	int Z;
	if(X>=Y){
		Z=X;
	}
	else Z=Y;
	cout << L-Z << endl;
	// your code goes here
	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> vec){ return (ll)vec.size(); }
ll sz(string s){ return (ll)s.size(); }

ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }

ll memo[101];

void prime_factorization(ll n){
    ll temp = n;
    for(ll i = 2; i <= n;i++){
        while(temp % i == 0){
            memo[i]++;
            temp /= i;
        }
    }
    return;
}

int main(){
    ll n,ans = 0;
    ll cnt[501] = {};
    cin >> n;
    rep(i,2,n+1) prime_factorization(i);
    rep(i,1,101) cnt[memo[i]]++;
    rrep(i,0,500) cnt[i] += cnt[i+1];

    if(cnt[74] >= 1) ans += cnt[74];
    if(cnt[2] >= 3 && cnt[4] >= 2) ans += (cnt[2]-2)*(cnt[4]-1)*cnt[4]/2;
    if(cnt[4] >= 2 && cnt[14] >= 1) ans += (cnt[4]-1)*cnt[14];
    if(cnt[2] >= 2 && cnt[24] >= 1) ans += (cnt[2]-1)*cnt[24];

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




Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < n; ++i)
#define fore(i, a, b) for(int i = a; i < b; ++i)

#define endl '\n'

const int MOD = 1000000007;
const int MOD2 = 998244353;

int q[200000];
int dst[200000];

pair<int, int> bfs(vector<vector<int>> &ar, int start) {
    memset(dst, 0, ar.size() * sizeof(int));
    int beg = 0;
    int end = 1;
    q[0] = start;
    dst[start] = 1;
    while (beg < end) {
        int cur = q[beg++];
        for (int to: ar[cur]) {
            if (dst[to]) continue;
            dst[to] = dst[cur] + 1;
            q[end++] = to;
        }
    }
    return make_pair(q[end - 1], dst[q[end - 1]]);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> ar(n);
    for (int i = 1; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        ar[a].push_back(b);
        ar[b].push_back(a);
    }
    pair<int, int> r1 = bfs(ar, 0);
    pair<int, int> r2 = bfs(ar, r1.first);
    bool win[200001];
    win[0] = false;
    win[1] = true;
    win[2] = false;
    for (int i = 3; i <= n; ++i) {
        win[i] = !(win[i - 1] && win[i - 2]);
    }
    if (win[r2.second]) {
        cout << "First" << endl;
    }
    else {
        cout << "Second" << endl;
    }
}

Measured memory_bytes: 13684
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

vector<pi> range;

int main(){
  string s,ss="YAKI";
  cin>>s;
  if(s.size()<4){cout<<"No"<<endl;return 0;}
  rep(i,4){
    if(s[i]!=ss[i]){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 1e9 + 1
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

#define MAX_N 100
#define MAX_M 100

int main(){
    double l;
    cin >> l;

    double a, b, c;
    a = l/3, b = l/3, c = l/3;

    printf("%.8f\n", a*b*c);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <sstream>
#include <set>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {

    // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int N, R;
    cin >> N >> R;

    int rate = 0;
    if (N >= 10) {
        rate = R;
    }
    else {
        rate = 100 * (10 - N) + R;
    }
    cout << rate << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())

S=[]
for i in range(n):
    c,p = map(str,input().split())
    S.append( [c,int(p)] )

C=[0]*n
for i in range(n):
    for j in range(n):
        if S[i][0]>S[j][0]:
            C[i]+=1
        elif S[i][0]==S[j][0]:
            if S[i][1]<S[j][1]:
                C[i]+=1

A=[0]*n
for i in range(n):
    print( C.index(i)+1 )



Measured memory_bytes: 9108
from numba import jit
import numpy as np
@jit
def main():
  R,C,K=map(int,input().split())
  scores=np.zeros((R,C),np.int64)
  for _ in range(K): #各マスにアイテム配置
    r,c,v=map(int,input().split())
    scores[r-1][c-1]=v
  dp=np.zeros((R+1,C+1,4),np.int64) #後のために余分に作っておく、scoresの配列は別なのでindexに注意
  for i in range(1,R+1):
    for j in range(1,C+1):
      for k in range(4):
        dp[i][j][k]=max(dp[i][j-1][k],dp[i-1][j][3]) #同じ行ですでに3つ拾ってから次の行にくるのかただ隣のマスに進むか
      for k in range(3,0,-1):
        dp[i][j][k]=max(dp[i][j][k],dp[i][j][k-1]+scores[i-1][j-1]) #そのマスでアイテムを拾うかどうか
  return dp[R][C][3]
print(main())


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

using namespace std;

int main(){
  int N;

  cin>>N;
  int heights[N];
  int cost[N];
  for(int i=0;i<N;i++){
    int h;
    cin>>h;
    heights[i] = h;
    cost[i] = INT_MAX;
  }
cost[0] = 0;
cost[1] = abs(heights[0]-heights[1]);
  for(int j=2;j<N;j++){
    int diff1 = abs(heights[j-1] - heights[j]);
    int diff2 = abs(heights[j-2] - heights[j]);
      cost[j] = min(cost[j-1] + diff1,cost[j-2] + diff2);
  }
  cout<<cost[N-1];
  return 0;
}


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

#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i) cin >> v[i];

    int ans = 0;
    for(int i=0; i<n; ++i) {
        if(v[i]==i+1) {
            if(i!=n-1) {
                int tmp = v[i];
                v[i] = v[i+1];
                v[i+1] = tmp;
            }
            else {
                int tmp = v[i];
                v[i] = v[i-1];
                v[i-1] = tmp;
            }
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b,c;
	cin>>a>>b>>c;
	int f=0,s=0;
	if(a==5)f++;
	else if(a==7)s++;
	if(b==5)f++;
	else if(b==7)s++;
	if(c==5)f++;
	else if(c==7)s++;
	if(f==2&&s==1)cout<<"YES";
	else cout<<"NO";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3600
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 10000000000000010ll
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE ll i=p;i<=n;++i)
#define go(x) for(ll i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE ll i=n;i>=p;--i)
#define vep(p,n,i) for(RE ll i=p;i<n;++i)
#define pii pair<ll,ll>
#define mk make_pair
#define RE register
#define P 1000000007
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define EPS 1e-8
#define sq sqrt
#define S second
#define F first
#define mod 1000000007
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
    RE ll x=0,f=1;RE char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const ll MAXN=200010;
ll n,k,cnt1,cnt2,ww;
ll a[MAXN],b[MAXN],vis[MAXN],c[MAXN];
priority_queue<pii>q;
inline ll cmp(ll x,ll y){return x>y;}
inline ll ksm(ll b,ll p)
{
	ll cnt=1;
	while(p)
	{
		if(p&1)cnt=(ll)cnt*b%mod;
		b=(ll)b*b%mod;p=p>>1;
	}
	return cnt;
}
signed main()
{
	//freopen("1.in","r",stdin);
	get(n);ww=get(k);ll mark=0;
	rep(1,n,i)
	{
		get(c[i]);
		if(c[i])q.push(mk(abs(c[i]),c[i]>0));
		else ++mark;
	}
	if(q.size()<k)puts("0");
	else
	{
		ll ans=1,cnt=1,w1=0,w2=0;
		while(q.size()&&k)
		{
			pii w=q.top();q.pop();
			if(!w.S)cnt=cnt^1,w2=w.F;
			else w1=w.F;
			ans=ans*w.F%mod;
			--k;
		}
		if(cnt)putl(ans);
		else
		{
			ll c1=0,c2=0;
			while(q.size())
			{
				pii w=q.top();q.pop();
				if(!c1&&w.S>0)c1=w.F;
				if(!c2&&!w.S)c2=w.F;
			}
			if((!c2||!w1)&&(!c1||!w2))
			{
				if(mark)puts("0");
				else
				{
					rep(1,n,i)c[i]=abs(c[i]);
					sort(c+1,c+1+n);ans=1;
					rep(1,ww,i)ans=ans*c[i]%mod;
					ans=mod-ans;putl(ans);return 0;
				}
			}
			else
			{
				if(!c1||!w2)
				{
					ans=ans*ksm(w1,mod-2)%mod;
					ans=ans*c2%mod;putl(ans);
					return 0;
				}
				if(!c2||!w1)
				{
					ans=ans*ksm(w2,mod-2)%mod;
					ans=ans*c1%mod;putl(ans);
					return 0;
				}
				if(w1*c1>w2*c2)
				{
					ans=ans*ksm(w2,mod-2)%mod;
					ans=ans*c1%mod;putl(ans);
					return 0;
				}
				else
				{
					ans=ans*ksm(w1,mod-2)%mod;
					ans=ans*c2%mod;putl(ans);
					return 0;
				}
			}
		}
	}
	return 0;
}

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

#define LIMIT 1000000

int main()
{
	bool ptable[LIMIT] = {0};
	int a,d,n;
	
	ptable[0] = 1;
	ptable[1] = 1;
	for(int i = 2 ; i <LIMIT ; i++)
	{
		if( ptable[i] != 0)
			continue;
		else
			for(int j = 2; i*j <LIMIT; j++)
			ptable[i*j] = 1;
	}
	
	
	while( cin >> a >> d >> n, (a||d||n))
	{
		int count = 0;
		for(int i = a; i < LIMIT; i += d)
		{
			if( ptable[i] == 0)
				count++;
				if(count == n)
				{
					cout << i <<endl;
					break;
				}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 998244353;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}

int n;
int a[50], b[50], c[50];

int ma, mb;

int dp[50][500][500];

signed main() {
	
	cin >> n >> ma >> mb;

	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	int ans = INF;
	memset(dp, 0x3f, sizeof(dp));

	/*
	  for(int i = 0; i <= 400; i++) {
	  for(int j = 0; j <= 400; j++) {
	  dp[0][i][j] = 0;
	  }
	  }
	*/

	for(int i = 0; i < n; i++) {
		dp[i][0][0] = 0;
		for(int j = 0; j <= 400; j++) {
			for(int k = 0; k <= 400; k++) {
				dp[i+1][j][k] = dp[i][j][k];
				
				if(j - a[i] >= 0 && k - b[i] >= 0) {
					
					chmin(dp[i+1][j][k], dp[i][j-a[i]][k-b[i]] + c[i]);
					
					if(j * mb == k * ma) { 
						chmin(ans, dp[i+1][j][k]);
					}
				}
			}
		}
	}

	if(ans == INF) ans = -1;
			
	cout << ans << endl;
	
	
    return 0;
}



Measured memory_bytes: 49152
#!/usr/bin/env python
# coding: utf-8

# In[25]:


N = int(input())
H = list(map(int, input().split()))


# In[26]:


ans = 0
x = 0
while x < N-1:
    tmp = 0
    height = H[x]
    for y in range(x+1,N):
        if height >= H[y]:
            tmp += 1
            height = H[y]
        else:
            break
    ans = max(ans, tmp)
    x = y
print(ans)


# In[ ]:






Measured memory_bytes: 14224
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
using namespace std;
int h,w,n,s[N+5];map<int,map<int,int> > p;
int main()
{
	RI i,t,x,y;for(scanf("%d%d%d",&h,&w,&n),i=1;i<=h;++i) s[i]=w+1;
	for(i=1;i<=n;++i) scanf("%d%d",&x,&y),s[x]=min(s[x],y);
	for(t=1,i=2;i<=h;++i) if(s[i]<=t) return printf("%d\n",i-1),0;else s[i]>t+1&&++t;
	return printf("%d\n",h),0;
}

Measured memory_bytes: 4532
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#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; }


int main () {
  int h,w;
  cin >> h >> w;
  std::vector<string> s(h);
  int l[h][w],d[h][w],r[h][w],u[h][w];
  rep(i,h) cin >> s[i];
  rep(i,h) {
    rep(j,w) {
      l[i][j] = 0;
      d[i][j] = 0;
      r[i][j] = 0;
      u[i][j] = 0;
    }
  }
  rep(i,h) {
    rep(j,w) {
      if(s[i][j] == '.') {
        if(j==0) l[i][j] = 1;
        else l[i][j] = l[i][j-1] + 1;
      }

      if(s[i][w-j-1] == '.') {
        if(j== 0) r[i][w-j-1] = 1;
        else r[i][w-j-1] = r[i][w-j] + 1;
      }

    }
  }
  rep(i,w) {
    rep(j,h) {
      if(s[j][i] == '.') {
        if(j==0) u[j][i] = 1;
        else u[j][i] = u[j-1][i] + 1;
      }
      if(s[h-j-1][i] == '.') {
        if(j==0) d[h-j-1][i] = 1;
        else d[h-j-1][i] = d[h-j][i] + 1;
      }
    }
  }
  int result = 0;
  rep(i,h) {
    rep(j,w) {
      result = max(result, l[i][j] + d[i][j] + r[i][j] + u[i][j] - 3);
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 66816
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int[] a = new int[]{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};
        System.out.println(a[k-1]);
        sc.close();

    }

}


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

int main() {
  string s;
  cin >> s;
  long long result = 0, b_stone = 0;
  int i;
  for (i = 0; i < s.length(); i++) {
    if (s.at(i) == 'B') {
      b_stone++;
    } else {
      result += b_stone;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	long long int arr[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	long long int dp[n+1];
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	for(int i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }

    z->parent=y;

    if(y==NIL) root=z;
    else if(z->key<y->key) y->left=z;
    else y->right=z;

}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  
}

void preorder(Node u){
  if(u==NIL) return;

  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25156
while (True):
  st = input()
  if st == ".":
      quit()
  han = []
  ans = "yes"
  for i in st:
    if i == "(":
      han.append("maru")
    elif i == "[":
      han.append("kaku")
    elif i == ")":
      if han == []:
        ans = "no"
        break
      elif han[-1] == "maru":
        del han[-1]
      else:
        ans = "no"
        break
    elif i == "]":
      if han == []:
        ans = "no"
        break
      elif han[-1] == "kaku":
        del han[-1]
      else:
        ans = "no"
        break
  if ans == "no" or han != []:
    print("no")
  else:
    print(ans)



Measured memory_bytes: 5580
#include <iostream>
using namespace std;
typedef long long ll;
ll a,b,n,ans=1e15;
int main(void){
    cin>>n;
    for(ll i=1LL;i*i<=n;i++){
        if(n%i==0){
            ans=min(ans,i+n/i-2);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  int cur = 1;
  while (cur < b){
    cur -= 1;
    cur += a;
    ans++;
  }
  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

6
1 1
7 1
2 2
6 2
1 3
7 3

 */

Measured memory_bytes: 256
// Problem : C - Lamps
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

vector<long> a;
vector<long> segTree;

void allocateTreeMemory() {
    segTree.resize(4 * a.size());
}

void build(long node, long l, long r) {
    if (l == r) segTree[node] = 0;
    else {
        long mid = (l + r) / 2;
        build(2 * node, l, mid);
        build(2 * node + 1, mid + 1, r);
        segTree[node] = 0;
    }
}

void nodeUpdate(long node, long add) {
    segTree[node] += add;
}

void push(long node) {
    nodeUpdate(2 * node, segTree[node]);
    nodeUpdate(2 * node + 1, segTree[node]);
    segTree[node] = 0;
}

void combineChildrenOf(long node) {
    segTree[node] = segTree[2 * node] + segTree[2 * node + 1];
}

void update(long node, long l, long r, long updateL, long updateR, long add) {
    if (updateL <= l && updateR >= r) nodeUpdate(node, add);
    else {
        push(node);
        long mid = (l + r) / 2;
        if (updateR >= mid + 1) update(2 * node + 1, mid + 1, r, updateL, updateR, add);
        if (updateL <= mid) update(2 * node, l, mid, updateL, updateR, add);
        
    }
}

long query(long node, long l, long r, long queryL, long queryR) {
    if (queryL <= l && queryR >= r) return segTree[node];
    else {
        push(node);
        long mid = (l + r) / 2;
        long val = 0;
        if (queryL <= mid) val += query(2 * node, l, mid, queryL, queryR);
        if (queryR >= mid + 1) val += query(2 * node + 1, mid + 1, r, queryL, queryR);
        
        return val;
    }
}


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

    long n, k;
    cin >> n >> k;
    a.resize(n + 1, 0);
    for (long i = 1; i <= n; i++) cin >> a[i];

    
    for (long i = 0; i < k; i++) {
        segTree.clear();
        allocateTreeMemory();
        build(1, 1, n);
        
        bool change = false;
        for (long j = 1; j <= n; j++) {
            update(1, 1, n, max((long)1, j - a[j]), min(n, j + a[j]), 1);
        }
        
        for (long j = 1; j <= n; j++) {
            long temp = query(1, 1, n, j, j);
            if (a[j] != temp) {
                change = true;
                a[j] = temp;
            }
        }
        if (!change) break;
    }
    
    for (long i = 1; i <= n; i++) cout << a[i] << " ";
    cout << "\n";
    
    
    return 0;
}


Measured memory_bytes: 11116
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

static void ABC120D_DecayedBridges();
static void ABC119D_LazyFaith();
static void ABC119A_StillTBD();

#if 1
int main()
{
	//ABC120D_DecayedBridges();
	//ABC119D_LazyFaith();
	ABC119A_StillTBD();

	fflush(stdout);
	return 0;
}
#endif

static void ABC119A_StillTBD()
{
	char szS[16] = { 0 };
	int yy, mm, dd;
	scanf(" %d/%d/%d", &yy, &mm, &dd);

	const char* ans = "Heisei";
	if ((yy > 2019) ||
		((yy == 2019) && (mm > 4))) {
		ans = "TBD";
	}
	printf("%s\n", ans);
}


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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()

ll weight[110],val[110];
ll dp[100010][110];

ll solve(ll cur,ll n,ll sw)
{
	if(sw<=0)return 0;
	if(cur==n)return 1e9;
	if(dp[sw][cur]!=-1)return dp[sw][cur];
	return dp[sw][cur]=min(solve(cur+1,n,sw),weight[cur]+solve(cur+1,n,sw-val[cur]));
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,W,s=0;
	cin>>n>>W;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++)cin>>weight[i]>>val[i],s+=val[i];
	for(ll i=s;i>0;i--)
		if(solve(0,n,i)<=W)
		{
			cout<<i<<"\n";
			return 0;
		}
	cout<<"0\n";
	return 0;
}


Measured memory_bytes: 86272
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(n)]

cnt=0
sum=0

for i in range(m):
  for j in range(n):
    sum+=b[i]*a[j][i]

for j in range(n):
  sum=0
  for i in range(m):
    sum+=b[i]*a[j][i]
  if sum+c>0:
    cnt+=1
  
print(cnt) 

Measured memory_bytes: 9152
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n; cin >> n;
	int A, B; cin >> A >> B;
	int C; cin >> C;

	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	sort( v.begin(), v.end(), greater<int>() );

	int price = A, cal = C;
	for (int i = 0; i < v.size(); ++i) {
		if ((cal+v[i])/(price+B) >= cal/price) {
			price += B, cal += v[i];
		}
	}
	cout << cal/price << endl;
}

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

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> l2r(N + 2, 0);
  vector<int> r2l(N + 2, 0);
  int count = 0;
  for(int i = 1; i <= N; ++i) {
    if(S[i - 1] == 'W') {
      count++;
    }
    l2r[i] = count;
  }
  count = 0;
  for(int i = N; i > 0; --i) {
    if(S[i - 1] == 'E') {
      count++;
    }
    r2l[i] = count;
  }
  int ans = 1e7;
  for(int i = 1; i <= N; ++i) {
    chmin(ans, l2r[i - 1] + r2l[i + 1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3076
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<>();
		int max = 0;
		for (int i = 0; i < h; i++) {
		    char[] arr = sc.next().toCharArray();
		    for (int j = 0; j < w; j++) {
		        if (arr[j] == '.') {
		            continue;
		        }
		        for (int x : list) {
		            int hh = x / w;
		            int ww = x % w;
		            max = Math.max(max, Math.abs(i - hh) + Math.abs(j - ww));
		        }
		        list.add(i * w + j);
		    }
		}
		System.out.println(max);
	}
}



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

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

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

  int r;
  cin >> r;

  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
def main():
    A, B, C, K = map(int, input().split())

    Kk = K - A
    vc = 0
    vb = 0
    if Kk > 0 :
        Kkk = Kk - B
        if Kkk > 0 :
            vc = (-1) * Kkk
        vb = 0
        print(A + vc)
    else :
        print(K)



if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  scanf("%d",&n);
  int a;
  int ans = 0;
  REP(i, n){
    scanf("%d",&a);
    while(a % 2 == 0){
      a /= 2;
      ans++;
    }
  }
  
  printf("%d\n",ans);
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,s,c=0,i;
    cin>>n;
    for(i=1;i<10;i++){
        if(n%i==0)
        m=n/i;
        if(m>=1 && m<=9){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define $$ long long int
#define pb push_back
#define db pop_back
#define q2(n) (n%2)==0
#define vp vector<pair <$$,$$> >
#define vctr vector<$$>
#define in(a) scanf("%lld",&a)
#define out(a) printf("%lld ",a)
#define loop(i,m,p) for ($$ i = m; i < p; i++)
#define loopn(i,m,p) for ($$ i = p-1; i >=m; --i)

using namespace std;


int main()
{
	$$ n;
	cin>>n;
	$$ a[n];
	loop(i,0,n) cin>>a[i];
	$$ cnt=0;
	loop(i,0,n)
	{
		while(q2(a[i])){
			cnt++;
			a[i]/=2;
		}
	}
	cout<<cnt<<endl;

 




return 0;
}


Measured memory_bytes: 384