akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int dy[] = { -1,0,0,1 }, dx[] = { 0,-1,1,0 };
int h, w;
vector<string> s;
int bfs(int sy, int sx, int gy, int gx) {
    auto dis = defvec<int>(INF, h, w);
    dis[sy][sx] = 0;
    queue<pair<int, int>> q;
    q.emplace(sy, sx);
    while (!q.empty()) {
        int y, x;
        tie(y, x) = q.front();
        q.pop();
        FOR(i, 0, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (out(ny, nx))continue;
            if (s[ny][nx] == '#')continue;
            if (chmin(dis[ny][nx], dis[y][x] + 1)) {
                q.emplace(ny, nx);
            }
        }
    }
    return dis[gy][gx];
}

int main() {
    init();
    
    cin >> h >> w;
    s.resize(h); cin >> s;

    int Max = 0;
    FOR(a, 0, h)FOR(b, 0, w) {
        if (s[a][b] == '#')continue;
        FOR(c, 0, h)FOR(d, 0, w) {
            if (s[c][d] == '#')continue;
            chmax(Max, bfs(a, b, c, d));
        }
    }

    cout << Max << "\n";
}


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

using namespace std;

typedef long long ll;

int main(){
    int x;
    cin >> x;
    if(x == 1)cout << "0" << endl;
    else cout << "1" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main()
{
    int a,b,c,d;

    scanf("%d %d %d %d",&a,&b,&c,&d);

    if(a+b < c+d){
        printf("Right\n");
    }else if(a+b == c+d){
        printf("Balanced\n");
    }else{
        printf("Left\n");
    }

    return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
fn main() {
  input! {
    r: f64,
  }

  println!("{:.15}", r * 2.0 * std::f64::consts::PI);
}


Measured memory_bytes: 2220
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007

int main()
{
    int r,c;
    cin >> r >> c;
    
    vector<vector<char>> grid(r,vector<char>(c));
    for(int i = 0; i < r; i++)
    {
        for(int j = 0; j < c; j++)
        {
            cin >> grid[i][j];
        }
    }
    
    vector<vector<int>> dp(r,vector<int>(c));
    for(int i = c-1; i >= 0; i--)
    {
        if(grid[r-1][i] == '.')
        {
            dp[r-1][i] = 1;
        }
        else
        {
            break;
        }
    }
    
    for(int i = r-1; i >= 0; i--)
    {
        if(grid[i][c-1] == '.')
        {
            dp[i][c-1] = 1;
        }
        else
        {
            break;
        }
    }
    
    for(int i = r-2; i >= 0; i--)
    {
        for(int j = c-2; j >= 0; j--)
        {
            if(grid[i][j] == '.')
            {
                dp[i][j] = (dp[i+1][j]+dp[i][j+1])%MOD;
            }
        }
    }
    
    // for(int i = 0; i < r; i++)
    // {
    //     for(int j = 0; j < c; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << '\n';
    // }
    
    cout << dp[0][0] << '\n';
    
    return 0;
}


Measured memory_bytes: 5248
X, N = [int(x) for x in input().split()]
try:
  p = list(map(int, input().split()))
except EOFError:
  p = []
option = list(range(0, 102))
for item in p:
  option[item] = -1
diff = 0
while True:
  if option[X-diff] == X-diff:
    print(X-diff)
    break
  elif option[X+diff] == X+diff:
    print(X+diff)
    break
  else:
    diff += 1

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
set<string>s;
int main()
{
    int n,flag=1,k=1;
    cin>>n;
    string p,q;
    while(n--)
    {

        cin>>p;
        if(!k) continue;
        if(flag)
        {
            s.insert(p);
            q=p;
            flag=0;
        }
        else
        {
            if(s.count(p)||p[0]!=q[q.size()-1])
            {
                k=0;
            }
            else
            {
                s.insert(p);
                q=p;
            }
        }
    }
    if(k) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = new String[3];
        for (int i = 0; i < 3; i++) s[i] = sc.next();
        int[] size = new int[3];
        for (int i = 0; i < 3; i++) size[i] = s[i].length();
        int[] cursor = new int[3];
        char ch = 'a';
        while (true) {
            int n = ch - 'a';
            if (cursor[n] >= size[n]) {
                System.out.println((char) ('A' + n));
                return;
            } else {
                ch = s[n].charAt(cursor[n]);
                cursor[n]++;
            }
        }
    }
}

Measured memory_bytes: 22100
my $N = <STDIN>;
my $s = <STDIN>;
chomp $s;
my @A = split(/ /,$s);
my $count=0;
my %R;
my %L;
for(0..$N){ $L{$_}=0;$R{$_}=0;}
for(my $i=0;$i<$N;$i++){
    $R{$i + $A[$i]}++;
    $L{$i - $A[$i]}++;
}
for(my $i=0;$i<$N;$i++){
    $count = $count + $R{$i}*$L{$i};
}
print "$count";

Measured memory_bytes: 97348
import Control.Monad
import Data.List
import Data.Monoid
import Data.IORef

unwrap [x] = x

initlist :: Int -> [Integer]
initlist n
    | (n == 0) = [0]
    | otherwise = 0 : (initlist (n - 1))

data Tree a = Leaf a | Node Int (Tree a) (Tree a)



setnode :: Num a => Tree a -> Tree a -> Tree a
setnode xt yt = Node (lsize xt) xt yt

lsize :: Num a => Tree a -> Int
lsize (Leaf x) = 1
lsize (Node n xt yt) = n + lsize yt

buildtree :: Num a => [a] -> Tree a
buildtree xs
    | (m == 0) = Leaf (unwrap xs)
    | otherwise = setnode (buildtree ys) (buildtree zs)
    where
        m = (length xs) `div` 2
        (ys,zs) = splitAt m xs

getval :: Num a => Tree a -> Int -> a
getval (Leaf x) 0 = x
getval (Node n xs ys) k = if k < n then getval xs k else getval ys (k - n)

updval :: Num a => Tree a -> Int -> a -> Tree a
updval (Leaf x) 0 k = (Leaf k)
updval (Node n xs ys) i k = if i < n then Node n (updval xs i k) ys else Node n xs (updval ys (i - n) k)

main = do
    n <- readLn
    let a = initlist n
    ar <- newIORef (buildtree a)
    rt1 <- readIORef ar
    writeIORef ar (updval rt1 0 2)
    rt2 <- readIORef ar
    writeIORef ar (updval rt2 1 1)
    when (n >= 2) $ do
        forM_ [2..n] $ \i -> do
            rt <- readIORef ar
            let v1 = getval rt (i - 1)
            let v2 = getval rt (i - 2)
            writeIORef ar (updval rt i (v1 + v2))
    rt3 <- readIORef ar
    print $ getval rt3 n

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 


int main(){
    int n,k;cin >> n >> k;
    vector<LL> dp(k+1,0);
    LL ans = 0;
    for (LL i = k; i >= 1; i--) {
        dp[i] = fpow(k / i, n);
        for (int j = 2; i * j <= k; j++) {
            dp[i] = (dp[i] + mod - dp[i * j])%mod;
        }
        ans = (ans + i * dp[i])%mod;
    }
    cout << ans << endl;
    return 0;
}



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

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

	int n;
	int mini, maxi;
	long long sum = 0;
	cin >> n;
	vector<int> input(n);
	for (int i = 0; i < n; i++){
		cin >> input[i];
		sum += input[i];
	}
	mini = *min_element(input.begin(), input.end());
	maxi = *max_element(input.begin(), input.end());
	cout << mini << " " << maxi << " " << sum << "\n";

	return 0;
}


