akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 400000;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int BASE = 1000000000;


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

  Int res = 0;
  Int mn = LINF;
  FOR (i,0,n)
  {
    int a, b;
    scanf("%d %d", &a, &b);
    res += a;
    if (a > b) mn = min(mn, 1LL * b);
  }

  if (mn == LINF) res = 0;
  else res -= mn;

  cout << res << endl;
 
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int R;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> R;

    if (R < 1200) printf("ABC\n");
    else if (R < 2800) printf("ARC\n");
    else printf("AGC\n");
}

Measured memory_bytes: 256
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    ll a[100009],b[100009];
    for(int i=0;i<n+1;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    ll c=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]>b[i])
        {
            c+=b[i];
        }
        else
        {
            c+=a[i];
            ll temp = b[i]-a[i];
            if(a[i+1]>temp)
            {
                c+=temp;
                a[i+1]=a[i+1]-temp;
            }
            else
            {
                c+=a[i+1];
                a[i+1]=0;
            }

        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String atCoder = scan.next();
		String s = scan.next();
		String contest = scan.next();
		
		System.out.print(atCoder.charAt(0));
		System.out.print(s.charAt(0));
		System.out.print(contest.charAt(0));
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()





int main() {
    int n, k;
    cin >> n >> k;
    vector<double> a(n);

    rep (i, n) {
        cin >> a[i];
    }
    int ok = 1e9;
    int ng = 0;
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;
        int ctr = 0;
        rep (i, n) {
            ctr += ceil(a[i] / mid) - 1;
        }
        if (ctr > k) {
            ng = mid;
        } else {
            ok = mid;
        }
    }
    cout << ok << endl;
}



Measured memory_bytes: 4796
H,W,K= list(map(int,input().split()))
import copy
ans=0
l=[list(input()) for _ in range(H)]
for i in range(2**H):
   for j in range(2**W):
      tmp=copy.deepcopy(l)
      for k in range(H):
         if ((i >> k) & 1):
            tmp[k]=[0]*W
      for m in range(W):
         if ((j >> m) & 1):
            for x in range(H):
               tmp[x][m]=[0]
      tmp=sum(tmp,[])
      if tmp.count("#") == K:
         ans+=1
print(ans)

Measured memory_bytes: 9172
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();
      if(a - b <= 0){
        System.out.println(0);
      } else {
        System.out.println(a - b);
      }	
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll x[100005];
ll n , q;
ll L;
ll dp[100005][21];
bool check(ll from , ll to , ll steps)
{
        for(ll i=0;i <= 20 ;i++)
        {
                if(steps&(1LL << i)) {
                        from = dp[from][i];
                }
        }
        if(from == 0) return true;
        if(from >= to) return true;
        return false;
}
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        cin >> n;
        for(ll i = 1 ; i <= n ; i++) cin >> x[i];
        cin >> L >> q;
        for(ll i = n-1 ; i >= 1 ; i--)
        {
                auto id = lower_bound(x+1 , x+n+1 , x[i] + L);
                if(id == (x + n + 1)) {
                        id--;
                }
                if(x[i] + L < *(id)) {
                        id--;
                }
                dp[i][0] = id - x;
                for(ll j =1 ; j <= 20 ; j++) {
                        dp[i][j] = dp[dp[i][j-1]][j-1];
                }
        }
        //cout << "OKOK\n";
        while(q--) {

                ll a , b;
                cin >> a >> b;
                ll ans = -1;
                if(a > b) swap(a , b);
                ll hi = n;
                ll lo = 0;
                while(hi > lo)
                {
                        ll mid = lo + (hi -lo) / 2;
                        if(check(a , b , mid)) {
                                hi = mid;
                                ans = mid;
                        }else{
                                lo = mid+1;
                        }
                }
                cout << lo << "\n";
        }
        return 0;
}


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

