akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int s, a, b;
  cin >> s;
  
  a = s / 100;
  b = s % 100;
  
  if((1 <= a && a <= 12) && (1 <= b && b <= 12)){
    cout << "AMBIGUOUS" << endl;
  }
  
  else if(1 <= a && a <= 12){
    cout << "MMYY" << endl;
  }
  
  else if(1 <= b && b <= 12){
    cout << "YYMM" << endl;
  }
  
  else{
    cout << "NA" << endl;
  }
}


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

int main(int argc, char const *argv[]) {
    /* code */
    int n;
    std::cin >> n;
    int d;
    std::list<int> dList;
    while(std::cin >> d){
        dList.emplace_back(d);
    }
    dList.sort();
    dList.erase(std::unique(dList.begin(), dList.end()), dList.end());
    std::cout << dList.size() << " " << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
ll a[100005],l;
int n,x=-1;
int main(void){
    scanf("%d%lld",&n,&l);
    for(int i=0;i<n;i++){
        scanf("%lld",a+i);
    }
    for(int i=0;i<n-1;i++){
        if(a[i]+a[i+1]>=l){
            x=i+1;
            break;
        }
    }
    if(x!=-1){
        printf("Possible\n");
        for(int i=n-2;i>=x;i--)printf("%d\n",i+1);
        for(int i=0;i<x;i++)printf("%d\n",i+1);
    }else printf("Impossible\n");
}


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

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

typedef pair<int, int> P;

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

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

int H, W;
char grid[2001][2001];
int dpw[2001][2001];
int dph[2001][2001];

signed main() {
	cin >> H >> W;

	REP( i, H ) {
		int wcnt = 0;
		REP( j, W ) {
			cin >> grid[j][i];
			if( grid[j][i] == '.' ) {
				wcnt++;
				if( j == W - 1 ) {
					REP( k, wcnt ) {
						dpw[j - k][i] = wcnt;
					}
				}

			} else {
				REP( k, wcnt ) {
					dpw[j - k - 1][i] = wcnt;
				}
				wcnt = 0;
			}


		}
	}

	REP( i, W ) {
		int hcnt = 0;
		REP( j, H ) {
			if( grid[i][j] == '.' ) {
				hcnt++;
				if( j == H - 1 ) {
					REP( k, hcnt ) {
						dph[i][j - k] = hcnt;
					}
				}

			} else {
				REP( k, hcnt ) {
					dph[i][j - k - 1] = hcnt;
				}
				hcnt = 0;
			}
		}
	}

	int ans = 0;
	REP( i, H ) {
		REP( j, W ) {
			chmax( ans, dpw[j][i] + dph[j][i] );
		}
	}

	cout << ans - 1 << endl; 
}


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

int main(){
	int i = 0;
	string str;
	getline(cin,str);
	for(int i=0;i<(int)str.size();i++){
		if('a'<=str[i]&&str[i]<='z'){
			str[i]=str[i]-'a'+'A';
			//str[i]=toupper(str[i]);
		}else if('A'<=str[i]&&str[i]<='Z'){
			str[i]=str[i]-'A'+'a';
			//str[i]=tolower(str[i]);
		}
	}
	cout<<str<<endl;
	return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a[10],b[100],c=0,i,j,d=0;
    cin>>a[0]>>a[1]>>a[2];
    cin>>a[3]>>a[4]>>a[5];
    cin>>a[6]>>a[7]>>a[8];
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>b[i];
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<9; j++)
        {
            if(b[i]==a[j])
            {
                c++;
                a[j] = -1;
            }
        }
    }
    if(c<3)
    {
        cout<<"No";
    }
    else
    {
        if(a[0]==-1 && a[1]==-1 && a[2]==-1)
        {
            d++;
        }
        else if(a[3]==-1 && a[4]==-1 && a[5]==-1)
        {
            d++;
        }
        else if(a[6]==-1 && a[7]==-1 && a[8]==-1)
        {
            d++;
        }
        else if(a[0]==-1 && a[3]==-1 && a[6]==-1)
        {
            d++;
        }
        else if(a[1]==-1 && a[4]==-1 && a[7]==-1)
        {
            d++;
        }
        else if(a[2]==-1 && a[5]==-1 && a[8]==-1)
        {
            d++;
        }
        else if(a[0]==-1 && a[4]==-1 && a[8]==-1)
        {
            d++;
        }
        else if(a[2]==-1 && a[4]==-1 && a[6]==-1)
        {
            d++;
        }
        if(d==0)
        {
            cout<<"No";
        }
        else
        {
            cout<<"Yes";
        }
    }
}


