akhauriyash/Code-Regression huggingface dataset:
extern crate proconio;
use proconio::input;

fn main() {
  input! {
    n: usize,
    m: u32,
    q: u32
  }
  let mut abcd: Vec<(usize, usize, u32, u32)> = vec![];
  let mut aa: Vec<u32> = vec![1];
  
  for _ in 0..q {
    input! {
      a: usize,
      b: usize,
      c: u32,
      d: u32,
    }
    abcd.push((a,b,c,d));
  }
  
  println!("{}", resolve(&mut aa, &abcd, n, m));
}

fn resolve(
  aa: &mut Vec<u32>,
  abcd: &Vec<(usize, usize, u32, u32)>,
  n: usize,
  m: u32
) -> u32 {
  if aa.len() > n + 1 {
    score(aa, abcd)
  } else {
    let mut ans: u32 = 0;
    for k in aa[aa.len()-1]..(m+1) {
      aa.push(k);
      ans = ans.max(resolve(aa, abcd, n, m));
      aa.pop();
  	}
    ans
  }
}

fn score(aa: &Vec<u32>, abcd: &Vec<(usize, usize, u32, u32)>) -> u32 {
  let mut ans: u32 = 0;
  for (a,b,c,d) in abcd {
    if aa[*b] - aa[*a] == *c {
      ans += d;
    }
  }
  ans
}

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

using namespace std;

int n,m,cnt,sum;
string s,a;

