akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <sstream>
using namespace std;

int main() {
  int A[4];
  int N;

  cin >> N;

  for (int i = 0; i < 4; ++i) {
    int div = pow(10,3-i);
    A[i] = N / div;
    N %= div;
  }

  int ops;
  for (int i = (1<<3)-1; i >= 0; --i) {
    int sum = A[0];
    for (int j = 0; j < 3; ++j) {
      bool op = (i >> j) & 1;
      if (op) {
        sum += A[j+1];
      } else {
        sum -= A[j+1];
      }
    }
    if (sum == 7) {
      ops = i;
      break;
    }
  }

  stringstream ss;
  ss << A[0];
  for (int i = 0; i < 3; ++i) {
    if (ops >> i & 1) {
      ss << '+';
    } else {
      ss << '-';
    }
    ss << A[i+1];
  }
  ss << "=7";

  cout << ss.str() << endl;

  return 0;
}


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

int main() {

	    ll n,ac=0,wa=0,tle=0,re=0;
	    cin>>n;
	    while(n--)
        {
            string s;
            cin>>s;
            if(s=="AC")ac++;
            if(s=="WA")wa++;
             if(s=="TLE")tle++;
            if(s=="RE")re++;
        }
        cout<<"AC x "<<ac<<endl;
        cout<<"WA x "<<wa<<endl;
        cout<<"TLE x "<<tle<<endl;
        cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void) 
{
	int i, S = 0, T = 0, score;

	for (i = 0; i < 4; i++) {
		scanf("%d", &score);
		S += score;
	}

	for (i = 0; i < 4; i++) {
		scanf("%d", &score);
		T += score;
	}

	printf("%d\n", (S >= T) ? S : T);
	return 0;
}

Measured memory_bytes: 592
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define ROOP1(i,n) for(int i=0;i<n;i++)
#define ROOP2(j,n) for(int j=0;j<n;j++)
#define Psi pair<string,int>
#define Pis pair<int,string>
#define Pii pair<int,int>
static const int INFTY = (1 << 21);
static const int MAX = 100;
static const int WHITE = 1;
static const int GRAY = 2;
static const int BLACK = 3;
// ??????????????????memset(a,0,sizeof(a));
// ?´???°?????? if(x<2)return0;else if(x==2)return1;if(x%2==0)return0;for(i=3;i*i<=x;i+=2){if(x%i==0)return0;}return1;}p440
//vector size();push_back(x);pop_back();begin();end();insert(p,x);erase(p);clear();
//stack  size();top();pop();push(x);emtpy();
//queue  size();front();pop();push(x);empty();
int n;
int M[MAX][MAX];
int color[MAX], d[MAX], p[MAX];

int main(){
	cin >> n;
	ROOP1(i, n){
		ROOP2(j, n){
			cin >> M[i][j];
		}
	}
	for (int i = 0; i < n; i++){
		d[i] = INFTY;
		color[i] = WHITE;
		p[i] = -1;
  	}
	bool flag =  true;
	d[0] = 0;
	while (flag){
		int mincost = INFTY; int u = 0;
		for (int i = 0; i < n; i++){
			if (color[i] != BLACK && d[i] < mincost){
				mincost = d[i];
				u = i;
			}
		}
		if (mincost == INFTY) break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++){
			if (M[u][v] != -1 && color[v] != BLACK){
				if (d[v] > M[u][v]){
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
 	}
	int sum = 0;
	for (int i = 0; i < n; i++){
		sum += M[i][p[i]];
	}
	cout << sum << endl;
	return 0;
}

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

const ll inf = 2e18;

void solve() {

    ll ans = -inf;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a*b <= 0 || c*d <= 0) {
        ans = 0;
    }

    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);

    cout << ans << endl;

}

int main(){

    solve();
    return 0;
}

