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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}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)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),M=in();
	auto v=vecin(M);
	vll dp(N+1,1LL<<60);
	dp[0]=0;

	REP(i,M){
		REP(j,N+1){
			if(j+v[i]<=N) chmin(dp[j+v[i]],dp[j]+1);
		}
	}

	out(dp[N]);
	return 0;
}



Measured memory_bytes: 3288
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n,k;
  cin >> n >> k;
  if(k>(n-1)*(n-2)/2){
    cout << -1 << endl;
    return 0;
  }
  cout << (n-1)+(-k+(n-1)*(n-2)/2) << endl;
  for(int i = 2; i <= n; i++){
    printf("1 %d\n",i);
  }
  ll res = -k+(n-1)*(n-2)/2;
  for(int i = 2; i <= n-1; i++){
    for(int j = i+1; j <=n; j++){
      if(res==0) return 0;
      printf("%d %d\n", i,j);
      res--;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
		int e = sc.nextInt();
        long ans = 0;
		long [] in = new long [c];
        long [] in2 = new long [d];
        long [] in3 = new long [e];
        long [] in4 = new long [a+b+e];
        for(int i=0;i<c;i++){
                             in[i] = sc.nextLong();
                            }
        for(int i=0;i<d;i++){
                             in2[i] = sc.nextLong();
                            }
        for(int i=0;i<e;i++){
                             in3[i] = sc.nextLong();
                            }
		Arrays.sort(in);
        Arrays.sort(in2);
        Arrays.sort(in3);
        for(int i=0;i<a;i++){
                             in4[i] = in[c-a+i];
                            }
        for(int i=0;i<b;i++){
                             in4[a+i] = in2[d-b+i];
                            }
        for(int i=0;i<e;i++){
                             in4[a+b+i] = in3[i];
                            }
        Arrays.sort(in4);
        for(int i=e;i<a+b+e;i++){ans+=in4[i];}  
		System.out.println(ans);
	}
}


Measured memory_bytes: 100348
#include <bits/stdc++.h>
using namespace std;
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all;

int main() {
  int N;
  string S;
  cin >> N >> S;
  replace_all(S, "ABC", "x");
  cout << count(S.begin(), S.end(), 'x') << "\n";
}

Measured memory_bytes: 256
//これ↓参考に解きなおし
//出典　http://drken1215.hatenablog.com/entry/2018/08/05/224100
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long D, G;
vector<long long> p, c;