int main (){
	cin >> n >> m;
	int mx,mn;
	mx = max(n,m);
	mn = min(n,m);
    for (int i = 1; i <= mx; i++){
        cout << mn;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

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

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  ll N,M;
  cin>>N>>M;
  ll ans=0;

  ll a1 = min(N,M/2);

  ll a2 = (M-a1*2)/4;
  ans=a1+a2;
  cout<<ans<<endl;

  return 0;
}
 


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
string s;
int main(){
    cin >> s;
    int mx = 0;
    int tmp = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G'|| s[i] == 'C'){
            tmp++;
        } else {
            mx = max(mx,tmp);
            tmp = 0;
        }
    }
    mx = max(mx,tmp);
    cout << mx << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  bool flag = true;
  REP(i, N){
    if(S[i] != S[N-1-i]) flag = false;
  }
  REP(i, (N-1)/2){
    if(S[i] != S[(N-1/2)-1-i] || S[N-1-i] != S[(N-1)/2+1+i]) flag = false;
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/*

                                  In the name of Allah, Most Gracious, Most Merciful


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

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********


int main()
{
    IOS;
    ll tc;
    cin>>tc;
    ll coin = ceil(tc/1000.00);

    cout<<coin*1000 - tc<<endl;



return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
 
 
int main(){
    
  int n;
  cin >>n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];

  sort(d.begin(),d.end());
  set<int> s;
  rep(i,n){
    s.insert(d[i]);
  }
  cout << s.size() << endl;
   }

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

#define int long long
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

using namespace std;

int N, C;
int s[100001];
int t[100001];
int c[100001];

int tt[100001];
int sm[100001];

signed main()
{
    cin >> N >> C;
    REP(i, N) cin >> s[i] >> t[i] >> c[i];

    REPS(i, C)
    {
        REP(j, 100001) tt[j] = 0;
        REP(j, N) if (i == c[j]) tt[s[j]-1]++, tt[t[j]]--;
        REPS(j, 100000) tt[j] += tt[j-1];
        REP(j, 100001) if (tt[j] > 0) sm[j]++;
    }

    int ans = 0;
    REP(i, 100000) ans = max(ans, sm[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4096
#D - Dice in Line
#一つのサイコロふったときに出る目の期待値は(面の数+1)/2
n,k=list(map(int,input().split()))
dices = list(map(float,input().split()))
expected = []
answer = 0
i = 0
j = 0
sumOfValue = 0
expected.append(i)
#サイコロの目を期待値に変換して累積和のリスト作る
for eyes in dices:
    i = (eyes+1)/2
    j = j + i
    expected.append(j)
#最大値を求める
for t in range(n-k+1):
    sumOfValue = expected[t+k] - expected[t]
    if(answer <= sumOfValue):
        answer = sumOfValue
print(answer)

Measured memory_bytes: 23588
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int d=sc.nextInt();
		int x=0;
		int y=0;
		int count=0;
		
		for(int i=0;i<n;i++) {
			x=sc.nextInt();
			y=sc.nextInt();
			if(Math.sqrt((Math.pow(x, 2)+Math.pow(y, 2)))<=d) {
				count++;
			}
		}
		System.out.println(count);
		
		sc.close();
	}
}


Measured memory_bytes: 59040
s = input()
t = input()

n = len(s)
nt = len(t)

ans = 1000
for i in range(n - nt + 1):
    string = s[i:i + nt]

    count = 0
    for c1, c2 in zip(string, t):
        if c1!=c2: count += 1
    
    ans = min(ans, count)

print(ans)

Measured memory_bytes: 67824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[100010][21];


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int N;
  cin >> N;
  vector<ll> X(N);
  memset(dp,-1,sizeof(dp));
  

  for (int i=0; i<N; i++) cin >> X[i];
  ll L;
  cin >> L;
  vector<ll> POS(N);
  //vector<ll> NEG(N);

  for (int i=0; i<N-1; i++){
    int left=i+1;
    int right=N;
    while (right-left>1){
      int mid=(left+right)/2;
      if (X[mid]-X[i]<=L) left=mid;
      else right=mid;
    }
    POS[i]=left;
    dp[i][0]=left;
  }
  cerr<<"hi"<<endl;

  for (int j = 1; j <= 20; ++j) {
    for (int i = 0; i < N; ++i) {
      if (dp[i][j-1]>=0 and dp[dp[i][j-1]][j-1]>=0) {
        dp[i][j] = dp[dp[i][j-1]][j-1];
      } 
    }
  }


  cerr<<"123"<<endl;
  //for (int i=0; i<=N; i++) cout<<POS[i]<<" ";
  //cout<<endl;
  //for (int i=0; i<=N; i++) cout<<NEG[i]<<" ";

  int Q;
  int a,b;
  cin >> Q;
  for (int i=0; i<Q; i++){ 
    cin >> a >> b;
    a--;
    b--;
    if (a>b) swap(a,b);
    //cout<<a<<" "<<b<<endl;
    cerr<<"yo"<<endl;
    int ans=0;
    int curr=a;
    for (int i=20; i>=0; i--){
      //cout<<i<< " "<<curr<<endl;
      if (dp[curr][i]>0 and dp[curr][i]<=b){
        ans+=1<<i;
        curr=dp[curr][i];
      }
    }
    if (curr!=b) ans++;



    
    cout<<ans<<endl;




  

  }


  


  

} 


Measured memory_bytes: 10624
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
 
using namespace std;

bool canBeMMYY(int a,int b){
	if( 1 <= a && a <= 12 && 0 <= b && b <= 99) return true;
	return false;
}

bool canBeYYMM(int a,int b){
	if( 1 <= b && b <= 12 && 0 <= a && a <= 99) return true;
	return false;
}


int main()
{
	string s;
	int a,b;
	cin>>s;
	a = stoi(s.substr(0,2),nullptr,10);
	b = stoi(s.substr(2,2),nullptr,10);
	if( canBeYYMM(a,b) == true && canBeMMYY(a,b) == true){
		cout<<"AMBIGUOUS"<<endl;
	}else if(canBeYYMM(a,b) != true && canBeMMYY(a,b) != true){
		cout<<"NA"<<endl;
	}else if( canBeYYMM(a,b) == true && canBeMMYY(a,b) != true){
		cout<<"YYMM"<<endl;
	}else{
		cout<<"MMYY"<<endl;
	}
		
	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    s,t = LI()
    e = collections.defaultdict(list)
    for _ in range(m):
        u,v,d = LI()
        e[u].append((v,d))
        e[v].append((u,d))

    def search(s,t):
        d = collections.defaultdict(lambda: inf)
        dc = collections.defaultdict(int)
        d[s] = 0
        dc[s] = 1
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            v[u] = True

            dc[u] %= mod
            if u == t:
                return (d,dc)

            uc = dc[u]

            for uv, ud in e[u]:
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] < vd:
                    continue
                if d[uv] > vd:
                    d[uv] = vd
                    dc[uv] = uc
                    heapq.heappush(q, (vd, uv))
                elif d[uv] == vd:
                    dc[uv] += uc

        return (d,dc)

    d1,dc1 = search(s,t)
    d2,dc2 = search(t,s)
    rd = d1[t]
    kk = rd / 2.0

    r = dc1[t] ** 2 % mod
    for k in list(d1.keys()):
        t = d1[k]
        c = dc1[k]
        if t > kk:
            continue
        if t == kk:
            if d2[k] == t:
                r -= pow(c,2,mod) * pow(dc2[k],2,mod) % mod
            continue

        for uv, ud in e[k]:
            if d2[uv] >= kk or t + ud + d2[uv] != rd:
                continue
            r -= pow(c,2,mod) * pow(dc2[uv],2,mod) % mod

    return r % mod




print(main())


Measured memory_bytes: 147428
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void lunlun(ll m, ll digits, vector<ll> &ans){
    ans.push_back(m);

    if(digits == 10) return;
 
    for(int i = -1; i <= 1; i++){
        int dif = (m % 10) + i;
        if(0 <= dif && dif <= 9) lunlun(m * 10 + dif, digits + 1, ans);
    }
}

int main(){
    int k; cin >> k;
    vector<ll> ans;
    
    for(int i = 1; i < 10; i++) lunlun(i, 1, ans);
    sort(ans.begin(), ans.end());

    /*for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }*/
    cout << ans[k - 1] << endl;


    /*int n; cin >> n
    string s; cin >> s;
    vector<int> white(n, 0);
    vector<int> white_sum(n + 1);
    vector<int> black(n, 0);
    vector<int> black_sum(n + 1);

    
    rep(i,n){
        if(s[i] == '.')white[i] = 1;
        if(s[i] == '#')black[i] = i;
    }
    _rep(i, 1, n + 1){
        white_sum[i] = white[i - 1] + white_sum[i - 1];
        black_sum[i] = black[i - 1] + black_sum[i - 1];
        cout << white_sum[i] << endl;
    }
    int ans_min = N;
    rep(i,n + 1){
        int ans = white_sum[n] - white_sum[i];
        ans_min = min(ans, ans_min);
    }
    cout << ans_min << endl;*/
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, m, a[N], b[N], pa[N], si[N], ans[N];

ll f(ll p) {
	if (pa[p] == p) return pa[p];
	return pa[p] = f(pa[p]);
}

int main()
{
	ll i, t1, t2;
	cin >> n >> m;
	for (i = 0; i < m; i++) scanf("%lld %lld", &a[i], &b[i]);
	for (i = 1; i <= n; i++) pa[i] = i, si[i] = 1;
	for (i = m - 1; i >= 0; i--) {
		t1 = f(a[i]);
		t2 = f(b[i]);
		if (t1 == t2) continue;
		ans[i] = si[t1] * si[t2];
		si[t1] += si[t2];
		pa[t2] = t1;
	}
	for (i = 0; i < m; i++) {
		printf("%lld\n", ans[i]);
		ans[i + 1] += ans[i];
	}
    return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<climits>
 
 
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF LLONG_MAX
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define ARRAY_MAX 100005


int main(){

    int n;
    cin >> n;
    string s,t,ans;
    cin >> s >> t;
    bool flag = false;
    for(int i = 0;i < s.length();i++){
        //cout << i << endl;
        string s2 = s.substr(i,s.length()-i);
        string t2 = t.substr(0,s.length()-i);
        if(s2 == t2){
            flag = true;
            for(int j = 0;j < n;j++){
                ans.push_back(t[j]);
            }
            break;
        }else{
            ans.push_back(s[i]);
        }
    }
    if(!flag){
        for(int i = 0;i < t.length();i++){
            ans.push_back(t[i]);
        }
    }

    cout << ans.length() << endl;

    return 0;
}

Measured memory_bytes: 256
s_list = list(input())
k = int(input())
s_len_list = []
dbls_len_list = []
dbls_list = s_list * 2
temp_len = 1
ans = 0

for i in range(len(s_list)-1):
    if s_list[i+1] == s_list[i]:
        temp_len += 1
    else:
        s_len_list.append(temp_len)
        temp_len = 1
s_len_list.append(temp_len)

temp_len = 1
for i in range(len(dbls_list)-1):
    if dbls_list[i+1] == dbls_list[i]:
        temp_len += 1
    else:
        dbls_len_list.append(temp_len)
        temp_len = 1
dbls_len_list.append(temp_len)
# print(s_list)
# print(s_len_list)
# print(dbls_list)
# print(dbls_len_list)
if len(s_len_list) == 1:
    ans = (s_len_list[0] * k) // 2
elif s_len_list[len(s_len_list)-1] % 2 == 1 and dbls_len_list[len(s_len_list)-1] % 2 == 0:
    for i in s_len_list:
        ans += i // 2
    ans *= k
    ans += (k-1)
else:
    for i in s_len_list:
        ans += i // 2
    ans *= k
print(ans)

Measured memory_bytes: 3064
MOD = 10**9 + 7
def main():
    n = int(input())
    t = list(map(int, input().split()))
    a = list(map(int, input().split()))
    h = [None]*n
    h[0] = t[0]
    for i in range(1, n):
        if t[i-1] < t[i]:
            h[i] = t[i]
    f = True
    if h[n-1] is not None and h[n-1] != a[n-1]:
        f = False
    if h[n-1] is None:
        h[n-1] = a[n-1]
    for i in reversed(range(n-1)):
        if a[i] > a[i+1]:
            if h[i] is None:
                h[i] = a[i]
            else:
                if h[i] != a[i]:
                    f = False
        if h[i] is not None and h[i] > a[i]:
            f = False
    if f:
        ans = 1
        for i in range(n):
            if h[i] is None:
                ans *= min(t[i], a[i])
                ans %= MOD
        print(ans % MOD)
    else:
        print(0)

if __name__ == "__main__":
    main()

Measured memory_bytes: 18624
import java.util.Scanner;
import java.lang.Math;
public class Main{

	public static void main(String[] args) {
		Scanner src=new Scanner(System.in);
		long N=src.nextLong();
		int s=(int)(Math.sqrt((double)N));
		for(int i=s;i>=1;i--) {
			if(N%i==0) {
				System.out.println(i+N/i-2);
				break;
			}
		}
		
				
		
		

	}

}

Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	string S;
	cin >> S;
	ll cnt = 0;
	ll k = 0;
	for (ll i = 0; i<S.size(); i++) {
		for (char c = 'A'; c <= 'Z'; c++) {
			if (S[i] == c) cnt++;
		}
	}
	for (ll i = 2; i < S.size() - 1; i++) {
		if (S[i] == 'C')k++;
	}

	if (S[0] == 'A'&&k==1&&cnt == 2) {
		cout << "AC" << endl;
	}
	else
		cout << "WA" << endl;

}








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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    double t,a;
    cin>>t>>a;
    Vec h(n);
    rep(i,n)cin>>h[i];
    ll ans=0;
    double diff=INF;

    rep(i,n){
        if(diff > abs(t-h[i]*0.006-a)){
            diff = abs(t-h[i]*0.006-a);
            ans = i+1;
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int t, sum=0;
	cin >> t;
	int a = t;
	while(t != 0){
		sum+=t%10;
		t/=10;
	}
	if(a%sum == 0) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = int(1e9 + 7)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	tot := 1
	x0 := 1
	x09 := 1
	for i := 0; i < N; i++ {
		tot *= 10
		tot %= mod
		x09 *= 8
		x09 %= mod
		x0 *= 9
		x0 %= mod
	}
	// out(tot, x0, x09)
	ans := tot + x09
	ans %= mod
	ans -= x0
	if ans < 0 {
		ans += mod
	}
	ans -= x0
	if ans < 0 {
		ans += mod
	}
	out(ans)
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int sss , s1 , s2 , s3;
cin >> sss;
s1 = sss/100;
s2 = sss/10-s1*10;
s3 = sss-s1*100-s2*10;
cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 1,N,K,q;
  cin >> N >> K;
  for(int i = 0;i < N;i++)cin >> q;
  N -= K;
  while(N > 0){
    N -= (K-1);
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int c=0;
void merge(int *A,int left,int mid,int right){
  int n1,n2,i,k,j,L[500000],R[500000];
  n1 = mid - left;
  n2 = right - mid;
  /*L=(int *)malloc(n1 * sizeof(int));
    R=(int *)malloc(n2 * sizeof(int));*/
  for(i=0;i<=n1-1;i++){
    L[i] = A[left + i];
  }
  for(i=0;i<=n2-1;i++){
    R[i] = A[mid + i];
  }
  
  L[n1] = 2147483647;
  R[n2] = 2147483647;
  i = 0;
  j = 0;
  for(k=left;k<=right-1;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i = i + 1;
    }
    else{
      A[k]=R[j];
      j = j + 1;
    }
    c++;
  }
}

void mergeSort(int *A,int left,int right){
  int mid;
  if(left+1<right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
      }
}



int main(){
  int i,n,S[500000],left,right;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  mergeSort(S,0,n);
  for(i=0;i<n;i++){
    if(i!=n-1){
    printf("%d ",S[i]);
    }
    else{
      printf("%d\n",S[i]);
    }
    
  }
    printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 5612
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int A,B,K,S,res=0,tmp=0;


int main(){
    cout << fixed << setprecision(18);
    cin>>A>>B;
    if(A*2>=B){
        cout<<B/2<<endl;
        return 0;
    }else{
        B-=2*A;
        res=A;
    }

    cout<<res+B/4<<endl;
}




Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
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; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	map<int, bool> mp;
	int n;
	cin >> n;
	vector<ll> a(n);
	set<ll> s;
	ll x = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		x ^= a[i];
		s.insert(a[i] ^ (a[i] - 1));
	}
	int ans = 0;
	for (ll i = 31; i >= 0; i--) {
		if ((1ll << i) & x) {
			auto it = s.lower_bound(1ll << i);
			if (it == s.end() || *it >= (1ll << (i + 1))) {
				dump(-1);
				return 0;
			}
			ans++;
			x ^= *it;
		}
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n;cin>>n;
  vector<long long> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) if(a[i]==0){ cout<<0<<endl; return 0; }
  long long aa=1;

  for(int i=0;i<n;i++){
    if(1000000000000000000/a[i]<aa){ cout<<-1<<endl; return 0; }
    else{ aa*=a[i]; }
  }
  cout<<aa<<endl;
  return 0;
}


Measured memory_bytes: 4048
#include<iostream>
#include<string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    char a[h][w];
    bool flag;
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    while(true){
        rep(i,h){
            flag=true;
            rep(j,w){
                if(a[i][j]=='#'){
                    flag = false;
                }
            }
            if(flag){
                rep(j,w){
                    a[i][j] =' ';
                }
                continue;
            }
        }
        rep(j,w){
            flag=true;
            rep(i,h){
                if(a[i][j]=='#'){
                    flag = false;
                }
            }
            if(flag){
                rep(i,h){
                    a[i][j] =' ';
                    continue;
                }
            }
        }
        break;
    }
    rep(i,h){
        flag =false;
        rep(j,w){
            if(a[i][j]!=' '){
                cout << a[i][j];
                flag=true;
            }
        }
        if(flag){
            printf("\n");
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		Arrays.sort(s);
		out.println(s[0]=='a'&&s[1]=='b'&&s[2]=='c'?"Yes":"No");
	}
}


Measured memory_bytes: 21716
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
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);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N, K; scanf("%lld%lld", &N, &K);
    vector<int> A(N), B(N), C(N);
    for(int i=0; i<N; i++) {
        A[i] = K + i;
        B[i] = K + N + i;
        C[i] = K + 2*N + i;
    }

    int ptr = N-1;
    while(ptr >= 0 and A[N-1] + B[ptr] > C[N-1]) ptr--;

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

    vector< pair<ll, ll> > ans;
    for(int i=0; i<N; i++) {
        ans.emplace_back(A[N-1-i], B[ptr]);
        ptr--;
        if(ptr < 0) ptr = N-1;
    }

    sort(ans.begin(), ans.end(), [](auto a, auto b) {
            return a.first + a.second < b.first + b.second;
        });

    bool ok = true;
    for(int i=0; i<N; i++) {
        ok &= (ans[i].first + ans[i].second <= C[i]);
    }

    if(ok) {
        for(int i=0; i<N; i++) {
            ll a, b, c; tie(a, b) = ans[i], c = C[i];
            printf("%lld %lld %lld\n", a, b, c);
        }
    }
    else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 5104
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	string s;
	cin >> s;
	bool res = true;
	REP(i, s.length()) REP(j, s.length()) res &= (i == j || s[i] != s[j]);
	cout << (res ? "yes" : "no") << endl;
	return 0;
}


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