Measured memory_bytes: 3628
$/=[*] 2..get;
my@e;
.++;
(.++;($/%$_||(@e[$_]++;$//=$_))xx 99)xx 99;
$_={@e.grep: *>$_-2};
say .(75)+.(25)*+^-.(3)+.(15)*+^-.(5)+.(5)*+^-.(5)*(.(3)-2)/2

Measured memory_bytes: 89256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


P dat[10000000];
int size_ = 1;
void init(int x) {
	while (size_ < x)size_ *= 2;
	rep(i, 2 * size_ - 1)dat[i] = { inf,inf };
}
void eval(int k, int l, int r) {
	if (dat[k].second != inf) {
		dat[k].first = dat[k].second;
		if (r - l > 1) {
			dat[k * 2 + 1].second = dat[k].second;
			dat[k * 2 + 2].second = dat[k].second;
		}
		dat[k].second = inf;
	}
}
void update(int a, int b, int k, int x, int l, int r) {
	eval(k, l, r);
	if (r <= a || b <= l)return;
	if (a <= l && r <= b) {
		dat[k].second = x;
		eval(k, l, r);
	}
	else {
		update(a, b, k * 2 + 1, x, l, (l + r) / 2);
		update(a, b, k * 2 + 2, x, (l + r) / 2, r);
		dat[k].first = min(dat[k * 2 + 1].first, dat[k * 2 + 2].first);
	}
}
int query(int a, int b, int k, int l, int r) {
	eval(k, l, r);
	if (r <= a || b <= l)return inf;
	if (a <= l && r <= b) {
		return dat[k].first;
	}
	int lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
	int rv = query(a, b, k * 2 + 2, (l + r) / 2, r);
	return min(lv, rv);
}
int n, q;
PiP p[214514];
signed main() {
	cin >> n >> q;
	vector<int>vec;
	rep(i, n) {
		cin >> p[i].second.first >> p[i].second.second >> p[i].first;
		vec.push_back(p[i].second.first - p[i].first); vec.push_back(p[i].second.second - p[i].first);
	}
	vecunique(vec);
	map<int, int>mp;
	rep(i, vec.size()) {
		mp[vec[i]] = i;
	}
	init(vec.size());
	sort(p, p + n, greater<>());
	rep(i, n) {
		update(mp[p[i].second.first - p[i].first], mp[p[i].second.second - p[i].first], 0, p[i].first, 0, size_);
	}
	rep(i, q) {
		int a; cin >> a;
		int k = upper_bound(all(vec), a) - vec.begin();
		if (k == 0)cout << -1 << endl;
		else {
			int m = query(mp[vec[k - 1]], mp[vec[k - 1]] + 1, 0, 0, size_);
			if (m == inf)cout << -1 << endl;
			else cout << m << endl;
		}
	}
}


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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  
  long long x=a+b-c;
  
  //2*sqrt(a*b)<c-a-b
  
  if(0<c-a-b && 4*a*b<x*x) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...); }
#else
    #define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    ll a;
    double b;
    cin>>a>>b;
    ll z=100*b +0.5;
    cout<<(a*z)/100<<endl;
    return 0;
}


Measured memory_bytes: 3728
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Picking Up
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

typedef pair<int,int> pii;
typedef map<pii,int> mpii;

/* global variables */

int xs[MAX_N], ys[MAX_N];
mpii ps;

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) scanf("%d%d", xs + i, ys + i);

  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int dx = xs[j] - xs[i], dy = ys[j] - ys[i];
      if (dx < 0) dx = -dx, dy = -dy;
      if (dx == 0 && dy < 0) dy = -dy;
      ps[pii(dx, dy)]++;
    }

  int maxd = 0;
  for (mpii::iterator mit = ps.begin(); mit != ps.end(); mit++) {
    //printf("(%d,%d) %d\n", mit->first.first, mit->first.second, mit->second);
    if (maxd < mit->second) maxd = mit->second;
  }

  printf("%d\n", n - maxd);
  return 0;
}