Measured memory_bytes: 764
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (int i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=2e5+1;
const ld PI=acos(-1);

int main(){
    rapgame
    //freopen("brokeday.in", "r", stdin);
    //freopen("richday.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        read(n);
        cout << n*n;
    }
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ll h, w;
    cin >> h >> w;
    ll ans1 = ((h + 2) / 3) * w - (h - (h + 2) / 3) * (w / 2);
    ll ans2 = (h - h / 3) * ((w + 1) / 2) - (h / 3) * w;
    ll ans3 = h * ((w + 2) / 3) - (h / 2) * (w - (w + 2) / 3);
    ll ans4 = ((h + 1) / 2) * (w - w / 3) - h * (w / 3);
    ll ans5 = h * ((w + 2) / 3) - h * (w / 3);
    ll ans6 = ((h + 2) / 3) * w - (h / 3) * w;
    cout << min(min(min(ans1, ans2), min(ans3, ans4)), min(ans5, ans6)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
int a[100005];
signed main()
{
	int k;
	cin>>k;
	cin>>a[0];
	int ans=0,sna=-1;
	for (int i=1;i<=k;i++){
		if (i<k)  cin>>a[i];
		else  a[k]=1000000002;
		if (a[i]<=a[i-1])  ans++;
		else  sna=max(sna,ans),ans=0;
	}
	cout<<sna;
	re 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	char s[105];
	scanf("%[^\n]" ,s);
	for(int i = 0; i < s[i]; i++){
		if(s[i] == ','){
		printf(" ");
		}
		else{
			printf("%c" ,s[i]);
		}
	}
	return 0;
}

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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
//#define int long long
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define all(x) x.begin(), x.end()
using pii = pair<int, int>;
using ll = long long;

constexpr int MAX_L = 500;
string dp[50][600];
struct Edge {
    int to;
    string lab;
};
string maxs;
vector<Edge> G[50];

struct Data {
    string spe;
    int n, l;
    Data(string spe, int n, int l) : spe(spe), n(n), l(l) {}
    bool operator>(const Data &rhs) const {
        if (spe != rhs.spe)
            return spe > rhs.spe;
        else if (l != rhs.l)
            return l > rhs.l;
        else
            return n > rhs.n;
    }
};

bool solve() {
    int n, a, s, g;
    cin >> n >> a >> s >> g;
    if (n == 0) return false;
    // s--, a--;
    REP(i, n) {
        G[i].clear();
        REP(j, MAX_L + 1) dp[i][j] = '|';
    }
    REP(i, a) {
        int u, v;
        cin >> u >> v;
        string lab;
        cin >> lab;
        G[u].push_back({v, lab});
    }
    dp[s][0] = "";
    priority_queue<Data, vector<Data>, greater<Data>> que;
    que.push({"", s, 0});
    while (!que.empty()) {
        Data dat = que.top();
        que.pop();
        int n = dat.n;
        int l = dat.l;
        for (auto e : G[n]) {
            if (l + (int)e.lab.size() > MAX_L) continue;
            string res = dat.spe + e.lab;
            if (res < dp[e.to][(int)res.size()]) {
                dp[e.to][res.size()] = res;
                que.push({res, e.to, (int)res.size()});
            }
        }
    }
    string ans = "|";
    REP(l, MAX_L) { ans = min(ans, dp[g][l]); }
    if ((int)ans.size() > 6 * 39 || ans == "|") {
        ans = "NO";
    }
    cout << ans << endl;
    return true;
}

signed main() {
    REP(i, MAX_L + 1) maxs += 'z';
    while (solve())
        ;
}


Measured memory_bytes: 31288
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    last = [-1 for _ in range(2 * 10 ** 5 + 1)]
    dp = [INF for _ in range(n + 1)]
    dp[0] = 1

    d = [ni()-1 for _ in range(n)]

    for i, di in enumerate(d):
        dp[i + 1] = dp[i]
        if last[di] != -1:
            if i - last[di] != 1:
                dp[i + 1] += dp[last[di] + 1]
                dp[i + 1] %= MOD
        last[di] = i

    print(dp[n])


if __name__ == '__main__':
    main()


Measured memory_bytes: 26884
/*

Sviatoslav Bidzilia 2019
CF: anakib1

*/

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <functional>
#include <utility>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define inf 1e17
#define sz(a) (int)(a.size())
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long

template<typename A, typename B, typename C>
struct triple
{
	A X;
	B Y;
	C Z;
	triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0)
{
	return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b)
{
	if (a.X != b.X)
		return a.X < b.X;
	if (a.Y != b.Y)
		return a.Y < b.Y;
	return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p)
{
	ofs << "( " << p.F << " , " << p.S << " )";
	return ofs;
}
template<typename T>
void print(T a)
{
	for (auto i : a)
		cout << i << ' ';
	cout << '\n';
}
template<typename T>
T max(T a, T b, T c)
{
	return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c)
{
	return min(a, min(b, c));
}
struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
int dp[3001][6001][3];
const int mod = 998244353;
signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	srand(time(NULL));
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	int n, s; cin >> n >> s;
	vi a(n); rngi(i, n) cin >> a[i];
	dp[0][0][0] = 1;
	rngi(i, n) {
		rngi(t, s + 1) {
			(dp[i + 1][t][0] += dp[i][t][0]) %= mod;
			(dp[i + 1][t][1] += dp[i][t][0] + dp[i][t][1]) %= mod;
			(dp[i + 1][t][2] += dp[i][t][0] + dp[i][t][1] + dp[i][t][2]) %= mod;
			(dp[i + 1][t + a[i]][1] += dp[i][t][0] + dp[i][t][1]) %= mod;
			(dp[i + 1][t + a[i]][2] += dp[i][t][0] + dp[i][t][1]) %= mod;
		}
	}
	cout << dp[n][s][2] << '\n';
}

Measured memory_bytes: 421504
#include<stdio.h>
#include<stdlib.h>
int a[100005], b[100005];
int asc(const void* x, const void* y)
{
	if (a[*(int*)x] > a[*(int*)y])return 1;
	if (a[*(int*)x] < a[*(int*)y])return -1;
	return 0;
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	for (i = 0; i < n + m - 1; i++)
	{
		scanf("%d %d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
	}
	int c[100005];
	for (i = 0; i < n + m; i++)
		c[i] = i;
	qsort(c, n + m - 1, sizeof(int), asc);
	int in[100005];
	for (i = 0; i < n; i++)
		in[i] = 0;
	for (i = 0; i < n + m - 1; i++)
		in[b[i]]++;
	int q[100005], p = 0;
	int min, mid, max;
	int ans[100005];
	for (i = 0; i < n; i++)
	{
		if (in[i] == 0)
		{
			ans[i] = -1;
			q[p] = i;
			p++;
		}
	}
	int u;
	while (p > 0)
	{
		p--;
		u = q[p];
		min = 0;
		max = n + m - 1;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (a[c[mid]] < u)
				min = mid;
			else
				max = mid;
		}
		if (a[c[min]] != u)
			min++;
		if (min < n + m - 1)
		{
			while (a[c[min]] == u)
			{
				in[b[c[min]]]--;
				if (in[b[c[min]]] == 0)
				{
					ans[b[c[min]]] = u;
					q[p] = b[c[min]];
					p++;
				}
				min++;
				if (min == n + m - 1)
					break;
			}
		}
	}
	for (i = 0; i < n; i++)
		printf("%d\n", ans[i] + 1);
	return 0;
}

Measured memory_bytes: 3128
n,k = map(int,input().split())
l = []
for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in a:
        l.append(j)
ans = 0
for i in range(n):
    if i + 1 not in l:
        ans += 1
print(ans)


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

int main() {
  int n;
  int64_t L;
  cin >> n >> L;
  vector<vector<int>> nxt(1, vector<int>(2, -1));
  vector<int> dep(1, 0);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int j = 0, x = 0; j < s.size(); ++j) {
      if (nxt[x][s[j] - '0'] == -1) {
        nxt[x][s[j] - '0'] = nxt.size();
        nxt.emplace_back(2, -1);
        dep.emplace_back(dep[x] + 1);
      }
      x = nxt[x][s[j] - '0'];
    }
  }
  int64_t res = 0;

  auto Grundy = [&](int64_t v) {
    if (v == 0) return 0LL;
    for (int i = 60; i >= 0; --i) {
      if (v % (1LL << i) == 0) return 1LL << i;
    }
  };

  for (int i = 0; i < nxt.size(); ++i) {
    if (nxt[i][0] == -1) res ^= Grundy(L - dep[i]);
    if (nxt[i][1] == -1) res ^= Grundy(L - dep[i]);
  }
  cout << (res > 0 ? "Alice" : "Bob") << "\n";
}