int main() {
    cin >> D >> G;
    p.resize(D); c.resize(D);
    for (int i = 0; i < D; i++) cin >> p[i] >> c[i];

    long long temp = 1<<29;
    for (int bit = 0; bit < (1 << D); bit++) {
        long long sum = 0;
        long long count = 0;
        for (int i = 0; i < D; i++) {
            if ((bit >> i)&1) {
                sum += (i+1)*100*p[i] + c[i];
                count += p[i];
            }
        }
        if (sum >= G) temp = min(temp, count);
        else{
            for (int i = D-1; i >= 0; i--) {
                if ((bit >> i)&1) continue;
                for (int j = 0; j < p[i]; j++) {
                    if (sum >= G) break;
                    sum += 100*(i+1);
                    count++;
                }
            }
            temp = min(temp, count);
        }
    }
    cout << temp << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int n;
	cin >> n;
	int ans = 0;
	int nh = 0;
	LOOP(i,n){
		int a;
		cin >> a;
		if(nh < a){
			ans += a-nh;
		}
		nh = a;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
X=int(input())

def is_prime(n):
    if n==1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

for i in range(X,1000000):
    if is_prime(i):
        print(i)
        break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    int x=(d*2)+1;
    int y=n/x;
    int z=n%x;
    if(z>0){
        y++;
    }
    cout<<y<<endl;
    return 0;
}


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

using namespace std;

int main() {
  int r, g, b;
  cin >> r >> g >> b;

  int a = r * 100 + g * 10 + b;
  if (a % 4 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,a[N],b[N];
map<int,int> s;
int chk(int x, int y) {
	auto t = s;
	b[1] = x, b[2] = y;
	--t[x], --t[y];
	REP(i,3,n) {
		if (t[b[i-1]^b[i-2]]) {
			--t[b[i-1]^b[i-2]];
			b[i] = b[i-1]^b[i-2];
		}
		else return 0;
	}
	if (b[1]^b[n]^b[n-1]) return 0;
	if (b[2]^b[1]^b[n]) return 0;
	return 1;
}
int main() {
	scanf("%d", &n);
	REP(i,1,n) scanf("%d", a+i),++s[a[i]];
	if (s.size()<=3) {
		for (auto a:s) for (auto b:s) {
			if (chk(a.x,b.x)) return puts("Yes"),0;
		}
		puts("No");
	}
	else puts("No");
}









Measured memory_bytes: 7936
a, b = map(int, input().split())
c = []
d = []
for i in range(a):
    c.append(list(input()))
for i in range(b):
    d.append(list(input()))
for i in range(a-b+1):
    for j in range(a-b+1):
        o = True
        for k in range(i, i+b):
            for l in range(j, j+b):
                if c[k][l] != d[k-i][l-j] and o:
                    o = not o
        if o:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 3064
#include<stdio.h>
#define MM	10000000
int main(void)
{
	int a[500][500];
	int n,m,i,j,k;
	int x,y,leng,minx,miny,minl;
	int flg[500];
	int cnt;
	int sum;
	
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		for(i=0;i<n;i++)	{
			for(j=0;j<n;j++)	{
				a[i][j]=MM;
			}
		}
		scanf("%d",&m);
		for(i=0;i<m;i++)	{
			scanf("%d,%d,%d",&x,&y,&leng);
			leng=leng/100-1;
			a[x][y]=leng;
			a[y][x]=leng;
		}

		for(i=0;i<n;i++)	{
			flg[i]=0;
		}
		flg[0]=1;
		cnt=1;
		sum=0;
		while(cnt<n)	{
			minl=MM;
			for(i=0;i<n;i++)	{
				if(flg[i]==1)	{
					for(j=0;j<n;j++)	{
						if(flg[j]==0 && a[i][j]<minl)	{
							minl=a[i][j];
							minx=i;
							miny=j;
						}
					}
				}
			}
			sum+=minl;
			flg[miny]=1;
			cnt++;
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 796
#pragma GCC target("avx")
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FORR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL dig(LL n){LL ret=0;while(n)n/=10,ret++;return ret;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a%m<0)return a%m+abs(m);else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i,ans=0,N;
  cin>>N;

  cout<<N*N*N<<endl;
}


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

int main() {
    ll n;
    cin >> n;
    vector<ll> l(n + 1);
    l[0] = 2; l[1] = 1;
    for (ll i = 2; i < n + 1; ++i) l[i] = l[i - 1] + l[i - 2];
    cout << l[n] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int>a(n),da(n),ans(n),used(n);
  rep(i,n)cin>>a[i];
  rep(i,n)da[i]=i+1-a[i];
  //rep(i,n)cout<<da[i]<<" ";
  rep(i,n)
  {
    int max0=-1;
    for(int j=n-1;j>=0;j--)
    {
      if(da[j]==0&&!used[j])
      {
        max0=j;
        used[j]=1;
        break;
      }
    }
    if(max0==-1)
    {
      cout<<-1<<endl;
      return 0;
    }
    ans[i]=a[max0];
    repi(j,max0+1,n)
    {
      da[j]--;
    }
  }
  for(int i=n-1;i>=0;i--)
  {
    cout<<ans[i]<<"\n";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() { IO;
  int a, b;
  cin >> a >> b;

  if (b % a == 0) {
    cout << a + b << endl;
  } else {
    cout << b - a << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(ll i = 0; i < (ll)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(ll i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 998244353ll;
const dou pi=3.141592653589793*2;
int main(){
    int n;
    std::cin >> n;
    int h=n,w=n;
    vvvector(a,char,n,n,n,0);
    reprep(i,j,n,n)std::cin >> a[0][i][j];
    rrep(ii,1,n){
        reprep(i,j,n,n){
            a[ii][i][(j+ii)%n]=a[0][i][j];
       //     std::cout << (i+ii)%n << std::endl;
            //if(j==0)std::cout  << std::endl;
            
        }
        
    }
    int ans=0;
    rep(ii,n){
        bool b=1;
        rep(i,n)rep(j,n){
            if(a[ii][i][j]!=a[ii][j][i])b=0;
        }
        if(b)ans+=n;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 30720
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define empb emplace_back
#define all(x) (x).begin(),(x).end()
const int N = 1e5 + 7;
const int m = 2019;
int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s; cin >> s;
	int n = s.size();
	int t = 1;
	vector<int> val(n);
	for(int i = n - 1; i >= 0; i--) {
		val[i] = (s[i] - '0') * t % m;
		t = t * 10 % m;
	}
	vector<int> cnt(2019);
	cnt[0]++;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		if(i) val[i] = (val[i - 1] + val[i]) % m;
		ans += cnt[val[i]];
		cnt[val[i]]++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
int INF=2e+9;
int main(){
	int A,B;
	int h=100,w=100;
	char mat[100][101];
	rep(i,h){
		rep(j,50){
			mat[i][j]='.';
			mat[i][j+50]='#';
		}
		mat[i][100]='\0';
	}
	scan(A);scan(B);
	int whitegyo=(A-1)/25+1,whiteretsu=A-1-(whitegyo-1)*25;
	int blackgyo=(B-1)/25+1,blackretsu=(B-1)-(blackgyo-1)*25;
	rep(i,whitegyo){
		if(i!=whitegyo-1){
			rep(j,25){
				mat[i*2][j*2+51]='.';
			}
		}
		else{
			rep(j,whiteretsu){
				mat[i*2][j*2+51]='.';
			}
		}
	}
	rep(i,blackgyo){
		if(i!=blackgyo-1){
			rep(j,25){
				mat[i*2][j*2]='#';
			}
		}
		else{
			rep(j,blackretsu){
				mat[i*2][j*2]='#';
			}
		}
	}
	printf("%d %d\n",h,w);
	rep(i,h){
		prin(mat[i]);
	}
	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++)

int main(){
  string A,B,C; cin >> A >> B >> C;
  int a = 1,b = 0,c = 0;
  int cardA = A.size(),cardB = B.size(),cardC = C.size();
  char x = A[0];
  cardA--;
  while(true){
      if(x == 'a'){
          if(cardA == 0){
          cout << 'A' << endl;
          break;
          }
          x = A[a];
          cardA--;
          a++;
      }else if(x == 'b'){
          if(cardB == 0){
          cout << 'B' << endl;
          break;
      }

          x = B[b];
          cardB--;
          b++;
      }else if(x == 'c'){
          if(cardC == 0){
          cout << 'C' << endl;
          break;
      }
          x = C[c];
          cardC--;
          c++;
      }
  }
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int a,b;

int main(){
  scanf("%d %d",&a,&b);
  if(a==b){
    printf("Draw\n");
  }else if(a==1 || (a>b && b != 1)){
    printf("Alice\n");
  }else{
    printf("Bob\n");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1000000007;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
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;
}

ll digitSum( ll v ){
    ll sum = 0;
    for( ; v > 0; v /= 10 ){
        sum += v % 10;
    }
    return sum;
}
int main()
{
    ll N, A, B;
    cin >> N >> A>> B;

    ll sum = 0;
    for ( ll i = 1; i <= N; ++ i ){
        auto v = digitSum(i);
        if ( A <= v && v <= B ){
            sum += i;
        }
    }
    cout << sum << endl;


    return 0;
}

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

const int N = (int) 1e5 + 5;

int n;
int a[N];
set <pair <int, int> > od, ev;
set <pair <int, int> > :: iterator it;
map <int, int> fo, fe;
int x[2], y[2];

int main() {
	
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i & 1) {
			fo[a[i]]++;
		} else {
			fe[a[i]]++;
		}
	}
	for (int i = 1; i <= n; i++)
		if (i & 1) {
			od.insert({fo[a[i]], a[i]});
		} else {
			ev.insert({fe[a[i]], a[i]});
		}
	if (od.size() == 1) od.insert({0, N});
	if (ev.size() == 1) ev.insert({0, N + 1});
	it = od.end(); it--; x[0] = it -> second; it--; x[1] = it -> second;
	it = ev.end(); it--; y[0] = it -> second; it--; y[1] = it -> second;
	int ans = (int) 1e9;
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 2; j++) {
			if (x[i] == y[j]) continue;
			ans = min(ans, n - fo[x[i]] - fe[y[j]]);
		}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 9984
import numpy as np
from decimal import Decimal
n=int(input())
q=np.zeros((19,19),"i8")
p=0
def f(x,y):
    d=0
    while x%y==0 and d<18:
        x//=y
        d+=1
    return d
for i in range(n):
    a=int(10**9*Decimal(input()))
    s,t=f(a,2),f(a,5)
    p+=q[18-s][18-t]
    q[:s+1,:t+1]+=1
print(p)

Measured memory_bytes: 27248
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

counter = Counter(A)

all_num = 0
for value in counter.values():
    all_num += value * (value - 1) // 2


for a in A:
    value = counter[a]
    before = value * (value - 1) // 2
    after = (value - 1) * (value -2) // 2
    print(all_num + after - before)


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

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

    return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>

int main(void){
    int num,i,q,o,sign=0;
    char map[100][4],line[50];
    for(;scanf("%d\n",&num),num;){
        for(i=0;i<num;i++){
            fgets(map[i],10,stdin);
        }
        scanf("%d\n",&q);
        for(i=0;sign=0,i<q;i++){
            fgets(line,50,stdin);
            for(o=0;o<num;o++)
                if(map[o][0]==line[0]){
                    printf("%c",map[o][2]);
                    sign=1;
                }
            if(sign==0)
                printf("%c",line[0]);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 596
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// b.rs ---
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        a: chars,
        b: chars,
        c: chars,
    };

    let ans = (0..n)
        .map(|i| {
            let (p, q, r) = (a[i], b[i], c[i]);
            let ab = if p != q { 1 } else { 0 };
            let bc = if q != r { 1 } else { 0 };
            let ca = if r != p { 1 } else { 0 };
            min(min(ab + bc, bc + ca), ca + ab)
        })
        .sum::<usize>();

    println!("{}", ans);
}


Measured memory_bytes: 4352
object Main {
  def main (args: Array[String]) {
    for(line <- scala.io.Source.stdin.getLines()){
      val Array(v1,opr,v2) = line.split(" ");
      if (opr == "?")  return
      val val1:Int = v1.toInt
      val val2:Int = v2.toInt
  
      opr match{
        case "+"  =>  println(val1 + val2)
        case "-"  =>  println(val1 - val2)
        case "*"  =>  println(val1 * val2)
        case "/"  =>  println(val1 / val2)
        case _ =>      
      }
    }
  }
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int c = (b - 1) / (a - 1);
	if ((b - 1) % (a - 1) == 0)cout << c << endl;
	else cout << (c + 1) << endl;
}

Measured memory_bytes: 256
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#s[i] is linked with t[len(s)-i-1]
def main():
	n,m = map(int,input().split())
	l,r = 1,n
	for i in range(m):
		t,e = map(int,input().split())
		if(l<t):
			l=t
		if(r>e):
			r=e
	print(0 if r-l+1<0 else r-l+1)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 69332
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main()
	{
		var nm = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var n = nm[0];
		var m = nm[1];

		if (m == 0) {
			if (n == 1) {
				Console.WriteLine(0);
				return;
			} else {
				Console.WriteLine(Math.Pow(10, n - 1));
				return;
			}
		}

		var scs = new Dictionary<int, int>();
		for (var i = 0; i < m; ++i) {
			var sc = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
			if (sc[0] == 1 && sc[1] == 0) {
				if (n == 1) {
					Console.WriteLine(0);
					return;
				} else {
					Console.WriteLine(-1);
					return;
				}
			}

			if (scs.ContainsKey(sc[0])) {
				if (sc[1] != scs[sc[0]]) {
					Console.WriteLine(-1);
					return;
				}
			} else {
				scs.Add(sc[0], sc[1]);
			}
		}

		var min = Math.Pow(10, n - 1);
		var max = Math.Pow(10, n) - 1;
		for (var i = min; i <= max; ++i) {
			var numText = i.ToString();
			var isRight = true;
			foreach (var sc in scs) {
				if (numText.Length < sc.Key) {
					isRight = false;
					break;
				} else if (int.Parse(numText[sc.Key - 1].ToString()) != sc.Value) {
					isRight = false;
					break;
				}
			}

			if (isRight) {
				Console.WriteLine(i);
				return;
			}
		}

		Console.WriteLine(-1);

		//デバッグ実行での確認用。そのまま提出しても問題なし		
		Console.ReadKey();
	}
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  //ll n; cin>>n;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  bool judge = true;

  ll a[4][4];
  for(i=1;i<=3;i++){
    for(j=1;j<=3;j++)cin>>a[i][j];
  }
  vector<ll> p={a[1][1]-a[1][2],a[1][1]-a[1][3]};
  vector<ll> q={a[2][1]-a[2][2],a[2][1]-a[2][3]};
  vector<ll> r={a[3][1]-a[3][2],a[3][1]-a[3][3]};
  judge=p[0]==q[0]&&p[0]==r[0]&&
        p[1]==q[1]&&p[1]==r[1];
  ans1(judge); 
  //cout<<p[0] spa p[1] spa q[0] spa q[1] spa r[0] spa r[1]<<endl;    

  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e10;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    ll a, b, t; cin >> a >> b >> t;
    ll ans = (t / a) * b;
    cout << ans << endl;
    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++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M,K;
    cin >> N>> M >> K;
    string ans="No";
    rep(i,N+1){
        rep(j,M+1){
            if(K==M*i+N*j-2*i*j) ans="Yes";
        }
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <vector>
#include <deque>
using namespace std;

int pl,cn,w,cs;
deque<string> str;
string fie[1001][101];
int main(void){
	while(1){
		scanf("%d%*c",&pl);
		if(pl==0)break;
		scanf("%d%*c",&cn);
		scanf("%d%*c",&w);
		scanf("%d%*c",&cs);
		for(int i=0;i<=1000;i++){
			for(int j=0;j<=100;j++)fie[i][j].clear();
		}
		while(1){
			string str2;
			getline(cin,str2);
			if(str2=="?")break;
			str.push_back(str2);
		}
		int np=0,nn=-1,cnum=0,nx=0;
		while(str.size()){
			string s=str[0];
			str.pop_front();
			nn=np;
			if(s.size()>w){
				string str3=s.substr(w);
				s=s.substr(0,w);
				str.push_front(str3);
			}
			while(s.size()<w)s+='.';
			fie[np][nx]+=s;
			if(cnum+1<cn){
				for(int i=0;i<cs;i++){
					fie[np][nx]+='.';
				}
			}
			nx++;
			if(nx==pl){
				nx=0;
				cnum++;
			}
			if(cnum==cn){
				cnum=0;
				np++;
			}
		}
		for(int i=0;i<=nn;i++){
			for(int j=0;j<pl;j++){
				while(fie[i][j].size()<cn*w+cs*(cn-1))fie[i][j]+='.';
				cout << fie[i][j] << endl;
			}
			cout << "#" << endl;
		}
		cout << "?" << endl;
	}
	return 0;
}

Measured memory_bytes: 2052
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(int i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")




int main() {
	vector<ll> a, b;
	int N;
	cin >> N;
	REP(i, 0, N) {
		ll a_, b_;
		cin >> a_ >> b_;
		a.push_back(a_);
		b.push_back(b_);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (N % 2 == 1) {
		PRI(b[N / 2] - a[N / 2] + 1);
	}
	else {
		PRI((b[N / 2 - 1] + b[N / 2]) - (a[N / 2 - 1] + a[N / 2]) + 1);
	}
	return 0;
}




Measured memory_bytes: 6532
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k)==2)
    {
        if(n%k)
            printf("1\n");
        else
            printf("0\n");
    }
    return 0;
}
/*
4 4
..##
..##
####
####
*/


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

#define rep(i,n) for(int i=0; i<n; i++)
int gcd(int x, int y){
  if(x<y){
    int kari = y;
    y=x;
    x=kari;
  }
  while (y>0){

    int r;
    r = x%y;
    x = y;
    y = r;
    //cout << r << x << y << endl;
  }
  return x;
}

int gcd2(int a, int b, int c){
  int d;
  d = gcd(a,b);
  //out << d << endl;
  return gcd(d,c);
}

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

  int sum = 0;
  for(int a=1; a<=k; a++){
    for(int b=1; b<=k; b++){
      for(int c=1; c<=k; c++){
        sum += gcd2(a,b,c);
      }
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3636
from sys import stdin
INF = 1<<21
WHITE, GRAY, BLACK = 0, 1, 2
n = int(stdin.readline())
M = [[INF] * n for _ in range(n)]
for u in range(0, n):
    U = list(map(int, stdin.readline().split()[2:]))
    for j in range(0, len(U), 2):
        M[u][U[j]] = U[j + 1]
d = [INF] * n
d[0] = 0
color = [WHITE] * n
color[0] = GRAY
def dijkstra():
    global n
    while True:
        minv = INF
        u = -1
        for i in range(0, n):
            if minv > d[i] and color[i] != BLACK:
                u = i
                minv = d[i]
        if u == -1: break
        color[u] = BLACK
        for v in range(0, n):
            if color[v] != BLACK and M[u][v] != INF and d[v] > d[u] + M[u][v]:
                d[v] = d[u] + M[u][v]
                color[v] = GRAY
    for i in range(0, n):
        print(i, (-1 if d[i] == INF else d[i]))
dijkstra()

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int md;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
#if !defined(_WIN32) || defined(_WIN64)
  return (int) ((long long) a * b % md);
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int n, k;

int main() {
  cin >> n >> k >> md;
  if(k % 2 == 0) {
    k /= 2;
    vector<int> dp((n + 1) / 2 + 1);
    dp[0] = 1;
    range(i, 1, (n + 3) / 2) {
      husk(j, i - 1, max(i - k - 2, -1)) {
        add(dp[i], dp[j]);
      }
      if(i <= k) add(dp[i], 1);
    }
    cout << mul(dp[n / 2], dp[(n + 1) / 2]);
    return 0;
  }
  vector<int> p(n + 1);
  p[0] = 1;
  range(i, 1, n + 1) p[i] = mul(p[i - 1], 2);
  vector<vector<int>> dp((n + 1) / 2 + 1, vector<int>(n / 2 + 1));
  range(a, 0, (n + 1) / 2 + 1) {
    range(b, 0, n / 2 + 1) {
      if(2 * a - 2 < k + 1 || 2 * b - 1 < k) {
        dp[a][b] = p[a + b];
        continue;
      }
      dp[a][b] = dp[a - 1][b];
      int sb = 2 * b - 1;
      int sl = k, sr = 2 * a - 2 - k;
      if(sl <= sr) {
        sr = min(sr, sb);
        add(dp[a][b], p[b - (sr - sl) / 2 - 1]);
      } else {
        add(dp[a][b], mul(p[(sl - sr) / 2 + 1] - 1, p[b - 1 - (sl - sr) / 2]));
      }
      range(x, 0, a - 1) {
        int l = 2 * x + 2 + k, r = 2 * a - 2 - k;
        if(l <= r) {
          r = min(r, sb);
          l = min(l, sb + 2);
          int cnt;
          if(l > sb) {
            cnt = 0;
          } else {
            cnt = (sb - r) / 2;
          }
          add(dp[a][b], mul(dp[x][l / 2], p[cnt]));
        } else {
          if(l > sb) {
            add(dp[a][b], dp[x][b]);
            continue;
          }
          int cur = 0;
          for(int y = r; y <= l; y += 2) {
            int res = dp[x][y / 2];
            sub(res, cur);
            cur = mul(cur, 2);
            add(cur, res);
            add(dp[a][b], mul(res, p[(sb - y) / 2]));
          }
        }
      }
    }
  }
  cout << dp[(n + 1) / 2][n / 2] << endl;
  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++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    rep(i,n)cin >> a[i];
    int ans = 0;
    /*ans += n/k;
    if(n % k != 0)ans++;*/
    ans += (n-1)/(k-1);
    if((n-1) % (k-1) != 0)ans++;
    cout << ans << endl;
    return 0;
}

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

int H,W;
char fid[100][100];

int main()
{
    for(int i = 0; i < 100; i++)for(int j = 0; j < 100; j++)fid[i][j] = '.';
    scanf("%d%d",&H,&W);
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            scanf(" %c",&fid[i + 1][j + 1]);
        }
    }

    bool flag = true;
    for(int i = 1; i <= H; i++)
    {
        for(int j = 1; j <= W; j++)
        {
            if(fid[i][j] == '.')continue;
            if(fid[i + 1][j] == '#' || fid[i - 1][j] == '#' || fid[i][j + 1] == '#' || fid[i][j - 1] == '#');
            else flag = false;
        }
    }

    if(flag)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    string s;
	cin>>s;
	if(s[0]=='R' and s[1]=='R' and s[2]=='R')
	{
		cout<<3;
		return 0;
	}
	if(s[1]=='R' and (s[0]=='R'  or s[2]=='R'))
	{
		cout<<2;
		return 0;
	}
	if(s[0]=='S' and s[1]=='S' and s[2]=='S')
	{
		cout<<0;
		return 0;
	}
	cout<<1;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
 
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
 
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
 
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
 
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


vector<vector<int>> G;

void dfs(int v,vector<bool> &visited,int &res ){
  bool end = true;
  rep(i,visited.size()) if(!visited[i] && i != v) end = false;
  if(end){
    res++;
    return;
  }

  visited[v] = true;
  for(auto nv : G[v]){
    if(visited[nv]) continue;
    dfs(nv,visited,res);
  }
  visited[v] = false;
  
}

int main(){
  int N,M;
  cin >> N >> M;
  G.assign(N,vector<int>());
  rep(i,M){
    int a,b;
    cin >> a >> b;a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<bool> visited(N,false);
  int res = 0;
  dfs(0,visited,res);
  cout << res << endl;
}

  
                           

                                                          






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

using namespace std;

int main()
{
    vector <int> S;
    int x, c;
    cin>>x;
    int A[x];
    for(int i=0; i<x; i++)
    {
        cin>>c;
        S.push_back(c);
    }
    sort(S.begin(),S.end());

    cout <<abs(S.front()-S.back())<<endl;
    return 0;
}



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

int b[25];
int main()
{
        int n,m,c,a;
        while(cin>>n>>m>>c)
        {
            for(int i=1;i<=m;i++)
                cin>>b[i];
            int sum=0;
            while(n--)
            {
                int ans=0;
                for(int i=1;i<=m;i++)
                    cin>>a,ans+=a*b[i];
                if(ans+c>0)
                    sum++;
            }
            cout<<sum<<endl;
        }
        return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int
main(int argc, char *argv[])
{
        int debt = 100000;
        int round;
        int n;

        for (scanf("%d", &n); n > 0; n--) {
                debt *= 1.05;
                round = 1000 - debt % 1000;
                if (round != 1000)
                        debt += round;
        }

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

Measured memory_bytes: 592
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n,k;
ll a[300005];
ll ans;
ll op(ll a,ll b){
    return max(a,b);
}
ll e(){
    return 0;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    segtree<ll,op,e> seg(300001);
    seg.set(a[0],1);
    for(int i=1;i<n;i++){
        ll l=max(a[i]-k,0ll);
        ll r=min(a[i]+k,300000ll);
        ll k=seg.prod(l,r+1);
        //cout<<i<<" "<<k+1<<endl;
        seg.set(a[i],k+1);
    }
    for(int i=0;i<300001;i++){
        ans=max(ans,seg.get(i));
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 16164
import sys
input = sys.stdin.readline
import numpy as np

N = int(input())
X = np.array(input().split(), dtype = np.int64)
L = int(input())

U = N.bit_length()
# 各ホテルから、2^n回でどこまで行けるか
next_x = []
next_x.append((np.searchsorted(X, X+L, side = 'right') - 1).tolist())
for i in range(U):
    next_x.append([next_x[i][next_x[i][n]] for n in range(N)])

def days(a,b):
    a -= 1
    b -= 1
    if b < a:
        a,b = b,a
    # 到着できない範囲で最大限進む
    result = 0
    for n in range(U,-1,-1):
        c = next_x[n][a]
        if c < b:
            a = c
            result += 1 << n
    return result + 1

Q = int(input())
for _ in range(Q):
    a,b = map(int,input().split())
    print(days(a,b))


Measured memory_bytes: 31900