akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    int n, m;
    cin >> n >> m;
    if(abs(n-m)>=2) {
        cout << 0 << endl;
        return 0;
    }
    int size = max(m, n);
    vector<int64_t> factorial(size+1);
    factorial[0] = factorial[1] = 1;
    for(int i = 2; i <= size; i++) {
        factorial[i] = (factorial[i-1]*i)%DIVISOR;
    }

    if(n > m) swap(n, m);
    // assume that n <= m
    // A B A B A

    int64_t res = 1;
    res = (res * factorial[n])%DIVISOR;
    res = (res * factorial[m])%DIVISOR;
    if(n == m) {
        res = (res * 2)%DIVISOR;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    
    vector<int> y_min(n), y_max(n);
    vector<pair<int, int>> x_p(2*n);
    for(int i=0; i<n; i++){
        int x1, x2;
        cin >> x1 >> y_min[i] >> x2 >> y_max[i];
        x_p[2*i] = make_pair(x1, i);
        x_p[2*i+1] = make_pair(x2, i);
    }

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

    set<int> x_st = {x_p[0].second};
    int prev_x = x_p[0].first;
    int area = 0;
    for(int i=1; i<2*n; i++){
        int now_x = x_p[i].first;
        int x_width = now_x - prev_x;
        
        vector<pair<int, int>> y_p;
        for(auto ind: x_st){
            y_p.push_back(make_pair(y_max[ind], ind));
            y_p.push_back(make_pair(y_min[ind], ind));
        }

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

        // 有効な y の幅を求め、逐次足す
        if(y_p.size() != 0){
            set<int> y_st;
            int prev_y = y_p[0].first;
            y_st.insert(y_p[0].second);
            for(int j=1; j<y_p.size(); j++){
                int now_y = y_p[j].first;
                int y_width = now_y - prev_y;
                if(!y_st.empty()){
                    area += x_width * y_width;
                }
                auto itr = y_st.find(y_p[j].second);
                if(itr != y_st.end()){
                    y_st.erase(itr);
                }
                else{
                    y_st.insert(y_p[j].second);
                }

                prev_y = now_y;
            }
        }

        
        prev_x = now_x;
        auto itr = x_st.find(x_p[i].second);
        if(itr != x_st.end()){
            // 削除
            x_st.erase(itr);
        }
        else{
            x_st.insert(x_p[i].second);
        }
    }
    cout << area << endl;
    return 0;
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n % 2 == 0){
        cout << 0.5000000000 << endl;
    }else{
        double ans;
        ans = ((n+1)/2.0)/n;
        cout << setprecision(10) << ans << endl;
        //cin >> n;
    }
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << (min(a, b) + min(c, d)) << endl;


    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    const int mod=100000;
    int w,h;
    //?????¨????????????0/???1????????\??????????????£?????????1
    int dp[100][100][2][2];

    while(cin >>w >>h,w|h)
    {
        memset(dp,0,sizeof(dp));

        dp[0][0][0][0]=1;
        dp[0][0][1][0]=1;

        rep(i,w)rep(j,h)
        {
            //???????????\????????????????????????
            //????????????????????????(?????§????????????)
            if(i+1<w)
            {
                dp[i+1][j][0][1]+=dp[i][j][0][0];
                dp[i+1][j][0][1]%=mod;
            }

            //???????????\?????????????????????
            //????????????????????????(?????§????????????)
            if(i+1<w)
            {
                dp[i+1][j][0][1]+=dp[i][j][0][1];
                dp[i+1][j][0][1]%=mod;
            }
            //????????£???????????????(?????§???????????????)
            if(j+1<h)
            {
                dp[i][j+1][1][0]+=dp[i][j][0][1];
                dp[i][j+1][1][0]%=mod;
            }

            //???????????\????????????????????????
            //????????????????????????(?????§????????????)
            if(j+1<h)
            {
                dp[i][j+1][1][1]+=dp[i][j][1][0];
                dp[i][j+1][1][1]%=mod;
            }

            //???????????\?????????????????????
            //????????????????????????(?????§????????????)
            if(j+1<h)
            {
                dp[i][j+1][1][1]+=dp[i][j][1][1];
                dp[i][j+1][1][1]%=mod;
            }
            //????????£???????????????(?????§???????????????)
            if(i+1<w)
            {
                dp[i+1][j][0][0]+=dp[i][j][1][1];
                dp[i+1][j][0][0]%=mod;
            }
        }

        int ans=0;
        rep(x,2)rep(y,2)
        {
            ans+=dp[w-1][h-1][x][y];
            ans%=mod;
        }

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

Measured memory_bytes: 3136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int x = Integer.parseInt(br.readLine());
			System.out.println(x * x * x);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24344
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

const INF: i64 = 1 << 60;

fn rec(dp: &mut Vec<Vec<i64>>, aa: &Vec<i64>, i: usize, j: usize) -> i64 {
    let n = aa.len();
    if i + j >= n {
        return 0;
    }
    if dp[i][j] != INF {
        return dp[i][j];
    }

    let ans;
    if (i+j)%2 == 0 {
        ans = max(
            rec(dp, aa, i+1, j) + aa[i],
            rec(dp, aa, i, j+1) + aa[n-j-1]
        )
    } else {
        ans = min(
            rec(dp, aa, i+1, j) - aa[i],
            rec(dp, aa, i, j+1) - aa[n-j-1]
        )
    }
    dp[i][j] = ans;
    ans
}

fn main() {
    input!{
      n: usize,
      aa: [i64; n],
    }
    let mut dp = vec![vec![INF; n]; n];
    println!("{}", rec(&mut dp, &aa, 0, 0));
}


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

using pii = pair<int, int>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    priority_queue<pii, vector<pii>, greater<pii>> q;
    while (n--) {
        int x;
        cin >> x;
        q.emplace(x, 1);
    }
    while (m--) {
        int b, c;
        cin >> b >> c;
        int i = b;
        while (i && q.top().first < c) {
            auto& p = q.top();
            if (i < p.second) {
                const_cast<pii&>(p).second -= i;
                i = 0;
            }
            else {
                i -= p.second;
                q.pop();

            }
        }
        if (i < b) {
            q.emplace(c, b - i);
        }

    }
    long long s = 0;
    while (!q.empty()) {
        auto& p = q.top();
        s += (long long) p.first * p.second;
        q.pop();
    }

    cout << s << '\n';

    return 0;
}