int main(){
  long long int num, ans = 0;
  cin >> num;
  if(num < 2) cout << 0 << endl;
  else if(num % 2 == 1) cout << 0 << endl;
  else{
    num /= 2;
    long long int p = 5;
      while(p <= num){
          ans += num/p;
          p *= 5;
      }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import           Data.Maybe ( fromJust, isNothing )

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,y] <- getParms
  putStrLn $ f n y

type Mai = Int
type Yen = Int
type Pochi = (Int,Int,Int) -- #s of 10000,5000,1000 bills

minPochi :: Yen -> Pochi
minPochi y = (a,b,c)
  where
    (a,r) = y `quotRem` 10000
    (b,s) = r `quotRem` 5000
    c     = s `quot` 1000

canPay :: Mai -> Yen -> Maybe Pochi
canPay n y = h i
  where
    i@(a,b,c) = minPochi y

    h :: Pochi -> Maybe Pochi
    h p@(a,b,c)
      | n == m = Just p
      | n - m > 3 && b > 0 = h (a, b-1, c+5)
      | n - m > 0 && a > 0 = h (a-1,b+2,c)
      | otherwise = Nothing
      where
        m = a+b+c

f n y
  | isNothing p = "-1 -1 -1"
  | otherwise   = show a ++ " " ++ show b ++ " " ++ show c
  where
    p = canPay n y
    (a,b,c) = fromJust p

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define DIV 998244353

using namespace std;

long a[301];
long dp1[301][90001];
long dp2[301][90001];

int main() {
    int n, sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }

    dp1[0][0] = 1;
    dp2[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 90001; ++j) {
            if (dp1[i][j] != 0) {
                dp1[i + 1][j] = (dp1[i + 1][j] + dp1[i][j] * 2) % DIV;
                dp1[i + 1][j + a[i]] = (dp1[i + 1][j + a[i]] + dp1[i][j]) % DIV;
            }
            if (dp2[i][j] != 0) {
                dp2[i + 1][j] = (dp2[i + 1][j] + dp2[i][j]) % DIV;
                dp2[i + 1][j + a[i]] = (dp2[i + 1][j + a[i]] + dp2[i][j]) % DIV;
            }
        }
    }
    long answer = 1;
    for (int i = 0; i < n; ++i) {
        answer = answer * 3 % DIV;
    }
    for (int i = sum; i > (sum - 1) / 2; --i) {
        long sub = dp1[n][i];
        if (i * 2 == sum) {
            sub -= dp2[n][i];
        }
        answer = (answer - 3 * sub) % DIV;
    }
    if (answer < 0) answer += DIV;
    cout << answer << endl;
}


