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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in(),K=in(),Q=in();
	vector<int> P(N,0);
	REP(i,Q){
		P[in()-1]++;
	}
	REP(i,N){
		if(P[i]+K>Q) out("Yes");
		else out("No");
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include<set>
#include<map>
#include<ctime>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL read(){
    LL f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
inline void print(int x){
	if(x<0) putchar('-'),x=-x;
	if(x>9)
		print(x/10);
	putchar(x%10+'0');
	return ;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
#define MOD int(1e9+7)
LL Pow[MAXN+5]={1};
LL A[MAXN+5],C[MAXN+5],q1[MAXN+5],q2[MAXN+5];
char str[MAXN+5];
int main(){
	scanf("%s",str+1);
	int n=strlen(str+1);
	for(int i=1;i<=n;i++)
		Pow[i]=(Pow[i-1]*3)%MOD;
	for(int i=1;i<=n;i++){
		A[i]=A[i-1],q1[i]=q1[i-1];
		if(str[i]=='A')
			A[i]++;
		if(str[i]=='?')
			q1[i]++;
	}
	for(int i=n;i>=1;i--){
		C[i]=C[i+1],q2[i]=q2[i+1];
		if(str[i]=='C')
			C[i]++;
		if(str[i]=='?')
			q2[i]++;
	}
	LL ans=0,t1,t2,t3,t4;
	for(int i=1;i<=n;i++)
		if(str[i]=='B'||str[i]=='?'){
			t1=((A[i-1]*C[i+1])%MOD*Pow[q1[i-1]+q2[i+1]])%MOD;
			t2=((A[i-1]*q2[i+1])%MOD*Pow[q1[i-1]+q2[i+1]-1])%MOD;
			t3=((C[i+1]*q1[i-1])%MOD*Pow[q1[i-1]+q2[i+1]-1])%MOD;
			t4=((q1[i-1]*q2[i+1])%MOD*Pow[q1[i-1]+q2[i+1]-2])%MOD;
			ans=(ans+((t1+t2)%MOD+(t3+t4)%MOD)%MOD)%MOD;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4224
/*            AUTHOR - SHIVAM GUPTA
                       Jalpaiguri Govt. Engg College             */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<ll> ve[100005];
ll vis[100005],z;
ll a[100005],dp[100005],n,k;

ll f(ll x)
{
    if(dp[x]!=-1)
    return dp[x];
    ll z=1e9;
    if(x>=n-1)
    return 0;
    for(ll i=1;i<=k and i+x<n;i++)
    z=min(z,abs(a[x]-a[x+i])+f(x+i));
    return dp[x]=z;
}

void solve()
{
    vector<ll> v;        vector<pair <ll,ll>> vp;
    map<ll,ll> mp;       set<ll> st;        multiset<ll> mst;
    ll m=0,i=0,j=0,c=0,l=0,r=0,p=0,q=0,x=0,y=0,z=0,flag=0,sum=0;
    // ll a[300005]={0},b[300005]={0},ans[300005];
    string s,t;
    cin>>n>>k;
    for(i=0;i<n;i++)
    cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<f(0)<<endl;
    
}
bool imp=false;int main()
{
    fio;
    int t=1;
    if(imp)
	cin>>t;
	ll j=t;
    while(t--){
    // cout<<"Case #"<<j-t<<": ";
    solve();}
    return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

const int N = 6;
double P [N],Q [N];
const double INF = 1e9;

double f(double m)
{
	double res = 0.0;
	FOR(i,0,N){
		res += max(P [i] * m,Q [i] * (1 - m));
	}
	return res;
}

int main()
{
	FOR(i,0,N){
		scanf("%lf",&P [i]);
		P [i] /= 100.0;
	}
	FOR(i,0,N){
		scanf("%lf",&Q [i]);
		Q [i] /= 100.0;
	}

	double lo = 0.0,hi = 1.0,mid1,mid2;
	FOR(i,0,100){
		mid1 = (lo + lo + hi) / 3.0;
		mid2 = (lo + hi + hi) / 3.0;
		if(f(mid1) >= f(mid2)){
			lo = mid1;
		}
		else{
			hi = mid2;
		}
	}

	printf("%.10f\n",f((lo + hi) / 2.0));

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

int main(void){
    // char ;
    ll n,m;
    ld b;
    scanf("%lld%lld",&n,&m);
    ll a[n],sum=0;
    rep(i,0,n){
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    sortdown(a,n);
    b=(ld)sum/4/m;
    if(b>a[m-1]){
        NO;
    }else{
        YES;
    }
    // printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 2000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
 

int calcPos(int h, int w, int MAX_W)
{
	return h * MAX_W + w;
}


int main()
{	
	
	int H, W;
	cin >> H >> W;

	vector<string> maze(H, "");
	rep(i, H)
	{
		cin >> maze[i];
	}

	int size = H * W;

	//迷路をグラフに見立ててコスト計算
	vector<vector<ll>> d(size, vector<ll>(size, INF));
	rep(i, H)
	{
		rep(j, W)
		{
			//壁は無視
			if (maze[i][j] == '#') continue;

			//位置を1次元に変換
			//int pos = i * W + j;
			int pos = calcPos(i, j, W);

			//道の場合、自分自身は必ず行くことができるので、コスト0
			d[pos][pos] = 0;

			//隣り合うマスに移動できる場合は1を設定
			if (i >= 1 && maze[i - 1][j] == '.')
			{
				//上
				int pos2 = calcPos(i - 1, j, W);
				d[pos][pos2] = 1;
			}
			
			if (i <= H - 2 && maze[i + 1][j] == '.')
			{
				//下
				int pos2 = calcPos(i + 1, j, W);
				d[pos][pos2] = 1;
			}

			if (j >= 1 && maze[i][j - 1] == '.')
			{
				//左
				int pos2 = calcPos(i, j - 1, W);
				d[pos][pos2] = 1;
			}

			if (j <= W - 2 && maze[i][j + 1] == '.')
			{
				//右
				int pos2 = calcPos(i, j + 1, W);
				d[pos][pos2] = 1;
			}
		}
	}



	//ワーシャルフロイト法で計算
	rep(k, size)
	{
		rep(i, size)
		{
			rep(j, size)
			{
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	//最大値を取得
	ll max_d = -1;
	rep(i, size)
	{
		rep(j, size)
		{
			if (d[i][j] == INF) continue;

			max_d = max(max_d, d[i][j]);
		}
	}


	cout << max_d << endl;

	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<iomanip>
#include<math.h>
using namespace std;
int main(){
	double x1,x2,y1,y2;
	cin>>x1>>y1>>x2>>y2;
	double x=(x1-x2)*(x1-x2),y=(y1-y2)*(y1-y2);
	cout<<fixed<<setprecision(10)<<(double)sqrt((double)x+y)<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>order(n);
  vector<int>satis(n);
  vector<int>extra(n-1);
  for(int i=0;i<n;i++){
    cin>>order[i];
  }
  for(int i=0;i<n;i++){
    cin>>satis[i];
  }
  for(int i=0;i<n-1;i++){
    cin>>extra[i];
  }
  int ans = satis[0];
  int prev = order[0];
  for(int i=1;i<n;i++){
    if(order[i]-1==prev){
      ans+=satis[i];
      ans+=extra[order[i]-2];
    }else{
      ans+=satis[i];
    }
    prev=order[i];
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
use itertools::iproduct;
use proconio::{input, source::auto};
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    println!("{}", solve(auto::AutoSource::new(stdin.lock())));
}

fn solve<T, R>(source: T) -> usize
where
    T: Into<auto::AutoSource<R>>,
    R: BufRead,
{
    input! {
        from source.into(),
        k: i32,
        s: i32,
    }

    let v: Vec<i32> = (0..=k).collect();
    iproduct!(&v, &v)
        .filter(|(x, y)| {
            let rest = s - *x - *y;
            0 <= rest && rest <= k
        })
        .count()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn case1() {
        assert_eq!(solve("2 2"), 6);
    }

    #[test]
    fn case2() {
        assert_eq!(solve("5 15"), 1)
    }
}


Measured memory_bytes: 2088
//Gvs Akhil (Vicennial)
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int N=1000006;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T> T power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
vvi g;
const int LF=17;
int par[N],level[N],st[N][LF],sc[N];
void dfs(int n,int p,int ct){
	par[n]=p;
	level[n]=ct;
	st[n][0]=p;
	sc[n]=1;
	tcf(g[n],i){
		if(i==p) continue;
		dfs(i,n,ct+1);
		sc[n]+=sc[i];
	}
}
void pre(int n){
	for(int j=1;(1<<j)<=n;j++){
		for(int i=0;i<n;i++){
			if(st[i][j-1]!=-1){
				st[i][j]=st[st[i][j-1]][j-1]; 
			}
		}
	}
}
int lca(int u,int v){
	if(level[u]<level[v]) swap(u,v);
	int dist=level[u]-level[v];
	while(dist){ 
		int k=log2(dist); dist-=(1<<k);
		u=st[u][k];
	}
	if(u==v) return u;
	for(int i=LF-1;i>=0;i--){ 
		if(st[u][i]!=-1 && st[u][i]!=st[v][i]){
			u=st[u][i];
			v=st[v][i];
		}
	}
	return par[u];
}
int32_t main(){
	sync;
	int n; cin>>n; g.resize(n);
	rep(i,0,n-1){
		int x,y; cin>>x>>y; --x; --y;
		g[x].eb(y);
		g[y].eb(x);
	}
	rep(i,0,n) rep(j,0,LF) st[i][j]=-1;
	dfs(0,-1,0);
	pre(n);
	vi v;
	int temp=n-1;
	while(par[temp]!=0){
		v.eb(par[temp]);
		temp=par[temp];
	}
	reverse(all(v));
	v.eb(n-1);
	int a=sc[0]-sc[v[v.size()/2]]-1,b=sc[v[v.size()/2]]-1;
//	trace3(a,b,v.size());
//	tcf(v,i) cout<<i+1<<endl;
	if(a<=b){
		cout<<"Snuke";
	}
	else cout<<"Fennec";
}



Measured memory_bytes: 36472
#include <stdio.h>
int main(void){
    // Your code here!
    int ans,n,m,i,sum=0,a;
    scanf("%d %d",&n,&m);
    for(i=0; i<m; i++){scanf("%d",&a); sum+=a;}
    ans = n - sum;
    if(ans<0) ans=-1;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
	using namespace std;
	#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
	#define ll long long int


	int main()
	{
		FAST;
		//ll testcase;
		//cin>>testcase;
		//for(ll t=0;t<testcase;t++)
		{
			//use long long
			//donot memeset other than 0 or 1 or -1
			//segmentation fault-> check for uninitialized global variable or out of bounds
			//always check for bottle neck (whether original constraints can be reduced by introducing some condition)
			//dont rush to writing code think through the logic	
			int n,k;
			cin>>n>>k;
			int a[n];
			map<int,int> m;
			for(int i=0;i<n;i++)
			{
				cin>>a[i];
				m[a[i]]++;
			}
			sort(a,a+n);
			ll sum=0;
			if(k<=n)
			{
				for(int i=0;i<k;i++)
				{
					sum+=a[i];
				}
				cout<<sum<<'\n';
			}
			else
			{
				int diff=k-n;
				for(int i=0;i<n;i++)
				{
					sum+=a[i];
				}
				//sort(m.begin(),m.end());
				for(auto i:m)
				{
					while(i.second--)
					{
						sum+=i.first;
						diff--;
						if(diff==0)
							break;
					}
					if(diff==0)
						break;
				}
				cout<<sum<<'\n';
			}
		}
		return 0;
	}



































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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[10];
    rep(i,9) cin >> A[i];
    int N;
    cin >> N;
    int b[20];
    rep(i,N) cin >> b[i];
    rep(i,9){
        rep(j,N){
            if(A[i] == b[j]) A[i] = -1;
        }
    }
    if(A[0] == -1 && A[1] == -1 && A[2] == -1) cout << "Yes" << endl;
    else if(A[3] == -1 && A[4] == -1 && A[5] == -1) cout << "Yes" << endl;
    else if(A[6] == -1 && A[7] == -1 && A[8] == -1) cout << "Yes" << endl;
    else if(A[0] == -1 && A[3] == -1 && A[6] == -1) cout << "Yes" << endl;
    else if(A[1] == -1 && A[4] == -1 && A[7] == -1) cout << "Yes" << endl;
    else if(A[2] == -1 && A[5] == -1 && A[8] == -1) cout << "Yes" << endl;
    else if(A[0] == -1 && A[4] == -1 && A[8] == -1) cout << "Yes" << endl;
    else if(A[2] == -1 && A[4] == -1 && A[6] == -1) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
char T[305]; int n, K, f[305][305][305]; inline int Cmax(int &x, int v){x < v ? x = v : 0;}
int main()
{
	scanf("%s",T+1), n = strlen(T+1), K = read();
	for(rint i = 1, k; i <= n; i++) for(k = 0; k <= K; f[i][i][k] = 1, k++);
	for(rint d = 2, l, r, k; d <= n; d++)
		for(l = 1, r = d; r <= n; l++, r++)
			for(k = 0; k <= K; k++)
			{
				Cmax(f[l][r][k],f[l][r-1][k]);
				Cmax(f[l][r][k],f[l+1][r][k]);
				T[l]==T[r] ? Cmax(f[l][r][k],f[l+1][r-1][k]+2) : 0;
				k ? Cmax(f[l][r][k],f[l+1][r-1][k-1]+2) : 0;
				k ? Cmax(f[l][r][k],f[l][r][k-1]) : 0;
			}	printf("%d\n",f[1][n][K]); return 0;
}

Measured memory_bytes: 110464
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 0x3f3f3f3f;
const double pi = 3.14;
int main() {
	// your code goes here
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n ,m; 
	cin >> n >> m;
	
	int work = 0;
	for(int i = 0 ; i < m ; i++)
	{
		int val;cin >> val;
		work +=val;
	}

	if(work>n) cout << "-1" << '\n';

	else cout << (n-work) << '\n';
	

	return 0;
	} 

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fr(i,a,n) for( i=a;i<=n;i++)
#define rf(i,n,a) for( i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pp(a,b) pb(mp(a,b))
#define fi first
#define se second
#define ll long long
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a))
#define cl(a) mem(a,0)
#define all(x) x.begin(),x.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std; 



int main() {
	fastio
	int n, a, b, c, d, i;
	cin >> n >> a >> b >> c >> d;
	
	bool f = c < d;
	
	string s;
	cin >> s;
	
	if(s[c-1] == '#' or s[d-1] == '#'){cout << "No";return 0;}
	
	i = a-1;
	while(i < c-1){
	    if(s[i+1] == '.')i++;
	    else if(s[i+2] == '.')i+=2;
	    else {cout << "No"; return 0;}
	}
	
	i = b-1;
	while(i < d-1){
        if(!f)
	     f |= (s[i-1] == '.' and s[i+1] == '.');
	     if(s[i+1] == '.')i++;
	     else if(s[i+2] == '.')i+=2;
	     else {cout << "No"; return 0;}
	    
	}
	if(!f)
	    f |= (s[i-1] == '.' and s[i+1] == '.');
	
	cout << (f?"Yes":"No");
	
	return 0;
}


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

int main(){
    ll a,b,ans;
    cin >> a >> b;
    if(a<b){
        rep(i,b) cout << a;
    }else{
        rep(i,a) cout << b;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define endl "\n"
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


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

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}

template<typename Head, typename... Tail>
struct vector_demensions
{
	using type=vector<typename vector_demensions<Tail...>::type>;
};

template<typename Head>
struct vector_demensions<Head> { using type=Head; };

template<typename T>
vector<T> make_vectors(int size, T val)
{
	return vector<T>(size, val);
}

template<typename T=int, typename... Args>
auto make_vectors(int size, Args... tail)
	-> typename vector_demensions<Args..., T>::type
{
	auto val=make_vectors<T>(forward<Args>(tail)...);
	return vector<decltype(val)>(size, val);
}



int main()
{
	int n;
	cin>>n;
	vector<VI> mat(n,VI(n));
	REP(i,n)
	{
		string s;
		cin>>s;
		REP(j,n)
			mat[i][j]=s[j]-'a';
	}
	int ans=0;
	REP(k,n)
	{
		bool f=true;
		REP(i,n)
		REP(j,i)
		{
			if(mat[(i+k)%n][j]!=mat[(j+k)%n][i])
			{
				f=false;
				break;
			}
		}
		if(f) ans++;
	}
	print(ans*n);
}


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

int n, k;
bool fb[10];

bool chkdig(int x){
	while(x){
		if(fb[x % 10]) return false;
		x /= 10;
	}
	return true;
}

int main(){
	cin >> n >> k;
	for(int i = 0; i < k; i++){
		int x; 
		cin >> x;
		fb[x] = true;
	}
	for(int i = n; ; i++) if(chkdig(i)) { cout << i << '\n'; return 0; }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint mod = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<double, lint> Pa;
typedef pair<plint, lint> tlint;
struct edge {
	lint cost;
	lint u, v;
};

lint A, B, C;
int main() {
	cin >> A >> B >> C;
	if (A <= B * C) cout << "Yes" << endk;
	else cout << "No" << endk;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	float a[N];
	float alt[N];
	for (int i = 0; i < N; ++i)
	{
		scanf("%f",&a[i]);
	}
	float total=0;
	float average;
	for (int i = 0; i < N; ++i)
	{
		total += a[i];
	}
	average = total/N;
	for (int i = 0; i < N; ++i)
	{
		if(a[i]-average<0){
			a[i] = (a[i]-average)*(-1);
		}
		else{
			a[i] -= average;
		}
		alt[i] = a[i];
	}
	for (int i = N; i > 0; --i)
	{
		for (int j = 0; j < i; ++j)
		{
			if(a[j] < a[j-1]){
				float tmp = a[j];
				a[j] = a[j-1];
				a[j-1] = tmp;
			}
		}
	}
	int answer;
	for (int i = 0; i < N; ++i)
	{
		if(alt[i]==a[0]){
			answer = i;
			break;
		}	
	}
	printf("%d",answer);	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

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

using namespace std;
string S;
int c1,c2;
int main(){
  c1 = 0;
  c2 = 0;
  cin >> S;
  int nagasa = S.size();
  REP(i,nagasa){
    if(S[i] == '0') c1++;
    else c2++;
  }
  cout << min(c1,c2)*2 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, q; cin >> n >> q;
	rep(i, q) {
		int u, w; cin >> u >> w;
		if (n == 1)cout << u << endl;
		else {
			while (true) {
				if (u == w) {
					cout << u << endl; break;
				}

				if (u < w) {
					w = (w + n - 2) / n;
				}
				else {
					u = (u + n - 2) / n;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        //~ if (A[i] != N) finito = false;
    }
    while (K > 0) {
        vector<pair<int,int>> bulbs;
        for (int i = 0; i < N; i++) bulbs.push_back({i - A[i], i + A[i]});
        sort(bulbs.begin(), bulbs.end());
        int at = 0;
        priority_queue<int> opened;
        bool finito = true;
        for (int i = 0; i < N; i++) {
            while (at < N and bulbs[at].first <= i) opened.push(-bulbs[at].second), at++;
            while (!opened.empty() and -opened.top() < i) opened.pop();
            A[i] = opened.size();
            if (A[i] != N) finito = false;
        }
        K--;
        if (finito) break;
    }
    for (int i = 0; i < N; i++) cout << A[i] << " ";
    cout << "\n";
}


Measured memory_bytes: 7680
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    K = int(input())
    A, B = map(int, input().split())

    res = False
    for i in range(A, B + 1):
        if i % K == 0:
            res = True

    if res:
        print("OK")
    else:
        print("NG")


if __name__ == '__main__':
    main()


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

int main()
{
    int n, m;
    cin >> n >> m;
    multiset<int> money;
    int a;

    rep(i,n){
        cin >> a;
        money.insert(a);
    }

    rep(i,m){
        auto itr = money.end();
        itr--;
        money.insert(*itr / 2);
        money.erase(itr);
    }

    ll ans = 0;
    for(auto itr = money.begin(); itr != money.end(); itr++){
        ans += *itr;
    }

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

Measured memory_bytes: 8320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    int D,T,S; cin >>D>>T>>S;
    cout << (S*T >= D ? "Yes" : "No") << endl;
    
}



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

int card[255][14] = {{0}};

int main(void){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        char c;
        int num;
        cin >> c >> num;
        card[(int)c][num] = 1; //発見
    }
    //Sを探す
    for(int i = 1; i <= 13; i++){
        if(card[(int)'S'][i] == 0){
            cout << "S " << i << endl;
        }
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'H'][i] == 0){
            cout << "H " << i << endl;
        }
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'C'][i] == 0){
            cout << "C " << i << endl;
        }
    }
    for(int i = 1; i <= 13; i++){
        if(card[(int)'D'][i] == 0){
            cout << "D " << i << endl;
        }
    }
}


Measured memory_bytes: 3092
n = int(input())

a =[]

for i in range(1,n+1):
  if i % 2 == 1:
    a.append(i)
    
ans = 0
for j in a:
  x=0
  for k in range(1,j+1):
    if j % k == 0:
      x += 1
    if x ==8:
      ans += 1
    else:
      continue
      
      
print(ans)
  
  

Measured memory_bytes: 2940
h,n = map(int,input().split())
skills = []
for _ in range(n):
  a,b = map(int,input().split())
  skills.append((a,b))
dp = [float('inf') for _ in range(h+max(skills,key=lambda x:x[1])[1] + 1)]
dp[0] = 0
  
for i in range(len(dp)):
  if dp[i] ==float('inf'):
    continue
  for damage,mp in skills:
    if i+damage >= len(dp):
      continue
    if dp[i+damage] > dp[i] + mp:
      dp[i+damage] = dp[i]+mp
ans = min(filter(lambda x :x>0,dp[h:]))
print(ans)
#print(dp)



Measured memory_bytes: 43228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  
  for (int i = 0; i < N; i++)
  {
  	if (ans * 2 <= ans + K) ans *= 2;
    else ans += K;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int a[500][500];
void solve(int l, int r, int k) {
	int N = r - l;
	if (N == 1) return;
	if (N == 2) {
		a[l][l + 1] = a[l + 1][l] = k;
		return;
	}
	int m = (l + r) / 2;
	for (int i = l; i < m; i++) {
		for (int j = m; j < r; j++) {
			a[i][j] = a[j][i] = k;
		}
	}
	solve(l, m, k + 1);
	solve(m, r, k + 1);
}
int main() {
	int N;
	cin >> N;
	solve(0, N, 1);
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1408
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
A = LIST()
a = 0
ans = INF

for i in range(-100, 101):
    a = 0
    for j in range(n):
        a += (A[j]-i) ** 2

    ans = min(ans, a)
print(ans)

    





exit()
ave = sum(L)/n
if ave == int(ave):
    print(int(ave))
    a = ave
    for i in range(n):
        ans += (L[i] - a) ** 2
    print(int(ans))
    exit()
left = 0
if ave != int(ave):
    for i in range(n):
        if L[i] < ave:
            left = i + 1
    print(left)
    right = n - left
    if left < right:
        a = ceil(ave)
    else:
        #print(floor(ave))
        a = floor(ave)
    print(a)
    for i in range(n):
        ans += abs(L[i] - a) ** 2
    print(ans)


Measured memory_bytes: 5320
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter


val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val xList = readIntegerList()
    val sortedList = xList.sorted()
    val bL = sortedList[n / 2 - 1]
    val bH = sortedList[n / 2]
    for (x in xList) {
        val ans = if (x <= bL) bH else bL
        out.println(ans)
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 72764
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n , m;
vector<int> e[N];
bool f[N];
int res[N];

int main() {
    scanf("%d%d" ,&n , &m);
    for (int i = 0 ; i < m ; ++ i) {
        int x , y;
        scanf("%d%d" , &x , &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    vector<int> res;
    int root = 0;
    for (int i = 1 ; i <= n ; ++ i) {
        if (!e[i].empty()) {
            root = i;
        }
    }

    int x = root;
    while (1) {
        res.push_back(x);
        f[x] = 1;
        bool w = 0;
        for (auto &y : e[x]) {
            if (!f[y]) {
                w = 1;
                x = y;
                break;
            }
        }
        if (!w) break;
    }
    reverse(res.begin() , res.end());
    x = root;
    while (1) {
        if (!f[x]) {
            f[x] = 1;
            res.push_back(x);
        }
        bool w = 0;
        for (auto &y : e[x]) {
            if (!f[y]) {
                w = 1;
                x = y;
                break;
            }
        }
        if (!w) break;
    }
    printf("%d\n" , res.size());
    for (int i = 0 ; i < res.size() ; ++ i) {
        printf("%d%c" , res[i] , " \n"[i + 1 == res.size()]);
    }
}


Measured memory_bytes: 6904
def check(num,k):
    if(num<k):
        return num==1
    if(num % k==0):
        return check(num//k,k)
    else:
        return check(num%k,k)

n=int(input())

yakusu=[[],[]]
for i in range(2):
    kazu=n-i
    for j in range(1,kazu+1):
        if(j*j>kazu):
            break
        if(kazu%j==0):
            if(j!=1):
                yakusu[i].append(j)
            if(j*j!=kazu):
                yakusu[i].append(kazu//j)
    yakusu[i].sort()

#for i in range(2):
#    print(yakusu[i])


ans=[]

for i in range(2):
    for y in yakusu[i]:
        if(check(n,y)):
            ans.append(y)

ans.sort()
#print(ans)
print(len(ans))


Measured memory_bytes: 3188
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	int nums[16384], ans[8192];
	int i, j, n, size, half, p;
	
	while(scanf("%d", &n), n){
		size = 0;
		half = (n-1) / 2;
		for(i=1; i<n; ++i)
			nums[size++] = (i*i) % n;

		sort(nums, nums + size);
		size = unique(nums, nums + size) - nums;

		for(i=1; i<=half; ++i)
			ans[i] = 0;
		
		for(i=0; i<size; ++i){
			for(j=0; j<i; ++j){
				++ans[(p=abs(nums[i]-nums[j]))>half?n-p:p];
			}
		}
		for(i=1; i<=half; ++i)
			printf("%d\n", ans[i]*2);
	}

	return 0;
}

Measured memory_bytes: 832
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;
vector<int> to[100005];
int64_t dp[100005][2]; // 0: 白で塗るパターン数, 1: 黒で塗るパターン数

int64_t dfs(int v, int from, bool black)
{
  if (dp[v][black] != -1)
  {
    return dp[v][black];
  }
  if (to[v].size() == 1 && from != -1)
  {
    return dp[v][black] = 1;
  }
  int64_t ret = 1;
  if (black)
  {
    for (int u : to[v])
    {
      if (u == from)
        continue;
      (ret *= dfs(u, v, 0)) %= MOD;
    }
  }
  else
  {
    for (int u : to[v])
    {
      if (u == from)
        continue;
      (ret *= ((dfs(u, v, 0) + dfs(u, v, 1)) % MOD)) %= MOD;
    }
  }
  return dp[v][black] = ret;
}

int main()
{
  int N, x, y;
  cin >> N;
  for (int i = 0; i < N - 1; i++)
  {
    cin >> x >> y;
    x--, y--;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  for (int i = 0; i < 100005; i++)
  {
    dp[i][0] = dp[i][1] = -1;
  }
  cout << (dfs(0, -1, 0) + dfs(0, -1, 1)) % MOD << endl;
}


Measured memory_bytes: 18740
#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a <= 0 && 0 <= b){
        cout << "Zero\n";
    }
    else if(b < 0){
        if((b - a) % 2){
            cout << "Positive\n";
        }else{
            cout << "Negative\n";
        }
    }else{
        cout << "Positive\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	string s;
	cin>>s;
	int n = s.size();
	vector<vector<ll> > dp(n,vector<ll>(13,0LL));
	vector<ll> power(n);
	power[n-1] = 1;
	for (int i = n-2; i >= 0; i--){
		power[i] = 10*power[i+1];
		power[i] %= 13;
	}

	for (int i = n-1; i >= 0; i--){
		if(i==n-1){
			if(s[i]=='?'){
				for (int j = 0; j < 10; j++){
					dp[i][j] = 1;
				}
			}else{
				dp[i][s[i]-'0'] = 1;
			}
			continue;
		}
		if(s[i]=='?'){
			for (ll j = 0; j < 10; j++){
				ll pl = j*power[i];
				pl %= mod;
				for (int k = 0; k < 13; k++){
					ll amari = (pl%13 + (ll)k)%13;
					dp[i][amari] += dp[i+1][k];
					dp[i][amari] %=mod;
				}
			}
		}else{
			ll j = s[i]-'0';
			ll pl = j*power[i];
			pl %= mod;
			for (int k = 0; k < 13; k++){
				ll amari = (pl%13 + (ll)k)%13;
				dp[i][amari] += dp[i+1][k];
				dp[i][amari] %=mod;
			} 
		}
	}

	cout<<dp[0][5]<<endl;

	return 0;
}

Measured memory_bytes: 14464
s = [int(e) for e in input().split()]
k =s[0]
n = s[1]
a=[int(e) for e in input().split()]
a_length=[]
for i in range(n-1):
    a_length.append(a[i+1]-a[i])
a_length.append(k-a[-1]+a[0])
amax = max(a_length)
print(k-amax)

Measured memory_bytes: 26444
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) {
            a[i + 1] <<= 1;
            a[i + 1] += a[i + 1] << 2;
            a[i + 1] += *pos++ - '0';
        }
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    rep(i, m) {
        while('0' <= *pos) {
            b[i + 1] <<= 1;
            b[i + 1] += b[i + 1] << 2;
            b[i + 1] += *pos++ - '0';
        }
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	ll n;
	cin >> n;
	for (int i = 1; i <= 3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			if ((4 * i*j - n*i - n*j)>0&&(n*i*j)%(4 * i*j - n*i - n*j)  == 0) {
				ll w = (n*i*j)/(4 * i*j - n*i - n*j);
				cout << i << " " << j << " " << w<<endl;
                return 0;
			}
		}
	}
}


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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int fN = findSumOfDigits(N);
  if (N % fN == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
def removeRow(matrix):
    _matrix = []
    for i in range(len(matrix)):
        if max(matrix[i]) == 1:
            _matrix.append(matrix[i])
    return _matrix

def removeCol(matrix):
    r = len(matrix)
    c = len(matrix[0])
    rightRotatedMatrix = []
    for i in range(c):
        col = []
        for j in range(r-1, -1, -1):
            col.append(matrix[j][i])
        rightRotatedMatrix.append(col)    
    rightRotatedMatrix = removeRow(rightRotatedMatrix)
    r = len(rightRotatedMatrix)
    c = len(rightRotatedMatrix[0])
    matrix = []
    for i in range(c-1, -1, -1):
        row = []
        for j in range(r):
            row.append(rightRotatedMatrix[j][i])
        matrix.append(row)
    return matrix

def answer(matrix):
    matrix = removeRow(matrix)
    return removeCol(matrix)

r, c = map(int, input().split())
matrix = []
for _ in range(r):
    row = [i for i in input()]
    for i in range(len(row)):
        if row[i] == '#':
            row[i] = 1
        if row[i] == '.':
            row[i] = 0
    matrix.append(row)
    
matrix = answer(matrix)
for i in range(len(matrix)):
    row = []
    for j in range(len(matrix[i])):
        if matrix[i][j] == 1:
            row.append('#')
        else:
            row.append('.')
    print("".join(row))
        

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
typedef long long ll;
#define MOD 1000000007
int main(){
    ll n;
    cin >> n;
    ll a[n];
    ll ans = 0;
    for(int i = 0;i < n;i++) cin >> a[i];

    for(ll  i = 0;i <= 60;i++){
        ll t = 0;
        for(ll j = 0;j < n;j++){
            if(a[j]&(1LL<<i)) t++;
        }
        ans = (ans+(1LL<<i)%MOD*t%MOD*(n-t))%MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0)
//#define MULTI_TEST
//#define GOOGLE
#ifdef LOCAL
#include "debugger.h"
#else
#define db(...)
#endif
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

ll fp(ll x,ll y)
{
	ll res = 1;
	while(y)
	{
		if(y & 1)
		res = mul(res,x,MOD);
		y /= 2;
		x = mul(x,x,MOD);
	}
	return res;
}

void solve()
{
	ll n,k;
	cin >> n >> k;
	ll ans = 0;
	ll l = 0,r = 0;
	for(int i = 1;i < k;i++)
	{
		l = add(l,i,MOD);
		r = add(r,n - i + 1,MOD);
	}
	for(int i = k;i < n + 2;i++)
	{
		ll temp = add(r,MOD - l,MOD);
		temp = add(temp,1,MOD);
		temp = add(temp,n - i + 1,MOD);
		ans = add(ans,temp,MOD);
		l = add(l,i,MOD);
		r = add(r,n - i + 1,MOD);
	}
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
	int t = 1;
#ifdef LOCAL
	clock_t start,stop;
	start = clock();
#endif
#ifdef MULTI_TEST
	cin >> t;
#endif
	for(int tc = 1;tc < t + 1;tc++)
	{
#ifdef GOOGLE
		cout << "Case #" << tc << ": ";
#endif
		solve();
	}
#ifdef LOCAL
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    if(s.find("C")==-1||s.find("F")==-1)cout << "No" <<endl;
    else if(s.find_first_of('C')<s.find_last_of('F'))cout << "Yes" <<endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int64_t INF = 1LL << 60;

int main() {
  string s;
  cin>>s;
  int count1=0;
  for(int i=0;i<s.size();i++){
    if(i%2==0&&s[i]!='1'){count1++;}
    else if(i%2!=0&&s[i]!='0'){count1++;}
  }
  int count2=0;
  for(int i=0;i<s.size();i++){
    if(i%2==0&&s[i]!='0'){count2++;}
    else if(i%2!=0&&s[i]!='1'){count2++;}
  }
  cout<<min(count1,count2)<<endl;
  return 0;}

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

using namespace std;

template <class T> inline bool chmin(T &a, T b) { /* {{{ */
  if (a > b) {
    a = b;
    return true;
  }
  return false;
} /* }}} */

int main() {
  int N;
  cin >> N;
  vector<int> C(26, 1e9);
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    vector<int> cnt(26);
    for (int j = 0; j < s.length(); j++) {
      int c = s[j] - 'a';
      cnt[c]++;
    }
    for (int j = 0; j < 26; j++) {
      chmin(C[j], cnt[j]);
    }
  }
  bool out = false;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < C[i]; j++) {
      cout << (char)('a' + i);
      out = true;
    }
  }
  if (out) cout << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var c = cin.ReadInt;
            var ans = 0;
            if(a-b == 0)
            {
               ans = c;
            }
            else if((a - b) < c)
            {
                ans = c - (a - b);
            }
            
            System.Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11220