Measured memory_bytes: 1400
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    s = input()
    print(s.replace(",", " "))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3944
n,c,k = map(int, input().split())
Ts = [int(input()) for i in range(n)] + [10**10]
Ts = sorted(Ts)

ans = 0
cnt = 1
flg = 0
prev = Ts[0]
for i in range(1,len(Ts)):
    now = Ts[i]
    if now - prev <= k:
        cnt += 1
    else:
        ans += 1
        cnt = 1
        prev = Ts[i]
    if cnt > c:
        ans += 1
        cnt = 1
        prev = Ts[i]
    # print("i",i,"cnt",cnt,"ans",ans)
print(ans)



Measured memory_bytes: 8076
void main() {
  problem();
}

class LunlunNumber {
  long number;

  this(long n) {
    deb([n]);
    number = n;

    if (!isValid) {
      throw new Exception("invalid number");
    }
  }

  bool isValid() {
    auto digits = number.digits;
    foreach(i; 1..digits.length) {
      const spread = digits[i] - digits[i-1];
      if (spread < -1 || spread > 1) return false;
    }

    return true;
  }

  LunlunNumber next() {
    if (number < 10) return new LunlunNumber(number + 1);

    auto digits = number.digits;
    if (digits.all!(d => d == 9)) return new LunlunNumber(number + 1);

    auto limit = digits.length - 1;
    foreach(i; 0..limit) {
      if (digits[i] < 9 && digits[i+1] >= digits[i]) {
        digits[i]++;
        break;
      }
      digits[i] = 0;

      if (i+1 == limit) {
        digits[i+1]++;
      }
    }

    foreach_reverse(i; 0..limit) {
      if (digits[i+1] - digits[i] > 1) {
        digits[i] = digits[i+1] == 0 ? 0 : cast(byte)(digits[i+1] - 1);
      }
    }

    return new LunlunNumber(digits.digitsTo!long);
  }

  override string toString() {
    return number.to!string;
  }

}