Measured memory_bytes: 421504
#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||x+r>W||y-r<0||y+r>H){
        printf("No\n");
    }else printf("Yes\n");
    
    return 0;
}


Measured memory_bytes: 2108
# 木なので親から繋がっている1辺のみ色が塗られている状態(根に限っては何も塗られていない)

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N-1)]

g = dict()
for i, (a, b) in enumerate(AB):
    a, b = a-1, b-1
    if a not in g:
        g[a] = set()
    if b not in g:
        g[b] = set()
    g[a].add((b, i))
    g[b].add((a, i))

col = [-1]*N
col[0] = -2
e_col = [-1]*(N-1)

q = [0]
while q:
    par = q.pop()
    par_col = col[par]

    c = 0
    for child, e_i in g[par]:
        # print(child, c)
        if col[child] != -1:
            continue
        while c == par_col:
            c += 1
        e_col[e_i] = c
        col[child] = c
        c += 1
        q.append(child)

# print(col)
# print(e_col)

print(max(e_col)+1)
for e_col_i in e_col:
    print(e_col_i+1)

Measured memory_bytes: 128360
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define pb push_back
int main(){
  int n;
  cin>>n;
  vector<P> e[n];
  bool colored[n]={};
  int color[n]={};
  rep(i,n-1){
	int u,v,w;
	cin>>u>>v>>w;
	w%=2;
	u--;v--;
	e[u].pb({v,w});
	e[v].pb({u,w});
  }
  queue<int> q;
  q.push(0);
  while(!q.empty()){
	int i=q.front();
    //cout<<i<<endl;
	q.pop();
	for(auto j:e[i]){
		int t=j.first;
		if(colored[t])continue;
		if(j.second){
			color[t]=color[i]==0?1:0;
		}else{
			color[t]=color[i]==0?0:1;
		}
		q.push(t);
		colored[t]=true;
	}
  }
  rep(i,n){
	cout<<color[i]<<endl;
  }
}


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

