akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (998244353))
#define umap unordered_map

struct Node
{
    long total = 1;
    set<long> adj;
};

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long k, n;
        cin >> k >> n;

        vector<long> a(n);
        for (auto &x : a) cin >> x;

        long best = INF;
        for (long i = 0; i < n-1; i++) {
            long dist = k - (a[i+1] - a[i]);
            best = min(best, dist);
        }
        long dist = a[n-1] - a[0];
        best = min(dist, best);
        printf("%lld\n", best);
    }
}


Measured memory_bytes: 4768
#include <cstdio>
int A, N;

int main() {
  scanf("%d", &N);
  double ret = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A);
    ret += 1.0 / A;
  }
  printf("%.9f\n", 1.0 / ret);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std ;
 
#define lli long long int
#define pb push_back

vector <int> v ;
int main ()
{
    int n ;
    cin >> n ;

    while (n--)
    {
        int k ;
        cin >> k ;

        if (k % 2 == 0 && k % 3 == 0)
        {
            continue ;
        }
        else if (k % 2 == 0 && k % 5 == 0)
        {
            continue ;
        }
        else if (k % 2 != 0)
        {
            continue ;
        }
        else
        {
            cout << "DENIED\n" ;
            return 0 ;
        }
        
    }

    cout << "APPROVED\n" ;

    return 0 ;
} 

Measured memory_bytes: 256
import math
import sys

N = input()

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


OP1 = ["+","-"]
OP2 = ["+","-"]
OP3 = ["+","-"]


for op1 in OP1:


    if op1 == "+":
        ab = a + b
    else:
        ab = a - b

    for op2 in OP2:
        if op2 == "+":
            abc = ab + c
        else:
            abc = ab - c

        for op3 in OP3:
            if op3 == "+":
                abcd = abc + d
            else:
                abcd = abc - d

            if abcd == 7:
                print("{}{}{}{}{}{}{}=7".format(a,op1,b,op2,c,op3,d))
                sys.exit(0)




Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 1000000, A = 1000000;

int aa[N], kk[1 + A];

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)
		cin >> aa[i];
	int d = 0;
	for (int i = 0; i < n; i++)
		d = gcd(d, aa[i]);
	if (d != 1) {
		cout << "not coprime\n";
		return 0;
	}
	for (int i = 0; i < n; i++) {
		int x = aa[i];
		for (int a = 2; a <= x / a; a++) {
			if (x % a == 0)
				kk[a]++;
			while (x % a == 0)
				x /= a;
		}
		if (x > 1)
			kk[x]++;
	}
	for (int a = 2; a <= A; a++)
		if (kk[a] > 1) {
			cout << "setwise coprime\n";
			return 0;
		}
	cout << "pairwise coprime\n";
	return 0;
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string t;
    cin, t;
    REP(i, 0, t.size()) {
        if (t[i] == '?') {
            t[i] = 'D';
        }
    }
    print(t);
    return 0;
}


Measured memory_bytes: 3776
n = int(input().strip())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

table=[[[None]*n for _ in range(n)] for _ in range(n)]
ans=0
for i in range(1,n+1):
    for j in range(i,n+1):
        for k in range(j,n+1):
            if i==j:
                if j==k:
                    ans+=gcd(gcd(i,j),k)
                else:
                    ans+=gcd(gcd(i,j),k)*3
            elif j==k:
                ans+=gcd(gcd(i,j),k)*3
            else:
                ans+=gcd(gcd(i,j),k)*6
            # print(ans)
print(ans)

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

int main() {
  string w;
  char s='s';
  cin>>w;
  
  if(w[w.size()-1]==s){
    
  cout<<w<<"es"<<endl;
  }
  
  else{
    cout<<w<<"s"<<endl;
  }


  // ここにプログラムを追記
}




Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;


