akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define For(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Rep(i,n) For(i,0,n)
#define Each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF INT_MAX/3;

#define MAX_N 100

int p, q;
int t[6];
string ans;

struct dice{
	int x, xx, y, yy, z, zz;
};
dice d;

void rotation(int *a, int *b, int *c, int *d){
	int t = *a;
	*a = *b;
	*b = *c;
	*c = *d;
	*d = t;
}
void roll_e(){ rotation(&d.x,&d.zz,&d.xx,&d.z); }
void roll_n(){ rotation(&d.y,&d.zz,&d.yy,&d.z); }
void roll_s(){ rotation(&d.y,&d.z,&d.yy,&d.zz); }
void roll_w(){ rotation(&d.x,&d.z,&d.xx,&d.zz); }

//void roll_xy(){ rotation(&d.x,&d.y,&d.xx,&d.yy); }
void make_dice(int *t){
	d.x = t[0]; d.xx = t[1]; d.y = t[2]; d.yy = t[3]; d.z = t[4]; d.zz = t[5];
}

bool check(){
	if(d.x < 0 || d.xx < 0 || d.y < 0 || d.yy < 0 || d.z < 0 || d.zz < 0) return false;
	int sum = d.x + d.xx + d.y + d.yy + d.z + d.zz;

	if(2*(d.z+d.zz) > sum) return false;
	if(2*(d.y+d.yy) - 1 > sum) return false;
	if(2*(d.x+d.xx) - 1 > sum) return false;
	return true;
}

string dfs(int n){
	if(!check()) return "impossible";
	//dbg(n);
	//dbg(d.x); dbg(d.xx); dbg(d.y); dbg(d.yy); dbg(d.z); dbg(d.zz);
	string ans = "";
	while(1){
		if(n == 0){
			if(d.x == 0 && d.xx == 0 && d.y == 0 && d.yy == 0 & d.z == 0 && d.zz == 0) return ans;
			else break;
		}
		//if(d.x < 0 || d.xx < 0 || d.y < 0 || d.yy < 0 || d.z < 0 || d.zz < 0) return "impossible";
		//if(!check()) return "impossible";

		roll_e();
		d.zz--;
		if(check()){
			ans += "E";
			n--;
			continue;
		}
		d.zz++;
		roll_w();

		roll_n();
		d.zz--;
		if(check()){
			ans += "N";
			n--;
			continue;
		}
		d.zz++;
		roll_s();

		roll_s();
		d.zz--;
		if(check()){
			ans += "S";
			n--;
			continue;
		}
		d.zz++;
		roll_n();

		roll_w();
		d.zz--;
		if(check()){
			ans += "W";
			n--;
			continue;
		}
		d.zz++;
		roll_e();
		break;
	}

	return "impossible";
}

int main(int argc, char const *argv[])
{
	while(1){
		Rep(i,6) scanf("%d", &t[i]);
		int sum = 0;
		Rep(i,6) sum += t[i];
		if(t[5] == 0) break;
		scanf("%d %d", &p, &q);
		p--;
		string res = "Z";
		do{
			make_dice(t);
			if((ans = dfs(sum)) != "impossible") res = min(ans,res);
		}while(next_permutation(t,t+6));
		if(res == "Z") printf("impossible\n");
		else cout << res.substr(p,q-p) << endl;
	}
	return 0;
}

Measured memory_bytes: 3424
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;
#define N 100050
int head[N],to[N<<1],nxt[N<<1],cnt,n,K,is[N],vv[N],dep[N],root,need[N],mn[N],ans[N],siz[N];
void gun() {puts("No"); exit(0);}
inline void add(int u,int v) {
	to[++cnt]=v; nxt[cnt]=head[u]; head[u]=cnt;
}
void d1(int x,int y) {
	int i;
	dep[x]=dep[y]+1;
	if(is[x]) {
		int tmp=vv[root]+dep[x]-vv[x];
		if(tmp<0||(tmp&1)) gun();
		need[x]=tmp>>1;
		mn[x]=need[x];
	}else mn[x]=1<<30;
	siz[x]=is[x];
	for(i=head[x];i;i=nxt[i]) if(to[i]!=y) {
		d1(to[i],x); siz[x]+=siz[to[i]]; mn[x]=min(mn[x],mn[to[i]]);
	}
}
void d2(int x,int y,int now) {
	int i;
	if(is[x]) {
		if(need[x]==now+1) now++;
		else if(need[x]>now+1) gun();
		
		
		if(need[x]!=now) gun();
		ans[x]=vv[x];
	}else {
		if(siz[x]&&mn[x]>now) {
			ans[x]=ans[y]-1;
			now++;
		}else {
			ans[x]=ans[y]+1;
		}
	}
	for(i=head[x];i;i=nxt[i]) if(to[i]!=y) {
		d2(to[i],x,now);
	}
}
int main() {
	scanf("%d",&n);
	int i,x,y;
	for(i=1;i<n;i++) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	scanf("%d",&K);
	for(i=1;i<=K;i++) {
		scanf("%d%d",&x,&y); is[x]=1; vv[x]=y; root=x;
	}
	dep[0]=-1;
	d1(root,0);
	d2(root,0,0);
	puts("Yes");
	for(i=1;i<=n;i++) printf("%d\n",ans[i]);
}


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int x;
  cin >> x;
  if (x == 7 || x == 5 || x == 3) cout << "YES" << "\n";
  else cout << "NO" << "\n";

  return 0;
}

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

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


Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int ls=s.length();
    int lt=t.length();
    int lcs[ls+1][lt+1];
    for(int i=0;i<=ls;i++)
    {
        for(int j=0;j<=lt;j++)
        {
            if(i==0 || j==0) lcs[i][j]=0;
            else if(s[i-1]==t[j-1]) lcs[i][j]=1+lcs[i-1][j-1];
            else lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
        }
    }
    int x=ls;
    int y=lt;
    char l[lcs[x][y]+1];
    int i=lcs[x][y];
    l[i]='\0';i--;
    while(x>0 && y>0 && i>=0)
    {
        if(s[x-1]==t[y-1]) {l[i]=s[x-1];i--;x--;y--;}
        else if(lcs[x-1][y]>lcs[x][y-1]) {x--;}
        else {y--;}
    }
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 35456
loop{
  n = gets.to_i
  break if n == 0

  from_str = ""
  to_str = ""
  n.times{
    from_char, to_char = gets.chomp.split
    from_str += from_char
    to_str += to_char
  }
  m = gets.to_i
  out_str = ""
  m.times{
    ch = gets.chomp
    out_str += ch
  }
  puts out_str.tr(from_str, to_str)
}

