akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

struct _node_table {
	int* next_node;
	int* cost;
	int size;
	int capacity;
} node_table[100005];

long long int dp[100005];

void init_node(int i) {
	node_table[i].capacity = 10;
	node_table[i].next_node = (int*)malloc(node_table[i].capacity*sizeof(int));
	node_table[i].cost = (int*)malloc(node_table[i].capacity*sizeof(int));
	node_table[i].size = 0;
}

void free_node(int i) {
	free(node_table[i].next_node);
	free(node_table[i].cost);
}

void grow_node(int s) {
	if(node_table[s].capacity < node_table[s].size * 1.25) {
		int size, i;
		int* next_node = node_table[s].next_node;
		int* cost = node_table[s].cost;
		node_table[s].capacity *= 1.5;
		node_table[s].next_node = (int*)malloc(node_table[s].capacity*sizeof(int));
		node_table[s].cost = (int*)malloc(node_table[s].capacity*sizeof(int));
		for(i=0,size=node_table[s].size;i<size;i++) {
			node_table[s].next_node[i] = next_node[i];
			node_table[s].cost[i] = cost[i];
		}
		free(next_node);
		free(cost);
	}
}

void add_next_node(int s, int t, int d) {
	int size = node_table[s].size;
	node_table[s].next_node[size] = t;
	node_table[s].cost[size] = d;
	node_table[s].size++;

	grow_node(s);
}

#define QUEUE_MAX 1000000
void solve(int r, int V) {
	int i, size, from, to, cost;
	int queue[QUEUE_MAX];
	long long int wp, rp;

	for(i=0;i<V;i++) dp[i] = INT_MAX;
	dp[r] = 0;

	wp = rp = 0;
	queue[wp++%QUEUE_MAX] = r;

	while(wp>rp) {
		from = queue[rp++%QUEUE_MAX];

		for(i=0,size=node_table[from].size;i<size;i++) {
			to = node_table[from].next_node[i];
			cost = node_table[from].cost[i];

			if(cost+dp[from] < dp[to]) {
				queue[wp++%QUEUE_MAX] = to;
				dp[to] = cost+dp[from];
			}
		}
	}
}