int c[17][15];
int p[17][15];

int main() {
    int w, h;
    while (cin >> w >> h, w|h) {
        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                int ci;
                cin >> ci;
                c[y][x] = ci;
            }
        }
        for (int x = 0; x < w; x++) {
            c[h][x] = c[h+1][x] = 2;
        }
        memset(p, 0, sizeof(p));
        for (int y = 0; y < h+2; y++) {
            for (int x = 0; x < w; x++) {
                if (c[y][x] == 1) {
                    continue;
                }
                if (y == 0) {
                    p[y][x] = 1;
                    continue;
                }
                if (c[y][x] == 0) {
                    if (x > 0 && c[y-1][x-1] == 0) {
                        p[y][x] += p[y-1][x-1];
                    }
                    if (x+1 < w && c[y-1][x+1] == 0) {
                        p[y][x] += p[y-1][x+1];
                    }
                }
                if (c[y-1][x] == 0) {
                    p[y][x] += p[y-1][x];
                }
                if (y >= 2 && c[y-2][x] == 2) {
                    p[y][x] += p[y-2][x];
                }
            }
        }
        int ans = 0;
        for (int y = h; y < h+2; y++) {
            for (int x = 0; x < w; x++) {
                ans += p[y][x];
            }
        }
        cout << ans << endl;
    }
}

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

