akhauriyash/Code-Regression huggingface dataset:
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9 + 7;
const ll MAXN = 2e5+5;
ll modpower(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modpower((x*x)%mod,n/2);
    else
        return (x*modpower((x*x)%mod,(n-1)/2))%mod;

}


void solve(){
	ll n,m,a,b;
	cin >> n >> m >> a >> b;
	if(b==1)
		cout << 1;
	else
		cout << 0;
}

int main() {
	isc;
	solve();
	return 0;
}


Measured memory_bytes: 256
def resolve():
    n, a, b = map(int, input().split())
    if a%2 == b%2: #偶奇が同じだと同じ場所で会える
        print((b-a)//2)
    else:#偶奇が違う→1 or Nで調整する
        print(min(a-1, n-b) + 1 + (b-a-1)//2)
resolve()

Measured memory_bytes: 9084
import heapq
N, K = [int(_) for _ in input().split()]
V = [int(_) for _ in input().split()]
ans = 0
for il in range(K + 1):
    for ir in range(K + 1 - il):
        if il + ir > min([N, K]):
            continue
        H = V[:il] + V[N - ir:N]
        heapq.heapify(H)
        now = 0
        for d in range(1, il + ir):
            if il + ir + d > K:
                break
            v = heapq.heappop(H)
            if v >= 0:
                now += v
                break
        now += sum(H)
        ans = max([ans, now])
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    int count[51] = {};
    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        count[a[i]]++;
        count[b[i]]++;
    }
    for(int i = 1; i <= n; i++) {
        cout << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);
int main(){
    int n;
    cin >> n;
    vector<int> vec(n+1);
    for(int i=1;i<=n;i++){
        for(int j=1;i*j<=n;j++){
            ++vec[i*j];
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=i*vec[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 42272
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int n;
int array[10];

bool dfs(int b,int c,int idx) {
    // cout<<b<<","<<c<<","<<idx<<endl;
    if(idx == 10) return true;

    int tb = array[idx] - b;
    int tc = array[idx] - c;

    if(tb<0 && tc<0) return false;

    bool ret = false;

    if(tb > 0) ret |= dfs(array[idx],c,idx+1);
    if(tc > 0) ret |= dfs(b,array[idx],idx+1);

    return ret;
}

void solve() {
    rep(i,10) cin>>array[i];

    string ans = "NO";
    if(dfs(0,0,0)) ans = "YES";
    cout<<ans<<endl;
}

int main() {
    cin>>n;
    rep(i,n) solve();
    return 0;
}

Measured memory_bytes: 1196
/*huzaifa242 copyright*/
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535897932384626
#define mod 1000000007
#define MAX 3003
int dp[MAX][MAX];
string s,t,ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);  
    #endif
    int i,j;
    ans="";
    cin>>s>>t;
    memset(dp,0,sizeof(dp));
    for(i=1;i<=s.length();i++)
    {
        for(j=1;j<=t.length();j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<"\n";
    }
    i=s.length();
    j=t.length();
    while(j>0 && i>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--;j--;
        }
        else if(dp[i][j-1]==dp[i][j])
        j--;
        else
        i--;
    }
    for(i=ans.length()-1;i>=0;i--)
    cout<<ans[i];
    cout<<'\n';
    return 0;
}

Measured memory_bytes: 35456
#include <stdio.h>
int main(void) {
    int a,b;
    scanf("%d %d",&a,&b);

    if (a<b)
      printf("a < b\n");
    else if (a>b)
      printf("a > b\n");
    else 
      printf("a == b\n");

    return 0;
}

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

using namespace std;

#define llong long long
#define ii pair<int, int>
#define xx first
#define yy second
#define len(s) ((int)s.size())
#define rep(i,n) for (int i = -1; ++i < n; )
#define rep1(i,n) for (int i = 0; ++i <= n; )

#define maxn 201010
int n;
llong a[maxn];

int main() {
  cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n;
  llong sum = 0;
  rep(i, n) {
    cin >> a[i]; 
    sum += a[i];
  }

  llong ts = 0;
  llong ans = 1e18;
  rep(i, n - 1) {
    ts += a[i];
    ans = min(ans, abs(2 * ts - sum));
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,a[500010],top,stk[500010],v[500010];
bool ck(int o){
	int now=a[1];
	top=0;
	FOR(i,2,n){
		if (a[i]>now){now=a[i];continue;}
		while (top && stk[top]>a[i]) --top;
		if (stk[top]!=a[i]) stk[++top]=a[i],v[top]=0;
		++v[top];
		if (v[top]>o-1){
			int t=top;
			while (t && stk[t-1]==stk[t]-1 && v[t]>=o-1) --t;
			if (t<1) return 0;
			if (v[t]>=o-1){
				stk[t]--;
				v[t]=1;
				top=t;
				if (o<2) return 0;
			}
			else{
				++v[t];
				top=t;
			}
		}
		now=a[i];
	}
	return 1;
}
int main(){
	cin>>n;
	FOR(i,1,n) getint(a[i]);
	int l=1,r=n;
	while (l<r){
		int o=l+r>>1;
		if (ck(o)) r=o;
		else l=o+1;
	}
	cout<<r<<endl;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<signed, null_type, less_equal<signed>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//find_by_order();
//order_of_key();
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;


//MODULAR ARITHMATIC
const int mmod = 1000000007;

int add(int a, int b, int m=mmod) {
	return (a%m + b%m)%m;
}

int sub(int a, int b, int m=mmod) {
    return (a%m - b%m + m)%m;
}

int mul(int a, int b, int m=mmod) {
	return ((a%m) * (b%m) % m);
}

int pow(int a, int b, int m=mmod) {
    a %= m;
    int r = 1;
    while (b) {
		if (b&1) r = r*a%m;
		b >>= 1;
		a = a*a%m;
    }
    return r;
}

int inv(int a, int m=mmod) {
	return pow(a, m-2, m);
}

ii norm(int a, int b) {
	int g = __gcd(a, b);
	a /= g, b /= g;
	if (a == 0) b = 1;
	if (b == 0) a = 1;
	if (a < 0) a = -a, b = -b;
	return {a, b};
}

ii inv(ii p) {
	return norm(-p.second, p.first);
}

int pw[200010];

int32_t main() {
	FAST_IO;
	pw[0] = 1;
	for(int i = 1; i < 2e5 + 7; i++)
		pw[i] = pw[i - 1] * 2 % mmod;
		
	int n;
	cin >> n;
	int a[n], b[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	
	int ans = 0;
	map<ii, int> cnt, vis;
	
	for (int i = 0; i < n; i++) {
		if (a[i] == 0 && b[i] == 0) ans++;
		else {
			ii p = norm(a[i], b[i]);
			cnt[p]++;
		}
	}
	int tt = 1;
	for (auto pp: cnt) {
		ii p = pp.first, q = inv(p);
		if (vis[p]) continue;
		tt = tt * (pw[cnt[p]] + pw[cnt[q]] - 1) % mmod;
		vis[p] = vis[q] = 1;
	}
	ans = add(ans, tt);
	ans = sub(ans, 1);
	cout << ans << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 58172
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
    int a,b;
    cin>>a>>b;
    if(a>=1&&a<=9&b>=1&&b<=9)
        cout<<a*b<<endl;
    else
        cout<<-1<<endl;
    
    return 0;
}



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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 500005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long

#define mod  1000000007


int main()
{
	FAST;
	int n; int a, b;
	cin >> n >> a >> b;
	
	for(int i = a; i <= b;  i ++){
		if(i % n == 0 ){
			cout << "OK";
			return 0;
			
		}
	}
	cout << "NG";
}

Measured memory_bytes: 3532
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

const int INF = 1 << 29;
typedef pair<int, int> P;

int n, q;

int nums[300001];
int main(void)
{
	while(cin >> n >> q && n)
	{
		memset(nums, 0, sizeof(nums));
		for (int i = 0; i < n; i++)
		{
			int c; cin >> c;
			nums[c] = c;
		}
		for (int i = 0; i < 300001; i++)
			nums[i] = max(nums[i - 1], nums[i]);

		for (int i = 0; i < q; i++)
		{
			int qj; cin >> qj;
			int ans = 0;
			for (int j = qj - 1; j < 300001; j += qj)
			{
				ans = max(ans, nums[j] % qj);
			}
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2340
#include<iostream>
using namespace std;
int main(){
    int n,m,t;
    int c[21];
    int T[21][100001];
    cin>>n>>m;
    int counter=0;
    for(int k=0;k<m;++k){
        cin>>t;
        c[k]=t;
        if(c[k]>n){
            c[k]=c[k+1];
            counter++;
        }
        for(int j=1;j<=n;++j){
            T[k][0]=0;
            T[0][j]=100000;
        }
    }
    int m1=m-counter;
    for(int i=1;i<=m1;++i){
        for(int j=1;j<=n;++j){
            if(c[i-1]<=j){
                T[i][j]=min(T[i-1][j],T[i][j-c[i-1]]+1);
                }
            else
                T[i][j]=T[i-1][j];
                
        }
    }
    cout<<T[m1][n]<<endl;
}

Measured memory_bytes: 7280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
int main() 
{
  vector<string> key(0);
  std::map<std::string,int> S;
  int N;
  cin >> N;
  string s;
  int criteria=0;
  rep(i, N)
  {
  cin >> s;
    int a = S[s];
   S[s]=a+1;
    if(a+1==1){
    key.push_back(s);
    }
    if(a+1>criteria)
      criteria=a+1;
  }
  sort(ALL(key));
  rep(i, S.size())
  {
    if(S[key[i]]==criteria)
      cout << key[i] << endl;
  }

}

Measured memory_bytes: 26736
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;
int n,m,k;
int cnt[100009];
int p[100009];
vector<int>s[100009];
vector<int>t[100009];

int find(int x){
  if(x==p[x])return x;
  return p[x]=find(p[x]);
}

int same(int x,int y){
  if(find(x)==find(y))return 1;
  else return 0;
}

void unite(int x,int y){
  x=find(x);
  y=find(y);
  p[x]=y;
  cnt[y]+=cnt[x];
}

int main(){
  cin>>n>>m>>k;
  for(int i=0;i<=n;i++){
    p[i]=i;
    cnt[i]=1;
  }
  rep(i,m){
    int a,b;
    cin>>a>>b;
    if(!same(a,b)){
      unite(a,b);
    }
    s[a].push_back(b);
    s[b].push_back(a);
  }
  rep(i,k){
    int a,b;
    cin>>a>>b;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  for(int i=1;i<=n;i++){
    int p=find(i);
    int ans=cnt[p]-(int)s[i].size()-1;
    rep(j,t[i].size()){
      if(same(i,t[i][j]))ans--;
    }
    cout<<ans;
    if(i==n)cout<<endl;
    else cout<<' ';
  }
  return(0);
}



Measured memory_bytes: 13176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    ll n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) {
    cin >> v[i];
    }
    sort(v.begin(),v.end());
    cout << v[v.size()-1]-v[0] << endl;
}



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

const int MAXN = 3.1e5;
const int MAXM = 1.1e5;
const int S = 1 << 17;

int seg[S * 2];

void update(int i) {
	for (int a = i+S; a; a /= 2) {
		seg[a]++;
	}
}

int query(int l, int r) {
	int ans = 0;
	for (int a = l+S, b = r+S; a < b; a /= 2, b /= 2) {
		if (a & 1) {
			ans += seg[a++];
		}
		if (b & 1) {
			ans += seg[--b];
		}
	}
	return ans;
}

int N, M;
vector<int> facs[MAXM];
vector<int> rights[MAXM];
int ans[MAXM];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		int l, r; cin >> l >> r;
		rights[l].push_back(r);
	}
	for (int d = 1; d <= M; d++) {
		for (int v = d; v <= M; v += d) {
			facs[v].push_back(d);
		}
	}
	for (int v = 1; v <= M; v++) {
		for (int r : rights[v]) {
			update(r);
		}
		for (int d : facs[v]) {
			ans[d] += query(v, min(M+1, v+d));
		}
	}
	for (int d = 1; d <= M; d++) {
		cout << ans[d] << '\n';
	}

	return 0;
}


Measured memory_bytes: 18048
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define vi vector<int>
#define pb push_back
#define p push
#define sll stack<long long>
#define qll queue<long long>
#define vll vector<long long>
#define vvll vector<vector<ll>>
#define mll map<ll,ll>
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define fork(n) for(int k=0;k<n;k++)
#define fori1(n) for(int i=1;i<=n;i++)
#define f(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define pi 3.14159265358979323
#include <math.h>
#define yn(n) if(n)cout<<"yes\n";else cout<<"no\n";
#define Yn(n) if(n)cout<<"Yes\n";else cout<<"No\n";
#define YN(n) if(n)cout<<"YES\n";else cout<<"NO\n";
#define mp   macke_pair 
#define MOD 1000000007
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
int md(int n){
	if(n>0)return n;
	else return -n;
}
void solve(){
	ll sum=0;string str;cin>>str;
	fori(str.length()){
	    sum+=str[i]-'0';
	    sum=sum%9;
	}
	if(sum%9)cout<<"No";
	else cout<<"Yes";
}


int main(){

 
    	
	int t;
	t=1;
	//cin >> t;
	while(t--){
		solve();
		
	}
	
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll a[3][3], n;
	zep(i, 0, 3){
		zep(j, 0, 3){
			cin >> a[i][j];
		}
	}
	cin >> n;
	ll b[n];
	zep(i, 0, n){
		cin >> b[i];
	
		zep(j, 0, 3){
			zep(k, 0, 3){
				if(a[j][k] == b[i]){
					a[j][k] = 0;
				}
			}
		}
	}
	
	bool ans = false;
	zep(i, 0, 3){
		if(a[i][0]+a[i][1]+a[i][2] == 0){
			ans = true;
		}
	}
	zep(j, 0, 3){
		if(a[0][j]+a[1][j]+a[2][j] == 0){
			ans = true;
		}
	}
	if(a[0][0]+a[1][1]+a[2][2] == 0){
		ans = true;
	}
	if(a[0][2]+a[1][1]+a[2][0] == 0){
		ans = true;
	}
	print((ans)? "Yes" : "No")
	return 0;
}

Measured memory_bytes: 256
A,B,M = map(int, input().split())

a=list(map(int, input().split()))
b=list(map(int, input().split()))
dis=[list(map(int,input().split()))  for l in range(M)]

comp1=a[dis[0][0]-1]+b[dis[0][1]-1]-dis[0][2]
for l in range(M):
    y=a[dis[l][0]-1]+b[(dis[l][1])-1]-dis[l][2]
    if comp1>y:
        comp1=y

comp2=min(a)+min(b)
                  
print(min(comp1,comp2))

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    cout << n*n << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int N,cnt = 0;
    string S,T;
    cin >> N >> S;
    for(int i = 0;i < N;i++){
        cin >> T;
        int c = 2;
        for(int j = 0;j < T.length();j++){
            if(S[0] != T[j])continue;
            for(int k = j+1;k < T.length();k++){
                if(S[1] != T[k])continue;
                for(int l = 1;l <= S.length()-2;l++){
                    if(k + (k-j)*l >= T.length())break;
                    if(S[l+1] == T[k + (k-j)*l])c++;
                }
                if(c/S.length())goto next;
                c = 2;
            }
        }
        next:if(c/S.length())cnt++;
    }
    cout << cnt << endl;
} 

Measured memory_bytes: 3196
n=int(input())
s=[]
for i in range(n):
    s_=input()
    s.append(s_)
# print(s)

import collections
c = collections.Counter(s)
print("AC x "+str(c["AC"]))
print("WA x "+str(c["WA"]))
print("TLE x "+str(c["TLE"]))
print("RE x "+str(c["RE"]))


Measured memory_bytes: 16532
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a;
	cin>>n>>a;
	n %= 500;
	if(a>=n) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

a =  (input().split())
b = [1, 1]
b[0] = int(a[0])
b[1] = int(a[1])
print(lcm(b)) 

Measured memory_bytes: 5096
n = int(input())
a = list(map(int, input().split()))
q = int(input())

bckt = [0]*(int(1e5)+1)
for i in a:
    bckt[i] += 1
    
s = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    q = bckt[b]
    bckt[c] += q
    bckt[b] -= q
    s += (c*q - b*q)
    print(s)
    

Measured memory_bytes: 84628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll INF = LLONG_MAX/3;

int main(){
    int sz[2];
    rep(i,2) cin >>sz[i];

    int q;
    cin >>q;

    vector<ll> v[2];
    rep(i,2){
        v[i] = vector<ll>(sz[i]);
        rep(j,sz[i]) cin >>v[i][j];
    }

    vector<ll> x(q);
    rep(i,q) cin >>x[i];

    auto G = [&](int vid, ll p){
        int idx = lower_bound(all(v[vid]),p) - v[vid].begin();
        ll ret = INF;
        for(int i=-1; i<=1; ++i){
            int j = idx+i;
            if(0<=j && j<sz[vid]) ret = min(ret, abs(p-v[vid][j]));
        }
        return ret;
    };

    auto F = [&](int vid, ll p){
        int idx = lower_bound(all(v[vid]),p) - v[vid].begin();
        ll ret = INF;
        for(int i=-1; i<=1; ++i){
            int j = idx+i;
            if(0<=j && j<sz[vid]){
                ll np = v[vid][j];
                ret = min(ret, abs(p-np)+G(!vid,np));
            }
        }
        return ret;
    };

    for(ll z:x){
        ll ans = INF;
        rep(j,2) ans = min(ans, F(j,z));
        cout << ans << "\n";
    }
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n, m;
	cin >> n >> m;
	int r=max(n,m);
	double ans=(double)4*M_PI*r*r*r/3;
	printf("%.10lf", ans);
	return 0;
}


Measured memory_bytes: 3204
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
S = []
N.times do |i|
  S[i] = gets.chomp
end

hash = Hash.new(0)

S.each do |s|
  hash[s] += 1
end

%w[AC WA TLE RE].each do |w|
  puts "#{w} x #{hash[w]}"
end


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef vector<ll> vll;

signed main() {
    int N, M;
    while (cin >> N >> M && N) {
        vi P(N + 1);
        rep(i, N) cin >> P[i];
        P[N] = 0;

        vi a;
        rep(i, N + 1) rep(j, i + 1) {
            if (P[i] + P[j] <= M) a.emplace_back(P[i] + P[j]);
        }

        sort(all(a));

        int ma = 0;
        int l = 0;
        int r = a.size() - 1;
        while (l <= r) {
            while (a[l] + a[r] > M) r--;
            ma = max(ma, a[l] + a[r]);
            l++;
        }

        cout << ma << endl;
    }
}

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

data=get_nsp.map(&:to_i)
ans=["+","+","+"]
(1<<3).times do|bit|
  val=data[0]
  3.times do|i|
    unless (bit&(1<<i)).zero?
      ans[i]="+"
      val+=data[i+1]
    else
      ans[i]="-"
      val-=data[i+1]
    end
  end 
  break if val==7
end
ans_s=""
3.times do|i|
  ans_s+=data[i].to_s
  ans_s+=ans[i]  
end
puts ans_s+data[3].to_s+"=7"

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

int main(int argc, char *argv[])
{
    int H, N;
    cin >> H >> N;
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        long v;
        cin >> v;
        sum += v;
    }
    if (sum >= H) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,i,j,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)
#define itr(x,n) for(x=0;x<n;x++)
#define itrab(x,a,b) for(x=a;x<b;x++)
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn
#define size(x) (ll)x.size()
#define pi 3.14159265359
#define dTor(x) ((x)*pi)/180.0
#define INF 1000000100;

typedef long long int ll;       //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;          //COMMON MODULO PRIMES
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff>b.ff);
    else
        return (a.ss>b.ss);
}
vector<bool> pr(1000000+1,1);
void sieve(ll mn, ll mx){       //SIEVE OF ERATOSTHENES
    for(ll i=mn;i*i<=mx;i++)
        if(pr[i-mn]==1)
            for(ll j=i*i;j<=mx;j+=i)
                pr[j-mn]=0;
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    standardVar;
    cin>>n>>m;
    ll y=m-2*n;
    if(y%2==0&&y/2>=0&&n-y/2>=0)
        cout<<"Yes" nn;
    else
        cout<<"No" nn;
    return 0;
}

Measured memory_bytes: 3728
S = input()
ans = [0, 0, 0, 0]

for i in range(len(S)):
    if (i % 2 == 0 and S[i] != '1') or (i % 2 == 1 and S[i] != '0'):
        ans[0] += 1
    if (i % 2 == 0 and S[i] != '0') or (i % 2 == 1 and S[i] != '1'):
        ans[1] += 1
    j = len(S) - i - 1
    if (j % 2 == 0 and S[j] != '1') or (j % 2 == 1 and S[j] != '0'):
        ans[2] += 1
    if (j % 2 == 0 and S[j] != '0') or (j % 2 == 1 and S[j] != '1'):
        ans[3] += 1
    
print(min(ans))





Measured memory_bytes: 3188
A,B=map(int,input().split())
pairs=(B-A+1)//2
if A%2==1 and B%2==1:
    print(A^1 if pairs%2==1 else A)
if A%2==1 and B%2==0:
    print(A^B^1 if (pairs-1)%2==1 else A^B)
if A%2==0 and B%2==1:
    print(1 if pairs%2==1 else 0)
if A%2==0 and B%2==0:
    print(B^1 if pairs%2==1 else B)

Measured memory_bytes: 3064
A, B = map(int, input().split())
S = input()
NUMS = "0123456789"
flg = True
for i in range(A):
  flg *= (S[i] in NUMS)
flg *= (S[A] == '-')
for i in range(A, A+B):
  flg *= (S[i+1] in NUMS)
if flg:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
 
H, W = MAP()
s = [input() for _ in range(H)]

dy = (1, 0, -1, 0)
dx = (0, -1, 0, 1)

for x in range(W):
	for y in range(H):
		if s[y][x] =="#":
			for i in range(4):
				ny = y + dy[i]
				nx = x + dx[i]
				if 0 <= ny < H and 0 <= nx < W and s[ny][nx] == "#":
					break
			else:
				print("No")
				exit()

print("Yes")



Measured memory_bytes: 5256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define nl '\n'
using namespace std;
using ll = long long;
using ld = long double;
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



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

  int a, b;
  cin >> a >> b;
  int n = 100;

  char x[101][102];
  for(int i=1; i<=n; i++) {
    for(int j=1; j<=n; j++) {
      if(i<=n/2)
	x[i][j] = '#';
      else
	x[i][j] = '.';
    }
    x[i][101] = 0;
  }

  a--, b--;
  for(int i=1; i<=n/2 and a>0; i+=2)
    for(int j=1; j<=n and a>0; j+=2) {
      x[i][j] = '.';
      a--;
    }

  for(int i=n/2+1; i<=n and b>0; i+=2)
    for(int j=1; j<=n and b>0; j+=2) {
      x[i+1][j] = '#';
      b--;
    }

  cout << n << ' ' << n << nl;
  for(int i=1; i<=n; i++)
    cout << 1+x[i] << nl;

  return 0;
}

/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


Measured memory_bytes: 256
q = int(input())
l, r = [0] * q, [0] * q
for i in range(q):
    l[i], r[i] = map(int, input().split())

MAX = 100010
is_prime = [True] * MAX
is_prime[0] = False
is_prime[1] = False
for i in range(2, MAX):
    if is_prime[i]:
        j = i * 2
        while j < MAX:
            is_prime[j] = False
            j += i
        

acc = [0] * (max(r) + 2)
for i in range(1, max(r) + 1):
    if is_prime[i] and is_prime[(i + 1) // 2]:
        acc[i] = acc[i - 1] + 1
    else:
        acc[i] = acc[i - 1]

ans = 0
for i in range(q):
    print(acc[r[i]] - acc[l[i] - 1])

Measured memory_bytes: 13344
n = int(input())
a = [0] * (n + 1)

for x in range(1, 10**2 + 1):
    for y in range(1, 10**2 + 1):
        for z in range(1, 10**2 + 1):
            tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if tmp <= n:
                a[tmp] += 1
for i in range(1, n + 1):
    print(a[i])

Measured memory_bytes: 69112
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n;
char buf[310][310];
int ans;
const long long p=100000000007LL;
long long hsh1[310][310];
long long pw[310];
long long hsh2[310][310];
long long gthsh1(int i,int l,int r)
{
	if(l>r)return 0;
	return hsh1[i][r]-hsh1[i][l-1]*pw[r-l+1];
}
long long gthsh2(int j,int l,int r)
{
	if(l>r)return 0;
	return hsh2[j][r]-hsh2[j][l-1]*pw[r-l+1];
}
int main()
{
	scanf("%d",&n);
	pw[0]=1;
	for(int i=1;i<=n;i++)pw[i]=pw[i-1]*p;
	for(int i=0;i<n;i++)
	{
		scanf("%s",buf[i]);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			hsh1[i+1][j+1]=hsh1[i+1][j]*p+buf[i][j];
		}
	}
	for(int j=0;j<n;j++)
	{
		for(int i=0;i<n;i++)hsh2[j+1][i+1]=hsh2[j+1][i]*p+buf[i][j];
	}
	for(int a=0;a<n;a++)
	{
		for(int b=0;b<n;b++)
		{
			bool f=true;
			int x=a+1,y=b+1;
			do
			{
				if(gthsh1(x,y,n)*pw[y-1]+gthsh1(x,1,y-1)!=gthsh2(y,x,n)*pw[x-1]+gthsh2(y,1,x-1))f=false;
				x++;
				y++;
				if(x>n)x-=n;
				if(y>n)y-=n;
			}
			while(f && x!=a+1);
			if(f)ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) printf("%lld\n", num)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
#define BLACK 0
#define WHITE 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    ll N, X;
    cin >> N >> X;
    ll i;
    ll l[60], b[60], p[60];
    ll ans=0;
    
    l[0]=1;
    b[0]=0;
    p[0]=1;
    for(i=1; i<=50; i++) {
        l[i]=2*l[i-1]+3;
        b[i]=2*b[i-1]+2;
        p[i]=2*p[i-1]+1;
    }
    
    ll len=l[N];
    i=N;
    while(i>=0) {
        if(X<=len/2) {
            len-=3;
            len/=2;
            X--;
            i--;
        }else {
            if(i==0) {
                ans++;
            }else {
                ans+=p[i-1]+1;
            }
            
            len-=3;
            len/=2;
            X-=2;
            X-=l[i-1];
            i--;
        }
    }
    
    pr(ans);
    
}

Measured memory_bytes: 256
N = int(input())
H = []
for i in range(N):
  A,B = map(int,input().split())
  H.append([A+B,[A,B]])
H.sort(reverse=True)
#print(H)
ans = 0
factor = 1
for i in range(N):
  ans += H[i][1][i%2] * factor
  factor *= -1
print(ans)

Measured memory_bytes: 69848
import heapq
h, w = map(int, input().split())
graph = [list(map(int, input().split())) for _ in range(10)]

trans_graph = list(zip(*graph))
next_nodes = []
for idx, d in enumerate(trans_graph[1]):
    next_nodes.append((d, idx))

heapq.heapify(next_nodes)

INF = 10**9
decided = [0]*10
decided[1] = 1
dist = [INF]*10
dist[1] = 0
while 0 in decided:
    distance, v = heapq.heappop(next_nodes)
    if decided[v]:
        continue
    decided[v] = 1
    dist[v] = distance
    for v2, x in enumerate(trans_graph[v]):
        if decided[v2]:
            continue
        heapq.heappush(next_nodes, (dist[v]+x, v2))

ans = 0
for _ in range(h):
    for x in map(int, input().split()):
        if x == -1:
            continue
        ans += dist[x]

print(ans)

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

using namespace std;

namespace ARC096C
{
ll a, b, c, x, y, ans, tmp, tmp2;
inline void solve()
{
	while(~scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y))
	{
    	tmp = min(x, y), tmp2 = max(x, y);
    	ans = x * a + y * b;
    	ans = min(ans, (c << 1) * tmp + (x - tmp) * a + (y - tmp) * b);
    	ans = min(ans, (c << 1) * tmp2);
    	printf("%lld", ans), ans = 0;
	}
}
}

int main()
{
    return ARC096C::solve(), 0;
}

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

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)
#define mem(x, val)    memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string str;
typedef pair<int, int> pii;


vector<int> v;
int dp[(int)1e5];
int n;
int jump(int i){
    if(i==n-1) return 0;
    if(i>=n) return 1e9;

    int &ret = dp[i];

    if(~ret) return ret;

    int cnt = 0;
    if(i+1<n) cnt = abs(v[i] - v[i+1]) + jump(i+1);
    if(i+2<n) cnt = min(cnt, abs(v[i] - v[i+2]) + jump(i+2));

    return ret = cnt;
}
int main()
{
    THINK_TWICE_CODE_ONCE
    //freopen("test cases\\.txt", "r", stdin) ;
    cin>>n;
    v.resize(n);
    for(int &i: v) cin>>i;
    mem(dp, -1);
    cout<<jump(0);
    return 0;
}






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

int dp[300][300][302];
void chmax(int& a, int b){
    a = max(a, b);
}

int main(){
    string S;
    int K;
    cin >> S >> K;
    int N = S.size();

    for(int i=0; i<N; i++) dp[i][i][0] = 1;
    for(int i=0; i<N-1; i++){
        if(S[i] == S[i+1]){
            dp[i][i+1][0] = 2;
        }else{
            dp[i][i+1][0] = 1;
            dp[i][i+1][1] = 2; 
        }
    }
    for(int d=2; d<N; d++){
        for(int i=0; i+d<N; i++){
            for(int k=0; k<=K; k++){
                chmax(dp[i][i+d][k], max(dp[i][i+d-1][k], dp[i+1][i+d][k]));
                chmax(dp[i][i+d][k + (S[i] != S[i+d])], dp[i+1][i+d-1][k] + 2);
            }
        }
    }
    int ans = 0;
    for(int k=0; k<=K; k++) chmax(ans, dp[0][N-1][k]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 104704
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=1;i<=n;i++)
#define ld long double
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
vi con[200005];
int n,m;
inline bool dfs(int v,int s){
	if (n==v&&s==2) return 1;
	if (s>1) return 0;
	bool res=0;
	for (int i=0;i<con[v].size();i++){
		res|=dfs(con[v][i],s+1);
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for (int i=1;i<=m;i++){
		int x,y;
		cin>>x>>y;
		con[x].pb(y);
		con[y].pb(x);
	}
	if (dfs(1,0)) cout<<"POSSIBLE";
	else cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 12016
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int arr[505][505];
struct nod
{
	int x1,y1,x2,y2;
}ans[250005];
int main()
{
    IOS
    int n,m,cnt = 0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>arr[i][j];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(arr[i][j]%2)
            {
                ans[cnt++] = (nod){i,j,i,j+1};
                arr[i][j+1]++;
            }
        }
    }
    for(int i=1;i<n;i++)
    {
        if(arr[i][m]%2)
        {
            ans[cnt++] = (nod){i,m,i+1,m};
            arr[i+1][m]++;
        }
    }
    cout<<cnt<<endl;
    for(int i=0;i<cnt;i++)
    {
        cout<<ans[i].x1<<" "<<ans[i].y1<<" "<<ans[i].x2<<" "<<ans[i].y2<<endl;
    }
    return 0;
}

Measured memory_bytes: 7040
N = int(input())
A = list(map(int, input().split()))

flag = True
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 != 0 and A[i] % 5 != 0:
            flag = False
            
if flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

const long long MOD = 1000000007;
const int MAX = 100001;

int N, K;
vector<int> G[MAX];
int flag[MAX]; 

long long ans;
long long fac[MAX], facinv[MAX], inv[MAX];

void facinit(){
    fac[0] = fac[1] = 1;
    facinv[0] = facinv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        facinv[i] = facinv[i - 1] * inv[i] % MOD;
    }
    
}

long long Perm(long long a, long long b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;

    return fac[a] * facinv[a - b] % MOD;
}

void dfs(int x){ 
    int p = G[x].size();
    if (x != 1 && p == 1) return; 

    if (x == 1) ans *= Perm(K - 1, p);
    else ans *= Perm(K - 2, p - 1);
    ans %= MOD;
    flag[x] = 1;

    for (auto& y : G[x]){
        if (flag[y] == 1) continue;
        else dfs(y);
    }
}

int main(){
    facinit();

    cin >> N >> K;
    for (int i = 0; i < N - 1; i++){
        int a, b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ans = K;
    dfs(1);
    cout << ans << endl;
}

Measured memory_bytes: 10752
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int dsum(long long n) {
  int res = 0;
  while (n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

int main() {
  long long K;
  cin >> K;
  long long x = 1;
  long long p = 1;
  while (K > 0) {
    cout << x << endl;
    K--;
    if (K < 0) break;
    long long nx1 = x + p;
    long long nx2 = x + p * 10;
    if (nx1 * dsum(nx2) <= nx2 * dsum(nx1)) {
      x = nx1;
    } else {
      x = nx2;
      p *= 10;
    }
  }
}

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

int  main()
{
	string s; cin >> s;
	string ans = "Yes\n";
	rep(i, s.size())
	{
		if (i%2 && s[i] == 'R')
		{
			ans = "No\n";
			break;
		}
		if (i % 2 == 0 && s[i] == 'L')
		{
			ans = "No\n";
			break ;
		}
	}
	cout << ans;
	return (0);
}


Measured memory_bytes: 384
a,b,c,d=gets.split
n=gets.to_i
a=a.to_i
b=b.to_i
c=c.to_i
d=d.to_i
arr=[a,b,c,d]
arr2=[8*a,4*b,2*c,d].sort

if arr2[0]==8*a
    puts n*4*a
elsif arr2[0]==4*b
    puts n*2*b
    
elsif  arr2[0]==2*c
 puts n*c
 
 elsif  arr2[1]==8*a
  puts (n/2)*d+4*a*(n%2)
  
  elsif  arr2[1]==4*b
  puts (n/2)*d+2*b*(n%2)
  
  elsif  arr2[1]==2*c
  puts (n/2)*d+c*(n%2)
  
  
  end
 

Measured memory_bytes: 1788
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

a,b,c = map(int, input().split())

ans = c - (a-b)

if (ans < 0):
    print(0)
else:
    print(ans)


Measured memory_bytes: 9140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    while(true){
        int N,M; cin >> N >> M;
        if(N==0 && M==0) break;
        int A[N]; rep(i,N) cin >> A[i];
        int ans=0;
        rep(i,N){
            rng(j,i+1,N){
                if(A[i]+A[j]<=M){
                    chmax(ans,A[i]+A[j]);
                }
            }
        }
        if(ans==0) cout << "NONE" << "\n";
        else cout << ans << "\n";
    }
}


Measured memory_bytes: 3148
def binary(N, LIST, num):  # 二分探索 # N:探索要素数
    l, r = -1, N
    while r - l > 1:
        if LIST[(l + r) // 2] > num:  # 条件式を代入
            r = (l + r) // 2
        else:
            l = (l + r) // 2
    return r + 1


n, d, a = map(int, input().split())
xh = sorted(list(map(int, input().split())) for _ in range(n))
x = [i for i, j in xh]
h = [j for i, j in xh]

bomb, bsum, ans = [0] * (n + 1), [0] * (n + 1), 0
for i in range(n):
    j = binary(n, x, x[i] + 2 * d) - 1
    bsum[i] += bsum[i - 1] + bomb[i]
    bnum = max((h[i] + a - 1) // a - bsum[i], 0)
    bomb[i] += bnum
    bomb[j] -= bnum
    bsum[i] += bnum
    ans += bnum
print(ans)


Measured memory_bytes: 63664
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
const int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};

bool in_range(int a, int b){
  return a >= 0 && a < b;
}

int main(){
  int H, W;
  cin >> H >> W;
  vector< vector<int> > A(H, vector<int>(W));
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      cin >> A[i][j];
    }
  }
  int N = 0;
  vector<int> Y_, X_, Y, X;
  for(int i = 0; i < H; ++i){
    if(i%2){
      for(int j = W-1; j >= 0; --j){
        if(i == H-1 && j == 0) continue;
        int x_ = j, y_ = i;
        if(j > 0) --x_;
        else ++y_;
        if(A[i][j]%2){
          Y.push_back(i+1);
          X.push_back(j+1);
          Y_.push_back(y_+1);
          X_.push_back(x_+1);
          ++N;
          --A[i][j];
          ++A[y_][x_];
        }
      }
    }else{
      for(int j = 0; j < W; ++j){
        if(i == H-1 && j == W-1) continue;
        int x_ = j, y_ = i;
        if(j < W-1) ++x_;
        else ++y_;
        if(A[i][j]%2){
          Y.push_back(i+1);
          X.push_back(j+1);
          Y_.push_back(y_+1);
          X_.push_back(x_+1);
          ++N;
          --A[i][j];
          ++A[y_][x_];
        }
      }
    }
  }
  cout << N << endl;
  for(int i = 0; i < N; ++i){
    //cout << Y[i] << " " << X[i] << " " << Y_[i] << " " << X_[i] << endl;
    printf("%d %d %d %d\n",Y[i],X[i],Y_[i],X_[i]);
  }
  return 0;
}


Measured memory_bytes: 5224
#include<iostream>
#include<cstdio>
#define lon long long
using namespace std;
lon n,p;
lon a[110]={1,682498929,491101308,76479948,723816384,67347853,27368307,
625544428,199888908,888050723,927880474,281863274,661224977,623534362,
970055531,261384175,195888993,66404266,547665832,109838563,933245637,
724691727,368925948,268838846,136026497,112390913,135498044,217544623,
419363534,500780548,668123525,128487469,30977140,522049725,309058615,
386027524,189239124,148528617,940567523,917084264,429277690,996164327,
358655417,568392357,780072518,462639908,275105629,909210595,99199382,
703397904,733333339,97830135,608823837,256141983,141827977,696628828,
637939935,811575797,848924691,131772368,724464507,272814771,326159309,
456152084,903466878,92255682,769795511,373745190,606241871,825871994,
957939114,435887178,852304035,663307737,375297772,217598709,624148346,
671734977,624500515,748510389,203191898,423951674,629786193,672850561,
814362881,823845496,116667533,256473217,627655552,245795606,586445753,
172114298,193781724,778983779,83868974,315103615,965785236,492741665,
377329025,847549272,698611116};
int main()
{
    p=1000000007;
    cin>>n;
    if(n>=p)
    {
        cout<<0;
        return 0;
    }
    if(p==1000000007)
    {
        lon now=n/10000000;
        lon ans=a[now];
        for(lon i=now*10000000+1;i<=n;i++)
        ans=ans*i%p;
        cout<<ans%p;
        return 0;
    }
    lon ans=1;
    for(int i=1;i<=n;i++)
    ans=ans*i%p;
    cout<<ans%p;
    return 0;
}


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

int main(int argc, char *argv[])
{
    int a, b;
    char op;
    while (1)
    {
        cin >> a >> op >> b;
        if (op == '?')
            break;
        switch (op)
        {
        case '+':
            cout << a + b << endl;
            break;
        case '-':
            cout << a - b << endl;
            break;
        case '*':
            cout << a * b << endl;
            break;
        case '/':
            cout << a / b << endl;
            break;
        default:
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3124