Measured memory_bytes: 384
/*
 * Author       : YangDavid
 * Created Time : 2020.06.28 19:33:21
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;
int main() {
    int n, sum = 0, mi = INF, mx = -INF;
    scanf("%d", &n);
    vector<int> a(n), ans;
    for(auto &g : a) {
        scanf("%d", &g);
        mi = min(mi, g);
        mx = max(mx, g);
        sum += g;
    }
    if(mi * 2 < mx) { puts("-1"); return 0; }
    while((int)ans.size() < sum) {
        vector<int> add, left, vis, bestleft;
        for(int len = 1; len <= n; ++len) {
            if((int)ans.size() + len < n || (int)ans.size() + len > sum) continue;
            vector<int> vals;
            left = a, vis.assign(n, 1);
            for(int j = 0; j < n - len; ++j)
                vis[ans[ans.size()-j-1]] = 0;
            for(int j = 0; j < n; ++j) if(vis[j])
                left[j]--, vals.push_back(j);
            mi = INF, mx = -INF;
            for(int j = 0; j < n; ++j) {
                mi = min(mi, left[j]);
                mx = max(mx, left[j]);
            }
            if(mi < 0 || mi * 2 + 1 < mx) continue;
            int idx = INF, xdx = -INF;
            for(int j = (int)ans.size()-len+n; j < (int)ans.size(); ++j) {
                if(left[ans[j]] == mi) idx = min(idx, j);
                if(left[ans[j]] == mx) xdx = max(xdx, j);
            }
            if(mi * 2 + 1 == mx && idx < xdx) continue;
            xdx = -INF;
            for(int j = 0; j < n; ++j) if(left[j] == mx) xdx = j;
#define key(x) (left[x] == mi ? pii(max(x, xdx), x+1) : pii(x, 0))
            if(mi * 2 + 1 == mx)
                sort(vals.begin(), vals.end(), [&](int x, int y) { return key(x) < key(y);} );
            else sort(vals.begin(), vals.end());
            if(add.empty() || add > vals) add = vals, bestleft = left;
        }
        assert(!add.empty());
        a = bestleft, ans.insert(ans.end(), add.begin(), add.end());
    }
    for(auto g : ans)
        printf("%d ", g + 1);

    return 0;
}



Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int main ()
  {
     long long int n,i,x;
     cin>>n;
     int a[n]={0};
     for(i=0;i<n-1;i++)
     {
       cin>>x;
       a[x-1]++;
     }
     for(i=0;i<n;i++)
       cout<<a[i]<<endl;
  return 0;
  }

Measured memory_bytes: 4368
from bisect import bisect_left, bisect_right

N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
A = sorted(A)
C = sorted(C)

ans = 0
for b in B:
    ans += bisect_left(A, b) * (N-bisect_right(C, b))
print(ans)

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


int main() {
    int n; cin >> n;
    vector<int> d(n,0);
    int a[n];
    rep(i, n){
        int x; cin >> a[i];
        x = a[i];
        d[a[i]-1] = i+1;
    }
    rep(i, n){
        cout << d[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1536
def main():
    ans = 0
    for i in range(1, int(input())+1, 2):
        c = 2 # 1とその数自身で+2
        for j in range(2, i // 2):
            if i % j == 0:
                c += 1
        #print(i, "->", c)
        if c == 8:
            ans += 1
    print(ans)
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
import java.math.BigDecimal;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		BigDecimal[] L = new BigDecimal[87];

		L[0] = BigDecimal.valueOf(2);
		L[1] = BigDecimal.valueOf(1);

		for(int i=2; i<=N; i++) {
			L[i] = L[i-2].add(L[i-1]);
		}
		System.out.println(L[N]);
	}

}


Measured memory_bytes: 21972
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int H, W;
    string s[105];
    cin >> H >> W;
    rep(i, H) {
        cin >> s[i];
    }

    rep(i, W+2) cout << '#';
    cout << endl;

    rep(i, H) {
        cout << '#' << s[i] << '#' << endl;
    }

    rep(i, W+2) cout << '#';
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

const ll MOD = 1e9 + 7;
const int NMAX = 2005;

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

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    vector<vector<ll>> comb(NMAX + 1, vector<ll> (NMAX + 1, 0));
    comb[0][0] = 1;
    for(int i = 1; i <= NMAX; i ++) {
        comb[i][0] = 1;
        for(int j = 1; j <= i; j ++)
            comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % MOD;
    }

    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= k; i ++) {
        ll ans = (comb[k - 1][i - 1] * comb[n - k + 1][i]) % MOD;
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	using namespace std;
	ll n,m;
	vector<ll> adj[100005];
	bool vis[100005]={false};
	ll len[100005]={0};
	ll dfs(ll s)
	{
		vis[s]=true;
		for(ll j:adj[s])
		{
			if(vis[j]==false)
				len[s]=max(len[s],dfs(j)+1);
			else
				len[s]=max(len[s],len[j]+1);
		}
		return len[s];
	}
	int main()
	{
		std::ios::sync_with_stdio(false);
		// cin.ignore(); must be there when using getline(cin, s)
		cin>>n>>m;
		ll u,v;
		while(m--)
		{
			cin>>u>>v;
			//cout<<u<<" "<<v<<endl;
			adj[u].push_back(v);
		}
		// for(ll i=1;i<=n;i++)
		// {
		// 	for(ll j:adj[i])
		// 		cout<<adj[i][j]<<" ";
		// 	cout<<endl;
		// }
		for(ll i=1;i<=n;i++){
			//cout<<i<<" ";
			if(!vis[i])
				dfs(i);

		}
		ll ml=0;
		for(ll i=1;i<=n;i++){
			//cout<<ml<<endl;
			ml=max(ml,len[i]);
		}
		cout<<ml;
		return 0;
	}


Measured memory_bytes: 7936
#include <iostream>
    #include <set>
    #include <vector>
    #include <cstring>
     
    using namespace std;
    vector<set<pair<int,int> > > v;
    set<pair<int,int> > s2;
    //
    int a[100005];
    int f[100005];
    int h[100005];
    int find(int x)
    {
    	if(f[x]==x) return x;
    	find(f[x]);
    }
    int main()
    {
    	long long cost=0;
    	int n,m;
    	cin>>n>>m;
    	memset(h,0,sizeof(h));
    	for(int i=0;i<n;i++) f[i]=i;
    	for(int i=0;i<n;i++) cin>>a[i];
    	for(int i=0;i<n;i++) s2.insert(make_pair(a[i],i));
    	for(int i=1;i<=m;i++)
    	{
    		int x,y;
    		cin>>x>>y;
    		f[find(x)]=find(y);
    	}
    	if(n-1==m) 
    	{
    		cout<<0<<endl;
    		return 0;
    	}
    	if((n-1-m)*2>n) 
    	{
    		cout<<"Impossible"<<endl;
    		return 0;
    	}
    	int tot=0;
    	for(int i=0;i<n;i++)
    	{
    		f[i]=find(f[i]);
    		if(h[f[i]]==0) h[f[i]]=++tot;
    	}
    	for(int i=1;i<=tot;i++)
    	{
    		set<pair<int,int> > s;
    		v.push_back(s);
    	}
    	for(int i=0;i<n;i++)
    	{
    		v[h[f[i]]-1].insert(make_pair(a[i],i));
    	}
    	for(int i=0;i<n-m;i++)
    	{
    		cost+=(*v[i].begin()).first;
    		s2.erase((*v[i].begin()));
    	}
    	int temp=(n-1-m)*2-(n-m);
    	for(int i=1;i<=temp;i++)
    	{
    		cost+=(*s2.begin()).first;
    		s2.erase(*s2.begin());
    	} 
    	cout<<cost<<endl;
    	return 0;
    }

Measured memory_bytes: 13424
import sys
numbers = sys.stdin.readline().split(' ')

a = int(numbers[0])
b = int(numbers[1])
c = int(numbers[2])
d = int(numbers[3])


if a <= c <= b <= d:
    print(b-c)
elif a <= c <= d <= b:
    print(d-c)
elif c <= a <= d <= b:
    print(d-a)
elif c <= a <= b <= d:
    print(b-a)
else:
    print(0)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,M;
	cin>>N>>M;
	int ans = (1900*M + 100 * (N-M))*pow(2, M);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int func(int x) {
	if (x % 2 != 0)return 0;
	return 1 + func(x / 2);
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,K;
	ll a, ans = 0;
	cin >> N >> K;

	a = N / K;
	ans += a * a*a;
	if (K%2 == 0 && N >= K/2) {
		a = (N - K / 2) / K+1;
		ans += a * a*a;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
char s[100005];
int w;
int main()
{
	scanf("%s%d",s,&w);
	for(int i=0;i<strlen(s);i+=w)
		printf("%c",s[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int d[26] = {};
    rep(i, 0, s.size()) d[s[i] - 'a']++;
    rep(i, 0, 26){
        if(d[i] == 0){
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
use std::io::*;
use std::cmp;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N: i32 = iter.next().unwrap().parse().unwrap();
    let A: i32 = iter.next().unwrap().parse().unwrap();
    let B: i32 = iter.next().unwrap().parse().unwrap();
    let C: i32 = iter.next().unwrap().parse().unwrap();
    let D: i32 = iter.next().unwrap().parse().unwrap();
    let mut va = 0;
    if N % A == 0 {
        va = ( N / A ) * B;
    } else {
        va = ( ( N / A ) + 1 ) * B;
    }
    let mut vb = 0;
    if N % C == 0 {
        vb = ( N / C ) * D;
    } else {
        vb = ( ( N / C ) + 1 ) * D;
    }
    println!("{}",cmp::min(va,vb));
}


Measured memory_bytes: 5028
n=int(input())
S=input().strip()
mod = 998244353
def mul(a, b):
    return (a * b) % mod

ff = 1
for i in range(n):
    ff=mul(ff, i+1)

def mkrgb():
    return {"R":0,"G":0,"B":0}

def ogb(c):
    if c == "R":
        return "GB"
    if c == "G":
        return "BR"
    if c == "B":
        return "RG"

cc={"R":0,"G":0,"B":0}
cc2={"R":0,"G":0,"B":0}
t=0
l=""
result = 1
for c in S:
    if cc2[c] != 0:
        result = mul(result, cc2[c])
        cc2[c]-=1
    elif cc[c] == 0:
        x,y = ogb(c)
        if cc[x] != 0:
            cc2[y] += 1
            result = mul(result, cc[x])
            cc[x] -= 1
        elif cc[y] != 0:
            cc2[x] += 1
            result = mul(result, cc[y])
            cc[y] -= 1
        else:
            cc[c]+=1
    else:
        cc[c] += 1
#    print(cc,cc2, result)

print(mul(result,ff))




Measured memory_bytes: 46936
n = int(input())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

count = 0
for i in range(n+1):
  if i%2 != 0:
    y = make_divisors(i)
    if len(y) == 8:
      count+=1
print(count)

Measured memory_bytes: 9152
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main(){
	int n,m;
	map<string,int> s;
	map<string,int>::iterator it;
	string t;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t;
		s[t]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>t;
		s[t]--;
	}
	int ans=0;
	for(it=s.begin();it!=s.end();it++){
		ans=max(ans,it->second);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception {
	    Scanner sc = new Scanner(System.in);   
	    
	    int A = sc.nextInt();
	    int B = sc.nextInt();
	    if (A * B % 2 == 0) {
	    	System.out.println("Even");
	    } else {
	    	System.out.println("Odd");
	    }
	}    
}	

Measured memory_bytes: 21844
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

ll comb(ll n, ll r)
{
  return (n) * (n - 1) / r;
}

int main()
{
  ll n;
  ll arr[200100];
  map<ll, ll> m;
  map<ll, ll> mp;
  cin >> n;
  for (ll i = 0; i < n; i++)
  {
    cin >> arr[i];
    m[arr[i]] += 1;
  }
  ll ret = 0;
  for (auto itr = m.begin(); itr != m.end(); itr++)
  {
    mp[itr->first] = comb(itr->second, 2);
    ret += mp[itr->first];
    // cout << "f" << itr->first << ',' << mp[itr->first] << endl;
  }
  // cout << ret << endl;
  for (ll i = 0; i < n; i++)
  {
    cout << ret + comb(m[arr[i]] - 1, 2) - comb(m[arr[i]], 2) << endl;
  }
}

Measured memory_bytes: 18944
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    ll m,d;
    cin >> m >> d;
    ll ans = 0;
    for (ll i=1;i<=m;i++){
        for (ll j=1;j<=d;j++){
            ll d1, d10;
            d1 = j%10;
            d10 = j/10;
            if(d1 * d10 == i and d1 != 1 and d10 != 1){
                ans++;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::min;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let b = scan.readn::<i64>(n-1);
    let mut a = vec![0;n];
    a[0] = b[0];
    a[n-1] = b[n-2];
    for i in 0..n-2 {
        a[i+1] = min(b[i], b[i+1]);
    }
    println!("{}", a.into_iter().sum::<i64>());
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

using namespace std;

typedef long long ll;

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

	string S;
	cin >> S;

	ll MOD = 1e9+7;

	int n = (int) S.size();
	vector<vector<ll>> dp(n+1, vector<ll>(13));
	dp[0][0] = 1;

	for(int i = 0; i < n; i++){
		if(S[i] == '?'){
			for(int j = 0; j < 13; j++){
				for(int k = 0; k < 10; k++){
					dp[i+1][(10 * j + k) % 13] += dp[i][j];
					dp[i+1][(10 * j + k) % 13] %= MOD;
				}
			}
		}else{
			int d = S[i] - '0';
			for(int j = 0; j < 13; j++){
				dp[i+1][(10 * j + d) % 13] += dp[i][j];
				dp[i+1][(10 * j + d) % 13] %= MOD;
			}
		}
	}

	cout << dp[n][5] << endl;
}


Measured memory_bytes: 13648
package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	"strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var N int
	N = nextInt()
	Nst := strconv.Itoa(N)
	r := regexp.MustCompile(`7+?`)
	if r.MatchString(Nst) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	// if err != nil {
	// 	panic(err)
	// }
	return i
}


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

using namespace std;

#define int long long
#define reg register
#define Raed Read
#define clr(a,b) memset(a,b,sizeof a)
#define Mod(x) (x>=mod)&&(x-=mod)
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(int i=(G).Head[x]; i; i=(G).Nxt[i])
#pragma GCC target("avx,avx2,sse4.2")
#pragma GCC optimize(3)

inline int Read(void) {
	int res=0,f=1;
	char c;
	while(c=getchar(),c<48||c>57)if(c=='-')f=0;
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>=48&&c<=57);
	return f?res:-res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a>b?a=b,1:0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a<b?a=b,1:0;
}
const int N=15,M=1e5+5;

bool MOP1;

char A[2][3];

bool MOP2;

void _main(void) {
//	cerr<<"M="<<(&MOP2-&MOP1)/1024.0/1024.0<<endl;
	rep(i,0,1)scanf("%s",A[i]+1);
	int tot=0;
	rep(i,1,3)if(A[1][i]==A[0][i])tot++;
	cout<<tot;
}

signed main() {
	_main();
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define Max zhi5968
typedef long long ll;
using namespace std;

int main ()
{
	char aa,bb;
	scanf("%c %c",&aa,&bb);
	int a,b;
	a=aa; b=bb;
	if(a>b)
		cout<<">"<<endl;
	if(a==b)
		cout<<"="<<endl;
	if(a<b)
		cout<<"<"<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

DEBUG = False

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def solve():
    return


def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]

def read_int():
    return int(sys.stdin.readline())

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n, m, k = read_int_list()
    potential_friends = UnionFind(n)
    count_friends = [0] * n
    count_blocking_in_potential_friends = [0] * n

    for _ in range(0, m):
        a, b = [p - 1 for p in read_int_list()]
        potential_friends.union(a, b)
        count_friends[a] += 1
        count_friends[b] += 1
    for _ in range(0, k):
        c, d = [p - 1 for p in read_int_list()]
        if potential_friends.same(c, d):
            count_blocking_in_potential_friends[c] += 1
            count_blocking_in_potential_friends[d] += 1
    
    ans = []
    for i in range(0, n):
        ans.append(str(potential_friends.size(i) - 1 - count_friends[i] - count_blocking_in_potential_friends[i]))

    print(" ".join(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 16840
#include<stdio.h>
int main()
{
	int a[7],b[7],sa[7];
	int i;
	
	for(i=0;i<7;i++){
		scanf("%d %d",&a[i],&b[i]);
		sa[i]=a[i]-b[i];
	}

	for(i=0;i<7;i++){
		printf("%d\n",sa[i]);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n;
    cin >> n;
    vector<ll> d(n);
    rep(i, n)cin >> d[i];
    sort(ALL(d));
    ll m;
    cin >> m;
    vector<ll> t(m);
    rep(i, m)cin >> t[i];
    sort(ALL(t), greater<ll>());

    rep(i, m){
        if(d.empty()){
            cout << "NO\n";
            return 0;
        }
        while(t[i] < d.back()){
            d.pop_back();
            if(d.empty()){
                cout << "NO\n";
                return 0;
            }
        }
        if(t[i]!=d.back()){
            cout << "NO\n";
            return 0;
        }
        else d.pop_back();
    }
    cout << "YES\n";

}

Measured memory_bytes: 3328
def main():
    #input data
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N,A,B = map(int,input().split())
    mod=10**9+7
    #solve
    #二項係数の和=2**n
    #2**n-1-nCa-nCb
    def cmb(n, r, mod=10**9+7):
        r = min(r, n-r)
        res = 1
        for i in range(r):
            res = res * (n - i) * pow(i+1, mod-2, mod) % mod
        return res
                
    ans = pow(2,N,mod)-1-cmb(N,A,mod)-cmb(N,B,mod)
    print(ans%mod)

if __name__=='__main__':
    main()

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

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define all(a) (a).begin(),(a).end()
using ll  = long long;
using vi  = vector<ll>;
using pii = pair<ll,ll>;
#define int ll

int n;
vi a;

template<typename T> class BIT{
  vector<T> vec;
  const ll n;
  
public:
  BIT(T _n) : vec(_n + 1), n(_n) {}

  T query(ll x) { /* query for [1, x] */
    T ret = 0;
    for(ll i = x; i > 0; i -= i & (-i)) ret += vec[i];
    return ret;
  }

  void update(ll x, T k) { /* update for [1, x] */
    for(ll i = x; i <= n; i += i & (-i)) vec[i] += k;
  }
};