int main() {
  int n,x,d=0,ans=1;
  cin>>n>>x;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    d+=a;
    if(d<=x) ans++;
    else break;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int abc[3];
	REP(i, 3) cin >> abc[i];
	sort(abc, abc + 3);
	cout << (abc[0] == 5 && abc[1] == 5 && abc[2] == 7 ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var input_array =input.trim().split("\n");
var numbers = input_array.map((n) => Number(n));

var max_value;
var min = 0;

for (var i = 1; i < numbers.length; i++) {
  if (i === 1) {
    min = numbers[i];
    continue;
  }
  max_value = typeof max_value === 'undefined' || numbers[i] - min > max_value ?  numbers[i] - min : max_value;
  min = numbers[i] < min ? numbers[i] : min;
}

console.log(max_value);


Measured memory_bytes: 40660
from functools import reduce
from fractions import gcd

N = int(input())
T = [int(input()) for i in range(N)]


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


print(lcm(*T))



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

int main() {
  int N;
  int i=0;
  bool flag=true;
  cin >> N ;
  while(i<N){
    string color;
    cin >> color;
    if(color=="Y"){
    cout << "Four" <<endl;
      flag=false;
      break;
    }
  i++;
  }
  if(flag){
    cout << "Three"<<endl;
  }
  // ここにプログラムを追記
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,h;
  cin >> n;
  string a;
  h = 0;
  for(int i =0;i<n;++i){
  cin >> a;
    if (a == "Y") {
    h = 1;
    break;
    }
    
    }
  if (h == 1) cout << "Four" << endl;
  else cout << "Three" << endl;
}


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

int ButtonCheck(int x,int y);

int main(){
  int N;
  cin >> N;
  vector<string> Blue = vector<string>(N);
  for(int i = 0;i<N;i++){ 
    cin >> Blue.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> Red = vector<string>(M);
  for(int i = 0;i<M;i++){ 
    cin >> Red.at(i);
  }
  
  int ans=0;
  
   for(int i = 0;i<N;i++){
   	int calc =0;
     for(int j=0;j<N;j++){
    	if(Blue.at(i)==Blue.at(j)){
  	  		calc++;
    	}
     }
      for(int j = 0;j<M;j++){ 
      if(Blue.at(i)==Red.at(j)){
  	  		calc--;
    	}
      }
   if(ans<calc){ans=calc;}
   }
  
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(int i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    ll cnt = 0;
    while(!(A < B)){
        B *= 2;
        cnt++;
    }
    while(!(C > B)){
        C *= 2;
        cnt++;
    }
    cout << (K >= cnt ? "Yes\n":"No\n");
}

Measured memory_bytes: 3648