akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans=0;cin>>N;ll A[N],R[N],L[N];
  REP(i,N)cin>>A[i];R[0]=0;L[0]=0;
  REP(i,N-1){
    R[i+1]=__gcd(R[i],A[i]);
    L[i+1]=__gcd(L[i],A[N-i-1]);
  }
  REP(i,N)ans=max(ans,__gcd(R[i],L[N-1-i]));
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    std::ios_base::sync_with_stdio(false);
    
    long long a, b, c, d;
    std::cin >> a >> b >> c >> d;

    long long max = std::max({a * c, a * d, b * c, b * d});
    std::cout << max << std::endl;

    return 0;
}

Measured memory_bytes: 3692
//
//  main.cpp
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>
#include <math.h>
#include <queue>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <set>
#include <memory>

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118

using namespace std;

int main() {
    while (true) {
        int W, H;
        scanf("%d %d", &H, &W);
        if (W == 0 && H == 0) {
            return 0;
        }
        unique_ptr<char[]> field(new char[W * H]);
        for (int i = 0; i < H; i++) {
            scanf("%s", field.get()+(W*i));
        }
        vector<int> stack;
        stack.reserve(W*H);
        int count = 0;
        for (int x = 0; x < W; x++) {
            for (int y = 0; y < H; y++) {
                if (field[x+y*W] == 'X') {
                    continue;
                }
                count++;
                char fruit = field[x+y*W];
                stack.push_back(x+y*W);
                field[x+y*W] = 'X';
                while (!stack.empty()) {
                    int idx = stack.back();
                    stack.pop_back();
                    int cx = idx % W;
                    int cy = idx / W;
                    for (int dx = 0; dx < 2; dx++) {
                        for (int dy = 0; dy < 2; dy++) {
                            int nx = cx + -1 + 1*dx + 1*dy;
                            int ny = cy + 0 + (-1)*dx + 1*dy;
                            if (nx < 0 || nx >= W || ny < 0 || ny >= H) {
                                continue;
                            }
                            if (field[nx+ny*W] != fruit) {
                                continue;
                            }
                            stack.push_back(nx+ny*W);
                            field[nx+ny*W] = 'X';
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}



Measured memory_bytes: 3192
import Text.Printf
import Data.List

merge :: [[Int]] -> [[Int]]
merge [] = []
merge ((x0:x1:x2:x3:_):[]) = [(x0:x1:x2:x3:[])]
merge ((x0:x1:x2:x3:_):((y0:y1:y2:y3:_):xs))
  | x0==y0 && x1==y1 && x2==y2 = merge ((x0:x1:x2:x3+y3:[]):xs)
  | otherwise                  = (x0:x1:x2:x3:[]):(merge ((y0:y1:y2:y3:[]):xs))

look :: [[Int]] -> (Int, Int, Int) -> Int
look [] (_,_,_) = 0
look ((x:y:z:v:_):xs) (b,f,r)
  | (x-1)==b && (y-1)==f && (z-1)==r  = v
  | otherwise             = look xs (b,f,r)

line = ["####################\n"]

ans3 :: [[Int]] -> (Int, Int, Int) -> Int -> String
ans3 table (b,f,r) k
  | k == r    = "\n"
  | otherwise = let c = look table (b,f,k)
                    s = printf " %d" c :: String
                in
                  s ++ (ans3 table (b,f,r) (k+1))

ans2 :: [[Int]] -> (Int, Int, Int) -> Int -> [String]
ans2 table (b,f,r) j
  | j == f     = []
  | otherwise  = (ans3 table (b,j,r) 0):(ans2 table (b,f,r) (j+1))

ans1 :: [[Int]] -> (Int, Int, Int) -> Int -> [String]
ans1 table (b,f,r) i
  | i == b - 1 = (ans2 table (i,f,r) 0)
  | otherwise  = (ans2 table (i,f,r) 0) ++ line ++ (ans1 table (b,f,r) (i+1))

main = do
  c <- getContents
  let l = map (map read) $ map words $ lines c :: [[Int]]
      i = drop 1 l
      i' = merge $ sort i
      o = ans1 i' (4,3,10) 0
  mapM_ putStr o

Measured memory_bytes: 4280
# abc127_a.py
# https://atcoder.jp/contests/abc127/tasks/abc127_a

# A - Ferris Wheel /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# A歳の高橋君が観覧車に乗ろうとしています。
# この観覧車は、13歳以上が乗るには B 円 (B は偶数) かかりますが、6 歳以上 12 歳以下の人はその半額で乗ることができ、 さらに 5歳以下の人は無料で乗ることができます。
# 高橋君が観覧車に乗るには何円かかるかを求めてください。

# 制約
#     0≤A≤100
#     2≤B≤1000
#     Bは偶数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B

# 出力
# 高橋君が観覧車に乗るには何円かかるかを出力せよ。

# 入力例 1
# 30 100

# 出力例 1
# 100

# 現在 30歳の高橋君は、観覧車に乗るのに 100円かかります。

# 入力例 2
# 12 100

# 出力例 2
# 50

# 12歳の高橋君は、観覧車に乗るのに 100 円の半額、すなわち 50円かかります。

# 入力例 3
# 0 100

# 出力例 3
# 0

# 0歳の高橋君は、観覧車に無料で乗ることができます。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(Q):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if A <= 5:
        result = 0
    elif A <= 12:
        result = int(B/2)
    else:
        result = B

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['30 100']
        lines_export = [100]
    if pattern == 2:
        lines_input = ['12 100']
        lines_export = [50]
    if pattern == 3:
        lines_input = ['0 100']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9268
#include <stdio.h>

int main()
{
    int a = 0;
    int b = 0;
    int c = 0;
    
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    
    int num_of_divisor = 0;
    int i = 0;
    
    for(i = a; i < b+1 ; i++ )
    {
        if(c%i == 0) num_of_divisor++;
    }
    
    printf("%d\n",num_of_divisor);
    
    return 0;
}


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

using namespace std;

int main()
{
	long long int n;
	vector<int> s;
	long long int ans = 0;
	long long int b;
	
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		s.push_back(num - (i + 1));
	}
	
	vector<int> cp(s);
	
	sort(cp.begin(), cp.end());
	
	b = cp[n / 2];
	
	for (int i = 0; i < n; i++) {
		ans += abs(s[i] - b);
	}
	cout << ans << endl;
	
	return (0);
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n, h, w; cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;

typedef pair<int,int> pii;
int x, k, a[MAXN], q, ans[MAXN];
pii qry[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();
    cin >> x;
    cin >> k;
    REP (i, k) {
        cin >> qry[i].first;
        qry[i].second = -1;
    }

    cin >> q;
    REP (i, q) {
        cin >> qry[i+k].first;
        qry[i+k].second = i;
        cin >> a[i];
    }

    sort(qry, qry+q+k);

    int L = 0, R = x, C = 0;
    int state = -1;
    REP (i, q+k) {
        int gap = qry[i].first - (i ? qry[i-1].first : 0);
        if (state < 0) {
            int mc = min(C, gap);
            C -= mc;
            gap -= mc;
            L += gap;
            L = min(x, L);
            R = max(R, L);
        } else {
            int mc =  min(x-(C+(R-L)), gap);
            C += mc;
            gap -= mc;
            R -= gap;
            C += gap;
            C = min(x, C);
            R = max(0, R);
            L = min(L, R);
        }
        debug(qry[i].first, L, R, C);

        if (qry[i].second == -1) {
            state *= -1;
        } else {
            int pos = a[qry[i].second];
            if (pos <= L) {
                ans[qry[i].second] = C;
            } else if (pos <= R) {
                ans[qry[i].second] = C + (pos - L);
            } else {
                ans[qry[i].second] = C + (R - L);
            }
        }
    }

    REP (i, q) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll f(ll b, ll n){
  if(n < b) return n;
  else return f(b, (ll)floor((double)n / (double)b)) + n % b;
}
int main(){
  ll n, s;
  cin >> n >> s;
  ll ans = -1;
  for(ll i = 2; i * i <= n; i++){
    if(f(i, n) == s){
      if(ans == -1) ans = i;
      else ans = min(ans, i);
    }
  }
  for(ll i = 0; i * i <= n; i++){
    if(i == 0){
      if(n == s){
        if(ans == -1) ans = n + 1;
        else ans = min(ans, n + 1);
      }
      continue;
    }
    ll num = n;
    if((n - s) % i != 0) continue;
    ll b = (n - s) / i + 1;
    if(b <= 1) continue;
    if(f(b, n) == s){
      if(ans == -1) ans = b;
      else ans = min(ans, b);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0];
    auto A = s[1];
    auto B = s[2];
    auto C = s[3];
    auto Q = N.iota.map!(_ => readln.chomp).array;

    dchar[] ans;

    void add(dchar plus, dchar minus) {
        ans ~= plus;
        if (plus == 'A') {
            A += 1;
        } else if (plus == 'B') {
            B += 1;
        } else {
            C += 1;
        }
        if (minus == 'A') {
            A -= 1;
        } else if (minus == 'B') {
            B -= 1;
        } else {
            C -= 1;
        }
    }

    foreach (i, q; Q) {
        if (q == "AB") {
            if (A == 0 && B == 0) {
                writeln("No");
                return;
            } else if (A == 1 && B == 1) {
                if (i == N - 1 || Q[i+1] == "AC") {
                    add('A', 'B');
                } else {
                    add('B', 'A');
                }
            } else if (A == 0) {
                add('A', 'B');
            } else if (B == 0) {
                add('B', 'A');
            } else if (A == 1) {
                add('A', 'B');
            } else if (B == 1) {
                add('B', 'A');
            } else if (A <= B) {
                add('A', 'B');
            } else {
                add('B', 'A');
            }
        } else if (q == "BC") {
            if (B == 0 && C == 0) {
                writeln("No");
                return;
            } else if (B == 1 && C == 1) {
                if (i == N - 1 || Q[i+1] == "AB") {
                    add('B', 'C');
                } else {
                    add('C', 'B');
                }
            } else if (B == 0) {
                add('B', 'C');
            } else if (C == 0) {
                add('C', 'B');
            } else if (B == 1) {
                add('B', 'C');
            } else if (C == 1) {
                add('C', 'B');
            } else if (B <= C) {
                add('B', 'C');
            } else {
                add('C', 'B');
            }
        } else {
            if (A == 0 && C == 0) {
                writeln("No");
                return;
            } else if (A == 1 && C == 1) {
                if (i == N - 1 || Q[i+1] == "AB") {
                    add('A', 'C');
                } else {
                    add('C', 'A');
                }
            } else if (A == 0) {
                add('A', 'C');
            } else if (C == 0) {
                add('C', 'A');
            } else if (A == 1) {
                add('A', 'C');
            } else if (C == 1) {
                add('C', 'A');
            } else if (A <= C) {
                add('A', 'C');
            } else {
                add('C', 'A');
            }
        }
    }

    writeln("Yes");
    ans.each!writeln;
}


Measured memory_bytes: 6900
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

// factorize
vector<pair<ll, ll> > prime_factorize(ll n) {
  vector<pair<ll, ll> > res;
  for (ll p = 2; p * p <= n; p++) {
    if (n %p != 0) continue;
    int num = 0;
    while (n % p == 0) {
      num++;
      n /= p;
    }
    res.push_back(make_pair(p,num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

// enumerate divisors
vector<int> enum_div(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i * i != n) {
        res.push_back(n/i);
      }
    } 
  }
  sort(res.begin(), res.end());
  return res;
}

const int MAX = 510000;


long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; 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;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  int N, M; cin >> N >> M;

  COMinit();
  
  vector<pair<ll, ll>> T = prime_factorize(M);

  ll ans = 1;
  for (auto x: T) {
    // cout << x.first << " "<< N + x.second - 1 << " " << N  -1 << endl;
    ans *= COM(N + x.second - 1, N - 1);
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 12544
#pragma GCC optimize("Ofast")
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define inf 1001001001001000
#define mod 1000000007
using namespace std;

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

    UnionFind(ll n) : par(n) { //最初は全てが根であるとして初期化
        rep(i,n) par[i] = i;
    }

    ll root(ll 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の木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

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

int main(void){
    ll n,m;
    cin>>n>>m;
    vl p(n),ip(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
        ip[p[i]] = i;
    }
    UnionFind uf(n);
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        x--;
        y--;
        uf.unite(x,y);
    }
    ll ans = 0;
    rep(i,n){
        if(uf.same(i,ip[i])) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
n=int(input())
flag=False
for i in range(1000):
    for j in range(-1000,i):
        if i*i*i*i*i-j*j*j*j*j==n:
            print(i,j)
            flag=True
            break
    if flag:
        break
#4970069925031
#1985049910084967

Measured memory_bytes: 63440
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N  = sc.nextInt();
		int M  = sc.nextInt();
		
		boolean[][] path = new boolean[8][8];

		
		for(int i = 0; i < M; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			path[a - 1][b - 1] = true;
			path[b - 1][a - 1] = true;
		}
		
		boolean[] x = new boolean[N];
		x[0] = true;
		
		int sum = root(0, N, x, path);
		System.out.println(sum);
	}
	
	public static int root(int a, int N, boolean[] x, boolean[][] path) {
		boolean y = true;
		for(int i = 0; i < N; i++) {
			if(!x[i]) {
				y = false;
			}
		}
		
		if(y) {
			return 1;
		}
		
		int ret = 0;
		
		for(int i = 0; i < N; i++) {
			if(path[a][i] && !x[i]) {
				x[i] = true;
				ret += root(i, N, x, path);
				x[i] = false;
			}
		}
		return ret;
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#include <string>
string char_to_str(char c){string tem(1,c);return tem;}

typedef pair<int, int> ii;
#define S second
#define F first
// string to integer atoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output


int main(){
	fastio;

	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	int n, a, b, c, d;
	cin>>n>>a>>b>>c>>d;
	char v[n];

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

	if(v[c-1]=='#' || v[d-1]=='#'){
		cout<<"No";
		return 0;
	}

	int max = 0;
	if(c<d){
		max=d;
	}
	else{
		max=c;
	}

	for (int i = a-1; i < max-1; ++i)
	{
		if(v[i]=='#' && v[i+1]=='#'){
			cout<<"No";
			return 0;
		}
	}

	if(c>d){
		int fg=0;
		for (int i = b-1; i < d-1; ++i)
		{
			if(v[i-1]=='.' && v[i]=='.' && v[i+1]=='.'){
				fg=1;
				break;
			}
		}
		if(v[d-2]=='#' || v[d]=='#'){
			if(fg==1){
				cout<<"Yes";
				return 0;
			}
			else{
				cout<<"No";
				return 0;
			}
		}
		else{
			cout<<"Yes";
			return 0;
		}
	}
	else{
		cout<<"Yes";
		return 0;
	}


	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    ll A;
    long double B;
    cin>>A>>B;
    cout << (ll)(A * B + 0.001) << endl;
}


Measured memory_bytes: 3680
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();

        int a = x%500;

        System.out.println((1000*(x/500))+((a/5)*5));
    }
}

Measured memory_bytes: 35524
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Graph = vector<vector<int>>;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int N, M, K, Q, W, H, R, C;

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

    cin >> N;
    Graph G(N);
    REP(i, N) {
        int u, k;
        cin >> u >> k;
        u--;
        REP(j, k) {
            int v;
            cin >> v;
            v--;
            G[i].push_back(v);
        }
    }

    vector<int> dis(N + 5, -1);
    dis[0] = 0;
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (auto v : G[u]) {
            if (dis[v] == -1) {
                que.push(v);
                dis[v] = dis[u] + 1;
            }
        }
    }
    REP(i, N) { cout << i + 1 << " " << dis[i] << endl; }

    return 0;
}



Measured memory_bytes: 3164
import java.util.Scanner;
import java.lang.Math;
public class Main {
	public static int gcd(int a, int b){
		if(a == -1){
			return b;
		}

		while(b != 0){
			int temp = b;
			b = a % b;
			a = temp;
		}

		return a;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n, x;
		n = sc.nextInt();
		x = sc.nextInt();

		int[] cities = new int[n];
		int res = -1;

		for(int i = 0; i < n; i++){
			cities[i] = sc.nextInt();
			res = gcd(res, Math.abs(cities[i] - x));
		}

		System.out.println(res);
	}
}

Measured memory_bytes: 52160
// 173

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long int;
#define NUM 1000000007

int main(){
    char c;
    vector<bool> v(3);
    for(int i=0; i<3; i++){
        cin >> c;
        if(c == 'R') {v.at(i) = true;}
        else if(c == 'S') {v.at(i) = false;}
    }
    if(v.at(0) && v.at(1) && v.at(2)){cout << 3 << endl; return 0;}
    else if((v.at(0) && v.at(1) && !v.at(2)) || (!v.at(0) && v.at(1) && v.at(2))){cout << 2 << endl; return 0;}
    else if(!v.at(0) && !v.at(1) && !v.at(2)){cout << 0 << endl; return 0;}
    else {cout << 1 << endl; return 0;}
}

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

int main()
{
  long int H, W; // 1<= H, W <= 10^9
  cin >> H >> W;
  long int cnt = 0;
  if(H == 1 || W == 1){
    cout << 1 << endl;
    return 0;
  }
  for(long int i=0; i<H; i++){
    long int j = 0;
    if(i&1) j = 1;
    for(j; j<W; j+=2){
      cnt++;
    }
  }
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int32_t main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
    	ll a, b , c ,k;
    	cin >> a >> b >> c >> k;
    	ll sum=0;
    	if(a>=k)
		{
			cout<< k << endl;
			continue;
		}
		else if(a+b>=k)
		{
			cout<< a << endl;
		}
		else
		{
			cout<< a-(k-a-b)<< endl;
		}
    }
    return 0;
}


Measured memory_bytes: 3532
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,m1,x1,x2,x3,max,min,ans;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	if(a<=b){
		x1=a;
	}
	else if(b<=a){
		x1=b;
	}
	if(x1<=c){
		x2=x1;
	}
	else if(c<=x1){
		x2=c;
	}
	if(x2<=d){
		x3=x2;
	}
	else if(d<=x2){
		x3=d;
	}
	if(e<=f){
		m1=e;
	}
	else if(f<=e){
		m1=f;
	}
	max=a+b+c+d+e+f;
	min=m1+x3;
	ans=max-min;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2712
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int n;
LL x, y;

inline void work() {
    cin >> n;
    cin >> x >> y;
    LL a = x + y;
    LL b = x - y;
    LL c = -x + y;
    LL d = -x - y;
    LL ans = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> x >> y;
        ans = max({ans, a - x - y, b - x + y, c + x - y, d + x + y});
        a = max(a, x + y);
        b = max(b, x - y);
        c = max(c, -x + y);
        d = max(d, -x - y);
    }
    cout << ans << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    ll l, r;
    cin >> l >> r;
    int ans = 30000;
    FOR(i,l,r-1) FOR(j,i+1,r) 
    {
        int tmp = (i * j) % 2019;
        if (tmp == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (ans > tmp) 
            ans = tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n=sc.nextInt();
        int x=sc.nextInt();
        int m[]=new int[n];
        for(int i=0;i<n;i++){
            m[i]=sc.nextInt();
        }
        int min=100000;
        for(int i=0;i<n;i++){
            if(min>m[i]) min=m[i];
            x-=m[i];
        }
        int count=n+x/min;
        System.out.println(count);
        

    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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(){
    Init();
    ll a, b, c, k; cin >> a >> b >> c >> k;
    cout << (ll)(a+b+c - max(a, max(b, c)) + (max(a, max(b, c))*pow(2, k))) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
unordered_set<int> m;
int main() {
  int n,k;
  cin >> n >> k;
  while(k--) {
	int d;
    cin >> d;
    while(d--) {
      int t;
      cin >> t;
      m.insert(t);
    }
  }
  cout << n - (int)m.size() << "\n";
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
#define vvi vector<vector <int> >
int solve(int i,int we, vvi &dp, vi &v,vi &w)
{
    if(i<0||we<=0)
    return 0;
    if(w[i]>we)
    {
        dp[i][we]=solve(i-1,we,dp,v,w);
        return dp[i][we];
    }
    if(dp[i][we]!=-1) return dp[i][we];
    else
    {
    dp[i][we]=max(solve(i-1,we-w[i],dp,v,w)+v[i],solve(i-1,we,dp,v,w));
    return dp[i][we];
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,i;
    cin>>n;
    int we;
    cin>>we;
    vi w(n),v(n);
    for(i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    vi v1(we+1,-1);
    vvi dp(n+1,v1);
    int ans=solve(n-1,we,dp,v,w);
    cout<<ans<<endl;
}

Measured memory_bytes: 80256
s=list(input())
n=len(s)
s1=s[:n//2]
s2=s[n//2+1:]
s1r=s1[::-1]
s2r=s2[::-1]
if s1==s1r and s2==s2r and s1==s2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll A,B;
    cin>>A>>B;
    if(A>=13){
        cout<<B<<endl;
    }else if(6<=A){
        cout<<B/2<<endl;
    }else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=len(s);
    s='2'+s;
    if(s[1]=='0' || s[n]=='1'){
      cout<<-1<<endl;
      return 0;
    }
    FOR(i,1,n){
      if(s[i]!=s[n-i]){
        cout<<-1<<endl;
        return 0;
      }
    }
    s[n]='1';
    s[1]='0';
    priority_queue<int,vector<int>,greater<int> > ind;
    FOR(i,1,n+1){
      if(s[i]=='1') ind.push(i);
    }
    int next=ind.top();
    ind.pop();
    FOR(i,1,n+1){
      if(s[i]=='0'){
        cout<<i<<' '<<next<<endl;
      }else{
        if(!ind.empty()){
          next=ind.top();
          ind.pop();
          cout<<i<<' '<<next<<endl;
        }
      }
    }
}

Measured memory_bytes: 2024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //整数入力
      int a = sc.nextInt();
      int b = sc.nextInt();
      
      //数字の小さい方を出力
      if(a<=b){
       for(int i =0; i<b; i++){
        System.out.print(a);
       }
      }
      if(b<a) {
       for(int i =0; i<a; i++){
         System.out.print(b);
       }
      }
    }
}

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

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class APayment {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        out<<(1000-N%1000)%1000<<'\n';
    }
};


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


Measured memory_bytes: 3664
n, p = map(int, input().split())
a = [_ % 2 for _ in [int(_) for _ in input().split()]]
num_zero = 0
num_one = 0
for _ in a:
    if _ == 0:
        num_zero += 1
    else:
        num_one += 1
#print(num_zero, num_one)

ans = 0
if p == 0:
    if num_one == 0:
        ans = 2 ** n
    else:
        ans = 2 ** (n - 1)
else:
    if num_one == 0:
        ans = 0
    else:
        ans = 2 ** (n - 1)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,k,ans;
int main()
{
	 cin>>n>>k;
	 ans=1;
	 for(int i=0;i<n;i++)
	{
		if(ans>k)
		{
			ans+=k;
		}
		else 
		ans*=2;
		
	}
	cout<<ans;
	
    
    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n,m;
	cin>>n>>m;
	if((n+1)/2>=m)yes;
	else no;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

#define eval() (x * x + y * y + z * z + x * y + y * z + z * x)

static large count(large n) {
    auto cnt = 0LL;
    for (auto x = 1LL; x <= 100; ++x) {
        for (auto y = 1LL; y <= 100; ++y) {
            auto m = x * x + y * y + x * y;
            if (m >= n)
                break;

            for (auto z = 1LL; z <= 100; ++z) {
                auto k = eval();
                if (k >= n) {
                    cnt += (k == n);
                    break;
                }
            }
        }
    }
    return cnt;
}

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

    auto a = string{};
    for (auto k = 1; k <= n; ++k) {
        a += to_string(count(k)) + "\n";
    }

    cout << a;
    return 0;
}


Measured memory_bytes: 3740
#include <iostream>
using namespace std;
int main(void){
    int t[4],a[4];
    for(int i=1;i<=4;i++){
        cin>>t[i]>>a[i];
        if(t[i]==1){
            cout<<6000*a[i]<<endl;
        }
        if(t[i]==2){
            cout<<4000*a[i]<<endl;
        }
        if(t[i]==3){
            cout<<3000*a[i]<<endl;
        }
        if(t[i]==4){
            cout<<2000*a[i]<<endl;
        }
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int h,n;
    cin >> h >> n;
    vi a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vector<ll> dp(300000,LINF);
    dp[0] = 0;
    rep(j,200000){
        rep(i,n){
            if(j-a[i]>=0){
                dp[j] = min(dp[j],dp[j-a[i]] + b[i]);
            }
        }
    }
    ll ans = LINF;
    for(int i=h;i<300000;i++){
        ans = min(ans,dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
rgb = set(["r","g","b"])
while 1:
	worm = raw_input()
	if worm == "0": break
	n = len(worm)
	L = 1
	cnt = flag = 0
	queset = set([worm])
	while 1:
		que = list(queset)
		queset = set()
		for r in range(L):
			Worm = que.pop(0)
			if len(set(Worm)) == 1:
				flag = 1
				break
			for i in range(n-1):
				if Worm[i] != Worm[i+1]:
					nextclr = list(rgb-set(Worm[i:i+2]))[0]
					worm = Worm[:i] + 2*nextclr + Worm[i+2:]
					queset.add(worm)
		L = len(queset)
		if flag: break
		cnt += 1
		if cnt > 15: break
	print cnt if flag else "NA"

Measured memory_bytes: 4976
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
2 1
3 2
4 3
)");
#define cin input
#endif

int main()
{
	int n[4] = {};
	REP (i, 6)
	{
		int x;
		cin >> x;
		++n[--x];
	}

	cout << (max({n[0], n[1], n[2], n[3]}) < 3 ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 256
n,m,x,y = map(int, input().split())
xlis = list(map(int, input().split()))
ylis = list(map(int, input().split()))

flag = 0

xmax = max(xlis)
ymin = min(ylis)

for i in range(x+1,y+1):
    if i > xmax and i <= ymin:
        flag = 1
        break
    
if flag:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

#define INCREASE 0
#define DECREASE 1
int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n; i++) {
        cin >> a[i];
    }
    int flag = -1;
    int i = 1;
    int answer = 1;
    for (i; i<n; i++) {
        if(a[i] > a[i-1]){
            flag = INCREASE;
            break;
        }else if(a[i] < a[i-1]){
            flag = DECREASE;
            break;
        }
    }
    if (flag == -1) {
        cout << answer << endl;
    }else{
        i++;
        for (i; i<n; i++) {
            if(a[i] > a[i-1] && flag == DECREASE){
                answer +=1;
                i++;
                for (i; i<n; i++) {
                    if(a[i] > a[i-1]){
                        flag = INCREASE;
                        break;
                    }else if(a[i] < a[i-1]){
                        flag = DECREASE;
                        break;
                    }
                }

            } else if(a[i] < a[i-1] && flag == INCREASE) {
                answer += 1;
                i++;
                for (i; i<n; i++) {
                    if(a[i] > a[i-1]){
                        flag = INCREASE;
                        break;
                    }else if(a[i] < a[i-1]){
                        flag = DECREASE;
                        break;
                    }
                }

            }
        }
        cout << answer << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
int main(){
    int n;
    std::cin>>n;
    std::vector<int>a(n);
    long long int sum=0;
    int max_a=-1000001,min_a=1000001;
    for(int i=0;i<n;i++){
        std::cin>>a.at(i);
        max_a=std::max(max_a,a.at(i));
        min_a=std::min(min_a,a.at(i));
        sum=sum+a.at(i);
    }
    std::cout<<min_a<<" "<<max_a<<" "<<sum<<std::endl;
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

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

    vector<int> a(n), b(n), c(m), d(m);

    REP(i, n) cin >> a[i] >> b[i];
    REP(i, m) cin >> c[i] >> d[i];


    REP(i, n){
        int diff = INT_MAX;
        int ans = 0;
        REP(j, m){
            int tmp = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(diff > tmp){
                diff = tmp;
                ans = j + 1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef long long ll;
const int p=1e8+7;

int main()
{
   ll a,b,c;
   cin>>a>>b>>c;
   ll l=4*a*b,r=(c-a-b)*(c-a-b);
   if(l<r&&(c>a+b)) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort()

AAA = sum(v[N-A:])/A
print(AAA)

p = 0
import math
for i in range(A,B+1):
    ans = v[N-i:]
    if sum(ans)/i == AAA:
        rest = v[:N-i]
        m = ans.count(ans[0])
        n = rest.count(ans[0])
        C = math.factorial(n+m)//(math.factorial(m)*math.factorial(n))
        p += C

print(p)


Measured memory_bytes: 9144
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n,m,x;
	cin>>n>>m;
	priority_queue<int> q;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		q.push(x);
	}
	while(!q.empty() && m>0)
	{
		--m;
		int x = q.top();
		q.pop();
		q.push(x/2);
	}
	ll sum(0);
	while(!q.empty())
	{
		sum += (ll)q.top();
		q.pop();
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 892