Measured memory_bytes: 6964
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

lol lcm(lol x,lol y){

  lol a = x * y;
  if(x < y){
    swap(x, y);
  }

  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }

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

    lol a, b, c, d;
    cin >> a >> b >> c >> d;
    a --;
    lol l = lcm(c, d);
    // cout << l << " ";
    cout << (b - a) - (b / c - a / c) - (b / d - a / d) + (b / l - a / l) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char o[2][51];
  scanf("%s%*c%s",o[0],o[1]);
    int i,olen=strlen(o[0]),elen=strlen(o[1]);
  for(i=0;i<olen;i++){
    printf("%c",o[0][i]);
    if(i!=elen)
      printf("%c",o[1][i]);
  }
  puts("");
  return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, k;
int a[N];

bool check(int x)
{
	int reqd = 0;
	for(int i = 1; i + 1 <= n; i++)
	{
		int diff = a[i + 1] - a[i];
		reqd += (diff - 1) / x;
		if(reqd > k)
			return 0;
	}
	return 1;
}

int binsearch(int lo, int hi)
{
	while(lo < hi)
	{
		int mid = (lo + hi) / 2;
		if(check(mid))
			hi = mid;
		else
			lo = mid + 1;
	}
	return lo;
}

int32_t main()
{
	IOS;
	{
		cin >> n >> k;
		a[1]=0;
		for(int i=1; i<=n; ++i)
			cin>>a[i+1];

		for(int i=1;i<=n;i++)
			a[i+1]+=a[i];
		n++;
		int ans = binsearch(1, 1e18);
		cout << ans << endl;
 	}	
	return 0;
}