void problem() {
  const K = scan!long;

  long solve() {
    auto lunlun = new LunlunNumber(1);
    foreach(i; 1..K) {
      lunlun = lunlun.next();
    }

    return lunlun.number;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.functional;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

byte[] digits(T)(T t) {
  byte[] digits = new byte[16];

  int i;
  while(true) {
    digits[i++] = t % 10;

    if ((t /= 10) == 0) break;
  }
  digits.length = i;

  return digits;
}

T digitsTo(T)(byte[] digits) {
  T t;
  T dec = 1;
  foreach(digit; digits) {
    t += dec * digit;
    dec *= 10;
  }
  return t;
}

// -----------------------------------------------


Measured memory_bytes: 1276
from math import gcd
K = int(input())
ans = 0

#すべての要素が等しい場合
for i in range(1,K+1):
    ans += i

#2要素が等しい場合(3*2通り)
for i in range(1,K):
    for j in range(i+1,K+1):
        ans += 6*gcd(i,j)
        
#すべての要素が異なる場合(6通り)
for i in range(1,K-1):
    for j in range(i+1,K):
        for k in range(j+1,K+1):
            ans += 6*gcd(gcd(i,j),k)


print(ans)

Measured memory_bytes: 67680
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair
#define INF (1LL<<60)
typedef long long Int;

struct node { int x, t, p; };
bool operator<(const node& l, const node& r) {
    return l.t!=r.t ? l.t<r.t : l.x!=r.x ? l.x<r.x : l.p<r.p;
}

int N, V, XL, XR;
node X[4000];

inline bool connect(int i, int j) {
    return abs(X[j].x-X[i].x)<=(long long)V*abs(X[j].t-X[i].t);
}

pair<int, int> pre[10000];
int vis[10000];
Int h[10000];
vector<int> v[10000];
vector<Int> c[10000];

inline void add_edge(int _u, int _v, Int _c) {
    v[_u].push_back(_v);
    c[_u].push_back(_c);
}

set<pair<Int, int> >::iterator z[10000];
int has[10000];

int main() {
    scanf("%d%d%d%d", &N, &V, &XL, &XR);
    X[0].x = XL;
    X[1].x = XR;
    rep(i, N) scanf("%d%d%d", &X[i+2].x, &X[i+2].t, &X[i+2].p);
    N += 2;
    sort(X, X+N);
    rep(i, 2) add_edge(0, 2+i*2, 0);
    rep(i, N) {
        const int f = 2+2*i+1;
        add_edge(f-1, f, -X[i].p);
        add_edge(f, 1, 0);
        for(int j=i+1; j<N; j++) if(connect(i, j)) add_edge(f, 2+j*2, 0);
    }
    rep(i, N) h[2+i*2] = INF;
    rep(i, 2) h[2+i*2] = 0, pre[2+i*2] = mp(0, i);
    rep(i, N) {
        const int f = 2+i*2+1;
        h[f] = h[f-1] - X[i].p;
        pre[f] = mp(f-1, 0);
        rep(j, v[f].size()) if(h[v[f][j]] > h[f]) {
            h[v[f][j]] = h[f];
            pre[v[f][j]] = mp(f, j);
        }
    }
    Int a = -h[1];
    int cur = 1;
    while(cur!=0) {
        const int f = pre[cur].first;
        const int k = pre[cur].second;
        add_edge(cur, f, -c[f][k]);
        c[f][k] = INF;
        cur = f;
    }
    set<pair<Int, int> > q;
    q.insert(mp(0, 0));
    while(!q.empty()) {
        const pair<Int, int> vv(*q.begin());
        q.erase(q.begin());
        const int cc = vv.first;
        const int ix = vv.second;
        if(vis[ix]) continue;
        vis[ix] = 1;
        if(ix==1) {
            a -= h[1] + cc;
            break;
        }
        rep(i, v[ix].size()) if(!vis[v[ix][i]]) {
            const Int nc = cc + c[ix][i] + h[ix] - h[v[ix][i]];
            if(has[v[ix][i]]) {
                if(z[v[ix][i]]->first <= nc) continue;
                q.erase(z[v[ix][i]]);
            }
            has[v[ix][i]] = true;
            z[v[ix][i]] = q.insert(mp(nc, v[ix][i])).first;
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 67000
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <string>
typedef long long ll;
using namespace std;

int main()
{
    ll square;
    ll x,y,z;
    while(~scanf("%lld%lld%lld",&x,&y,&z))
    {
        printf("%lld\n",(x*y)/2);
    }
    return 0;
}


Measured memory_bytes: 128
H, W, K = $stdin.gets.split.map {|i| i.to_i }
map = []
0.upto(H - 1) do |h|
  map[h] = $stdin.gets.strip.split(//).map do |c|
    case c
    when '.'; 0
    when '#'; 1
    end
  end
end

def info(*s)
  #$stderr.puts s.join
end

map.each do |row|
  info row
end

total = 0
0.upto((1 << H) - 1) do |hmask|
  0.upto((1 << W) - 1) do |wmask|
    info "Hmask: #{hmask} / Wmask: #{wmask}"
    k = 0
    0.upto(H - 1) do |h|
      hf = 1 << h
      hm = hf & hmask
      info "H: #{h} / #{hf} & #{hmask} = #{hm}"
      next if hm != 0
      0.upto(W - 1) do |w|
        wf = 1 << w
        wm = wf & wmask
        info "W: #{w} / #{wf} & #{wmask} = #{wm}"
        next if wm != 0
        k += map[h][w]
      end
    end
    if K == k
      total += 1
    end
    info "K = #{k} / total = #{total}"
  end
end

puts total


Measured memory_bytes: 14116
#include <iostream>
#include <vector>
#include <cmath>
#include <tuple>
#include <algorithm>
using namespace std;

class SegmentTree {
public:
	int size_ = 1;
	vector<pair<long long, int>> dat;

	void init(int sz) {
		while (size_ <= sz) size_ *= 2;
		dat.resize(size_ * 2, make_pair(1LL << 60, 0));

		for (int i = size_; i < size_ * 2; i++) {
			int cx = i;
			dat[cx] = make_pair(1LL << 60, i - size_);

			while (cx >= 2) {
				cx >>= 1;
				dat[cx] = min(dat[cx * 2], dat[cx * 2 + 1]);
			}
		}
	}
	void update(int pos, long long x) {
		pos += size_;
		dat[pos] = make_pair(x, pos - size_);

		while (pos >= 2) {
			pos >>= 1;
			dat[pos] = min(dat[pos * 2], dat[pos * 2 + 1]);
		}
	}
	pair<long long, int> query_(int l, int r, int a, int b, int u) {
		if (l <= a && b <= r) return dat[u];
		if (r <= a || b <= l) return make_pair(1LL << 60, -1);

		pair<long long, int> v1 = query_(l, r, a, (a + b) >> 1, u * 2);
		pair<long long, int> v2 = query_(l, r, (a + b) >> 1, b, u * 2 + 1);
		return min(v1, v2);
	}
	pair<long long, int> query(int l, int r) {
		return query_(l, r, 0, size_, 1);
	}
};

long long N, D, A[1 << 18], group[1 << 18];
vector<int> G[1 << 18];

long long getdist(int u, int v) {
	return A[u] + A[v] + 1LL * D * abs(v - u);
}

int main() {
	cin >> N >> D;
	for (int i = 1; i <= N; i++) { cin >> A[i]; G[i].push_back(i); group[i] = i; }

	long long FinalAns = 0;
	SegmentTree Z1; Z1.init(N + 2); for (int i = 1; i <= N; i++) Z1.update(i, A[i] - 1LL * D * i);
	SegmentTree Z2; Z2.init(N + 2); for (int i = 1; i <= N; i++) Z2.update(i, A[i] + 1LL * D * i);

	while (true) {
		vector<int> B;
		for (int i = 1; i <= N; i++) {
			if (G[i].size() >= 1) B.push_back(i);
		}
		if (B.size() == 1) break;

		vector<pair<int, int>> L;
		for (int pos : B) {
			tuple<long long, int, int> minx = make_tuple(1LL << 60, -1, -1);
			for (int j : G[pos]) {
				Z1.update(j, 1LL << 60);
				Z2.update(j, 1LL << 60);
			}
			for (int j : G[pos]) {
				pair<long long, int> v1 = Z1.query(1, j); v1.first += 1LL * D * j;
				pair<long long, int> v2 = Z2.query(j + 1, N + 1); v2.first -= 1LL * D * j;
				minx = min(minx, make_tuple(v1.first + A[j], v1.second, j));
				minx = min(minx, make_tuple(v2.first + A[j], v2.second, j));
			}
			L.push_back(make_pair(get<1>(minx), get<2>(minx)));
			for (int j : G[pos]) {
				Z1.update(j, A[j] - 1LL * D * j);
				Z2.update(j, A[j] + 1LL * D * j);
			}
		}

		for (int j = 0; j < L.size(); j++) {
			int ca = group[L[j].first], cb = group[L[j].second];
			if (ca == cb) continue;
			if (G[ca].size() < G[cb].size()) swap(ca, cb);
			FinalAns += getdist(L[j].first, L[j].second);

			for (int j = 0; j < G[cb].size(); j++) {
				group[G[cb][j]] = ca;
				G[ca].push_back(G[cb][j]);
			}
			G[cb].clear();
		}
	}
	cout << FinalAns << endl;
	return 0;
}

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

#include <queue>

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

/*********** Constants ***********/
const auto INF = static_cast<ll>(1e15);
const auto MOD = static_cast<ll>(1e9 + 7);

/*********** Variables ***********/
ll H, W, ANS;
vector<string> MAP;
vector<vector<ll>> MEMO;

/*********** Functions ***********/
void initialize() {
    cin >> H >> W;
    MAP.resize(H);
    for (auto& item : MAP) {
        cin >> item;
    }
    MEMO.resize(H, vector<ll>(W, -1));
}

ll solve(ll h, ll w) {
    if (h == 0 && w == 0) {
        return 1;
    }
    if (h < 0 || w < 0) {
        return 0;
    }
    if (MAP[h][w] == '#') {
        return 0;
    }
    if (MEMO[h][w] >= 0) {
        return MEMO[h][w];
    }
    return MEMO[h][w] = (solve(h - 1, w) + solve(h, w - 1)) % MOD;
}

void output() {
    cout << ANS % MOD << endl;
}

int main() {
    initialize();
    ANS = solve(H - 1, W - 1);
    output();
    return 0;
}


Measured memory_bytes: 9216
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long  int MOD = 1000000007;
const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

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

	cin >> N >> M;
	vector<long long int>by(M + 1, 1);
	vector<long long int>rev_by(M + 1, 1);
	for (int i = 1; i <= M; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev_by[i] = power(by[i], MOD - 2, MOD);
	}
	long long int ans = 0;
	for (int i = 0; i * 2 < M; i++) {
		long long int t = M - i - N + 1;
		if (t <= 0)continue;
		long long int b = i - t;
		long long int add = by[M];
		add *= rev_by[i];
		add %= MOD;
		add *= rev_by[M - i];
		add %= MOD;
		ans += add;
		ans %= MOD;
		if (b < 0 || M - b < 0)continue;
		long long int minus = by[M];
		minus *= rev_by[b];
		minus %= MOD;
		minus *= rev_by[M - b];
		minus %= MOD;
		ans -= minus;
		ans += MOD;
		ans %= MOD;
	}

	if (M % 2 == 0) {
		long long int t = M - M / 2 - N + 1;
		if (t > 0) {
			long long int b = M / 2 - t;
			long long int add = by[M - 1];
			add *= rev_by[M / 2 - 1];
			add %= MOD;
			add *= rev_by[M - M / 2];
			add %= MOD;
			ans += add;
			ans %= MOD;
			if (b > 0) {
				long long int minus = by[M - 1];
				minus *= rev_by[b - 1];
				minus %= MOD;
				minus *= rev_by[M - b];
				minus %= MOD;
				ans -= minus;
				ans += MOD;
				ans %= MOD;
			}
		}
	}

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

Measured memory_bytes: 8064
n, m = map(int, input().split())
alist = list(sorted(map(int, input().split())))[::-1]
md = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

dp = [-float('inf') for _ in range(n+1)]
dp[0] = 0

for i in range(n+1):
  for a in alist:
    if i - md[a] >= 0:
      if dp[i] < dp[i - md[a]] + 1:
        dp[i] = dp[i - md[a]] + 1

ans = ''
res = n
while i > 0:
  for a in alist:
    if i >= md[a] and dp[i]-1 == dp[i-md[a]]:
      ans += str(a)
      i -= md[a]
      break

print(ans)


Measured memory_bytes: 3316
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int X=sc.nextInt();
		int a[]=new int [N];
		int b=N;
		int c=1000;
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
			X=X-a[i];
			if(a[i]<c) {
				c=a[i];
			}
		}
		b=b+X/c;
		System.out.println(b);
	}
}

Measured memory_bytes: 21204
import collections
h,w=map(int,input().split())
a=''
for i in range(h):
    a+=str(input())
l=list(a)
r=collections.Counter(l)
rr=list(r.values())
R=[]
x=0;y=0;z=0
for i in rr:
    R.append(i%4)
    if i%4==1 or i%4==3:
        x+=1
    elif i%4==2:
        y+=1
    else:
        z+=1

if h%2==0 and w%2==0:
    if x==0 and y==0:
        print('Yes')
    else:
        print('No')
elif h%2==1 and w%2==1:
        if x<=1 and y<=(h-1)//2+(w-1)//2:
            print('Yes')
        else:
            print('No')
else:
    if h%2==0:
        if x==0 and y<=h//2:
            print('Yes')
        else:
            print('No')
    else:
        if x==0 and y<=w//2:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 39024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] params = sc.nextLine().split(" " );
        int n = Integer.parseInt( params[0] );
        int r = Integer.parseInt( params[1] );
        int into;
        if( n >= 10 ){
            into = r;
        }
        else {
            into = r + 100 * (10-n);
        }
        System.out.println( into );

    }

}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;

int N;
pair<int, int> arr[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> N;
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        arr[i] = {x+y, x-y};
    }
    sort(arr, arr+N);
    
    int last = -1000000005;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (arr[i].second < last) continue;
        last = arr[i].first;
        ans++;
    }
    cout << ans << "\n";
}


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

