akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

const int MaxH = 1000 + 5, MaxW = 1000 + 5;
const int Mod = 1000000007;

int H, W;
char A[MaxH][MaxW];
int Dp[MaxH][MaxW];

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }

void init() {
  scanf("%d %d", &H, &W);
  for (int i = 1; i <= H; ++i)
    scanf("%s", A[i] + 1);
}

void solve() {
  Dp[1][1] = 1;
  for (int i = 1; i <= H; ++i)
    for (int j = 1; j <= W; ++j) {
      if (i == 1 && j == 1) continue;
      if (A[i][j] == '#') continue;
      Dp[i][j] = add(Dp[i - 1][j], Dp[i][j - 1]);
    }
  printf("%d\n", Dp[H][W]);
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 5120
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
MOD = 10**9+7

def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

def main():
    n = int(input().strip())
    v = list(map(int, input().strip().split()))
    a = v[0]
    lcm = v[0]
    for i in range(n):
        if i > 0:
            tmp = a
            a = gcd(a, v[i])
            c_lcm = tmp * v[i] // a
            lcm = c_lcm * lcm // gcd(c_lcm, lcm)
    ans = 0
    # for i in range(n):
    #     ans += lcm // v[i]
    # print(ans % (10**9+7))
    for i in range(n):
        ans += lcm * pow(v[i], MOD-2, MOD)
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73048
N, K = map(int, input().split())
ps = list(map(int, input().split()))
es = [(p+1)/2 for p in ps]
rs = []
s = sum(es[0:K])
rs.append(s)
for i in range(N-K):
  s = s-es[i]+es[i+K]
  rs.append(s)
#print(rs)
r = max(rs)
print(r)


Measured memory_bytes: 25060
input = raw_input
n = int(input())

flag = True
nums = map(int, input().split(" "))
for num in nums:
    if num % 2 == 0:
        if num % 3 == 0 or num % 5 == 0:
            pass
        else:
            flag = False
            break

if flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 28012
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <inttypes.h>

#define MAX (1 << 18) /* 262144 */
#define INF INT64_C(99999999999999999)

int64_t ki[MAX * 2 - 1];
int64_t ki_all[MAX * 2 - 1];

void ki_add_i(int idx, int qmin, int qmax, int smin, int smax, int64_t delta) {
	if (qmax <= smin || smax <= qmin) { /* はずれ */
		/* nop */
	} else if (qmin <= smin && smax <= qmax) { /* セグメントがクエリに完全に含まれる */
		ki_all[idx] += delta;
	} else {
		int smid = smin + (smax - smin) / 2;
		int lidx = idx * 2 + 1;
		int ridx = idx * 2 + 2;
		int64_t left, right;
		ki_all[lidx] += ki_all[idx];
		ki_all[ridx] += ki_all[idx];
		ki_all[idx] = 0;
		ki_add_i(lidx, qmin, qmax, smin, smid, delta);
		ki_add_i(ridx, qmin, qmax, smid, smax, delta);
		left = ki[lidx] + ki_all[lidx];
		right = ki[ridx] + ki_all[ridx];
		ki[idx] = left >= right ? left : right;
	}
}

void ki_add(int min, int max, int64_t delta) {
	ki_add_i(0, min, max, 0, MAX, delta);
}

int64_t ki_max_i(int idx, int qmin, int qmax, int smin, int smax) {
	if (qmax <= smin || smax <= qmin) { /* はずれ */
		return -INF;
	} else if (qmin <= smin && smax <= qmax) { /* セグメントがクエリに完全に含まれる */
		return ki[idx] + ki_all[idx];
	} else {
		int smid = smin + (smax - smin) / 2;
		int lidx = idx * 2 + 1;
		int ridx = idx * 2 + 2;
		int64_t left = ki_max_i(lidx, qmin, qmax, smin, smid);
		int64_t right = ki_max_i(ridx, qmin, qmax, smid, smax);
		return (left >= right ? left : right) + ki_all[idx];
	}
}

int64_t ki_max(int min, int max) {
	return ki_max_i(0, min, max, 0, MAX);
}

struct mon {
	int X, H;
};

int cmp(const void* x, const void* y) {
	int a = ((const struct mon*)x)->X, b = ((const struct mon*)y)->X;
	return a < b ? -1 : a > b;
}

int N, D, A;
struct mon m[271828];

/* 座標がzahyo以下の右端のやつを求める */
int kugyu(int zahyo) {
	int yes = 0, no = N - 1;
	if (m[no].X <= zahyo) return no;
	if (zahyo < m[yes].X) return -1;
	while (yes + 1 < no) {
		int mid = yes + (no - yes) / 2;
		if (m[mid].X <= zahyo) yes = mid; else no = mid;
	}
	return yes;
}

int tasu(int a, int b) {
	return b > INT_MAX - a ? INT_MAX : (a + b);
}

int main(void) {
	int i;
	int64_t count = 0;
	if (scanf("%d%d%d", &N, &D, &A) != 3) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &m[i].X, &m[i].H) != 2) return 1;
	}
	qsort(m, N, sizeof(*m), cmp);
	for (i = 0; i < N; i++) {
		ki_add(i, i + 1, m[i].H);
	}
	for (i = 0; i < N; i++) {
		int64_t left = ki_max(i, i + 1);
		if (left > 0) {
			int64_t use = (left + A - 1) / A;
			int migi = kugyu(tasu(tasu(m[i].X, D), D));
			count += use;
			if (i <= migi) ki_add(i, migi + 1, -A * use);
		}
	}
	printf("%" PRId64 "\n", count);
	return 0;
}