Measured memory_bytes: 5060
H, W = map(int, input().split())
S = []
for i in range(H):
  ss = input()
  S.append(ss)
UF = list(range(H*W))
def par(m):
  if UF[m] == m:
    return m
  r = par(UF[m])
  UF[m] = r
  return r
def unite(m, n):
  i = par(m)
  j = par(n)
  UF[i] = j
for i in range(H):
  for j in range(W):
    if i+1 < H and S[i][j] != S[i+1][j]:
      unite(i*W+j, (i+1)*W+j)
    if j+1 < W and S[i][j] != S[i][j+1]:
      unite(i*W+j, i*W+j+1)
nsb = [0]*(H*W)
nsw = [0]*(H*W)
for i in range(H):
  for j in range(W):
    p = par(i*W+j)
    if S[i][j] == "#":
      nsb[p] += 1
    if S[i][j] == ".":
      nsw[p] += 1
r = 0
for p in range(H*W):
  r += nsb[p]*nsw[p]
print(r)
#  print(UF[i*W:(i+1)*W])


Measured memory_bytes: 12404
h, n = [int(i) for i in input().split()]
a, b = [0]*n, [0]*n

eff = 0
eff_index = 0
for i in range(n):
    a[i], b[i] = [int(_) for _ in input().split()]

max_a = max(a)

ans = float('inf')
H = h + max_a
dp = [float('inf')] * (H+1)
# dp[i] iのダメージを与える最小消費魔力
dp[0] = 0
for i in range(H+1):
    for j in range(n):
        if i >= a[j]:
            dp[i] = min(dp[i], dp[i-a[j]]+b[j])

    if i >= h:
        ans = min(ans, dp[i])
print(ans)