//関数
const int ord=40;//>log_2 {10^12}+1
    
//main関数
int main() {
    
    
    
    //入力
    long A,B;
    cin>>A>>B;
    
    
    
    
    //計算
    long dist=B-A+1;
    vector<int> a(ord);//
    vector<int> b(ord);
    vector<int> c(ord);
    for(int i=0;i<ord;i++){
        a.at(i)=A%2;
        b.at(i)=B%2;
        
        A/=2;
        B/=2;
    }
    if(a.at(0)==1){
        dist--;
        for(int i=0;i<ord;i++){
            c.at(i)+=a.at(i);
        }
    }
    if(b.at(0)==0){
        dist--;
        for(int i=0;i<ord;i++){
            c.at(i)+=b.at(i);
        }
    }
    if((dist/2)%2==1) c.at(0)++;
    
    long ans=0;
    for(int i=ord-1;i>=0;i--){
        c.at(i)%=2;
        ans*=2;
        ans+=c.at(i);
    }
    
    //出力
    cout <<ans<<endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[200010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=2;i<=n;i++)
	if(a[i]==a[i-1])
	{
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 896
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), X = sc.nextInt();
		int[] a = new int[n + 1];
		long[] sum = new long[n + 1];
		for (int i = 1; i <= n; i++) {
			sum[i] = a[i] = sc.nextInt();
			sum[i] += sum[i - 1];
		}
		BigInteger ans = null;

		for (int k = 1; k <= n; k++) {
			BigInteger curr = BigInteger.ZERO;
			for (int i = n, c = 1; i > 0; i -= k, c++) {

				long rangeSum = sum[i];
				if (i >= k) {
					rangeSum -= sum[i - k];
				}

				int coeff = c == 1 ? 5 : (2 * c + 1);
				curr = curr.add(BigInteger.valueOf(coeff).multiply(BigInteger.valueOf(rangeSum)));
			}
			curr = curr.add(BigInteger.valueOf(k).multiply(BigInteger.valueOf(X)));
			if (ans == null || curr.compareTo(ans) < 0)
				ans = curr;
//			ans = Math.min(ans, curr + k * 1L * X);
		}
		out.println(ans.add(BigInteger.valueOf(n * 1L * X)));
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 278872
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;
    bool ok = true;
    for (int i = b + 1; i < d; ++i) {
        if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No"
                 << "\n";
            return 0;
        }
    }
    for (int i = a + 1; i < c; ++i) {
        if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No"
                 << "\n";
            return 0;
        }
    }
    if (d > c)
        cout << "Yes"
             << "\n";
    else {
        bool ok = false;
        for (int i = b; i <= d; ++i) {
            if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
                ok = true;
                break;
            }
        }
        if (ok)
            cout << "Yes"
                 << "\n";
        else
            cout << "No"
                 << "\n";
    }
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
#define F(i,a,b) for(int i=a;i<=(b);++i)
int gcd(int a,int b){
   return  b==0? a: gcd(b,a%b);
}
int main()
{   int t;
    while(cin>>t){
        int sum=0;
   F(i,1,t){
       F(j,1,t){
           F(k,1,t){
               int cnt=i+j+k;
               int a=max(max(i,j),k);
               int c=min(min(i,j),k);
               int b=cnt-a-c;
               sum+=gcd(gcd(a,b),c);
           }
       }
    }
    cout<<sum<<endl;
   }
   return 0;
}


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