Measured memory_bytes: 7916
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll a,b,n;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> a >> b >> n;
}

int solve(){
    ll x;
    if(n<b) x = min(n,b-1);
    else x = b-1;
    cout << (a*x)/b << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


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

// a mod b を最大化するには a = a-1

int main()
{
  int N;
  cin >> N;
  vector<ll> a(N);
  rep(i, N)
  {
    cin >> a[i];
  }
  ll ans = 0;
  rep(i, N)
  {
    ans += a[i] - 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()
                
T = input()
s = len(S)
t = len(T)
list1 =[]

for i in range(s):
    if (S[i]==T[i]):
        list1.append(i)
ll = len(list1)

if (ll+1==t):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<int, int>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
	ll n; cin >> n;
	ll ans = 0;

	// 頂点i個の森が,(n-i+1)個存在する
	for (int i = 1; i <= n; ++i) {
		ans += i * (n - i + 1);
	}
	// 辺(u,v)が含まれる区間は u * (n + 1 - v) 個存在する
	// 例 (2,3) は 2個 (L=1,2, R=3)存在する : 2 * (3-3+1) 
	for (int i = 0; i < n - 1; ++i) {
		ll u, v; cin >> u >> v;
		if (u > v) swap(u, v);
		ans -= u * (n - v + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
L, R = map(int,input().rstrip().split())
if R - L >=2018:
    ans = 0
else:
    ans = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            if (i*j)%2019<ans:
                ans=(i*j)%2019
print(ans)

Measured memory_bytes: 9132
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long m = 1000000007;
  int n;
  cin >> n;
  long long ans =1;
  for(int i=1;i<=n;i++)
    ans = (ans%m * i%m)%m;
  cout<<ans%m;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	return !printf("%d\n", (a + b + 1) / 2);
}

Measured memory_bytes: 256
N = int(input())
ws = [input()]

flg = True
for i in range(N-1):
    Wi = input()
    if Wi in ws:
        flg = False
    elif ws[-1][-1] != Wi[0]:
        flg = False
    ws.append(Wi)

if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int bits[25];
vector <pair <int, pair<int,int > > > nonzeroes;

void addnumber(int a){
    for(int i=0;i<25;i++){
        if(a%2==1){
            bits[i]++;
        }
        a/=2;
    }
}

void removenumber(int a){
    for(int i=0;i<25;i++){
        if(a%2==1){
            bits[i]--;
        }
        a/=2;
    }
}

bool checkbits(){
    for(int i=0;i<25;i++){
        if(bits[i]>1){
            return false;
        }
    }
    return true;
}

int main(){
    int n;
    cin>>n;
    int a[n];
    int indexfirst=0,indexlast=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]!=0){
            nonzeroes.push_back({a[i],{0,0}});
        }
    }
    int z=0;
    int initialzeroes=0;
    while(z<n&&a[z]==0){
        initialzeroes++;
        z++;
    }
    int countnon=0;
    int count0s=0;
    long long int ans=0;
    ans+=((long long)initialzeroes*(long long)(initialzeroes+1))/2;
    if(!nonzeroes.empty()){
        nonzeroes[0].second.first=initialzeroes;
        countnon++;
        for(int i=initialzeroes+1;i<n;i++){
            if(a[i]==0){
                count0s++;
            }
            else{
                ans+=((long long)count0s*(long long)(count0s+1))/2;
                nonzeroes[countnon-1].second.second=count0s;
                nonzeroes[countnon].second.first=count0s;
                countnon++;
                count0s=0;
            }
        }
        ans+=((long long)count0s*(long long)(count0s+1))/2;
        nonzeroes[nonzeroes.size()-1].second.second=count0s;
    }
    int numnon=nonzeroes.size();
    for(int i=1;i<=25;i++){
        if(n>=numnon){
            for(int j=0;j<numnon;j++){
                if(j<i-1){
                    addnumber(nonzeroes[j].first);
                }
                else if(j==i-1){
                    addnumber(nonzeroes[j].first);
                    if(checkbits()){
                        ans+=(long long)(nonzeroes[0].second.first+1)*(long long)(nonzeroes[j].second.second+1);
                    }
                }
                else{
                    removenumber(nonzeroes[j-i].first);
                    addnumber(nonzeroes[j].first);
                    if(checkbits()){
                        ans+=(long long)(nonzeroes[j].second.second+1)*(long long)(nonzeroes[j-i+1].second.first+1);
                    }
                }
            }
        }
        for(int i=0;i<25;i++){
            bits[i]=0;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 4852
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll d[300][300];
ll V;
 
void warshall_floyd(){
  rep(k,V){
    rep(i,V){
      rep(j,V)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  V=n;
  rep(i,n){
    rep(j,n){
      if(i!=j)d[i][j]=longinf;
      else d[i][j]=0;
    }
  }
  ll e[n][n]={};
  rep(i,m){
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    e[x][y]=z;
    e[y][x]=z;
    d[x][y]=z;
    d[y][x]=z;
  }
  warshall_floyd();
  ll ans=0;
  rep(i,n){
    for(int j=i+1;j<n;j++){
      if(e[i][j]!=0 && e[i][j]==d[i][j]){
        ans++;
      }
    }
  }
  ans*=-1;
  ans+=m;
  cout << ans << endl;
return 0;}

Measured memory_bytes: 512
import sys, math
from collections import defaultdict
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()

ans = 0
for i in range(1, N+1):
	if len(list(str(i))) % 2 == 1:
		ans += 1
print(ans)


Measured memory_bytes: 73920
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> w(n);
    for(int i = 0; i < n; i++)
    {
        cin >> w[i];
    }
    if(n == 2)
    {
        cout << abs(w[0] - w[1]);
        return 0;
    }
    int s = 0;
    for(int i = 0; i < n; i++)
    {
        s += w[i];
    }
    int mid = s / 2;
    int s1 = 0;
    int s2 = 0;
    int s3 = 0;
    int i = 0;
    while(s1 < mid)
    {
        s1 += w[i];
        i++;
    }
    for(int j = i; j < n; j++)
    {
        s2 += w[j];
    }
    for(int j = i - 1; j < n; j++)
    {
        s3 += w[j];
    }
    cout << min((abs(s1 - s2)), abs((s1 - w[i - 1]) - s3));

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int n;
int a[200010];
long long D = 1000000007;
long long f[200010], u[200010];
long long res = 0;
int have[200010];

long long pw2(long long x, long long aa)
{
	long long y = 1;
	while(aa>0){
		if(aa % 2 == 1){
			y *= x;
			y %= D;
		}
		aa /= 2;
		x *= x;
		x %= D;
	}
	return y;
}

void pre()
{
	int i;
	f[0] = f[1] = 1;
	for(i=2; i<=n; i++){
		f[i] = f[i-1] * i;
		f[i] %= D;
	}
	u[0] = u[1] = 1;
	for(i=2; i<=n; i++){
		u[i] = pw2(f[i], D-2);
	}
}

//long long calcC(long long nn, long long mm)
long long calcC(int nn, int mm)
{
	//long long nn = nni;
	//long long mm = mmi;
	if(nn < mm)
		return 0;
	long long r = f[nn];
	r *= u[mm];
	r %= D;
	r *= u[nn-mm];
	r %= D;
	return r;
}

void solve()
{
	pre();
	int i;
	int vv, ll=-1, rr=-1;
	for(i=0; i<n+1; i++){
		have[a[i]] ++;
		if(have[a[i]] == 2)
			vv = a[i];
	}
	for(i=0; i<n+1; i++){
		if(a[i] == vv){
			if(ll==-1)
				ll = i;
			else
				rr = i;
		}
	}
	printf("%d\n", n);
	for(i=2; i<=n; i++){
		res = 0;
		res += calcC(n-1, i);
		res += calcC(n-1, i-1);
		res %= D;
		res += calcC(n-1, i-1);
		res %= D;
		res += D;
		res -= calcC(n+1-(rr-ll+1), i-1);
		res %= D;
		res += calcC(n-1, i-2);
		res %= D;
		printf("%lld\n", res);
	}
	printf("%d\n", 1);
}

int main()
{
	int i;
	scanf("%d", &n);	
	for(i=0; i<n; i++)
		scanf("%d", &a[i]);
	solve();
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n;
	cin >>n;
	
	
	ll b=1; string s("");
	for(;n != 0;){
		if(abs(n) & abs(b)){
			n -=b; s="1"+s;
		} else s ="0"+s;
		b *= -2;
	}
	if(s=="") s="0";
	cout << s <<"\n";
	return 0;
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {
	int n;
	cin >> n;
	if (n==0) {
		cout << "Yes\n";
		return;
	}
	for (int j = 0; j <= n; ++j) {
		for (int k = 0; k <= n; ++k) {
			if (4*j+7*k==n) {
				cout << "Yes\n";
				return;
			} 
		}
	}

	cout << "No\n";
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n = II()
    cnt = 0
    val = 10
    if n%2==1: print(cnt); exit(0)
    while True:
        if n < val: break
        cnt += n//val
        val *= 5
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int arr[100005], memo[100005],k;

int dp(int n){
    if(n==0) return 0;
    if(memo[n]!=-1) return memo[n];
    int cost=1e9;
    for(int i=1; i<=k&&i<=n; ++i) cost=min(dp(n-i)+abs(arr[n]-arr[n-i]),cost);
    return memo[n]=cost;
}

int main(){
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(memo, -1, sizeof(memo));
    int n;
    cin>>n>>k;
    for(int i=0; i<n; ++i) cin>>arr[i];
    cout<<dp(n-1)<<"\n";
    //for(int i=0; i<n; ++i) cout<<memo[i]<<"\n";
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int a,b;
  cin >> a >> b ;

  cout << (a + b > 9 ? "error" :  to_string(a+b)) << endl; 
  return 0;
} 

Measured memory_bytes: 3664
def solve():
    N, M = map(int, input().split())
    K = [list(map(int, input().split())) for _ in range(M)]
    P = list(map(int, input().split()))
    # bit全探索
    ans = 0

    for i in range(2**N):
        s = [False] * N

        for j in range(N): #それぞれのスイッチがonかoffか
            if 1 & (i >> j):
                s[j] = True

        for light in range(M):
            count = 0
            for switch in range(1, K[light][0]+1):
                if s[K[light][switch]-1]: #1indexなので
                    count += 1
            if count &1 != P[light] &1:
                break
        else: #breakせず終了した場合、すべて点灯している。
            ans += 1
    print(ans)



if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long int
using namespace std;
int check(string s1, string s2) {
    for(int i=0;i<min(s2.length(), s1.length());i++) {
        if(s1[i] != s2[i])
            return 0;
    }
    return 1;
}
void solve() {
   string s1, s2;
   cin >> s1 >> s2;
   sort(s1.begin(), s1.end());
   sort(s2.begin(), s2.end(), greater<char>());
   if(check(s1, s2)) {
        if(s2.length() > s1.length())
            cout << "Yes" << '\n';
        else
            cout << "No" << '\n';
   }
   else {
        if(s2[0] > s1[0])
            cout << "Yes" << '\n';
        else    
            cout << "No" << '\n';
   }
    return ;
} 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

//-----CODE------//

void solve(void)
{ 
  int N;cin>>N;
  cout<<180*(N-2)<<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}



int main() {
    vector<int> dp(100001, 1e9);
    // dp[i]: mininum number of coins to make i yen
    dp[0] = 0;
    int n, m;
    cin >> n;
    vector<int> as(16);
    as[0] = 1;
    for (int i = 1; i < 8; i++){
        as[i] = pow(6, i);
    }
    for (int i = 8; i < 16; i++){
        as[i] = pow(9, i - 7);
    }
    for (int i = 0; i < 16; i++) {
        for (int j = 0; j <= 100000; j++) {
            if (j + as[i] > 100000) continue;
            dp[j + as[i]] = min(dp[j + as[i]], dp[j] + 1);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		System.out.println(N % 1000 == 0 ? 0 : 1000 - N % 1000);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 32752
s = input()
start = 0
end = 0
for i in range(len(s)-2):
    if s[i] == s[i+1]:
        start = i+1
        end = i+2
        break
    if s[i] == s[i+2]:
        start = i+1
        end = i+3
        break
if s[-1] ==s[-2]:
    print(len(s)-1,len(s))
elif start != 0 and end != 0:
    print(start,end)
else:
    print(-1,-1)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(), vec.end()

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int ans = (n+m > 0)-(n+m < 0);
    printf("%d\n", ans);
}



Measured memory_bytes: 3208
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    string s;
    cin >> s;

    int mx = 0;
    int tmp = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
            tmp++;
            mx = max(mx, tmp);
        } else {
            tmp = 0;
        }
    }

    cout << mx << "\n";
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

int main()
{
    ll i,j,n,k;
    cin>>n>>k;
    vector<ll> l(n),r(n);
    for(i=0;i<n;i++) cin>>l[i]>>r[i];
    vector<ll> dp(n+1,0),dpsum(n+1,0);
    dp[1] = 1;
    dpsum[1] = 1;
    ll mod = 998244353;
    for(i=2;i<=n;i++)
    {
        for(j=0;j<k;j++)
        {
            ll li = i-r[j];
            ll ri = i-l[j];
            if(ri<0) continue;
            li = max(li,1ll);
            dp[i] += dpsum[ri] - dpsum[li-1];
            dp[i]= (dp[i] + mod)%mod;
        }
        dpsum[i] = dpsum[i-1] + dp[i];
        dpsum[i]%=mod;
    }
    cout<<dp[n];
}

Measured memory_bytes: 9520
while True:
	H,W = map(int,input().split())
	if H ==0 and W == 0:
		break
	
	for i in range (H):
		for j in range (W):
			if i == 0 or i == H-1:
				print('#', end = "")
			elif j == 0 or j == (W-1):
				print('#', end = "")
			else:
				print('.', end = "")
		print("")
	print("")

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

#define pb push_back
#define mp make_pair

using namespace std;

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

int main() {
  int n;
  cin >> n;
  
  vector<ll> cities;
  
  for (int i = 0; i < n+1; ++i) {
    ll c;
    cin >> c;
    
    cities.pb(c);
  }
  
  ll res = 0;
  
  for (int i = 0; i < n; ++i) {
    ll h;
    cin >> h;
    
    
    int mi0 = min(h, cities.at(i));
    h -= mi0;
    
    int mi1 = min(h, cities.at(i+1));
    
    cities.at(i) -= mi0;
    cities.at(i+1) -= mi1;
    
    res += mi0;
    res += mi1;
  }
  
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 4284
#include <bits/stdc++.h>
#define ll         long long int 
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define MN(a,b,c)  min(a,min(b,c))
#define pr         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(int i=0;i<n;i++)
#define f1(i,x,y)  for(int i=x;i<=y;i++)
#define f2(i,x,y)  for(int i=x;i>=y;i--)
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
ll dolog(ll n)
{
    int y=1,x=0;
    while(y<=n){y*=2;x++;}
  x--;
  return x;
}
ll pow2(ll x)
{
    ll y=1;
    while(x--){y*=2;}
    return y;
}
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
   string s;
   cin>>s;
   if(s=="RRR")cout<<3;
   else if(s=="RRS" || s=="SRR")cout<<2;
   else if(s=="SSS")cout<<0;
  else
    cout<<1;
}

Measured memory_bytes: 3640
<?php

fscanf(STDIN, "%d %d %d", $n, $k, $q);

$points = array_fill(0, $n, $k - $q);

for ($i = 0; $i < $q; ++$i) {
    fscanf(STDIN, "%d", $a);
    ++$points[$a - 1];
}

for ($i = 0; $i < $n; ++$i) {
    echo $points[$i] > 0 ? 'Yes' : 'No', PHP_EOL;
}


Measured memory_bytes: 9080
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[105],c,m;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1);
	c=0;
	for(int i=n;i>0;i--)
	{
	if(!c)m+=a[i],c=1;
	else m-=a[i],c=0;	
	}
	cout<<m;
 } 

Measured memory_bytes: 256
N, MOD = int(input()), 10 ** 9 + 7
A = list(map(int, input().split()))

A.sort()
ok = False
if A[0] == 0 and N % 2 == 1:
    ok = True
    for i in range(N):
        if A[i] != (i + 1) // 2 * 2:
            ok = False
            break
elif A[0] == 1 and N % 2 == 0:
    ok = True
    for i in range(N):
        if A[i] != i // 2 * 2 + 1:
            ok = False

if ok:
    print(2 ** (N // 2) % MOD)
else:
    print(0)


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) { cin >> a[i]; }
    unordered_map<ll, ll> table;
    ll ans = 0;
    REP(i, n) {
        ans += table[a[i] - i];
        table[-a[i] - i]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20020
D,G=map(int,input().split())
G//=100
p=[0]*D
c=[0]*D

for i in range(D):
    p[i],c[i]=map(int,input().split())
    c[i]//=100

ans=10**10
for bit in range(2**D):
    score=G
    problems=0
    SET=set([i for i in range(D)])

    for g in range(bit):
        if (bit>>g)&1:
            score-=(g+1)*p[g]+c[g]
            problems+=p[g]
            SET.remove(g)
    
    if score<=0:
        ans=min(ans,problems)
    else:
        #SETが空集合になる時は全ての問題を解いた時であり、全ての問題を解けば必ずscoreは負になるので
        #「ValueError: max() arg is an empty sequence」は防げる。
        MAX=max(SET)
        for _ in range(p[MAX]):
            score-=(MAX+1)
            problems+=1
            if score<=0:
                ans=min(ans,problems)    
                break
print(ans)

Measured memory_bytes: 44652
#include <cstdio>
#include <vector>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)

#define PR 510

vector<int> e[PR];
bool invalid, vis[PR], start;
int sum, deg[PR], n, h;

void dfs(int x) {
	vis[x] = true;
	sum += deg[x];
	if (deg[x] != 0) {
		start = true;
		if ((deg[x] > 0) != (x <= h)) invalid = true;
	}
	for (int v : e[x]) if (!vis[v]) dfs(v);
}

int main() {
	scanf("%d%d", &n, &h);
	iter(i, 2 * h) vis[i] = true;
	iter(i, n) {
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int u = c == 0 ? a : c + h;
		int v = d == 0 ? b + h : d;
		e[u].push_back(v);
		e[v].push_back(u);
		//printf("%d->%d\n", u, v);
		++deg[u], --deg[v]; vis[u] = vis[v] = false;
	}

	//iter(i, 2 * h) printf("%d ", deg[i]);

	iter(i, 2 * h) if (!vis[i]) {
		start = false; dfs(i);
		if (sum != 0 || !start) invalid = true;
	}

	puts(invalid ? "NO" : "YES");
	return 0;
}


Measured memory_bytes: 1664
// http://yumai6.hatenablog.com/entry/2015/12/21/222930

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

int N, M;

multiset<int>	D;

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

	cin >> N;
	int wk;
	REP(i, N) {
		cin >> wk;
		D.insert(wk);
	}
//	cout << "[" << D.size() << "]" << endl;
	
	cin >> M;
	string ans = "YES";
	REP(i, M) {
		cin >> wk;
		auto itr = D.find(wk);
		if(itr == D.end()) {
			ans = "NO";
			break;
		}
		D.erase(itr);
//		cout << wk << "  [" << D.size() << "]" << endl;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9600
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

vector<int> v;
void solve(int n, int bef){
	if(n == 0){
		for(int i=0; i<v.size(); i++){
			cout << v[i] << (i == v.size()-1 ? "\n" : " ");
		}
		return;
	}
	for(int i=min(bef, n); i>=1; i--){
		v.PB(i);
		solve(n-i, i);
		v.pop_back();
	}
}

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0) break;
		solve(n, INT_MAX);
	}
}


Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  
  int N, K, i;
  cin >> N >> K;
  vector<int> h(N);
  
  for(i = 0; i < N; i++){
    cin >> h.at(i);
  }
  
  int cnt = 0;
  
  for(i = 0; i < N; i++){
    if(K <= h.at(i)){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <queue>

#define MAX_W (50)
#define MAX_H (50)
#define INF (1000000000)
#define SIZE_BUF (30)

using namespace std;

const int dis[] = {1, 0, -1, 0}, djs[] = {0, 1, 0, -1};
void bellman_ford(char *fields, int H, int W, int i0, int j0, int *distances) {
  // initialize
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      distances[j + i * W] = INF;
    }
  }
  distances[j0 + i0 * W] = 0;

  // calculate shortest path
  for (int k = 0; k < H * W; k++) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        for (int d = 0; d < 4; d++) {
          const int i2 = i + dis[d], j2 = j + djs[d];
          if (i2 >= 0 && i2 < H && j2 >= 0 && j2 < W &&
              fields[j2 + i2 * W] == '.') {
            distances[j2 + i2 * W] =
                min(distances[j2 + i2 * W], distances[j + i * W] + 1);
          }
        }
      }
    }
  }
}

void bfs(char *fields, int H, int W, int i0, int j0, int *distances) {
  // initialize
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      distances[j + i * W] = -1;
    }
  }
  // bfs
  queue<int> i_que, j_que;
  i_que.push(i0);
  j_que.push(j0);
  distances[j0 + i0 * W] = 0;
  while (!i_que.empty()) {
    const int i = i_que.front(), j = j_que.front();
    i_que.pop();
    j_que.pop();
    for (int d = 0; d < 4; d++) {
      const int i2 = i + dis[d], j2 = j + djs[d];
      if (i2 >= 0 && i2 < H && j2 >= 0 && j2 < W &&
          fields[j2 + i2 * W] == '.' && distances[j2 + i2 * W] < 0) {
        distances[j2 + i2 * W] = distances[j + i * W] + 1;
        i_que.push(i2);
        j_que.push(j2);
      }
    }
  }
}

int main(int argc, char *argv[]) {
  // read inputs
  int H, W;
  char fields[MAX_H * MAX_W], buf[SIZE_BUF];
  scanf("%d %d", &H, &W);
  fgets(buf, SIZE_BUF, stdin);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      scanf("%c", &fields[j + i * W]);
    }
    fgets(buf, SIZE_BUF, stdin);
  }

  // find shortest path
  int distances[MAX_H * MAX_W];
  // bellman_ford(fields, H, W, 0, 0, distances);
  bfs(fields, H, W, 0, 0, distances);

  // count the number of white squares
  int count_white = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (fields[j + i * W] == '.') {
        count_white++;
      }
    }
  }

  // if (distances[W * H - 1] < INF) {
  if (distances[W * H - 1] >= 0) {
    printf("%d\n", count_white - distances[W * H - 1] - 1);
  } else {
    printf("-1\n");
  }

  return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
