akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
  string s;
  cin >> s;
  for(int i = s.size() - 2; i >= 0; i -= 2) {
    int f = 0;
    for(int j = 0; j < i / 2; j++) {
      if(s[j] != s[j+i/2]) {
        f++;
        break;
      }
    }
    if(f == 0) {
      cout << i;
      break;
    }
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

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

        if(b.equals("A")){
            System.out.println("T");
        }
        else if(b.equals("C")){
            System.out.println("G");
        }
        else if (b.equals("G")) {
            System.out.println("C");
        }
        else if (b.equals("T")) {
            System.out.println("A");
        }
        sc.close();
    }
}

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

using namespace std;

int main(void) {
  int N, W; cin >> N >> W;
  int vmax = N * 1000;
  long long dpa[vmax+1], dpb[vmax+1];
  memset(dpa, 0x7F, sizeof(dpa));
  dpa[0] = 0;

  for (int i = 0; i < N; i++) {
    memcpy(dpb, dpa, sizeof(dpb));
    int w, v; cin >> w >> v;

    for (int i = v; i <= vmax; i++) {
      dpa[i] = min(dpb[i], dpb[i-v] + w);
    }
  }

  for (int i = vmax; i >= 0; i--) {
    if (dpa[i] <= W) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double c=0;
    int i=1;
    double sum;
    while(i<=n)
    {
        if(i%2==1)
        {
             c++;
        }

      i++;
    }

    sum=c/n;
    cout<<sum;





    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
//X番目(0-indexed)の問題を選ぶことができるか？
bool check(ll N, ll M, ll V, ll P, vec A, ll X)
{
    ll z = A[P - 1];
    if (X <= P - 1)
        return true;
    if (A[X] + M < z)
        return false;
    //投票されても構わない回数
    ll nopro = 0;
    nopro += (P - 1) * M;
    nopro += (N - X) * M;
    for (ll i = P - 1; i <= X - 1; i++)
    {
        nopro += (A[X] + M - A[i]);
    }
    if (nopro >= M * V)
        return true;
    else
        return false;
}
int main()
{
    cout << fixed << setprecision(30);
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vec A(N);
    loop(i, N) cin >> A[i];
    sort(all(A));
    reverse(all(A));
    ll ok = 0, ng = N;
    loop(i, 100)
    {
        ll mid = (ok + ng) / 2;
        if (check(N, M, V, P, A, mid))
            ok = mid;
        else
            ng = mid;
        if (ok == ng)
            break;
    }
    putout(ok + 1);
    return 0;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define ll long long
using namespace std;
int n,m,a[100100];
ll c[2][100100],s,t,ans;
void add(int id,int le,int ri,ll val){
	for(;ri;ri-=lowbit(ri)) c[id][ri]+=val;
	le--;if(le==0) return;
	for(;le;le-=lowbit(le)) c[id][le]-=val;
}
ll get(int id,int x){
	ll tot=0;
	for(;x<=m;x+=lowbit(x)) tot+=c[id][x];
	return tot;
}
ll gans(int x){
	ll ans=0;
	ans+=get(0,x);
	ans+=(ll)(x)*get(1,x);
	return ans;
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<n;i++){
		s=a[i];t=a[i+1];
		if(s<t){
			add(0,1,s,t-s);
			add(0,s+1,t,t+1);
			add(1,s+1,t,-1);
			add(0,t+1,m,t-s);
		}
		else{
			add(0,1,t,t+1);
			add(1,1,t,-1);
			add(0,t+1,s,t+m-s);
			add(0,s+1,m,t+m+1);
			add(1,s+1,m,-1);
		}
	}
	ans=1e18;
	for(int i=1;i<=m;i++) ans=min(ans,gans(i));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5560
/**
 *    author: apurba_debnath
**/
#include <bits/stdc++.h>


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}
int main(void)
{
    int K;
    cin >> K;
    lli sum = 0;
    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            int tmp = gcd(i, j);
            for (int k = 1; k <= K; k++)
            {
                sum += gcd(tmp, k);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main(void) {
	int n, a, b, c, d, e;  cin >> a >> b >> c >> d >> e;
	if (a <= 0) {
		cout << abs(a) * c + d + b * e << endl;
	}
	else {
		cout << (b - a) * e << endl;
	}
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	int N, M; cin >> N >> M;
	if (N == M) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    map<int,int> s;
    for(int i=0;i<n;i++){
        int c;
        cin>>c;
        s[c]=1;
    }
    int ans=0;
    for(auto x:s){
        ans+=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int A = sc.nextInt();
		final int B = sc.nextInt();

		int[] monsters = new int[N];
		int maxHp = 0;
		for (int i = 0; i < N; i++) {
			monsters[i] = sc.nextInt();
			maxHp = Math.max(maxHp, monsters[i]);
		}

		int turnLow = 0;
		int turnHigh = maxHp / B + 1;

		while (turnLow < turnHigh) {
			int turn = (turnLow + turnHigh) / 2;
			if (clearable(turn, monsters, A, B)) {
				turnHigh = turn;
			} else {
				turnLow = turn + 1;
			}
		}
		System.out.println(turnLow);
		sc.close();
	}

	private boolean clearable(int t, int[] m, int A, int B) {
		int delta = A - B;
		int baseDamage = B * t;
		long extraTurn = 0;
		for (int i = 0; i < m.length; i++) {
			extraTurn += divRoundUp(Math.max(0, m[i] - baseDamage), delta);
			if (extraTurn > t) {
				return false;
			}
		}
		return true;
	}

	private int divRoundUp(int n, int divisor) {
		if (n % divisor == 0) {
			return n / divisor;
		} else {
			return n / divisor + 1;
		}
	}
}

Measured memory_bytes: 50152
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int n,m,k;
ll f[105][105],c[105][105],MOD,pw[105][10005];
ll pw1n[105][105][105],pw1m[105][105][105],pw2n[105][105][105],pw2m[105][105][105];
ll quick_pow(ll x,ll a)
{
	ll ans=1;
	while(a)
	{
		if(a&1)ans=ans*x%MOD;
		x=x*x%MOD;
		a>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d%d%d%lld",&n,&m,&k,&MOD);
	for(int i=1;i<=k;i++)
	{
		pw[i][0]=1;
		for(int j=1;j<=n*m;j++)pw[i][j]=pw[i][j-1]*i%MOD;
	}
	for(int i=0;i<=k;i++)
	{
		for(int x=0;x<=n;x++)
		for(int y=0;y<=m;y++)
		{
			pw1n[i][x][y]=pw[i][x*y]*pw[k-i+1][x*(m-y)]%MOD;
			pw1m[i][y][x]=pw[i][y*x]*pw[k-i+1][y*(n-x)]%MOD;
			pw2n[i][x][y]=pw[i][x*y]*pw[k-i][x*(m-y)]%MOD;
			pw2m[i][y][x]=pw[i][y*x]*pw[k-i][y*(n-x)]%MOD;
		}
	}
	c[0][0]=1;
	for(int i=0;i<=100;i++)
	for(int j=0;j<=100;j++)
	{
		if(c[i][j]>=MOD)c[i][j]-=MOD;
		c[i+1][j+1]+=c[i][j];
		c[i+1][j]+=c[i][j];
	}
	f[0][0]=1;
	for(int i=1;i<=k;i++)
	{
		for(int x=n;x>=0;x--)
		for(int y=m;y>=0;y--)
		{
			for(int j=1;j<=x;j++)
			{
				f[x][y]=(f[x][y]+f[x-j][y]*c[n-x+j][j]%MOD*pw1n[k-i+1][j][y])%MOD;
			}
		}
		for(int x=n;x>=0;x--)
		for(int y=m;y>=0;y--)
		{
			for(int j=1;j<=y;j++)
			{
				f[x][y]=(f[x][y]+f[x][y-j]*c[m-y+j][j]%MOD*pw1m[k-i+1][j][x])%MOD;
			}
		}
		for(int x=n;x>=0;x--)
		for(int y=m;y>=0;y--)
		{
			for(int j=1;j<=x;j++)
			{
				if(j&1)f[x][y]=(f[x][y]-f[x-j][y]*c[n-x+j][j]%MOD*pw2n[k-i][j][y])%MOD;
				else f[x][y]=(f[x][y]+f[x-j][y]*c[n-x+j][j]%MOD*pw2n[k-i][j][y])%MOD;
			}
		}
		for(int x=n;x>=0;x--)
		for(int y=m;y>=0;y--)
		{
			for(int j=1;j<=y;j++)
			{
				if(j&1)f[x][y]=(f[x][y]-f[x][y-j]*c[m-y+j][j]%MOD*pw2m[k-i][j][x])%MOD;
				else f[x][y]=(f[x][y]+f[x][y-j]*c[m-y+j][j]%MOD*pw2m[k-i][j][x])%MOD;
			}
		}
	}
	if(f[n][m]<0)f[n][m]+=MOD;
	printf("%lld\n",f[n][m]);
	return 0;
}

Measured memory_bytes: 44416
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for(int& val: arr)
        cin >> val;
    // 1st term is positive
    ll tmp = 0, tmp2 = 0;
    ll acc = 0;
    for(int i = 0; i < n; i++) {
        acc += arr[i];
        if (i % 2 == 0) { // pos
            if (acc <= 0) {
                tmp += (1-acc);
                acc = 1;
            }
        } else { // neg
            if (acc >= 0) {
                tmp += acc - (-1);
                acc = -1;
            }
        }
    }
    // 1st term is negative
    acc = 0;
    for(int i = 0; i < n; i++) {
        acc += arr[i];
        if (i % 2 == 0) { // neg
            if (acc >= 0) {
                tmp2 += acc - (-1);
                acc = -1;
            }
        } else { // pos
            if (acc <= 0) {
                tmp2 += 1 - acc;
                acc = 1;
            }
        }
    }
    cout << min(tmp, tmp2) << endl;
    return 0;
}




Measured memory_bytes: 640
n,k = map(int,input().split())
s = input()
c = s[0]
t = 0
l = [0]
for x in s:
  if x == c:
    t += 1
  else:
    l.append(t)
    c = x
    t = 1
f = s[0] == "0"
l.append(t)
m = len(l)
for i in range(1,m):
  l[i] += l[i-1]
l += [n]*2*(k+1)
ans = l[2*k]-l[0]
for i in range(f,m+1,2):
  ans = max(ans,l[i+2*k+1] - l[i])
print(ans) 

Measured memory_bytes: 7928
#include <stdio.h>
#include <ctype.h>

int main()
{
	char in;
	int count[26] = {}, i;
	while (scanf("%c", &in) != EOF) {
		if (isalpha(in)) {
			if (isupper(in)) {
				in = tolower(in);
			}
			count[in - 'a']++;
		}
	}
	for (i = 0; i < 26; i++) {
		printf("%c : %d\n", i + 'a', count[i]);
	}
	return 0;
}

Measured memory_bytes: 548
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 N;
	cin >> N;

	if (N % 111 == 0)
	{
		cout << N << endl;
	}
	else
	{
		cout << (N / 111 * 111 + 111) << endl;
	}
	return 0;
}


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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007

const int MAXV = 100005;
struct edge {
    int to, cost;
    edge(int a, int b) {to = a; cost = b;}
};

vector<edge> G[MAXV]; // G[from]はfrom を始点とする辺を動的配列としておさめる
vi color(MAXV);
int B = 1, W = 0, yet = -1;

bool dfs(int n, int s) { //頂点nを色sで塗る
    color[n] = s;

    for (auto e : G[n]) {
        int x = (color[n] + e.cost) % 2;
        if (color[e.to] == x) {
            continue;
        }
        else if (color[e.to] == -1) {
            if (!dfs(e.to, x)) {
                return false;
            }
        }
        else if (color[e.to] != x) {
            return false;
        }
        
    }
    return true;
}

int main() {
    int N; cin >> N;
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].pb(edge(v, w));
        G[v].pb(edge(u, w));
    }
    color.assign(MAXV, -1);

    bool can = true;

    rep(i, N) {
        if (color[i] != -1) {
            continue;
        }
        else if (!dfs(i, 0)) {
            can = false;
            break;
        }
    }
    if(can) rep(i, N) cout << color[i] << endl;
    else   cout << "No" << endl;

}


Measured memory_bytes: 7680
#include <iostream>
#include <vector>

using namespace std;

int sum(int x[], int xNum) {
	int result = 0;
	for (int i = 0; i < xNum; i++) {
		result += x[i];
	}
	return result;
}

int main(void){
    int aSum, bSum;
	int a[4], b[4];

	cin >> a[0] >> a[1] >> a[2] >> a[3];
	cin >> b[0] >> b[1] >> b[2] >> b[3];

	aSum = sum(a, sizeof a / sizeof a[0]);
	bSum = sum(b, sizeof b / sizeof b[0]);

	cout << ((aSum >= bSum) ? aSum : bSum) << endl;

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


void solve()
{
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    const ld pi=3.14159265359;

    ld no1 = 0.5*m+30*h;
    ld no2 = 6*m;
    ld dif = no1-no2;
    // if(dif<0)
    // {
    //     dif=-dif;
    // }
    // if(dif>180)
    // {
    //     dif-=180;
    // }
    // cout<<dif<<"\n";
    // cout<<cos()<<"\n";
    ld ans = a*a*1.0+ b*b*1.0 -2*a*b*(1.0)*cos((pi*dif)/(180));
    // cout<<ans<<"\n";

    cout<<fixed<<sqrt(ans)<<"\n";

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

int main(){
    int x,a,b;
    cin >> x >> a >> b ;
    if(b<=a){
        cout << "delicious"<< endl;
    }
    else if(b<=a+x){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long LL;
#define M(a,b) memset(a,b,sizeof(a))
#define pb push_back
const int maxn = 100000+5;
const LL mod = 1000000007;
int main() {

    int k,s;
    scanf("%d%d",&k,&s);
    int ans=0;
    for (int i=0;i<=k;++i) {
        for (int j=0;j<=k;++j) {
            int tmp=s-i-j;
            if (0<=tmp&&tmp<=k) {
                ++ans;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time1 = h1 * 60 + m1;
    int time2 = h2 * 60 + m2;
    int ans = time2 - time1 - k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for (auto c : s)
        if (c == '1')
            cnt++;

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000
#define ll long long
#define P pair<int,int>
using namespace std;
const int mod = 1000000007;
//char c[MAX][MAX];
int step[MAX][MAX];
int H,W,N; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

signed main(){
    ll n; cin >> n;
    vector<pair <ll,ll>> x;
    rep(i,n) {
        pair<ll,ll> p;
        ll a,b; cin >> a >> b;
        p.first = a + b; p.second = a - b;
        x.push_back(p);
        }
    sort(x.begin(),x.end());
    ll now = mod * -1; ll ans=0;
    rep(i,n){
        if(now <= x[i].second){
            now = x[i].first;
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES":"NO");}
void Yn(bool z){cout<<(z?"Yes":"No");}
void yn(bool z){cout<<(z?"yes":"no");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
map<string, int> m;
int n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    string s;
    cin >> s;
    m[s]++;
  }
  cin >> n;
  FOR(i, 0, n){
    string s;
    cin >> s;
    m[s]--;
  }
  int ans = 0;
  each(itr, m) maxs(ans, itr->se);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// スタックサイズ: 100MB

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

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



int main() {
	vll a(5);
	rep(i, 5) cin >> a[i];
	ll k; cin >> k;
	sort(all(a));
	cout << (k < a.back() - a[0] ? ":(" : "Yay!") << endl;
}

Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#define ll long long
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
#define MM 200000
#define N 131072
#define MOD 1000000007
struct edge{int nx,t,w;}e[MM*2+5];
int h[MN+5],en,fs[MN+5],ft[MN+5],r[MN+5],q[MN+5],qn;ll ds[MN+5],dt[MN+5];
struct node{ll x;int f;}t[N*2+5];
inline void ins(int x,int y,int w)
{
	e[++en]=(edge){h[x],y,w};h[x]=en;
	e[++en]=(edge){h[y],x,w};h[y]=en;
}
inline node min(const node&a,const node&b){return a.x<b.x?a:b;}
void change(int k,ll x){for(t[k+=N].x=x;k>>=1;)t[k]=min(t[k<<1],t[k<<1|1]);}
void dj(int s,ll*d,int*f)
{
	memset(d,40,sizeof(ll)*(MN+5));memset(t,40,sizeof(t));
	int i,j,x;
	for(i=1;i<=MN;++i)t[i+N].f=i;
	for(change(s,d[s]=0);t[1].x<t[0].x;)
	{
		x=t[1].f;change(x,t[0].x);
		for(i=h[x];i;i=e[i].nx)if(d[x]+e[i].w<d[e[i].t])
			change(e[i].t,d[e[i].t]=d[x]+e[i].w);
	}
	for(i=1;i<=MN;++i)for(j=h[i];j;j=e[j].nx)if(d[i]+e[j].w==d[e[j].t])++r[e[j].t];
	for(f[q[i=qn=0]=s]=1;i<=qn;++i)for(j=h[x=q[i]];j;j=e[j].nx)if(d[x]+e[j].w==d[e[j].t])
	{
		f[e[j].t]=(f[e[j].t]+f[x])%MOD;
		if(!--r[e[j].t])q[++qn]=e[j].t;
	}
}
int main()
{
	int n,m,s,t,i,j,x,y,ans;
	n=read();m=read();s=read();t=read();
	while(m--)x=read(),y=read(),ins(x,y,read());
	dj(s,ds,fs);dj(t,dt,ft);
	for(ans=1LL*fs[t]*ft[s]%MOD,i=1;i<=n;++i)
		if(ds[i]==dt[i])ans=(ans+MOD-1LL*fs[i]*fs[i]%MOD*ft[i]%MOD*ft[i]%MOD)%MOD;
		else if(ds[i]<dt[i])for(j=h[i];j;j=e[j].nx)if(ds[i]+e[j].w+dt[e[j].t]==ds[t]&&ds[e[j].t]>dt[e[j].t])
			ans=(ans+MOD-1LL*fs[i]*fs[i]%MOD*ft[e[j].t]%MOD*ft[e[j].t]%MOD)%MOD;
	printf("%d",ans);
}

Measured memory_bytes: 12416
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def cal(x)
    return (x+1)/2.0
end
N,K=get_i
p=get_i
e=array(N,0.0)
N.times do|i|
  e[i]=cal(p[i])
end
tail=0
val=0.0
ans=0.0
(N-K+1).times do|i|
  while tail-i<K
    val+=e[tail]
    tail+=1
  end
  if val>ans
      ans=val
  end
  val-=e[i]
end
puts ans

Measured memory_bytes: 17548
import java.util.Arrays;
import java.util.Scanner;

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

        String[] array = scanner.nextLine().split(" ");

        int N = Integer.parseInt(array[0]);
        int x = Integer.parseInt(array[1]);

        int[] a = new int[N];

        array = scanner.nextLine().split(" ");

        for (int i = 0; i < N; ++i) {
            a[i] = Integer.parseInt(array[i]);
        }
        Arrays.sort(a);

        for (int i = 0; i < N; ++i) {
            if (x < a[i]) {
                System.out.println(i);
                return;
            } else if (x == a[i]) {
                System.out.println(i + 1);
                return;
            } else {
                x -= a[i];
            }
        }
        System.out.println(N - 1);
    }
}

Measured memory_bytes: 23636
#include <stdio.h>
 
int main(void) {
  char d;
  scanf("%c", &d);
  if(d == 'A'){
  printf("T\n");
  }
  else if (d == 'T'){
  printf("A\n");
  }
  else if (d == 'C'){
  printf("G\n");
  }else if (d == 'G'){
  printf("C\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
 
int A[2000000];
int B[2000000];
 
void Counting_Sort(int k){
  int i,j;
  int C[10001];
  for(i=0;i<10001;i++)C[i]=0;
  for(j=0;j<k;j++)C[A[j]]++;
  for(i=1;i<10001;i++)C[i]+=C[i-1];  
  for(j=k-1;j>=0;j--){
    C[A[j]]--;
    B[C[A[j]]]=A[j];
  }
}
 
int main(){
  int n,i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  Counting_Sort(n);
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}

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

int main(){

    int a,b,c;
	
	cin >> a >>b>>c;
	
	int max;
	if (a>b){
	    max=a;
	}else{
	    max=b;
	}
	if (c>max){
	    max=c;
	}
	cout<<max*10+a+b+c-max<<endl;

	
	return 0;

}

Measured memory_bytes: 256
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

/*----------------------------------------------------------------------------- 
	定義
-------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF			2e9
#define MOD			1e9+7
#define MIN(a, b)	((a) < (b) ? a : b)
#define MAX(a, b)	((a) > (b) ? a : b)

typedef long long int QWORD;
typedef long long int ll;

/*-----------------------------------------------------------------------------
	処理
-------------------------------------------------------------------------------*/
bool IsPrime(QWORD num)
{
	if (num <= 2) return true;

	QWORD sqrtNum = sqrt(num);
	for (QWORD i = 2; i <= sqrtNum; i++) {
		if (num % i == 0) {
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}


QWORD gcd(QWORD a, QWORD b)
{
	QWORD r;

	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}


int main()
{
	QWORD A;
	QWORD B;

	// 最大公約数
	cin >> A;
	cin >> B;
#if 1
	QWORD maxYakusu;
	vector<QWORD>	yakusuA;
	vector<QWORD>	yakusuB;
	
	maxYakusu = sqrt(A);
	for (QWORD i = 1; i <= maxYakusu; i++) {
		if ((A % i) == 0) {
			if (IsPrime(i)) {
				yakusuA.push_back(i);
			}
			if (IsPrime(A / i)) {
				if (i != (A / i)) {
					yakusuA.push_back(A / i);
				}
			}
		}
	}
	reverse(yakusuA.begin(), yakusuA.end());

	maxYakusu = sqrt(B);
	for (QWORD i = 1; i <= maxYakusu; i++) {
		if ((B % i) == 0) {
			if (IsPrime(i)) {
				yakusuB.push_back(i);
			}
			if (IsPrime(B / i)) {
				if (i != (B / i)) {
					yakusuB.push_back(B / i);
				}
			}
		}
	}
	reverse(yakusuB.begin(), yakusuB.end());

	QWORD cnt = 0;
	QWORD nextPos = 0;
	for (QWORD i = 0; i < yakusuA.size(); i++) {
		QWORD	yakusuOne = yakusuA[i];
		for (QWORD j = nextPos; j < yakusuB.size(); j++) {
			if (yakusuOne < yakusuB[j]) {
				// continue
			} else if (yakusuOne == yakusuB[j]) {
				nextPos = j + 1;
				cnt++;
				break;
			} else {
				nextPos = j;
				break;
			}
		}
	}

#else
	QWORD maxYaksuu = gcd(A, B);

	// 素数をカウント
	int iCnt = 1;
	QWORD sqrtNum = sqrt(maxYaksuu);
	for (int i = 2; i <= sqrtNum; i++) {
		if ((maxYaksuu % i) == 0) {
			if (IsPrime(i)) {
				iCnt++;
			}
			if (IsPrime((maxYaksuu / i))) {
				iCnt++;
			}
		}
	}
#endif

	cout << cnt;
	return 0;
}



Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


def resolve():
    # s = input()
    # n = int(input())
    x, y = map(int, input().split())
    # l = [list(map(int, input().split())) for _ in range(n)]

    if y <= 4 * x and 2 * x <= y and y % 2 == 0:
        print('Yes')
    else:
        print('No')

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 8"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 100"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 2"""
        output = """Yes"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 71012
s = input().rstrip().split(' ')
a = int(s[0])
b = int(s[1])
k = int(s[2])
mini = min(a, b)
maxi = max(a, b)
lst = []
for i in range(1, mini):
  if a % i == 0 and b % i == 0:
    lst.append(i)
if maxi % mini == 0:
  lst.append(mini)
lst.reverse()
print(int(lst[k-1]))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[10];
int main(){
	int n, maxi = 0, s = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		s += a[i];
		maxi = max(maxi, a[i]);
	}
	s -= maxi;
	if(maxi < s)
		cout << "Yes";
	else
		cout << "No";
}

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

#define N 2*1000000
int main(void){
    char str[N];
    char before[N], after[N];
    fgets(str, sizeof(str), stdin);
    sscanf(str, "%s", before);
    fgets(str, sizeof(str), stdin);
    sscanf(str, "%s", after);
    
    int i = 0, counter = 0;
    while(before[i] != '\0'){
        if(strncmp(&before[i], &after[i], 1) != 0){
            counter++;
        }
        i++;
    }
    i = 0;
    
    printf("%d\n", counter);
}


Measured memory_bytes: 2368
#include<bits/stdc++.h>
using namespace std;
int nm[1000001];
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    set<int> s;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s.insert(a[i]);
        nm[a[i]] ++;
    }
    vector<bool> b(1e6 + 1, true);
    int c, d;
    for(auto i : s){
        c = i;
        d = 2 * c;
        while(d <= 1e6){
            b[d] = false;
            d += c;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
        if(b[a[i]] && nm[a[i]] == 1)
            ans ++;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int NS = (int)2e5 + 4;
int N, k;
int arr[NS], chk[NS], ff;
int tree[NS * 4], Tree[NS * 4];

void push(int num, int s, int e, int pos, int val){
    if(s == e){
        tree[num] = min(tree[num], val);
        Tree[num] = max(Tree[num], val);
        return;
    }
    if(pos <= (s + e) / 2) push(num * 2, s, (s + e) / 2, pos, val);
    else push(num * 2 + 1, (s + e) / 2 + 1, e, pos, val);
    tree[num] = min(tree[num * 2], tree[num * 2 + 1]);
    Tree[num] = max(Tree[num * 2], Tree[num * 2 + 1]);
}

int getmin(int num, int s, int e, int fs, int fe){
    ++ff;
    if(s == fs && e == fe) return tree[num];
    int rv = (int)1e9;
    if(fs <= (s + e) / 2) rv = min(rv, getmin(num * 2, s, (s + e) / 2, fs, min(fe, (s + e) / 2)));
    if(fe > (s + e) / 2) rv = min(rv, getmin(num * 2 + 1, (s + e) / 2 + 1, e, max(fs, (s + e) / 2 + 1), fe));
    return rv;
}

int getmax(int num, int s, int e, int fs, int fe){
    ++ff;
    if(s == fs && e == fe) return Tree[num];
    int rv = 0;
    if(fs <= (s + e) / 2) rv = max(rv, getmax(num * 2, s, (s + e) / 2, fs, min(fe, (s + e) / 2)));
    if(fe > (s + e) / 2) rv = max(rv, getmax(num * 2 + 1, (s + e) / 2 + 1, e, max(fs, (s + e) / 2 + 1), fe));
    return rv;
}

int main(){
    for(int i = 0; i < NS * 4; ++i) tree[i] = (int)1e9;
    scanf("%d %d", &N, &k);
//    N = (int)2e5, k = 100000;
//    mt19937 gen(time(NULL));
//    uniform_int_distribution < int > uid(0, (int)2e5 - 1);
    for(int i = 0; i < N; ++i){
        scanf("%d", arr + i);
//        arr[i] = uid(gen);
        push(1, 0, N - 1, i, arr[i]);
    }
    int ans = N - k + 1, cnt = 0, val = 1;
    for(int i = 1; i < N; ++i){
        if(arr[i] > arr[i - 1]){
            ++val;
            if(val == k){
                chk[i - k + 1] = 1;
                ++cnt;
                --val;
            }
        }
        else{
            val = 1;
        }
    }
    ans -= max(0, cnt - 1);
    for(int i = 0; i < N - k; ++i){
        if(getmin(1, 0, N - 1, i, i + k) == arr[i] && getmax(1, 0, N - 1, i, i + k) == arr[i + k]){
            if(chk[i] && chk[i + 1]) continue;
            --ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

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

    int n; cin >> n;
    int sum = 0;
    rep(i,1,n+1){
        if(i%3==0 || i%5==0) continue;
        sum += i;
    }

    cout << sum << '\n';

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
#define dl long double
#define ff first
#define ss second
#define pb push_back
#define inf 1000000007
#define MAXN 2019
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair<int,int> pii;
const int M = 1e9+7;

int dp[MAXN][MAXN];

int mod(int a,int m){
	int r = a%m;
	if(r<0)r+=m;
	return r;
}

int32_t main(){
	fastio;
	int n,m;
	cin>>n>>m;
	vector<int> s(n+2),t(m+2);
	for(int i=1;i<=n;i++)cin>>s[i];
	for(int i=1;i<=m;i++)cin>>t[i];
	
	for(int i=0;i<MAXN;i++){
		dp[0][i]=0;
		dp[i][0]=0;
	}
	

	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			dp[i][j] = mod(dp[i][j-1]+dp[i-1][j],M);
			dp[i][j] = mod(dp[i][j]-dp[i-1][j-1],M);
			if(s[i]==t[j]){
				dp[i][j]=mod(dp[i][j]+1+dp[i-1][j-1],M);
			}
			
		}
	}   	

	cout<<dp[n][m]+1<<endl;
}

Measured memory_bytes: 32000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
int main(){
  ll n;cin>>n;
  if(n==3){
    cout<<61<<endl;
    return 0;
  }
  bool a[256];fill(a,a+256,false);
  for(int i=0;i<256;i++){
    int c[4];
    int u=i;
    for(int j=0;j<4;j++){
      c[j]=u%4;
      u/=4;
    }
    int now=0;
    for(int j=0;j<4;j++){
      vector<int> r;
      for(int k=0;k<4;k++){
        if(j==k)continue;
        r.push_back(c[k]);
      }
      if(r[0]==2&&r[1]==3&&r[2]==0){
        now=3;
        break;
      }
      
    }
     if(c[0]==2&&c[1]==0&&c[2]==3)now=3;
    if(c[1]==2&&c[2]==0&&c[3]==3)now=3;
      if(c[0]==3&&c[1]==2&&c[2]==0)now=3;
    if(c[1]==3&&c[2]==2&&c[3]==0)now=3;
    if(now==3){
      a[i]=true;
      //cout<<c[3]<<c[2]<<c[1]<<c[0]<<" ";
    }
  }
  ll dp[n][64];
  for(ll i=0;i<n;i++)fill(dp[i],dp[i]+64,0);
  for(int i=0;i<64;i++)dp[2][i]=1;
  for(int i=2;i<n-1;i++){
    for(int j=0;j<64;j++){
      for(int k=0;k<4;k++){
        ll u=j+k*64;
        ll c[3];
        ll y=j;
        for(int l=0;l<3;l++){
          c[l]=y%4;
          y/=4;
        }
        ll num=c[1]+c[2]*4+k*16;
        if(a[u]==false){
          dp[i+1][num]+=dp[i][j];
          dp[i+1][num]%=mod;
        }
      }
    }
  }
  ll ans=0;
  for(ll i=0;i<64;i++){
    ans+=dp[n-1][i];
    ans%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
int dp[2001][2];
int a[2001];
int N;
int  Z, W;
using namespace std;
int main(){
   cin >> N >> Z >> W;
   for(int i = 0 ; i< N ; i++ ) cin >> a[i];
   int ans = abs(W-a[N-1]);
   if( N >=2 ){
      ans = max(ans, abs( a[N-2]-a[N-1]) );
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

ll getnum(const string & s) {
  ll x = 0;
  for (char t : s) x = x * 10 + t - '0';
  return x;
}

void add(array<int, 2>& a, ll x, int zn) {
  vi d = {2, 5};
  for (int i = 0; i < 2; ++i) {
    int c = 0;
    if (x) {
      while (x % d[i] == 0) {
        x /= d[i];
        ++c;
      }
    } else c = 11;
    a[i] += c * zn;
  }
}

ll c2(ll x) {
  return x * (x - 1) / 2;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vl pw10(19, 1);
  for (int i = 1; i < pw10.size(); ++i) pw10[i] = pw10[i - 1] * 10;
  vector<array<int, 2>> a(n, {0, 0});
  map<array<int, 2>, int> w;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    int j = 0;
    while (j < s.size() && s[j] != '.') ++j;
    ll num = 0, den = 1;
    if (j == s.size()) {
      num = getnum(s);
    } else {
      ll x = getnum(s.substr(0, j)), y = getnum(s.substr(j + 1));
      den = pw10[s.size() - j - 1];
      num = y + x * den;
    }
    add(a[i], num, 1);
    add(a[i], den, -1);
    w[a[i]]++;
  }
  vector<array<ll, 3>> v;
  for (auto x : w) {
    v.push_back({x.first[0], x.first[1], x.second});
  }
  ll res = 0;
  for (int i = 0; i < v.size(); ++i) {
    if (v[i][0] >= 0 && v[i][1] >= 0) res += c2(v[i][2]);
    for (int j = i + 1; j < v.size(); ++j) if (v[i][0] + v[j][0] >= 0 && v[i][1] + v[j][1] >= 0) {
      res += v[i][2] * v[j][2];
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4664
#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <fstream>
#include <iostream>
#include <sstream>

#include <iomanip>

using namespace std;

typedef pair<int, int> pint;
typedef vector<int> vint;
typedef long long ll;

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)

#define NEXTP(c) next_permutation(ALL(c))
#define SUM(c) accumulate(ALL(c),0)
#define MP( a, b ) make_pair( ( a ), ( b ) )

#define DUMP(x)  cerr << #x << " = " << (x) << endl;

#define INF 1000000000 // 10^9
const double EPS = 1e-10;
vector<int> ball;

bool dfs(int i,int left,int right){
    if (i==10) return true;
    
    if (ball[i]>left&&ball[i]>right) {
        return dfs(i+1, ball[i], right)||dfs(i+1, left, ball[i]);
    }else if(ball[i]>left&&ball[i]<right){
        return dfs(i+1, ball[i], right);
    }else if(ball[i]<left&&ball[i]>right){
        return dfs(i+1, left, ball[i]);
    }else{
        return false;
    }
    
}

int main(){
    int N;
    cin>>N;
    REP(i, N){
        ball.clear();
        ball.resize(10);
    
        REP(j, 10)cin>>ball[j];
        
        cout<<(dfs(0,0,0)?"YES":"NO")<<endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::vector<int> a(3);
	for(int i = 0; i < 3; i++) scanf("%d", &a[i]);
	sort(begin(a), end(a));
	
	if(a[0] + a[1] == a[2]) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
def main():
    x, n = list(map(int, input().split()))
    p = list(map(int, input().split()))
    p = sorted(p)

    s = x
    t = x
    while True:
        if t not in p:
            print(t)
            break
        elif s not in p:
            print(s)
            break
        else:
            s += 1
            t -= 1

if __name__ == "__main__":
    main()

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


int main(){
    int n,hantei;
    cin >> n;
    hantei = n % 100;
    if(hantei <=5 & n>= 100){
        cout << 1;
    }
    else if (hantei <=10 & n>= 200)
    {
        cout << 1;
    }
    else if (hantei <=15 & n>= 300)
    {
        cout << 1;
    }
    else if (hantei <=20 & n>= 400)
    {
        cout << 1;
    }
    else if (hantei <=25 & n>= 500)
    {
        cout << 1;
    }
    else if (hantei <=30 & n>= 600)
    {
        cout << 1;
    }
    else if (hantei <=35 & n>= 700)
    {
        cout << 1;
    }
    else if (hantei <=40 & n>= 800)
    {
        cout << 1;
    }
    else if (hantei <=45 & n>= 900)
    {
        cout << 1;
    }
    else if (hantei <=50 & n>= 1000)
    {
        cout << 1;
    }
    else if (hantei <=55 & n>= 1100)
    {
        cout << 1;
    }
    else if (hantei <=60 & n>= 1200)
    {
        cout << 1;
    }
    else if (hantei <=65 & n>= 1300)
    {
        cout << 1;
    }
    else if (hantei <=70 & n>= 1400)
    {
        cout << 1;
    }
    else if (hantei <=75 & n>= 1500)
    {
        cout << 1;
    }
    else if (hantei <=80 & n>= 1600)
    {
        cout << 1;
    }
    else if (hantei <=85 & n>= 1700)
    {
        cout << 1;
    }
    else if (hantei <=90 & n>= 1800)
    {
        cout << 1;
    }
    else if (hantei <=95 & n>= 1900)
    {
        cout << 1;
    }
    else if (hantei <=99 & n>= 2000)
    {
        cout << 1;
    }
    else
    {
        cout << 0;
    }
}

Measured memory_bytes: 256
object Main {

  import java.util.Scanner

  def main(args: Array[String]): Unit = {
    val scanner = new Scanner(System.in)

    val a = scanner.nextInt
    val b = scanner.nextInt

    var ans: Int = a * b % 2
    if (ans equals 1) {
      println("Odd")
    } else {
      println("Even")
    }
  }
}


Measured memory_bytes: 25416
#include<stdio.h>

    int main(){
        int X,A,B,temp=0,save;
        scanf("%d\n",&X);
        scanf("%d\n",&A);
        scanf("%d\n",&B);

        if(X>=(A+B) && X<=10000 && B<=1000 && A>=1){

        temp=X-A;
        save=temp%B;
        printf("%d\n",save);
     }
     return 0;
    }


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

#define ll long long
#define pint pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(),(VECTOR).end()

ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	if (a%b == 0)return b;
	return gcd(b, a%b);

}
//最大公約数

ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}
//最小公倍数
int main(){

	string S;
	cin>>S;
	ll cntz=0,cnto=0;
	for(int i=0; i<S.size(); i++){
		if(S[i]=='0')cntz++;
		else cnto++;
	}
	cout<<min(cntz,cnto)*2<<endl;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int flag,n,a[100005];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]),flag|=a[i];
	if (!flag){
		puts("Yes");
		return 0;
	}
	sort(a+1,a+n+1);
	if (n%3!=0){
		puts("No");
		return 0;
	}
	for (int i=1;i<=n;i++)
		if (i%(n/3)!=1&&n!=3&&a[i]!=a[i-1]){
			puts("No");
			return 0;
		}
	if (a[1]^a[n/3+1]^a[n/3*2+1])puts("No");
	else puts("Yes");	
} 

Measured memory_bytes: 640