using namespace std;

#define rep(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 each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string s; cin >> s;

    ll ans = 0, w = 0;
    for (int i = s.size() - 1; i >= 0; --i) {
        if (s[i] == 'W') w++;
        if (s[i] == 'B') ans += w;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n;
  vector< vector<int> > g(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  vector< vector<int> > dp(n, vector<int>(2, -1));
  function<int(int,int,int)> dfs = [&](int u, int pa, int c) {
    if (dp[u][c] != -1) {
      return dp[u][c];
    }
    int res = 1;
    for (auto v : g[u]) {
      if (v != pa) {
        if (c == 0) {
          res = mul(res, (dfs(v, u, 0) + dfs(v, u, 1) % md));
        } else {
          res = mul(res, dfs(v, u, 0));
        }
      }
    }
    return (dp[u][c] = res);
  };

  cout << (dfs(0, -1, 0) + dfs(0, -1, 1)) % md << '\n';
  return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x)  (int)x.size()
#define en     '\n'
#define sp     ' '
#define in(v)  for(auto &a: v)cin >> a;
#define out(v) for(auto &a: v)cout << a << sp;cout << en;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll a, b, c, d, ans = -1000000000000000000;
    cin >> a >> b >> c >> d;
    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);
    cout << ans << en;
    return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