bool solve(int mid){
  vi s(n+1);
  rep(i,n){
    s[i+1] = (a[i] >= mid) ? 1 : -1;
    s[i+1] += s[i];
  }

  BIT<ll> bit(n*3);
  int inv = 0;
  rep(i,n+1){
    // cout << i << endl;
    inv += bit.query(s[i]+n*2);
    bit.update(s[i]+n*2, 1);
  }

  int tmp = (n+1) * n / 2;
  // cout << (inv >= (tmp+1)/2) << endl;
  if(inv >= (tmp+1) / 2) return true;
  else return false;
}

int bs(int _ok, int _ng){
  int ok = _ok;
  int ng = _ng;

  while(abs(ok - ng) > 1){
    int mid = (ok + ng) / 2;
    if(solve(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  return ok;
}

main(){
  cin >> n;
  a.resize(n); rep(i,n) cin >> a[i];
  int ans = bs(0,1e9+1);
  cout << ans << endl;
}

Measured memory_bytes: 4180
a=input()
b=map(int,raw_input().split())
ans=0
while True:
    c=0
    for i in range(a):
        if b[i]==i+1:
            if b[i]!=i and i!=a-1:
                x=b[i]
                y=b[i + 1]
                b[i]=y
                b[i+1]=x
                ans+=1
            elif i!=0:
                x = b[i]
                y = b[i-1]
                b[i] = y
                b[i-1] = x
                ans += 1
            c=1
    if c==0:
        break

print ans

Measured memory_bytes: 11328
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N;
    cin >> N;
    vector<map<char, int>> mp(N);
    rep(i, N){
        string s;
        cin >> s;
        int len = (int)s.size();
        rep(j, len){
            mp[i][s[j]]++;
        }
    }
    string ans;
    rep(i, 26){
        char word = char(i + 'a');
        int min_cnt = N + 100;
        rep(j, N){
            min_cnt = min(min_cnt, mp[j][word]);
        }
        rep(j, min_cnt) ans.push_back(word);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
N=int(input())
S=input()

accum=[]
num_r=num_g=num_b=0
for i in range(N):
  if S[i]=="R":
    num_r+=1
  elif S[i]=="G":
    num_g+=1
  else:
    num_b+=1
  accum.append((num_r,num_g,num_b))

dp=[0]*N
for i in range(3,N):
  dp[i]=dp[i-1]
  nr,ng,nb=accum[i-1]
  if S[i]=="R":
    dp[i]+=ng*nb
  elif S[i]=="G":
    dp[i]+=nr*nb
  else:
    dp[i]+=ng*nr
    
  for j in range(1,i//2+1):
    #print(i,i-j,i-2*j)
    set_rgb=set()
    set_rgb.add(S[i])
    set_rgb.add(S[i-j])
    set_rgb.add(S[i-2*j])
    if len(set_rgb)==3:
      dp[i]-=1
      
print(dp[-1])

Measured memory_bytes: 68880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    
           int l,r,d;
           cin >>l>>r>>d;
  int cnt=0;

 for(int i=l;i<=r;i++){
 if(i%d==0)cnt++;

  
}
  cout << cnt <<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[1005];
	cin>>s;

		for(int i=0;i<strlen(s);i++)
	cout<<s[i];
		if(s[strlen(s)-1]!='s')
	{
		cout<<'s'<<endl;
}
else cout<<"es"<<endl;
}

Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

const int mod=1e9+7;
//lint dp[100010][2][110]={};

int main()
{
	string K;
	lint D;
	
	cin >> K >> D;
	
	const lint N=K.length();
	lint dp[100010][2][110]={};
	dp[0][0][0]=1;
	
	for(lint i=0;i<N;i++)
	{
		for(lint j=0;j<2;j++)
		{
			for(lint k=0;k<D;k++)
			{
				int dmax;
				if(j==1)dmax=9;
				else dmax=K[i]-'0';
				for(int d=0;d<=dmax;d++)
				{
					dp[i+1][j | (d<K[i]-'0')][(d+k)%D]+=dp[i][j][k];
					dp[i+1][j | (d<K[i]-'0')][(d+k)%D]%=mod;
				}
			}
		}
	}
	
	cout << (dp[N][0][0]+dp[N][1][0]-1+mod)%mod << endl;
	return 0;
}

Measured memory_bytes: 172160
#include<stdio.h>
long long int n,k;
long long int abs(long long int a){
	return a<0?-a:a;
}
int main(){
	scanf("%lld %lld",&n,&k);
	n%=k;
	if(n>abs(n-k))n=abs(n-k);
	printf("%lld",n);
}

Measured memory_bytes: 128
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    sum = a[2] - (a[0] - a[1])
    
    if sum < 0:
        sum =0

    print(sum)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(ix,v.size())cout<<" "<<v[ix];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))

const int INF = 2125252830;

int r,c,n;
pii ps[125252];
int val[125252];

int xmin[125252];
vector<pii> ys[125252];
vector<pii> g[125252];
ll dist[125252];
bool used[125252];

bool po[125252];
vi node;
int vere[125252];

bool check(){
  int a = node.size();
  REP(i,a)vere[node[i]] = i;
  REP(i,a)dist[i] = 0;
  REP(i,a)used[i] = false;
  dist[0] = 0;
  used[0] = true;
  queue<int> Q;
  Q.push(0);
  while(!Q.empty()){
    int p = Q.front(); Q.pop();
    int id = node[p];
    ll d = dist[p];
    REP(i,g[id].size()){
      int to = vere[g[id][i].first];
      ll cost = (ll)g[id][i].second;
      ll nd = d+cost;
      if(used[to]){
        if(dist[to]!=nd)return false;
      }else{
        dist[to] = nd;
        used[to] = true;
        Q.push(to);
      }
    }
  }
  // negative check
  ll sm = *min_element(dist,dist+a);
  REP(i,a){
    if(sm + (ll)xmin[node[i]] < 0){
      return false;
    }
    if(i==a-1)break;
    sm -= dist[i+1]-dist[i];
  }
  return true;
}
 
bool valid(int n){
  REP(i,125252)po[i]=false;
  REP(i,n){
    if(po[i])continue;
    node.clear();
    po[i] = true;
    node.push_back(i);
    queue<int> Q;
    Q.push(i);
    while(!Q.empty()){
      int p = Q.front(); Q.pop();
      REP(j,g[p].size()){
        int to = g[p][j].first;
        if(po[to])continue;
        po[to] = true;
        node.push_back(to);
        Q.push(to);
      }
    }
    sort(ALL(node));
    if(!check())return false;
  }
  return true;
}

int Mx[125252],My[125252];
 
int main(){
  scanf("%d%d%d",&r,&c,&n);
  vi Sx,Sy;
  REP(i,n){
    int x,y,a;
    scanf("%d%d%d",&x,&y,&a);
    ps[i] = pii(x,y);
    val[i] = a;
    Sx.push_back(x);
    Sy.push_back(y);
  }
  sort(ALL(Sx));
  sort(ALL(Sy));
  Sx.erase(unique(ALL(Sx)),Sx.end());
  Sy.erase(unique(ALL(Sy)),Sy.end());
  REP(i,Sx.size()){
    Mx[Sx[i]] = i;
  }
  REP(i,Sy.size()){
    My[Sy[i]] = i;
  }
  r = Sx.size();
  c = Sy.size();

  REP(i,125252)xmin[i] = INF;
  REP(i,n){
    int x,y;
    x=Mx[ps[i].first];
    y=My[ps[i].second];
    CHMIN(xmin[y],val[i]);
    ys[x].push_back(pii(y,val[i]));
    ps[i] = pii(x,y);
  }
  // graph
  REP(i,r){
    sort(ALL(ys[i]));
    vector<pii> &vec = ys[i];
    REP(j,vec.size()-1){
      int s,t;
      s = vec[j].first;
      t = vec[j+1].first;
      int sa = vec[j+1].second - vec[j].second;
      g[s].push_back(pii(t,sa));
      g[t].push_back(pii(s,-sa));
    }
  }
  if(!valid(r)){
    puts("No");
    return 0;
  }
  // ok
  puts("Yes");
  return 0;
}


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

int main() {

	int n; cin >> n;
	vector<ll> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = n-1; i >= 1; i--) {
		if (h[i - 1] > h[i]) h[i - 1]--;
	}
	bool ok = true;
	for (int i = 1; i < n; i++) {
		if (!(h[i - 1] <= h[i])) {
			ok = false;
		}
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3932
using System;
using System.Linq;

namespace B_PaintingBallswithAtCoDeer
{
    class Program
    {
        static void Main(string[] args)
        {
            var intputs = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = intputs[0];
            var K = intputs[1];

            var result = 0L;
            result = K;
            for (var i = 1; i < N; i++)
            {
                result = result * (K - 1);
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13396
import java.util.*;

public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int r = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
      for (int y = 1; y <= 10; y++) {
        x = r*x - d;
        System.out.println(x);
      }
  }
}

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

int main(){
    int N;
    int64_t K;
    cin >> N >> K;
    vector<int> P(N);
    for(int i=0; i<N; i++) cin >> P[i], P[i]--;
    vector<int64_t> C(N);
    for(int i=0; i<N; i++) cin >> C[i];

    vector<int> visited(N);
    vector<vector<int>> VV;
    for(int i=0; i<N; i++) if(!visited[i]){
        vector<int> v = {i};
        int pt = P[i];
        while(pt != i){
            v.push_back(pt);
            pt = P[pt];
        }
        for(int a : v) visited[a] = 1;
        VV.push_back(v);
    }

    int64_t ans = -1e18;
    for(auto& v : VV){
        int sz = v.size();
        for(int r=0; r<sz; r++){
            vector<int64_t> S(sz+1);
            for(int i=0; i<sz; i++) S[i+1] = S[i] + C[v[i]];
            for(int t=0; t<sz; t++){
                int64_t lmn = (t ? 0 : 1);
                int64_t lmx = (K+sz-t)/sz - 1;
                if(lmn > lmx) continue;
                int64_t l = (S[sz] > 0 ? lmx : lmn);
                int64_t res = l*S[sz] + S[t];
                ans = max(ans, res);
            }
            rotate(v.begin(), v.begin()+1, v.end());
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3768
#-*-coding:utf-8-*-
from collections import Counter

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    a_element = list(set(a_list))
    a_element.sort(reverse=True)

    counter = Counter(a_list)

    ans = []
    xy = []
    for i in a_element:
        if counter[i] >= 4:
            ans.append(i * i)
        if counter[i] >= 2:
            xy.append(i)
        if len(xy) == 2:
            ans.append(xy[0] * xy[1])
            break
    if len(ans) == 0:
        print(0)
    else:
        print(max(ans))



if __name__ == '__main__':
    main()

Measured memory_bytes: 20900
#include <iostream>
#include <functional>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;


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

	if (n < 10) {
		cout << n;
		return 0;
	}

	int i = 0;
	bool all9 = true;
	while(true) {
		if (n % 10 != 9) {
			all9 = false;
		}
		if (n >= 10) {
			n /= 10;
			i++;
		}
		if(n< 10) {
			break;
		}
	}
	if (all9) {
		cout << n + i * 9;
	}
	else {
		cout << n - 1 + i * 9;
	}

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] >> h[i];
  }

  int t = 0;
  for (int i = 0; i < n; ++i)
    if (h[i] != 0) t = i;

  for (int cx = 0; cx <= 100; ++cx) {
    for (int cy = 0; cy <= 100; ++cy) {
      int hh = h[t] + abs(x[t] - cx) + abs(y[t] - cy);
      bool ok = true;
      for (int i = 0; i < n; ++i) {
        if (h[i] != max(0, hh - abs(x[i] - cx) - abs(y[i] - cy))) ok = false;
      }
      if (ok) {
        cout << cx << " " << cy << " " << hh << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 998244353;
int main () {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll a, b, c;
    scanf("%lld %lld.%lld", &a, &b, &c);
    cout << (a * (b * 100 + c)) / 100 << endl;

}

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

int main()
{
    char s[11];
    int i,n,flag[3]={};

    cin >> s;

    for(n=0 ; s[n]!='\0' ; n++);

    if(s[0] == 'A')
        flag[0]=1;
    for(i=2 ; i<n-1 ; i++){
        if(s[i] == 'C')
            flag[1]++;
    }
    for(i=1 ; i<n ; i++){
        if((s[i] >= 'a')&&(s[i] <= 'z')){
            flag[2]++;
        } 
    }
    
    if(flag[0]==1 && flag[1]==1 && flag[2]==n-2)
        cout << "AC" << endl;
    else
        cout << "WA" << endl;

    return 0;
}

Measured memory_bytes: 256
n,q=map(int,input().split());s="_"+input()+"_";l,r=0,n+1
for(m,h)in[input().split()for i in range(q)][::-1]:L=h=="L";R=h=="R";l+=(m==s[l+1]and L)-(m==s[l]and R);r+=(m==s[r]and L)-(m==s[r-1]and R)
print(max(0,r-l-1))

Measured memory_bytes: 40892