int main(void) {
	int i, V, E, r;
	scanf("%d %d %d\n", &V, &E, &r);
	for(i=0;i<V;i++) init_node(i);

	for(i=0;i<E;i++) {
		int s, t, d;
		scanf("%d %d %d\n", &s, &t, &d);
		add_next_node(s, t, d);
	}

	solve(r, V);

	for(i=0;i<V;i++) {
		free_node(i);
		if(dp[i] == INT_MAX) {
			printf("INF\n");
		} else {
			printf("%d\n", dp[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 16524
# 上一列だけ見るのでよくない？なんなら直前のやつだけでもいいんじゃない？
# あ 敷き詰め方は与えられるのか。それも含めて総数を出すのかと思ってた
# 雑に試したらいけたっぽい ifを重ねるたびに不安になる
# 直前が縦に同じ色で今が縦に同じ色 -> 2種類使える
# 直前が縦に同じ色で今が横に同じ色 -> （直前に使った色以外の2種類を縦に重ねる組み合わせで）2種類使える
# 直前が横に同じ色で今が縦に同じ色 -> （直前に2色使っているので）1色だけ使える
# 直前が横に同じ色で今が横に同じ色 -> （直下参照）3パターンある

# --- 縦に2種類使った後に縦に2種類使う組み合わせ ---
# 1 - 2,2,3
# 2 - 1,3,1
# よって3パターン

n = int(input())
s1, s2 = input(), input()
ans = 0
idx = 0
MOD = 10**9 + 7
pre = -1  # i-1の色の数 1or2
while idx < n:
    if s1[idx] == s2[idx]:
        if idx == 0:
            ans = 3
        else:
            if pre == 1:
                ans *= 2
            elif pre == 2:
                ans *= 1  # 直前で使ってない色だけ使える
        pre = 1
        idx += 1
    else:
        if idx == 0:
            ans = 6
        else:
            if pre == 1:
                ans *= 2
            elif pre == 2:
                ans *= 3
        pre = 2
        idx += 2
    ans %= MOD

print(ans)

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

int gcd(int x, int y) {
	if (y == 0)return x;
	else return gcd(y, x%y);
}

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

	int g;

	if (n == 2) {
		int a, b;
		cin >> a >> b;
		g = gcd(a, b);
	}

	else {
		int a, b, c;
		cin >> a >> b >> c;
		int d = gcd(a, b);
		g = gcd(c, d);
	}

	vector<int>v;
	for (int i = 1;i*i <= g;i++) {
		if (g%i == 0) {
			if (g / i == i)v.push_back(i);
			else {
				v.push_back(i);
				v.push_back(g / i);
			}
		}
	}
	sort(v.begin(), v.end());

	for (int i = 0;i < v.size();i++) {
		cout << v[i] << endl;
	}
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a != 0 ? gcd (b % a, a) : b; }

const int mod = 1000*1000*1000+7;
const int rev2 = (mod + 1) / 2;

int n;
int m;
int v[3000];
ii w[3000];
int g[3000][3000];
int u[3000][3000];
int was[3000][3000];
int x[3000];
int y[3000];
int ct;

inline int get (int i, int j) {
	if (was[i][j] == ct) re u[i][j];
	re g[i][j];
}

inline int apply (int a, int b, int c) {
	if (a == b) re c;
	if (a == c) re b;
	re a;
}

inline int div2 (int x) {
	if (!(x & 1)) re x >> 1;
	if (x < mod) re (x + mod) >> 1; else re (x - mod) >> 1;
}

int main () {
	scanf ("%d%d", &n, &m);
	for (int i = 0; i < n; i++) scanf ("%d", &v[i]);
	int tot = 1;
	for (int i = 0; i < m; i++) {
		scanf ("%d%d", &x[i], &y[i]); x[i]--; y[i]--;
		tot = (tot * 2) % mod;
	}
	memset (g, 0, sizeof (g));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			g[i][j] = int (i < j);
	ct = 0;
	for (int i = m - 1; i >= 0; i--) {
		ct++;
		int a = x[i];
		int b = y[i];
		for (int j = 0; j < n; j++) {
			was[j][a] = was[j][b] = was[a][j] = was[b][j] = ct;
			u[j][a] = g[j][a];
			u[j][b] = g[j][b];
			u[a][j] = g[a][j];
			u[b][j] = g[b][j];
		}
		for (int t = 0; t < n; t++) {
			if (a < t) {
				int j = a;
				int k = t;
				int nj = b;
				int nk = apply (k, a, b);
				g[j][k] = div2 (g[j][k] + get (nj, nk));
				g[k][j] = mod + 1 - g[j][k];
				if (g[k][j] >= mod) g[k][j] -= mod;
			}
			if (b < t) {
				int j = b;
				int k = t;
				int nj = a;
				int nk = apply (k, a, b);
				g[j][k] = div2 (g[j][k] + get (nj, nk));
				g[k][j] = mod + 1 - g[j][k];
				if (g[k][j] >= mod) g[k][j] -= mod;
			}
			if (t < a && t != a && t != b) {
				int j = t;
				int k = a;
				int nj = apply (j, a, b);
				int nk = b;
				g[j][k] = div2 (g[j][k] + get (nj, nk));
				g[k][j] = mod + 1 - g[j][k];
				if (g[k][j] >= mod) g[k][j] -= mod;
			}
			if (t < b && t != a && t != b) {
				int j = t;
				int k = b;
				int nj = apply (j, a, b);
				int nk = a;
				g[j][k] = div2 (g[j][k] + get (nj, nk));
				g[k][j] = mod + 1 - g[j][k];
				if (g[k][j] >= mod) g[k][j] -= mod;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (v[i] > v[j])
				ans = (ans + g[i][j]) % mod;
	ans = ((ll)ans * tot) % mod;
	cout << ans << endl;
	cerr << clock () << endl;
	return 0;
}

Measured memory_bytes: 105728
#include <iostream>

using namespace std;
typedef long long ll;

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

    bool ret = true;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0)ret = false;
    }
    cout << (ret ? "APPROVED" : "DENIED") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N, M;
llint x[1010], y[1010], z[1010];


llint solve(){
	llint ans = 0;
	rep(i, 0, 1<<3){
		VLL v;
		rep(j, 0, N){
			llint sum = (int)pow(-1, i&1)*x[j]+(int)pow(-1, (i>>1)&1)*y[j]+(int)pow(-1, (i>>2)&1)*z[j];
			v.pb(sum);
		}
		sort(ALL(v), greater<llint>());
		ans = max(ans, accumulate(v.begin(), v.begin()+M, 0LL));
	}
	return ans;
}


signed main(){
	cin >> N >> M;
	rep(i, 0, N) cin >> x[i] >> y[i] >> z[i];

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=5010; //check the limits, dummy
ll a[N], b[N];
ll n, k;
int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=0; i<n; ++i){
		scanf("%lld",a+i);
		--a[i];
	}
	for(int i=0; i<n; ++i){
		scanf("%lld",b+i);
	}
	ll ans=-1e9, tmp, sm, cnt, tmp1, tmp2;
	for(int i=0; i<n; ++i){
		sm=0;
		tmp=i;
		for(int j=1; j<=min(k, 3*n); ++j){
			sm+=b[tmp];
			tmp=a[tmp];
			ans=max(ans, sm);
		}
		if(k>3*n){
			tmp=i;
			sm=0;
			cnt=0;
			for(int j=0; 1; ++j){
				++cnt;
				sm+=b[tmp];
				tmp=a[tmp];
				if(tmp==i){
					break;
				}
			}
			auto sm1=sm;
			sm=0;
			tmp2=0;
			for(int j=1; j<=k%cnt; ++j){
				sm+=b[tmp];
				tmp=a[tmp];
				tmp2=max(tmp2, sm);
			}
			tmp2+=k/cnt*sm1;
			ans=max(ans, tmp2);
			tmp2=0;
			sm=0;
			tmp2=0;
			for(int j=1; j<=cnt; ++j){
				sm+=b[tmp];
				tmp=a[tmp];
				tmp2=max(tmp2, sm);
			}
			tmp2+=(k/cnt-1)*sm1;
			ans=max(ans, tmp2);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3728
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);


void init() {
     
}

void solve() {
    int n; scanf(I,&n);
    int r = n % 10;
    if (r == 3) puts("bon");
    else if (r == 0 || r == 1 || r == 6 || r == 8) puts("pon");
    else puts("hon");
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 3656
///
// File:  2013.cpp
// Author: ymiyamoto
//
// Created on Sun Nov 19 01:11:43 2017
//

#include <array>
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t n;
    cin >> n;
    if (n == 0) break;

    array<int32_t, 24 * 60 * 60> arr{0};
    for (uint32_t _ = 0; _ < n; _++) {
      uint32_t h, m, s;
      char __;
      cin >> h >> __ >> m >> __ >> s;
      arr[60 * 60 * h + m * 60 + s]++;
      cin >> h >> __ >> m >> __ >> s;
      arr[60 * 60 * h + m * 60 + s]--;
    }

    int32_t max_val = arr[0];
    for (uint32_t i = 0; i < arr.size() - 1; i++) {
      arr[i + 1] += arr[i];
      max_val = max(max_val, arr[i + 1]);
    }
    cout << max_val << endl;
  }
  return 0;
}

Measured memory_bytes: 3424
num = list(input())
count_c = num[2:-1].count("C")

if num[0] != "A":
  print("WA")
else:
  if count_c > 1:
    print("WA")
  else:
    if count_c == 1:
      num.remove("C")
      num.remove("A")
      jadge = "".join(num)
      if jadge:
        suuzi = "false"
        for i in range(len(num)):
          if num[i].isdecimal():
            suuzi = "true"
            break
          elif num[i].isupper():
            suuzi = "true"
            break
        if(suuzi == "false"):
          print("AC")
        else:
          print("WA")
      else:
        print("WA")
    else:
      print("WA")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)

constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;


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

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

	double ans = 0.0;
	rep(i, 1, n + 1) {
		int j = i;
		int cnt = 0;
		while (j < k) {
			j <<= 1;
			cnt++;
		}
		ans += pow(0.5, (double)cnt) / (double)n;
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;



int main(){
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a;  cin >> a;
    cout << a + a*a + a*a*a << endl;
}


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

int main() {
    int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
    vector<int> p(A), q(B), r(C);
    for (int i = 0; i < A; i++) cin >> p[i];
    for (int i = 0; i < B; i++) cin >> q[i];
    for (int i = 0; i < C; i++) cin >> r[i];
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());

    vector<int> vec;
    for (int i = 0; i < X; i++) vec.push_back(p[A-i-1]);
    for (int i = 0; i < Y; i++) vec.push_back(q[B-i-1]);
    for (int i = 0; i < C; i++) vec.push_back(r[i]);

    sort(vec.begin(), vec.end());
    ll ans = 0;
    for (int i = 0; i < X+Y; i++) {
        ans += vec[vec.size() - i - 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

int Y, X;
char g[505][505];

int main() {
    scanf("%d%d", &Y, &X);
    for (int y = 0; y < Y; y++) scanf(" %s", g[y]);
    for (int y = 0; y < Y; y++) {
        for (int x = 0; x < X; x++) {
            if (x < X-1 && (x == 0 || y%2 == 1 || g[y][x] == '#')) printf("#");
            else printf(".");
        }
        printf("\n");
    }
    printf("\n");
    for (int y = 0; y < Y; y++) {
        for (int x = 0; x < X; x++) {
            if (x != 0 && (x == X-1 || y%2 == 0 || g[y][x] == '#')) printf("#");
            else printf(".");
        }
        printf("\n");
    }
}


Measured memory_bytes: 1024
ans [] = 0
ans ('I':'V':xs) =   4 + ans xs
ans ('I':'X':xs) =   9 + ans xs
ans ('X':'L':xs) =  40 + ans xs
ans ('X':'C':xs) =  90 + ans xs
ans ('C':'D':xs) = 400 + ans xs
ans ('C':'M':xs) = 900 + ans xs
ans ('I':xs)     =   1 + ans xs
ans ('V':xs)     =   5 + ans xs
ans ('X':xs)     =  10 + ans xs
ans ('L':xs)     =  50 + ans xs
ans ('C':xs)     = 100 + ans xs
ans ('D':xs)     = 500 + ans xs
ans ('M':xs)     =1000 + ans xs

main = do
  c <- getContents
  let i = lines c
      o = map ans i
  mapM_ print o

Measured memory_bytes: 3464
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;


 
 
int main(){
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	rep(i,tx-sx)cout<<"R";
	rep(i,ty-sy)cout<<"U";
	rep(i,tx-sx)cout<<"L";
	rep(i,ty-sy+1)cout<<"D";
	rep(i,tx-sx+1)cout<<"R";
	rep(i,ty-sy+1)cout<<"U";
	rep(i,1)cout<<"L";
	rep(i,1)cout<<"U";
	rep(i,tx-sx+1)cout<<"L";
	rep(i,ty-sy+1)cout<<"D";
	rep(i,1)cout<<"R";
	cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>

#include <string>

using std::cin;
using std::cout;
using std::endl;

using std::string;

static int
solve(string const &s)
{
  char const *top = s.data();
  while (*top != 'A')
  {
    top++;
  }
  char const *bot = s.data() + s.size();
  while (*--bot != 'Z')
  {
  }
  return bot - top + 1;
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int S, a, b, c, d;
  cin >> S;
  
  a = S % 10;
  b = (S - a) /10 % 10;
  c = (S - a - b * 10) / 100;
  d = a + b + c;
  
  cout << d << endl;
}


Measured memory_bytes: 3640
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	double r;
	cin>>r;
	double circum=2*pi*r;
	cout<<circum;


#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}

Measured memory_bytes: 3820
while True:
    a = input().split()
    if a == ["#"]:
        break
    a[1] = int(a[1])
    a[2] = int(a[2])
    if a[1] >= 32 or (a[1] == 31 and a[2] >= 5):
        a[1] -= 30
        a[0] = "?"
    a[1] = str(a[1])
    a[2] = str(a[2])
    print(" ".join(a))


Measured memory_bytes: 5604
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

struct Input
{
	int n;
	int k;
	int[] h;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto nk = readln().strip().split();
		n = nk[0].to!int;
		k = nk[1].to!int;

		auto array = readln().strip().split();
		h = array.map!(a=>a.to!int).array;
	}
}

struct Output
{
}

auto main2(Input* input)
{
	uint result = 0;
	foreach (h; input.h)
	{
		if (h >= input.k)
			result++;
	}
	return result;
}

unittest { writeln("begin unittest"); }

unittest // example1
{
	string example =
`4 150
150 140 100 200`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 2);
}

unittest // example2
{
	string example =
`1 500
499`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 0);
}

unittest // example3
{
	string example =
`5 1
100 200 300 400 500`;
	Input input = void;
	parseExample(input, example);
	auto result = main2(&input);
	writeln(result);
	assert(result == 5);
}

unittest { writeln("end unittest"); }

void parseExample(out Input input, string example)
{
	struct Adapter
	{
		string[] _lines;
		this(string input) { _lines = input.splitLines(); }
		string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
	}
	parseInput(input, Adapter(example));
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	auto result = main2(&input);
	writeln(result);
}


Measured memory_bytes: 4092
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var A=Arr.shift();
   if(A=="0 0 0")break;
   var arr=A.split(" ").map(Number);
   var m=arr[1];
   var start=arr[2];
   var hpq=[];
   for(var i=0;i<m;i++)hpq.push(Arr.shift());
   hpq.sort(function(a,b){
      a=(a.split(" "))[0]-0;
      b=(b.split(" "))[0]-0;
      if(a>=b)return -1;
      else return 1;
   });
  var H=1001;
   for(var i=0;i<hpq.length;i++){
      var HPQ=hpq[i].split(" ").map(Number);
      var h=HPQ[0];
      var p=HPQ[1];
      var q=HPQ[2];
      if(H==h)continue;
      if(start==p || start==q){
         H=h;
         start=(start==p)?q:p;
      }
   }
   console.log(start);
}

Measured memory_bytes: 30836
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
int a,b,c,d,e;
int main(){
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	puts(abs(a-c)<=1ll*(b-d)*e?"YES":"NO");
	return 0;
}

Measured memory_bytes: 3760
#ifndef ___Class_Union_Find
#define ___Class_Union_Find

#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

class Union_Find
{
private:

    vector<int> data;
    
public:

    Union_Find(unsigned size_) : data(size_, -1) { }
    
    void unite(int x, int y);
    
    bool same(int x, int y);
    
    int root(int x);
};

void Union_Find::unite(int x, int y)
{
    x = root(x);
    y = root(y);
    
    if (x != y)
    {
        if (data[x] < data[y])
        {
            swap(x, y);
        }
        
        data[x] += data[y];
        data[y] = x;
    }
}

bool Union_Find::same(int x, int y)
{
    return root(x) == root(y);
}

int Union_Find::root(int x)
{
    return data[x] < 0 ? x : data[x] = root(data[x]);
}

#endif // ___Class_Union_Find


// ------ main ------ //

#include <cstdio>

int n, m, q, x, y;

int main()
{
    scanf("%d", &n);
    scanf("%d", &m);
    
    Union_Find u(n);
    
    for (int i = 0; i < m; i++)
    {
        scanf("%d", &x);
        scanf("%d", &y);
        
        u.unite(x, y);
    }
    
    scanf("%d", &q);
    
    for(int i = 0; i < q; i++)
    {
        scanf("%d", &x);
        scanf("%d", &y);
        
        printf("%s\n", u.same(x, y) ? "yes" : "no");
    }
    
    return 0;
}

Measured memory_bytes: 3340
from collections import defaultdict
import math
def comb(n,r):
	if n < r:
		return 0
	return int(math.factorial(n) / (math.factorial(r) * math.factorial(n-r)))

N = int(input())
A = list(map(int,input().split()))
cum_sum = [0] * N
cum_sum[0] = A[0]
for i in range(1,N):
	cum_sum[i] = cum_sum[i-1] + A[i]

cnt = defaultdict(int)
for cs in cum_sum:
	cnt[cs] += 1

res = 0
for key,value in cnt.items():
	if key == 0:
		res += value
	res += comb(value, 2)

print(res)


Measured memory_bytes: 41776
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
int n;
int l[2009];
int memo[2009][9][2009];

int dp(int i,int cnt,int sum){
  if(memo[i][cnt][sum]!=-1)return memo[i][cnt][sum];
  if(i==n)return 0;
  int rec=dp(i+1,cnt,sum);
  if(cnt==2){
    if(l[i]<sum)rec++;
  }
  else{
    rec+=dp(i+1,cnt+1,sum+l[i]);
  }
  return memo[i][cnt][sum]=rec;
}

int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n;
  rep(i,n){
    cin>>l[i];
  }
  sort(l,l+n);

  cout<<dp(0,0,0)<<endl;

  return(0);
}


Measured memory_bytes: 142208
#include <iostream>
#include <iomanip>
 int main() {
  double r;
  std::cin >> r;
  double a, b;
  a = 1.0 * r*r*3.141592653589;
  b = 1.0 * 2*r*3.141592653589;
  std::cout << std::fixed << std::setprecision(10);
  std::cout << a << " " << b <<std::endl;



 return 0;


}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
	int N;
	cin >> N;
	int cnt = 0;
	bool f = false;
	for(int i=0; i<N; i++){
		int x,y;
		cin >> x >> y;
		if(x == y) cnt++;
		else cnt = 0;
		if(cnt == 3) f = true;
	}

	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ub              upper_bound
#define lb              lower_bound
#define isrt            insert
#define clr             clear
#define rsz             resize
#define ff              first
#define ss              second
#define lli             long long int
#define pb              push_back
#define pf              push_front
#define mkp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<int>
#define mii             map<lli,lli>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define INF             1e9
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define endl            "\n"
const double PI = acos(-1);

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

lli maxm(lli a, lli b)
{
  return (a >= b ? a : b);
}


lli minm(lli a, lli b)
{
  return (a <= b ? a : b);
}

lli power(lli x, lli y, lli p)
{
  lli res = 1;

  x = x % p;
  if (x == 0)
    return 0;

  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;


    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

lli nCrmodp(lli n, lli r, lli p)
{
  if (r == 0)
    return 1;
  if (r == 1)
    return n;


  lli pro = 1, k = n;
  while (k > r)
  {
    pro *= k;
    pro %= p;
    --k;
  }

  k = 2;
  while (k <= (n - r))
  {
    pro *= power(k, (p - 2), p);
    pro %= p;
    ++k;
  }

  return pro;
}


lli first_big(lli n, lli k, vector<lli> arr)
{
  lli l, r, ans = n;
  l = 0;
  r = n - 1;

  while (l <= r) {
    lli m = l + (r - l) / 2;

    if (arr[m] > k) {
      ans = m;
      r = m - 1;
    }

    else
      l = m + 1;
  }

  return ans;
}

lli last_small(lli n, lli k, vector<lli> arr)
{
  lli l, r, ans = -1;
  l = 0;
  r = n - 1;

  while (l <= r)
  {
    lli mid = (l + r) / 2;

    if (arr[mid] <= k)
    {
      ans = mid;
      l = mid + 1;
    }
    else
      r = mid - 1;
  }

  return ans;
}

void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int main()
{
  c_p_c();

  lli n, ans = 0, s1 = 1e18, s2 = 0, s3 = 1e18, s4 = (-1) * 1e18;

  vector<pii>v;

  cin >> n;
  lli x, y;

  for (int i = 0; i < n; ++i)
  {
    cin >> x >> y;
    v.pb(make_pair(x, y));
  }

  sort(all(v));

  for (int i = 0; i < n; ++i)
  {
    lli s = v[i].ff + v[i].ss;
    s1 = minm(s, s1);
    s2 = maxm(s, s2);

    s = v[i].ff - v[i].ss;
    s3 = minm(s, s3);
    s4 = maxm(s, s4);

  }


  lli p, q;
  p = s2;
  p -= s1;

  q = s4;
  q -= s3;

  ans = maxm(p, q);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7428
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int w, h ,n;
  cin >> w >> h >> n;
  int xl = 0, xm = w, yl = 0, ym = h;
  for(int i = 0; i < n; i++){
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1){
     xl = max(x,xl);
    } else if(a == 2){
      xm = min(x,xm);
    } else if(a == 3){
      yl = max(y,yl);
    } else if(a == 4){
      ym = min(y,ym);
    }
  }
  int ans = (xm - xl) * (ym - yl);
  if(xm < xl || ym < yl){
    cout << 0 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val mod = 1000000007L
    val n = readLine()!!.toInt()
    val s = readLine()!!
    readLine()!!
    var i = if (s[0] == s.getOrNull(1)) 2 else 1
    var ans = if (s[0] == s.getOrNull(1)) 6L else 3L
    var before = if (s[0] == s.getOrNull(1)) "yoko" else "tate"

    while (i < s.length) {
        val cur = if (s[i] == s.getOrNull(i+1)) "yoko" else "tate"
        if (s[i] == s.getOrNull(i+1)) i += 2 else i++
        when {
            (before == "tate" && cur == "tate") -> {ans*=2}
            (before == "tate" && cur == "yoko") -> {ans*=2}
            (before == "yoko" && cur == "tate") -> {ans*=1}
            (before == "yoko" && cur == "yoko") -> {ans*=3}
        }
        ans%=mod
        before = cur
    }
    println(ans)
}

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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m;
	cin >> n >> m;

	typedef tuple<int, int, int> t;
	priority_queue<t> pq;

	for (int i = 0, x; i < n; ++i)
	{
		cin >> x;
		pq.push(make_tuple(x, 1, x));
	}

	while (m--)
	{
		t u = pq.top();
		pq.pop();
		if (get<0>(u) == 0) break;
		t v = make_tuple(get<2>(u) / (get<1>(u) * 2), get<1>(u) * 2, get<2>(u));
		pq.push(v);
	}

	ll ans = 0;
	while (!pq.empty())
	{
		ans += get<0>(pq.top());
		pq.pop();
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

			String str = reader.readLine();
			double r = Double.parseDouble(str);
			String S = String.format("%.5f", r * r * Math.PI);
			String C = String.format("%.5f", 2 * r * Math.PI);
			System.out.println(S + " " + C);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

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

const int N = 3054, mod = 1000000007;

int n, q;
int ri[N], f[N][N];
int S[N];
char s[N];

inline int & up(int &x, const int y) {return x < y ? x = y : x;}
inline void add(int &x, const int y) {x += y - mod, x += x >> 31 & mod;}

int main() {
	int i, j, k, l, r, cur, append;
	scanf("%d%d%s", &n, &q, s + 1);
	for (; q; --q) scanf("%d%d", &l, &r), up(ri[l], r);
	for (i = 1; i <= n; ++i) up(up(ri[i], ri[i - 1]), i), S[i] = S[i - 1] + (s[i] & 1);
	f[0][ S[ri[1]] ] = 1, ri[n + 1] = n;
	for (i = 0; i < n; ++i)
		for (j = 0, k = ri[i + 1] - i; k >= 0; ++j, --k) if (cur = f[i][j]) {
			append = S[ri[i + 2]] - S[ri[i + 1]];
			if (j) add(f[i + 1][j - 1 + append], cur);
			if (k) add(f[i + 1][j + append], cur);
		}
	printf("%d\n", *f[n]);
	return 0;
}

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

using namespace std;

int n;
int a[51];

int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
        scanf("%d",&a[i]);
    sort(a + 1,a + 1 + n);
    double sum = a[1] * 1.0;
    for(int i = 2;i <= n;i++)
    {
        sum = (sum + a[i]) / 2.0;
    }
    printf("%.8f\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main()
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i = 0 ; i <= VMAX ; i++)
    {
      C[i]=0;
    }

  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&A[i+1]);
      C[A[i+1]]++;

    }

  for(i = 1 ; i <= VMAX ; i++)
    {
      C[i] = C[i] + C[i - 1];
    }

  for(j = 0 ; j <= n ; j++)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }

  for(i = 1 ; i <= n ; i++)
    {
      if(i > 1) printf(" ");

      printf("%d",B[i]);
    }
  printf("\n");

  return 0;
}



Measured memory_bytes: 9712
N,K = map(int,input().split())
M = 10 ** 9 + 7
l = [0] * (K + 1)
cnt = 0
for k in range(K,0,-1):
    a = pow(K // k, N, M)
    l[k] = a - sum(l[k*2::k])
for k in range(1,K + 1):
    cnt += k * l[k]
print(cnt % M)


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

using namespace std;

string s;
int k;

int main(int argc, char const *argv[]){
	
	cin >> s >> k;
	int n = s.size();

	int have = k;

	for(int i=0; i<n; i++) {
		if(s[i] == 'a') continue;
		int need = 'z' - s[i];
		need++;
		if(need > have) {
			continue;
		}
		s[i] = 'a';
		have -= need;
	}

	have %= 26;
	
	int idx = -1;
	for(int i=n-1; i>=0; i--) {
		if(s[i] != 'a') {
			idx = i;
			break;
		}
	}

	if(idx == -1) {
		s[n-1] = char('a' + have);
	}
	else {
		s[idx] = char(s[idx] + have);
	}

	cout << s;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int k;
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>k;
    k++;
    vector<int>a,b;
    int cur=1,n=0;
    while(cur*2<=k){
        n++;
        a.pb(n),b.pb(n);
        cur*=2;
    }
    k-=cur;
    for(int i=50;i>=0;i--){
        if((k>>i)&1){
            n++;
            vector<int>c;
            if(i==0){
                c.pb(n);
                for(int j:a)c.pb(j);
                a=c;
            }
            else{
            rep(j,a.size()){
                c.pb(a[j]);
                if(a[j]==i)c.pb(n);
            }
            }
            a=c;
            b.pb(n);
        }
    }
    cout<<2*n<<endl;
    for(int i:a)cout<<i<<" ";
    for(int i:b)cout<<i<<" ";
    cout<<endl;
    return 0;
}

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

int main()
{
  for ( ; ; ) {
    int a, b;
    vector<int> g(101, 0);
    while (cin >> a >> b) {
      if ((a|b) == 0)
	break;
      ++g[a];
      ++g[b];
    }
    
    if (cin.eof())
      break;

    bool valid = true;
    for (int i = 3; i < g.size(); ++i) {
      if (g[i] & 1)
	valid = false;
    }
    
    if ((g[1] & 1) && (g[2] & 1) && valid)
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
 
using ll = long long;
const ll mod = 998244353;
 
 
ll dp[3030][3030][3];
int a[3030];
int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0;i<n;i++)
      cin >> a[i];
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            (dp[i+1][j][0] += dp[i][j][0]) %= mod;
            (dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
            (dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
            if(j + a[i] <= k){
                (dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
                (dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
            }
        }
    }
    cout << dp[n][k][2] << endl;
}

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

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    set<ll> g_piv;
    set<ll> s_piv;
    set<ll> ans;
    for(int i = 0; i < (int)M; ++i){
        if(b[i] == N) g_piv.insert(a[i]);
        if(a[i] == 1) s_piv.insert(b[i]);
    }
    set_intersection(s_piv.begin(), s_piv.end(),
                    g_piv.begin(), g_piv.end(),
                    inserter(ans, ans.end()));
    if(ans.empty()) cout << NO << endl;
    else cout << YES << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


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

int main() {

  long long N, K;
  cin >> N >> K;

  long long answer = 0;

  if (K % 2 == 0) {
    long long c1 = N / K;
    long long c2 = N / (K / 2) - c1;
    answer =(long long) c1 * c1 * c1 + c2 * c2 * c2;
  } else {
    long long c = N / K;
    answer =(long long) c * c * c;
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int a,b; cin >>a>>b ;
	if(a==b) cout << "a == b"<<endl;
	if(a<b) cout << "a < b"<<endl;
	if(a>b) cout <<"a > b"<<endl;

}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    int a = -1, b = -1;
    string s; cin >> s;
    rep(i, 0, s.size()-1){
        if (s[i] == s[i+1]){
            a = i + 1;
            b = i + 2;
            break;
        }else if (i+2 < s.size() && s[i] == s[i+2]){
            a = i + 1;
            b = i + 3;
            break;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::priority_queue;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

ulli N, Q, H, S, D;
ulli one, two;

int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
	cin >> Q >> H >> S >> D;
	cin >> N;
	one = min({Q*4, H*2, S});
	if(one*2 < D){
		cout << N*one;
	}else{
		if(N%2 == 0){
			cout << D*(N/2);
		}else{
			cout << D*(N/2)+one;
		}
	}

  return 0;
}


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

const int MAXN = 100005;

int K, A[MAXN];
int main(){
	scanf("%d", &K);
	for(int i = 0; i < K; i++)
		scanf("%d", &A[i]);
		
	long long L = 2, R = 2;
	for(int i = K - 1; i >= 0; i--){
		long long L_ = (L + A[i] - 1) / A[i] * A[i];
		if(L_ > R){
			printf("-1\n");
			return 0;
		}
		long long R_ = R + (A[i] - R % A[i] - 1);
		
		L = L_;
		R = R_;
	}
	printf("%lld %lld\n", L, R);
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	map<int, string>m;
	for (int i = 0; i < N;++i) {
		m[i] = "-1";
	}
	string ans;
	for (int i = 0; i < M;++i) {
		int s; string c;
		cin >> s; cin >> c;
		s--;
		if (m[s] != "-1" && m[s] != c) {
			cout << "-1" << endl;
			return 0;
		}
		else {
			m[s] = c;
		}
	}
	for (int i = 0; i < N;++i) {
		if (N != 1 && i == 0 && m[i] == "0") {
			cout << "-1" << endl;
			return 0;
		}
		if (m[i] == "-1" && i == 0 && N != 1)ans += "1";
		else if (m[i] == "-1")ans += "0";
		else ans += m[i];
	}
	cout << ans << endl;
}



Measured memory_bytes: 2560
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lli long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<lli>   vll;
typedef vector<int>   vi;
typedef set<lli>      sll;
typedef set<int>      si;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

int i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
//
vll node[100001];
bool vis[100001];

void dfs(int idx)
{
	vis[idx]=1;
	int k;
	rep(k,0, sz(node[idx])-1)
	 if(vis[ node[idx][k] ]==0)
	 	dfs(node[idx][k]);
}
void solve()
{
	lli n,m; cin>>n>>m;
	int x,y,z;
	rep(i,1,m)
	{
	 cin>>x>>y>>z;
      node[x].pb(y);
      node[y].pb(x);
	}
    
    int cnt=0;
    rep(i,1,n)
     if(vis[i]==0)
     	 { ++cnt;
     	 	dfs(i);
     	 }

     	 cout<<"\n"<<cnt;
}

Measured memory_bytes: 8448
# coding: utf-8
# Your code here!

n = int(input())
L = []
a_l = 'abcdefghijklmnopqrstuvwxyz'
i = 1
L.append(1)
while True:
    if n//(26**i)>0:
        L.append(26**i+L[i-1])
    else:
        break
    i += 1

#print(L)
L  = sorted(L,reverse=True)

for i in range(len(L)):
    if i < len(L)-1:
        a = (n-L[i+1])//(L[i]-L[i+1])
        n = n%(L[i]-L[i+1])
    else:
        a = n
    #print(n,a)
    if (i == 0 and a > 0) or i > 0:
        print(a_l[a-1],end='')
    

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,x;
    cin>>n>>x;
    
    if(x==1||x==2*n-1)cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        int t=2;
        rep(i,n-2){
            if(t==x)t++;
            cout<<t<<endl;
            t++;
        }
        
        cout<<1<<endl;
        cout<<x<<endl;
        cout<<2*n-1<<endl;
        
        rep(i,n-2){
            if(t==x)t++;
            cout<<t<<endl;
            t++;
        }
    }
    
    return 0;
}


Measured memory_bytes: 1536