Measured memory_bytes: 43612
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Point[] arr = new Point[n];
		int zero = 0;
		for(int i=0;i<n;i++){
			
			arr[i] = new Point(sc.nextInt(), sc.nextInt(), sc.nextInt());
			
			if(arr[i].h==0)
			    zero++;
		}
		
		/*if(zero==n){
		    System.out.println("0 0 1");
		}*/
		//else{
			
			Arrays.sort(arr, new Comparator<Point>(){

				@Override
				public int compare(Point arg0, Point arg1) {
					// TODO Auto-generated method stub
					return -Integer.compare(arg0.h, arg1.h);
				}
				
			});
			
    		int h = 0;
    		boolean val=true;
    		L1:for(int x=0;x<=100;x++){
    			for(int y=0;y<=100;y++){
    				val=true;
    				for(int i=0;i<n;i++){
    					if(i==0){
    						h = Math.abs(x-arr[i].x)+Math.abs(y-arr[i].y)+arr[i].h;
    					}
    					else{
    						if(Math.max(h-Math.abs(x-arr[i].x)-Math.abs(y-arr[i].y), 0)!=arr[i].h){
    							val=false;
    							break;
    						}
    					}
    				}
    				if(val && h>=1){
    					System.out.println(x+" "+y+" "+h);
    					break L1;
    				}
    			}
    		}   
		//}
	}
}
class Point{
	int x, y, h;
	Point(int x, int y, int h){
		this.x=x;
		this.y=y;
		this.h=h;
	}
}
/*
4
2 3 5
2 1 5
1 2 5
3 2 5

5
2 3 5
2 1 5
1 2 5
3 2 5
10 20 0

2
47 23 0
10 20 0
*/

Measured memory_bytes: 23124
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int K, S;
    std::cin >> K >> S;

    int count = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if ((0 <= z) && (z <= K)) {
                count++;
            }
        }
    }

    std::cout << count << std::endl;
    return 0;
}

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


struct rect {
  double leftX, leftY;
  double rightX, rightY;
};