ans_list = []
for i in range(tx - sx):
    ans_list.append("R")
for j in range(ty-sy):
    ans_list.append("U")
for i in range(tx - sx):
    ans_list.append("L")
for j in range(ty-sy):
    ans_list.append("D")
ans_list.append("D")
for i in range(tx - sx + 1):
    ans_list.append("R")
for j in range(ty-sy + 1):
    ans_list.append("U")
ans_list.append("L")
ans_list.append("U")
for i in range(tx - sx + 1):
    ans_list.append("L")
for j in range(ty-sy + 1):
    ans_list.append("D")
ans_list.append("R")
print("".join(ans_list))


Measured memory_bytes: 3188
#include<stdio.h>
int main(void){
	int a,b,c,i,cout=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			cout++;
		}
	}
	printf("%d\n",cout);
	return 0;
}


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

#define QUEUE_SIZE 1000002
#define next(a) (((a)+1)%QUEUE_SIZE)

int queue[QUEUE_SIZE];
int front,rear;
void enqueue(int x){
	if(next(rear)==front){
		exit(1);
	}
	queue[rear]=x;
	rear = next(rear);
}
int dequeue(){
	if(front==rear){
		exit(1);
	}
	int x = queue[front];
	front = next(front);
	return x;
}

int empty(){
	return front==rear;
}
void init(){
	front = rear = 0;
}
int black[1000001];
int score[1001][1001];
void init2(){
	for(int i=0;i<1001;i++)for(int j=0;j<1001;j++)score[i][j]=-1;
}
int main(void){
	int H,W;
	int bc=0;
	init2();
	cin >> H >> W;
	string s[H];
	for(int i=0;i<H;i++){
		cin >> s[i];
	}
	//初期の黒い点の座標を保存する
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(s[i][j]=='#'){
				enqueue(100000*i+j);
				score[i][j]=0;
			}
		}
	}
	while(empty()==0){
		int temp = dequeue();
		int x = temp/100000;
		int y = temp%100000;
		
		for(int i=0;i<4;i++){
			int dx[4]={0,0,1,-1};
			int dy[4]={1,-1,0,0};
			if(x+dx[i]<0 || x+dx[i]>H || y+dy[i]<0 || y+dy[i]>W)continue;
			if(score[x+dx[i]][y+dy[i]]==-1 ||score[x+dx[i]][y+dy[i]]>score[x][y]+1){
				score[x+dx[i]][y+dy[i]] = score[x][y]+1;
				enqueue((x+dx[i])*100000+y+dy[i]);
			}
		}
	}
	int ans = 0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(ans<score[i][j])ans=score[i][j];
		}
	}
	cout << ans;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