Measured memory_bytes: 3240
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		int N = Integer.parseInt(W);

		String S = in.readLine();
		int ans =0;
		char bef = '-';
		for(int i=0;i<N;i++){
			if(bef==S.charAt(i)){

			}else{
				bef=S.charAt(i);
				ans++;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin>>a>>b;
  
  if(a>12){
    cout<<b<<endl;
    return 0;
  }
  if(a<6){
    cout<<0<<endl;
    return 0;
  }
  cout<<b/2<<endl;
}

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

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const double PI = acos(-1.0);
const int MOD = pow(10, 9) + 7;

#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()

ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (size_t i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

class Pos {
public:
	double x, y;
	Pos(double x, double y) {
		this->x = x;
		this->y = y;
	}
	Pos() {
		x = 0.0;
		y = 0.0;
	}
};

class Mod {
	static inline ll Add(ll a, ll b) {
		return (a + b) % MOD;
	}

	static inline ll Sub(ll a, ll b) {
		ll ans = (a - b) % MOD;
		return (ans < 0) ? (ans + MOD) : ans;
	}

	static inline ll Mul(ll a, ll b) {
		return (a * b) % MOD;
	}
	
	static inline ll Div(ll a, ll b) {
		return (a % MOD) * modinv(b, MOD) % MOD;
	}
};

inline double distance(Pos p1, Pos p2) {
	return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}

inline int Kaijo(int n) {
	int ans = 1;
	for (int i = 2; i <= n; ++i) {
		ans *= i;
	}
	return ans;
}

template <typename T>
inline int keta(T num) {
	return to_string(num).length();
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
		cout << endl;
	}
}

int main() {
	bool debug = false;
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	if (debug) {
		cout << "\x1b[41m" << "Debug Mode このまま提出すると死" << endl;
	}
	try {
		(debug) ? DebugMain() : Main();
	}
	catch (exception& e) {
		cout << e.what() << endl;
	}
	return 0;
}

inline void Main(){
	int m1, m2, d1, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (m1 == m2) {
		cout << 0;
	}
	else {
		cout << 1;
	}
}

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

bool replace(string &s1, const string &s2, const string &s3){
    int pos = s1.find(s2);
    if(pos == string::npos)return false;
    s1.replace(pos, s2.size(), s3);
    return true;
}

int main(){
    
    int N; cin >> N;
    string s; cin >> s;
    string t = s;
    while(replace(t, "()", ""));
    for(int i = 0; i < t.size(); i++)if(t[i] == ')')cout << "(";
    cout << s;
    for(int i = 0; i < t.size(); i++)if(t[i] == '(')cout << ")";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) (a)<=(i) && (i)<(b)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;

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

  int a,b,c;
  cin >> a >> b >> c;

  int ans = 0;
  ans += min(c,a+b+1);
  ans += b;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 764
#include <stdio.h>

int a[1000005];

void solve(int n) {
    long long ans=0;
    for(int i=1;i<=n;i++) {
        if(i%3==0||i%5==0) continue;
        ans+=i;
    }
    printf("%lld",ans);
}

int main () {
    int N;
    scanf("%d",&N);
    solve(N);
}


Measured memory_bytes: 1680
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  for(int i=0;i<k;i++){
    int x,y;
    cin>>x>>y;
    if(n%2==0){
      if(x>n/2) x=n-x+1;
      if(y>n/2) y=n-y+1;
    }
    else{
      if(x>n/2+1) x=n-x+1;
      if(y>n/2+1) y=n-y+1;
    }
    if(y<x) x=y;
    if(x%3==0) cout<<3<<endl;
    else cout<<x%3<<endl;
  }
  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
ll res=1;
bool fl=1;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
	{
		ll x;
		cin >>x;
		if (!x)
		{
			fl=1;
			res=0;
			break;
		}
		//cout <<x<<" "<<(ll)1e18/res<<" ##\n";
		if (x>(ll)1e18/res) fl=0;
		else res*=x;
	}
	cout <<(fl ? res : -1);
	return 0;
}