int main(){
    int a[5];
    rep(i,5){
        cin >> a[i];
    }
    rep(i,5){
        if(a[i] == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
	return 0;
}


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

int main()
{
    int N;
    string S;
    cin >> N >> S;
    int size = S.size();
    rep(i, size)
    {
        S.at(i) = (char)((((int)(S.at(i)) - 'A') + N) % 26) + 'A';
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<long long> A(n + 1, 0);
    for(int i = 2; i <= n; i++){
        int a = i, j = 2;
        while(a > 1){
            if(a % j == 0){
                a /= j;
                A[j]++;
            }else{
                j++;
            }
        }
    }

    long long ans = 1;
    for(int i = 2; i <= n; i++){
        if(A[i] > 0){
            ans = ((ans % MOD) * ((A[i] + 1) % MOD)) % MOD;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    bool can = true;
    int dt = 0, dx = 0, dy = 0;
    for (int i = 0; i < n; ++i) {
        int t, x, y;
        cin >> t >> x >> y;
        if (i == 0) {
            dt = t;
            dx = x;
            dy = y;
        } else {
            dt = abs(dt - t);
            dx = abs(dx - x);
            dy = abs(dy - y);
        }

        int dm = dx + dy;
        if (dt % 2 == 0) {
            if (dm % 2 != 0 || dm > dt) {
                can = false;
            }
        } else {
            if (dm % 2 == 0 || dm > dt) {
                can = false;
            }
        }
    }
    cout << (can ? "Yes" : "No") << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
#define MOD 1000000007
using namespace std;
int n,m,l,r,x,f[301][301][301],res;
vector<pair<int,int> > con[301];
void add(int &ff,int delta){ff=(ff+delta)%MOD;}
bool legal(int x,int y,int z){
	int tot;
	for(int i=0;i<con[x].size();i++){
		tot=1+(y>=con[x][i].first)+(z>=con[x][i].first);
		if(tot!=con[x][i].second) return false;
	}
	return true;
}
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<=m;i++){
		cin>>l>>r>>x;
		if((r-l+1)<x){cout<<0<<endl;return 0;}
		con[r].push_back(make_pair(l,x));
	}
	if(!legal(1,0,0)){
		cout<<0<<endl;
		return 0;
	}
	f[1][0][0]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<i;j++){
			for(int k=j+1;k<i;k++){
				if(!f[i][j][k]) continue;
				if(legal(i+1,j,i)) add(f[i+1][j][i],f[i][j][k]);
				if(legal(i+1,k,i)) add(f[i+1][k][i],f[i][j][k]);
				if(legal(i+1,j,k)) add(f[i+1][j][k],f[i][j][k]);
			}
		}
		if(!f[i][0][0]) continue;
		if(legal(i+1,0,i)) add(f[i+1][0][i],f[i][0][0]);
		if(legal(i+1,0,0)) add(f[i+1][0][0],f[i][0][0]);
	}
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			for(int k=1;k<=6;k++)
				add(res,f[n][i][j]);
	for(int i=1;i<=3;i++) add(res,f[n][0][0]);
	cout<<res<<endl;
	return 0;
}


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

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

    int len = s.length() - 2;

    while (len > 1) {
        if (s.substr(0, len / 2) == s.substr(len / 2, len / 2)) {
            cout << len << endl;
            return 0;
        }

        len -= 2;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb push_back
#define mp std::make_pair
#define endl "\n"
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll MAX=500000;
const ll INF=(1ll<<62)-1;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
struct Binary_indexed_tree{
    int N;
    vi bit;
    Binary_indexed_tree(int n):N(n){
        bit.resize(N+1,0);
    }
    void add(int x,int a){
        for(x;x<=N;x+=(x&-x)) bit[x]+=a;
    }
    ll sum(int x){
        ll ret=0;
        for(x;x>0;x-=(x&-x)) ret+=bit[x];
        return ret;
    }
};
ll modpow(ll X,ll Y){
    ll sum=X,cnt=1;
    vi A;
    while(cnt<=Y){
        A.pb(sum);
        sum*=sum;
        sum%=MOD;
        cnt*=2;
    }
    int M=A.size();
    ll ret=1;
    REP(i,1,M){
        if(Y>=(1ll<<M-i)){
            Y-=(1ll<<M-i);
            ret*=A[M-i];
            ret%=MOD;
        }
    }
    return ret;
}
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=finv[1]=finv[0]=inv[0]=inv[1]=1;
    rep(i,2,MAX){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=modpow(i,MOD-2);
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(ll n,ll r){
    if(n<r||n<0||r<0) return 0;
    return fac[n]*finv[r]%MOD*finv[n-r]%MOD;
}
signed main(){
    ll N,Q; cin>>N>>Q;
    vi A(N);
    rep(i,0,N) cin>>A[i];
    rep(i,0,Q){
        ll K,X,M; cin>>K>>X>>M;
        X%=M;
        vi B(N);
        rep(j,0,N){
            B[j]=A[j]%M;
            if(B[j]==0) B[j]=M;
        }
        vi dp(N+1);
        rep(j,0,N) dp[j+1]=dp[j]+B[j];
        K--;
        ll sum=X;
        sum+=K/N*dp[N]+dp[K%N];
        ll ans=K;
        ans-=sum/M;
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 384
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll n,d;cin>>n>>d;
    dump(n, d);
    ll cnt = 0;
    rep(i, n){
        ll x,y;cin>>x>>y;
        if (x*x + y*y <= d*d) {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3624
n,t=gets.to_i,[]
a=gets.split.map(&:to_i)
n.times{|i|
  t.push(a[i]-(i+1))
}
an=0
t.sort!
tt=n%2==1 ? t[(n/2.0).floor] : ((t[n/2]+t[n/2-1])/2).round
n.times{|i|
  an+=(a[i]-(tt+i+1)).abs
}
p an

Measured memory_bytes: 19896
#include <cstdio>
  #include <iostream>
  #include <string.h>
  #include <cstring>
  #include <cmath>
  #include <math.h>
  #include <algorithm>
  #include <iomanip>
  #include <map>
  #include <set>
  #include <vector>
  #include <sstream>
  #include <queue>  
  #include <bitset>
#define MAX 100005
#define INF 9999999999999
#define pb push_back
using namespace std;
typedef long long int ll;
 typedef pair<ll,ll> ii;
 typedef vector<ii> vii;
 typedef vector <ll > vi;
vector <vii> adj(MAX);
ll arr[200005];
int main()
{
//  freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll arr[200005];
  string str;
  ll n,a,b,c,p,q,sum=0,cnt=0;
  cin>>a>>b>>c;
  sum+=100*a+10*b+c;
  if(sum%4==0)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
 

 return 0;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//


// agc071
int main(){
	int N;cin>>N;
	vector<int> p(N);
	REP(i,N)cin>>p[i];

	int cnt=0;

	REPS(i,1,N-1){
		if(p[i-1] <= p[i] && p[i] < p[i+1])cnt++;
		if(p[i-1] > p[i] && p[i] >= p[i+1])cnt++;
	}

	cout << cnt << endl;


	return 0;
}




Measured memory_bytes: 256
h,w,k=map(int,input().split())
s=[list(input()) for i in range(h)]
Sep=[]
f=0
for i in range(h-1):
    if f or "#" in s[i]:
        if "#" in s[i+1]:
            Sep.append(i+1)
        else:
            f=1
Sep.append(h)
now=0
ind=1
for x in range(len(Sep)):
    f=0
    for j in range(w):
        for i in range(now,Sep[x]):
            if s[i][j]=="#":
                f+=1
                if f>1:
                    ind+=1
                    for y in range(now,Sep[x]):
                        s[y][j]=ind
                    break
            s[i][j]=ind
    now=Sep[x]
    ind+=1
for i in s:
    print(*i)

Measured memory_bytes: 7504
(defun go-down (h)
  (loop with count = 0
        for (x . xs) on h
        if (or (null xs)
               (< x (first xs)))
        do (return (values count xs))
        else
        do (incf count)))

(defun solve (n h)
  (declare (ignore n))
  (let ((result 0))
    (loop
      (multiple-value-bind (count rest)
          (go-down h)
        (setf result (max result count))
        (unless rest
          (return))
        (setf h rest)))
    result))

#-swank
(let* ((n (read))
       (h (loop repeat n collect (read))))
  (format t "~A~%" (solve n h)))


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

class card
{
public:
    char c, suit;
    int value;
    card();
    void input();
};

card::card(){}

void card::input(){
    cin >> suit >> c;
    value = c - '0';
}

void show(card* a, int n)
{
    for(int i = 0; i < n - 1; i++) cout << a[i].suit << a[i].value << " ";
    cout << a[n - 1].suit << a[n - 1].value << endl;
}

void BubbleSort(card* a, int n)
{
    int i;
    card z;
    bool inv = true;

    while(inv){
        inv = false;
        for(i = n - 1; i > 0; i--){
            if(a[i].value < a[i - 1].value){
                z = a[i];
                a[i] = a[i - 1];
                a[i - 1] = z;
                inv = true;
            }
        }
    };
    show(a, n);
    cout << "Stable" << endl;
}

void SelectionSort(card* a, int n)
{
    int i, j, minj;
    card z;

    for(i = 0; i < n; i++){
        minj = i;
        for(j = i; j < n; j++){
            if(a[minj].value > a[j].value) minj = j;
        }
        if(i < minj){
            z = a[minj];
            a[minj] = a[i];
            a[i] = z;
        }
    }
    show(a, n);
}

bool IsStable(card* a, card* b, int n)
{
    for(int i = 0; i < n; i++){
        if(a[i].suit != b[i].suit) return false;
    }
    return true;
}

int main()
{
    card A[36], B[36];
    int i, N;
    cin >> N;
    for(i = 0; i < N; i++){
        A[i].input();
        B[i] = A[i];
    }

    BubbleSort(A, N);
    SelectionSort(B, N);
    if(IsStable(A, B, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

    return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")


signed main() {
    int n;
    string s;
    cin >> n >> s;
    int red = count_if(be(s), [](char e){ return e == 'R'; });
    cout << (n - red < red ? "Yes" : "No") << nl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
int n[6];
int c=0,cc=0;
bool f=true;
while(scanf("%d,%d,%d,%d,%d",&n[0],&n[1],&n[2],&n[3],&n[4])!=EOF){
for(int i=0;i<5;i++)
for(int j=4;j>i;j--)
if(n[j-1]>n[j]){int t=n[j];n[j]=n[j-1];n[j-1]=t;}

for(int i=0;i<4;i++){
if(n[i]==n[i+1])c++;
else if(c>=1){cc=c;c=0;}
else {c=0;}
}

for(int i=0;i<4;i++){
if(n[i+1]!=(n[i]+1))f=false;
}
if(n[0]==1&&n[1]==10&&n[2]==11&&n[3]==12&&n[4]==13)f=true;





if(c>=3||cc>=3)printf("four card\n");
else if(c==2&&cc==1)printf("full house\n");
else if(c==1&&cc==2)printf("full house\n");
else if(f==true)printf("straight\n");
else if(c==2||cc==2)printf("three card\n");
else if(n[0]==n[1]&&n[2]==n[3])printf("two pair\n");
else if(n[0]==n[1]&&n[3]==n[4])printf("two pair\n");
else if(n[1]==n[2]&&n[3]==n[4])printf("two pair\n");
else if(n[0]==n[1]||n[2]==n[3]||n[1]==n[2]||n[3]==n[4])printf("one pair\n");
else printf("null\n");

c=0,cc=0;f=true;
}
return 0;
}

Measured memory_bytes: 1168
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
x,y = map(int,input().split())
if (x in A and y in A) or (x in B and y in B) or (x in C and y in C) :
    print("Yes")
else :
    print("No")
    
    

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>

using namespace std;


long a,b;
long c,d;
long cd;
long ans = 0;

int main() {
  long i;
  long buf, r;
  long buf_c,buf_d;

  cin >> a >> b >> c >> d;

  if (c<d) {
    //NOTHING
  } else {
    buf = c;
    c = d;
    d = buf;
  }

  buf_c = c;
  buf_d = d;
  r = buf_c % buf_d;
  while(r!=0){
    buf_c = buf_d;
    buf_d = r;
    r = buf_c % buf_d;
  }
  cd = c * d / buf_d;



  //bまででcでわれるかず
  long b_c = b/c;
  //bまででdでわれるかず
  long b_d = b/d;
  //bまででどっちでも割れるかず
  long b_cd = b/cd;
  //aまででcでわれるかず
  long a_c = (a-1)/c;
  //aまででdでわれるかず
  long a_d = (a-1)/d;
  //aまででどっちでもわれるかず
  long a_cd = (a-1)/cd;

  ans = (b - b_c - b_d + b_cd) - (a-1 - a_c - a_d + a_cd);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            if (str == "a" || str == "e" || str == "i" || str == "o" || str == "u")
                Console.WriteLine("vowel");
            else
                Console.WriteLine("consonant");
        }
    }
}


Measured memory_bytes: 2648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, D;
  cin >> N >> D;
  int answer = 0;
  rep(i, N) {
    int64_t X, Y;
    cin >> X >> Y;
    if ((X * X + Y * Y) <= (D * D)) ++answer;
  }
  cout << answer << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
const int N=1e4+10;
int a[N];
int mp[N];
int n,k;
char s1[15];
char s2[15];
int main()
{
    scanf("%s",s1);
    scanf("%s",s2);
    int flag=1;
    for(int i=0;i<strlen(s1);i++){
        if(s1[i]!=s2[i]){
            flag=0;
            break;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

import sys
sys.setrecursionlimit(300000)


def solve(N: int, S: "List[str]"):
    s = set(S)
    ret = len(s)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


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

namespace ABC178
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            int x = int.Parse(Console.ReadLine());
            if (x == 0)
                Console.WriteLine(1);
            else
                Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 27468
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long int ll;
int main(){
	int n;
	cin >> n;
	int ans;
	if(n % 2 == 0){
		ans = n/2;
	}
	else{
		ans = (n+1)/2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846


int main(){
	REP(k,10){
		string s;
		cin >> s;
		if(s=="-"){return 0;}
		ll m,j=0;
		cin >> m;
		REP(i,m){
			ll h;
			cin >> h;
			ll limit = j;
			FOR(i,j,h+limit){
				s += s[j];
				s[j] = '|';
				j=i+1;
			}
		}
		REP(i,s.size()){
			if(s[i]!='|'){
				cout << s[i];
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n,s=1;
string a;
char c;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n>>a;
	c=a[0];
	for (int i=1;i<n;i++){
		if (a[i]!=c){
			s++;
			c=a[i];
		}
	}
	cout<<s;
	return 0;
}

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

const int MAX_N = 100;

int main(int argc, char const *argv[]) {
  int N, A, B;
  cin >> N >> A >> B;

  if (abs(A-B-1)%2 == 1) cout << "Alice" << endl;
  else cout << "Borys" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> s(n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> s[i]; sum += s[i];
    }
    sort(s.begin(), s.end());
    if(sum % 10 != 0) {cout << sum << endl; return 0;}
    else {
        for(int i = 0; i < n; i++){
            if(s[i] % 10 == 0) continue;
            else {cout << sum - s[i] << endl; return 0;}
        }
    }
    cout << 0 << endl;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N,M,X;
    cin >> N >> M >> X;
    vector<int> a(M);
    int left = 0;
    int right = 0;
    for (int i = 0; i < M; i++){
        cin >> a[i];
        if (a[i] < X) {
            left++;
        } else {
            right++;
        }
    }
    cout << min(left,right) << endl;


    return 0;
}


Measured memory_bytes: 632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    string a; cin >> a;

    map<char, ll> mp;
    rep(i, a.size()){
        mp[a[i]]++;
    }

    ll d = 0;
    for(auto e : mp){
        ll num = e.second;
        if(num >= 2){
            d += num * (num-1) / 2;
        }
    }

    cout << a.size() * (a.size() - 1) / 2 - d + 1 << endl;

    return 0;
}

Measured memory_bytes: 720
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = 0, max_index = 0;
long long min_value = MAX, min_index = 0;
long long sum = 0;

typedef pair<int, int> Pa;
typedef long long ll;

int dp[(int)1e5+1] = {INF};
int main() {
    vector<int> vec;
    vec.push_back(1);
    for(int i=6;i<=1e5;i*=6){
        vec.push_back(i);
    }
    for(int i=9;i<=1e5;i*=9){
        vec.push_back(i);
    }
    sort(vec.begin(), vec.end());
    cin >> N;
    dp[0] = 0;
    rep(i, N){
        dp[i+1] = MAX;
        rep(j, vec.size()){
            if(i+1-vec[j] < 0) continue;
            dp[i+1] = min(dp[i+1], dp[i+1-vec[j]]+1); 
        }
    }
    cout << dp[N];
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string o,e;
    cin>>o>>e;
    if(o.size()>e.size()){  
    for(int i=0;i<e.size();i++){
        cout<<o[i]<<e[i];
    }
    cout<<o[o.size()-1]<<endl;
    }
    else{
        for(int i=0;i<o.size();i++){
            cout<<o[i]<<e[i];
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const ll mod = 1e9+7;
const int MAX = 1e5;
vector<vector<ll>> dp(MAX,vector<ll>(2,0));
vector<ll> g[MAX];

void dfs(int u, int p){
    dp[u][0] = 1;
    dp[u][1] = 1;
    rep(i,g[u].size()){
        if(g[u][i] != p){
            dfs(g[u][i],u);
            (dp[u][0] *= dp[g[u][i]][1]) %= mod; 
            (dp[u][1] *= dp[g[u][i]][0]) %= mod;
        }
    }
    (dp[u][0] += dp[u][1]) %= mod;
    return; 
}

int main(){
    int n;
    cin >> n;
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0,-1);
    cout << dp[0][0] << endl;
    return 0;
} 


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

int N, K;
vector<int> tree[21000];

int depth[21000];
void dfs(int v, int cur = 0) {
    depth[v] = cur;
    for (int i = 0; i < tree[v].size(); ++i) {
        int to = tree[v][i];
        if (depth[to] == -1) {
            dfs(to, cur + 1);
        }
    }
}

int main() {
    while (cin >> N >> K) {
        for (int i = 0; i < 21000; ++i) tree[i].clear();
        for (int i = 0; i < N-1; ++i) {
            int a, b; cin >> a >> b; --a; --b;
            tree[a].push_back(b);
            tree[b].push_back(a);
        }
        int res = N;
        if (K & 1) {
            for (int u = 0; u < N; ++u) {
                for (int i = 0; i < tree[u].size(); ++i) {
                    int v = tree[u][i];
                    memset(depth, -1, sizeof(depth));
                    depth[u] = 0;
                    depth[v] = 0;
                    dfs(u);
                    dfs(v);

                    int num = 0;
                    for (int i = 0; i < N; ++i) {
                        if (depth[i] > K/2) ++num;
                    }
                    chmin(res, num);
                }
            }
        }
        else {
            for (int v = 0; v < N; ++v) {
                memset(depth, -1, sizeof(depth));
                dfs(v);
                int num = 0;
                for (int i = 0; i < N; ++i) {
                    if (depth[i] > K/2) ++num;
                }
                chmin(res, num);
            }
        }
        cout << res << endl;
    }
}





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

int main() {
	int n, m, ans, tmp;
	string s, t;
	cin >> s >> t;
	n = int(s.size()), m = int(t.size());
	ans = n;
	for (int i = 0; i < n - m + 1; i++) {
		tmp = 0;
		for (int j = i; j < i + m; j++) if (s[j] != t[j - i]) tmp++;
		ans = min(ans, tmp);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
typedef long long ll;
typedef long double ld;
#define trace(x)  cerr << #x << ": " << x << endl;
const ll N=5*1e5+5;ll mod=998244353;
vector<ll> v;ll n,k;
bool check(ll x)
{
	ll cut=0;
	for(auto u:v)
	{
		cut+=(ceil((double)u/x)-1);
	}
	return cut<=k;
}
int main()
{
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	{
		ll a;cin>>a;v.push_back(a);
	}
	ll l=1,r=1e10;
	while(l<r)
	{
		ll m=(l+r)/2;
		if(check(m))
		{
			r=m;
		}
		else l=m+1;
	}
	cout<<l;

}

Measured memory_bytes: 5300
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		int[] a = nia( ni());
		for (int i=0; i<a.length;i++)
			a[i]-=(i+1);
		Arrays.sort(a);
		int m = a[a.length/2];
		long ans = 0;
		for (int i=0; i<a.length;i++)
			ans += Math.abs(a[i]-m);
//		Helper.tr(a);
		out.println(ans);
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 50784
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

 int main(){
  ll n,z,w;cin>>n>>z>>w ;
  vector<ll> A(n) ;rep(i,n) cin>>A[i] ;
  if(n==1) cout<< abs(A[n-1]-w)<<endl ;
  else cout<<max(abs(A[n-1]-A[n-2]),abs(A[n-1]-w))<<endl ;
   return 0;
  }

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

int main()
{
    int N;
    cin >> N;
    vector<int> mochi(N);
    for (int i = 0; i < N; i++)
    {
        cin >> mochi.at(i);
    }

    sort(mochi.begin(), mochi.end());

    int ans = 0;
    int prev = -1;
    for (int i = 0; i < N; i++)
    {
        if (mochi.at(i) != prev)
        {
            ans += 1;
        }
        prev = mochi.at(i);
    }

    cout << ans << endl;
}

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

int main() {
  int N, y=0;
  string a;
  cin >> N;
  
  for (int i=0; i<N; i++){
    cin >> a;
    if(a== "Y")
      y=1;
  }
  if(y==0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <iostream>
#define REP(i,a,b)for (int i=a;i<=b;++i)
#define PER(i,a,b)for (int i=a;i>=b;--i)
#define RVC(i,S)for (int i=0;i<S.size();++i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> VI;

int ai[200005],n;
int main(){
	scanf("%d",&n);
	REP(i,1,n){
		scanf("%d",&ai[i]);
		ai[i]-=i;
	}
	sort(ai+1,ai+n+1);
	LL ans=0;
	REP(i,1,n/2)ans+=ai[n-i+1]-ai[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    int N; cin >> N;
    int A[N]; rep(i, N) cin >> A[i];
    sort(A, A + N);
    int ans = 0;
    int count = 0;
    for (int i = 0; i < N; i++) {
        count = 1;
        while (A[i] == A[i+1]){
            count++; i++;
        }
        if (count % 2 == 1) ans++;
    }

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

Measured memory_bytes: 640
# https://hiramekun.hatenablog.com/entry/2019/06/18/184256

def main():
    MOD = 10 ** 9 + 7

    N, M = map(int, input().split())
    *s, = map(int, input().split())
    *t, = map(int, input().split())

    dp = [[0] * (M + 1) for _ in range(N + 1)]  # (i,j)で丁度終わる文字列数
    dp[0][0] = 0
    dp[0][1] = 0
    dp[1][0] = 0

    acc = [[0] * (M + 1) for _ in range(N + 1)]
    acc[0][0] = 0
    acc[0][1] = 0
    acc[1][0] = 0

    for i, si in enumerate(s, 1):
        for j, ti in enumerate(t, 1):
            if si == ti:
                dp[i][j] = acc[i - 1][j - 1] + 1
            else:
                dp[i][j] = 0
            acc[i][j] = (acc[i - 1][j] + acc[i][j - 1] + dp[i][j] - acc[i - 1][j - 1]) % MOD

    ans = acc[N][M] + 1  # ("","")のケース

    print(ans)


if __name__ == '__main__':
    main()


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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)
#define pb push_back


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n;
	cin>>n;
	string s; cin>>s;
	ll ans = 0;
	ll dp[n+1][n+1];
	f(mask,0,1<<n) {
		string r,t;
		f(i,0,n) if (mask>>i&1) r.pb(s[i]);
		else t.pb(s[i]);
		f(i,0,n+1) f(j,0,n+1) 
			dp[i][j] = 0;
		int a = r.size(), b = s.size();
		dp[0][0] = 1;
		f(i,0,n) f(j,0,a+1) if (dp[i][j]) {
			int k = i-j;
			char cur = s[2*n-1-i];
			if (j<a&&cur==r[j]) dp[i+1][j+1] += dp[i][j];
			if (k<b&&cur==t[k]) dp[i+1][j] += dp[i][j];
		}	
		ans += dp[n][a];
	}	
	cout << ans << endl;
	

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

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

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

	vector<array<int, 3>> g[n];

	int mx = 0;
	for(int i = 0; i < m; ++i){
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		--u, --v;
		g[u].push_back({v, a, b});
		g[v].push_back({u, a, b});
		mx += a;
	}
	
	vector<pair<int, int>> f(n);
	for(auto &p : f){
		cin >> p.X >> p.Y; // c, d
	}

	s = min(s, mx);
	vector<vector<ll>> best(n, vector<ll>(mx + 1, 9e18));
	queue<array<int, 2>> q;
	q.push({0, s});
	best[0][s] = 0;

	while(!q.empty()){
		auto ar = q.front();
		q.pop();
		int x = ar[0];
		int silver = ar[1];

		// cout << x << " " << silver << endl;

		int t = 1;
		if(silver + t * f[x].X <= mx){
			if(best[x][silver + t * f[x].X] > best[x][silver] + t * f[x].Y){
				best[x][silver + t * f[x].X] = best[x][silver] + t * f[x].Y;
				q.push({x, silver + t * f[x].X});
			}
			t++;
		}

		for(auto &p : g[x]){
			int y = p[0];
			int a = p[1];
			int b = p[2];
			if(silver >= a && best[y][silver - a] > best[x][silver] + b){
				best[y][silver - a] = best[x][silver] + b;
				q.push({y, silver - a});
			}
		}
	}

	for(int i = 1; i < n; ++i){
		cout << *min_element(all(best[i])) << "\n";
	}

	return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int vx = x2 - x1, vy = y2 - y1;
  int vx2 = -vy, vy2 = vx;
  int vx3 = -vx, vy3 = -vy;
  cout << x2 + vx2 << " " << y2 + vy2 << " " << x2 + vx2 + vx3 << " " << y2 + vy2 + vy3 << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define sz(v)  v.size()


void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}

bool sorti(string &a, string &b) {
    return a.size() < b.size();
}

ll fastExpo(ll a, ll b) {
    if (!b)return 1;
    ll half = fastExpo(a, b / 2);
    ll ans = (half * half);
    if (b & 1)return (ans * a);
    return ans;
}

int n, k;
string s;
int prifix[100009];
int check(int in){
    int l=in,r=n-1,mid;
    int temp=0;
    while(l<=r){
        mid=(l+r)/2;
        if(prifix[mid+1]-prifix[in+1]+(prifix[in+1]>0&&s[in]!='1')<=k)temp=mid-in+1,l=mid+1;
        else r=mid-1;
    }
    return temp;
}
int main() {
    fast();
    cin >> n >> k;
    cin>>s;
    prifix[0]=(s[0]=='0');
    for (int i = 0; i <n ; ++i) {
        prifix[i+1]=prifix[i]+(s[i]=='0'&&(s[i-1]=='1'));
    }
    int ans=0;
    for (int j = 0; j < n; ++j) {
        ans=max(ans,check(j));
    }
    cout<<ans;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535


int main()
{
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> a(q);
    for(ll i = 0; i < q; i++) cin >> a[i];
    vector<ll> point(n + 1);
    for(ll i= 1; i <= n; i++) point[i] = k;
    for(ll i = 0; i < q; i++){
        point[a[i]]++;
    }
    for(ll i = 1; i <= n; i++){
        point[i] -= q;
        if(point[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

}

Measured memory_bytes: 2176