int main(){
    unsigned long long a;
    double b;
    int b100;
    int bint;
    int bdec;
    unsigned long long answer;
    cin >> a >> b;
    b100 = (int)(b*100);
    bint = b100/100;
    bdec = b100%100;
    answer = a*bint + a*bdec/100;
    cout << answer;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

vector<vi> G;

vi color;
vi memo;

void dfs(int v, int d, int c){
    if(d < memo[v]) return;
    memo[v] = d + 1;

    if(color[v] == 0) color[v] = c;
    for(auto& nv : G[v]){
        dfs(nv, d - 1, c);
    }
}

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

    int n, m; cin >> n >> m;
    G = vector<vi>(n);
    rep(loop, m){
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    int Q; cin >> Q;
    using VDC = tuple<int, int, int>;
    vector<VDC> vdc(Q);
    for(auto& e : vdc){
        int v, d, c; cin >> v >> d >> c;
        v--;
        e = VDC(v, d, c);
    }

    color = vi(n);
    memo  = vi(n);
    rrep(i, Q){
        int v, d, c; tie(v, d, c) = vdc[i];
        dfs(v, d, c);
    }

    rep(v, n){
        cout << color[v] << endl;
    }

    return 0;
}


Measured memory_bytes: 8440
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll h,w;
    cin>>h>>w;
    if(h==1 || w==1) cout<<1<<endl;
    else cout<<(h*w+2-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 3584
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>

int main(void){
int a,b,c;
double rad;
double d,e,f;

scanf("%d %d %d",&a,&b,&c);
rad = c*(M_PI/180);
d = a * b * sin(rad) / 2;
e = a + b + sqrt(a*a + b*b - 2*a*b*cos(rad));
f = b * sin(rad);
printf("%.13lf\n%.13lf\n%.13lf\n",d,e,f);

return 0;
}


Measured memory_bytes: 2100
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = input()

from collections import defaultdict
d = defaultdict(int)

for i in range(N):
    s = S[i]
    d[s] += 1
cnt = 0
for i in range(N-2):
    for j in range(i,N-1):
        k = 2*j - i
        if k <= N-1 and (S[i] != S[j] and S[j] != S[k] and S[k] != S[i]):
            cnt += 1
if d["R"] and d["G"] and d["B"]:
    ans = d["R"] * d["G"] * d["B"] - cnt
    print(ans)
else:
    print(0)

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

int A,B,C,X;
int main(){
    cin >> A >> B >> C >> X;

    int ans = 0;
    for(int i=0;i<=A;++i){
        for(int j=0;j<=B;++j){
            int res = X - i*500 - j*100;
            if(res >= 0 && res <= 50 * C) ans++;
        }   
    }   
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

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

    vector<mint> dp(n + 1, -1);

    vector<int> a(n + 1);
    rep(i, m) {
        int num;
        cin >> num;
        a[num] = 1;
    }


    dp[n] = 1;
    for (int i = n - 1; i >= 0; i--) {
        if (a[i] == 1) {
            dp[i] = 0;
            continue;
        }
        if (i == n - 1) {
            dp[i] = 1;
            continue;
        }
        dp[i] = dp[i + 1] + dp[i + 2];
    }

    cout << dp[0] << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

ll dp1[2020], dp2[2020];
int division[2000001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    for(int i = 1; i <= 200000; i++)
        division[i] = i % 2019;
    ll answer = 0;
    dp1[s[0] - '0'] += 1;
    int n = s.size();
    for(int i = 1; i < n; i++)
    {
        for(int j = 0; j <= 2018; j++)
        {
            int nxt = division[j * 10 + (s[i] - '0')];
            dp2[nxt] += dp1[j];
        }
        answer += dp2[0];
        memcpy(dp1, dp2, sizeof dp2);
        dp1[s[i] - '0'] += 1;
        memset(dp2, 0, sizeof dp2);
    }
    cout << answer;
}



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

struct CODE{
	char before;
	char after;
};

int main()
{
	int n,m;
	
	while(cin >> n, n != 0){
		
		vector<CODE> conversion;
		
		while(n-- > 0){
			CODE tmp;
			cin >> tmp.before >> tmp.after;
			conversion.push_back(tmp);
		}
	
		cin >> m;
	
		while(m-- > 0){
			char c;
		
			cin >> c;
		
			for (int i = 0; i < conversion.size(); i++){
				if (conversion[i].before == c){
					c = conversion[i].after;
					break;
				}
			}
			cout << c;
		}
	
		cout << endl;
	}
	return (0);
}

Measured memory_bytes: 1212