int main() {
  rect a, b;

  while(cin >> a.leftX >> a.leftY >> a.rightX >> a.rightY >> b.leftX >> b.leftY >> b.rightX >> b.rightY) {
    if(b.rightX < a.leftX || a.rightX < b.leftX || b.rightY < a.leftY || a.rightY < b.leftY) {
      cout << "NO" << endl;
    }else {
      cout << "YES" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3088
/*
    @uthor: Amit Kumar
    user --> GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"\Case #"<<x<<"\:"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}


void virus(){
        ll a,b,c,k;
        cin>>a>>b>>c>>k;
        if( k <= a) cout<<k;
        else if( a + b >= k) cout<<a;
        else cout<<a - (k - a - b);
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3616
#include <string>
#include <vector>
#include <iostream>
using namespace std;
string s; int n, sums; long long prods = 1, fact[19];
long long anagram(string t) {
	int c[10] = { 0 };
	for (int i = 0; i < t.size(); i++) c[t[i] - 48]++;
	long long ret = fact[t.size()];
	for (int i = 0; i < 10; i++) ret /= fact[c[i]];
	return ret;
}
long long anagram2(int ptr, string t) {
	if (ptr == n) return 0;
	long long ret = 0;
	bool vis[26] = { false };
	for (int i = 0; i < t.size(); i++) {
		if (vis[t[i] - 48]) continue;
		if (t[i] < s[ptr]) {
			string u = t; u.erase(u.begin() + i);
			ret += anagram(u);
		}
		if (t[i] == s[ptr]) {
			string u = t; u.erase(u.begin() + i);
			ret += anagram2(ptr + 1, u);
		}
		vis[t[i] - 48] = true;
	}
	return ret;
}
long long rec(int ptr, int digit, int sum, long long prod, string x) {
	if (ptr == 10) {
		if (digit != n) return 0;
		if (sum != sums) return (sum < sums ? anagram(x) : 0);
		if (prod != prods) return (prod < prods ? anagram(x) : 0);
		return anagram2(0, x);
	}
	long long ret = 0;
	for (int i = 0; digit + i <= n; i++) {
		ret += rec(ptr + 1, digit + i, sum, prod, x);
		sum += ptr;
		prod *= (ptr + 1);
		x += ptr + 48;
	}
	return ret;
}
int main() {
	cin >> s; n = s.size();
	fact[0] = 1;
	for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
	for (int i = 0; i < n; i++) {
		sums += s[i] - 48;
		prods *= s[i] - 47;
	}
	long long ret = rec(0, 0, 0, 1, "");
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3140
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next(); //("00000" + nexts()).substr(-5).split("").map(x => +x);
    let a = nexts(3 * n).sort((a, b) => b - a);
    let ans = 0;
    for (let i = 0; i < n; i++) {
        ans += a[2 * i + 1]
    }

    return ans;
}

Measured memory_bytes: 65972
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
typedef long long ll;
//プロトタイプ宣言
int gcd(int , int);
int GCD(int , int);


int main(){
    int a,b,x;
    cin >> a >> b >> x;
    float ra = (float)(a) , rb =(float)(b) , rx =(float)(x); 
    float sum = 0.0 , rad = 0.0 , ans = 0.0;
    if(a*a*b >= 2*x){
        rad = atan((float)(b*b*a) / (float)(2*x));
        ans = rad*(180 / M_PI);
    }
    else {
        rad = atan((float)(2*b*a*a - 2*x) / (float)(a*a*a));
        ans = rad*180.0 / (float)M_PI;
    }
    cout << setprecision(10) << ans << endl;
}








































//以下、ライブラリ
//ユークリッドの互除法
int gcd(int a, int b){
    while(1){
        int remain = a % b;
        if(remain == 0) return b;
        else{
            a = b;
            b = remain;
        }
    }
}

int GCD(int a, int b) {
  return b ? GCD(b, a%b) : a;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let mut a:String = read!();
    let mut b:String = read!();
    let mut a:Vec<char> = a.chars().collect_vec();
    let mut b:Vec<char> = b.chars().collect_vec();
    let mut c=0;
    for i in 0..a.len()-b.len()+1 {
        let mut sum = 0;
        for j in 0..b.len() {
            if a[j+i]==b[j] {
                sum+=1;
            }
        }
        if sum>c {
            c=sum;
        }
    }
    println!("{}",b.len()-c);
}

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

int main(){
    int n,i=0,j=0,onajimoji;
    cin >> n;
    string s,t;
    cin >> s >> t;
    for(i=0;i<n;i++){
        onajimoji=0;
        for(j=0;j<n-i;j++){ 
            if(s[i+j]==t[j])onajimoji++;
        }
        if(onajimoji==n-i)break;
    }
    cout << 2*n - onajimoji << endl;
    return 0;
}

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

int main(){
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  priority_queue<int,vector<int>,greater<int> > pq;
  int j=N-1;
  for(int i=0;i<N;i++){
    j%=N;
    int ans=A.at(j)-A.at(i);
    if(ans<0){
      ans+=K;
    }
    pq.push(ans);
    j++;
  }
  cout << pq.top() << endl;
  return 0;
}


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

int main()
{
	int n;
	int d[50];
	long long sum = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += (d[i] * d[j]);
		}
	}

	cout << sum << endl;

	return 0;
}

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

void solve()
{
	int d, t, s;
	cin >> d >> t >> s;
	
	if(s * t >= d) 
	{
		cout << "Yes\n";
	}
	else cout << "No\n";
	
}

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


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

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

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    int R0, W, C, R;
    while(cin>>R0>>W>>C>>R&&R0){
        cout << max(0, (C * W - R0 + R - 1) / R) << endl;
    }
    return 0;
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#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)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

using P = std::pair<string, double>;

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N;
  cin >> N;
  vector<P> X(N);
  rep(i, N) cin >> X[i].second >> X[i].first;
  double sum {};
  rep(i, N) {
    if (X[i].first == "JPY") sum += X[i].second;
    else {
      sum += ((X[i].second)*380000.0);
    }
  }
  cout << std::fixed << sum << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

string tmp[4]={"dream","dreamer","erase","eraser"};


int main(){
	string s;
	cin>>s;
	bool check=true;
	while(s.size()>0){
		if(s.size()>=7&&s.substr(s.size()-7,7)==tmp[1])s.erase(s.size()-7);
		else if(s.size()>=5&&s.substr(s.size()-5,5)==tmp[0])s.erase(s.size()-5); 
		else if(s.size()>=6&&s.substr(s.size()-6,6)==tmp[3])s.erase(s.size()-6);
		else if(s.size()>=5&&s.substr(s.size()-5,5)==tmp[2])s.erase(s.size()-5);
		else{
			check=false;
			break;
		}
	}
	cout<<((check)?"YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 512
import numpy as np

input_str = input()
input_list = input_str.split(" ")

# 長さを
window_length = int(input_list[0])
curtain_length = int(input_list[1])

# カーテンで隠れていない長さを計算する
not_covered_length = None

if window_length < curtain_length*2:
    not_covered_length = 0
else:
    not_covered_length = window_length - curtain_length*2

# 計算結果を出力
print(not_covered_length)

Measured memory_bytes: 21164
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define int long long
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int i[111100];
bool ii[11111];
int u;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=1,h=2,j;
  string s,w;
  cin >>a>>b;
  cout <<a-b+1<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
int main()
{
	int n,x;
	bool a[110];
	rep(i,110)
	{
		a[i]=1;
	}
	cin>>x>>n;
	int ans=0;
	rep(i,n)
	{
		int b;
		cin>>b;
		a[b]=false;
	}
	int minn=1e9;
	rep(i,102)
	{
		if(a[i]&&abs(x-i)<minn)
		{
			ans=i;
			minn=abs(x-i);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3672
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N;
	cin >> N;
	for (int i = 1; i <= 7; i++) {
		if (pow(2, i) > N) {
			cout << pow(2, i - 1) << endl;
			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 limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#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;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    string s;
    cin >> s;
    
    int a[200]={};

    int ans = 0;
    rep(i,n){
        int ans2=0;
        rep(j,200){
            a[j]=0;
        }
        rep(j,i){
            a[s[j]]=1;
        }
        srep(j,i,n){
            if(a[s[j]]==1){
                a[s[j]]=2;
            }
        }
        rep(j,200){
            if(a[j]==2){
                ans2++;
            }
        }
        maxs(ans,ans2);
    }
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
N,A,B,C=map(int,input().split())
l=[int(input())for _ in range(N)]
def dfs(i,a,b,c,x):
    if i==N:
        return(abs(A-a)+abs(B-b)+abs(C-c)+10*(x-3))if a*b*c!=0 else 10**9
    ret1=dfs(i+1,a,b,c,x)
    ret2=dfs(i+1,a+l[i],b,c,x+1)
    ret3=dfs(i+1,a,b+l[i],c,x+1)
    ret4=dfs(i+1,a,b,c+l[i],x+1)
    return(min(ret1,ret2,ret3,ret4))
print(dfs(0,0,0,0,0))

Measured memory_bytes: 42200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include <string.h>
#include <math.h>

using namespace std;


int main()
{
	string s;
	int n, f=0;
	cin >> s;
	n = stoi(s);
	for (int i = 0; i < s.size(); i++)f += s[i]-'0';
	if (n%f == 0)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#define USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 30;
const double EPS = 1E-9;

ll dp[20][20];
bool no[20][20][20][20];

int main(){
	int T;
	int gy, gx, n;
	cin >> T;
	for(int t = 0; t < T; t++){
		memset(dp, 0, sizeof(dp));
		memset(dp, false, sizeof(no));
		dp[0][0] = 1;
		cin >> gx >> gy;
		cin >> n;
		for(int i = 0; i < n; i++){
			int x1, x2, y1, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			no[x1][y1][x2][y2] = true;
			no[x2][y2][x1][y1] = true;
		}

		for(int i = 0; i <= gy; i++){
			for(int j = 0; j <= gx; j++){
				if(!no[j][i][j+1][i]) dp[i][j+1] += dp[i][j];
				if(!no[j][i][j][i+1]) dp[i+1][j] += dp[i][j];
			}
		}
		if(dp[gy][gx] == 0) cout << "Miserable Hokusai!" << endl;
		else cout << dp[gy][gx] << endl;

	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp=0,start=0,p;
  char s[LIMIT1];
  int u[LIMIT2]={0};
  int cc[10010]={0};
  
  scanf("%lld %lld",&n,&p);
  scanf("%s",s);
  if(p==2||p==5){
    for(i=0;i<n;i++){
      tmp=(ll)(s[i]-'0');
      if(tmp%p==0) result+=i+1;
    }
  }else{
    for(i=n-1;i>=0;i--){
      //tmp=1;
      tmp=modpow(10,n-1-i,p);
      tmp*=(int)(s[i]-'0');
      if(i<n-1) tmp+=u[i+1];
      tmp%=p;
      u[i]=tmp;
      cc[u[i]]++;
    }
    //qsort(u,n,sizeof(int),upint);
    result=cc[0];
    for(i=0;i<p;i++){
      result+=nCr(cc[i],2);
    }
    //rep(i,n) printf("%d ",u[i]);
    //printf("\n");
  }
  printf("%lld",result);
  return 0;
}




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

using namespace std;

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

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

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

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

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

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

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

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

    ll h,a;
    cin>>h>>a;
    ll ans=(h+a-1)/a;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

vll Ns;

void dfs(S s){
    bool ok3=false,ok5=false,ok7=false;
    rp(i,s.size()){
        if(s[i]=='3')   ok3=true;
        if(s[i]=='5')   ok5=true;
        if(s[i]=='7')   ok7=true;
    }
    if(ok3&&ok5&&ok7){
        ll m=0;
        rp(i,s.size()){
            m+=(s[i]-'0')*pow(10,i);
        }
        Ns.pb(m);
    }    
    if(s.size()==10){
        return;
    }

    dfs(s+'3');
    dfs(s+'5');
    dfs(s+'7');
    
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    dfs("");
    sort(Ns);
    rp(i,Ns.size()){
        if(n<Ns[i]){
            cout << i << endl;
            break;
        }elif(n==Ns[i]){
            cout << i+1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;
int main() {
	int N, K, array[50] = { 0 };
	int sum = 0;
	cin >> N >> K;
	for (int i = 0;i < N;i++) {
		cin >> array[i];
	}
	sort(array, array + N, greater<int>());

	for (int i = 0;i < K;i++) {
		sum += array[i];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;


int main()
{
    int64_t N, C;
    std::cin >> N >> C;

    boost::multi_array<int64_t, 2> D(boost::extents[C][C]);
    for (auto p = D.data(); p < (D.origin() + D.num_elements()); ++p) {
        std::cin >> *p;
    }

    boost::multi_array<int64_t, 2> c(boost::extents[N][N]);
    for (auto p = c.data(); p < (c.origin() + c.num_elements()); ++p) {
        int64_t t;
        std::cin >> t;
        t--;
        *p = t;
    }

    // memo[g][col]: グループg[0,1,2] を色[0,C)に塗った時に生じる違和感
    boost::multi_array<int64_t, 2> memo(boost::extents[3][C]);

    for (int64_t y = 0; y < N; ++y) {
        for (int64_t x = 0; x < N; ++x) {
            const auto g = (x+y) % 3;
            for (int64_t col = 0; col < C; ++col) {
                memo[g][col] += D[c[y][x]][col];
            }
        }
    }

    int64_t mi = INT64_MAX;

    for (int64_t i = 0; i < C; ++i) {
        for (int64_t j = 0; j < C; ++j) {
            if (j == i) {
                continue;
            }
            for (int64_t k = 0; k < C; ++k) {
                if (k == i || k == j) {
                    continue;
                }
                mi = std::min(mi, memo[0][i] + memo[1][j] + memo[2][k]);
            }
        }
    }

    std::cout << mi << std::endl;

    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using ll = long long;
using namespace std;

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	vector<int>b(M);
	rep(i, M) {
		cin >> b[i];
	}
	vector<vector<int>>A(N, vector<int>(M));
	rep(i, N) {
		rep(j, M) {
			cin >> A[i][j];
		}
	}
	int ans = 0;
	rep(i, N) {
		long int tmp = 0;
		rep(j, M) {
			tmp += A[i][j] * b[j];
		}
		if (tmp + C > 0) {
			ans++;
		}
	}
	cout << ans << endl;
}


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

int main() {

	ll k, x; cin >> k >> x;
	ll left = x - (k - 1);
	ll right = x + (k - 1);
	for (int i = left; i <= right; i++) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3628