Measured memory_bytes: 3676
#include<stdio.h>
int main()
{
    long long int N,i,w=0;
    scanf("%lld",&N);
    for(i=1;i<=N;i++){
        if(i%3!=0 && i%5!=0){
            w+=i;
        }

    }
    printf("%lld\n",w);

return 0;


}


Measured memory_bytes: 1728
#include<stdio.h>
#include<stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *next;
    struct Node *prev;
};

struct Node *nil;

struct Node *listseach(int key)
{
    struct Node *cur=nil->next;
    while(cur!=nil && cur->key!=key){
        cur=cur->next;
    }
    return cur;
}

void init()
{
    nil=(struct Node *)malloc(sizeof(struct Node));
    nil->next=nil;
    nil->prev=nil;
}

void printlist(void)
{
    struct Node *cur=nil->next;
    int isf=0;
    while(1){
        if(cur==nil) break;
        if(isf++>0) printf(" ");
        printf("%d",cur->key);
        cur=cur->next;
    }
    printf("\n");
}

void delete(struct Node *t)
{
    if(t==nil) return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void deletefirst(void)
{
    delete(nil->next);
}

void deletelast(void)
{
    delete(nil->prev);
}

void deletekey(int key)
{
    //検索したノードの削除
    delete(listseach(key));
}

void insert(int key)
{
    struct Node *x=(struct Node*)malloc (sizeof(struct Node));
    x->key=key;

    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}

int main(){
    int key,n,i,size=0;
    char str[20];
    int np=0,nd=0;

    scanf("%d",&n);
    init();
    for(i=0;i<n;i++){
    scanf("%s%d",str,&key);
    if(str[0]=='i'){
        insert(key);
        np++;
        size++;
    }
    else if(str[0]=='d'){
        if(strlen(str)>6){
            if(str[6]=='F') deletefirst();
            if(str[6]=='L') deletelast();
        }else{
            deletekey(key);
            nd++;
        }
        size--;
        }
    }
    printlist();
    return 0;
}


Measured memory_bytes: 33112
void main()
{
    string s = rdStr;
    long k = rdElem;

    long len = s.length;
    string[] lists;
    foreach (i; 0 .. len)
    {
        foreach (j; 1 .. k+1)
        {
            if (i + j > len) break;
            lists ~= s[i..i+j];
        }
    }

    string[] dicts = lists.sort!"a < b".uniq.array;

    dicts[k-1].writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 2812
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
LP p[200001];

bool comp(LP &lhs, LP &rhs)
{
    if(lhs.se < rhs.se) return true;
    if(lhs.se == rhs.se){
        return lhs.fi < rhs.fi;
    }
    return false;
}

void solve()
{
    sort(p, p+N, comp);
    ll t = 0;
    bool ok = true;
    REP(i, N){
        if(t+p[i].fi > p[i].se){
            ok = false;
            break;
        }
        t += p[i].fi;
    }
    cout << (ok ? "Yes" : "No") << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> p[i].fi >> p[i].se;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;
  scanf("%d", &n);
  vector<bitset<10> > v;
  REP (i, n) {
    string nums;
    REP(j, 10) {
      string a;
      cin >> a;
      nums += a;
    }
    v.push_back(bitset<10>(nums));
  }

  vector<vector<int> > p;
  REP (i, n) {
    int a;
    vector<int> tmp;
    REP (j, 11) {
      scanf("%d", &a);
      tmp.push_back(a);
    }
    p.push_back(tmp);
  }

  int ans = INT_MIN;
  FOR (i, 1, 2 << 9) {
    int sum = 0;
    REP (j, n) {
      int b = (v[j] & bitset<10>(i)).count();
      sum += p[j][b];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    bool ans = true;
    set<string> words;
    char prev;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        ans &= not words.count(s) and (i == 0 or s[0] == prev);
        words.insert(s);
        prev = s.back();
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
/*#include<iostream>
using namespace std;
int main(){
	int a,b,c,k,ans=-1;
	cin>>a>>b>>c>>k;
	int s=1,n=1,p=1;
	int aa=a,bb=b,cc=c;
	for(int i=0;i<k;i++){
		for(int f=0;f<i;f++)s*=2;
		aa*=s;
		for(int j=0;j<k-i;j++){
			for(int f2=0;f2<j;f2++)n*=2;
			bb*=n;
			for(int x=0;x<k-j;x++){
				for(int f3=0;f3<x;f3++)p*=2;
				cc*=p;
				//cout<<aa<<" "<<bb<<" "<<cc<<endl;;
				ans=max(ans,aa+bb+cc);
				p=1;
				cc=c;
			}
			n=1;
			bb=b;
		}
		s=1;
		aa=a;
	}
	cout<<ans<<endl;
}*/
#include<iostream>
using namespace std;
int main(){
	int h,w;
	char s[55][55];
	int a[55][55]={0};
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s[i][j];
			
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				if(s[i+1][j]=='#'){
					a[i+1][j]=1;
					a[i][j]=1;
				}
				if(s[i][j+1]=='#'){
					a[i][j+1]=1;
					a[i][j]=1;
				}
				if(s[i-1][j]=='#'){
					a[i-1][j]=1;
					a[i][j]=1;
				}
				if(s[i][j-1]=='#'){
					a[i][j-1]=1;
					a[i][j]=1;
				}
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='#'){
				if(a[i][j]!=1){
					cout<<"No"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int top = 0, stack[1000];

void push(int n){
    stack[++top] = n;
}

int pop(){
    top--;
    return stack[top+1];
}

int main(int argc, char* argv[]) {
    char s[100];
    int a, b;
    while (scanf("%s", s) != EOF){
        if (s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if (s[0] == '-'){
            a = pop();
            b = pop();
            push(b-a);
        }else if (s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else push(atoi(s));
    }
    cout << pop() << endl;
    return 0;
}



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

int main() {
  string s;
  cin >> s;
  cout << ( s=="AKIHABARA" or s=="AKIHABAR" or s=="AKIHABRA" or s=="AKIHBARA" or s=="KIHABARA" or s=="AKIHABR" or s=="AKIHBAR" or s=="KIHABAR" or s=="AKIHBRA" or s=="KIHABRA" or s=="KIHBARA" or s=="AKIHBR" or s=="KIHABR" or s=="KIHBAR" or s=="KIHBRA" or s=="KIHBR" ?"YES" :"NO") << "\n";

}

Measured memory_bytes: 256
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 
 
void Fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
}
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=1e9 + 7; 
const int N=3e3 + 1;
int dp[N][N];
ll OO=1e12; 
 
ll n,m,k,cnt,SU,idx,len,MN,MX,T;
ll l,r,mid;
ll a,b,c,d;

string str,s,ans;

int Solve(int x,int y){
	
	if(x == SZ(str) || y == SZ(s))
		return 0;
		
	int &ret=dp[x][y];
	if(~ret)
		return ret;

	if(str[x] == s[y])
		return ret = 1 + Solve(x+1,y+1);
	
	ret = 0;
	ret = max(ret,Solve(x,y+1));
	ret = max(ret,Solve(x+1,y));
	
	return ret;
		
	
}

void Output(int x,int y){
	
	if(x == SZ(str) || y == SZ(s))
		return;
	
	if(str[x] == s[y]){
		ans+=str[x];
		Output(x+1,y+1);
		return;
	}
	
	int a=Solve(x,y+1);
	int b=Solve(x+1,y);
	
	int val=Solve(x,y);
	
	
	if(val == a)
		Output(x,y+1);
	else
		Output(x+1,y);
	
		
	
}


 
 
int main(){
	Fast();
	
	getline(cin,str);
	getline(cin,s);
		
	memset(dp,-1,sizeof dp);
		
	Solve(0,0);
	Output(0,0);
	cout<<ans<<endl;

	

}

Measured memory_bytes: 35840
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int n;
vector<char> a;

void rec(int x, int m) {
    if (x == n) {
        for (int i = 0; i < n; ++i) {
            cout << a[i];
        }
        cout << "\n";
        return;
    }
    for (int i = 0; i <= m; ++i) {
        a[x] = 'a' + i;
        rec(x + 1, max(i + 1, m));
    }
}

int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif
    while (cin >> n) {
        a.resize(n);
        rec(0, 0);
    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll dp[105][4][4][4];

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

  dp[0][3][3][3]=1;
  for (int i=0; i<N; i++) {
    for (int c1=0; c1<4; c1++) { 
      for (int c2=0; c2<4; c2++) {
	for (int c3=0; c3<4; c3++) {
	  for (int a=0; a<4; a++) {
	    if (c2==0&&c1==1&&a==2
		||c3==0&&c1==1&&a==2
		||c2==1&&c1==0&&a==2
		||c2==0&&c1==2&&a==1
		||c3==0&&c2==1&&a==2) continue;
	    dp[i+1][c2][c1][a]+=dp[i][c3][c2][c1];
	    dp[i+1][c2][c1][a]%=1000000007;
	  }
	}
      }
    }
  }
  ll ans=0;
  for (int c3=0; c3<4; c3++) {
    for (int c2=0; c2<4; c2++) {
      for (int c1=0; c1<4; c1++) {
	ans+=dp[N][c3][c2][c1];
        ans%=1000000007;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,m,s,i,j,t,flag=0;
    scanf("%d%d%d",&n,&m,&s);
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            t=i*m+j*n-2*i*j;
            //printf("%d %d %d\n",i,j,t);
            if(t==s)
            flag=1;
        }
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    string target = "CODEFESTIVAL2016";
    string s;
    cin >> s;

    int ans = 0;
    REP(i,16) {
        if (s[i] != target[i])ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair



const  ll modo=1e9+7;

class ppo
{
    public:
    int l=0;
    int r=0;
    int u=0;
    int d=0;
};


int main()
{
    faf;
    int h,w;
    cin>>h>>w;
    ppo dp[h+4][w+4];
    char ar[h][w];
    int i;
    int j;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)cin>>ar[i][j];
    }
    
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(ar[i][j]=='.')
            {
                if(j>0)
                {
                    dp[i][j].l=1+dp[i][j-1].l;
                }
                else dp[i][j].l=1;
            }
        }
    }
    for(i=0;i<h;i++)
    {
        for(j=w-1;j>=0;j--)
        {
            if(ar[i][j]=='.')dp[i][j].r=1+dp[i][j+1].r;
        }
    }
    
    for(j=0;j<w;j++)
    {
        for(i=0;i<h;i++)
        {
            if(ar[i][j]=='.'){
            if(i>0)
            {
                dp[i][j].u=1+dp[i-1][j].u;
            }
            else dp[i][j].u=1;
            }
        }
    }
    
    for(j=0;j<w;j++)
    {
        for(i=h-1;i>=0;i--)
        {
            if(ar[i][j]=='.')dp[i][j].d=1+dp[i+1][j].d;
        }
    }
    int ans=0;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(ar[i][j]=='.')
            {
                ans=max(ans,dp[i][j].l+dp[i][j].r+dp[i][j].u+dp[i][j].d-3);
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 66944
fun main(args: Array<String>) {
    val (N, x) = readLine()!!.split(" ").map {it.toLong()}
    val a = readLine()!!.split(" ").map{it.toLong()}.toLongArray()

    var res = 0L
    for (i in 1 until a.size) {
        if (a[i - 1] + a[i] > x) {
            val l = a[i - 1] + a[i] - x
            res += l
            a[i] = Math.max(0L, a[i] - l)
        }
    }

    println(res)
}

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

#if DEBUG && !ONLINE_JUDGE
    #include "header.h"
#else
    #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
    return;
}
int dp[100004];
int n;
vi ar;
bool solve(int K) {
    if(K<0) {
        return false;
    }
    if(dp[K] != -1) return dp[K];
    //debug(K);
    bool ans = false;
    rep(j,0,n) {
        ans = ans | solve(K-ar[j]);
    }
    //debug(K, !ans);
    //debug(K, false);
    if(ans == false) return dp[K] = 1;
    else return dp[K] = 0;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preprocess();
    cin>>n;
    int k; cin>>k;
    memset(dp,-1,sizeof dp);
    ar.resize(n);
    rep(i,0,n) cin>>ar[i];
    bool ans = false;
    rep(i,0,n) {
        ans = ans | solve(k-ar[i]);
    }
    debug("AA");
    if(ans == true) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}



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

int main() {
	int n;cin >>n;
	vector<long long> v;
	for(int i=0;i<n;++i){
		long long a;cin >> a;
		if(a==0){
			cout << 0 << endl;
			return 0;
		}
		v.push_back(a);
	}
	long long out = 1LL;
	for (int j=0; j<v.size();++j){
    if(v[j]<=1000000000000000000/out){
      out *= v[j];
    } else{
      out = -1;
      break;
    }
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 4324
program abc166b
      implicit none
      integer::n,k
      integer,allocatable::a(:),sunuke(:)
      integer::i,j,d,count

         read *, n,k
         allocate(a(n),sunuke(n))

         sunuke=0;a=0
         do i=1,k
            read *, d
            read *, a(1:d)
            do j=1,d
               sunuke(a(j))=sunuke(a(j))+1
            end do
         end do

         count=0
         do i=1,n
            if (sunuke(i)==0) count=count+1
         end do

         print *, count

   end program abc166b

Measured memory_bytes: 2864
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 610
#define mdn 1000000007
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int f[N][N],g[N][N];
int n,a[N],b[N],fac[N],k;
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
bool in(int x,int l,int r){return x>=l&&x<=r;}
int main()
{
	n=read(),k=read(); fac[0]=1; int top=2*n;
	for(int i=1;i<=k;i++)	a[i]=read(),b[i]=read();
	for(int i=2;i<=2*n;i+=2)	fac[i]=1ll*fac[i-2]*(i-1)%mdn;
	for(int i=1;i<=top;i++)	for(int j=i+1;j<=top;j+=2)
	{
		int flag=1,tot=0;
		for(int w=1;w<=k;w++)
			flag&=(in(a[w],i,j)==in(b[w],i,j)),tot+=in(a[w],i,j)+in(b[w],i,j);
		if(!flag)	continue;
		g[i][j]=fac[j-i+1-tot]; g[j][i]=fac[top-2*k-j+i-1+tot];
	}
	int ans=0;
	for(int len=2;len<=2*n;len+=2)	for(int i=1;i+len-1<=top;i++)
	{
		int j=i+len-1; f[i][j]=g[i][j];
		for(int k=i+1;k<j;k+=2)	upd(f[i][j],mdn-1ll*f[i][k]*g[k+1][j]%mdn);
		upd(ans,1ll*f[i][j]*g[j][i]%mdn);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3072
using System;
using System.IO;
using System.Text.RegularExpressions;

namespace Atcoder1
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int a = int.Parse(inputs[0]);
            int b = int.Parse(inputs[1]);

            Console.WriteLine(a * b);

        }
    }
}

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

int main(){
    ll h, n;
    cin >> h >> n;
    int a;
    ll sum  = 0;
    for(int i=0; i<n; i++){
       cin >> a;
       h-=a;
    }
    if(h<=0)puts("Yes");
    else puts("No");

}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	int n; cin >> n;
	ll a[n];
	for(int i = 0; i < n; ++i) cin >> a[i];
	ll po = 0, ans = 1;
	for(int i = 1; i < n; ++i){
		if(!po){
			po = (a[i - 1] == a[i] ? 0 : (a[i - 1] < a[i] ? 1 : -1));
		}else if(po == 1 && a[i - 1] > a[i] || po == -1 && a[i - 1] < a[i]){
			++ans;
			po = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353
#define MAX 100000

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

using namespace std;

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

void solv(vvl &R, vl &T, ll parent, ll num, ll cnt) {
	cnt = T[num] += cnt;
	
	rep(i, R[num].size()) {
		if (R[num][i] == parent)continue;
		solv(R, T, num, R[num][i], cnt);
	}
}

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

	ll N, Q;
	cin >> N >> Q;

	vvl R(N);
	vl T(N, 0);

	ll A, B;

	rep(i, N-1) {
		cin >> A >> B;
		R[A-1].pb(B-1);
		R[B-1].pb(A-1);
	}

	rep(i, Q) {
		cin >> A >> B;
		T[A - 1] += B;
	}

	solv(R, T, -1, 0, 0);

	rep(i, N) {
		cout << T[i] << " ";
	}

	return 0;
}



Measured memory_bytes: 30592
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e;
    int f;
    int g;

    int w = a+c;
    int x = a+d;
    int y = b+c;
    int z = b+d;

    e = Math.min(w,x);
    f = Math.min(e,y);
    g = Math.min(f,z);
    System.out.println(g);
  }
}


Measured memory_bytes: 21716
#include <iostream>
using namespace std;
#include <algorithm>
int main(){
long long n,h;
cin >> n>>h;
long long a[n],b[n];
for(long long i=0;i<n;i++){
cin >> a[i]>>b[i];
}
sort(a,a+n);
sort(b,b+n);
long long max=a[n-1];
long long count=0;
int flag=1;
for(long long i=n-1;i>=0;i--){
if(h<=0){
break;
}
if(b[i]>max){
h=h-b[i];
count++;
}
else{
long long div=h/max;
if((h%max)!=0){
div++;
}
h=0;
count+=div;
break;
}
}
if(h>0){
long long div=h/max;
if((h%max)!=0){
div++;
}
count+=div;
}
cout <<count <<endl;
return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n))
typedef bitset<21> MASK;

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}
ll n,arr[22][22],dp[22][1<<21],mod=1e9+7;;

ll ans(int i,MASK mask){
//    cout<<i<<" ";
    if(i==n)return 1;
   ll &res=dp[i][mask.to_ulong()];
   if(~res)return res;
     res=0;
    for (int j = 0; j <n ; ++j) {
        if(arr[i][j]&&mask[j]){
            MASK t=mask;
            t[j]=0;
            res+=ans(i+1,t)%mod;
            res%=mod;
        }
    }
    return res;
}


int main() {
    fast();
    clr(dp,-1);
    MASK m;
    m.flip();
//    cout<<m.to_string();
    cin>>n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <n ; ++j) {
            cin>>arr[i][j];
        }
    }
    cout<<ans(0,m);


}


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

#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define repr(i, a, b) for (int i = (int)(a - 1); i >= b; i--)
#define rep(i, n) repl(i, 0, n)
#define each(itr, v) for (auto itr : v)
#define pb(s) push_back(s)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cout << #x " = " << x << endl
#define maxch(x, y) x = max(x, y)
#define minch(x, y) x = min(x, y)
#define uni(x) x.erase(unique(all(x)), x.end())
#define exist(x, y) (find(all(x), y) != x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX / 3

int main() {
  cin.sync_with_stdio(false);
  int p, q;
  cin >> p >> q;
  int t = q / __gcd(p, q);
  int ans = 1, i = 2, s = t;
  while (i < (int)sqrt(t) + 2) {
    if (s % i == 0) {
      while (s % i == 0) s /= i;
      ans *= i;
    }
    i++;
  }
  cout << ans * s << endl;
  return 0;
}



Measured memory_bytes: 3224
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String[] arr = sc.nextLine().split(" ");
			int len = Integer.valueOf(arr[0]);
			int n = arr.length-1;
			int[] r = new int[n];
			for(int i=0;i<n;i++) r[i] = Integer.valueOf(arr[i+1]);
			
			Integer[] a = new Integer[1<<n];
			for(int i=0;i<1<<n;i++) a[i] = i;
			Arrays.sort(a, new Comparator<Integer>(){
				public int compare(Integer o1, Integer o2) {
					String num1 = Integer.toBinaryString(o1);
					int cnt1 = 0;
					for(int i=0;i<num1.length();i++) if(num1.charAt(i)=='1') cnt1++;
					
					String num2 = Integer.toBinaryString(o2);
					int cnt2 = 0;
					for(int i=0;i<num2.length();i++) if(num2.charAt(i)=='1') cnt2++;
					
					return cnt1-cnt2;
				}
			});
			
			
			double[][] dp = new double[1<<n][n];
			for(int i=0;i<1<<n;i++){
				for(int j=0;j<n;j++){
					dp[i][j] = Double.MAX_VALUE;
				}
			}
			for(int i=0;i<1<<n;i++){
				for(int j=0;j<n;j++){
					if(i==0){
						dp[1<<j][j] = r[j]*2;
					}else if((a[i]>>j&1)==1){
						for(int k=0;k<n;k++){
							if((a[i]>>k&1)==0){
								double tmp = dp[a[i]][j] - r[j] + r[k] + Math.sqrt((r[j]+r[k])*(r[j]+r[k]) - (r[j]-r[k])*(r[j]-r[k]));
								int id = a[i] + (1<<k);
								dp[id][k] = Math.min(dp[id][k], tmp);
							}
						}
					}
				}
			}
		
			double min = Double.MAX_VALUE;
			for(int i=0;i<n;i++){
				min = Math.min(min, dp[(1<<n)-1][i]);
			}
			
			if(min<=len) System.out.println("OK");
			else System.out.println("NA");
		}
	}
}

Measured memory_bytes: 137964
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n,k;
  cin>>n>>k;
  vecint ary(n);
  REP(i,n) cin>>ary[i];
  sort(ALL(ary));
  int mn = 1000000000;
  REP(i,n-k+1) {
    mn = min(mn, ary[i+k-1]-ary[i]);
  }
  cout<<mn<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
    int n,m;
    std::cin >> n>>m;
    std::vector<int> x(m),y(m);
    rep(i,m){
        std::cin >> x[i]>>y[i];
        x[i]--;y[i]--;
    }
    std::vector<bool> han(n,0);
    std::vector<int> ko(n,1);
    han[0]=1;
    rep(i,m){
        ko[y[i]]++;
        if(han[x[i]])han[y[i]]=1;
        ko[x[i]]--;
        if(ko[x[i]]==0)han[x[i]]=0;
        
    }
    int ans=0;
    rep(i,n)if(han[i])ans++;
    std::cout << ans << std::endl;
    
    
}

Measured memory_bytes: 1408