int main (void){
int n;
int a[50];
scanf("%d",&n);
for(int i=1;i<n;i++){
    scanf("%d",&a[i]);
}
int b=0;
for(int i=1;i<n;i++){
    if(a[i]!=i){
        b++;
    }
}
if(b<=2){
    printf("YES");
}else{
    printf("NO");
}
return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
   int i,m,a[10000];
	long long int n;
	scanf("%lld%d",&m,&n);
	
	for(i=0 ; i<n ; i++)
		scanf("%d",&a[i]);
		
	for(i=0 ; i<n ; i++)
		m-=a[i];
	
	
	if(m<0)
		printf("-1\n");
	else
		printf("%d\n",m);

	return 0;

}

								


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    int win = 15-s.size();
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == 'o') ++win;
    }
    cout << (win >= 8 ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
template<class T> int Factor_L(T N){
  T i;
  int sz = 0;
  if(N%2==0){
    while(N%2==0){
      N /= 2;
    }
    sz++;
  }
  for(i=3;i*i<=N;i+=2){
    if(N%i==0){
      while(N%i==0){
        N /= i;
      }
      sz++;
    }
  }
  if(N > 1){
    sz++;
  }
  return sz;
}
template<class T> inline T GCD_L(T a,T b){
  T r;
  while(a){
    r=b;
    b=a;
    a=r%a;
  }
  return b;
}
long long A;
long long B;
int main(){
  rd(A);
  rd(B);
  wt_L(Factor_L(GCD_L(A, B))+1);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190929-1

// --- original code ---
// ll A, B;
// {
//   rd(A,B);
//   wt(Factor(gcd(A,B))+1);
// }


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;
    vector<vector<i64>> tree(N);
    vector<i64> deg(N);
    rep(i,0,N-1){
        i64 a,b;
        cin >> a >> b;
        --a;
        --b;
        tree[a].emplace_back(b);
        tree[b].emplace_back(a);
        ++deg[a];
        ++deg[b];
    }

    vector<i64> c(N);
    rep(i,0,N){
        cin >> c[i];
    }

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

    queue<i64> que;
    rep(i,0,N){
        if(deg[i]==1){
            que.push(i);
        }
    }

    i64 M=0;
    vector<i64> d(N,-1);
    rep(i,0,N){
        auto u=que.front();
        que.pop();

        d[u]=c[i];
        for(auto v:tree[u]){
            if(d[v]==-1){
                --deg[v];
                if(deg[v]==1){
                    que.push(v);
                }
            }else{
                M+=min(d[u],d[v]);
            }
        }
    }

    cout << M << endl;
    rep(i,0,N){
        cout << d[i];
        if(i==N-1) cout << endl;
        else cout << " ";
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1280
n,k=map(int,input().split())
p=list(map(int,input().split()))
e=[]
for i in range(n):
  ep=(1+p[i])*p[i]/(2*p[i])
  e.append(ep)
s=[e[0]]
for i in range(1,n):
  s.append(s[i-1]+e[i])
ans=s[k-1]
for i in range(k,n):
  ans=max(ans,s[i]-s[i-k])
print(ans)

Measured memory_bytes: 24812
using System;

namespace SHIP_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var n = int.Parse(Console.ReadLine());
            for (int i = 0; i*n < s.Length; i++)
            {
                Console.Write(s.Substring(i*n, 1));
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	const string weathers[] = { "Sunny", "Cloudy", "Rainy" };
	const int weatherArrSize = sizeof(weathers)/sizeof(weathers[0]);
	string S;
	int resultIdx = 0;
	cin >> S;
	for(int i = 0; i < weatherArrSize; i++) {
		if (S == weathers[i]) {
			resultIdx = (i == weatherArrSize - 1) ? 0 : i + 1;
			break;
		}
	}
	cout << weathers[resultIdx] << endl;
}

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


int main(){


    int n, m, i, l, r, k;

    int L = 0;

    int R = 100000;


    cin >> n >> m;


    for( i = 0 ; i < m ; i = i + 1 ){

         cin >> l >> r;

         if( R < l || r < L ){

             k = 0;

             break;

             }

         if( L < l ) L = l;

         if( r < R ) R = r;

         k = R - L + 1;

         }


    cout << k << endl;


    return 0;

    }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int r, D;
    int x[11];
    cin >> r >> D >> x[0];
    for(int i=0; i<10; i++){
        x[i+1] = r*x[i] - D;
        cout << x[i+1] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1,0};
const int dy[]={0,1,0,-1,1,1,-1,-1,0};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}
int main() {
	int dp[2][101]={{}};
	int N;
	cin >> N;
	int stage[2][101];
	rep(i,2){
		rep(j,N){
			cin >> stage[i][j];
		}
	}

	dp[0][0] = stage[0][0];

	rep(i,2){
		rep(j,N){
			rep(k,2){
				int ny = i + dy[k];
				int nx = j + dx[k];
				if(ny >= 2 || nx >= N){
					continue;
				}
				dp[ny][nx] =  max(dp[ny][nx],dp[i][j] + stage[ny][nx]);
			}
		}
	}
	cout << dp[1][N-1] << endl;

	return 0;
}

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

int main() {
    string ABCD; // 0000~9999
    cin >> ABCD;

    // A op1 B op2 C op3 D = 7 となるような式を出力 ex) 1+2+2+2=7
    // op = '+' or '-'

    // op1～3の組み合わせは2^3通り
    for (int bit = 0; bit < (1 << 3); bit++) {
        int sum = 0;

        // Aを加算
        sum += stoi(ABCD.substr(0, 1));

        // BCDを加算減算
        for (int i = 0; i < 3; i++) {
            if (bit & (1<<i)) {
                sum += stoi(ABCD.substr(i+1, 1));
            } else {
                sum -= stoi(ABCD.substr(i+1, 1));
            }
        }
        // 合計が7になれば式を出力
        if (sum == 7) {
            cout << ABCD.at(0);
            for (int i = 0; i < 3; i++) {
                if (bit & (1<<i)) {
                    cout << '+';
                } else {
                    cout << '-';
                }
                cout << ABCD.at(i+1);
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}

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

using namespace std;

int main()
{
    int N,A;
    cin >> N;
    int* R = new int[N];
    for(int i = 0;i < N;i++){
        R[i] = 0; 
    }
    for(int i = 0;i < N - 1;i++){
        cin >> A;
        R[A - 1]++;
    }
    for(int i = 0;i < N;i++){
        cout<< R[i] << endl;
    }
    return 0;
}

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

int main() {
  int a, b, c=0,d=0,count=0; 
  cin >> a >> b;
  if(b>0 && b<10){
    c=10;
  }
  else if(b>9 && b<100){
    c=100;
  }
  else if(b==100){
    c=1000;
  }
   d=b+a*c;
  for(int i=0;i<10000;i++) {
    if(i*i==d){
      count++;
    }
  }
    if(count>0){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int cnt = 0;
  for(int i = 0; i < N - 2; i++){
    if(S[i] == 'A' & S[i + 1] == 'B' & S[i + 2] == 'C') cnt++;
  }
  print(cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll r,g,b,n;
	ll ans=0;
	cin>>r>>g>>b>>n;
	for(int i=0;i*r<=n;i++){
		for(int j=0;i*r+j*g<=n;j++){
			if((n-i*r-j*g)%b==0)ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256