Measured memory_bytes: 98844
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



class UnionFind {
private:
	vector<ll> data;
public:
	UnionFind(ll size) : data(size, -1) { }
	bool unite(ll x, ll y) { //x が入っている集合と y が入っている集合を併合する. (O(α(n)))
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	ll find(ll x) { // x のグループ番号を得る. (O(α(n)))
		return root(x);
	}
	ll root(ll x) { // x のみが入る集合 {x} を作る.
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	ll size(ll x) { // x が入っている集合の大きさを調べる. (O(1))
		return -data[root(x)];
	}
};

int main() {
	
	ll N, M;
	cin >> N >> M;
	vll p(N);
	rep(i, N) {
		cin >> p[i];
		--p[i];
	}
	UnionFind uf(N);
	rep(i, M) {
		ll x, y;
		cin >> x >> y;
		uf.unite(x - 1, y - 1);
	}

	ll ans = 0;
	rep(i, N) if (uf.find(i) == uf.find(p[i])) ++ans;
	cout << ans << endl;
}

Measured memory_bytes: 1792
import copy

def paint_h(h, w, t):
    for i in range(w):
        t[h][i] = ' '

def paint_v(h, w, t):
    for i in range(h):
        t[i][w] = ' '

def count_b(h, w, t):
    total = 0
    for i in range(h):
        for j in range(w):
            if t[i][j] == '#':
                total += 1
    return total


h, w, k = [int(e) for e in input().split()]

m = []
for i in range(h):
    m.append(list(input()))

count = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        t = copy.deepcopy(m)
        
        for a in range(h):
            if i & (2 ** a) == (2 ** a):
                paint_h(a, w, t)
        for a in range(w):
            if j & (2 ** a) == (2 ** a):
                paint_v(h, a, t)
        
        if k == count_b(h, w, t):
            count += 1

print(count)


Measured memory_bytes: 9376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define deb(x) cerr<<#x<<" : "<<x<<endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
#define INF 1000000000000000000
using namespace __gnu_pbds;
using namespace std;
const int N=2e5+5;
signed main()
{
	fast
	int n;
	cin>>n;
	vi left(n),right(n);
	f(i,0,n)
	{
		cin>>left[i]>>right[i];
	}
	f(i,0,n-3+1)
	{
		if(left[i]==right[i] && left[i+1]==right[i+1] && left[i+2]==right[i+2])
		{
			cout<<"Yes";
			baar;
		}
		
	}
	cout<<"No";
	return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  ll n,k;
  cin >> n >> k;
  vector<ll>vec(n);
  rep(i,n) cin >> vec[i];
  ll ans=INF;
  rep(i,n-k+1){
    ll left=vec[i],right=vec[i+k-1];
    if(left>0)ans=min(ans,right);
    else if(right<0)ans=min(ans,abs(left));
    else ans=min({ans,abs(left)*2+abs(right),abs(right)*2+abs(left)});
  }
  cout << ans << endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t m, k;
  std::cin >> m >> k;
  if (m == 1) {
    if (k == 0) {
      std::cout << "0 0 1 1" << std::endl;
    } else {
      std::cout << -1 << std::endl;
    }
  } else if ((1 << m) <= k) {
    std::cout << -1 << std::endl;
  } else {
    const auto max = (1 << m) - 1;
    for (int64_t i = 0; i <= max; i++) {
      if (i != k) {
        std::cout << i << " ";
      }
    }
    std::cout << k << " ";
    for (int64_t i = max; 0 <= i; i--) {
      if (i != k) {
        std::cout << i << " ";
      }
    }
    std::cout << k << std::endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int c[100];

int main()
{
	for (int i=1;i<=4;i++) {
		int x; scanf("%d",&x);
		c[x]++;
	}
	
	if (c[1]==1 && c[9]==1 && c[7]==1 && c[4]==1) puts("YES");
		else puts("NO");
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

input = sys.stdin.readline

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, Q, STX, D):
    E = []
    for i, (s, t, x) in enumerate(STX):
        E.append((s-x, 1, x, i))
        E.append((t-x, -1, x, i))
    E.sort(reverse=True)

    q = []
    done = set()
    ans = [-1] * Q
    for j, d in enumerate(D):
        while E and E[-1][0] <= d:
            t, e, x, i = E.pop()
            if e == 1:
                heapq.heappush(q, (x, i))
            else:
                done.add((x, i))

        while q and q[0] in done:
            done.remove(heapq.heappop(q))

        if q:
            ans[j] = q[0][0]

    for i in range(Q):
        print(ans[i])


def main():
    N, Q = read_int_n()
    STX = list(read_int_n() for _ in range(N))
    D = list(read_int() for _ in range(Q))
    (slv(N, Q, STX, D))


if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;

constexpr int MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	int mnx = INT_MAX, mny = INT_MAX, mxx = 0, mxy = 0;
	for (int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		int nx = x + y;
		int ny = y - x;
		mnx = min(mnx, nx);
		mny = min(mny, ny);
		mxx = max(mxx, nx);
		mxy = max(mxy, ny);
	}
	cout << max(mxx - mnx, mxy - mny) << '\n';
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define fs first
#define sc second

// 1次元vectorの出力
template <class S>
void print(vector<S> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    cerr << v[i] << ' ';
  }
  cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    for (ll j = 0; j < (ll)v[i].size(); j++) {
      cerr << v[i][j] << ' ';
    }
    cerr << endl;
  }
}

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	int r=0; int g=0; int b=0;
    for(char i: s){
		if(i == 'R') r++;
		else if(i == 'B') b++;
		else  g++;
	}
	ll ans = (ll)r * g * b;
	for(int mid=1; mid<n-1; mid++){
		for(int left=0; left<mid; left++){
			int right = mid + mid -left;
			if(right < n){
				if (s[left]!=s[mid] && s[mid]!=s[right] && s[left]!=s[right]) ans--;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3576
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>

using namespace std;
using ll = long long;

const int N = 701;

int g[N][N];
int comp[N];
int n;
int sz;
int p[N], q[N];

void dfs(int v) {
    p[sz] += comp[v] == 1;
    q[sz] += comp[v] == 2;
    for (int i = 1; i <= n; i++) {
        if (g[v][i] == 0 && v != i) {
            if (comp[i] == comp[v]) {
                cout << "-1\n";
                exit(0);
            }
            if (!comp[i]) {
                comp[i] = 3 - comp[v];
                dfs(i);
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g[a][b] = g[b][a] = 1;
    }
    for (int i = 1; i <= n; i++) {
        if (!comp[i]) {
            comp[i] = 1;
            dfs(i);
            sz++;
        }
    }
    int best = N * N;
    bitset<N> kek;
    kek.set(0);
    for (int i = 0; i < sz; i++) {
        kek = (kek << p[i]) | (kek << q[i]);
    }
    for (int i = 0; i <= n; i++) {
        if (kek[i]) {
            best = min(best, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
        }
    }
    cout << best << '\n';
    return 0;
}

Measured memory_bytes: 2176
S=input()
T=input()
l=len(T)

pos=[]
for i in range(len(S)-l+1):
    s_tmp=S[i:i+l]
    for s,t in zip(s_tmp, T):
        if s==t or s=="?":
            continue
        else:
            break
    else:
        pos.append(i)

if pos:
    p=pos[-1]
    S=S[:p]+T+S[p+l:]
    ans=""
    for s in S:
        if s=="?":
            ans+="a"
        else:
            ans+=s
    print(ans)
else:
    print("UNRESTORABLE")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {

    ll h,w,a,b; cin >> h >> w >> a >> b;
    rep(i,h){
        rep(j,w){
            if(j < a && i < b) cout << 1;
            else if(j < a && i >= b) cout << 0;
            else if(j >= a && i >= b) cout << 1;
            else if(j >= a && i < b) cout << 0;
        }
        cout << endl;
    }

}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main() {
	int a,b,x,y;
	int k;
	while(cin >> a >> b && a!=0){
		cin >> k;
		int DP[20][20]={};	
		bool isStone[20][20]={};		
	for(int i=0;i<k;i++){
			cin >> x >> y;
			isStone[x][y]=true;
		}
		DP[1][1]=1;
		for(int j=1;j<=b;j++)
			for(int i=1;i<=a;i++)
				if(i!=1||j!=1)
					if(!isStone[i][j])
						DP[i][j]=DP[i-1][j]+DP[i][j-1];
		cout << DP[a][b] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

import static java.lang.System.*;

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

        long[][] dp = new long[S.length() + 1][4];
        long prime = 1000000007;
        dp[0][0] = 1;
        for (int i = 1; i <= S.length(); i++) {
            for (int j = 0; j < 4; j++) {
                dp[i][j] = dp[i - 1][j];
                dp[i][j] %= prime;
            }
            if (S.charAt(i - 1) == 'A') {
                dp[i][1] += dp[i - 1][0];
                dp[i][1] %= prime;
            } else if (S.charAt(i - 1) == 'B') {
                dp[i][2] += dp[i - 1][1];
                dp[i][2] %= prime;
            } else if (S.charAt(i - 1) == 'C') {
                dp[i][3] += dp[i - 1][2];
                dp[i][3] %= prime;
            } else {
                for (int j = 0; j < 4; j++) {
                    dp[i][j] += 2 * dp[i - 1][j];
                    dp[i][j] %= prime;
                }
                dp[i][1] += dp[i - 1][0];
                dp[i][2] += dp[i - 1][1];
                dp[i][3] += dp[i - 1][2];
                dp[i][1] %= prime;
                dp[i][2] %= prime;
                dp[i][3] %= prime;
            }
        }

        out.println(dp[S.length()][3]);
    }
}

Measured memory_bytes: 31180
#include "bits/stdc++.h"

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define DOUBLE fixed << setprecision(10)
#define fi first
#define se second
const double pi = acos(-1.0);
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };
template <typename T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
};
template <typename T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
};
void Pvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void Pvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Ps(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void Pvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}

//最大公約数
ll gcd(ll m, ll n) {
	if ((0 == m) || (0 == n))
		return 0;

	// ユークリッドの方法
	while (m != n)
	{
		if (m > n) m = m - n;
		else         n = n - m;
	}
	return m;
}
//最小公倍数
ll lcm(ll m, ll n) {
	if ((0 == m) || (0 == n))
		return 0;

	return (m * n / gcd(m, n));
}

ll  n, m, r, l, k, h, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;

void INIT() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << DOUBLE;
}

int main() {
	INIT();
	ll a, b;
	cin >> a >> b;
	cout << max(a + b,max(a - b, a*b)) << endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  char a;
  IN(a);
  if('a'<=a && a<='z'){
    OUT('a');
  }else{
    OUT('A');
  }

  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,t[110],s;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",t+i),s+=t[i];
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		int p,x;
		scanf("%d%d",&p,&x);
		printf("%d\n",s-t[p]+x);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
	static BufferedReader br;
    static PrintWriter out;
    static StringTokenizer st;
	public static void main(String[] args) throws IOException{
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        //# is black, . is white
        int A = readInt(), B = readInt();
        char[][] grid = new char[100][100];
        for (int i=0; i<100; i++){
        	for (int j=0; j<50; j++){
        		grid[i][j] = '#';
        	}
        }
        for (int i=0; i<100; i++){
        	for (int j=50; j<100; j++){
        		grid[i][j] = '.';
        	}
        }
        A--; 
        B--;
        for (int i=0; i<100; i++){
        	for (int j=0; j<100; j++){
        		if (i%2==0 && j%2==0 && j<50 && A>0){
        			grid[i][j] = '.';
        			A--;
        		}else if (i%2==0 && j%2==1 && j>=50 && B>0){
        			grid[i][j] = '#';
        			B--;
        		}
        	}
        }
        System.out.println("100 " + "100");
        for (int i=0; i<100; i++){
        	for (int j=0; j<100; j++){
        		System.out.print(grid[i][j]);
        	}
        	System.out.println();
        }
        
	}
	static String next () throws IOException {
	    while (st == null || !st.hasMoreTokens())
	    st = new StringTokenizer(br.readLine().trim());
	    return st.nextToken();
	}

	static long readLong () throws IOException {
	    return Long.parseLong(next());
	}

	static int readInt () throws IOException {
	    return Integer.parseInt(next());
	}

	static double readDouble () throws IOException {
	    return Double.parseDouble(next());
	}

	static char readCharacter () throws IOException {
	    return next().charAt(0);
	}

	static String readLine () throws IOException {
	    return br.readLine().trim();
	}
	
}

Measured memory_bytes: 35656
def ok(s):
    for i in range(len(s)//2):
        if s[i] != s[len(s)-i-1]:
            return False
    return True

s = input()
n = len(s)

print("Yes" if ok(s) and ok(s[:(n-1)//2]) and ok(s[(n+3)//2-1:]) else "No")

Measured memory_bytes: 3060
#include<iostream>
#include<map>

int main(){
    std::string s;
    std::cin >> s;

    std::map<char, int> mp;
    for(char c = 'a'; c <= 'z'; c++){
        mp[c] = 0;
    }

    for(int i = 0; i < s.length(); i++){
        mp[s[i]]++;
    }

    for(char c = 'a'; c <= 'z'; c++){
        if(mp[c] == 0){
            std::cout << c << std::endl;
            return 0;
        }
    }

    std::cout << "None" << std::endl; 

}


Measured memory_bytes: 512
#include <stdio.h>

#define NUM 3

int main(void){
	int a, b;
	int area, circumference;
	int i;
	
	scanf("%d %d", &a, &b);
	
	area = a * b;
	circumference = 2 * a + 2 * b;
	
	printf("%d %d\n", area, circumference);	
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	string S;
	cin >> S;

	cout << S[0] << S.size() - 2 << S[S.size() - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
asum = 0
maxtemp = 0
bj = m
bsum = sum(b)
for i in range(n):
    if(asum >k):
        temp = i-1
        if(maxtemp < temp):
            maxtemp = temp
        break
    for j in range(bj):
        if(asum + bsum <= k):
            bj = bj - j
            temp = i + bj
            break
        bsum -= b[bj-1 - j]
    else:
        bj = 0
        temp = i
    if(maxtemp < temp):
        maxtemp = temp
    asum +=a[i]
for j in range(bj):
    if(asum + bsum <= k):
        bj = bj - j
        temp = n + bj
        break
    bsum -= b[bj-1 - j]
else:
    if(asum <= k):
        temp = n
if(maxtemp < temp):
    maxtemp = temp
print(maxtemp)

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

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

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

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

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n; cin>>n;
  vi a(n);
  int pos = -1;
  rep(i,0,n) {
    cin>>a[i];
    if(a[i] == 1 && pos == -1) {
      pos = i;
    }
  }
  if(pos == -1) {
    cout<<-1<<endl;
    return 0;
  }
  int k = 1;
  rep(i,pos,n) {
    if(a[i] == k) {
      k++;
    }
  }
  k--;
  cout<<n-k<<endl;
}



Measured memory_bytes: 1024
s = input()

if s == "SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Measured memory_bytes: 2940
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define fi first
#define se second
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;        
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }                                                                                   
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}             
const ll N=10;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll x;
  cin>>x;
  if(x==7||x==5||x==3)
  {
    cout<<"YES\n";
  }
  else cout<<"NO\n";
}
//nothing is impossible

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    n = int(input())
    a = [0]+list(map(int, input().split()))
    factor = sum([ abs(a[tmp]-a[tmp+1]) for tmp in range(n) ]) + abs(a[-1]-a[0])
    for position in range(1,n+1):
        if position != n:
            difference = abs(a[position-1]-a[position])+abs(a[position]-a[position+1])
            ans = factor-difference+abs(a[position-1]-a[position+1])
        else:
            difference = abs(a[position-1]-a[position])+abs(a[position]-a[0])
            ans = factor-difference+abs(a[position-1]-a[0])
        print(ans)

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  ll n, m=10000000000000009;
  cin >> n;
  for(int i=0; i<5; i++){
    ll tmp;
    cin >> tmp;
    m = min(m, tmp);
  }
  ll ans = n/m+4;
  if(n%m!=0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
vector <int> g[N];
int n,k;
ll ans;
ll bfs(int u,int fa,int dep)
{
    int tem=k-min(dep,2);
    for(int i=0; i<g[u].size(); i++)
    {
        int v=g[u][i];
        if(v==fa)
            continue;
        if(bfs(v,u,dep+1)==0)
            return 0;
        ans=ans*tem%mod;
        tem--;
    }
    return ans;
}
int main()
{
    cin>>n>>k;
    for(int i=1; i<n; i++)
    {
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    ans=k;
    printf("%lld\n",bfs(1,-1,1));
    return 0;
}


Measured memory_bytes: 15992
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=600+10,mod=1e9+7;
int n,m,g[maxn],dp[maxn][maxn],a[maxn],b[maxn],sum[maxn],ans;
inline bool check(int l,int r){
	REP(i,1,m) if((l<=a[i] && a[i]<=r)^(l<=b[i] && b[i]<=r)) return 0;
	return 1;
}
int main(){
	n=read()*2,m=read();
	REP(i,1,n) sum[i]=1;
	REP(i,1,m){
		a[i]=read(),b[i]=read();
		if(a[i]>b[i]) swap(a[i],b[i]);
		sum[a[i]]=sum[b[i]]=0;
	}
	REP(i,1,n) sum[i]+=sum[i-1];
	g[0]=1;
	REP(i,2,n) g[i]=(ll)g[i-2]*(i-1)%mod;
	for(int l=2;l<=n;l+=2) REP(i,1,n-l+1){
		int j=i+l-1;
		if(!check(i,j)) continue;
		dp[i][j]=g[sum[j]-sum[i-1]];
		for(int k=i-1;k<j;k+=2) dp[i][j]=(dp[i][j]-(ll)dp[i][k]*g[sum[j]-sum[k]])%mod;
		ans=(ans+(ll)dp[i][j]*g[sum[n]-sum[j]+sum[i-1]])%mod;
	}
	ans=(ans+mod)%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1664
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint ans(n);
    REP(i,n){
        int a;
        cin >> a;
        ans[a-1] = i+1;
    }
    REP(i,n){
        cout << ans[i] << ((i==n-1)?("\n"):(" "));
    }

    return 0;
}

Measured memory_bytes: 1280
from collections import Counter
from functools import reduce

N = int(input())

def pf(n):
    if n == 1: return []
    f = []
    for i in range(2, n + 1):
        while n % i == 0:
            f.append(i)
            n //= i
    return f

def main():
    li = []
    for i in range(1, N + 1):
        li += pf(i)
    ans = 1
    for v in Counter(li).values():
        ans *= v + 1
    print(ans % 1000000007)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
<?php
fscanf(STDIN, "%d %d", $n, $k);
$h = fgets(STDIN);
$hArr = explode(" ", $h);

$cnt = 0;
for($i=0; $i<$n; $i++) {
  if($hArr[$i] >= $k) $cnt ++;
}
echo $cnt;

Measured memory_bytes: 21620
import itertools
import math

def dist(xy1,xy2):
  x1,y1=xy1
  x2,y2=xy2
  return math.sqrt((x2-x1)**2+(y2-y1)**2)

N=int(input())
xylist=[]

for i in range(N):
  x,y=map(int,input().split())
  xylist.append((x,y))
  
#print(xylist)
allperm=list(itertools.permutations(range(N)))

allsum=0
for perm in allperm:
  for i in range(N-1):
    allsum+=dist(xylist[perm[i]],xylist[perm[i+1]])
    
print(allsum/len(allperm))

Measured memory_bytes: 7972
def intlog10(n):
    if n <= 0:
        return -1
    i = 0
    while 10**i <= n:
        i += 1
    return i-1

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
    
L = [2, 5, 5, 4, 5, 6, 3, 7, 6]
B = [[A[i], L[A[i]-1]] for i in range(M)]

best = sorted(B, key = lambda x: x[1]*10-x[0])[0]

adj = 0
if N > 500:
    adj = (N - 500)//best[1]
    N -= best[1] * adj

X = [0] + [-10**9] * N
for i in range(1, N+1):
    if i > 50 and i < N-50:
        X[i] = X[i-best[1]]*10 + best[0]
    else:
        for b in B:
            if b[1] <= i:
                if X[i-b[1]] == 0:
                    X[i] = max(X[i], b[0])
                else:
                    X[i] = max(X[i], X[i-b[1]]*10 + b[0])

ans = str(X[N])
if adj > 0:
    ans = ans[:50] + str(best[0]) * adj + ans[50:]

print(ans)


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

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

using ll = long long;

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  whole(sort, a, greater<int>());
  ll prev = 0;
  ll height = 0, width = 0;
  REP(i,n) {
    if (height && width) break;
    if (prev == a[i]) {
      if (height) width = a[i];
      else height = a[i];
      prev = 0;
    } else {
      prev = a[i];
    }
  }
  cout << height * width << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;
#define DUMPR(v) REP(_i,v.size()){std::cerr<< #v << "[" << _i << "] = " << (v[_i]) << std::endl;}
#define CIN_VEC(v,N) {v.clear(); v.reserve(N); REP(i,N){typename decltype(v)::value_type x; cin>>x; v.emplace_back(x);}};

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;

int main() {
  int N;
  cin>>N;
  vector<int> a;
  CIN_VEC(a,N);
  sort(a.begin(), a.end());

  map<int,int> counts;
  set<int> values(a.begin(), a.end());

  for(const auto x : values) {
    auto low = lower_bound(a.begin(), a.end(), x);
    auto up  = upper_bound(a.begin(), a.end(), x);
    int sz = up - low;
    counts[x] = sz;
  }

  int ans = 0;
  for(auto p : counts) {
    auto x = p.first;
    auto sz = p.second;

    if(sz < x) ans += sz; // erase all
    else ans += sz - x;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		
		int n = s.length();
		
		for(int i = 0 ; i < n ;i++) {
			if(s.charAt(i) != t.charAt(i)) {
				System.out.println("No");
				return;
			}
		}
		
		System.out.println("Yes");
		
	}

}


Measured memory_bytes: 35700
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_int_list():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


def main():
    a, b = get_int_list()
    if b % a == 0:
        print(a + b)
    else:
        print(b - a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
N,M = map(int, input().split())

G = [[] for _ in range(N)]
INF = 10**9
D = [[ INF for _ in range(N)] for _ in range(N)]
for i in range(N):
  D[i][i] = 0

E = []
for _ in range(M):
  a,b,c = map(int, input().split())
  a,b = a-1, b-1
  G[a].append((b,c))
  G[b].append((a,c))
  D[a][b] = c
  D[b][a] = c
  E.append((a,b,c))
  

for k in range(N):
  for i in range(N):
    for j in range(N):
      if D[i][k] + D[k][j] < D[i][j]:
        D[i][j] = D[i][k] + D[k][j]
        D[j][i] = D[i][k] + D[k][j]
  
ans = 0
for a,b,c in E:
  flg = False
  for i in range(N):
    if D[i][a] + c == D[i][b]:
      flg = True
      break
   
  if not flg:
    ans += 1
    
print(ans)

Measured memory_bytes: 9480
'use strict' 
function main(inp) {
    inp = inp.trim().split(' ');
    let N = parseInt(inp[0]);
    let K = parseInt(inp[1]);
    let ans = 0;
    while (N >= K) {
        N = N / K;
        ++ans;
    }
    console.log(ans + 1);
}

// 変更しない
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>

using namespace std;

int arr[100000];
bool cont[100000];
int n, m;
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("inout.txt", "w", stdout);
    scanf("%d %d\n", &n, &m);
    for (int i = 0; i < n; i++)
        arr[i] = 1;
    cont[0] = true;
    for (int i = 0; i < m; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--;
        b--;
        if (cont[a])
            cont[b] = true;
        arr[a]--;
        arr[b]++;
        if (arr[a] == 0)
            cont[a] = false;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
        if (cont[i])
            cnt++;
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,W,H,h,w;
    cin >>H>>W;
    cin >>h>>w;
    ans=(H-h)*(W-w);

    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#![allow(unused_imports)]
    #![allow(dead_code)]
    use std::io::prelude::*;
    use std::cmp::{max, min};
    use std::collections::BinaryHeap;

    const MOD: i64 = 1e9 as i64 + 7; 

    fn main(){
        let n: isize = read();
        let mut ans: isize = 1 << 30;
        for i in 0..n+1{
            let mut c: isize = 0;
            let mut x: isize = i;
            while x > 0{
                c += x % 6;
                x /= 6;
            }
            x = n - i;
            while x > 0{
                c += x % 9;
                x /= 9;
            }
            ans = min(ans, c);
        }
        println!("{}", ans);
    }

    fn read<T>() -> T
    where
        T: std::str::FromStr,
    {
        let stdin = std::io::stdin();
        let token: String = stdin
            .lock()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        token.parse().ok().unwrap()
    }


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

int main(){
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;

    int ans = 0;
    int flag=0;
    if(N-K < 0){
        ans += N*X;
    }else{
        ans += K*X + (N-K)*Y;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
  
  	if(a+b > c+d)
    	cout << "Left" << endl;
	else if(a+b == c+d)
        cout << "Balanced" << endl;
  	else
      	cout << "Right" << endl;
  
  	return 0;
}


Measured memory_bytes: 256