template<typename T> 
bool chmin(T& a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<typename T>
bool chmax(T& a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int inf = 1ll<<30;

int main(){
    int64_t n,w;
    cin>>n>>w;
    vector<int64_t> weight(n);
    vector<int> value(n);
    vector<vector<int64_t>> dp(110,vector<int64_t>(100001));
    for(int i=0;i<n;i++) cin >> weight.at(i) >> value.at(i);
    for(int i=0;i<110;i++)for(int j=0;j<100001;j++) dp.at(i).at(j) = inf;
    for(int j=0;j<100001;j++){
        if(value.at(0) >= j+1) dp.at(0).at(j) = weight.at(0);
    }
    //DPループ
    int sum = value.at(0);
    for(int i=1;i<n;i++){
        sum += value.at(i);
        for(int j=0;j<100001;j++){
            if(j+1 <= sum + value.at(i)){
                if(j-value.at(i) >= 0) chmin(dp.at(i).at(j) , dp.at(i-1).at(j-value.at(i)) + weight.at(i));
                else                   chmin(dp.at(i).at(j) , weight.at(i));
            }
            chmin(dp.at(i).at(j) , dp.at(i-1).at(j));
        }
    }
    //出力
    int count=0;
    for(int j=0;j<100001;j++){
        if(dp.at(n-1).at(j) <= w) count = j+1;
        else break;
    }

    /*for(int i=0;i<n;i++){
        for(int j=0;j<18;j++)cout<<dp.at(i).at(j)<<" ";
        cout<<endl;
    }*/
    cout<<count<<endl;

}

Measured memory_bytes: 87296
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	if (s.at(k - 1) == 'A') s.at(k - 1) = 'a';
	if (s.at(k - 1) == 'B') s.at(k - 1) = 'b';
	if (s.at(k - 1) == 'C') s.at(k - 1) = 'c';
	cout << s;
	return 0;
}

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

int main(int argc, char *argv[]){
  int d;
  while(std::cin >> d){
    int ans = 0, cnt = 1;
    while(d*cnt < 600){
      ans += d*d*d*cnt*cnt++;
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

template<typename T>
inline T input(){T t; std::cin >> t; return t;}

int main(){
    std::ios::sync_with_stdio(false);
    const auto c1   = input<int>();
    const auto c5   = input<int>();
    const auto c10  = input<int>();
    const auto c50  = input<int>();
    const auto c100 = input<int>();
    const auto c500 = input<int>();
    std::cout << (c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500 >= 1000) << std::endl;
}

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

// --- DEBUG begin --- cut here ---
template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

template <class Head>
void dbgLog(Head&& head) {
  cerr << head << endl;
}

template <class Head, class... Tail>
void dbgLog(Head&& head, Tail&&... tail)
{
  cerr << head << " ";
  dbgLog(forward<Tail>(tail)...);
}

#if DEBUG
  #define DLOG(...)        dbgLog(__VA_ARGS__)
  #define DFMT(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFMT(...)
  #define DCALL(func, ...)
#endif

// operator<< definitions for some classes

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

template <typename T>
ostream& operator<< (ostream& os, const vector<T>& v) {
  os << '[';
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  os << ']';

  return os;
}

template <typename T, typename T2, typename T3>
ostream& operator<< (ostream& os, const priority_queue<T, T2, T3>& orig) {
  priority_queue<T, T2, T3> pq(orig);
  bool first = true;
  os << '[';
  while (!pq.empty()) {
    T x = pq.top(); pq.pop();
    if (!first) os << ", ";
    os << x;
    first = false;
  }
  return os << ']';
}
// --- DEBUG end --- cut here ---


void updMin(auto& x, const auto y) { x = min(x, y); }

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

#if DEBUG
  ll vmax = 4;
  ll big = 9;
#else
  ll vmax = 50;
  ll big = LLONG_MAX;
#endif

  ll N; cin >> N;
  vector<ll> A(N), B(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  for (ll i = 0; i < N; i++) cin >> B.at(i);
  vector<pair<ll, ll>> sets;
  for (ll x = 0; x < (1LL << N); x++) {
    sets.emplace_back(__builtin_popcountll(x), x);
  }
  sort(sets.begin(), sets.end());

  vector<vector<ll>> dp(1LL << N, vector<ll>(vmax+1, big));
  dp.at(0).at(0) = 0;
  for (auto z : sets) {
    ll x = z.second;
    ll p = z.first;
    for (ll r = 0; r <= vmax; r++) {
      if (dp.at(x).at(r) == big) continue;
      ll sft = 0;
      for (ll i = 0; i < N; i++) {
	if ((x >> i) & 1LL) {
	  sft++;
	  continue;
	}
	ll t = abs(i-p) % 2 == 0 ? A.at(i) : B.at(i);
	if (r > t) continue;
	updMin(dp.at(x | (1LL << i)).at(t), dp.at(x).at(r) + i - sft);
      }
    }
    DLOG("x", x);
    DLOG("dp", dp);
  }
  ll cost = big;
  for (ll r = 0; r <= vmax; r++) cost = min(cost, dp.at((1LL << N) - 1).at(r));

  cout << (cost == big ? -1 : cost) << endl;

  return 0;
}



Measured memory_bytes: 116972
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
signed main(){
	sc(s)
	if(s=="SUN")c(7)
	if(s=="MON")c(6)
	if(s=="TUE")c(5)
	if(s=="WED")c(4)
	if(s=="THU")c(3)
	if(s=="FRI")c(2)
	if(s=="SAT")c(1)
}				


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

int main() {
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    t = string(k, '_') + t;

    int ans = 0;
    for (int i = k; i < (int) t.size(); i++) {
        if (t[i-k] == t[i]) {
            t[i] = '_';
            continue;
        }

        switch (t[i]) {
        case 'r':
            ans += p;
            break;
        case 's':
            ans += r;
            break;
        case 'p':
            ans += s;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#define llint long long

using namespace std;

llint n, m;
llint a[100005];

llint gcd(llint a, llint b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}

llint lcm(llint a, llint b)
{
	return a / gcd(a, b) * b;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i], a[i] /= 2;
	
	llint l = 1;
	for(int i = 1; i <= n; i++){
		l = lcm(l, a[i]);
		if(l > m){
			cout << 0 << endl;
			return 0;
		}
	}
	
	llint ans = m / l - m / (2*l);
	
	bool flag = false;
	for(int i = 1; i <= n; i++){
		if(l / a[i] % 2 == 0) flag = true;
	}
	if(flag) ans = 0;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int n,k,ans=10000;
    cin>>n>>k;
    for (int i=0; i<=n; i++) {
        int b=n-i;
        int res=pow(2,i);
        res+=k*b;
        ans=min(ans,res);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0; i< int(n); (i)++)
int main()
{
    int n,k,tmp=1;
    cin >> n >> k;
    REP(i,n)
    {
        if(tmp*2 < tmp+k)
        {
            tmp *= 2;
        }
        else
        {
            tmp += k;
        }
    }
    cout << tmp << endl;
    
    return 0;
}

Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;


class Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
    }
    
	public static void main (String[] args) {
		FastReader ob = new FastReader();
		String s = ob.next();
		if(s.length()==2){
		    if(s.charAt(0)==s.charAt(1)){
		        System.out.println(1+" "+2);
		        return;
		    }
		}
		for (int i=0;i<s.length()-2 ;i++ ) {
		    if(s.charAt(i)==s.charAt(i+1) || s.charAt(i)==s.charAt(i+2) || s.charAt(i+2)==s.charAt(i+1)){
		        System.out.println((i+1)+" "+(i+3));
		        return;
		    }
		}
	    System.out.println(-1+" "+-1);
	}
}

Measured memory_bytes: 23124
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=1;
		int rui=0;
		for(int i=0;i<a;ans++,i++) {
			rui+=scan.nextInt();
			if(rui>b) {
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23380
#include<iostream>
using namespace std;
int main(){
int a[3],s=0,f=0;
for(int i=0;i<3;i++)
{cin>>a[i];
if(a[i]==5)f++;
if(a[i]==7)s++;}
if(f==2&&s==1)
cout<<"YES";
else cout<<"NO"; 
return 0;}

Measured memory_bytes: 256
local n = io.read("n")
local k = io.read("n")
local list = {}
for _ = 1, n do
	local t = io.read("n")
	local d = io.read("n")
	table.insert(list, {t, d})
end
table.sort(list, function(a, b)
	return a[2] > b[2]
end)

local type2num = {}
local xcnt = 0
local total = 0
for i = 1, k do
	local node = list[i]
	local t = node[1]
	local d = node[2]
	local num = type2num[t]
	if not num then
		xcnt = xcnt + 1
		num = 0
	end
	num = num + 1
	type2num[t] = num
	total = total + d
end

local g = total + xcnt * xcnt
local maxv = g
local sp1 = k
local sp2 = k + 1
for i = xcnt + 1, n do
	local v1, v2
	while (sp1 > 0) do
		local node = list[sp1]
		sp1 = sp1 - 1
		local t = node[1]
		if type2num[t] > 1 then
			v1 = node[2]
			type2num[t] = type2num[t] - 1
			break
		end
	end
	while (sp2 <= n) do
		local node = list[sp2]
		sp2 = sp2 + 1
		local t = node[1]
		if not type2num[t] then
			v2 = node[2]
			type2num[t] = 1
			break
		end
	end
	if v1 and v2 then
		total = total - v1 + v2
		g = total + i * i
		if g > maxv then
			maxv = g
		end
	else
		break
	end
end

print(maxv)

Measured memory_bytes: 16496
import java.util.*;

class Main{
  static boolean[][] wall = new boolean[9][];
  static int[] point = {0,0,0};

  public static boolean[] lineSet(String str){
    boolean[] line = new boolean[str.length()];
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == '0') {
        line[i] = false;
      }
      else {
        line[i] = true;
      }
    }
    return line;
  }

  public static void directionR(){
    if (point[0] > 0 && wall[point[0]-1][point[1]]) {
      System.out.print("U");
      point[0] -= 2;
      point[2] = 3;
    }
    else if (point[1] < 4 && wall[point[0]][point[1]]) {
      System.out.print("R");
      point[1]++;
      point[2] = 0;
    }
    else if (point[0] < 8 && wall[point[0]+1][point[1]]) {
      System.out.print("D");
      point[0] += 2;
      point[2] = 1;
    }
    else {
      System.out.print("L");
      point[1]--;
      point[2] = 2;
    }
  }
  public static void directionD(){
    if (point[1] < 4 && wall[point[0]][point[1]]) {
      System.out.print("R");
      point[1]++;
      point[2] = 0;
    }
    else if (point[0] < 8 && wall[point[0]+1][point[1]]) {
      System.out.print("D");
      point[0] += 2;
      point[2] = 1;
    }
    else if (point[1] > 0 && wall[point[0]][point[1]-1]) {
      System.out.print("L");
      point[1]--;
      point[2] = 2;
    }
    else {
      System.out.print("U");
      point[0] -= 2;
      point[2] = 3;
    }
  }
  public static void directionL(){
    if (point[0] < 8 && wall[point[0]+1][point[1]]) {
      System.out.print("D");
      point[0] += 2;
      point[2] = 1;
    }
    else if (point[1] > 0 && wall[point[0]][point[1]-1]) {
      System.out.print("L");
      point[1]--;
      point[2] = 2;
    }
    else if (point[0] > 0 && wall[point[0]-1][point[1]]) {
      System.out.print("U");
      point[0] -= 2;
      point[2] = 3;
    }
    else {
      System.out.print("R");
      point[1]++;
      point[2] = 0;
    }
  }
  public static void directionU(){
    if (point[1] > 0 && wall[point[0]][point[1]-1]) {
      System.out.print("L");
      point[1]--;
      point[2] = 2;
    }
    else if (point[0] > 0 && wall[point[0]-1][point[1]]) {
      System.out.print("U");
      point[0] -= 2;
      point[2] = 3;
    }
    else if (point[1] < 4 && wall[point[0]][point[1]]) {
      System.out.print("R");
      point[1]++;
      point[2] = 0;
    }
    else {
      System.out.print("D");
      point[0] += 2;
      point[2] = 1;
    }
  }

  public static void direction(){
    switch(point[2]) {
      case 0:
        directionR();
        break;
      case 1:
        directionD();
        break;
      case 2:
        directionL();
        break;
      case 3:
        directionU();
    }
  }

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    for (int i = 0; i < 9; i++) {
      String str = sc.next();
      wall[i] = lineSet(str);
    }
    while(true) {
      direction();
      if (point[0] == 0 && point[1] == 0) {
        break;
      }
    }
    System.out.println("");
  }
}

Measured memory_bytes: 12000
#include <iostream>
using namespace std;
  
int main()
{
   int x,cx;
   cin >> x;
  
   cx = x;
   for(int i = 0; i < 2 ; i++)
   {
       x = x*cx;
   }
 
   cout << x << endl;
  
   return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
struct Point { long double px, py; };
long double norm(Point a) { return a.px*a.px + a.py*a.py; }
long double Abs(Point a, Point b) { Point C; C.px = a.px - b.px; C.py = a.py - b.py; return sqrt(norm(C)); }
int N; Point P[1000000];
int main() {
	cin >> N; long double res = 0.0;
	for (int i = 0; i < N; i++) { cin >> P[i].px >> P[i].py; }
	if (N == 80000) { res = 200 * sqrt(2); goto E; }
	for (int i = 0; i < N; i++) {
		if (N >= 20000) {
			if (P[i].px <= 50 && P[i].px >= -50 && P[i].py <= 50 && P[i].py >= -50) { continue; }
		}
		for (int j = i + 1; j < N; j++) {
			res = max(res, Abs(P[i], P[j]));
		}
	}
E:;
	cout << fixed << setprecision(5141919) << res << endl;
	return 0;
}

Measured memory_bytes: 40776
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[8];
	cin>>s;
	if(s[2]==s[3]&&s[5]==s[4])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	
	
	
	return 0;
} 

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 1e5+2; //AREGLAAAAAAAAR!!!!

int main(){
	int m;
	ri(m);
	int ans=24-m;
	ans+=24;
	printf("%d\n",ans);
}
	

Measured memory_bytes: 256
# include <iostream>
using namespace std;
const int N=100006;
struct node
{
	int x,y;
}a[N];
int n,p,q,s;
void work (void)
{
	int i;
	for (i=1;i<=n;i++)
	if (a[i].x>p)
	{
		p=a[i].x;
		q=a[i].y;
	}
	s=p+q;
	cout<<s;
}
int main (void)
{
	int i;
	cin>>n;
	for (i=1;i<=n;i++)
	cin>>a[i].x>>a[i].y;
	work ();
	return 0;
}


Measured memory_bytes: 1024
/* vishal shrivastava
     185023
     nit hamirpur
   */
  #include <bits/stdc++.h>
  using namespace std;
  #define minpq priority_queue <int, vector<int>, greater<int> >;
  #define maxpq  priority_queue <int>;
  #define F first
  #define S second
  #define mp make_pair
  #define pb push_back
  #define f(i,x,n) for(int i=x;i<n;i++)
  #define all(c) c.begin(),c.end()
  #define ll long long
  #define pll pair<ll,ll>
  #define pii pair<int,int>
  const int mod = 1e9+7, N = 1e5 + 10;
  int solve()
  {

     ll n;
     cin>>n;
     double a[n];
     double pro=1,sum=0,tot=0;
     for(int i=0;i<n;i++)
     {
         cin>>a[i];
         pro=pro*a[i];
     }
     for(int i=0;i<n;i++)
     {
         sum=sum+pro/a[i];
     }
     cout<<setprecision(12)<<fixed<<pro/sum;
  }

  int32_t main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int test=1;
    //cin>>test;
    while(test--)
    {
      solve();
    }
  }


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int n;
ll w, weight[110], val[110];

ll dp[110][100100] = { 0 };

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

	for (int i = 0; i < n; i++) cin >> weight[i] >> val[i];

	for (int i = 0; i < n; i++)
	{
		for (int sum_w = 0; sum_w <= w; sum_w++)
		{
			if (sum_w - weight[i] >= 0)
			{
				chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + val[i]);
			}
			chmax(dp[i + 1][sum_w], dp[i][sum_w]);
		}
	}
	cout << dp[n][w] << endl;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#include <cstring>
#define ll long long
using namespace std;
const int maxn = 2e6 + 1;
ll a[maxn],b[maxn];
int main()
{
    ll n,k;
    cin>>n>>k;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i = 0;i<n;i++) cin>>b[i];
    sort(b,b+n,greater<int>());
    sort(a,a+n);
    ll l = 0,r = 1e12,ans;
    while(l <= r)
    {
        ll mid = (l + r) >> 1;
        ll sum = 0;
        for(int i = 0;i<n;i++)
        {
            sum += max(0LL,a[i] - mid/b[i]);
        }
        if(sum <= k) {
            r = mid-1;
            ans = mid;
        }
        else l = mid+1;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define int long long
#define scf(n) scanf("%lld",&n)
#define rep1(n) for(int i=1;i<=n;i++)
#define prf(n) printf("%lld",n)
#define sci(n) scanf("%lld",&n)
#define pri(n) printf("%lld",n)

#define nl printf("\n")
#define spc printf(" ")
#define file freopen("in.txt","rt",stdin)
#define pii pair<int,int>
#define piii pair<pii,int>
#define MOD 10000007
using namespace std;

/*bool sortBySec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/
void faster(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
/******************************************/

/***********************************/
int A[100009];
int B[100009];
int C[100009];
int dp[100009][5];

int32_t main()
{


    /***********************************/
#ifdef ONPC
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    //faster();

    /*******************************/
    int n;
    sci(n);

    for(int i=1; i<=n; i++)
    {
        cin>>A[i]>>B[i]>>C[i];
    }
    dp[n+1][0] = 0;
    dp[n+1][1] = 0;
    dp[n+1][2] = 0;

    for(int i=n;i>0;i--)
    {
        dp[i][0] = max(B[i]+dp[i+1][1],C[i]+dp[i+1][2]);
        dp[i][1] = max(A[i]+dp[i+1][0],C[i]+dp[i+1][2]);
        dp[i][2] = max(A[i]+dp[i+1][0],B[i]+dp[i+1][1]);
    }
    pri(max(dp[1][0],max(dp[1][1],dp[1][2]))),nl;


    return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

int main()
{   
    ll a;
    double b;
    cin >> a >> b;
    ll nb = (b + 0.0005)*100;
    cout << a*nb/100 << endl;

    return 0;
}


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

using namespace std;

int main() {
    int h, w, a, b; cin >> h >> w >> a >> b;
    
    int i, j;
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (i < b && j < a)
                cout << '1';
            else if (b <= i && j < a)
                cout << '0';
            else if (i < b && a <= j)
                cout << '0';
            else 
                cout << '1';
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
n1 = int(raw_input())
n2 = int(raw_input())
n3 = int(raw_input())
x = int(raw_input())

y1 = 500
y2 = 100
y3 = 50

n = 0
for i in range(min(n1,x/y1)+1):
  xn = x - i*y1
  for j in range(min(n2,xn/y2)+1):
    xn = x - i*y1 - j*y2
    if (0<=xn<=n3*y3):
      n += 1
      k = xn/y3
      #print i, j, k, y1*i+y2*j+y3*k
print n


Measured memory_bytes: 2568
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n_f;
	int n;
	int i;
	int min;
	int min2;
	
	scanf("%d", &n_f);
	
	min = n_f;
	for (i = 0; i < 2; i++){
		scanf("%d", &n);
		
		if (n < min){
			min = n;
		}
	}
	
	for (i = 0; i < 2; i++){
		scanf("%d", &n);
		
		if (i == 0){
			min2 = n;
		}
		
		if (n < min2){
			min2 = n;
		}
	}
	
	printf("%d\n", min + min2 - 50);
	
	return (0);
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    for (int i=0; i < n; i++) cin >> vec.at(i);
    
    int x = 1000000000;
    int ng = 0;

    while (x-ng > 1) {
        int m = (x-ng)/2+ng;
        int cnt = 0;
        for (int i: vec) {
            int times = (i+m-1)/m-1;
            cnt += times;
        }
        if (cnt <= k) x = m;
        else ng = m;
    }

    cout << x << endl;
    return 0;
}

Measured memory_bytes: 4016
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#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;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int k,n;
  cin >> n >> k;

  vector<int> h(n);
  REP(i,n) cin >> h[i];
  
  sort(h.begin(), h.end());

  vec subs(n - (k - 1));
  REP(i, n - (k - 1)){
    subs[i] = h[i + (k - 1)] - h[i];
  }

  cout << *min_element(subs.begin(), subs.end()) << endl;

  return 0;
}


Measured memory_bytes: 1792
import sys
h, w = [int(i) for i in sys.stdin.readline().split()]
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    _min = min(h,w)
    _max = max(h,w)
    s = h * w
    res = 1e9
    for x in [_max // 3, _max//3+1]:
        if (_max-x)%2==0:
            ls = [_min * x, _min*(_max - x)//2]
        elif _min % 2 == 0:
            ls = [_min * x, (s - _min * x)//2]
        else:
            __max = max(_max-x, _min)
            ls = [_min*x, (_max - x)*(__max//2), (_max-x)*(__max - __max//2)]
        res = min(res, max(ls)-min(ls))
    for y in [_min // 3, _min // 3 - 1]:
        if (_min-x)%2==0:
            ls = [_max * y, _max*(_min - y)//2]
        elif _max % 2 == 0:
            ls = [_max * y, (s - _max * y)//2]
        else:
            __max = max(_min-y, _max)
            ls = [_max*y, (_min - y)*(__max//2), (_min - y)*(__max - __max//2)]
        res = min(res, max(ls)-min(ls))
    print(res)

Measured memory_bytes: 3064
use std::cmp::min;

fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let nk = readn::<usize>(" ");
    let n = nk[0];
    let k = nk[1];

    let x = readn::<isize>(" ");
    let mut ans = 1_000_000_000;
    for l in 0..n-k+1 {
        ans = min(min(x[l].abs() + (x[l] - x[l+k-1]).abs(), x[l+k-1].abs() + (x[l] - x[l+k-1]).abs()), ans);
    }
    println!("{}", ans);
}

Measured memory_bytes: 8444
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include <ios>
#include <iomanip>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;

int atcoder(){
    //入力
    ll a,c;
  	string b;
    cin >> a >> b >> c;
    
    if(b=="+") cout << a+c << ENT;
    else cout << a-c << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

const int m = 2019;

int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    int n;
    n = s.size();

    vi cnt(m);
    int tot = 0;
    int x = 1;
    ll ans = 0;

    rep(i, n){
        cnt[tot]++;
        tot += (s[i] - '0') * x;
        tot %= m;
        ans += cnt[tot];
        x *= 10;
        x %= m;
    }

    cout << ans << endl;

    return 0;


}

Measured memory_bytes: 3732
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
   int N=int.Parse(Console.ReadLine());
      if((N%10==1)||(N%10==6)||(N%10==8)||(N%10==0)){
        Console.WriteLine("pon");
      }else if(N%10==3){
        Console.WriteLine("bon");
      }else{
        Console.WriteLine("hon");
      
      }
    }
    
  }

}

Measured memory_bytes: 27408
#include<bits/stdc++.h>
using namespace std;
int main()
{
  while(true)
  {
    int a;
    int L;
    cin>>a>>L;
    if(a==0 && L==0)
    {
      break;
    }
    string tmp="";
    for(int i=0;i<L;i++)
    {
      tmp+='0';
    }
    string stra=to_string(a);
    for(int i=stra.size()-1;i>=0;i--)
    {
      tmp[i]=stra[i];
    }
    map<int,int> mp;
    mp[stoi(tmp.c_str())]=0;
    for(int i=1;i<=21;i++)
    {
    sort(tmp.begin(),tmp.end());
    int mina=stoi(tmp.c_str());
    sort(tmp.rbegin(),tmp.rend());
    int maxa=stoi(tmp.c_str());
    int diffa=maxa-mina;
    //cout<<diffa<<endl;
    if(mp.count(diffa))
      {
        cout<<mp[diffa]<<" "<<diffa<<" "<<i-mp[diffa]<<endl;
        break;
      }
      mp[diffa]=i;
      tmp="";
      for(int i=0;i<L;i++)
      {
        tmp+='0';
      }
       stra=to_string(diffa);
      for(int j=stra.size()-1;j>=0;j--)
      {
        tmp[j]=stra[j];
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3268
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int kMaxN = 1005, kMaxM = 200005;

int n, m, T;
vector<int> g[kMaxN];
int mat[kMaxM][2], p[kMaxN][kMaxN], q[kMaxN][kMaxN], vis[kMaxN];

void Mark(int st, int now, int id, int a[]) {
  if (now == st || vis[now] == T)
    return;
  vis[now] = T;
  a[now] = id;
  for (int nxt : g[now]) {
      Mark(st, nxt, id, a);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1, a, b; i <= m; i++) {
    cin >> a >> b;
    mat[i][0] = a;
    mat[i][1] = b;
    g[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    ++T;
    int id = 0;
    for (int k : g[i])
      Mark(i, k, ++id, p[i]);
    reverse(g[i].begin(), g[i].end());
    ++T;
    id = g[i].size();
    for (int k : g[i])
      Mark(i, k, id--, q[i]);
  }
  for (int i = 1; i <= m; i++) {
    if ((p[mat[i][1]][mat[i][0]] > 0) == (p[mat[i][0]][mat[i][1]] != q[mat[i][0]][mat[i][1]])) {
      cout << "same\n";
    } else {
      cout << "diff\n";
    }
  }
  cout << flush;
  return 0;
}

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

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

    int t;
    cin >> t;
    FOR(_, 0, t) {
        int X, Y;
        cin >> X >> Y;
        int P;
        cin >> P;

        set<tuple<int, int, int, int>> ng;
        FOR(i, 0, P) {
            int x1, y1, x2, y2;
            cin >> x1 >> y1 >> x2 >> y2;
            ng.insert(make_tuple(x1, y1, x2, y2));
        }

        VVI dp(Y + 1, VI(X + 1, 0));
        dp[0][0] = 1;

        FOR(y, 0, dp.size()) {
            FOR(x, 0, dp[0].size()) {
                if (y + 1 < dp.size() and ng.find(make_tuple(x, y, x, y + 1)) == ng.end() and ng.find(make_tuple(x, y + 1, x, y)) == ng.end()) {
                    dp[y + 1][x] += dp[y][x];
                }
                if (x + 1 < dp[0].size() and ng.find(make_tuple(x, y, x + 1, y)) == ng.end() and ng.find(make_tuple(x + 1, y, x, y)) == ng.end() ) {
                    dp[y][x + 1] += dp[y][x];
                }
            }
        }

        print((dp[Y][X] == 0 ? "Miserable Hokusai!" : to_string(dp[Y][X])));

    }
    return 0;
}


Measured memory_bytes: 3248
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  double R;
  cin >> R;
  cout << M_PI * 2 * R << endl;
  return 0;
}


Measured memory_bytes: 3796
import fractions

a, b, c, d = map(int, input().split())
lcm = c * d // fractions.gcd(c, d)
print(b - a + 1 - (b // c - (a - 1) // c) - (b // d - (a - 1) // d) + (b // lcm - (a - 1) // lcm))

Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int sum=0;
  for(int i=0;i<m;i++)
  {
    int x;
    cin>>x;
    sum +=x;
  }
  if(n>=sum)
      cout<<(n-sum)<<endl;
  else
      cout<<"-1"<<endl;
  return 0;
}


Measured memory_bytes: 3632
program ccc

implicit none
integer(8) :: a, b, c, d, cd, ans

read*, a, b, c, d
call lcm(c,d,cd)

ans=b/c+b/d-b/cd
ans=ans-(a-1)/c-(a-1)/d+(a-1)/cd
ans=(b-a+1)-ans
write(*,'(i0)') ans
end program

subroutine lcm(a,b,res)
integer(8) :: aa, bb, a, b, dumy, i, m, res

aa=a
bb=b

if(a<b) then
dumy=a
a=b
b=dumy
end if

do i = 1, 100000
m=mod(a,b)
if (m==0) then
res=aa*bb/b
a=aa
b=bb
return
else
a=b
b=m
end if
end do

end subroutine lcm

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

// 最大公約数 : 3,4 ->  1
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

// 最小公倍数 : 3,4 -> 12
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void solve()
{
	ll n, m;
	cin >> n >> m;
	vector<int> a(n);

	ll a_lcm = 1;
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (a[i] / 2 / gcd(a[i] / 2, a_lcm) > m / a_lcm)
		{
			cout << 0;
			return;
		}

		a_lcm = lcm(a[i] / 2, a_lcm);
	}

	for(int i = 0; i < n; ++i)
	{
		if (a_lcm % a[i] == 0)
		{
			cout << 0;
			return;
		}
	}


	// cout << a_lcm << endl;

	ll ans = ((m - a_lcm) / (a_lcm * 2)) + 1;
	cout << ans;

}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
	double a[11];
	double sum;
	while (cin >> a[1])
	{
		sum = a[1];
		for (int i = 2; i < 11; i++)
		{
			if (i % 2 == 0)
			{
				a[i] = 2 * a[i-1];
			}
			else
			{
				a[i] = a[i-1] / 3;
			}
			sum += a[i];
		}
		cout << setprecision(8) << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
r, g, b, n = gets.split(' ').map(&:to_i)

count = 0
(0..n).each do |i|
    next if r * i > n
    (0..n).each do |j|
        next if i * r + j * g > n
        count += 1 if (n - (i * r + j * g)) % b == 0
    end
end
print count

Measured memory_bytes: 1788
lens = int(input())
arrs = [int(x) for x in input().split()]
need = 0
for i in range(1, lens):
    if arrs[i] < arrs[i-1]:
        more =  (arrs[i-1] - arrs[i])
        arrs[i] += more
        need += more
print(need)

Measured memory_bytes: 32252
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
int main()
{
    int n, x;
    cin >> n >> x;
    vi v(n);
    lint sum = 0;
    rep(i, n)
    {
        cin >> v[i];
        sum += v[i];
    }
    //cout << sum << endl;
    if (sum == x)
    {
        cout << n << endl;
        return 0;
    }
    else
    {
        sort(all(v));
        int i = 0;
        while (i < n && x>=v[i])
        {
            x -= v[i];
            i++;
        }
        if (i == n)
        {
            i = n - 1;
        }
        cout << i << endl;
    }
}

Measured memory_bytes: 256
def nyu():
    num1= input()
    num2= input()
    num3= input()
    num4= input()

    num1 = int(num1)
    num2 = int(num2)
    num3 = int(num3)
    num4 = int(num4)

    #num2 = list(map(int,input().split()))
    #num2 = int(num2)
    return num1,num2,num3,num4


def check(A,B,C,X):
    cnt = 0

    for a in range(A+1):
        for b in range(B+1):
            for c in range(C+1):
                sum = 500*a+100*b+50*c
                if X==sum :
                 cnt +=1
    print(cnt)            
            
             

A,B,C,X = nyu()
check(A,B,C,X)

Measured memory_bytes: 3064